JBoss Community

Re: How can I get a itemDefinition related to a process variable?

created by Francesco Pietrobelli in jBPM - View the full discussion

The only solution i found is parsing the bpmn file in which the process is defined in follwiong way:

 

org.jbpm.workflow.instance.WorkflowProcessInstance currentProcess=(org.jbpm.workflow.instance.WorkflowProcessInstance)ksession.getProcess(processInstanceId);
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document doc = documentBuilder.parse(((org.jbpm.process.core.Process) currentProcess.getProcess()).getResource().getInputStream());
 
 
XPathFactory xFactory = XPathFactory.newInstance();
XPath xPath = xFactory.newXPath();
xPath.setNamespaceContext(new BPMN2Namespaces());
 
Map<String, String> outMap = currentNode.getHumanTaskNode().getOutMappings();
for (String outParameter : outMap.keySet()) {
     XPathExpression xExpr1 = xPath.compile("//bpmn2:definitions/bpmn2:process/bpmn2:property[@id='"
                                + outMap.get(outParameter)
                                + "']/@itemSubjectRef");
     String itemSubjectRef = xExpr1.evaluate(doc);
     XPathExpression xExpr2 = xPath.compile("//bpmn2:definitions/bpmn2:itemDefinition[@id='"
                                + itemSubjectRef + "']/@structureRef");
     String structureRef = xExpr2.evaluate(doc);
 
     System.out.println("Type of out parameter named '"+outParameter+"': "+structureRef);
}

 

But if same one know a way to do that without parsing bpmn file is very appreciated....

Regards,

Francesco

Reply to this message by going to Community

Start a new discussion in jBPM at Community