Discussion:
[jboss-user] [jBPM] - Custom WorkItemHandler - variables being converted to String
Victor Tatai
2013-03-20 12:12:12 UTC
Permalink
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&containerType=14&container=2034]
annah
2013-03-20 12:19:37 UTC
Permalink
annah [https://community.jboss.org/people/annah] created the discussion

"Re: Custom WorkItemHandler - variables being converted to String"

To view the discussion, visit: https://community.jboss.org/message/803790#803790

--------------------------------------------------------------
Hi,


I had the sam problem, and it seems to me that this is a bug. See my post (and the solution I used) here: https://community.jboss.org/message/733820#733820 https://community.jboss.org/message/733820#733820
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/803790#803790]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Victor Tatai
2013-03-20 13:21:16 UTC
Permalink
Victor Tatai [https://community.jboss.org/people/vtatai] created the discussion

"Re: Custom WorkItemHandler - variables being converted to String"

To view the discussion, visit: https://community.jboss.org/message/803813#803813

--------------------------------------------------------------
Hey thanks, but I guess your workaround won't work for me - I don't know the types before hand, so I actually can't serialize.

If this is actually a bug I'll open a ticket in Jira, it would be nice to get some confirmation though from the powers that be that this is the case.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/803813#803813]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Victor Tatai
2013-03-21 11:14:51 UTC
Permalink
Victor Tatai [https://community.jboss.org/people/vtatai] created the discussion

"Re: Custom WorkItemHandler - variables being converted to String"

To view the discussion, visit: https://community.jboss.org/message/804017#804017

--------------------------------------------------------------
Ok I created a pull request for this:

https://github.com/droolsjbpm/jbpm/pull/157 https://github.com/droolsjbpm/jbpm/pull/157

Hopefully one of the devs will be able to take a look at it, but the pull request queue looks rather stale (2 years for the oldest pull request?).
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/804017#804017]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Maciej Swiderski
2013-03-25 09:17:20 UTC
Permalink
Maciej Swiderski [https://community.jboss.org/people/swiderski.maciej] created the discussion

"Re: Custom WorkItemHandler - variables being converted to String"

To view the discussion, visit: https://community.jboss.org/message/804535#804535

--------------------------------------------------------------
Victor, is there already jira opened for this? If not could you please create one and assign it to me, I'll take a look at the pull request.

Thanks a lot!
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/804535#804535]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Victor Tatai
2013-03-25 13:33:34 UTC
Permalink
Victor Tatai [https://community.jboss.org/people/vtatai] created the discussion

"Re: Custom WorkItemHandler - variables being converted to String"

To view the discussion, visit: https://community.jboss.org/message/804608#804608

--------------------------------------------------------------
Hey Maciej, thanks for looking into this - I've just noticed though in JIRA that there are no further releases in the 5.x line, does that mean I should have any changes into 6.0?

In git I branched off 5.4.x, so perhaps I'll need to create a new pull request if that is the case.

Thanks!
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/804608#804608]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Maciej Swiderski
2013-03-25 13:36:59 UTC
Permalink
Maciej Swiderski [https://community.jboss.org/people/swiderski.maciej] created the discussion

"Re: Custom WorkItemHandler - variables being converted to String"

To view the discussion, visit: https://community.jboss.org/message/804611#804611

--------------------------------------------------------------
yes, please provide pull request for 6.0 (master in git) as this is where all changes are applied now. Could you please include test case for it as well?

Thanks
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/804611#804611]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Victor Tatai
2013-03-25 17:58:31 UTC
Permalink
Victor Tatai [https://community.jboss.org/people/vtatai] created the discussion

"Re: Custom WorkItemHandler - variables being converted to String"

To view the discussion, visit: https://community.jboss.org/message/804707#804707

--------------------------------------------------------------
Ok I'll set everything up and let you know once it is all ready for review.

Thanks!
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/804707#804707]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Loading...