1 Reply Latest reply on May 18, 2012 2:44 PM by borlinp

    WorkItemHandler not honoring data type

    borlinp

      Hi,

       

      I am in the process of upgrading from Drools 5.0 rule flows to jBPM 5.3 BPMN processes.  All is going well for the most part, but I ran into an odd snag.  I have 25+ WorkItemHandler's defined.  Several of them use IntegerDataType's for input parameters.  Now, in jBPM 5.3, all parameters seem to be passed to the hander as String, regardless if it's defined as a type other than StringDataType().

       

      For example, let me share one definition that is causing me fits:

       

      [

              "name" : "SFTPget",

              "parameters" : [

                  "Host Name" : new StringDataType(),

                  "User Name" : new StringDataType(),

                  "Password" : new StringDataType(),

                  "File Location" : new StringDataType(),

                  "File Name" : new StringDataType(),

                  "Target Directory" : new StringDataType(),

                  "Delete Original" : new StringDataType(),

                  "Log Level" : new StringDataType(),

                  "Date Format" : new StringDataType(),

                  "Date Format to lowercase" : new StringDataType(),

                  "Date Format Offset" : new IntegerDataType(),

                  "Reply Timeout": new IntegerDataType()

              ],

              "displayName" : "sFTP Get",

              "icon" : "icons/computer_world.gif"

          ]

       

       

      In the WorkItemHandler, I have the following code that worked prior to upgrading, but now throws ClassCastException:

       

      Integer dateOffset = (Integer) ((workItem.getParameter("Date Format Offset") == null)? 0: workItem.getParameter("Date Format Offset"));

       

      The object returned by workItem.getParameter("Date Format Offset") is a String.

       

       

      My questions would be as follows:

      1. Is this just the way jBPM 5.3 works, and am I to manually cast all parameters from String to the desired type?

      2. If #1 is no, then is this a bug or something I need to change in my code?

       

      Thanks for the help/tips!

       

      -Paul

        • 1. Re: WorkItemHandler not honoring data type
          borlinp

          This appears to be a feature of the past.  I've discovered that the DataType implementations were handled in the rule flow <parameter> element in addtion to the work item definition.  Currently, there isn't an element or attribute in the BPMN2 XML to set such.  Additionally, I've discoverd that the IDE in eclipse barks if you attempt to update any definition that is not StringDataType in the work item definition.

           

          If I were designing this....

          I'd make a single point of definition for these handler parameter types and import them on compile of the processes definition.  It would be wonderful to bring this feature back in any stretch of the imagination!