-
1. Re: Query the workflow process definition
melc Sep 29, 2011 9:44 AM (in response to skodagally)Hello,
Take a look here and the referenced threads
http://community.jboss.org/message/623594#623594
it shows how to iterate the process structure... so with the appropriate casting of the nodes you may get the info you need.
-
2. Re: Query the workflow process definition
skodagally Oct 3, 2011 5:54 AM (in response to melc)Thanks Chris,
My requirement is also to get the list of human activities from knowledge base, since i need this list even when no process instances are running.
So based on the processid is there a way to query the process definition?
-
3. Re: Query the workflow process definition
calca Oct 3, 2011 8:48 AM (in response to skodagally)Hi,
I don't know if it can be obtained from the kbase. I have made it from bpmn file, but parsing it and obtaining userTask nodes. You can check it here:
Regards,
Demian
-
4. Re: Query the workflow process definition
swiderski.maciej Oct 4, 2011 2:47 PM (in response to skodagally)Have you tried to use knowledge base to get processes and then cast it to NodeContainer?
Collection<Process> processes = kbase.getProcesses(); for (Process p : processes) { NodeContainer container = (NodeContainer) p; // following line should return all nodes in the process - hopefully container.getNodes(); }
NOTE: It is written by hand the code so it can have some typos... don't have access to my development environment now so was not able to verify that.
HTH
-
5. Re: Query the workflow process definition
melc Oct 5, 2011 5:42 AM (in response to swiderski.maciej)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 one of your outgoing connections based on some logic, here it is assumed that there is always one outgoing that moves forward etc*/
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.
-
6. Re: Query the workflow process definition
skodagally Oct 10, 2011 5:33 AM (in response to melc)Thank you all,
Thanks Chris i was able to get the list of Human Tasks and Constraints (transitions) associated with a Split node.