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

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


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

    NodeSocket defaultOutSocket = node.getDefaultExitSocket();
    if (defaultOutSocket == null)
    {
      String msg = LogUtil.error(getClass(), "No default exit socket present for fork node $0. [{1}]", node.getQualifier(), context);
      throw new EngineException("NoDefaultExitSocket", msg);
    }

    Object collectionParamValue = TokenContextUtil.getParamValue(context, entrySocket, CoreConstants.FORK_COLLECTION_PARAM);
    if (collectionParamValue != null)
    {
      // Automatic fork node based on input collection
      if (defaultOutSocket.getParamByName(CoreConstants.FORK_COLLECTION_ELEMENT_PARAM) == null)
      {
        String msg = LogUtil.error(getClass(), "Fork node having a $0 input parameter requires a $1 output parameter. [{2}]", CoreConstants.FORK_COLLECTION_PARAM, CoreConstants.FORK_COLLECTION_ELEMENT_PARAM, context);
        throw new EngineException("NoCollectionElementForFork", msg);
      }

      Iterator it = CollectionUtil.iterator(collectionParamValue);
      while (it.hasNext())
      {
        Object collectionElement = it.next();

        // Create a new child context
        TokenContext childContext = getEngine().getTokenContextService().createChildContext(context);

        // Provide the collection element to it
        Param outParam = defaultOutSocket.getParamByName(CoreConstants.FORK_COLLECTION_ELEMENT_PARAM);
        if (outParam != null)
        {
          // If the exit socket contains a 'WorkflowTask' parameter, set it
          TokenContextUtil.setParamValue(childContext, outParam, collectionElement);
        }

        // Copy the data of the node entry socket in the current context
        // to the exit socket in the child context.
        EngineUtil.copySocketData(entrySocket, context, defaultOutSocket, childContext);

        childContext.setCurrentSocket(defaultOutSocket);
        getEngine().resumeToken(childContext);
      }
    }
    else
    {
      // Iterate all exit sockets
      for (Iterator itOutSockets = node.getSockets(false); itOutSockets.hasNext();)
      {
        final NodeSocket outSocket = (NodeSocket) itOutSockets.next();

        if (outSocket.getName().equals(CoreConstants.FORK_RESUME))
          continue;
View Full Code Here

TOP

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

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.