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

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


      String msg = e.getMessage();
      msgs.addMsg(null, "Cannot resolve the process name of an entry. Maybe the process has been deleted.\n" + msg);
      return;
    }

    Node node = process.getNodeByName(entryName);
    if (node instanceof InitialNode)
    {
      initialNode = (InitialNode) node;
    }
    else
View Full Code Here


      }

      // Count the number of sockets (i. e. entry and final nodes)
      for (Iterator it = process.getNodes(); it.hasNext();)
      {
        Node node = (Node) it.next();

        if (node instanceof InitialNode || node instanceof FinalNode)
          ++additionalSockets;
      }
View Full Code Here

      else
      {
        if (next instanceof SocketFigure)
        {
          NodeFigure nodeFigure = (NodeFigure) ((SocketFigure) next).getParent();
          Node node = nodeFigure.getNode();
          if (node instanceof SingleSocketNode)
          {
            // We may not delete the only socket of a node
            return false;
          }
View Full Code Here

        if (next instanceof NodeFigure)
        {
          NodeFigure nodeFigure = (NodeFigure) next;
          nodeFigure.encodeGeometry();

          Node node = nodeFigure.getNode();

          // Remember that we have copied this one
          copiedSourceNodes.add(node);

          // Clone the node and add it to the process
          node = (Node) node.clone();
          process.addNode(node);

          copyFlavor = ClientFlavors.PROCESS_ITEM;
        }

        else if (next instanceof TextElementFigure)
        {
          TextElementFigure textElementFigure = (TextElementFigure) next;
          textElementFigure.encodeGeometry();

          TextElement textElement = textElementFigure.getTextElement();

          // Clone the element and add it to the process
          textElement = (TextElement) textElement.clone();
          process.addTextElement(textElement);

          copyFlavor = ClientFlavors.PROCESS_ITEM;
        }

        else if (next instanceof SocketFigure)
        {
          SocketFigure socketFigure = (SocketFigure) next;
          socketFigure.encodeGeometry();

          NodeSocket socket = socketFigure.getNodeSocket();

          if (socketHolder == null)
          {
            socketHolder = new ActivityNodeImpl();
            socketHolder.setName("NodeDummy");
            process.addNode(socketHolder);
          }

          // Clone the socketand add it to the dummy node
          socket = (NodeSocket) socket.clone();
          socketHolder.addSocket(socket);

          copyFlavor = ClientFlavors.NODE_SOCKETS;
        }

        else if (next instanceof ParamFigure)
        {
          ParamFigure paramFigure = (ParamFigure) next;

          NodeParam param = paramFigure.getNodeParam();

          if (paramHolder == null)
          {
            if (socketHolder == null)
            {
              socketHolder = new ActivityNodeImpl();
              socketHolder.setName("NodeDummy");
              process.addNode(socketHolder);
            }

            paramHolder = new NodeSocketImpl();
            paramHolder.setName("SocketDummy");
            socketHolder.addSocket(paramHolder);
          }

          // Clone the socket and add it to the dummy node
          param = (NodeParam) param.clone();
          paramHolder.addParam(param, - 1);

          copyFlavor = ClientFlavors.NODE_PARAMS;
        }
      }

      // When copying a link, we perform the following steps:
      // 1. Encode the geometry
      // 2. Generate reference names from the actual object references
      //    (e. g. node names for control links, parameter names for data links etc.)
      // 3. Clone the object
      // 4. Add the cloned object to the dummy process
      // 5. Re-establish the object references (now based on the elements of the dummy process)
      //    If this fails, the object will be removed from the dummy process again.

      StandardMsgContainer msgContainer = ModelConnector.getInstance().getMsgContainer();
      msgContainer.clearMsgs();

      for (FigureEnumeration fe = workspaceView.selectionElements(); fe.hasMoreElements();)
      {
        Figure next = fe.nextFigure();

        if (next instanceof FlowConnection)
        {
          FlowConnection flowConnection = (FlowConnection) next;

          ControlLink link = flowConnection.getControlLink();

          if (! copiedSourceNodes.contains(link.getSourceSocket().getNode())
            || ! copiedSourceNodes.contains(link.getTargetSocket().getNode()))
          {
            // Link source or target has not been copied
            continue;
          }

          flowConnection.encodeGeometry();

          link = (ControlLink) link.clone();
          process.addControlLink(link);

          if (! msgContainer.isEmpty())
          {
            // One of the end points of the link is not present in the copied set,
            // so remove the link from the dummy process again.
            process.removeControlLink(link);
            msgContainer.clearMsgs();
          }
        }

        else if (next instanceof ParamConnection)
        {
          ParamConnection paramConnection = (ParamConnection) next;

          DataLink link = paramConnection.getDataLink();

          Param sourceParam = link.getSourceParam();
          Param targetParam = link.getTargetParam();

          if (sourceParam instanceof NodeParam)
          {
            if (! copiedSourceNodes.contains(((NodeParam) sourceParam).getSocket().getNode()))
            {
              // Link source or target has not been copied
              continue;
            }
          }
          else
          {
            // Don't copy process variable links
            continue;
          }

          if (targetParam instanceof NodeParam)
          {
            if (! copiedSourceNodes.contains(((NodeParam) targetParam).getSocket().getNode()))
            {
              // Link source or target has not been copied
              continue;
            }
          }
          else
          {
            // Don't copy process variable links
            continue;
          }

          paramConnection.encodeGeometry();

          link = (DataLink) link.clone();
          process.addDataLink(link);

          if (! msgContainer.isEmpty())
          {
            // One of the end points of the link is not present in the copied set,
            // so remove the link from the dummy process again.
            process.removeDataLink(link);
            msgContainer.clearMsgs();
          }
        }
      }

      // Re-establish inter-object links and links to other items
      // and remove links to figures to make the gc work
      // TODO Fix 4 This seems to produce some maintainReferences error: "Cannot resolve ... in Model /System"
      process.maintainReferences(ModelObject.RESOLVE_GLOBAL_REFS | ModelObject.RESOLVE_LOCAL_REFS | ModelObject.UNLINK_FROM_REPRESENTATION);

      if (copyFlavor != null && (process.getNodes().hasNext() || process.getTextElements().hasNext()))
      {
        Transferable ret = new SimpleTransferable(process, copyFlavor);

        if (copiedSourceNodes.size() == 1)
        {
          // If we have a single node selected, add the model qualifier of the node in addition
          Node node = (Node) copiedSourceNodes.get(0);
          ModelQualifier qualifier = node.getQualifier();

          MultiTransferable mt = new MultiTransferable();
          mt.addTransferable(ret);
          mt.addTransferable(new SimpleTransferable(qualifier, ClientFlavors.MODEL_QUALIFIER));
          ret = mt;
View Full Code Here

    Figure firstFigure = null;

    // Add the nodes to the target process
    for (Iterator it = source.getNodes(); it.hasNext();)
    {
      Node node = (Node) it.next();

      target.addNode(node);

      // Rebuild the references after adding the object to the target
      node.maintainReferences(ModelObject.SYNC_GLOBAL_REFNAMES);

      NodeFigure nodeFigure = drawing.createNodeFigure(node);
      if (nodeFigure == null)
      {
        target.removeNode(node);
View Full Code Here

  protected void printMethods()
    throws Exception
  {
    for (Iterator itNodes = process.getNodes(); itNodes.hasNext();)
    {
      Node node = (Node) itNodes.next();

      if (! (node instanceof InitialNode))
        continue;

      printMethod((InitialNode) node);
View Full Code Here

  {
    boolean start = true;

    for (NodeSocket socket = startSocket; socket != null;)
    {
      Node node = socket.getNode();

      if (node == stopNode)
      {
        // We reached the stop condition
        break;
      }

      if (! start)
      {
        // Print a newline to separate the node from the last one
        w.println();
      }
      start = false;

      NodeSocket entrySocket = null;
      NodeSocket exitSocket = null;

      if (socket.isEntrySocket())
      {
        // Entry socket specified, determine the default exit socket
        entrySocket = socket;
        exitSocket = node.getDefaultExitSocket();
      }
      else
      {
        // Exit socket specified, no entry socket (e. g. for initial node)
        exitSocket = socket;
      }

      String comment = node.getDisplayText();
      if (comment != null)
      {
        w.printComment(comment, JavaTemplateWriter.COMMENT_SHORT);
      }

      if (node instanceof DecisionNode)
      {
        // Decision node: if-then-else statement
        DecisionNode decisionNode = (DecisionNode) node;

        // Determine the outgoing sockets of the decision node
        // and advance to the entry socket of the next nodes.
        NodeSocket yesSocket = getNamedSocket(node, CoreConstants.SOCKET_YES);
        yesSocket = ((ControlLink) yesSocket.getControlLinks().next()).getTargetSocket();
        NodeSocket noSocket = getNamedSocket(node, CoreConstants.SOCKET_NO);
        noSocket = ((ControlLink) noSocket.getControlLinks().next()).getTargetSocket();

        Node joinNode = skipDecisionNodeBranches(decisionNode);

        printDecisionNodeCondition(decisionNode, entrySocket);
        printDecisionNodeThen(decisionNode, yesSocket, joinNode);
        printDecisionNodeElse(decisionNode, noSocket, joinNode);

        // Continue with the join node
        if (joinNode != null)
        {
          socket = joinNode.getDefaultEntrySocket();
          continue;
        }

        // No common join point, end here
        break;
View Full Code Here

    throws CodeGeneratorException
  {
    // Follow the 'yes' path of the decision node
    for (NodeSocket socket = yesSocket; socket != null;)
    {
      Node node = socket.getNode();

      // Check if this node is also present in the 'no' path.
      if (containsPathNode(node, noSocket))
        // Yes, the node is common to both paths.
        // This is our join node.
        return node;

      if (node instanceof DecisionNode)
      {
        Node joinNode = skipDecisionNodeBranches((DecisionNode) node);
        if (joinNode == null)
          // Both decision node branches end with final nodes
          return null;
        socket = joinNode.getDefaultEntrySocket();
        continue;
      }
      else if (node instanceof FinalNode)
        // Yes branch ends with final node
        return null;
View Full Code Here

  protected boolean containsPathNode(Node nodeToSearch, NodeSocket socket)
    throws CodeGeneratorException
  {
    while (socket != null)
    {
      Node node = socket.getNode();

      if (node == nodeToSearch)
        // Found the node
        return true;

      if (node instanceof DecisionNode)
      {
        Node joinNode = skipDecisionNodeBranches((DecisionNode) node);
        if (joinNode == null)
        {
          // Both decision node branches end with final nodes
          break;
        }
        socket = joinNode.getDefaultEntrySocket();
        continue;
      }
      else if (node instanceof FinalNode)
      {
        // Yes branch ends with final node
View Full Code Here

    ModelMgr modelMgr = getProcessServer().getModelMgr();
    ModelQualifier qualifier = new ModelQualifier(PROCESSREF);
    qualifier.setItemType(ItemTypes.PROCESS);
    ProcessItem process = (ProcessItem) modelMgr.getItemByQualifier(qualifier, true);
 
    Node startNode = process.getNodeByName("Start");
    assertTrue(startNode instanceof InitialNode);
    NodeSocket socket = (NodeSocket) startNode.getDefaultEntrySocket();
   
    List socketDescriptorList = ModelInspectorUtil.determinePossibleExits(socket, WaitStateNode.class, false);
    assertEquals(4, socketDescriptorList.size());

    Node waitStateNode = process.getNodeByName("WaitState");
    assertTrue(waitStateNode instanceof WaitStateNode);
    socket = (NodeSocket) waitStateNode.getDefaultEntrySocket();
   
    socketDescriptorList = ModelInspectorUtil.determinePossibleExits(socket, WaitStateNode.class, true);
    assertEquals(2, socketDescriptorList.size());
  }
View Full Code Here

TOP

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

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.