[jboss-user] [jBPM] - Re: Query the workflow process definition

Chris Melas do-not-reply at jboss.com
Wed Oct 5 05:41:06 EDT 2011


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]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20111005/88905028/attachment-0001.html 


More information about the jboss-user mailing list