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

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


    }

    if (handlingOption == EngineExceptionHandlerEvent.HANDLING_OPTION_ERROR_SOCKET)
    {
      // Let's see if there is an error socket to continue with.
      NodeSocket socket = determineErrorSocket(context);
      if (socket != null)
      {
        LogUtil.trace(getClass(), "Continuing execution at error socket $0 after handling of exception. [{0}]", socket.getQualifier(), context, t);

        context.setCurrentSocket(socket);

        // Try to find an exception parameter at the socket we're going to start with.
        NodeParam exceptionParam = socket.getParamByName(CoreConstants.EXCEPTION_PARAM_NAME);
        if (exceptionParam != null)
        {
          // ...and set the exception to be handled.
          TokenContextUtil.setParamValue(context, exceptionParam, t);
        }
View Full Code Here


   * @param context Context
   * @return The error socket or null if no such socket could be found.
   */
  protected NodeSocket determineErrorSocket(TokenContext context)
  {
    NodeSocket socket = null;
    try
    {
      socket = engine.resolveSocketRef(CoreConstants.ERROR_SOCKET_NAME, context.getCurrentSocket(), context, false);
    }
    catch (OpenBPException e2)
View Full Code Here

   * @throws OpenBPException On error
   */
  public void executeModelObject(ModelObject mo, EngineExecutor ee)
  {
    TokenContext context = ee.getTokenContext();
    NodeSocket entrySocket = context.getCurrentSocket();
    DecisionNode node = (DecisionNode) entrySocket.getNode();

    boolean result = false;

    String expression = node.getExpression();
    if (expression != null)
    {
      // Evaluate a script expression
      ScriptEngine scriptEngine = getEngine().getScriptEngineFactory().obtainScriptEngine(context);
      try
      {
        // Evaluate the expression
        scriptEngine.prepareNodeSocketExecution(entrySocket);
        Object value = scriptEngine.executeScript(expression, "Decision node script", entrySocket.getNode()
                              .getQualifier().toString());
        scriptEngine.finishNodeSocketExecution(entrySocket);

        // Assign the result to the parameter
        if (value != null && ! value.equals(Boolean.FALSE))
          result = true;
      }
      finally
      {
        getEngine().getScriptEngineFactory().releaseScriptEngine(scriptEngine);
      }
    }

    String socketName = result ? CoreConstants.SOCKET_YES : CoreConstants.SOCKET_NO;
    NodeSocket nextSocket = getEngine().resolveSocketRef(socketName, entrySocket, context, true);
    context.setCurrentSocket(nextSocket);
  }
View Full Code Here

      {
        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))
      {
        // Search the continous nodes and exit sockets to the searched entry only in the process
        // with the initial node
        if (node instanceof FinalNode)
        {
          if (entry.getName().equals(((FinalNode) node).getJumpTarget()))
            foundReferences.add(node);
        }
        else if (node instanceof MultiSocketNode)
        {
          MultiSocketNode socketNode = (MultiSocketNode) node;
          Iterator exitSockets = socketNode.getSockets(false);
          while (exitSockets.hasNext())
          {
            NodeSocket exit = (NodeSocket) exitSockets.next();
            if (! exit.hasControlLinks() && exit.getName().equals(entry.getName()))
              foundReferences.add(exit);
          }
        }
      }
    }
View Full Code Here

    {
      Figure f = fe.nextFigure();
      if (f instanceof SocketFigure)
      {
        SocketFigure socketFigure = (SocketFigure) f;
        NodeSocket socket = socketFigure.getNodeSocket();

        String geometry = socket.getGeometry();
        if (geometry != null && geometry.indexOf("angle") >= 0)
        {
          // Alreayd layed out
          continue;
        }

        if (socket.getNode() instanceof WorkflowNode && socket.isExitSocket() && socket.getName().equals(CoreConstants.SOCKET_TASK_PUBLISHED))
        {
          if (othersToLayout == null)
            othersToLayout = new LinkedList();
          othersToLayout.add(socketFigure);
        }
View Full Code Here

   * true: The node's orientation is top-down.<br>
   * false: The node's orientation is left-right.
   */
  public boolean isVerticallyOriented()
  {
    NodeSocket socket = null;

    if (node instanceof MultiSocketNode)
    {
      // Multi socket nodes are vertically oriented if their entry socket lies in the top quadrant of the circle.
      socket = ((MultiSocketNode) node).getDefaultEntrySocket();
View Full Code Here

   * false: Get an exit socket
   * @return The point figure or null
   */
  public SocketFigure getConnectableSocket(boolean isEntry)
  {
    NodeSocket socket = node.getConnectableSocket(isEntry);

    if (socket != null)
      return (SocketFigure) socket.getRepresentation();

    return null;
  }
View Full Code Here

    // First, give the call stack a chance to update itself.
    if (!context.getCallStack().performProcessUpdate(process))
      result = false;

    // Second, try to update current position.
    NodeSocket currentSocket = context.getCurrentSocket();
    if (currentSocket != null && currentSocket.getProcess() == process)
    {
      NodeSocket newSocket = EngineUtil.updateSocketReference(currentSocket, process);
      if (newSocket != null)
      {
        currentSocket = newSocket;
      }
      else
View Full Code Here

      int nExit = 0;

      boolean found = false;
      for (Iterator it = node.getSockets(); it.hasNext();)
      {
        NodeSocket nodeSocket = (NodeSocket) it.next();

        if (nodeSocket.isEntrySocket())
          ++nEntry;
        else
          ++nExit;
        found = true;
      }
      if (! found)
        // No sockets, no drop
        return false;

      int DO_ENTRY = JMsgBox.TYPE_YES;
      int DO_EXIT = JMsgBox.TYPE_NO;
      int DO_ALL = JMsgBox.TYPE_YES_FOR_ALL;
      int choice = 0;

      if ((nEntry == 1 && nExit == 0) || (nEntry == 0 && nExit == 1))
      {
        // If there is only one entry or exit, we won't ask.
        choice = DO_ALL;
      }
      else
      {
        // Ask the user; we will use the 'yes' button for entry, the 'no' button for exit sockets
        int msgType = JMsgBox.TYPE_CANCEL;
        if (nEntry > 0)
          msgType |= DO_ENTRY;
        if (nExit > 0)
          msgType |= DO_EXIT;
        if (nEntry > 0 && nExit > 0)
          msgType |= DO_ALL;

        ResourceCollection res = getDrawing().getEditor().getPluginResourceCollection();
        String title = res.getRequiredString("node.addparam.title");
        String text = res.getRequiredString("node.addparam.text");

        try
        {
          DataTypeItem type = (DataTypeItem) data.getTransferData(ClientFlavors.TYPE_ITEM);
          text = MsgFormat.format(text, type.getDisplayText());
        }
        catch (UnsupportedFlavorException e)
        {
          // Silently ignore
        }
        catch (IOException e)
        {
          // Silently ignore
        }

        JMsgBox msgBox = new JMsgBox(null, title, text, msgType);
        msgBox.setResource(res);
        msgBox.setResourcePrefix("node.addparam.");

        msgBox.initDialog();
        SwingUtil.show(msgBox);

        choice = msgBox.getUserChoice();
      }

      // Add to sockets
      for (Iterator it = node.getSockets(); it.hasNext();)
      {
        NodeSocket nodeSocket = (NodeSocket) it.next();

        boolean doit = false;
        if (nodeSocket.isEntrySocket())
        {
          doit = (choice & (DO_ENTRY | DO_ALL)) != 0;
        }
        else
        {
          doit = (choice & (DO_EXIT | DO_ALL)) != 0;
        }

        if (doit)
        {
          SocketFigure socketFigure = (SocketFigure) nodeSocket.getRepresentation();
          socketFigure.importData(REGION_TYPE, data, null);
        }
      }

      return true;
View Full Code Here

   * @throws OpenBPException On error
   */
  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;

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

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

        childContext.setCurrentSocket(outSocket);
        getEngine().resumeToken(childContext);
      }
    }

    // When there is a 'Resume' exit socket, let's continue there; otherwise simply end
    NodeSocket nextSocket = getEngine().resolveSocketRef(CoreConstants.FORK_RESUME, entrySocket, context, false);
    if (nextSocket != null)
    {
      context.setCurrentSocket(nextSocket);
    }
    else
View Full Code Here

TOP

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

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.