-
1. Re: obsolete id
eaa Sep 7, 2011 7:44 AM (in response to d.y.)One thing are the ids used in the process definition (xml) and another thing are the runtime ids.
I'm a little bit confused about the sentence "I could run my process when...". Could you please explain what are you trying to do?
-
2. Re: obsolete id
d.y. Sep 7, 2011 8:03 AM (in response to eaa)I want to access the outgoing connections of the current node / workitem. when i try it this way:
((RuleFlowProcess) process).getNode(workItemId).getOutgoingConnections().values() i get a NullPointer exception because the workitemId is 10 and there is no more node with id 10 in my bpmn file.
-
3. Re: obsolete id
eaa Sep 7, 2011 8:08 AM (in response to d.y.)Ok, but I just want to make sure that you are not trying to continue the execution of the process using its outgoing connections. Right?
-
4. Re: obsolete id
d.y. Sep 7, 2011 8:12 AM (in response to eaa)nono, i know that this works automatic
-
5. Re: obsolete id
eaa Sep 7, 2011 8:17 AM (in response to d.y.)It is not automatic. You have to use workItemManager.completeWorkItem(...);
But, regarding to the work item Id, what you get when you do wi.getId() is something like a runtime id. Is an id that is only valid for the pocess instance where the work item handler got invoked. It has nothing to do with the id attribute of the Task node in your bpmn2 file.
AFAIK, there is no way to know that information inside a work item handler. I think you may need to preprocess this before the node and pass it as a parameter.
Best Regards,
-
6. Re: obsolete id
francesco.pietrobelli Sep 7, 2011 8:56 AM (in response to eaa)1 of 1 people found this helpfulYou can use this method:
/** * Get the node instance corresponding to a work item identified with * <code>workItemId</code> * * @param workItemId * identification of work item id * @param container * the container that contains the node instance, in most case * the process instance * @return null if no node instance is found, the correspond node instance * otherwise */ public static WorkItemNodeInstance findNodeInstance(long workItemId, NodeInstanceContainer container) { for (NodeInstance nodeInstance : container.getNodeInstances()) { if (nodeInstance instanceof WorkItemNodeInstance) { WorkItemNodeInstance workItemNodeInstance = (WorkItemNodeInstance) nodeInstance; if (workItemNodeInstance.getWorkItem().getId() == workItemId) { return workItemNodeInstance; } } if (nodeInstance instanceof NodeInstanceContainer) { WorkItemNodeInstance result = findNodeInstance(workItemId, ((NodeInstanceContainer) nodeInstance)); if (result != null) { return result; } } } return null; }
and then invoke the method getNodeId() on returned object.
Of course your WorkItemHandler needs a reference to StatefulKnowledgeSession, but you can pass it when you register your WorkItemHandler on your session.
I hope this is useful.
-
7. Re: obsolete id
d.y. Sep 7, 2011 11:35 AM (in response to francesco.pietrobelli)Well that could help but I'm having trouble casting the process to a processInstance:
WorkflowProcessInstance wfpI = (WorkflowProcessInstance) (process);
or
RuleFlowProcessInstance rfpI = (RuleFlowProcessInstance) (process);
doesn't work. how do you do that?
-
8. Re: obsolete id
francesco.pietrobelli Sep 8, 2011 3:38 AM (in response to d.y.)1 of 1 people found this helpfulyep... this is very strange!!!
are you sure to use org.jbpm.workflow.instance.WorkflowProcessInstance? because the code for HumanTaskHandler that i'am actually using with jBPM5.1 is:
public void executeWorkItem(WorkItem item, WorkItemManager manager) { WorkflowProcessInstance currentProcess = (WorkflowProcessInstance) ksession .getProcessInstance(item.getProcessInstanceId()); if (currentProcess == null) { log.error("Can't find current process instance relative to " + item); manager.abortWorkItem(item.getId()); return; } HumanTaskNodeInstance currentNode = (HumanTaskNodeInstance) JbpmUtility .findNodeInstance(item.getId(), currentProcess); if (currentNode == null) { log.error("Can't find current node instance relative to " + item); manager.abortWorkItem(item.getId()); return; } ... ... }
-
9. Re: obsolete id
d.y. Sep 8, 2011 4:22 AM (in response to francesco.pietrobelli)you are right, i used the wrong package. casting works now, thank you.:-) strangely my session is null. i gotta check out why. nvm, everything works :-)