提交 41295b26 编写于 作者: R roo00

bug fix 动态表数据删除失败

上级 27d7d1be
package com.x.query.assemble.designer;
package com.x.base.core.entity.dynamic;
import java.io.File;
import java.util.Date;
......@@ -39,19 +39,20 @@ import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.SliceJpaObject;
import com.x.base.core.entity.annotation.CheckPersist;
import com.x.base.core.entity.annotation.ContainerEntity;
import com.x.base.core.entity.dynamic.DynamicEntity.BooleanField;
import com.x.base.core.entity.dynamic.DynamicEntity.DateField;
import com.x.base.core.entity.dynamic.DynamicEntity.DateTimeField;
import com.x.base.core.entity.dynamic.DynamicEntity.DoubleField;
import com.x.base.core.entity.dynamic.DynamicEntity.Field;
import com.x.base.core.entity.dynamic.DynamicEntity.IntegerField;
import com.x.base.core.entity.dynamic.DynamicEntity.LongField;
import com.x.base.core.entity.dynamic.DynamicEntity.StringField;
import com.x.base.core.entity.dynamic.DynamicEntity.StringLobField;
import com.x.base.core.entity.dynamic.DynamicEntity.StringMapField;
import com.x.base.core.entity.dynamic.DynamicEntity.TimeField;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.tools.ListTools;
import com.x.query.assemble.designer.DynamicEntity.BooleanField;
import com.x.query.assemble.designer.DynamicEntity.DateField;
import com.x.query.assemble.designer.DynamicEntity.DateTimeField;
import com.x.query.assemble.designer.DynamicEntity.DoubleField;
import com.x.query.assemble.designer.DynamicEntity.Field;
import com.x.query.assemble.designer.DynamicEntity.IntegerField;
import com.x.query.assemble.designer.DynamicEntity.LongField;
import com.x.query.assemble.designer.DynamicEntity.StringField;
import com.x.query.assemble.designer.DynamicEntity.StringLobField;
import com.x.query.assemble.designer.DynamicEntity.StringMapField;
import com.x.query.assemble.designer.DynamicEntity.TimeField;
public class DynamicEntityBuilder {
......
......@@ -13,6 +13,7 @@ import com.google.gson.reflect.TypeToken;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.dynamic.DynamicEntity;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.gson.XGsonBuilder;
......@@ -20,7 +21,6 @@ import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.scripting.ScriptingEngine;
import com.x.query.assemble.designer.Business;
import com.x.query.assemble.designer.DynamicEntity;
import com.x.query.core.entity.schema.Statement;
import com.x.query.core.entity.schema.Table;
......@@ -53,12 +53,21 @@ class ActionExecute extends BaseAction {
this.beforeScript(business, effectivePerson, statement, parameter);
DynamicEntity dynamicEntity = new DynamicEntity(table.getName());
EntityManager em = emc.get((Class<JpaObject>) Class.forName(dynamicEntity.className()));
@SuppressWarnings("unchecked")
Class<? extends JpaObject> cls = (Class<JpaObject>) Class.forName(dynamicEntity.className());
EntityManager em = emc.get(cls);
Query query = em.createQuery(statement.getData());
for (Entry<String, Object> en : parameter.entrySet()) {
query.setParameter(en.getKey(), en.getValue());
}
Object data = query.getResultList();
Object data = null;
if (StringUtils.equalsIgnoreCase(statement.getType(), Statement.TYPE_SELECT)) {
data = query.getResultList();
} else {
emc.beginTransaction(cls);
data = query.executeUpdate();
emc.commit();
}
if (StringUtils.isNotBlank(statement.getAfterScriptText())) {
this.initScriptingEngine(business, effectivePerson);
scriptingEngine.bindingData(data);
......@@ -81,7 +90,6 @@ class ActionExecute extends BaseAction {
private void initScriptingEngine(Business business, EffectivePerson effectivePerson) {
if (null == this.scriptingEngine) {
this.scriptingEngine = business.createScriptEngine().bindingEffectivePerson(effectivePerson);
}
}
......
package com.x.query.assemble.designer.jaxrs.table;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
......@@ -20,6 +22,8 @@ import org.apache.commons.lang3.SystemUtils;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.dynamic.DynamicEntity;
import com.x.base.core.entity.dynamic.DynamicEntityBuilder;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.gson.XGsonBuilder;
......@@ -31,8 +35,6 @@ import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.DefaultCharset;
import com.x.base.core.project.tools.JarTools;
import com.x.query.assemble.designer.Business;
import com.x.query.assemble.designer.DynamicEntity;
import com.x.query.assemble.designer.DynamicEntityBuilder;
import com.x.query.core.entity.schema.Enhance;
import com.x.query.core.entity.schema.Table;
......@@ -76,19 +78,7 @@ class ActionBuildAll extends BaseAction {
Iterable<JavaFileObject> res = fileManager.list(StandardLocation.SOURCE_PATH, DynamicEntity.CLASS_PACKAGE,
EnumSet.of(JavaFileObject.Kind.SOURCE), true);
compiler.getTask(null, fileManager, null, null, null, res).call();
// URLClassLoader urlClassLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
// Class<?> urlClass = URLClassLoader.class;
// Method method = urlClass.getDeclaredMethod("addURL", new Class[] { URL.class });
// method.setAccessible(true);
//
// method.invoke(urlClassLoader, new Object[] { target.toURI().toURL() });
//
// Collection<File> files = FileUtils.listFiles(target, FileFilterUtils.suffixFileFilter(DOT_CLASS),
// DirectoryFileFilter.INSTANCE);
//
// for (File f : files) {
// PCEnhancer.main(new String[] { f.getAbsolutePath() });
// }
fileManager.close();
this.enhance();
......@@ -122,14 +112,28 @@ class ActionBuildAll extends BaseAction {
paths.add(Config.dir_commons_ext().getAbsolutePath() + File.separator + "*");
paths.add(Config.dir_local_temp_dynamic_target().getAbsolutePath());
String command = commandJavaFile.getAbsolutePath() + " -cp \"" + StringUtils.join(paths, File.pathSeparator)
+ "\" " + Enhance.class.getName();
String command = commandJavaFile.getAbsolutePath() + " -classpath \""
+ StringUtils.join(paths, File.pathSeparator) + "\" " + Enhance.class.getName() + " \""
+ Config.dir_local_temp_dynamic_target() + "\"";
logger.debug("enhance command:{}.", command);
Process process = Runtime.getRuntime().exec(command);
ProcessBuilder processBuilder = new ProcessBuilder();
if (SystemUtils.IS_OS_AIX) {
processBuilder.command("sh", "-c", command);
} else if (SystemUtils.IS_OS_LINUX) {
processBuilder.command("sh", "-c", command);
} else if (SystemUtils.IS_OS_MAC) {
processBuilder.command("sh", "-c", command);
} else {
processBuilder.command("cmd", "/c", command);
}
Process process = processBuilder.start();
process.waitFor();
}
public static class Wo extends WrapBoolean {
......
......@@ -9,6 +9,7 @@ import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.entity.dynamic.DynamicEntity;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
......@@ -21,7 +22,6 @@ import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.tools.ListTools;
import com.x.query.assemble.designer.Business;
import com.x.query.assemble.designer.DynamicEntity;
import com.x.query.core.entity.schema.Table;
class ActionCreate extends BaseAction {
......
......@@ -9,6 +9,7 @@ import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.entity.dynamic.DynamicEntity;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.cache.ApplicationCache;
......@@ -22,7 +23,6 @@ import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.tools.ListTools;
import com.x.query.assemble.designer.Business;
import com.x.query.assemble.designer.DynamicEntity;
import com.x.query.core.entity.schema.Statement;
import com.x.query.core.entity.schema.Table;
......
......@@ -12,6 +12,7 @@ import com.google.gson.JsonObject;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.dynamic.DynamicEntity;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.gson.XGsonBuilder;
......@@ -21,7 +22,6 @@ import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
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 ActionListRowNext extends BaseAction {
......
......@@ -13,6 +13,7 @@ import com.google.gson.JsonObject;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.dynamic.DynamicEntity;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.gson.XGsonBuilder;
......@@ -22,7 +23,6 @@ import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
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 ActionListRowPrev extends BaseAction {
......
......@@ -9,12 +9,12 @@ import org.apache.commons.lang3.StringUtils;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.dynamic.DynamicEntity;
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.query.assemble.designer.Business;
import com.x.query.assemble.designer.DynamicEntity;
import com.x.query.core.entity.schema.Table;
class ActionListRowSelectWhere extends BaseAction {
......
......@@ -7,13 +7,13 @@ import org.apache.commons.lang3.StringUtils;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.dynamic.DynamicEntity;
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 ActionRowCountWhere extends BaseAction {
......
......@@ -3,13 +3,13 @@ package com.x.query.assemble.designer.jaxrs.table;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.dynamic.DynamicEntity;
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.WrapBoolean;
import com.x.query.assemble.designer.Business;
import com.x.query.assemble.designer.DynamicEntity;
import com.x.query.core.entity.schema.Table;
class ActionRowDelete extends BaseAction {
......
......@@ -11,13 +11,13 @@ 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.entity.dynamic.DynamicEntity;
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 {
......
......@@ -12,6 +12,7 @@ import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.dynamic.DynamicEntity;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.http.ActionResult;
......@@ -20,7 +21,6 @@ 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 {
......
......@@ -3,12 +3,12 @@ package com.x.query.assemble.designer.jaxrs.table;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.dynamic.DynamicEntity;
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.query.assemble.designer.Business;
import com.x.query.assemble.designer.DynamicEntity;
import com.x.query.core.entity.schema.Table;
class ActionRowGet extends BaseAction {
......
......@@ -8,13 +8,13 @@ import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.entity.dynamic.DynamicEntity;
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.WrapBoolean;
import com.x.query.assemble.designer.Business;
import com.x.query.assemble.designer.DynamicEntity;
import com.x.query.core.entity.schema.Table;
class ActionRowInsert extends BaseAction {
......
......@@ -5,6 +5,7 @@ import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.entity.dynamic.DynamicEntity;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.gson.XGsonBuilder;
......@@ -12,7 +13,6 @@ import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapBoolean;
import com.x.query.assemble.designer.Business;
import com.x.query.assemble.designer.DynamicEntity;
import com.x.query.core.entity.schema.Table;
class ActionRowUpdate extends BaseAction {
......
......@@ -129,26 +129,6 @@
"description": "lbf2"
}
],
"listDateFieldList": [
{
"name": "ldtf1",
"description": "ldtf1"
},
{
"name": "ldtf2",
"description": "ldtf2"
}
],
"listTimeFieldList": [
{
"name": "ltf1",
"description": "ltf1"
},
{
"name": "ltf2",
"description": "ltf2"
}
],
"listDateTimeFieldList": [
{
"name": "ldttf1",
......
package com.x.query.assemble.surface;
import java.util.List;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -8,7 +10,10 @@ import com.x.base.core.entity.JpaObject;
import com.x.base.core.project.cache.ApplicationCache;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.organization.OrganizationDefinition;
import com.x.base.core.project.scripting.Scripting;
import com.x.base.core.project.scripting.ScriptingEngine;
import com.x.base.core.project.tools.ListTools;
import com.x.base.core.project.webservices.WebservicesClient;
import com.x.organization.core.express.Organization;
import com.x.query.assemble.surface.factory.QueryFactory;
import com.x.query.assemble.surface.factory.RevealFactory;
......@@ -18,6 +23,8 @@ import com.x.query.core.entity.Query;
import com.x.query.core.entity.Reveal;
import com.x.query.core.entity.Stat;
import com.x.query.core.entity.View;
import com.x.query.core.entity.schema.Statement;
import com.x.query.core.entity.schema.Table;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
......@@ -103,6 +110,13 @@ public class Business {
}
}
public ScriptingEngine createScriptEngine() {
ScriptingEngine engine = Scripting.getEngine();
engine.bindingOrganization(this.organization);
engine.bindingWebservicesClient(new WebservicesClient());
return engine;
}
public boolean readable(EffectivePerson effectivePerson, Query query) throws Exception {
if (null == query) {
return false;
......@@ -221,4 +235,86 @@ public class Business {
}
return false;
}
public boolean readable(EffectivePerson effectivePerson, Table o) throws Exception {
boolean result = false;
if (null != o) {
if (ListTools.isEmpty(o.getReadPersonList()) && ListTools.isEmpty(o.getReadUnitList())) {
result = true;
}
if (!result) {
if (effectivePerson.isManager() || (this.organization().person().hasRole(effectivePerson,
OrganizationDefinition.Manager, OrganizationDefinition.QueryManager))) {
result = true;
}
if (!result) {
if (effectivePerson.isUser(o.getEditPersonList())
|| effectivePerson.isUser(o.getReadPersonList())) {
result = true;
}
if (!result && (ListTools.isNotEmpty(o.getEditUnitList())
|| ListTools.isNotEmpty(o.getReadUnitList()))) {
List<String> units = this.organization().unit()
.listWithPerson(effectivePerson.getDistinguishedName());
if (ListTools.containsAny(units, o.getEditUnitList())
|| ListTools.containsAny(units, o.getReadUnitList())) {
result = true;
}
}
}
}
}
return result;
}
public boolean editable(EffectivePerson effectivePerson, Table o) throws Exception {
boolean result = false;
if (effectivePerson.isManager() || (this.organization().person().hasRole(effectivePerson,
OrganizationDefinition.Manager, OrganizationDefinition.QueryManager))) {
result = true;
}
if (!result && (null != o)) {
if (ListTools.isEmpty(o.getEditPersonList()) && ListTools.isEmpty(o.getEditUnitList())) {
result = true;
if (!result) {
if (effectivePerson.isUser(o.getEditPersonList())) {
result = true;
}
if (!result && ListTools.isNotEmpty(o.getEditUnitList())) {
List<String> units = this.organization().unit()
.listWithPerson(effectivePerson.getDistinguishedName());
if (ListTools.containsAny(units, o.getEditUnitList())) {
result = true;
}
}
}
}
}
return result;
}
public boolean executable(EffectivePerson effectivePerson, Statement o) throws Exception {
boolean result = false;
if (null != o) {
if (ListTools.isEmpty(o.getExecutePersonList()) && ListTools.isEmpty(o.getExecuteUnitList())) {
result = true;
}
if (!result) {
if (effectivePerson.isManager()
|| (this.organization().person().hasRole(effectivePerson, OrganizationDefinition.Manager,
OrganizationDefinition.QueryManager))
|| effectivePerson.isUser(o.getExecutePersonList())) {
result = true;
}
if ((!result) && ListTools.isNotEmpty(o.getExecuteUnitList())) {
List<String> units = this.organization().unit()
.listWithPerson(effectivePerson.getDistinguishedName());
if (ListTools.containsAny(units, o.getExecuteUnitList())) {
result = true;
}
}
}
}
return result;
}
}
\ No newline at end of file
......@@ -10,6 +10,8 @@ import com.x.query.assemble.surface.jaxrs.query.QueryAction;
import com.x.query.assemble.surface.jaxrs.reveal.RevealAction;
import com.x.query.assemble.surface.jaxrs.segment.SegmentAction;
import com.x.query.assemble.surface.jaxrs.stat.StatAction;
import com.x.query.assemble.surface.jaxrs.statement.StatementAction;
import com.x.query.assemble.surface.jaxrs.table.TableAction;
import com.x.query.assemble.surface.jaxrs.test.TestAction;
import com.x.query.assemble.surface.jaxrs.view.ViewAction;
......@@ -24,6 +26,8 @@ public class ActionApplication extends AbstractActionApplication {
classes.add(TestAction.class);
classes.add(SegmentAction.class);
classes.add(NeuralAction.class);
classes.add(TableAction.class);
classes.add(StatementAction.class);
return classes;
}
......
package com.x.query.assemble.surface.jaxrs;
import javax.servlet.annotation.WebFilter;
import com.x.base.core.project.jaxrs.AnonymousCipherManagerUserJaxrsFilter;
@WebFilter(urlPatterns = "/jaxrs/statement/*", asyncSupported = true)
public class StatementJaxrsFilter extends AnonymousCipherManagerUserJaxrsFilter {
}
package com.x.query.assemble.surface.jaxrs;
import javax.servlet.annotation.WebFilter;
import com.x.base.core.project.jaxrs.AnonymousCipherManagerUserJaxrsFilter;
@WebFilter(urlPatterns = "/jaxrs/table/*", asyncSupported = true)
public class TableJaxrsFilter extends AnonymousCipherManagerUserJaxrsFilter {
}
package com.x.query.assemble.surface.jaxrs.statement;
import java.util.Map;
import java.util.Map.Entry;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonElement;
import com.google.gson.reflect.TypeToken;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.dynamic.DynamicEntity;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.gson.XGsonBuilder;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.scripting.ScriptingEngine;
import com.x.query.assemble.surface.Business;
import com.x.query.core.entity.schema.Statement;
import com.x.query.core.entity.schema.Table;
class ActionExecute extends BaseAction {
private ScriptingEngine scriptingEngine;
ActionResult<Object> execute(EffectivePerson effectivePerson, String flag, JsonElement jsonElement)
throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Object> result = new ActionResult<>();
Business business = new Business(emc);
Statement statement = emc.flag(flag, Statement.class);
if (null == statement) {
throw new ExceptionEntityNotExist(flag, Statement.class);
}
if (!business.executable(effectivePerson, statement)) {
throw new ExceptionAccessDenied(effectivePerson, statement);
}
Table table = emc.find(statement.getTable(), Table.class);
if (null == table) {
throw new ExceptionEntityNotExist(statement.getTable(), Table.class);
}
Map<String, Object> parameter = XGsonBuilder.instance().fromJson(jsonElement,
new TypeToken<Map<String, Object>>() {
}.getType());
this.beforeScript(business, effectivePerson, statement, parameter);
DynamicEntity dynamicEntity = new DynamicEntity(table.getName());
@SuppressWarnings("unchecked")
EntityManager em = emc.get((Class<JpaObject>) Class.forName(dynamicEntity.className()));
Query query = em.createQuery(statement.getData());
for (Entry<String, Object> en : parameter.entrySet()) {
query.setParameter(en.getKey(), en.getValue());
}
Object data = query.getResultList();
if (StringUtils.isNotBlank(statement.getAfterScriptText())) {
this.initScriptingEngine(business, effectivePerson);
scriptingEngine.bindingData(data);
data = scriptingEngine.eval(statement.getAfterScriptText());
}
result.setData(data);
return result;
}
}
private void beforeScript(Business business, EffectivePerson effectivePerson, Statement statement,
Map<String, Object> parameter) throws Exception {
if (StringUtils.isNotBlank(statement.getBeforeScriptText())) {
this.initScriptingEngine(business, effectivePerson);
scriptingEngine.bindingParameter(parameter);
scriptingEngine.eval(statement.getBeforeScriptText());
}
}
private void initScriptingEngine(Business business, EffectivePerson effectivePerson) {
if (null == this.scriptingEngine) {
this.scriptingEngine = business.createScriptEngine().bindingEffectivePerson(effectivePerson);
}
}
}
\ No newline at end of file
package com.x.query.assemble.surface.jaxrs.statement;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
abstract class BaseAction extends StandardJaxrsAction {
}
package com.x.query.assemble.surface.jaxrs.statement;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import com.google.gson.JsonElement;
import com.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
import com.x.base.core.project.annotation.JaxrsParameterDescribe;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.HttpMediaType;
import com.x.base.core.project.jaxrs.ResponseFactory;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
@Path("statement")
@JaxrsDescribe("语句")
public class StatementAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(StatementAction.class);
@JaxrsMethodDescribe(value = "执行语句.", action = ActionExecute.class)
@POST
@Path("{flag}/execute")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void execute(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("flag") String flag, JsonElement jsonElement) {
ActionResult<Object> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionExecute().execute(effectivePerson, flag, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
}
\ No newline at end of file
package com.x.query.assemble.surface.jaxrs.table;
import java.util.List;
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.annotation.FieldDescribe;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.query.assemble.surface.Business;
import com.x.query.core.entity.schema.Table;
class ActionListNext extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionListNext.class);
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String id, Integer count) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
logger.debug(effectivePerson, "id:{}, count:{}.", id, count);
Business business = new Business(emc);
if (!business.editable(effectivePerson, new Table())) {
throw new ExceptionAccessDenied(effectivePerson.getDistinguishedName());
}
ActionResult<List<Wo>> result = new ActionResult<>();
result = this.standardListNext(Wo.copier, id, count, JpaObject.sequence_FIELDNAME, null, null, null, null, null, null, null,
null, true, DESC);
return result;
}
}
public static class Wo extends Table {
private static final long serialVersionUID = 2886873983211744188L;
static WrapCopier<Table, Wo> copier = WrapCopierFactory.wo(Table.class, Wo.class,
JpaObject.singularAttributeField(Table.class, true, true), null);
@FieldDescribe("排序号")
private Long rank;
public Long getRank() {
return rank;
}
public void setRank(Long rank) {
this.rank = rank;
}
}
}
package com.x.query.assemble.surface.jaxrs.table;
import java.util.List;
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.annotation.FieldDescribe;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.query.assemble.surface.Business;
import com.x.query.core.entity.schema.Table;
class ActionListPrev extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionListPrev.class);
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String id, Integer count) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
logger.debug(effectivePerson, "id:{}, count:{}.", id, count);
Business business = new Business(emc);
if (!business.editable(effectivePerson, new Table())) {
throw new ExceptionAccessDenied(effectivePerson.getDistinguishedName());
}
ActionResult<List<Wo>> result = new ActionResult<>();
result = this.standardFetchAttributeListPrev(emc, Wo.copier, id, count, JpaObject.sequence_FIELDNAME, null,
null, null, null, null, null, null, true, DESC);
return result;
}
}
public static class Wo extends Table {
private static final long serialVersionUID = 2886873983211744188L;
static WrapCopier<Table, Wo> copier = WrapCopierFactory.wo(Table.class, Wo.class,
JpaObject.singularAttributeField(Table.class, true, true), null);
@FieldDescribe("排序号")
private Long rank;
public Long getRank() {
return rank;
}
public void setRank(Long rank) {
this.rank = rank;
}
}
}
package com.x.query.assemble.surface.jaxrs.table;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonObject;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.dynamic.DynamicEntity;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.gson.XGsonBuilder;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.query.assemble.surface.Business;
import com.x.query.core.entity.schema.Table;
class ActionListRowNext extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionListRowNext.class);
ActionResult<List<JsonObject>> execute(EffectivePerson effectivePerson, String tableFlag, String id, Integer count)
throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<JsonObject>> result = new ActionResult<>();
logger.debug(effectivePerson, "table:{}, id:{}, count:{}.", tableFlag, id, count);
Business business = new Business(emc);
Table table = emc.flag(tableFlag, Table.class);
if (null == table) {
throw new ExceptionEntityNotExist(tableFlag, Table.class);
}
if (!business.readable(effectivePerson, table)) {
throw new ExceptionAccessDenied(effectivePerson.getDistinguishedName());
}
DynamicEntity dynamicEntity = new DynamicEntity(table.getName());
Class<? extends JpaObject> cls = dynamicEntity.getObjectClass();
EntityManager em = emc.get(cls);
Object sequence = null;
if (!StringUtils.equals(EMPTY_SYMBOL, id)) {
JpaObject o = emc.fetch(id, cls, ListTools.toList(JpaObject.sequence_FIELDNAME));
if (null != o) {
sequence = o.getSequence();
}
}
List<String> fields = JpaObject.singularAttributeField(cls, true, true);
fields.add(JpaObject.sequence_FIELDNAME);
List<String> selects = new ArrayList<>();
for (String str : fields) {
selects.add("o." + str);
}
String sql = "select " + StringUtils.join(selects, ", ") + " from " + cls.getName() + " o";
Long rank = 0L;
if (null != sequence) {
sql += " where o." + JpaObject.sequence_FIELDNAME + " < ?1";
rank = emc.countGreaterThanOrEqualTo(cls, JpaObject.sequence_FIELDNAME, sequence);
}
sql += " order by o." + JpaObject.sequence_FIELDNAME + " DESC";
Query query = em.createQuery(sql, Object[].class);
if (null != sequence) {
query.setParameter(1, sequence);
}
List<Object[]> list = query.setMaxResults(Math.max(Math.min(count, list_max), list_min)).getResultList();
List<JsonObject> wos = new ArrayList<>();
result.setCount(emc.count(cls));
for (Object[] os : list) {
JsonObject jsonObject = XGsonBuilder.instance().toJsonTree(JpaObject.cast(cls, fields, os))
.getAsJsonObject();
jsonObject.getAsJsonObject().addProperty("rank", ++rank);
wos.add(jsonObject);
}
result.setData(wos);
return result;
}
}
}
package com.x.query.assemble.surface.jaxrs.table;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.JsonObject;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.dynamic.DynamicEntity;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.gson.XGsonBuilder;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.query.assemble.surface.Business;
import com.x.query.core.entity.schema.Table;
class ActionListRowPrev extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionListRowPrev.class);
ActionResult<List<JsonObject>> execute(EffectivePerson effectivePerson, String tableFlag, String id, Integer count)
throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<JsonObject>> result = new ActionResult<>();
logger.debug(effectivePerson, "table:{}, id:{}, count:{}.", tableFlag, id, count);
Business business = new Business(emc);
Table table = emc.flag(tableFlag, Table.class);
if (null == table) {
throw new ExceptionEntityNotExist(tableFlag, Table.class);
}
if (!business.readable(effectivePerson, table)) {
throw new ExceptionAccessDenied(effectivePerson.getDistinguishedName());
}
DynamicEntity dynamicEntity = new DynamicEntity(table.getName());
Class<? extends JpaObject> cls = dynamicEntity.getObjectClass();
EntityManager em = emc.get(cls);
Object sequence = null;
if (!StringUtils.equals(EMPTY_SYMBOL, id)) {
JpaObject o = emc.fetch(id, cls, ListTools.toList(JpaObject.sequence_FIELDNAME));
if (null != o) {
sequence = o.getSequence();
}
}
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);
}
result.setCount(emc.count(cls));
String sql = "select " + StringUtils.join(selects, ", ") + " from " + cls.getName() + " o";
Long rank = 0L;
List<JsonObject> wos = new ArrayList<>();
if (null != sequence) {
sql += " where o." + JpaObject.sequence_FIELDNAME + " > ?1 order by o." + JpaObject.sequence_FIELDNAME
+ " ASC";
rank = emc.countGreaterThan(cls, JpaObject.sequence_FIELDNAME, sequence);
Query query = em.createQuery(sql, Object[].class);
query.setParameter(1, sequence);
List<Object[]> list = query.setMaxResults(Math.max(Math.min(count, list_max), list_min))
.getResultList();
for (Object[] os : list) {
JsonObject jsonObject = XGsonBuilder.instance().toJsonTree(JpaObject.cast(cls, fields, os))
.getAsJsonObject();
jsonObject.getAsJsonObject().addProperty("rank", rank--);
wos.add(jsonObject);
}
} else {
sql += " order by o." + JpaObject.sequence_FIELDNAME + " ASC";
rank = result.getCount();
Query query = em.createQuery(sql, Object[].class);
List<Object[]> list = query.setMaxResults(Math.max(Math.min(count, list_max), list_min))
.getResultList();
for (Object[] os : list) {
JsonObject jsonObject = XGsonBuilder.instance().toJsonTree(JpaObject.cast(cls, fields, os))
.getAsJsonObject();
jsonObject.getAsJsonObject().addProperty("rank", rank--);
wos.add(jsonObject);
}
}
Collections.reverse(wos);
result.setData(wos);
return result;
}
}
}
\ No newline at end of file
package com.x.query.assemble.surface.jaxrs.table;
import java.util.List;
import javax.persistence.EntityManager;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.dynamic.DynamicEntity;
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.query.assemble.surface.Business;
import com.x.query.core.entity.schema.Table;
class ActionListRowSelectWhere extends BaseAction {
ActionResult<List<?>> execute(EffectivePerson effectivePerson, String tableFlag, String where) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<?>> 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> clz = (Class<JpaObject>) Class.forName(dynamicEntity.className());
EntityManager em = emc.get(clz);
String sql = "SELECT o FROM " + clz.getName() + " o";
if (StringUtils.isNotBlank(where) && (!StringUtils.equals(where, EMPTY_SYMBOL))) {
sql += " where (" + where + ")";
}
List<?> list = em.createQuery(sql).getResultList();
result.setData(list);
return result;
}
}
}
\ No newline at end of file
package com.x.query.assemble.surface.jaxrs.table;
import javax.persistence.EntityManager;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.dynamic.DynamicEntity;
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.surface.Business;
import com.x.query.core.entity.schema.Table;
class ActionRowCountWhere extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String tableFlag, String where)
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());
EntityManager em = emc.get(cls);
String sql = "SELECT count(o) FROM " + cls.getName() + " o";
if (StringUtils.isNotBlank(where) && (!StringUtils.equals(where, EMPTY_SYMBOL))) {
sql += " where (" + where + ")";
}
Long count = (Long) em.createQuery(sql).getSingleResult();
Wo wo = new Wo();
wo.setValue(count);
result.setData(wo);
return result;
}
}
public static class Wo extends WrapLong {
}
}
\ No newline at end of file
package com.x.query.assemble.surface.jaxrs.table;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.dynamic.DynamicEntity;
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.WrapBoolean;
import com.x.query.assemble.surface.Business;
import com.x.query.core.entity.schema.Table;
class ActionRowDelete extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String tableFlag, String id) 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());
JpaObject o = emc.find(id, cls);
Wo wo = new Wo();
wo.setValue(false);
if (null != o) {
emc.beginTransaction(cls);
emc.remove(o);
emc.commit();
wo.setValue(true);
}
result.setData(wo);
return result;
}
}
public static class Wo extends WrapBoolean {
}
}
\ No newline at end of file
package com.x.query.assemble.surface.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.entity.dynamic.DynamicEntity;
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.surface.Business;
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.surface.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.entity.dynamic.DynamicEntity;
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.surface.Business;
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
package com.x.query.assemble.surface.jaxrs.table;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.dynamic.DynamicEntity;
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.query.assemble.surface.Business;
import com.x.query.core.entity.schema.Table;
class ActionRowGet extends BaseAction {
ActionResult<Object> execute(EffectivePerson effectivePerson, String tableFlag, String id) throws Exception {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Object> 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());
JpaObject o = emc.find(id, cls);
result.setData(o);
return result;
}
}
}
\ No newline at end of file
package com.x.query.assemble.surface.jaxrs.table;
import java.util.ArrayList;
import java.util.List;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.entity.dynamic.DynamicEntity;
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.WrapBoolean;
import com.x.query.assemble.surface.Business;
import com.x.query.core.entity.schema.Table;
class ActionRowInsert 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());
List<Object> os = new ArrayList<>();
if (jsonElement.isJsonArray()) {
jsonElement.getAsJsonArray().forEach(o -> {
os.add(gson.fromJson(o, cls));
});
} else if (jsonElement.isJsonObject()) {
os.add(gson.fromJson(jsonElement, cls));
}
emc.beginTransaction(cls);
for (Object o : os) {
emc.persist((JpaObject) o, CheckPersistType.all);
}
emc.commit();
Wo wo = new Wo();
if (os.isEmpty()) {
wo.setValue(false);
} else {
wo.setValue(true);
}
result.setData(wo);
return result;
}
}
public static class Wo extends WrapBoolean {
}
}
\ No newline at end of file
package com.x.query.assemble.surface.jaxrs.table;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.entity.dynamic.DynamicEntity;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.gson.XGsonBuilder;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapBoolean;
import com.x.query.assemble.surface.Business;
import com.x.query.core.entity.schema.Table;
class ActionRowUpdate extends BaseAction {
ActionResult<Wo> execute(EffectivePerson effectivePerson, String tableFlag, String id, 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());
JpaObject o = emc.find(id, cls);
Wo wo = new Wo();
wo.setValue(false);
if (null != o) {
JpaObject n = XGsonBuilder.instance().fromJson(jsonElement, cls);
n.copyTo(o, JpaObject.FieldsUnmodify);
emc.beginTransaction(cls);
emc.check(o, CheckPersistType.all);
emc.commit();
wo.setValue(true);
}
result.setData(wo);
return result;
}
}
public static class Wo extends WrapBoolean {
}
}
\ No newline at end of file
package com.x.query.assemble.surface.jaxrs.table;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
abstract class BaseAction extends StandardJaxrsAction {
}
package com.x.query.assemble.surface.jaxrs.table;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
import com.x.base.core.project.annotation.JaxrsParameterDescribe;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.HttpMediaType;
import com.x.base.core.project.jaxrs.ResponseFactory;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
@Path("table")
@JaxrsDescribe("表")
public class TableAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(TableAction.class);
@JaxrsMethodDescribe(value = "列示表对象,下一页.", action = ActionListNext.class)
@GET
@Path("list/{id}/next/{count}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listNext(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id,
@JaxrsParameterDescribe("数量") @PathParam("count") Integer count) {
ActionResult<List<ActionListNext.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListNext().execute(effectivePerson, id, count);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
@JaxrsMethodDescribe(value = "列示Stat对象,上一页.", action = ActionListPrev.class)
@GET
@Path("list/{id}/prev/{count}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listPrev(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("标识") @PathParam("id") String id,
@JaxrsParameterDescribe("数量") @PathParam("count") Integer count) {
ActionResult<List<ActionListPrev.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListPrev().execute(effectivePerson, id, count);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
@JaxrsMethodDescribe(value = "获取表中某一行数据", action = ActionRowGet.class)
@GET
@Path("{tableFlag}/row/{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void rowGet(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("表标识") @PathParam("tableFlag") String tableFlag,
@JaxrsParameterDescribe("行标识") @PathParam("id") String id) {
ActionResult<Object> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionRowGet().execute(effectivePerson, tableFlag, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
@JaxrsMethodDescribe(value = "通过where 获取表中的数据,格式为jpql语法,o.name='zhangsan'", action = ActionListRowSelectWhere.class)
@GET
@Path("list/{tableFlag}/row/select/where/{where}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listRowSelectWhere(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("表标识") @PathParam("tableFlag") String tableFlag,
@JaxrsParameterDescribe("where语句") @PathParam("where") String where) {
ActionResult<List<?>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListRowSelectWhere().execute(effectivePerson, tableFlag, where);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
@JaxrsMethodDescribe(value = "通过where 统计数量", action = ActionRowCountWhere.class)
@GET
@Path("{tableFlag}/row/count/where/{where}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void rowCountWhere(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("表标识") @PathParam("tableFlag") String tableFlag,
@JaxrsParameterDescribe("where语句") @PathParam("where") String where) {
ActionResult<ActionRowCountWhere.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionRowCountWhere().execute(effectivePerson, tableFlag, where);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
@JaxrsMethodDescribe(value = "指定表中插入数据.", action = ActionRowInsert.class)
@POST
@Path("{tableFlag}/row")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void rowInsert(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("表标识") @PathParam("tableFlag") String tableFlag, JsonElement jsonElement) {
ActionResult<ActionRowInsert.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionRowInsert().execute(effectivePerson, tableFlag, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
@JaxrsMethodDescribe(value = "更新指定表中指定行数据.", action = ActionRowUpdate.class)
@PUT
@Path("{tableFlag}/row/{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void rowUpdate(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("表标识") @PathParam("tableFlag") String tableFlag,
@JaxrsParameterDescribe("行标识") @PathParam("id") String id, JsonElement jsonElement) {
ActionResult<ActionRowUpdate.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionRowUpdate().execute(effectivePerson, tableFlag, id, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, jsonElement);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
@JaxrsMethodDescribe(value = "更新指定表中指定行数据.", action = ActionRowDelete.class)
@DELETE
@Path("{tableFlag}/row/{id}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void rowDelete(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("表标识") @PathParam("tableFlag") String tableFlag,
@JaxrsParameterDescribe("行标识") @PathParam("id") String id) {
ActionResult<ActionRowDelete.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionRowDelete().execute(effectivePerson, tableFlag, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
@JaxrsMethodDescribe(value = "更新指定表中指定行数据.", action = ActionRowDeleteAll.class)
@DELETE
@Path("{tableFlag}/row/delete/all")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void rowDeleteAll(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("表标识") @PathParam("tableFlag") String tableFlag) {
ActionResult<ActionRowDeleteAll.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionRowDeleteAll().execute(effectivePerson, tableFlag);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
@JaxrsMethodDescribe(value = "列示表中的行对象,下一页.", action = ActionListRowNext.class)
@GET
@Path("list/{tableFlag}/row/{id}/next/{count}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listRowNext(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("表标识") @PathParam("tableFlag") String tableFlag,
@JaxrsParameterDescribe("标识") @PathParam("id") String id,
@JaxrsParameterDescribe("数量") @PathParam("count") Integer count) {
ActionResult<List<JsonObject>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListRowNext().execute(effectivePerson, tableFlag, id, count);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
@JaxrsMethodDescribe(value = "列示表中的行对象,上一页.", action = ActionListRowPrev.class)
@GET
@Path("list/{tableFlag}/row/{id}/prev/{count}")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listRowPrev(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("表标识") @PathParam("tableFlag") String tableFlag,
@JaxrsParameterDescribe("标识") @PathParam("id") String id,
@JaxrsParameterDescribe("数量") @PathParam("count") Integer count) {
ActionResult<List<JsonObject>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionListRowPrev().execute(effectivePerson, tableFlag, id, count);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getDefaultActionResultResponse(result));
}
}
\ No newline at end of file
......@@ -9,15 +9,19 @@ import org.apache.commons.io.filefilter.FileFilterUtils;
import org.apache.openjpa.enhance.PCEnhancer;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
public class Enhance {
private static final String DOT_CLASS = ".class";
private static Logger logger = LoggerFactory.getLogger(Enhance.class);
public static void main(String... args) throws Exception {
Collection<File> files = FileUtils.listFiles(Config.dir_local_temp_dynamic_target(),
FileFilterUtils.suffixFileFilter(DOT_CLASS), DirectoryFileFilter.INSTANCE);
Collection<File> files = FileUtils.listFiles(new File(args[0]), FileFilterUtils.suffixFileFilter(DOT_CLASS),
DirectoryFileFilter.INSTANCE);
for (File f : files) {
PCEnhancer.main(new String[] { f.getAbsolutePath() });
......
......@@ -43,6 +43,11 @@ public class Statement extends SliceJpaObject {
private static final String TABLE = PersistenceProperties.Schema.Statement.table;
public static final String TYPE_SELECT = "select";
public static final String TYPE_DELETE = "delete";
public static final String TYPE_UPDATE = "update";
public static final String TYPE_INSERT = "insert";
public String getId() {
return id;
}
......@@ -86,13 +91,20 @@ public class Statement extends SliceJpaObject {
@CheckPersist(allowEmpty = true)
private String description;
public static final String type_FIELDNAME = "type";
@FieldDescribe("语句类型,insert,delete,update,select")
@Column(length = length_16B, name = ColumnNamePrefix + type_FIELDNAME)
@Index(name = TABLE + IndexNameMiddle + type_FIELDNAME)
@CheckPersist(allowEmpty = false)
private String type;
public static final String executePersonList_FIELDNAME = "executePersonList";
@FieldDescribe("可执行的用户.")
@PersistentCollection(fetch = FetchType.EAGER)
@ContainerTable(name = TABLE + ContainerTableNameMiddle
+ executePersonList_FIELDNAME, joinIndex = @Index(name = TABLE + IndexNameMiddle
+ executePersonList_FIELDNAME + JoinIndexNameSuffix))
@OrderColumn(name = ORDERCOLUMNCOLUMN)
@OrderColumn(name = ORDERCOLUMNCOLUMN)
@ElementColumn(length = length_255B, name = ColumnNamePrefix + executePersonList_FIELDNAME)
@ElementIndex(name = TABLE + IndexNameMiddle + executePersonList_FIELDNAME + ElementIndexNameSuffix)
@CheckPersist(allowEmpty = true)
......@@ -103,7 +115,7 @@ public class Statement extends SliceJpaObject {
@PersistentCollection(fetch = FetchType.EAGER)
@ContainerTable(name = TABLE + ContainerTableNameMiddle + executeUnitList_FIELDNAME, joinIndex = @Index(name = TABLE
+ IndexNameMiddle + executeUnitList_FIELDNAME + JoinIndexNameSuffix))
@OrderColumn(name = ORDERCOLUMNCOLUMN)
@OrderColumn(name = ORDERCOLUMNCOLUMN)
@ElementColumn(length = length_255B, name = ColumnNamePrefix + executeUnitList_FIELDNAME)
@ElementIndex(name = TABLE + IndexNameMiddle + executeUnitList_FIELDNAME + ElementIndexNameSuffix)
@CheckPersist(allowEmpty = true)
......@@ -254,4 +266,12 @@ public class Statement extends SliceJpaObject {
this.afterScriptText = afterScriptText;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
\ No newline at end of file
......@@ -495,7 +495,7 @@ public abstract class Plan extends GsonPropertyObject {
switch (ItemStringValueType.valueOf(Objects.toString(o.get(2)))) {
case s:
if (null != o.get(3)) {
if (StringUtils.isNotEmpty(Objects.toString(o.get(4)))) {
if ((null != o.get(4)) && 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)));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册