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

增加动态表

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