[jboss-user] [jBPM] - How can I get a itemDefinition related to a process variable?
Francesco Pietrobelli
do-not-reply at jboss.com
Wed Aug 10 11:53:05 EDT 2011
Francesco Pietrobelli [http://community.jboss.org/people/francesco.pietrobelli] created the discussion
"How can I get a itemDefinition related to a process variable?"
To view the discussion, visit: http://community.jboss.org/message/620413#620413
--------------------------------------------------------------
Hi guys,
I would like to build forms for human activities in an automatic and dynamic fashion, but to do this I need to know the data type associated to every dataOutput of the tasks.
My first idea was to retrieve the data type of a process variable inside a WorkItemHandler in the following way:
public void executeWorkItem(WorkItem item, WorkItemManager manager) {
WorkflowProcessInstance currentProcess = (WorkflowProcessInstance) ksession.getProcessInstance(item.getProcessInstanceId());
HumanTaskNodeInstance currentNode = (HumanTaskNodeInstance) findNodeInstance(item.getId(), currentProcess);
Map<String, String> outMappings = ht.getHumanTaskNode().getOutMappings();
for (String outParameterName : outMappings.keySet()) {
System.out.println("Type of process variable: "+currentProcess.getVariable(outMappings.get(outParameterName)).getClass());
}
}
private 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;
}
But in many case outMappings.get(outParameterName) returns null because process variable wasn't set before and so and i can't invoke getClass() on it.
Does any one have any suggestion? is possible to do this programmatically via API?
Francesco.
P.S: I'am using jBPM 5.1Final
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/620413#620413]
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/20110810/44b6920d/attachment.html
More information about the jboss-user
mailing list