提交 5c495f82 编写于 作者: R roo00

增加动态表

上级 9ad6cc4d
......@@ -93,8 +93,8 @@ public class Business {
public boolean editable(EffectivePerson effectivePerson, Query o) throws Exception {
boolean result = false;
if (effectivePerson.isManager()
|| (this.organization().person().hasRole(effectivePerson, OrganizationDefinition.QueryManager))) {
if (effectivePerson.isManager() || (this.organization().person().hasRole(effectivePerson,
OrganizationDefinition.Manager, OrganizationDefinition.QueryManager))) {
result = true;
}
if (!result && (null != o)) {
......@@ -113,7 +113,7 @@ public class Business {
}
if (!result) {
if (effectivePerson.isManager() || (this.organization().person().hasRole(effectivePerson,
OrganizationDefinition.QueryManager))) {
OrganizationDefinition.Manager, OrganizationDefinition.QueryManager))) {
result = true;
}
if (!result) {
......@@ -138,18 +138,24 @@ public class Business {
public boolean editable(EffectivePerson effectivePerson, Table o) throws Exception {
boolean result = false;
if (effectivePerson.isManager()
|| (this.organization().person().hasRole(effectivePerson, OrganizationDefinition.QueryManager))) {
if (effectivePerson.isManager() || (this.organization().person().hasRole(effectivePerson,
OrganizationDefinition.Manager, OrganizationDefinition.QueryManager))) {
result = true;
}
if (!result && (null != o)) {
if (effectivePerson.isUser(o.getEditPersonList())) {
if (ListTools.isEmpty(o.getEditPersonList()) && ListTools.isEmpty(o.getEditUnitList())) {
result = true;
}
if (!result && ListTools.isNotEmpty(o.getEditUnitList())) {
List<String> units = this.organization().unit().listWithPerson(effectivePerson.getDistinguishedName());
if (ListTools.containsAny(units, o.getEditUnitList())) {
result = true;
if (!result) {
if (effectivePerson.isUser(o.getEditPersonList())) {
result = true;
}
if (!result && ListTools.isNotEmpty(o.getEditUnitList())) {
List<String> units = this.organization().unit()
.listWithPerson(effectivePerson.getDistinguishedName());
if (ListTools.containsAny(units, o.getEditUnitList())) {
result = true;
}
}
}
}
}
......@@ -164,7 +170,8 @@ public class Business {
}
if (!result) {
if (effectivePerson.isManager()
|| (this.organization().person().hasRole(effectivePerson, OrganizationDefinition.QueryManager))
|| (this.organization().person().hasRole(effectivePerson, OrganizationDefinition.Manager,
OrganizationDefinition.QueryManager))
|| effectivePerson.isUser(o.getExecutePersonList())) {
result = true;
}
......
......@@ -17,32 +17,30 @@ public class DynamicEntity extends GsonPropertyObject {
private String name;
private List<StringField> stringFields;
private List<IntegerField> integerFields;
private List<LongField> longFields;
private List<DoubleField> doubleFields;
private List<BooleanField> booleanFields;
private List<DateField> dateFields;
private List<TimeField> timeFields;
private List<DateTimeField> dateTimeFields;
private List<StringField> listStringFields;
private List<IntegerField> listIntegerFields;
private List<LongField> listLongFields;
private List<DoubleField> listDoubleFields;
private List<BooleanField> listBooleanFields;
private List<DateField> listDateFields;
private List<TimeField> listTimeFields;
private List<DateTimeField> listDateTimeFields;
private List<StringLobField> stringLobFields;
private List<StringMapField> stringMapFields;
private List<StringField> stringFieldList;
private List<IntegerField> integerFieldList;
private List<LongField> longFieldList;
private List<DoubleField> doubleFieldList;
private List<BooleanField> booleanFieldList;
private List<DateField> dateFieldList;
private List<TimeField> timeFieldList;
private List<DateTimeField> dateTimeFieldList;
private List<StringField> listStringFieldList;
private List<IntegerField> listIntegerFieldList;
private List<LongField> listLongFieldList;
private List<DoubleField> listDoubleFieldList;
private List<BooleanField> listBooleanFieldList;
private List<DateTimeField> listDateTimeFieldList;
private List<StringLobField> stringLobFieldList;
private List<StringMapField> stringMapFieldList;
public void addStringField(String name, String description) {
StringField field = new StringField();
field.setName(name);
field.setDescription(description);
this.stringFields.add(field);
this.stringFieldList.add(field);
}
public String tableName() throws Exception {
......@@ -71,26 +69,24 @@ public class DynamicEntity extends GsonPropertyObject {
}
public DynamicEntity() {
this.stringFields = new ArrayList<>();
this.integerFields = new ArrayList<>();
this.longFields = new ArrayList<>();
this.doubleFields = new ArrayList<>();
this.booleanFields = new ArrayList<>();
this.dateFields = new ArrayList<>();
this.timeFields = new ArrayList<>();
this.dateTimeFields = new ArrayList<>();
this.listStringFields = new ArrayList<>();
this.listIntegerFields = new ArrayList<>();
this.listLongFields = new ArrayList<>();
this.listDoubleFields = new ArrayList<>();
this.listBooleanFields = new ArrayList<>();
this.listDateFields = new ArrayList<>();
this.listTimeFields = new ArrayList<>();
this.listDateTimeFields = new ArrayList<>();
this.stringLobFields = new ArrayList<>();
this.stringMapFields = new ArrayList<>();
this.stringFieldList = new ArrayList<>();
this.integerFieldList = new ArrayList<>();
this.longFieldList = new ArrayList<>();
this.doubleFieldList = new ArrayList<>();
this.booleanFieldList = new ArrayList<>();
this.dateFieldList = new ArrayList<>();
this.timeFieldList = new ArrayList<>();
this.dateTimeFieldList = new ArrayList<>();
this.listStringFieldList = new ArrayList<>();
this.listIntegerFieldList = new ArrayList<>();
this.listLongFieldList = new ArrayList<>();
this.listDoubleFieldList = new ArrayList<>();
this.listBooleanFieldList = new ArrayList<>();
this.listDateTimeFieldList = new ArrayList<>();
this.stringLobFieldList = new ArrayList<>();
this.stringMapFieldList = new ArrayList<>();
}
public DynamicEntity(String name) {
......@@ -153,156 +149,140 @@ public class DynamicEntity extends GsonPropertyObject {
public static class StringMapField extends Field {
}
public List<StringField> getStringFields() {
return stringFields;
}
public void setStringFields(List<StringField> stringFields) {
this.stringFields = stringFields;
}
public List<IntegerField> getIntegerFields() {
return integerFields;
}
public void setIntegerFields(List<IntegerField> integerFields) {
this.integerFields = integerFields;
}
public List<LongField> getLongFields() {
return longFields;
public String getName() {
return name;
}
public void setLongFields(List<LongField> longFields) {
this.longFields = longFields;
public void setName(String name) {
this.name = name;
}
public List<DoubleField> getDoubleFields() {
return doubleFields;
public List<StringField> getStringFieldList() {
return stringFieldList;
}
public void setDoubleFields(List<DoubleField> doubleFields) {
this.doubleFields = doubleFields;
public void setStringFieldList(List<StringField> stringFieldList) {
this.stringFieldList = stringFieldList;
}
public List<BooleanField> getBooleanFields() {
return booleanFields;
public List<IntegerField> getIntegerFieldList() {
return integerFieldList;
}
public void setBooleanFields(List<BooleanField> booleanFields) {
this.booleanFields = booleanFields;
public void setIntegerFieldList(List<IntegerField> integerFieldList) {
this.integerFieldList = integerFieldList;
}
public List<DateField> getDateFields() {
return dateFields;
public List<LongField> getLongFieldList() {
return longFieldList;
}
public void setDateFields(List<DateField> dateFields) {
this.dateFields = dateFields;
public void setLongFieldList(List<LongField> longFieldList) {
this.longFieldList = longFieldList;
}
public List<TimeField> getTimeFields() {
return timeFields;
public List<DoubleField> getDoubleFieldList() {
return doubleFieldList;
}
public void setTimeFields(List<TimeField> timeFields) {
this.timeFields = timeFields;
public void setDoubleFieldList(List<DoubleField> doubleFieldList) {
this.doubleFieldList = doubleFieldList;
}
public List<DateTimeField> getDateTimeFields() {
return dateTimeFields;
public List<BooleanField> getBooleanFieldList() {
return booleanFieldList;
}
public void setDateTimeFields(List<DateTimeField> dateTimeFields) {
this.dateTimeFields = dateTimeFields;
public void setBooleanFieldList(List<BooleanField> booleanFieldList) {
this.booleanFieldList = booleanFieldList;
}
public List<StringField> getListStringFields() {
return listStringFields;
public List<DateField> getDateFieldList() {
return dateFieldList;
}
public void setListStringFields(List<StringField> listStringFields) {
this.listStringFields = listStringFields;
public void setDateFieldList(List<DateField> dateFieldList) {
this.dateFieldList = dateFieldList;
}
public List<IntegerField> getListIntegerFields() {
return listIntegerFields;
public List<TimeField> getTimeFieldList() {
return timeFieldList;
}
public void setListIntegerFields(List<IntegerField> listIntegerFields) {
this.listIntegerFields = listIntegerFields;
public void setTimeFieldList(List<TimeField> timeFieldList) {
this.timeFieldList = timeFieldList;
}
public List<LongField> getListLongFields() {
return listLongFields;
public List<DateTimeField> getDateTimeFieldList() {
return dateTimeFieldList;
}
public void setListLongFields(List<LongField> listLongFields) {
this.listLongFields = listLongFields;
public void setDateTimeFieldList(List<DateTimeField> dateTimeFieldList) {
this.dateTimeFieldList = dateTimeFieldList;
}
public List<DoubleField> getListDoubleFields() {
return listDoubleFields;
public List<StringField> getListStringFieldList() {
return listStringFieldList;
}
public void setListDoubleFields(List<DoubleField> listDoubleFields) {
this.listDoubleFields = listDoubleFields;
public void setListStringFieldList(List<StringField> listStringFieldList) {
this.listStringFieldList = listStringFieldList;
}
public List<BooleanField> getListBooleanFields() {
return listBooleanFields;
public List<IntegerField> getListIntegerFieldList() {
return listIntegerFieldList;
}
public void setListBooleanFields(List<BooleanField> listBooleanFields) {
this.listBooleanFields = listBooleanFields;
public void setListIntegerFieldList(List<IntegerField> listIntegerFieldList) {
this.listIntegerFieldList = listIntegerFieldList;
}
public List<DateField> getListDateFields() {
return listDateFields;
public List<LongField> getListLongFieldList() {
return listLongFieldList;
}
public void setListDateFields(List<DateField> listDateFields) {
this.listDateFields = listDateFields;
public void setListLongFieldList(List<LongField> listLongFieldList) {
this.listLongFieldList = listLongFieldList;
}
public List<TimeField> getListTimeFields() {
return listTimeFields;
public List<DoubleField> getListDoubleFieldList() {
return listDoubleFieldList;
}
public void setListTimeFields(List<TimeField> listTimeFields) {
this.listTimeFields = listTimeFields;
public void setListDoubleFieldList(List<DoubleField> listDoubleFieldList) {
this.listDoubleFieldList = listDoubleFieldList;
}
public List<DateTimeField> getListDateTimeFields() {
return listDateTimeFields;
public List<BooleanField> getListBooleanFieldList() {
return listBooleanFieldList;
}
public void setListDateTimeFields(List<DateTimeField> listDateTimeFields) {
this.listDateTimeFields = listDateTimeFields;
public void setListBooleanFieldList(List<BooleanField> listBooleanFieldList) {
this.listBooleanFieldList = listBooleanFieldList;
}
public List<StringLobField> getStringLobFields() {
return stringLobFields;
public List<DateTimeField> getListDateTimeFieldList() {
return listDateTimeFieldList;
}
public void setStringLobFields(List<StringLobField> stringLobFields) {
this.stringLobFields = stringLobFields;
public void setListDateTimeFieldList(List<DateTimeField> listDateTimeFieldList) {
this.listDateTimeFieldList = listDateTimeFieldList;
}
public List<StringMapField> getStringMapFields() {
return stringMapFields;
public List<StringLobField> getStringLobFieldList() {
return stringLobFieldList;
}
public void setStringMapFields(List<StringMapField> stringMapFields) {
this.stringMapFields = stringMapFields;
public void setStringLobFieldList(List<StringLobField> stringLobFieldList) {
this.stringLobFieldList = stringLobFieldList;
}
public String getName() {
return name;
public List<StringMapField> getStringMapFieldList() {
return stringMapFieldList;
}
public void setName(String name) {
this.name = name;
public void setStringMapFieldList(List<StringMapField> stringMapFieldList) {
this.stringMapFieldList = stringMapFieldList;
}
}
......@@ -2,6 +2,7 @@ package com.x.query.assemble.designer;
import java.io.File;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import javax.lang.model.element.Modifier;
......@@ -153,31 +154,31 @@ public class DynamicEntityBuilder {
}
private void createStringFields(Builder builder) {
for (StringField field : ListTools.trim(dynamicEntity.getStringFields(), true, true)) {
for (StringField field : ListTools.trim(dynamicEntity.getStringFieldList(), true, true)) {
this.createField(builder, field, String.class);
}
}
private void createIntegerFields(Builder builder) {
for (IntegerField field : ListTools.trim(dynamicEntity.getIntegerFields(), true, true)) {
for (IntegerField field : ListTools.trim(dynamicEntity.getIntegerFieldList(), true, true)) {
this.createField(builder, field, Integer.class);
}
}
private void createLongFields(Builder builder) {
for (LongField field : ListTools.trim(dynamicEntity.getLongFields(), true, true)) {
for (LongField field : ListTools.trim(dynamicEntity.getLongFieldList(), true, true)) {
this.createField(builder, field, Long.class);
}
}
private void createDoubleFields(Builder builder) {
for (DoubleField field : ListTools.trim(dynamicEntity.getDoubleFields(), true, true)) {
for (DoubleField field : ListTools.trim(dynamicEntity.getDoubleFieldList(), true, true)) {
this.createField(builder, field, Double.class);
}
}
private void createBooleanFields(Builder builder) {
for (BooleanField field : ListTools.trim(dynamicEntity.getBooleanFields(), true, true)) {
for (BooleanField field : ListTools.trim(dynamicEntity.getBooleanFieldList(), true, true)) {
this.createField(builder, field, Boolean.class);
}
}
......@@ -212,7 +213,7 @@ public class DynamicEntityBuilder {
}
private void createDateFields(Builder builder) {
for (DateField field : ListTools.trim(dynamicEntity.getDateFields(), true, true)) {
for (DateField field : ListTools.trim(dynamicEntity.getDateFieldList(), true, true)) {
this.createDateField(builder, field);
}
}
......@@ -223,8 +224,7 @@ public class DynamicEntityBuilder {
.addMember("name", "ColumnNamePrefix + " + field.fieldName()).build();
AnnotationSpec temporal = AnnotationSpec.builder(Temporal.class)
.addMember("value", "javax.persistence.Temporal.DATE").build();
.addMember("value", "javax.persistence.TemporalType.DATE").build();
FieldSpec fieldSpec = FieldSpec.builder(Date.class, field.getName(), Modifier.PRIVATE)
.addAnnotation(this.fieldDescribe(field)).addAnnotation(this.index(field))
.addAnnotation(this.checkPersist(field)).addAnnotation(column).addAnnotation(temporal).build();
......@@ -239,7 +239,7 @@ public class DynamicEntityBuilder {
}
private void createTimeFields(Builder builder) {
for (TimeField field : ListTools.trim(dynamicEntity.getTimeFields(), true, true)) {
for (TimeField field : ListTools.trim(dynamicEntity.getTimeFieldList(), true, true)) {
this.createTimeField(builder, field);
}
}
......@@ -250,7 +250,7 @@ public class DynamicEntityBuilder {
.addMember("name", "ColumnNamePrefix + " + field.fieldName()).build();
AnnotationSpec temporal = AnnotationSpec.builder(Temporal.class)
.addMember("value", "javax.persistence.Temporal.TIME").build();
.addMember("value", "javax.persistence.TemporalType.TIME").build();
FieldSpec fieldSpec = FieldSpec.builder(Date.class, field.getName(), Modifier.PRIVATE)
.addAnnotation(this.fieldDescribe(field)).addAnnotation(this.index(field))
......@@ -266,7 +266,7 @@ public class DynamicEntityBuilder {
}
private void createDateTimeFields(Builder builder) {
for (DateTimeField field : ListTools.trim(dynamicEntity.getDateTimeFields(), true, true)) {
for (DateTimeField field : ListTools.trim(dynamicEntity.getDateTimeFieldList(), true, true)) {
this.createDateTimeField(builder, field);
}
}
......@@ -277,7 +277,7 @@ public class DynamicEntityBuilder {
.addMember("name", "ColumnNamePrefix + " + field.fieldName()).build();
AnnotationSpec temporal = AnnotationSpec.builder(Temporal.class)
.addMember("value", "javax.persistence.Temporal.TIMESTAMP").build();
.addMember("value", "javax.persistence.TemporalType.TIMESTAMP").build();
FieldSpec fieldSpec = FieldSpec.builder(Date.class, field.getName(), Modifier.PRIVATE)
.addAnnotation(this.fieldDescribe(field)).addAnnotation(this.index(field))
......@@ -293,37 +293,37 @@ public class DynamicEntityBuilder {
}
private void createListStringFields(Builder builder) {
for (StringField field : ListTools.trim(dynamicEntity.getListStringFields(), true, true)) {
for (StringField field : ListTools.trim(dynamicEntity.getListStringFieldList(), true, true)) {
this.createListFields(builder, field, String.class);
}
}
private void createListIntegerFields(Builder builder) {
for (IntegerField field : ListTools.trim(dynamicEntity.getListIntegerFields(), true, true)) {
for (IntegerField field : ListTools.trim(dynamicEntity.getListIntegerFieldList(), true, true)) {
this.createListFields(builder, field, Integer.class);
}
}
private void createListLongFields(Builder builder) {
for (LongField field : ListTools.trim(dynamicEntity.getListLongFields(), true, true)) {
for (LongField field : ListTools.trim(dynamicEntity.getListLongFieldList(), true, true)) {
this.createListFields(builder, field, Long.class);
}
}
private void createListDoubleFields(Builder builder) {
for (DoubleField field : ListTools.trim(dynamicEntity.getListDoubleFields(), true, true)) {
for (DoubleField field : ListTools.trim(dynamicEntity.getListDoubleFieldList(), true, true)) {
this.createListFields(builder, field, Double.class);
}
}
private void createListBooleanFields(Builder builder) {
for (BooleanField field : ListTools.trim(dynamicEntity.getListBooleanFields(), true, true)) {
for (BooleanField field : ListTools.trim(dynamicEntity.getListBooleanFieldList(), true, true)) {
this.createListFields(builder, field, Boolean.class);
}
}
private void createListDateTimeFields(Builder builder) {
for (BooleanField field : ListTools.trim(dynamicEntity.getListBooleanFields(), true, true)) {
for (DateTimeField field : ListTools.trim(dynamicEntity.getListDateTimeFieldList(), true, true)) {
this.createListFields(builder, field, Date.class);
}
}
......@@ -336,7 +336,7 @@ public class DynamicEntityBuilder {
// + IndexNameMiddle + groupList_FIELDNAME + JoinIndexNameSuffix))
// @ElementIndex(name = TABLE + IndexNameMiddle + groupList_FIELDNAME + ElementIndexNameSuffix)
// @PersistentCollection(fetch = FetchType.EAGER)
// @OrderColumn(name = PersistenceProperties.orderColumn)
// @OrderColumn(name = ORDERCOLUMNCOLUMN)
// @ElementColumn(length = JpaObject.length_id, name = ColumnNamePrefix + groupList_FIELDNAME)
// @CheckPersist(allowEmpty = true, citationExists = @CitationExist(type = Group.class))
// private List<String> groupList;
......@@ -354,8 +354,8 @@ public class DynamicEntityBuilder {
AnnotationSpec persistentCollection = AnnotationSpec.builder(PersistentCollection.class)
.addMember("fetch", "javax.persistence.FetchType.EAGER").build();
AnnotationSpec orderColumn = AnnotationSpec.builder(OrderColumn.class)
.addMember("name", "com.x.organization.core.entity.AbstractPersistenceProperties.orderColumn").build();
AnnotationSpec orderColumn = AnnotationSpec.builder(OrderColumn.class).addMember("name", "ORDERCOLUMNCOLUMN")
.build();
AnnotationSpec elementColumn = AnnotationSpec.builder(ElementColumn.class).addMember("length", "length_255B")
.addMember("name", "ColumnNamePrefix + " + field.fieldName()).build();
......@@ -378,7 +378,7 @@ public class DynamicEntityBuilder {
}
private void createStringLobFields(Builder builder) {
for (StringLobField field : ListTools.trim(dynamicEntity.getStringLobFields(), true, true)) {
for (StringLobField field : ListTools.trim(dynamicEntity.getStringLobFieldList(), true, true)) {
this.createStringLobField(builder, field);
}
}
......@@ -413,7 +413,7 @@ public class DynamicEntityBuilder {
}
private void createStringMapFields(Builder builder) {
for (StringMapField field : ListTools.trim(dynamicEntity.getStringMapFields(), true, true)) {
for (StringMapField field : ListTools.trim(dynamicEntity.getStringMapFieldList(), true, true)) {
this.createStringMapField(builder, field);
}
}
......@@ -454,16 +454,19 @@ public class DynamicEntityBuilder {
AnnotationSpec keyIndex = AnnotationSpec.builder(KeyIndex.class)
.addMember("name", "TABLE + IndexNameMiddle + " + field.fieldName() + " + KeyIndexNameSuffix").build();
FieldSpec fieldSpec = FieldSpec.builder(String.class, field.getName(), Modifier.PRIVATE)
ClassName type = ClassName.get(String.class);
ClassName map = ClassName.get(LinkedHashMap.class);
TypeName map_type = ParameterizedTypeName.get(map, type, type);
FieldSpec fieldSpec = FieldSpec.builder(map_type, field.getName(), Modifier.PRIVATE)
.addAnnotation(this.fieldDescribe(field)).addAnnotation(persistentMap).addAnnotation(containerTable)
.addAnnotation(keyColumn).addAnnotation(elementColumn).addAnnotation(elementIndex)
.addAnnotation(keyIndex).build();
MethodSpec get = MethodSpec.methodBuilder("get" + StringUtils.capitalize(field.getName()))
.addModifiers(Modifier.PUBLIC).returns(String.class).addStatement("return this." + field.getName())
.build();
.addModifiers(Modifier.PUBLIC).returns(map_type).addStatement("return this." + field.getName()).build();
MethodSpec set = MethodSpec.methodBuilder("set" + StringUtils.capitalize(field.getName()))
.addModifiers(Modifier.PUBLIC).returns(void.class).addParameter(String.class, field.getName())
.addModifiers(Modifier.PUBLIC).returns(void.class).addParameter(map_type, field.getName())
.addStatement("this." + field.getName() + " = " + field.getName()).build();
builder.addField(this.fieldName(field)).addField(fieldSpec).addMethod(get).addMethod(set);
......
package com.x.query.assemble.designer.jaxrs.statement;
import java.util.Map;
import java.util.Map.Entry;
import javax.persistence.EntityManager;
......@@ -8,14 +9,15 @@ import javax.persistence.Query;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
import com.google.gson.reflect.TypeToken;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.gson.XGsonBuilder;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.scripting.AbstractRuntime;
import com.x.base.core.project.scripting.ScriptingEngine;
import com.x.query.assemble.designer.Business;
import com.x.query.assemble.designer.DynamicEntity;
......@@ -44,43 +46,43 @@ class ActionExecute extends BaseAction {
throw new ExceptionEntityNotExist(statement.getTable(), Table.class);
}
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Map<String, Object> parameter = XGsonBuilder.instance().fromJson(jsonElement,
new TypeToken<Map<String, Object>>() {
}.getType());
this.beforeScript(business, statement, wi);
this.beforeScript(business, effectivePerson, statement, parameter);
DynamicEntity dynamicEntity = new DynamicEntity(table.getName());
EntityManager em = emc.get((Class<JpaObject>) Class.forName(dynamicEntity.className()));
Query query = em.createQuery(statement.getData());
for (Entry<String, Object> en : wi.getParameter().entrySet()) {
for (Entry<String, Object> en : parameter.entrySet()) {
query.setParameter(en.getKey(), en.getValue());
}
Object data = query.getResultList();
if (StringUtils.isNotBlank(statement.getAfterScriptText())) {
this.initScriptingEngine(business);
this.initScriptingEngine(business, effectivePerson);
scriptingEngine.bindingData(data);
data = scriptingEngine.eval(statement.getBeforeScriptText());
data = scriptingEngine.eval(statement.getAfterScriptText());
}
result.setData(data);
return result;
}
}
private void beforeScript(Business business, Statement statement, Wi wi) throws Exception {
private void beforeScript(Business business, EffectivePerson effectivePerson, Statement statement,
Map<String, Object> parameter) throws Exception {
if (StringUtils.isNotBlank(statement.getBeforeScriptText())) {
this.initScriptingEngine(business);
scriptingEngine.bindingParameter(wi);
this.initScriptingEngine(business, effectivePerson);
scriptingEngine.bindingParameter(parameter);
scriptingEngine.eval(statement.getBeforeScriptText());
}
}
private void initScriptingEngine(Business business) {
private void initScriptingEngine(Business business, EffectivePerson effectivePerson) {
if (null == this.scriptingEngine) {
this.scriptingEngine = business.createScriptEngine();
}
}
public static class Wi extends AbstractRuntime {
this.scriptingEngine = business.createScriptEngine().bindingEffectivePerson(effectivePerson);
}
}
}
\ No newline at end of file
......@@ -36,11 +36,11 @@ import com.x.query.assemble.designer.DynamicEntityBuilder;
import com.x.query.core.entity.schema.Enhance;
import com.x.query.core.entity.schema.Table;
class ActionBuild extends BaseAction {
class ActionBuildAll extends BaseAction {
private static final String DOT_JAR = ".jar";
private static Logger logger = LoggerFactory.getLogger(ActionBuild.class);
private static Logger logger = LoggerFactory.getLogger(ActionBuildAll.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
......@@ -104,6 +104,7 @@ class ActionBuild extends BaseAction {
}
private void enhance() throws Exception {
File commandJavaFile = null;
if (SystemUtils.IS_OS_AIX) {
commandJavaFile = new File(Config.dir_jvm_aix(), "bin/java");
......@@ -126,7 +127,9 @@ class ActionBuild extends BaseAction {
logger.debug("enhance command:{}.", command);
Runtime.getRuntime().exec(command);
Process process = Runtime.getRuntime().exec(command);
process.waitFor();
}
public static class Wo extends WrapBoolean {
......
......@@ -19,6 +19,7 @@ import com.x.base.core.project.gson.XGsonBuilder;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.tools.ListTools;
import com.x.query.assemble.designer.Business;
import com.x.query.assemble.designer.DynamicEntity;
import com.x.query.core.entity.schema.Table;
......@@ -64,7 +65,8 @@ class ActionCreate extends BaseAction {
private static final long serialVersionUID = -5237741099036357033L;
static WrapCopier<Wi, Table> copier = WrapCopierFactory.wi(Wi.class, Table.class, null,
JpaObject.FieldsUnmodify);
ListTools.toList(JpaObject.FieldsUnmodify, Table.creatorPerson_FIELDNAME,
Table.lastUpdatePerson_FIELDNAME, Table.lastUpdateTime_FIELDNAME));
}
}
\ No newline at end of file
......@@ -20,6 +20,7 @@ import com.x.base.core.project.gson.XGsonBuilder;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.tools.ListTools;
import com.x.query.assemble.designer.Business;
import com.x.query.assemble.designer.DynamicEntity;
import com.x.query.core.entity.schema.Statement;
......@@ -69,6 +70,7 @@ class ActionEdit extends BaseAction {
private static final long serialVersionUID = -5237741099036357033L;
static WrapCopier<Wi, Table> copier = WrapCopierFactory.wi(Wi.class, Table.class, null,
JpaObject.FieldsUnmodify);
ListTools.toList(JpaObject.FieldsUnmodify, Table.creatorPerson_FIELDNAME,
Table.lastUpdatePerson_FIELDNAME, Table.lastUpdateTime_FIELDNAME));
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import org.apache.commons.lang3.StringUtils;
......@@ -30,6 +31,7 @@ class ActionListRowNext extends BaseAction {
ActionResult<List<JsonObject>> execute(EffectivePerson effectivePerson, String tableFlag, String id, Integer count)
throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<JsonObject>> result = new ActionResult<>();
logger.debug(effectivePerson, "table:{}, id:{}, count:{}.", tableFlag, id, count);
Business business = new Business(emc);
......@@ -50,19 +52,29 @@ class ActionListRowNext extends BaseAction {
sequence = o.getSequence();
}
}
String sql = "select o from " + cls.getName() + " o";
List<String> fields = JpaObject.singularAttributeField(cls, true, true);
fields.add(JpaObject.sequence_FIELDNAME);
List<String> selects = new ArrayList<>();
for (String str : fields) {
selects.add("o." + str);
}
String sql = "select " + StringUtils.join(selects, ", ") + " from " + cls.getName() + " o";
Long rank = 0L;
if (null != sequence) {
sql += " where o.sequence > '" + sequence + "'";
rank = emc.countLessThanOrEqualToDesc(cls, JpaObject.sequence_FIELDNAME, sequence);
sql += " where o." + JpaObject.sequence_FIELDNAME + " < ?1";
rank = emc.countGreaterThanOrEqualTo(cls, JpaObject.sequence_FIELDNAME, sequence);
}
sql += " order by o." + JpaObject.sequence_FIELDNAME + " DESC";
List<? extends JpaObject> list = em.createQuery(sql, cls)
.setMaxResults(Math.max(Math.min(count, list_max), list_min)).getResultList();
Query query = em.createQuery(sql, Object[].class);
if (null != sequence) {
query.setParameter(1, sequence);
}
List<Object[]> list = query.setMaxResults(Math.max(Math.min(count, list_max), list_min)).getResultList();
List<JsonObject> wos = new ArrayList<>();
result.setCount(emc.count(cls));
for (JpaObject jpa : list) {
JsonObject jsonObject = XGsonBuilder.instance().toJsonTree(jpa).getAsJsonObject();
for (Object[] os : list) {
JsonObject jsonObject = XGsonBuilder.instance().toJsonTree(JpaObject.cast(cls, fields, os))
.getAsJsonObject();
jsonObject.getAsJsonObject().addProperty("rank", ++rank);
wos.add(jsonObject);
}
......
......@@ -5,6 +5,7 @@ import java.util.Collections;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import org.apache.commons.lang3.StringUtils;
......@@ -31,6 +32,7 @@ class ActionListRowPrev extends BaseAction {
ActionResult<List<JsonObject>> execute(EffectivePerson effectivePerson, String tableFlag, String id, Integer count)
throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<JsonObject>> result = new ActionResult<>();
logger.debug(effectivePerson, "table:{}, id:{}, count:{}.", tableFlag, id, count);
Business business = new Business(emc);
......@@ -51,25 +53,46 @@ class ActionListRowPrev extends BaseAction {
sequence = o.getSequence();
}
}
String sql = "select o from " + cls.getName() + " o";
Long rank = 0L;
if (null != sequence) {
sql += " where o.sequence < '" + sequence + "'";
rank = emc.countLessThanDesc(cls, JpaObject.sequence_FIELDNAME, sequence);
List<String> fields = JpaObject.singularAttributeField(cls, true, true);
fields.add(JpaObject.sequence_FIELDNAME);
List<String> selects = new ArrayList<>();
for (String str : fields) {
selects.add("o." + str);
}
sql += " order by o." + JpaObject.sequence_FIELDNAME + " DESC";
List<? extends JpaObject> list = em.createQuery(sql, cls)
.setMaxResults(Math.max(Math.min(count, list_max), list_min)).getResultList();
List<JsonObject> wos = new ArrayList<>();
result.setCount(emc.count(cls));
for (JpaObject jpa : list) {
JsonObject jsonObject = XGsonBuilder.instance().toJsonTree(jpa).getAsJsonObject();
jsonObject.getAsJsonObject().addProperty("rank", rank--);
wos.add(jsonObject);
String sql = "select " + StringUtils.join(selects, ", ") + " from " + cls.getName() + " o";
Long rank = 0L;
List<JsonObject> wos = new ArrayList<>();
if (null != sequence) {
sql += " where o." + JpaObject.sequence_FIELDNAME + " > ?1 order by o." + JpaObject.sequence_FIELDNAME
+ " ASC";
rank = emc.countGreaterThan(cls, JpaObject.sequence_FIELDNAME, sequence);
Query query = em.createQuery(sql, Object[].class);
query.setParameter(1, sequence);
List<Object[]> list = query.setMaxResults(Math.max(Math.min(count, list_max), list_min))
.getResultList();
for (Object[] os : list) {
JsonObject jsonObject = XGsonBuilder.instance().toJsonTree(JpaObject.cast(cls, fields, os))
.getAsJsonObject();
jsonObject.getAsJsonObject().addProperty("rank", rank--);
wos.add(jsonObject);
}
} else {
sql += " order by o." + JpaObject.sequence_FIELDNAME + " ASC";
rank = result.getCount();
Query query = em.createQuery(sql, Object[].class);
List<Object[]> list = query.setMaxResults(Math.max(Math.min(count, list_max), list_min))
.getResultList();
for (Object[] os : list) {
JsonObject jsonObject = XGsonBuilder.instance().toJsonTree(JpaObject.cast(cls, fields, os))
.getAsJsonObject();
jsonObject.getAsJsonObject().addProperty("rank", rank--);
wos.add(jsonObject);
}
}
Collections.reverse(wos);
result.setData(wos);
return result;
}
}
}
}
\ No newline at end of file
......@@ -19,10 +19,9 @@ import com.x.query.core.entity.schema.Table;
class ActionListRowSelectWhere extends BaseAction {
ActionResult<List<Object>> execute(EffectivePerson effectivePerson, String tableFlag, String where)
throws Exception {
ActionResult<List<?>> execute(EffectivePerson effectivePerson, String tableFlag, String where) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Object>> result = new ActionResult<>();
ActionResult<List<?>> result = new ActionResult<>();
Table table = emc.flag(tableFlag, Table.class);
Business business = new Business(emc);
if (null == table) {
......@@ -32,14 +31,15 @@ class ActionListRowSelectWhere extends BaseAction {
throw new ExceptionAccessDenied(effectivePerson, table);
}
DynamicEntity dynamicEntity = new DynamicEntity(table.getName());
@SuppressWarnings("unchecked")
Class<? extends JpaObject> clz = (Class<JpaObject>) Class.forName(dynamicEntity.className());
EntityManager em = emc.get(clz);
String sql = "SELECT o FROM " + clz.getName() + " o";
if (StringUtils.isNotBlank(where) && (!StringUtils.equals(where, EMPTY_SYMBOL))) {
sql += " where (" + where + ")";
}
List<? extends Object> list = em.createQuery(sql).getResultList();
result.setData((List<Object>) list);
List<?> list = em.createQuery(sql).getResultList();
result.setData(list);
return result;
}
}
......
......@@ -31,9 +31,10 @@ class ActionRowCountWhere extends BaseAction {
throw new ExceptionAccessDenied(effectivePerson, table);
}
DynamicEntity dynamicEntity = new DynamicEntity(table.getName());
Class<? extends JpaObject> clz = (Class<JpaObject>) Class.forName(dynamicEntity.className());
EntityManager em = emc.get(clz);
String sql = "SELECT count(o) FROM " + clz.getName() + " o";
@SuppressWarnings("unchecked")
Class<? extends JpaObject> cls = (Class<JpaObject>) Class.forName(dynamicEntity.className());
EntityManager em = emc.get(cls);
String sql = "SELECT count(o) FROM " + cls.getName() + " o";
if (StringUtils.isNotBlank(where) && (!StringUtils.equals(where, EMPTY_SYMBOL))) {
sql += " where (" + where + ")";
}
......
......@@ -25,12 +25,13 @@ class ActionRowDelete extends BaseAction {
throw new ExceptionAccessDenied(effectivePerson, table);
}
DynamicEntity dynamicEntity = new DynamicEntity(table.getName());
Class<? extends JpaObject> clz = (Class<JpaObject>) Class.forName(dynamicEntity.className());
JpaObject o = emc.find(id, clz);
@SuppressWarnings("unchecked")
Class<? extends JpaObject> cls = (Class<JpaObject>) Class.forName(dynamicEntity.className());
JpaObject o = emc.find(id, cls);
Wo wo = new Wo();
wo.setValue(false);
if (null != o) {
emc.beginTransaction(clz);
emc.beginTransaction(cls);
emc.remove(o);
emc.commit();
wo.setValue(true);
......
package com.x.query.assemble.designer.jaxrs.table;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapLong;
import com.x.query.assemble.designer.Business;
import com.x.query.assemble.designer.DynamicEntity;
import com.x.query.core.entity.schema.Table;
class ActionRowDeleteAll extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String tableFlag) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Table table = emc.flag(tableFlag, Table.class);
Business business = new Business(emc);
if (null == table) {
throw new ExceptionEntityNotExist(tableFlag, Table.class);
}
if (!business.editable(effectivePerson, table)) {
throw new ExceptionAccessDenied(effectivePerson, table);
}
DynamicEntity dynamicEntity = new DynamicEntity(table.getName());
@SuppressWarnings("unchecked")
Class<? extends JpaObject> cls = (Class<JpaObject>) Class.forName(dynamicEntity.className());
List<String> ids = null;
Long count = 0L;
do {
ids = this.listIds(business, cls);
if (!ids.isEmpty()) {
emc.beginTransaction(cls);
count += this.delete(business, cls, ids);
emc.commit();
}
} while (!ids.isEmpty());
Wo wo = new Wo();
wo.setValue(count);
result.setData(wo);
return result;
}
}
private <T extends JpaObject> List<String> listIds(Business business, Class<T> cls) throws Exception {
EntityManager em = business.entityManagerContainer().get(cls);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<T> root = cq.from(cls);
List<String> os = em.createQuery(cq.select(root.get(JpaObject.id_FIELDNAME))).setMaxResults(2000)
.getResultList();
return os;
}
private <T extends JpaObject> Integer delete(Business business, Class<T> cls, List<String> ids) throws Exception {
EntityManager em = business.entityManagerContainer().get(cls);
Query query = em.createQuery("delete from " + cls.getName() + " o where o.id in :ids");
query.setParameter("ids", ids);
return query.executeUpdate();
}
public static class Wo extends WrapLong {
}
}
\ No newline at end of file
package com.x.query.assemble.designer.jaxrs.table;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaDelete;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapIdList;
import com.x.base.core.project.jaxrs.WrapLong;
import com.x.base.core.project.tools.ListTools;
import com.x.query.assemble.designer.Business;
import com.x.query.assemble.designer.DynamicEntity;
import com.x.query.core.entity.schema.Table;
class ActionRowDeleteBatch extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String tableFlag, JsonElement jsonElement)
throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Table table = emc.flag(tableFlag, Table.class);
Business business = new Business(emc);
if (null == table) {
throw new ExceptionEntityNotExist(tableFlag, Table.class);
}
if (!business.editable(effectivePerson, table)) {
throw new ExceptionAccessDenied(effectivePerson, table);
}
DynamicEntity dynamicEntity = new DynamicEntity(table.getName());
@SuppressWarnings("unchecked")
Class<? extends JpaObject> cls = (Class<JpaObject>) Class.forName(dynamicEntity.className());
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
Long count = 0L;
if (ListTools.isNotEmpty(wi.getIdList())) {
for (List<String> ids : ListTools.batch(wi.getIdList(), 2000)) {
emc.beginTransaction(cls);
count += this.delete(business, cls, ids);
emc.commit();
}
}
Wo wo = new Wo();
wo.setValue(count);
result.setData(wo);
return result;
}
}
private <T extends JpaObject> Integer delete(Business business, Class<T> cls, List<String> ids) throws Exception {
EntityManager em = business.entityManagerContainer().get(cls);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaDelete<T> cd = cb.createCriteriaDelete(cls);
Root<T> root = cd.from(cls);
Predicate p = cb.isMember(root.get(JpaObject.id_FIELDNAME), cb.literal(ids));
return em.createQuery(cd.where(p)).executeUpdate();
}
public static class Wi extends WrapIdList {
}
public static class Wo extends WrapLong {
}
}
\ No newline at end of file
......@@ -24,8 +24,9 @@ class ActionRowGet extends BaseAction {
throw new ExceptionAccessDenied(effectivePerson, table);
}
DynamicEntity dynamicEntity = new DynamicEntity(table.getName());
Class<? extends JpaObject> clz = (Class<JpaObject>) Class.forName(dynamicEntity.className());
JpaObject o = emc.find(id, clz);
@SuppressWarnings("unchecked")
Class<? extends JpaObject> cls = (Class<JpaObject>) Class.forName(dynamicEntity.className());
JpaObject o = emc.find(id, cls);
result.setData(o);
return result;
}
......
package com.x.query.assemble.designer.jaxrs.table;
import java.util.ArrayList;
import java.util.List;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.gson.XGsonBuilder;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.jaxrs.WrapBoolean;
import com.x.query.assemble.designer.Business;
import com.x.query.assemble.designer.DynamicEntity;
import com.x.query.core.entity.schema.Table;
......@@ -28,19 +31,34 @@ class ActionRowInsert extends BaseAction {
throw new ExceptionAccessDenied(effectivePerson, table);
}
DynamicEntity dynamicEntity = new DynamicEntity(table.getName());
Class<? extends JpaObject> clz = (Class<JpaObject>) Class.forName(dynamicEntity.className());
JpaObject o = XGsonBuilder.instance().fromJson(jsonElement, clz);
emc.beginTransaction(clz);
emc.persist(o);
@SuppressWarnings("unchecked")
Class<? extends JpaObject> cls = (Class<JpaObject>) Class.forName(dynamicEntity.className());
List<Object> os = new ArrayList<>();
if (jsonElement.isJsonArray()) {
jsonElement.getAsJsonArray().forEach(o -> {
os.add(gson.fromJson(o, cls));
});
} else if (jsonElement.isJsonObject()) {
os.add(gson.fromJson(jsonElement, cls));
}
emc.beginTransaction(cls);
for (Object o : os) {
emc.persist((JpaObject) o, CheckPersistType.all);
}
emc.commit();
Wo wo = new Wo();
wo.setId(o.getId());
if (os.isEmpty()) {
wo.setValue(false);
} else {
wo.setValue(true);
}
result.setData(wo);
return result;
}
}
public static class Wo extends WoId {
public static class Wo extends WrapBoolean {
}
......
......@@ -29,14 +29,15 @@ class ActionRowUpdate extends BaseAction {
throw new ExceptionAccessDenied(effectivePerson, table);
}
DynamicEntity dynamicEntity = new DynamicEntity(table.getName());
Class<? extends JpaObject> clz = (Class<JpaObject>) Class.forName(dynamicEntity.className());
JpaObject o = emc.find(id, clz);
@SuppressWarnings("unchecked")
Class<? extends JpaObject> cls = (Class<JpaObject>) Class.forName(dynamicEntity.className());
JpaObject o = emc.find(id, cls);
Wo wo = new Wo();
wo.setValue(false);
if (null != o) {
JpaObject n = XGsonBuilder.instance().fromJson(jsonElement, clz);
JpaObject n = XGsonBuilder.instance().fromJson(jsonElement, cls);
n.copyTo(o, JpaObject.FieldsUnmodify);
emc.beginTransaction(clz);
emc.beginTransaction(cls);
emc.check(o, CheckPersistType.all);
emc.commit();
wo.setValue(true);
......
......@@ -35,16 +35,16 @@ public class TableAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(TableAction.class);
@JaxrsMethodDescribe(value = "编译表对象生成实体类进行数据库建表,执行后需要重新启动.", action = ActionBuild.class)
@JaxrsMethodDescribe(value = "编译表对象生成实体类进行数据库建表,执行后需要重新启动.", action = ActionBuildAll.class)
@GET
@Path("build/table")
@Path("build/all")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void build(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request) {
ActionResult<ActionBuild.Wo> result = new ActionResult<>();
public void buildAll(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request) {
ActionResult<ActionBuildAll.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionBuild().execute(effectivePerson);
result = new ActionBuildAll().execute(effectivePerson);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
......@@ -163,7 +163,7 @@ public class TableAction extends StandardJaxrsAction {
@JaxrsMethodDescribe(value = "获取表中某一行数据", action = ActionRowGet.class)
@GET
@Path("table/{tableFlag}/row/{id}")
@Path("{tableFlag}/row/{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void rowGet(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
......@@ -182,13 +182,13 @@ public class TableAction extends StandardJaxrsAction {
@JaxrsMethodDescribe(value = "通过where 获取表中的数据,格式为jpql语法,o.name='zhangsan'", action = ActionListRowSelectWhere.class)
@GET
@Path("list/table/{tableFlag}/row/select/where/{where}")
@Path("list/{tableFlag}/row/select/where/{where}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listRowSelectWhere(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("表标识") @PathParam("tableFlag") String tableFlag,
@JaxrsParameterDescribe("where语句") @PathParam("where") String where) {
ActionResult<List<Object>> result = new ActionResult<>();
ActionResult<List<?>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListRowSelectWhere().execute(effectivePerson, tableFlag, where);
......@@ -201,7 +201,7 @@ public class TableAction extends StandardJaxrsAction {
@JaxrsMethodDescribe(value = "通过where 统计数量", action = ActionRowCountWhere.class)
@GET
@Path("table/{tableFlag}/row/count/where/{where}")
@Path("{tableFlag}/row/count/where/{where}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void rowCountWhere(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
......@@ -220,7 +220,7 @@ public class TableAction extends StandardJaxrsAction {
@JaxrsMethodDescribe(value = "指定表中插入数据.", action = ActionRowInsert.class)
@POST
@Path("table/{tableFlag}")
@Path("{tableFlag}/row")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void rowInsert(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
......@@ -238,7 +238,7 @@ public class TableAction extends StandardJaxrsAction {
@JaxrsMethodDescribe(value = "更新指定表中指定行数据.", action = ActionRowUpdate.class)
@PUT
@Path("table/{tableFlag}/row/{id}")
@Path("{tableFlag}/row/{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void rowUpdate(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
......@@ -257,7 +257,7 @@ public class TableAction extends StandardJaxrsAction {
@JaxrsMethodDescribe(value = "更新指定表中指定行数据.", action = ActionRowDelete.class)
@DELETE
@Path("table/{tableFlag}/row/{id}")
@Path("{tableFlag}/row/{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void rowDelete(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
......@@ -274,9 +274,27 @@ public class TableAction extends StandardJaxrsAction {
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
@JaxrsMethodDescribe(value = "更新指定表中指定行数据.", action = ActionRowDeleteAll.class)
@DELETE
@Path("{tableFlag}/row/delete/all")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void rowDeleteAll(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("表标识") @PathParam("tableFlag") String tableFlag) {
ActionResult<ActionRowDeleteAll.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionRowDeleteAll().execute(effectivePerson, tableFlag);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
@JaxrsMethodDescribe(value = "列示表中的行对象,下一页.", action = ActionListRowNext.class)
@GET
@Path("list/table/{tableFlag}/row/{id}/next/{count}")
@Path("list/{tableFlag}/row/{id}/next/{count}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listRowNext(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
......@@ -296,7 +314,7 @@ public class TableAction extends StandardJaxrsAction {
@JaxrsMethodDescribe(value = "列示表中的行对象,上一页.", action = ActionListRowPrev.class)
@GET
@Path("list/table/{tableFlag}/row/{id}/prev/{count}")
@Path("list/{tableFlag}/row/{id}/prev/{count}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listRowPrev(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
......
package com.x.query.assemble.designer.test;
import java.io.File;
import java.util.Collection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.DirectoryFileFilter;
import org.apache.commons.io.filefilter.FileFilterUtils;
import org.junit.Test;
import com.google.gson.JsonElement;
import com.x.base.core.project.connection.HttpConnection;
import com.x.base.core.project.gson.XGsonBuilder;
public class TestClient {
@Test
public void test() {
Collection<File> files = FileUtils.listFiles(new File("d:/aaa"), FileFilterUtils.suffixFileFilter(".java"),
DirectoryFileFilter.INSTANCE);
for (File f : files) {
System.out.println(f.getAbsolutePath());
public void insert() throws Exception {
String address = "http://127.0.0.1:20020/x_query_assemble_designer/jaxrs/table/dd/row";
for (int j = 0; j < 200; j++) {
List<JsonElement> list = new ArrayList<>();
for (int i = 0; i < 200; i++) {
String value = Objects.toString(j * 100 + i);
Map<String, Object> map = new HashMap<>();
map.put("sf1", "sf1" + value);
List<String> os = new ArrayList<>();
os.add("lsf1" + value);
map.put("lsf1", os);
map.put("slf1", "slf1"
+ "你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好");
list.add(XGsonBuilder.instance().toJsonTree(map));
}
JsonElement jsonElement = HttpConnection.postAsObject(address, null, XGsonBuilder.toJson(list),
JsonElement.class);
System.out.println(jsonElement);
}
}
@Test
public void insert1() throws Exception {
String address = "http://127.0.0.1:20020/x_query_assemble_designer/jaxrs/table/dd/row";
for (int i = 0; i < 200; i++) {
String value = Objects.toString(i);
Map<String, Object> map = new HashMap<>();
map.put("sf1", "sf1" + value);
List<String> os = new ArrayList<>();
os.add("lsf1" + value);
map.put("lsf1", os);
map.put("slf1", "slf1"
+ "你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好");
Thread.sleep(1000);
JsonElement jsonElement = HttpConnection.postAsObject(address, null, XGsonBuilder.toJson(map),
JsonElement.class);
}
}
}
{
"stringFieldList": [
{
"name": "sf1",
"description": "sf1"
},
{
"name": "sf2",
"description": "sf2"
}
],
"integerFieldList": [
{
"name": "if1",
"description": "if1"
},
{
"name": "if2",
"description": "if2"
}
],
"longFieldList": [
{
"name": "lf1",
"description": "lf1"
},
{
"name": "lf2",
"description": "lf2"
}
],
"doubleFieldList": [
{
"name": "df1",
"description": "df1"
},
{
"name": "df2",
"description": "df2"
}
],
"booleanFieldList": [
{
"name": "bf1",
"description": "bf1"
},
{
"name": "bf2",
"description": "bf2"
}
],
"dateFieldList": [
{
"name": "dtf1",
"description": "dtf1"
},
{
"name": "dtf2",
"description": "dtf2"
}
],
"timeFieldList": [
{
"name": "tf1",
"description": "tf1"
},
{
"name": "tf2",
"description": "tf2"
}
],
"dateTimeFieldList": [
{
"name": "dttf1",
"description": "dttf1"
},
{
"name": "dttf2",
"description": "dttf2"
}
],
"listStringFieldList": [
{
"name": "lsf1",
"description": "lsf1"
},
{
"name": "lsf2",
"description": "lf2"
}
],
"listIntegerFieldList": [
{
"name": "lif1",
"description": "lif1"
},
{
"name": "lif2",
"description": "lif2"
}
],
"listLongFieldList": [
{
"name": "llf1",
"description": "llf1"
},
{
"name": "llf2",
"description": "llf2"
}
],
"listDoubleFieldList": [
{
"name": "ldf1",
"description": "ldf1"
},
{
"name": "ldf2",
"description": "ldf2"
}
],
"listBooleanFieldList": [
{
"name": "lbf1",
"description": "lbf1"
},
{
"name": "lbf2",
"description": "lbf2"
}
],
"listDateFieldList": [
{
"name": "ldtf1",
"description": "ldtf1"
},
{
"name": "ldtf2",
"description": "ldtf2"
}
],
"listTimeFieldList": [
{
"name": "ltf1",
"description": "ltf1"
},
{
"name": "ltf2",
"description": "ltf2"
}
],
"listDateTimeFieldList": [
{
"name": "ldttf1",
"description": "ldttf1"
},
{
"name": "ldttf2",
"description": "ldttf2"
}
],
"stringLobFieldList": [
{
"name": "slf1",
"description": "slf1"
},
{
"name": "slf2",
"description": "slf2"
}
],
"stringMapFieldList": [
{
"name": "smf1",
"description": "smf1"
},
{
"name": "smf2",
"description": "smf2"
}
]
}
......@@ -107,7 +107,7 @@ public class Query extends SliceJpaObject {
@ContainerTable(name = TABLE + ContainerTableNameMiddle
+ availableIdentityList_FIELDNAME, joinIndex = @Index(name = TABLE + IndexNameMiddle
+ availableIdentityList_FIELDNAME + JoinIndexNameSuffix))
@OrderColumn(name = AbstractPersistenceProperties.orderColumn)
@OrderColumn(name = ORDERCOLUMNCOLUMN)
@ElementColumn(length = length_255B, name = ColumnNamePrefix + availableIdentityList_FIELDNAME)
@ElementIndex(name = TABLE + IndexNameMiddle + availableIdentityList_FIELDNAME + ElementIndexNameSuffix)
@CheckPersist(allowEmpty = true)
......@@ -119,7 +119,7 @@ public class Query extends SliceJpaObject {
@ContainerTable(name = TABLE + ContainerTableNameMiddle
+ availableUnitList_FIELDNAME, joinIndex = @Index(name = TABLE + IndexNameMiddle
+ availableUnitList_FIELDNAME + JoinIndexNameSuffix))
@OrderColumn(name = AbstractPersistenceProperties.orderColumn)
@OrderColumn(name = ORDERCOLUMNCOLUMN)
@ElementColumn(length = length_255B, name = ColumnNamePrefix + availableUnitList_FIELDNAME)
@ElementIndex(name = TABLE + IndexNameMiddle + availableUnitList_FIELDNAME + ElementIndexNameSuffix)
@CheckPersist(allowEmpty = true)
......@@ -142,7 +142,7 @@ public class Query extends SliceJpaObject {
public static final String controllerList_FIELDNAME = "controllerList";
@FieldDescribe("查询管理者")
@PersistentCollection(fetch = FetchType.EAGER)
@OrderColumn(name = PersistenceProperties.orderColumn)
@OrderColumn(name = ORDERCOLUMNCOLUMN)
@ContainerTable(name = TABLE + ContainerTableNameMiddle
+ controllerList_FIELDNAME, joinIndex = @Index(name = TABLE + IndexNameMiddle + controllerList_FIELDNAME))
@ElementColumn(length = length_255B, name = ColumnNamePrefix + controllerList_FIELDNAME)
......
......@@ -122,7 +122,7 @@ public class Reveal extends SliceJpaObject {
@ContainerTable(name = TABLE + ContainerTableNameMiddle
+ availableIdentityList_FIELDNAME, joinIndex = @Index(name = TABLE + IndexNameMiddle
+ availableIdentityList_FIELDNAME + JoinIndexNameSuffix))
@OrderColumn(name = AbstractPersistenceProperties.orderColumn)
@OrderColumn(name = ORDERCOLUMNCOLUMN)
@ElementColumn(length = length_255B, name = ColumnNamePrefix + availableIdentityList_FIELDNAME)
@ElementIndex(name = TABLE + IndexNameMiddle + availableIdentityList_FIELDNAME + ElementIndexNameSuffix)
@CheckPersist(allowEmpty = true)
......@@ -134,7 +134,7 @@ public class Reveal extends SliceJpaObject {
@ContainerTable(name = TABLE + ContainerTableNameMiddle
+ availableUnitList_FIELDNAME, joinIndex = @Index(name = TABLE + IndexNameMiddle
+ availableUnitList_FIELDNAME + JoinIndexNameSuffix))
@OrderColumn(name = AbstractPersistenceProperties.orderColumn)
@OrderColumn(name = ORDERCOLUMNCOLUMN)
@ElementColumn(length = length_255B, name = ColumnNamePrefix + availableUnitList_FIELDNAME)
@ElementIndex(name = TABLE + IndexNameMiddle + availableUnitList_FIELDNAME + ElementIndexNameSuffix)
@CheckPersist(allowEmpty = true)
......
......@@ -120,7 +120,7 @@ public class Stat extends SliceJpaObject {
@ContainerTable(name = TABLE + ContainerTableNameMiddle
+ availableIdentityList_FIELDNAME, joinIndex = @Index(name = TABLE + IndexNameMiddle
+ availableIdentityList_FIELDNAME + JoinIndexNameSuffix))
@OrderColumn(name = AbstractPersistenceProperties.orderColumn)
@OrderColumn(name = ORDERCOLUMNCOLUMN)
@ElementColumn(length = length_255B, name = ColumnNamePrefix + availableIdentityList_FIELDNAME)
@ElementIndex(name = TABLE + IndexNameMiddle + availableIdentityList_FIELDNAME + ElementIndexNameSuffix)
@CheckPersist(allowEmpty = true)
......@@ -132,7 +132,7 @@ public class Stat extends SliceJpaObject {
@ContainerTable(name = TABLE + ContainerTableNameMiddle
+ availableUnitList_FIELDNAME, joinIndex = @Index(name = TABLE + IndexNameMiddle
+ availableUnitList_FIELDNAME + JoinIndexNameSuffix))
@OrderColumn(name = AbstractPersistenceProperties.orderColumn)
@OrderColumn(name = ORDERCOLUMNCOLUMN)
@ElementColumn(length = length_255B, name = ColumnNamePrefix + availableUnitList_FIELDNAME)
@ElementIndex(name = TABLE + IndexNameMiddle + availableUnitList_FIELDNAME + ElementIndexNameSuffix)
@CheckPersist(allowEmpty = true)
......
......@@ -188,7 +188,7 @@ public class View extends SliceJpaObject {
@ContainerTable(name = TABLE + ContainerTableNameMiddle
+ availableIdentityList_FIELDNAME, joinIndex = @Index(name = TABLE + IndexNameMiddle
+ availableIdentityList_FIELDNAME + JoinIndexNameSuffix))
@OrderColumn(name = AbstractPersistenceProperties.orderColumn)
@OrderColumn(name = ORDERCOLUMNCOLUMN)
@ElementColumn(length = length_255B, name = ColumnNamePrefix + availableIdentityList_FIELDNAME)
@ElementIndex(name = TABLE + IndexNameMiddle + availableIdentityList_FIELDNAME + ElementIndexNameSuffix)
@CheckPersist(allowEmpty = true)
......@@ -200,7 +200,7 @@ public class View extends SliceJpaObject {
@ContainerTable(name = TABLE + ContainerTableNameMiddle
+ availableUnitList_FIELDNAME, joinIndex = @Index(name = TABLE + IndexNameMiddle
+ availableUnitList_FIELDNAME + JoinIndexNameSuffix))
@OrderColumn(name = AbstractPersistenceProperties.orderColumn)
@OrderColumn(name = ORDERCOLUMNCOLUMN)
@ElementColumn(length = length_255B, name = ColumnNamePrefix + availableUnitList_FIELDNAME)
@ElementIndex(name = TABLE + IndexNameMiddle + availableUnitList_FIELDNAME + ElementIndexNameSuffix)
@CheckPersist(allowEmpty = true)
......
......@@ -93,7 +93,7 @@ public class Entry extends SliceJpaObject {
public static final String inValueLabelList_FIELDNAME = "inValueLabelList";
@FieldDescribe("输入标签")
@PersistentCollection(fetch = FetchType.EAGER)
@OrderColumn(name = AbstractPersistenceProperties.orderColumn)
@OrderColumn(name = ORDERCOLUMNCOLUMN)
@ContainerTable(name = TABLE + ContainerTableNameMiddle
+ inValueLabelList_FIELDNAME, joinIndex = @Index(name = TABLE + IndexNameMiddle + inValueLabelList_FIELDNAME
+ JoinIndexNameSuffix))
......@@ -105,7 +105,7 @@ public class Entry extends SliceJpaObject {
public static final String outValueLabelList_FIELDNAME = "outValueLabelList";
@FieldDescribe("结果标签")
@PersistentCollection(fetch = FetchType.EAGER)
@OrderColumn(name = AbstractPersistenceProperties.orderColumn)
@OrderColumn(name = ORDERCOLUMNCOLUMN)
@ContainerTable(name = TABLE + ContainerTableNameMiddle
+ outValueLabelList_FIELDNAME, joinIndex = @Index(name = TABLE + IndexNameMiddle
+ outValueLabelList_FIELDNAME + JoinIndexNameSuffix))
......
......@@ -260,7 +260,7 @@ public class Model extends SliceJpaObject {
@PersistentCollection(fetch = FetchType.EAGER)
@ContainerTable(name = TABLE + ContainerTableNameMiddle + processList_FIELDNAME, joinIndex = @Index(name = TABLE
+ IndexNameMiddle + processList_FIELDNAME + JoinIndexNameSuffix))
@OrderColumn(name = AbstractPersistenceProperties.orderColumn)
@OrderColumn(name = ORDERCOLUMNCOLUMN)
@ElementColumn(length = length_255B, name = ColumnNamePrefix + processList_FIELDNAME)
@ElementIndex(name = TABLE + IndexNameMiddle + processList_FIELDNAME + ElementIndexNameSuffix)
@CheckPersist(allowEmpty = true)
......@@ -271,7 +271,7 @@ public class Model extends SliceJpaObject {
@PersistentCollection(fetch = FetchType.EAGER)
@ContainerTable(name = TABLE + ContainerTableNameMiddle + applicationList_FIELDNAME, joinIndex = @Index(name = TABLE
+ IndexNameMiddle + applicationList_FIELDNAME + JoinIndexNameSuffix))
@OrderColumn(name = AbstractPersistenceProperties.orderColumn)
@OrderColumn(name = ORDERCOLUMNCOLUMN)
@ElementColumn(length = length_255B, name = ColumnNamePrefix + applicationList_FIELDNAME)
@ElementIndex(name = TABLE + IndexNameMiddle + applicationList_FIELDNAME + ElementIndexNameSuffix)
@CheckPersist(allowEmpty = true)
......
......@@ -92,7 +92,7 @@ public class Statement extends SliceJpaObject {
@ContainerTable(name = TABLE + ContainerTableNameMiddle
+ executePersonList_FIELDNAME, joinIndex = @Index(name = TABLE + IndexNameMiddle
+ executePersonList_FIELDNAME + JoinIndexNameSuffix))
@OrderColumn(name = AbstractPersistenceProperties.orderColumn)
@OrderColumn(name = ORDERCOLUMNCOLUMN)
@ElementColumn(length = length_255B, name = ColumnNamePrefix + executePersonList_FIELDNAME)
@ElementIndex(name = TABLE + IndexNameMiddle + executePersonList_FIELDNAME + ElementIndexNameSuffix)
@CheckPersist(allowEmpty = true)
......@@ -103,7 +103,7 @@ public class Statement extends SliceJpaObject {
@PersistentCollection(fetch = FetchType.EAGER)
@ContainerTable(name = TABLE + ContainerTableNameMiddle + executeUnitList_FIELDNAME, joinIndex = @Index(name = TABLE
+ IndexNameMiddle + executeUnitList_FIELDNAME + JoinIndexNameSuffix))
@OrderColumn(name = AbstractPersistenceProperties.orderColumn)
@OrderColumn(name = ORDERCOLUMNCOLUMN)
@ElementColumn(length = length_255B, name = ColumnNamePrefix + executeUnitList_FIELDNAME)
@ElementIndex(name = TABLE + IndexNameMiddle + executeUnitList_FIELDNAME + ElementIndexNameSuffix)
@CheckPersist(allowEmpty = true)
......
......@@ -12,6 +12,8 @@ import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Lob;
import javax.persistence.OrderColumn;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;
import org.apache.commons.lang3.StringUtils;
......@@ -99,7 +101,7 @@ public class Table extends SliceJpaObject {
@PersistentCollection(fetch = FetchType.EAGER)
@ContainerTable(name = TABLE + ContainerTableNameMiddle + readPersonList_FIELDNAME, joinIndex = @Index(name = TABLE
+ IndexNameMiddle + readPersonList_FIELDNAME + JoinIndexNameSuffix))
@OrderColumn(name = AbstractPersistenceProperties.orderColumn)
@OrderColumn(name = ORDERCOLUMNCOLUMN)
@ElementColumn(length = length_255B, name = ColumnNamePrefix + readPersonList_FIELDNAME)
@ElementIndex(name = TABLE + IndexNameMiddle + readPersonList_FIELDNAME + ElementIndexNameSuffix)
@CheckPersist(allowEmpty = true)
......@@ -110,7 +112,7 @@ public class Table extends SliceJpaObject {
@PersistentCollection(fetch = FetchType.EAGER)
@ContainerTable(name = TABLE + ContainerTableNameMiddle + readUnitList_FIELDNAME, joinIndex = @Index(name = TABLE
+ IndexNameMiddle + readUnitList_FIELDNAME + JoinIndexNameSuffix))
@OrderColumn(name = AbstractPersistenceProperties.orderColumn)
@OrderColumn(name = ORDERCOLUMNCOLUMN)
@ElementColumn(length = length_255B, name = ColumnNamePrefix + readUnitList_FIELDNAME)
@ElementIndex(name = TABLE + IndexNameMiddle + readUnitList_FIELDNAME + ElementIndexNameSuffix)
@CheckPersist(allowEmpty = true)
......@@ -121,7 +123,7 @@ public class Table extends SliceJpaObject {
@PersistentCollection(fetch = FetchType.EAGER)
@ContainerTable(name = TABLE + ContainerTableNameMiddle + editPersonList_FIELDNAME, joinIndex = @Index(name = TABLE
+ IndexNameMiddle + editPersonList_FIELDNAME + JoinIndexNameSuffix))
@OrderColumn(name = AbstractPersistenceProperties.orderColumn)
@OrderColumn(name = ORDERCOLUMNCOLUMN)
@ElementColumn(length = length_255B, name = ColumnNamePrefix + editPersonList_FIELDNAME)
@ElementIndex(name = TABLE + IndexNameMiddle + editPersonList_FIELDNAME + ElementIndexNameSuffix)
@CheckPersist(allowEmpty = true)
......@@ -132,7 +134,7 @@ public class Table extends SliceJpaObject {
@PersistentCollection(fetch = FetchType.EAGER)
@ContainerTable(name = TABLE + ContainerTableNameMiddle + editUnitList_FIELDNAME, joinIndex = @Index(name = TABLE
+ IndexNameMiddle + editUnitList_FIELDNAME + JoinIndexNameSuffix))
@OrderColumn(name = AbstractPersistenceProperties.orderColumn)
@OrderColumn(name = ORDERCOLUMNCOLUMN)
@ElementColumn(length = length_255B, name = ColumnNamePrefix + editUnitList_FIELDNAME)
@ElementIndex(name = TABLE + IndexNameMiddle + editUnitList_FIELDNAME + ElementIndexNameSuffix)
@CheckPersist(allowEmpty = true)
......@@ -156,17 +158,6 @@ public class Table extends SliceJpaObject {
@Column(length = length_255B, name = ColumnNamePrefix + lastUpdatePerson_FIELDNAME)
private String lastUpdatePerson;
// public static final String controllerList_FIELDNAME = "controllerList";
// @FieldDescribe("表管理者")
// @PersistentCollection(fetch = FetchType.EAGER)
// @OrderColumn(name = PersistenceProperties.orderColumn)
// @ContainerTable(name = TABLE + ContainerTableNameMiddle
// + controllerList_FIELDNAME, joinIndex = @Index(name = TABLE + IndexNameMiddle + controllerList_FIELDNAME))
// @ElementColumn(length = length_255B, name = ColumnNamePrefix + controllerList_FIELDNAME)
// @ElementIndex(name = TABLE + IndexNameMiddle + controllerList_FIELDNAME + ElementIndexNameSuffix)
// @CheckPersist(allowEmpty = true)
// private List<String> controllerList;
public static final String data_FIELDNAME = "data";
@FieldDescribe("表结构方案.")
@Lob
......
......@@ -152,40 +152,6 @@ public abstract class Plan extends GsonPropertyObject {
return calculateRow;
}
// /*
// * 分类计算输出格式 [ { "group": "报销申请", "list": [ { "column":
// * "C7AC7F427FC0000141704670375F79F0", "displayName": "金额", "value": 1000 } ]
// },
// * { "group": "项目经理审批", "list": [ { "column":
// * "C7AC7F427FC0000141704670375F79F0", "displayName": "金额", "value": 1110 } ]
// }
// * ]
// */
// private CalculateGroupTable calculateGroup() throws Exception {
// CalculateGroupTable calculateGroupTable = new CalculateGroupTable();
// for (GroupRow groupRow : this.groupGrid) {
// List<CalculateCell> list = new TreeList<>();
// for (CalculateEntry entry : calculate.calculateList) {
// switch (entry.calculateType) {
// case CALCULATE_SUM:
// list.add(new CalculateCell(entry, entry.sum(groupRow.list)));
// break;
// case CALCULATE_AVERAGE:
// list.add(new CalculateCell(entry, entry.average(groupRow.list)));
// break;
// default:
// list.add(new CalculateCell(entry, entry.count(groupRow.list)));
// break;
// }
// }
// CalculateGroupRow calculateGroupRow = new CalculateGroupRow();
// calculateGroupRow.group = groupRow.group;
// calculateGroupRow.list = list;
// calculateGroupTable.add(calculateGroupRow);
// }
// return calculateGroupTable;
// }
@SuppressWarnings({ "rawtypes", "unchecked" })
private GroupTable group(Table table) throws Exception {
final String orderType = (null == this.group) ? SelectEntry.ORDER_ORIGINAL : this.group.orderType;
......@@ -517,8 +483,9 @@ public abstract class Plan extends GsonPropertyObject {
p = cb.and(p, cb.or(cb.isNull(root.get(Item_.path7)), cb.equal(root.get(Item_.path7), "")));
}
cq.multiselect(root.get(Item_.bundle), root.get(Item_.itemPrimitiveType), root.get(Item_.itemStringValueType),
root.get(Item_.stringShortValue), root.get(Item_.dateValue), root.get(Item_.timeValue),
root.get(Item_.dateTimeValue), root.get(Item_.booleanValue), root.get(Item_.numberValue)).where(p);
root.get(Item_.stringShortValue), root.get(Item_.stringLongValue), root.get(Item_.dateValue),
root.get(Item_.timeValue), root.get(Item_.dateTimeValue), root.get(Item_.booleanValue),
root.get(Item_.numberValue)).where(p);
List<Tuple> list = em.createQuery(cq).getResultList();
Row row = null;
for (Tuple o : list) {
......@@ -528,36 +495,40 @@ public abstract class Plan extends GsonPropertyObject {
switch (ItemStringValueType.valueOf(Objects.toString(o.get(2)))) {
case s:
if (null != o.get(3)) {
row.put(selectEntry.getColumn(), Objects.toString(o.get(3)));
if (StringUtils.isNotEmpty(Objects.toString(o.get(4)))) {
row.put(selectEntry.getColumn(), Objects.toString(o.get(4)));
} else {
row.put(selectEntry.getColumn(), Objects.toString(o.get(3)));
}
}
break;
case d:
if (null != o.get(4)) {
row.put(selectEntry.getColumn(), JpaObjectTools.confirm((Date) o.get(4)));
}
break;
case t:
if (null != o.get(5)) {
row.put(selectEntry.getColumn(), JpaObjectTools.confirm((Date) o.get(5)));
}
break;
case dt:
case t:
if (null != o.get(6)) {
row.put(selectEntry.getColumn(), JpaObjectTools.confirm((Date) o.get(6)));
}
break;
case dt:
if (null != o.get(7)) {
row.put(selectEntry.getColumn(), JpaObjectTools.confirm((Date) o.get(7)));
}
break;
default:
break;
}
break;
case b:
if (null != o.get(7)) {
row.put(selectEntry.getColumn(), (Boolean) o.get(7));
if (null != o.get(8)) {
row.put(selectEntry.getColumn(), (Boolean) o.get(8));
}
break;
case n:
if (null != o.get(8)) {
row.put(selectEntry.getColumn(), (Number) o.get(8));
if (null != o.get(9)) {
row.put(selectEntry.getColumn(), (Number) o.get(9));
}
break;
default:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册