private void shareTokenSets(final NodeToken newToken, final NodeToken origToken) {
   for (NodeTokenSetMember setMember : origToken.getTokenSetMemberships()) {
     TokenSet tokenSet = setMember.getTokenSet();
     NodeTokenSetMember newSetMember =
         engine.getFactory().newNodeTokenSetMember(tokenSet, newToken, setMember.getMemberIndex());
     newToken.getTokenSetMemberships().add(newSetMember);
     tokenSet.getActiveNodeTokens(engine).add(newToken);
     tokenSets.add(tokenSet);
   }
 }
Exemplo n.º 2
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);
  }
Exemplo n.º 3
0
  private ArcToken generateArcToken(
      final GraphProcess process, final Arc arc, final NodeToken token) {
    ArcToken arcToken = getFactory().newArcToken(process, arc, ExecutionType.Forward, token);
    token.getChildTokens().add(arcToken);

    for (NodeTokenSetMember setMember : token.getTokenSetMemberships()) {
      TokenSet tokenSet = setMember.getTokenSet();
      if (!tokenSet.isComplete()) {
        ArcTokenSetMember newSetMember =
            getFactory().newArcTokenSetMember(tokenSet, arcToken, setMember.getMemberIndex());
        tokenSet.getActiveArcTokens(this).add(arcToken);
        arcToken.getTokenSetMemberships().add(newSetMember);
      }
    }

    return arcToken;
  }