[JBoss jBPM] - Re: JBPM BPEL 1.1.1 Getting variables of processInstance
by 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.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4241408#4241408
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4241408
16 years, 9 months
[JBoss jBPM] - Re: JBPM BPEL 1.1.1 Getting variables of processInstance
by dhanushgopinath
I dont think there is any converter as of now.
Here is how I did it
| JbpmContext 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.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4241396#4241396
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4241396
16 years, 9 months