4 Replies Latest reply on Jan 28, 2011 10:04 AM by candy_633

    JBPM 5 variable (Result Mapping Problem)

    candy_633

      Hello, JBPM friends,

       

      I am a beginner with JBPM 5, could I ask a question related to variable?

       

      I want to passing Java class parameters through JBPM nodes. Using "Parameter Mappping" in properties of graph can control input parameters of nodes, which is also <dataInputAssociation> in xml. But "Result Mapping" is not working. I can not passing parameters out and send it to the next node.

       

      Do you know how to realize this?

       

      I appreciate your help so much!

       

      Best Regards,

       

      Candy

        • 1. JBPM 5 variable (Result Mapping Problem)
          krisverlaenen

          Here's an example:

          https://github.com/krisv/jbpm/blob/master/jbpm-bpmn2/src/test/resources/BPMN2-ServiceProcess.bpmn2

           

          Did you define your variables you are mapping your parameters to as a process variable?

          And are you sure that the data that is being passed in as the result is not null?

           

          Kris

          • 2. JBPM 5 variable (Result Mapping Problem)
            candy_633

            Dera Kris,

             

            Thank you so much for your reply. I guess the problem is related to my Java code. Could you please help me take a look at it? I attached my test project "HelloJBPM.zip" to the article on the first floor.

             

             

            I appreciate your help so much!

             

             

            I tried your example, there are some errors:

             

            1) seems my code could not call: ServiceTaskHandler(), even I import org.jbpm.bpmn2.handler.ServiceTaskHandler;

             

            2) my code could not identify <serviceTask; I am using <task id="_4" name="RecordHandler" tns:taskName="Handler" >, is it because of different version?

             

             

            Thanks you so much!

             

             

            Shanshan

            • 3. JBPM 5 variable (Result Mapping Problem)
              krisverlaenen

              You are using a task with task name "Handler" and registering your WorkingHandler, so that will be invoked when the task needs to be executed.  If you want to pass data back in as the result of the execution, you should however do so when completing your work item, for example:

               

                          Map results = new HashMap();

                          results.put("MyResultParam", "MyValue");

                          manager.completeWorkItem(workItem.getId(), results);

               

              Your result mapping also seems to be incorrect.  In this case, you should map the value of the parameter "MyResultParam" to the process variable "Result" in the result mapping: {MyResultParam=Result}

              This looks like this in bpmn2 xml:

                  <task id="_4" name="Notification" tns:taskName="Notification" >

                    <ioSpecification>

                        .....

                      <dataOutput id="_4_MyResultParamOutput" name="MyResultParam" />

                       .....

                      <outputSet>

                        <dataOutputRefs>_4_MyResultParamOutput</dataOutputRefs>

                      </outputSet>

                    </ioSpecification>
                     .....

                    <dataOutputAssociation>

                      <sourceRef>_4_MyResultParamOutput</sourceRef>

                      <targetRef>Result</targetRef>

                    </dataOutputAssociation>

                  </task>

               

              After that, your value should be written out in the final script task.

               

              Kris

              • 4. JBPM 5 variable (Result Mapping Problem)
                candy_633

                Thank you so much Kris for helping us!!!