7 Replies Latest reply on Sep 8, 2011 7:00 PM by sroot

    JBPM5 Content data problem

    sroot

      Hi all!

      I was wondering if someone might be able to assist with this.

      I have a process with a custom task and User Task,

      I have Map and couple of Strings def

       

      ined as process variables.

      When the process goes to human task, and I retrieve

       

      the Content for the Task via the TaskClient using Mina, I am unable to restore the Map. I found the following in the HumanTaskExample and it is exactly what I was doing

      Content content = getContentResponseHandler.getContent();

      ByteArrayInputStream bis = new ByteArrayInputStream(content.getContent());

      ObjectInputStream in;

      in = newObjectInputStream(bis);

      Object result = in.readObject();

      in.close();

      Map<?, ?> map = (Map<?, ?>) result;

       

       

      The problem is that "result" at this point is seen as a java.lang.String. All of my data is there when I print it out but I am unable to cast it back to a map. My process variable Map is being set when I complete the previous workitem

       

      Am I missing something here? Looking at the JBPM source and examples it seems like this should work.

       

       

      I'd appreciate all input, thanks.

       

      -Scott.

        • 1. Re: JBPM5 Content data problem
          calca

          Could please you share:

          1) your process definition

          2) how you are calling the taskClient.complete method?

           

          Thanks

           

          Demian

          • 2. Re: JBPM5 Content data problem
            sroot

            Thanks for responding.

            Process def attached to oringal post above.

            My problem is even before I call taskClient.complete.

            Its at the point where I retreive the Content and need to display data to the user. At that point content.getContent() I expect to return a byte array of type Map, but it is always String. It does have my Map key/value pairings and the values may themselves be another Map or even a List

             

            This is how I get the Content:

             

             

             

             

             

            public Content getContentForTask(Task task) {

            long documentContentId = task.getTaskData().getDocumentContentId();

            BlockingGetContentResponseHandler getContentResponseHandler =

            new BlockingGetContentResponseHandler();

             

            taskClient.getContent(documentContentId, getContentResponseHandler);

             

            return getContentResponseHandler.getContent();

            }

             

            • 3. Re: JBPM5 Content data problem
              calca

              If I don't remember wrong, if you evaluate this expresion:

                      <targetRef>_12_ContentInput</targetRef>

                      <assignment>

                        <from xsi:type="tFormalExpression">#{transportMap}</from>

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

                      </assignment>

               

              It is converted to string.

               

              You could try this one:

                       <sourceRef>transportMap</sourceRef>

                      <targetRef>_12_ContentInput</targetRef>

               

              Demian

              • 4. Re: JBPM5 Content data problem
                calca
                • 5. Re: JBPM5 Content data problem
                  sroot

                  Hmmmm, so does that mean that you really can't have anything other than a String as a process variable if you want to be able to later retrieve and display it from the Content of a Task?

                   

                  Note that I am using the WSHumanTaskHandler and in my custom task handler just before the User Task I set my Map on a resuts map and then pass the results Map when I complete the workItem:

                   

                  Map<String, Object> resultsMap = new HashMap<String, Object>();

                  resultsMap.put("MYMAP", myMap);

                  resultsMap.put("OTHERSTUFF", otherStuff);

                  workItemManager.completeWorkItem(workItem.getId(), resultMap);

                   

                  The next step is User Task and I then attemtpt to retrieve the original Map from Task Content.

                  • 6. Re: JBPM5 Content data problem
                    calca

                    No, it does not mean so..

                    If you use the expresion assignment(<from xsi:type="tFormalExpression">#{transportMap}</from>), it is resolved as an string, but if you map your process variable like this

                             <sourceRef>transportMap</sourceRef>

                            <targetRef>_12_ContentInput</targetRef>

                    I think should work.

                     

                    You can check for example here:

                    https://github.com/Salaboy/emergency-service-drools-app/blob/master/emergency-service-core/src/main/resources/processes/procedures/DefaultHeartAttackProcedure.bpmn

                     

                    To see how that parameters to the user task are sent.

                    For example,

                    <dataInputAssociation>

                            <sourceRef>emergency</sourceRef>

                            <targetRef>_6_emergencyInput</targetRef>

                          </dataInputAssociation>

                     

                    You can also check this post:

                    http://dcalca.wordpress.com/2011/05/06/variables-in-jbpm5-human-tasks/

                     

                    Demian    

                    • 7. Re: JBPM5 Content data problem
                      sroot

                      Thanks Demian!

                      That was extremley helpful.

                      I have it working now.