3 Replies Latest reply on Jan 12, 2012 1:32 PM by tsurdilovic

    Problem accessing Mapped Input Parameter in domain specific work item handler.

    krujos

      Hello,

       

      I'm having an isue accessing a mapped input parameter from my work item handler. I'm using jbpm 5.2. Reading the documentation & examples this seems like it should be straight forward, but I must have missed a step somewhere. Could someone please provide a pointer as to where I've gone wrong?

       

      My .wid looks like this:

      {code}

      import org.drools.process.core.datatype.impl.type.StringDataType;

       

      [

        [

          "name" : "MyWorkItem",

          "parameters" : [

            "Text" : new StringDataType(),

            "OptionXML" : new StringDataType(),

          ],

          "displayName" : "MyWorkItem",

        ]

      ]

      {code}

       

      The relevant bpmn looks like this:

      {code:xml}

      ...

      ...

      <property id="boolResult" itemSubjectRef="_boolResultItem"/>

      ...

         <startEvent id="StartEvent_1" name="Start" />

          <task id="_3" name="This is a single select." tns:taskName="MyWorkItem" >

            <ioSpecification>

              <dataInput id="_3_boolResultInput" name="boolResult" />

              <dataInput id="_3_OptionXMLInput" name="OptionXML" />

              <dataInput id="_3_TextInput" name="Text" />

              <dataOutput id="_3_singleResultOutput" name="singleResult" />

              <inputSet>

                <dataInputRefs>_3_boolResultInput</dataInputRefs>

                <dataInputRefs>_3_OptionXMLInput</dataInputRefs>

                <dataInputRefs>_3_TextInput</dataInputRefs>

              </inputSet>

              <outputSet>

                <dataOutputRefs>_3_singleResultOutput</dataOutputRefs>

              </outputSet>

            </ioSpecification>

            <dataInputAssociation>

              <sourceRef>boolResult</sourceRef>

              <targetRef>_3_boolResultInput</targetRef>

            </dataInputAssociation>

            <dataInputAssociation>

              <targetRef>_3_OptionXMLInput</targetRef>

              <assignment>

                <from xsi:type="tFormalExpression">&lt;xml&gt;foo&lt;/questions&gt;</from>

                <to xsi:type="tFormalExpression">_3_OptionXMLInput</to>

              </assignment>

            </dataInputAssociation>

            <dataInputAssociation>

              <targetRef>_3_TextInput</targetRef>

              <assignment>

                <from xsi:type="tFormalExpression">This is my text</from>

                <to xsi:type="tFormalExpression">_3_TextInput</to>

              </assignment>

            </dataInputAssociation>

            <dataOutputAssociation>

              <sourceRef>_3_singleResultOutput</sourceRef>

              <targetRef>singleResult</targetRef>

            </dataOutputAssociation>

          </task>

      {code}

       

      When I try to access the mapped parameter boolResult from my workitem handler I do the following:

       

      {code}

      public final void executeWorkItem(WorkItem wi, WorkItemManager wim) {

                logger.info("Loading workitem: " + wi.getId());

       

                for (String key : wi.getParameters().keySet()) {

                          logger.info("Parameter: " + key);

                }

                logger.info("boolResult = " + wi.getParameter("boolResult"));

      {code}

       

      In my log I see the values of OptionXML and Text in the parameters hash, but boolResult is not in the hash. Is my expectation that mapped parameters should show up in the work item's parametrs correct? Does anyone see an error?

      Thanks!

      Josh

        • 1. Re: Problem accessing Mapped Input Parameter in domain specific work item handler.
          tsurdilovic

          Any parameter you define in your BPMN2 should be accessible in the workitem. The wid is simply just to show some default paramters in the tooling support (Eclipse, Designer).

           

          I think the problem may be here:

           

          <dataInputAssociation>

                  <sourceRef>boolResult</sourceRef>

                  <targetRef>_3_boolResultInput</targetRef>

                </dataInputAssociation>

           

          You seem to be mapping boolResult to itself and not setting its value.

           

          Hope this helps.

          • 2. Re: Problem accessing Mapped Input Parameter in domain specific work item handler.
            krujos

            Thnaks for the reply!

            My goal is to map the process parameter boolResult into the workItem as a parameter named boolResult. I've tried changing the name of the paramater to something different than boolResult, but the result is the same.

             

            The xml is generated by the eclipse plugin, is that trustworthy?

             

            Here's the snip of the process variables decleration:

             

            {code}

              <process processType="Private" isExecutable="true" id="com....jbpm.select_examples" name="select_examples" tns:packageName="com....jbpm" >

             

             

                <!-- process variables -->

                <property id="boolResult" itemSubjectRef="_boolResultItem"/>

                <property id="singleResult" itemSubjectRef="_singleResultItem"/>

                <property id="multiResult" itemSubjectRef="_multiResultItem"/>

            ...

            {code}

             

            Is it not allowed / reccomended to use the same name in both places?

             

            FWIW I'm able to use boolResult in a resultMapping in this fashion (i.e. boolResult => boolResult).

            • 3. Re: Problem accessing Mapped Input Parameter in domain specific work item handler.
              tsurdilovic

              I think it's ambiguous anyways to define a process variable and a data input parameter of a task that have the same name.

              In your case lets say you have a process var:

              <property id="boolResult" itemSubjectRef="_boolResultItem"/>

              Then in your task you could have lets say:

              <ioSpecification>

              ....

              <dataInput id="_3_boolResultINInput" name="boolResultIN" />

                 <inputSet>

                 ...

                 <dataInputRefs>_3_boolResultINInput</dataInputRefs>

                 </>

                 <dataInputAssociation>

                      <sourceRef>boolResult</sourceRef>

                      <targetRef>_3_boolResultINInput</targetRef>

                  </dataInputAssociation>

                  ...

              </>

               

              You do have to make sure to set a value for the boolResult process var when you start the process or that it has a value by the time it reaches your task.

               

              Hope this helps.