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

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


    while (nodeList.hasNext())
    {
      Node node = (Node) nodeList.next();
      if (node instanceof SubprocessNode)
      {
        SubprocessNode subprocessNode = (SubprocessNode) node;
        ProcessItem subprocess = subprocessNode.getSubprocess();
        if (subprocess == null || !subprocess.getQualifier().matches(searchFor.getQualifier(), ModelQualifier.COMPARE_ALL))
          continue;
        NodeSocket socket = subprocessNode.getSocketByName(entry.getName());
        if (socket != null)
          foundReferences.add(socket);
      }

      if (scaned.getQualifier().matches(searchFor.getQualifier(), ModelQualifier.COMPARE_ALL))
View Full Code Here


   */
  public void executeModelObject(ModelObject mo, EngineExecutor ee)
  {
    TokenContext context = ee.getTokenContext();
    NodeSocket entrySocket = context.getCurrentSocket();
    SubprocessNode node = (SubprocessNode) entrySocket.getNode();

    // If we do not have a sub process, simply continue with the default exit socket
    NodeSocket nextSocket = node.getDefaultExitSocket();

    ProcessItem subprocess = node.getSubprocess();

    // Dynamic sub processes:
    // If we have a Process Name parameter and its value is a string...
    Object result = TokenContextUtil.getParamValue(context, entrySocket, CoreConstants.DYNAMIC_SUBPROCESS_PARAM_NAME);
    if (result != null && result instanceof String)
    {
      // ...try to lookup and return a corresponding process.
      try
      {
        subprocess = (ProcessItem) context.getExecutingModel().resolveItemRef((String) result, ItemTypes.PROCESS);
      }
      catch (ModelException re)
      {
        // Fall thru to the default.
      }
    }

    if (subprocess != null)
    {
      // The default exit socket of the initial node of the sub process
      // that has the same name as the initial node of this sub process
      // node is our initial socket for execution of the sub process.
      String entryName = entrySocket.getName();
      Node subprocessInitialNode = subprocess.getNodeByName(entryName);

      if (subprocessInitialNode == null)
      {
        String msg = LogUtil.error(getClass(), "Initial node $0 called by $1 not found in process $2. [{3}]", entryName, node.getQualifier(), subprocess.getQualifier(), context);
        throw new EngineException("InitialNodeNotFound", msg);
      }

      if (!(subprocessInitialNode instanceof InitialNode))
      {
        String msg = LogUtil.error(getClass(), "Node $0 called by $1 is not an initial node. [{2}]", subprocessInitialNode.getQualifier(), node.getQualifier(), context);
        throw new EngineException("NotAnInitialNode", msg);
      }

      // Continue with the initial node of the sub process
      nextSocket = subprocessInitialNode.getDefaultExitSocket();
      if (nextSocket == null)
      {
        String msg = LogUtil.error(getClass(), "No default exit socket present for sub process initial node $0. [{1}]", subprocessInitialNode.getQualifier(), context);
        throw new EngineException("NoDefaultExitSocket", msg);
      }

      // Push the current position onto the call stack
      context.getCallStack().pushSubprocess(entrySocket);

      // Create the process variables of the subprocess
      EngineUtil.createProcessVariables(subprocess, context);

      // Copy the data of the node entry socket in the current context
      // to the initial node of the sub process in the new context
      EngineUtil.copySocketData(entrySocket, context, nextSocket, context);
    }
    else
    {
      String msg = LogUtil.error(getClass(), "Missing sub process for sub process node $0. [{1}]", node.getQualifier(), context);
      throw new EngineException("MissingSubprocess", msg);
    }

    context.setCurrentSocket(nextSocket);
  }
View Full Code Here

TOP

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

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.