Victor Tatai [
https://community.jboss.org/people/vtatai] created the discussion
"Custom WorkItemHandler - variables being converted to String"
To view the discussion, visit:
https://community.jboss.org/message/803788#803788
--------------------------------------------------------------
Hello,
I am in the process of implementing a custom WorkItemHandler which allows calling Spring
bean methods. It is all working so far, except when I use an expression for setting a
parameter such as:
<dataInputAssociation>
<targetRef>_3_Param3Input</targetRef>
<assignment>
<from xsi:type="tFormalExpression">#{processData}</from>
<to xsi:type="tFormalExpression">_3_Param3Input</to>
</assignment>
</dataInputAssociation>
(#{processData} is actually a java.util.Map)
then in my custom WorkItemHandler, when I do WorkItem#getParameters() for that parameter,
it is there, but it is converted as a String - i.e., it is not a Map anymore.
I was actually able to debug and found this bit of code inside jBPM's
WorkItemNodeInstance#createWorkItem():
Object variableValue = variableScopeInstance.getVariable(paramName);
String variableValueString = variableValue == null ? "" :
variableValue.toString();
replacements.put(paramName, variableValueString);
I was actually able to see that variableValue is the map I am expecting, so the variable
exists and is being located correctly. What seems odd to me is the conversion from
variableValue to variableValueString by calling 'variableValue.toString()'.
Perhaps I'm doing something wrong in my WorkItemHandler, but I can't really see
what. Please help!
For reference, my wid file is:
import org.drools.process.core.datatype.impl.type.StringDataType;
import org.drools.process.core.datatype.impl.type.ObjectDataType;
[
[
"name" : "Spring",
"parameters" : [
"Bean" : new StringDataType(),
"Method" : new StringDataType(),
"Param1" : new ObjectDataType(),
"Param2" : new ObjectDataType(),
"Param3" : new ObjectDataType(),
"Param4" : new ObjectDataType(),
"Param5" : new ObjectDataType(),
"Param6" : new ObjectDataType(),
"Param7" : new ObjectDataType(),
"Param8" : new ObjectDataType(),
"Param9" : new ObjectDataType()
],
"displayName" : "Spring",
"icon" : "icons/spring.png"
]
]
Thanks for the help,
Victor
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/803788#803788]
Start a new discussion in jBPM at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]