Package org.openbp.core.model.item.process

Examples of org.openbp.core.model.item.process.NodeParam


      // First, provide any data from process variables the parameters might be connected to
      // We do this before evaluating any parameter expressions because they might depend on the global values.
      for (int i = 0; i < nParams; ++i)
      {
        NodeParam param = (NodeParam) paramList.get(i);

        checkGlobalLinks(param);
      }

      // Now evaluate parameter expressions and check for required parameters
      for (int i = 0; i < nParams; ++i)
      {
        NodeParam param = (NodeParam) paramList.get(i);

        Object value = null;
        boolean required = ! param.isOptional();

        String expression = param.getExpression();
        if (expression != null)
        {
          // Evaluate the expression before checking the parameters
          if (ScriptUtil.isConstantExpression(expression))
          {
            // Evaluate constant expressions only if we do not yet have a parameter value
            value = TokenContextUtil.getParamValue(context, param);

            if (value == null)
            {
              value = ScriptUtil.getConstantExpressionValue(expression);

              if (value != null)
              {
                // Finally, we have a value. Assign it to to the parameter
                TokenContextUtil.setParamValue(context, param, value);
              }
            }
          }
          else
          {
            // Evaluate a script expression
            ScriptEngine scriptEngine = engine.getScriptEngineFactory().obtainScriptEngine(context);
            try
            {
              // Evaluate the expression
              scriptEngine.prepareNodeParamExecution(param);
              value = scriptEngine.executeScript(expression, "entry parameter script", param.getQualifier().toString());
              scriptEngine.finishNodeParamExecution(param);

              // Assign the result to the parameter
              TokenContextUtil.setParamValue(context, param, value);
            }
            finally
            {
              engine.getScriptEngineFactory().releaseScriptEngine(scriptEngine);
            }
          }
        }
        else
        {
          if (required)
          {
            value = TokenContextUtil.getParamValue(context, param);
          }
        }

        if (required && value == null)
          // This is an error in this case
          throw new EngineException("RequiredParameterMissing", "Required parameter '" + param.getQualifier() + "' not present");
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.openbp.core.model.item.process.NodeParam

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.