Package org.openbp.server.engine.script

Examples of org.openbp.server.engine.script.ExpressionParser


    Object value = null;

    try
    {
      ExpressionParser parser = EngineUtil.createExpressionParser(context, null);
      value = parser.getContextPathValue(parserExpression, null, 0);
    }
    catch (OpenBPException e)
    {
      LogUtil.error(getClass(), "Error evaluating expression $0. [{1}]", parserExpression, context, e);
    }
View Full Code Here


   * @param engine Engine
   * @return The new instance
   */
  public static ExpressionParser createExpressionParser(TokenContext context, Engine engine)
  {
    ExpressionParser ep = new ExpressionParser(new TokenContextToExpressionContextAdapter(context));
    if (engine != null)
    {
      ep.setPersistenceContextProvider(engine.getPersistenceContextProvider());
    }
    return ep;
  }
View Full Code Here

    Object value;
    if (sourceMember != null)
    {
      // We have a member path specification for the source.
      // We need an expression parser to evaluate it.
      ExpressionParser parser = EngineUtil.createExpressionParser(context, engine);

      String contextName = sourceParam.getContextName();
      String paramName = sourceParam.getName();
      int pos = contextName.lastIndexOf(paramName);
      String contextPrefix = contextName.substring(0, pos);

      parser.setContextPrefix(contextPrefix);

      // Any members that are missing in the path will cause a null value to be returned
      String expr;
      if (sourceMember.startsWith(ExpressionConstants.MEMBER_OPERATOR))
        expr = paramName + sourceMember;
      else if (sourceMember.startsWith(ExpressionConstants.REFERENCE_KEY_OPERATOR))
        expr = paramName + sourceMember;
      else
        expr = paramName + ExpressionConstants.MEMBER_OPERATOR + sourceMember;
      value = parser.getContextPathValue(expr, null, 0);
    }
    else
    {
      // Direct parameter value access, cache the parameter value for remaining data links
      value = TokenContextUtil.getParamValue(context, sourceParam);
    }

    if (value != null && link.isCloningSource())
    {
      // This link want to have the source value cloned
      try
      {
        value = CopyUtil.copyObject(value, Copyable.COPY_DEEP, context.getExecutingModel().getClassLoader());
      }
      catch (Exception e)
      {
        throw new EngineException("Clone", "Cloning of data link value failed.", e);
      }
    }

    //
    // Set the target value
    //
    if (targetMember != null)
    {
      // We have a member path specification for the target.
      // We need an expression parser to evaluate it.
      ExpressionParser parser = EngineUtil.createExpressionParser(context, engine);

      String contextName = targetParam.getContextName();
      String paramName = targetParam.getName();
      int pos = contextName.lastIndexOf(paramName);
      String contextPrefix = contextName.substring(0, pos);

      parser.setContextPrefix(contextPrefix);

      // Provide the target parameter type and the 'create all objects' flag to the parser,
      // so any members that are missing in the path will be created on the fly.
      parser.setContextPathValue(targetMember, value, targetParam.getDataType(), ExpressionParser.CREATE_ALL_OBJECTS);
    }
    else
    {
      // Add the value directly as target parameter value to the context
      TokenContextUtil.setParamValue(context, targetParam, value);
View Full Code Here

TOP

Related Classes of org.openbp.server.engine.script.ExpressionParser

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.