-
1. Re: how to find ProcessInstance current state or node
johan.parent Dec 26, 2007 11:40 AM (in response to tprime)Hi,
You can get the root token for your process. From there you can find out in which node(s) it resides.
A bit like below (this collects all the active nodes) but then again you'll need to do some instanceof work to see what type of node you actually got.... ProcessInstance p = ctx.loadProcessInstance(id); // Second build a Set with all the active nodes in the process instance Token t = p.getRootToken(); Map <String, Token> children = t.getChildren(); // Put in the set Set<Map.Entry<String,Token>> cSet = children.entrySet(); for (Iterator<Map.Entry<String,Token>> it = cSet.iterator(); it.hasNext();) { Map.Entry<String,Token> e = it.next(); Token tok = e.getValue(); // nodes.add(tok.getNode()); } // Also add the node for this token (if any) to the set Node here = t.getNode(); if (here != null) nodes.add(here);
And oh yeah, since the hibernate proxies will get in the way of your instanceof logic you'll need to do something like below first (believe me ;)// We need to this to access the real object otherwise // we bump into the proxy object and instanceof won't work if (nodeinstanceof HibernateProxy) { node= ((HibernateProxy)node).getHibernateLazyInitializer().getImplementation(); }
Hope this helps,
Johan -
2. Re: how to find ProcessInstance current state or node
tprime Jan 3, 2008 5:02 AM (in response to tprime)Thanks Johan that helped.
Just wondering if the method will be recursive i mean do i need to the process for the children node too? or first level node will be enough? -
3. Re: how to find ProcessInstance current state or node
tprime Jan 3, 2008 5:15 AM (in response to tprime)Also is there a possibility that we can use HQL to get current states/nodes?
-
4. Re: how to find ProcessInstance current state or node
tprime Jan 3, 2008 5:16 AM (in response to tprime)Because i actually want to know all the process instance in particular state/node, and i do not have the process instance id or anything.
-
5. Re: how to find ProcessInstance current state or node
johan.parent Jan 3, 2008 12:54 PM (in response to tprime)Ah ok I see. Well I saw I complicated things anyway. There seems to be a findActiveNodesByProcessInstance() in the GraphSession
So combining that with getGraphSession().findProcessInstances(processDefinitionId), which returns you a list of processes, you could get the list you are looking for.
Otherwise have a look in hibernate.queries.hbm.xml file and make your own hql with those used by the above mentioned methods.
Good luck,
Johan