diff --git a/etl/src/main/java/com/orientechnologies/orient/etl/block/OETLCodeBlock.java b/etl/src/main/java/com/orientechnologies/orient/etl/block/OETLCodeBlock.java index c554401f9c4..ecd74669b95 100644 --- a/etl/src/main/java/com/orientechnologies/orient/etl/block/OETLCodeBlock.java +++ b/etl/src/main/java/com/orientechnologies/orient/etl/block/OETLCodeBlock.java @@ -19,8 +19,6 @@ package com.orientechnologies.orient.etl.block; import com.orientechnologies.orient.core.command.OCommandContext; -import com.orientechnologies.orient.core.command.script.OCommandExecutorScript; -import com.orientechnologies.orient.core.command.script.OCommandScript; import com.orientechnologies.orient.core.record.impl.ODocument; import java.util.HashMap; import java.util.Map; @@ -29,7 +27,6 @@ public class OETLCodeBlock extends OETLAbstractBlock { protected String language = "javascript"; protected String code; - protected OCommandExecutorScript cmd; protected Map params = new HashMap(); @Override @@ -48,8 +45,6 @@ public void configure(final ODocument iConfiguration, OCommandContext iContext) if (iConfiguration.containsField("code")) code = iConfiguration.field("code"); else throw new IllegalArgumentException("'code' parameter is mandatory in Code Transformer"); - - cmd = new OCommandExecutorScript().parse(new OCommandScript(language, code)); } @Override @@ -59,6 +54,6 @@ public String getName() { @Override public Object executeBlock() { - return cmd.executeInContext(context, params); + return context.getDatabase().execute(language, code, (Map) params); } } diff --git a/etl/src/main/java/com/orientechnologies/orient/etl/listener/OETLScriptImporterListener.java b/etl/src/main/java/com/orientechnologies/orient/etl/listener/OETLScriptImporterListener.java index 70709ce5993..f6dccd99c45 100644 --- a/etl/src/main/java/com/orientechnologies/orient/etl/listener/OETLScriptImporterListener.java +++ b/etl/src/main/java/com/orientechnologies/orient/etl/listener/OETLScriptImporterListener.java @@ -19,7 +19,6 @@ package com.orientechnologies.orient.etl.listener; import com.orientechnologies.orient.core.command.OCommandContext; -import com.orientechnologies.orient.core.command.script.OCommandScript; import com.orientechnologies.orient.core.db.document.ODatabaseDocument; import com.orientechnologies.orient.core.index.OIndex; import com.orientechnologies.orient.core.record.impl.ODocument; @@ -28,7 +27,6 @@ public class OETLScriptImporterListener implements OETLImporterListener { private final Map events; - private Map scripts = new HashMap(); public OETLScriptImporterListener() { events = new HashMap(); @@ -78,23 +76,14 @@ private Object executeEvent( final ODatabaseDocument db, final String iEventName, final OCommandContext iContext) { if (events == null) return null; - OCommandScript script = scripts.get(iEventName); + final String code = events.get(iEventName); - if (script == null) { - final String code = events.get(iEventName); - if (code != null) { - // CACHE IT - script = new OCommandScript(code).setLanguage("Javascript"); - scripts.put(iEventName, script); - } - } - - if (script != null) { + if (code != null) { final Map pars = new HashMap(); pars.put("task", iContext); pars.put("importer", this); - return db.command(script).execute(pars); + return db.execute("javascript", code, pars); } return null; } diff --git a/etl/src/main/java/com/orientechnologies/orient/etl/transformer/OETLCodeTransformer.java b/etl/src/main/java/com/orientechnologies/orient/etl/transformer/OETLCodeTransformer.java index e78a502c91f..d00efcfaba1 100644 --- a/etl/src/main/java/com/orientechnologies/orient/etl/transformer/OETLCodeTransformer.java +++ b/etl/src/main/java/com/orientechnologies/orient/etl/transformer/OETLCodeTransformer.java @@ -19,8 +19,6 @@ package com.orientechnologies.orient.etl.transformer; import com.orientechnologies.orient.core.command.OCommandContext; -import com.orientechnologies.orient.core.command.script.OCommandExecutorScript; -import com.orientechnologies.orient.core.command.script.OCommandScript; import com.orientechnologies.orient.core.db.document.ODatabaseDocument; import com.orientechnologies.orient.core.db.record.OIdentifiable; import com.orientechnologies.orient.core.record.impl.ODocument; @@ -31,7 +29,7 @@ public class OETLCodeTransformer extends OETLAbstractTransformer { private final Map params = new HashMap(); private String language = "javascript"; - private OCommandExecutorScript cmd; + private String code = null; @Override public ODocument getConfiguration() { @@ -53,8 +51,7 @@ public void configure(final ODocument iConfiguration, OCommandContext iContext) String code; if (iConfiguration.containsField("code")) code = iConfiguration.field("code"); else throw new IllegalArgumentException("'code' parameter is mandatory in Code Transformer"); - - cmd = new OCommandExecutorScript().parse(new OCommandScript(language, code)); + this.code = code; } @Override @@ -70,14 +67,14 @@ public Object executeTransform(ODatabaseDocument db, final Object input) { if (input instanceof OIdentifiable) params.put("record", ((OIdentifiable) input).getRecord()); try { - Object result = cmd.executeInContext(context, params); + Object result = context.getDatabase().execute(language, code, params); - debug("executed code=%s, result=%s", cmd, result); + debug("executed code=%s, result=%s", code, result); return result; } catch (Exception e) { - error("exception=%s - input=%s - command=%s ", e.getMessage(), input, cmd); + error("exception=%s - input=%s - command=%s ", e.getMessage(), input, code); throw e; } diff --git a/tools/src/main/java/com/orientechnologies/orient/console/OConsoleDatabaseApp.java b/tools/src/main/java/com/orientechnologies/orient/console/OConsoleDatabaseApp.java index df2df18f361..c21a39399f5 100755 --- a/tools/src/main/java/com/orientechnologies/orient/console/OConsoleDatabaseApp.java +++ b/tools/src/main/java/com/orientechnologies/orient/console/OConsoleDatabaseApp.java @@ -42,8 +42,6 @@ import com.orientechnologies.orient.core.OSignalHandler; import com.orientechnologies.orient.core.Orient; import com.orientechnologies.orient.core.command.OCommandOutputListener; -import com.orientechnologies.orient.core.command.script.OCommandExecutorScript; -import com.orientechnologies.orient.core.command.script.OCommandScript; import com.orientechnologies.orient.core.config.OGlobalConfiguration; import com.orientechnologies.orient.core.config.OStorageConfiguration; import com.orientechnologies.orient.core.config.OStorageEntryConfiguration; @@ -1340,10 +1338,7 @@ public void js( long start = System.currentTimeMillis(); while (true) { try { - final OCommandExecutorScript cmd = new OCommandExecutorScript(); - cmd.parse(new OCommandScript("Javascript", iText)); - - currentResult = cmd.execute(null); + currentResult = getCurrentDatabase().execute("javascript", iText); break; } catch (ORetryQueryException e) { continue;