This content has been marked as final.
Show 1 reply
-
1. Re: How can I get a itemDefinition related to a process variable?
francesco.pietrobelli Sep 8, 2011 11:55 AM (in response to francesco.pietrobelli)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