plugins/actions/eval/src/main/java/org/apache/hop/workflow/actions/eval/ActionEval.java
public boolean evaluate(
      Result result, IWorkflowEngine<WorkflowMeta> parentWorkflow, Result prevResult) {
    Context cx;
    Scriptable scope;

    cx = ContextFactory.getGlobal().enterContext();

    try {
      scope = cx.initStandardObjects(null);

      Long errors = new Long(result.getNrErrors());
      Long linesInput = new Long(result.getNrLinesInput());
      Long linesOutput = new Long(result.getNrLinesOutput());
      Long linesUpdated = new Long(result.getNrLinesUpdated());
      Long linesRejected = new Long(result.getNrLinesRejected());
      Long linesRead = new Long(result.getNrLinesRead());
      Long linesWritten = new Long(result.getNrLinesWritten());
      Long exitStatus = new Long(result.getExitStatus());
      Long filesRetrieved = new Long(result.getNrFilesRetrieved());
      Long nr = new Long(result.getEntryNr());

      scope.put("errors", scope, errors);
      scope.put("lines_input", scope, linesInput);
      scope.put("lines_output", scope, linesOutput);
      scope.put("lines_updated", scope, linesUpdated);
      scope.put("lines_rejected", scope, linesRejected);
      scope.put("lines_read", scope, linesRead);
      scope.put("lines_written", scope, linesWritten);
      scope.put("files_retrieved", scope, filesRetrieved);
      scope.put("exit_status", scope, exitStatus);
      scope.put("nr", scope, nr);
      scope.put("is_windows", scope, Boolean.valueOf(Const.isWindows()));
      scope.put("_entry_", scope, this); // Compatible
      scope.put("_action_", scope, this);
      scope.put("action", scope, this); // doc issue

      Object[] array = null;
      if (result.getRows() != null) {
        array = result.getRows().toArray();
      }

      scope.put("rows", scope, array);
      scope.put("parent_job", scope, parentWorkflow); // migration
      scope.put("parent_workflow", scope, parentWorkflow);
      scope.put("previous_result", scope, prevResult);
      scope.put("log", scope, getLogChannel());

      try {
        Object res = cx.evaluateString(scope, this.script, "<cmd>", 1, null);
        boolean retval = Context.toBoolean(res);
        result.setNrErrors(0);

        return retval;
      } catch (Exception e) {
        result.setNrErrors(1);
        logError(BaseMessages.getString(PKG, "ActionEval.CouldNotCompile", e.toString()));
        return false;
      }
    } catch (Exception e) {
      result.setNrErrors(1);
      logError(BaseMessages.getString(PKG, "ActionEval.ErrorEvaluating", e.toString()));
      return false;
    } finally {
      Context.exit();
    }
  }
/**
   * Evaluate the result of the execution of previous action.
   *
   * @param result The result to evaulate.
   * @param prevResult the previous result
   * @param parentWorkflow the parent workflow
   * @return The boolean result of the evaluation script.
   */
Evaluate the result of the execution of previous action.
@param result The result to evaulate.
@param prevResult the previous result
@param parentWorkflow the parent workflow
@return The boolean result of the evaluation script.
Evaluate the result of the execution of previous action . @param result The result to evaulate . @param prevResult the previous result @param parentWorkflow the parent workflow @return The boolean result of the evaluation script .
public boolean evaluate(
      Result result, IWorkflowEngine<WorkflowMeta> parentWorkflow, Result prevResult) {
    Context cx;
    Scriptable scope;
    cx = ContextFactory.getGlobal().enterContext();
    try {
      scope = cx.initStandardObjects(null);
      Long errors = new Long(result.getNrErrors());
      Long linesInput = new Long(result.getNrLinesInput());
      Long linesOutput = new Long(result.getNrLinesOutput());
      Long linesUpdated = new Long(result.getNrLinesUpdated());
      Long linesRejected = new Long(result.getNrLinesRejected());
      Long linesRead = new Long(result.getNrLinesRead());
      Long linesWritten = new Long(result.getNrLinesWritten());
      Long exitStatus = new Long(result.getExitStatus());
      Long filesRetrieved = new Long(result.getNrFilesRetrieved());
      Long nr = new Long(result.getEntryNr());
      scope.put("errors", scope, errors);
      scope.put("lines_input", scope, linesInput);
      scope.put("lines_output", scope, linesOutput);
      scope.put("lines_updated", scope, linesUpdated);
      scope.put("lines_rejected", scope, linesRejected);
      scope.put("lines_read", scope, linesRead);
      scope.put("lines_written", scope, linesWritten);
      scope.put("files_retrieved", scope, filesRetrieved);
      scope.put("exit_status", scope, exitStatus);
      scope.put("nr", scope, nr);
      scope.put("is_windows", scope, Boolean.valueOf(Const.isWindows()));
      scope.put("_entry_", scope, this); 
      scope.put("_action_", scope, this);
      scope.put("action", scope, this); 
      Object[] array = null;
      if (result.getRows() != null) {
        array = result.getRows().toArray();
      }
      scope.put("rows", scope, array);
      scope.put("parent_job", scope, parentWorkflow); 
      scope.put("parent_workflow", scope, parentWorkflow);
      scope.put("previous_result", scope, prevResult);
      scope.put("log", scope, getLogChannel());
      try {
        Object res = cx.evaluateString(scope, this.script, "<cmd>", 1, null);
        boolean retval = Context.toBoolean(res);
        result.setNrErrors(0);
        return retval;
      } catch (Exception e) {
        result.setNrErrors(1);
        logError(BaseMessages.getString(PKG, "ActionEval.CouldNotCompile", e.toString()));
        return false;
      }
    } catch (Exception e) {
      result.setNrErrors(1);
      logError(BaseMessages.getString(PKG, "ActionEval.ErrorEvaluating", e.toString()));
      return false;
    } finally {
      Context.exit();
    }
  }
