提交 7f113cb6 编写于 作者: O o2null

Merge branch 'fix/statement' into 'develop'

fix statement

See merge request o2oa/o2oa!453
......@@ -22,20 +22,29 @@ import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.gson.GsonPropertyObject;
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.designer.Business;
import com.x.query.core.entity.schema.Statement;
import com.x.query.core.entity.schema.Table;
class ActionGetEntityProperties extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionGetEntityProperties.class);
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String entity, String entityCategory)
throws Exception {
LOGGER.debug("execute:{}, entity:{}, entityCategory:{}.", effectivePerson::getDistinguishedName, () -> entity,
() -> entityCategory);
ClassLoader classLoader = Business.getDynamicEntityClassLoader();
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
if (!business.controllable(effectivePerson)) {
throw new ExceptionAccessDenied(effectivePerson);
}
Class<? extends JpaObject> cls = this.clazz(business, entity, entityCategory);
Class<? extends JpaObject> cls = this.clazz(business, classLoader, entity, entityCategory);
result.setData(this.getEntityDes(cls, true, false));
return result;
}
......@@ -72,12 +81,13 @@ class ActionGetEntityProperties extends BaseAction {
}
@SuppressWarnings("unchecked")
private Class<? extends JpaObject> clazz(Business business, String entity, String entityCategory) throws Exception {
private Class<? extends JpaObject> clazz(Business business, ClassLoader classLoader, String entity,
String entityCategory) throws Exception {
Class<? extends JpaObject> cls = null;
if (StringUtils.equals(Statement.ENTITYCATEGORY_OFFICIAL, entityCategory)
|| StringUtils.equals(Statement.ENTITYCATEGORY_CUSTOM, entityCategory)) {
try {
cls = (Class<? extends JpaObject>) Thread.currentThread().getContextClassLoader().loadClass(entity);
cls = (Class<? extends JpaObject>) classLoader.loadClass(entity);
} catch (Exception e) {
throw new ExceptionEntityNotExist(entity, entityCategory);
}
......@@ -88,8 +98,7 @@ class ActionGetEntityProperties extends BaseAction {
}
DynamicEntity dynamicEntity = new DynamicEntity(table.getName());
try {
cls = (Class<? extends JpaObject>) Thread.currentThread().getContextClassLoader()
.loadClass(dynamicEntity.className());
cls = (Class<? extends JpaObject>) classLoader.loadClass(dynamicEntity.className());
} catch (Exception e) {
throw new ExceptionEntityNotExist(entity, entityCategory);
}
......
......@@ -19,6 +19,8 @@ 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.WoId;
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.core.entity.Query;
......@@ -26,7 +28,13 @@ import com.x.query.core.entity.schema.Statement;
import com.x.query.core.entity.schema.Table;
class ActionCreate extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionCreate.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
LOGGER.debug("execute;{}.", effectivePerson::getDistinguishedName);
ClassLoader classLoader = Business.getDynamicEntityClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Business business = new Business(emc);
......@@ -45,12 +53,11 @@ class ActionCreate extends BaseAction {
statement.setTable(table.getId());
} else {
try {
Thread.currentThread().getContextClassLoader().loadClass(statement.getEntityClassName());
classLoader.loadClass(statement.getEntityClassName());
} catch (Exception e) {
throw new ExceptionEntityClass(statement.getEntityClassName());
}
}
if (!business.editable(effectivePerson, query)) {
throw new ExceptionAccessDenied(effectivePerson, query);
}
......@@ -77,6 +84,8 @@ class ActionCreate extends BaseAction {
public static class Wo extends WoId {
private static final long serialVersionUID = -6780522841538599608L;
}
public static class Wi extends Statement {
......
......@@ -8,12 +8,20 @@ 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.WoId;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.query.assemble.designer.Business;
import com.x.query.core.entity.Query;
import com.x.query.core.entity.schema.Statement;
class ActionDelete extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionDelete.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
LOGGER.debug("execute;{}, flag:{}.", effectivePerson::getDistinguishedName, () -> flag);
ClassLoader classLoader = Business.getDynamicEntityClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Business business = new Business(emc);
......
......@@ -29,9 +29,12 @@ import com.x.query.core.entity.schema.Table;
class ActionEdit extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionEdit.class);
private static final Logger LOGGER = LoggerFactory.getLogger(ActionEdit.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag, JsonElement jsonElement) throws Exception {
LOGGER.debug("execute;{}, flag:{}.", effectivePerson::getDistinguishedName, () -> flag);
ClassLoader classLoader = Business.getDynamicEntityClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Business business = new Business(emc);
......@@ -58,7 +61,7 @@ class ActionEdit extends BaseAction {
statement.setTable(table.getId());
} else {
try {
Thread.currentThread().getContextClassLoader().loadClass(statement.getEntityClassName());
classLoader.loadClass(statement.getEntityClassName());
} catch (Exception e) {
throw new ExceptionEntityClass(statement.getEntityClassName());
}
......@@ -86,6 +89,8 @@ class ActionEdit extends BaseAction {
public static class Wo extends WoId {
private static final long serialVersionUID = 2191345451588705624L;
}
public static class Wi extends Statement {
......
......@@ -23,10 +23,14 @@ import com.x.query.core.entity.schema.Statement;
class ActionEditPermission extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionEditPermission.class);
private static final Logger LOGGER = LoggerFactory.getLogger(ActionEditPermission.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag, JsonElement jsonElement) throws Exception {
logger.debug(effectivePerson.getDistinguishedName());
LOGGER.debug("execute:{}, flag:{}.", effectivePerson::getDistinguishedName, () -> flag);
ClassLoader classLoader = Business.getDynamicEntityClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Business business = new Business(emc);
......@@ -60,6 +64,8 @@ class ActionEditPermission extends BaseAction {
public static class Wo extends WoId {
private static final long serialVersionUID = -272543657827689218L;
}
public static class Wi extends Statement {
......
......@@ -19,6 +19,8 @@ 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.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.script.AbstractResources;
import com.x.base.core.project.scripting.JsonScriptingExecutor;
import com.x.base.core.project.scripting.ScriptingFactory;
......@@ -34,9 +36,16 @@ class ActionExecute extends BaseAction {
private static final String[] pageKeys = { "GROUP BY", " COUNT(" };
private static final Logger LOGGER = LoggerFactory.getLogger(ActionExecute.class);
ActionResult<Object> execute(EffectivePerson effectivePerson, String flag, Integer page, Integer size,
JsonElement jsonElement) throws Exception {
LOGGER.debug("execute:{}, flag:{}, page:{}, size:{}.", effectivePerson::getDistinguishedName, () -> flag,
() -> page, () -> size);
ClassLoader classLoader = Business.getDynamicEntityClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Object> result = new ActionResult<>();
Business business = new Business(emc);
......@@ -53,9 +62,9 @@ class ActionExecute extends BaseAction {
Object data = null;
if (StringUtils.equalsIgnoreCase(statement.getFormat(), Statement.FORMAT_SCRIPT)) {
data = this.script(effectivePerson, business, statement, runtime);
data = this.script(effectivePerson, business, classLoader, statement, runtime);
} else {
data = this.jpql(business, statement, runtime);
data = this.jpql(business, classLoader, statement, runtime);
}
result.setData(data);
......@@ -63,13 +72,13 @@ class ActionExecute extends BaseAction {
}
}
private Object script(EffectivePerson effectivePerson, Business business, Statement statement, Runtime runtime)
throws Exception {
private Object script(EffectivePerson effectivePerson, Business business, ClassLoader classLoader,
Statement statement, Runtime runtime) throws Exception {
Object data = null;
ScriptContext scriptContext = this.scriptContext(effectivePerson, runtime);
CompiledScript cs = ScriptingFactory.functionalizationCompile(statement.getScriptText());
String text = JsonScriptingExecutor.evalString(cs, scriptContext);
Class<? extends JpaObject> cls = this.clazz(business, statement);
Class<? extends JpaObject> cls = this.clazz(business, classLoader, statement);
EntityManager em;
if (StringUtils.equalsIgnoreCase(statement.getEntityCategory(), Statement.ENTITYCATEGORY_DYNAMIC)
&& StringUtils.equalsIgnoreCase(statement.getType(), Statement.TYPE_SELECT)) {
......@@ -97,9 +106,10 @@ class ActionExecute extends BaseAction {
return data;
}
private Object jpql(Business business, Statement statement, Runtime runtime) throws Exception {
private Object jpql(Business business, ClassLoader classLoader, Statement statement, Runtime runtime)
throws Exception {
Object data = null;
Class<? extends JpaObject> cls = this.clazz(business, statement);
Class<? extends JpaObject> cls = this.clazz(business, classLoader, statement);
EntityManager em;
if (StringUtils.equalsIgnoreCase(statement.getEntityCategory(), Statement.ENTITYCATEGORY_DYNAMIC)
&& StringUtils.equalsIgnoreCase(statement.getType(), Statement.TYPE_SELECT)) {
......@@ -137,20 +147,20 @@ class ActionExecute extends BaseAction {
return true;
}
private Class<? extends JpaObject> clazz(Business business, Statement statement) throws Exception {
@SuppressWarnings("unchecked")
private Class<? extends JpaObject> clazz(Business business, ClassLoader classLoader, Statement statement)
throws Exception {
Class<? extends JpaObject> cls = null;
if (StringUtils.equals(Statement.ENTITYCATEGORY_OFFICIAL, statement.getEntityCategory())
|| StringUtils.equals(Statement.ENTITYCATEGORY_CUSTOM, statement.getEntityCategory())) {
cls = (Class<? extends JpaObject>) Thread.currentThread().getContextClassLoader()
.loadClass(statement.getEntityClassName());
cls = (Class<? extends JpaObject>) classLoader.loadClass(statement.getEntityClassName());
} else {
Table table = business.entityManagerContainer().flag(statement.getTable(), Table.class);
if (null == table) {
throw new ExceptionEntityNotExist(statement.getTable(), Table.class);
}
DynamicEntity dynamicEntity = new DynamicEntity(table.getName());
cls = (Class<? extends JpaObject>) Thread.currentThread().getContextClassLoader()
.loadClass(dynamicEntity.className());
cls = (Class<? extends JpaObject>) classLoader.loadClass(dynamicEntity.className());
}
return cls;
}
......
......@@ -48,6 +48,11 @@ class ActionExecuteV2 extends BaseAction {
ActionResult<Object> execute(EffectivePerson effectivePerson, String flag, String mode, Integer page, Integer size,
JsonElement jsonElement) throws Exception {
LOGGER.debug("execute:{}, flag:{}, page:{}, size:{}.", effectivePerson::getDistinguishedName, () -> flag,
() -> page, () -> size);
ClassLoader classLoader = Business.getDynamicEntityClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Object> result = new ActionResult<>();
Business business = new Business(emc);
......@@ -67,10 +72,10 @@ class ActionExecuteV2 extends BaseAction {
case Statement.MODE_DATA:
switch (Objects.toString(statement.getFormat(), "")) {
case Statement.FORMAT_SCRIPT:
data = this.script(effectivePerson, business, statement, runtime, mode);
data = this.script(effectivePerson, business, classLoader, statement, runtime, mode);
break;
default:
data = this.jpql(business, statement, runtime, mode);
data = this.jpql(business, classLoader, statement, runtime, mode);
break;
}
result.setData(data);
......@@ -78,10 +83,10 @@ class ActionExecuteV2 extends BaseAction {
case Statement.MODE_COUNT:
switch (Objects.toString(statement.getFormat(), "")) {
case Statement.FORMAT_SCRIPT:
count = this.script(effectivePerson, business, statement, runtime, mode);
count = this.script(effectivePerson, business, classLoader, statement, runtime, mode);
break;
default:
count = this.jpql(business, statement, runtime, mode);
count = this.jpql(business, classLoader, statement, runtime, mode);
break;
}
result.setData(count);
......@@ -90,12 +95,13 @@ class ActionExecuteV2 extends BaseAction {
default:
switch (Objects.toString(statement.getFormat(), "")) {
case Statement.FORMAT_SCRIPT:
data = this.script(effectivePerson, business, statement, runtime, Statement.MODE_DATA);
count = this.script(effectivePerson, business, statement, runtime, Statement.MODE_COUNT);
data = this.script(effectivePerson, business, classLoader, statement, runtime, Statement.MODE_DATA);
count = this.script(effectivePerson, business, classLoader, statement, runtime,
Statement.MODE_COUNT);
break;
default:
data = this.jpql(business, statement, runtime, Statement.MODE_DATA);
count = this.jpql(business, statement, runtime, Statement.MODE_COUNT);
data = this.jpql(business, classLoader, statement, runtime, Statement.MODE_DATA);
count = this.jpql(business, classLoader, statement, runtime, Statement.MODE_COUNT);
break;
}
result.setData(data);
......@@ -105,8 +111,8 @@ class ActionExecuteV2 extends BaseAction {
}
}
private Object script(EffectivePerson effectivePerson, Business business, Statement statement, Runtime runtime,
String mode) throws Exception {
private Object script(EffectivePerson effectivePerson, Business business, ClassLoader classLoader,
Statement statement, Runtime runtime, String mode) throws Exception {
Object data = null;
ScriptContext scriptContext = this.scriptContext(effectivePerson, runtime);
String scriptText = statement.getScriptText();
......@@ -115,7 +121,7 @@ class ActionExecuteV2 extends BaseAction {
}
CompiledScript cs = ScriptingFactory.functionalizationCompile(scriptText);
String jpql = JsonScriptingExecutor.evalString(cs, scriptContext);
Class<? extends JpaObject> cls = this.clazz(business, statement);
Class<? extends JpaObject> cls = this.clazz(business, classLoader, statement);
EntityManager em;
if (StringUtils.equalsIgnoreCase(statement.getEntityCategory(), Statement.ENTITYCATEGORY_DYNAMIC)
&& StringUtils.equalsIgnoreCase(statement.getType(), Statement.TYPE_SELECT)) {
......@@ -155,9 +161,10 @@ class ActionExecuteV2 extends BaseAction {
return data;
}
private Object jpql(Business business, Statement statement, Runtime runtime, String mode) throws Exception {
private Object jpql(Business business, ClassLoader classLoader, Statement statement, Runtime runtime, String mode)
throws Exception {
Object data = null;
Class<? extends JpaObject> cls = this.clazz(business, statement);
Class<? extends JpaObject> cls = this.clazz(business, classLoader, statement);
EntityManager em;
if (StringUtils.equalsIgnoreCase(statement.getEntityCategory(), Statement.ENTITYCATEGORY_DYNAMIC)
&& StringUtils.equalsIgnoreCase(statement.getType(), Statement.TYPE_SELECT)) {
......@@ -217,20 +224,20 @@ class ActionExecuteV2 extends BaseAction {
return true;
}
private Class<? extends JpaObject> clazz(Business business, Statement statement) throws Exception {
@SuppressWarnings("unchecked")
private Class<? extends JpaObject> clazz(Business business, ClassLoader classLoader, Statement statement)
throws Exception {
Class<? extends JpaObject> cls = null;
if (StringUtils.equals(Statement.ENTITYCATEGORY_OFFICIAL, statement.getEntityCategory())
|| StringUtils.equals(Statement.ENTITYCATEGORY_CUSTOM, statement.getEntityCategory())) {
cls = (Class<? extends JpaObject>) Thread.currentThread().getContextClassLoader()
.loadClass(statement.getEntityClassName());
cls = (Class<? extends JpaObject>) classLoader.loadClass(statement.getEntityClassName());
} else {
Table table = business.entityManagerContainer().flag(statement.getTable(), Table.class);
if (null == table) {
throw new ExceptionEntityNotExist(statement.getTable(), Table.class);
}
DynamicEntity dynamicEntity = new DynamicEntity(table.getName());
cls = (Class<? extends JpaObject>) Thread.currentThread().getContextClassLoader()
.loadClass(dynamicEntity.className());
cls = (Class<? extends JpaObject>) classLoader.loadClass(dynamicEntity.className());
}
return cls;
}
......
......@@ -9,12 +9,22 @@ 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.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.query.assemble.designer.Business;
import com.x.query.core.entity.Query;
import com.x.query.core.entity.schema.Statement;
class ActionGet extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionGet.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
LOGGER.debug("execute:{}, flag:{}.", effectivePerson::getDistinguishedName, () -> flag);
ClassLoader classLoader = Business.getDynamicEntityClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Business business = new Business(emc);
......
......@@ -11,13 +11,23 @@ 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.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.core.entity.Query;
import com.x.query.core.entity.schema.Statement;
class ActionListWithQuery extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionListWithQuery.class);
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String flag) throws Exception {
LOGGER.debug("execute:{}, flag:{}.", effectivePerson::getDistinguishedName, () -> flag);
ClassLoader classLoader = Business.getDynamicEntityClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
......
......@@ -10,11 +10,21 @@ 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.designer.Business;
import com.x.query.core.entity.schema.Statement;
class ActionManageList extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionManageList.class);
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson) throws Exception {
LOGGER.debug("execute:{}.", effectivePerson::getDistinguishedName);
ClassLoader classLoader = Business.getDynamicEntityClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
......
......@@ -31,7 +31,6 @@ class ActionExecute extends BaseAction {
LOGGER.debug("execute:{}.", effectivePerson::getDistinguishedName);
ClassLoader classLoader = Business.getDynamicEntityClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
Thread.currentThread().setContextClassLoader(Business.getDynamicEntityClassLoader());
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Object> result = new ActionResult<>();
Business business = new Business(emc);
......
......@@ -24,6 +24,8 @@ 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.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.script.AbstractResources;
import com.x.base.core.project.scripting.JsonScriptingExecutor;
import com.x.base.core.project.scripting.ScriptingFactory;
......@@ -37,11 +39,18 @@ import com.x.query.core.express.statement.Runtime;
class ActionExecute extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionExecute.class);
private static final String[] pageKeys = { "GROUP BY", " COUNT(" };
ActionResult<Object> execute(EffectivePerson effectivePerson, String flag, Integer page, Integer size,
JsonElement jsonElement) throws Exception {
LOGGER.debug("execute:{}, flag:{}, page:{}, size:{}.", effectivePerson::getDistinguishedName, () -> flag,
() -> page, () -> size);
ClassLoader classLoader = Business.getDynamicEntityClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
ActionResult<Object> result = new ActionResult<>();
Statement statement = this.getStatement(flag);
if (null == statement) {
......
......@@ -24,6 +24,8 @@ 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.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.script.AbstractResources;
import com.x.base.core.project.scripting.JsonScriptingExecutor;
import com.x.base.core.project.scripting.ScriptingFactory;
......@@ -36,12 +38,19 @@ import com.x.query.core.entity.schema.Table;
import com.x.query.core.express.statement.Runtime;
class ActionExecuteNative extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionExecuteNative.class);
private static final String[] pageKeys = { "GROUP BY", " COUNT(" };
ActionResult<Object> execute(EffectivePerson effectivePerson, String flag, Integer page, Integer size,
JsonElement jsonElement) throws Exception {
LOGGER.debug("execute:{}, flag:{}, page:{}, size:{}.", effectivePerson::getDistinguishedName, () -> flag,
() -> page, () -> size);
ClassLoader classLoader = Business.getDynamicEntityClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
ActionResult<Object> result = new ActionResult<>();
Statement statement = this.getStatement(flag);
if (null == statement) {
......
......@@ -56,6 +56,12 @@ class ActionExecuteV2 extends BaseAction {
ActionResult<Object> execute(EffectivePerson effectivePerson, String flag, String mode, Integer page, Integer size,
JsonElement jsonElement) throws Exception {
LOGGER.debug("execute:{}, flag:{}, page:{}, size:{}.", effectivePerson::getDistinguishedName, () -> flag,
() -> page, () -> size);
ClassLoader classLoader = Business.getDynamicEntityClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
Statement statement = null;
ActionResult<Object> result = new ActionResult<>();
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
......
......@@ -9,12 +9,22 @@ 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.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.query.assemble.surface.Business;
import com.x.query.core.entity.Query;
import com.x.query.core.entity.schema.Statement;
class ActionGet extends BaseAction {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionGet.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String flag) throws Exception {
LOGGER.debug("execute:{}, flag:{}.", effectivePerson::getDistinguishedName, () -> flag);
ClassLoader classLoader = Business.getDynamicEntityClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<Wo> result = new ActionResult<>();
Business business = new Business(emc);
......
......@@ -18,6 +18,8 @@ import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.gson.GsonPropertyObject;
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.SortTools;
import com.x.query.assemble.surface.Business;
import com.x.query.core.entity.Query;
......@@ -25,7 +27,16 @@ import com.x.query.core.entity.View;
import com.x.query.core.entity.schema.Statement;
class ActionListWithQuery extends BaseAction {
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String queryFlag, JsonElement jsonElement) throws Exception {
private static final Logger LOGGER = LoggerFactory.getLogger(ActionGet.class);
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String queryFlag, JsonElement jsonElement)
throws Exception {
LOGGER.debug("execute:{}, queryFlag:{}.", effectivePerson::getDistinguishedName, () -> queryFlag);
ClassLoader classLoader = Business.getDynamicEntityClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
ActionResult<List<Wo>> result = new ActionResult<>();
Business business = new Business(emc);
......@@ -41,10 +52,10 @@ class ActionListWithQuery extends BaseAction {
for (String id : emc.idsEqual(Statement.class, Statement.query_FIELDNAME, query.getId())) {
Statement o = business.pick(id, Statement.class);
if (null != o) {
if(BooleanUtils.isTrue(wi.getHasView()) && StringUtils.isBlank(o.getView())){
if (BooleanUtils.isTrue(wi.getHasView()) && StringUtils.isBlank(o.getView())) {
continue;
}
if(BooleanUtils.isTrue(wi.getJustSelect()) && !Statement.TYPE_SELECT.equals(o.getType())){
if (BooleanUtils.isTrue(wi.getJustSelect()) && !Statement.TYPE_SELECT.equals(o.getType())) {
continue;
}
if (business.readable(effectivePerson, o)) {
......@@ -58,7 +69,7 @@ class ActionListWithQuery extends BaseAction {
}
}
public static class Wi extends GsonPropertyObject{
public static class Wi extends GsonPropertyObject {
@FieldDescribe("是否只查询select语句.")
private Boolean justSelect;
......
......@@ -20,6 +20,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
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.annotation.CheckPersistType;
import com.x.base.core.project.cache.Cache.CacheKey;
import com.x.base.core.project.cache.CacheManager;
......@@ -88,7 +89,7 @@ abstract class BaseAction extends StandardJaxrsAction {
private void setProcessEdition(ProcessPlatformPlan processPlatformPlan) throws Exception {
if (!processPlatformPlan.where.processList.isEmpty()) {
List<String> processIds = ListTools.extractField(processPlatformPlan.where.processList,
Process.id_FIELDNAME, String.class, true, true);
JpaObject.id_FIELDNAME, String.class, true, true);
List<Process> processList;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册