This content has been marked as final.
Show 3 replies
-
1. Re: JBPM BPEL 1.1.1 Getting variables of processInstance
evilsephiroth Jul 2, 2009 2:52 AM (in response to evilsephiroth)up...
No one has encountered this problem? -
2. Re: JBPM BPEL 1.1.1 Getting variables of processInstance
dhanushgopinath Jul 2, 2009 4:25 AM (in response to evilsephiroth)I dont think there is any converter as of now.
Here is how I did itJbpmContext jbpmContext = GetJbpmConfiguration().createJbpmContext(); ProcessInstance processInstance = GetJbpmGraphSession(jbpmContext) .getProcessInstance(Long.parseLong(strProcessInstanceId)); // Get the context instance ContextInstance processContextInstance = processInstance .getContextInstance(); // get the all token variables map Map allTokenVariablsMap = processContextInstance.getTokenVariableMaps(); // get the correct token for the variable Token tokenForVariable = GET THE CORRECT TOKEN HERE FROM THE MAP // get the variable from the context instance Object variable = processContextInstance.getVariable(strVariableName, tokenForVariable); // Variable will be an instance of MessageValue if (variable instanceof MessageValue) { MessageValue messageElement = (MessageValue) variable; Map partElems = messageElement.getParts(); // Get the first Element String partName = (String) partElems.keySet().iterator().next(); Element partElement = (Element) partElems.values().iterator() .next();
The partElement is an XML Element . You can recurse through this and get the values using a DOM Parser. -
3. Re: JBPM BPEL 1.1.1 Getting variables of processInstance
evilsephiroth Jul 2, 2009 5:09 AM (in response to evilsephiroth)yes i was doing something similar to get the variables. The problem is the parsing of the element. I want to implement a generic parser for all the processes deployed on the console. But every process has its implementation of variables so i can't effectively know in what node is the variable data(some in the first child, some other in nested childs).
if (variable instanceof MessageValue) { MessageValue messageElement = (MessageValue) variable; Map partElems = messageElement.getParts(); // Get the first Element String partName = (String) partElems.keySet().iterator().next(); org.apache.xerces.dom.DeferredElementNSImpl partElement = (org.apache.xerces.dom.DeferredElementNSImpl) partElems.values().iterator() .next(); String valueVar=partElement.getFirstChild().getFirstChild().getNodeValue(); }
This code won't work for all processes because in another process this line will be :
valueVar=partElement.getFirstChild().getNodeValue();
I was thinking a node searcher/comparer to variable Name but i hope something simpler will come out...
any help is appreciated.