提交 61f9c9eb 编写于 作者: R Ray

update eval

上级 3ae00039
......@@ -170,3 +170,4 @@ typings/
**/nbproject/
*.lock
*.checkstyle
o2server/test.sh
......@@ -20,6 +20,7 @@ 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.script.AbstractResources;
import com.x.base.core.project.scripting.JsonScriptingExecutor;
import com.x.base.core.project.scripting.ScriptingFactory;
import com.x.base.core.project.tools.DateTools;
import com.x.base.core.project.webservices.WebservicesClient;
......@@ -76,7 +77,7 @@ class ActionExecute extends BaseAction {
}
try {
compiledScript.eval(scriptContext);
JsonScriptingExecutor.eval(compiledScript, scriptContext);
} catch (Exception e) {
throw new ExceptionAgentEval(e, e.getMessage(), agent.getId(), agent.getName(),
agent.getAlias(), agent.getText());
......
......@@ -69,9 +69,6 @@ class ActionExecute extends BaseAction {
ScriptContext scriptContext = this.scriptContext(effectivePerson, runtime);
CompiledScript cs = ScriptingFactory.functionalizationCompile(statement.getScriptText());
String text = JsonScriptingExecutor.evalString(cs, scriptContext);
// Object o = ScriptFactory.scriptEngine.eval(ScriptFactory.functionalization(statement.getScriptText()),
// scriptContext);
// String text = ScriptFactory.asString(o);
Class<? extends JpaObject> cls = this.clazz(business, statement);
EntityManager em;
if (StringUtils.equalsIgnoreCase(statement.getEntityCategory(), Statement.ENTITYCATEGORY_DYNAMIC)
......
......@@ -114,8 +114,6 @@ class ActionExecuteV2 extends BaseAction {
}
CompiledScript cs = ScriptingFactory.functionalizationCompile(scriptText);
String jpql = JsonScriptingExecutor.evalString(cs, scriptContext);
// Object o = ScriptFactory.scriptEngine.eval(ScriptFactory.functionalization(scriptText), scriptContext);
// String jpql = ScriptFactory.asString(o);
Class<? extends JpaObject> cls = this.clazz(business, statement);
EntityManager em;
if (StringUtils.equalsIgnoreCase(statement.getEntityCategory(), Statement.ENTITYCATEGORY_DYNAMIC)
......
......@@ -20,6 +20,8 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Order;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.script.CompiledScript;
import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import javax.script.ScriptException;
......@@ -35,6 +37,7 @@ import com.x.base.core.entity.tools.JpaObjectTools;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.gson.GsonPropertyObject;
import com.x.base.core.project.organization.OrganizationDefinition;
import com.x.base.core.project.scripting.JsonScriptingExecutor;
import com.x.base.core.project.scripting.ScriptingFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.query.core.entity.Item;
......@@ -256,9 +259,10 @@ public abstract class Plan extends GsonPropertyObject {
}
Table table = this.order(fillTable);
/* 新增测试 */
if (!this.selectList.emptyColumnCode()) {
ScriptEngine engine = this.getScriptEngine();
engine.put("gird", table);
if (BooleanUtils.isFalse(this.selectList.emptyColumnCode())) {
// ScriptEngine engine = this.getScriptEngine();
ScriptContext scriptContext = ScriptingFactory.scriptContextEvalInitialScript();
scriptContext.getBindings(ScriptContext.ENGINE_SCOPE).put("gird", table);
for (SelectEntry selectEntry : this.selectList) {
if (StringUtils.isNotBlank(selectEntry.code)) {
List<ExtractObject> extractObjects = new TreeList<>();
......@@ -270,8 +274,8 @@ public abstract class Plan extends GsonPropertyObject {
extractObject.setEntry(r);
extractObjects.add(extractObject);
});
engine.put("extractObjects", extractObjects);
StringBuffer text = new StringBuffer();
scriptContext.getBindings(ScriptContext.ENGINE_SCOPE).put("extractObjects", extractObjects);
StringBuilder text = new StringBuilder();
text.append("function executeScript(o){\n");
text.append(selectEntry.code);
text.append("\n");
......@@ -284,7 +288,9 @@ public abstract class Plan extends GsonPropertyObject {
text.append("}\n");
text.append("extractObject.setValue(executeScript.apply(o));\n");
text.append("}");
engine.eval(text.toString());
// engine.eval(text.toString());
CompiledScript cs = ScriptingFactory.compile(text.toString());
JsonScriptingExecutor.eval(cs, scriptContext);
for (ExtractObject extractObject : extractObjects) {
table.get(extractObject.getBundle()).put(extractObject.getColumn(), extractObject.getValue());
}
......@@ -595,7 +601,6 @@ public abstract class Plan extends GsonPropertyObject {
private ScriptEngine getScriptEngine() throws ScriptException, Exception {
if (null == this.scriptEngine) {
scriptEngine = ScriptingFactory.newScriptEngine();
// scriptEngine.eval(Config.mooToolsScriptText());
}
return scriptEngine;
}
......
......@@ -434,7 +434,7 @@ public class Generate {
List<String> attachments = ListTools.extractProperty(attachmentObjects, Attachment.name_FIELDNAME,
String.class, true, true);
scriptContext.getBindings(ScriptContext.ENGINE_SCOPE).put(BaseAction.PROPERTY_ATTACHMENTS, attachments);
attachmentCompiledScript.eval(scriptContext);
JsonScriptingExecutor.eval(attachmentCompiledScript, scriptContext);
attachmentObjects = ListTools.removePropertyNotIn(attachmentObjects, Attachment.name_FIELDNAME,
attachments);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册