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