Chris Melas [http://community.jboss.org/people/melc] created the discussion

"Re: Query the workflow process definition"

To view the discussion, visit: http://community.jboss.org/message/630192#630192

--------------------------------------------------------------
Hello,
You can get any node you like
i.e.
WorkflowProcess workFlowProcess = ((WorkflowProcess) 
knowledgeBase.getProcess("yourProcessId"));
        nodes = workFlowProcess.getNodes();

then you can loop and cast to whatever node you want look at the types in 
package org.jbpm.workflow.core.node i.e. there is a HumanTaskNode etc 
i.e. finding the start node

Node startNode = null;
        for (Node node : nodes) {
            if (node instanceof StartNode) {
                startNode = node;
            }
        }

you can even traverse your process
i.e. call the following method as traverseProcessForHumanTaskNodes(startNode, 
new ArrayList<Node>()); then it will return a collection with all the human 
task nodes

public static Collection traverseProcessForHumanTaskNodes(Node startNode, 
Collection<Node> nodes) {
/*you can choose on of your outgoing connections based on some logic*/
        Node nextNode = 
startNode.getOutgoingConnections("DROOLS_DEFAULT").get(0).getTo();

        if (nextNode instanceof HumanTaskNode) {
                nodes.add(nextNode);
        } else if (nextNode instanceof EndNode) {
            return nodes;
        }
        return traverseProcessForHumanTaskNodes(nextNode, nodes);
    }

This is just to get you starting.... with a little debugging you will see that 
everything is connected and you can easily retrieve it.
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/630192#630192]

Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to