public boolean evaluate ( Result result , IWorkflowEngine < WorkflowMeta > parentWorkflow , Result prevResult ) { Context cx ; Scriptable scope ; cx = ContextFactory . getGlobal ( ) . enterContext ( ) ; try { scope = cx . initStandardObjects ( null ) ; Long errors = new Long ( result . getNrErrors ( ) ) ; Long linesInput = new Long ( result . getNrLinesInput ( ) ) ; Long linesOutput = new Long ( result . getNrLinesOutput ( ) ) ; Long linesUpdated = new Long ( result . getNrLinesUpdated ( ) ) ; Long linesRejected = new Long ( result . getNrLinesRejected ( ) ) ; Long linesRead = new Long ( result . getNrLinesRead ( ) ) ; Long linesWritten = new Long ( result . getNrLinesWritten ( ) ) ; Long exitStatus = new Long ( result . getExitStatus ( ) ) ; Long filesRetrieved = new Long ( result . getNrFilesRetrieved ( ) ) ; Long nr = new Long ( result . getEntryNr ( ) ) ; scope . put ( "errors" , scope , errors ) ; scope . put ( "lines_input" , scope , linesInput ) ; scope . put ( "lines_output" , scope , linesOutput ) ; scope . put ( "lines_updated" , scope , linesUpdated ) ; scope . put ( "lines_rejected" , scope , linesRejected ) ; scope . put ( "lines_read" , scope , linesRead ) ; scope . put ( "lines_written" , scope , linesWritten ) ; scope . put ( "files_retrieved" , scope , filesRetrieved ) ; scope . put ( "exit_status" , scope , exitStatus ) ; scope . put ( "nr" , scope , nr ) ; scope . put ( "is_windows" , scope , Boolean . valueOf ( Const . isWindows ( ) ) ) ; scope . put ( "_entry_" , scope , this ) ; scope . put ( "_action_" , scope , this ) ; scope . put ( "action" , scope , this ) ; Object [ ] array = null ; if ( result . getRows ( ) != null ) { array = result . getRows ( ) . toArray ( ) ; } scope . put ( "rows" , scope , array ) ; scope . put ( "parent_job" , scope , parentWorkflow ) ; scope . put ( "parent_workflow" , scope , parentWorkflow ) ; scope . put ( "previous_result" , scope , prevResult ) ; scope . put ( "log" , scope , getLogChannel ( ) ) ; try { Object res = cx . evaluateString ( scope , this . script , "<cmd>" , 1 , null ) ; boolean retval = Context . toBoolean ( res ) ; result . setNrErrors ( 0 ) ; return retval ; } catch ( Exception e ) { result . setNrErrors ( 1 ) ; logError ( BaseMessages . getString ( PKG , "ActionEval.CouldNotCompile" , e . toString ( ) ) ) ; return false ; } } catch ( Exception e ) { result . setNrErrors ( 1 ) ; logError ( BaseMessages . getString ( PKG , "ActionEval.ErrorEvaluating" , e . toString ( ) ) ) ; return false ; } finally { Context . exit ( ) ; } }
Evaluate the result of the execution of previous action.
Evaluate the result of the execution of previous action .
// Compatible // doc issue // migration