Discussion:
[jboss-user] [jBPM] - Get Activity Coordinates
roxy1987
2013-01-04 22:12:18 UTC
Permalink
roxy1987 [https://community.jboss.org/people/roxy1987] created the discussion

"Get Activity Coordinates"

To view the discussion, visit: https://community.jboss.org/message/787725#787725

--------------------------------------------------------------
Hi,

In jBPM 4, we could use the RepositoryService to get the activity coordinates. Whats the API to achieve the same in jBPM 5?

Regards.
--------------------------------------------------------------

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

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
roxy1987
2013-01-09 16:45:42 UTC
Permalink
roxy1987 [https://community.jboss.org/people/roxy1987] created the discussion

"Re: Get Activity Coordinates"

To view the discussion, visit: https://community.jboss.org/message/789783#789783

--------------------------------------------------------------
Anything regarding this question guys pls..
--------------------------------------------------------------

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

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Marcelo Zabalet
2013-01-09 19:05:09 UTC
Permalink
Marcelo Zabalet [https://community.jboss.org/people/zabalet] created the discussion

"Re: Get Activity Coordinates"

To view the discussion, visit: https://community.jboss.org/message/789809#789809

--------------------------------------------------------------
Maybe there is a simple way, but here goes something:


This gives you the list of visited nodes (actuals and past)
List<NodeInstanceLog> nodeInstanceLogs = JPAProcessInstanceDbLog.findNodeInstances(new Long(processInstanceId));

Iterates and acquire Node objects
for (NodeInstanceLog nodeInstanceLog : nodeInstanceLogs) {
    Node node = ((WorkflowProcess) process).getNode(Long.parseLong(nodeInstanceLog.getNodeId()));
    // ie: this gives you x coordinate: node.getMetaData().get("x");
}

Hope this help.
--------------------------------------------------------------

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

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
roxy1987
2013-01-09 19:35:03 UTC
Permalink
roxy1987 [https://community.jboss.org/people/roxy1987] created the discussion

"Re: Get Activity Coordinates"

To view the discussion, visit: https://community.jboss.org/message/789815#789815

--------------------------------------------------------------
Cool. I am gonna give it a try. Any help is much appreciated. I will get back with the output. Thanks a lot Marcelo.
--------------------------------------------------------------

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

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
roxy1987
2013-01-09 20:00:13 UTC
Permalink
roxy1987 [https://community.jboss.org/people/roxy1987] created the discussion

"Re: Get Activity Coordinates"

To view the discussion, visit: https://community.jboss.org/message/789822#789822

--------------------------------------------------------------
What is the object "process" here? How do i get it? All i have is the processinstance id.

--------------------------------------------------------------

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

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Marcelo Zabalet
2013-01-09 20:46:33 UTC
Permalink
Marcelo Zabalet [https://community.jboss.org/people/zabalet] created the discussion

"Re: Get Activity Coordinates"

To view the discussion, visit: https://community.jboss.org/message/789832#789832

--------------------------------------------------------------
Sorry, I forget this...

org.drools.definition.process.Process process = knowledgeBase.getProcess(processInstanceLog.getProcessId());
--------------------------------------------------------------

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

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
roxy1987
2013-01-09 21:49:24 UTC
Permalink
roxy1987 [https://community.jboss.org/people/roxy1987] created the discussion

"Re: Get Activity Coordinates"

To view the discussion, visit: https://community.jboss.org/message/789842#789842

--------------------------------------------------------------

Ok. So the following should do the trick?

KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.+newKnowledgeBuilder+();
KnowledgeBase knowledgeBase = kbuilder.newKnowledgeBase();
Process process = knowledgeBase.getProcess(processInstanceId);
--------------------------------------------------------------

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

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Marcelo Zabalet
2013-01-10 15:28:47 UTC
Permalink
This post might be inappropriate. Click to display it.
roxy1987
2013-01-10 16:04:16 UTC
Permalink
roxy1987 [https://community.jboss.org/people/roxy1987] created the discussion

"Re: Get Activity Coordinates"

To view the discussion, visit: https://community.jboss.org/message/790143#790143

--------------------------------------------------------------
I would go for the APIs. I am gonna give it a shot. If it doesnt work then I can use the XML file instead to read the coordinates. Thanks Man.
For now I am gonna mark it as correct.

Another question if you could help me with.
https://community.jboss.org/message/790142#790142 https://community.jboss.org/message/790142
Thanks.

--------------------------------------------------------------

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

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
roxy1987
2013-01-10 17:54:18 UTC
Permalink
roxy1987 [https://community.jboss.org/people/roxy1987] created the discussion

"Re: Get Activity Coordinates"

To view the discussion, visit: https://community.jboss.org/message/790167#790167

--------------------------------------------------------------
Okay so I tried the code and it gave me a class cast exception. Then I tried your previous code, it seems to be giving me the coordinates but not exactly in a way I need them.

I have got a process with a start node, 3 human task nodes, and an end node. So total of 5 nodes.

Out of the 3 human task nodes, I have completed 1 human task. It is at 2nd human task.

The code returned me 5 nodes. But the first 2 nodes returned are both start nodes, next 2 are both of first human task and 5th node is of second human task. Even in the db I have 5 nodes. I am not sure if thats how the information is logged or if this is a bug.

But what I am looking for is the coordinate of just the second human task since the process is pending at it.

But at least I am getting the coordinates now thanks to you. I am gonna try to figure out the problem/logic. If you already know then you are most welcome to share. Thanks.
--------------------------------------------------------------

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

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Marcelo Zabalet
2013-01-10 18:04:42 UTC
Permalink
Marcelo Zabalet [https://community.jboss.org/people/zabalet] created the discussion

"Re: Get Activity Coordinates"

To view the discussion, visit: https://community.jboss.org/message/790170#790170

--------------------------------------------------------------
Taht's because it logs the enter and the exit, so, usually, when a process instance ends, you end up with to registers per node. The NodeInstanceLog object has a type attribute. You could use it to determine if you are "in" the node or you just "passed" the node. If you have ENTER but not EXIT, you are in.

nodeInstanceLog.getType() == NodeInstanceLog.NodeInstanceLog.TYPE_ENTER

nodeInstanceLog.getType() == NodeInstanceLog.NodeInstanceLog.TYPE_EXIT

Hope this help.
--------------------------------------------------------------

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

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
roxy1987
2013-01-10 19:17:46 UTC
Permalink
roxy1987 [https://community.jboss.org/people/roxy1987] created the discussion

"Re: Get Activity Coordinates"

To view the discussion, visit: https://community.jboss.org/message/790187#790187

--------------------------------------------------------------
Cool. This helped. It wont give me the current active node though. But It will surely filter the list to the enter type nodes.
--------------------------------------------------------------

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

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Marcelo Zabalet
2013-01-10 19:22:00 UTC
Permalink
Marcelo Zabalet [https://community.jboss.org/people/zabalet] created the discussion

"Re: Get Activity Coordinates"

To view the discussion, visit: https://community.jboss.org/message/790188#790188

--------------------------------------------------------------
This was the class cast exception, my mistake :)

replace // import org.jbpm.workflow.core.impl.NodeImpl
by        // import org.drools.definition.process.Node
--------------------------------------------------------------

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

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
roxy1987
2013-01-10 20:11:46 UTC
Permalink
roxy1987 [https://community.jboss.org/people/roxy1987] created the discussion

"Re: Get Activity Coordinates"

To view the discussion, visit: https://community.jboss.org/message/790204#790204

--------------------------------------------------------------
Great. It is working now.
I mixed your two code frags to get the currently active task. Becuase the previous code gives me both type 0 and type 1 nodes and the other code gives me all the nodes of the process. So I am checking if a node has both type 0 and type 1 then it has definitely been completed. Otherwise it is pending. Btw. I am hoping that there are only 2 types for a task. Enter and Exit.









List<NodeInstanceLog> nodeInstanceLogList;


**for** (Node node : (Node[]) ((WorkflowProcessImpl) process).getNodes()){
nodeInstanceLogList = JPAProcessInstanceDbLog.+findNodeInstances+(Long.+parseLong+(processInstanceId),

**new** Long(node.getId()).toString());

**if**(nodeInstanceLogList.size() == 1){

coordinates.add(node.getMetaData().get(
"height"));coordinates.add(node.getMetaData().get(

"width"));}
}


--------------------------------------------------------------

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

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