Beispiel #1
0
  private void completeExecuteArc(GraphProcess process, Node targetNode, List<ArcToken> tokens) {
    NodeToken nodeToken = getFactory().newNodeToken(process, targetNode, tokens);
    process.addNodeToken(nodeToken);

    // Add new node token to add the token sets which its generating arc tokens are members of
    Set<TokenSet> tokenSets = new HashSet<TokenSet>();

    for (ArcToken token : tokens) {
      for (ArcTokenSetMember setMember : token.getTokenSetMemberships()) {
        TokenSet tokenSet = setMember.getTokenSet();
        if (!tokenSet.isComplete() && !tokenSets.contains(tokenSet)) {
          tokenSets.add(tokenSet);
          NodeTokenSetMember newSetMember =
              getFactory().newNodeTokenSetMember(tokenSet, nodeToken, setMember.getMemberIndex());
          tokenSet.getActiveNodeTokens(this).add(nodeToken);
          nodeToken.getTokenSetMemberships().add(newSetMember);
        }
      }
    }

    fireEvent(NodeTokenEvent.newCreatedEvent(this, nodeToken));

    for (ArcToken token : tokens) {
      process.removeActiveArcToken(token);
      if (token.isPending()) {
        token.markProcessed(this);
      }
      token.markComplete(this, nodeToken);
      fireEvent(ArcTokenEvent.newCompletedEvent(this, token));
    }

    executeNode(process, nodeToken);
  }
Beispiel #2
0
  @Override
  public void startProcess(GraphProcess process) {
    process.setState(ProcessState.Executing);
    fireEvent(ProcessEvent.newStartedEvent(this, process));

    arcExecutionStarted = true;

    try {
      for (Node startNode : process.getGraph().getStartNodes()) {
        NodeToken startToken =
            getFactory().newNodeToken(process, startNode, new ArrayList<ArcToken>(0));
        process.addNodeToken(startToken);
        executeNode(process, startToken);
      }
      executeQueuedArcTokens(process);
    } finally {
      arcExecutionStarted = false;
      drainAsyncQueue(process);
    }

    if (process.isExecuting()) {
      checkForCompletion(process);
    }
  }