Manage Alfresco´s JBPM Implementation Context

As a current task in the current project, its a requirement providing access to all comments of a workflow. For sure, you can doing this by retriving all completet tasks orderd by creation time. This can be performed using WorklfowQueries like this:

WorkflowTaskQuery query = new WorkflowTaskQuery();
query.setActive(null);

query.setProcessId(wi.id);

query.setTaskState(WorkflowTaskState.COMPLETED);

query.setOrderBy(new WorkflowTaskQuery.OrderBy[] {

  WorkflowTaskQuery.OrderBy.TaskCreated_Desc,

  WorkflowTaskQuery.OrderBy.TaskActor_Asc });
  List<WorkflowTask> tasks = Repository.getServiceRegistry(context).

     getWorkflowService().queryTasks(query);

But this is just one approach to getting what we currently need. Another option is to setting up a processing variable in the workflow context. Once the node is leaved by the token a event has been implemented for adding every task comment to the global variable. Its a little bit tricky, i mention, because alfresco differentiates between jbpm variables and event-driven variables. So if you want using jbpm variables in the workflow context accessing the jbpm context is a requirement for retriving the appropriate comment variable. Hence, when alfresco stores a comment given by user, normally this variable does not appering in the alfresco workflow context. Therefore, accessing directly jbpm variables is the right way:

<event type="task-end">
  <script>
    <expression>
      wf_reviewerCount = wf_reviewerCount + 1;
      if(token.comments.size() > 0){
        for(i = 0; i < token.comments.size(); i++)
          bpm_allComments += "rn" + token.comments.get(i).getMessage();
          <!-- this doesnt work and we getting still void as value:
               bpm_allComments += "rn" + bpm_comment;
          -->
        }
      </expression>
    <variable name="wf_reviewerCount" access="read,write" />
    <variable name="bpm_allComments" access="read,write" />
  </script>
</event>

Comments

2 Responses to “Manage Alfresco´s JBPM Implementation Context”

  1. Marijn Vriens. on January 2nd, 2009 8:20 pm

    Thanks for the comment.

    I stumbled upon your blog looking for a solution to this problem, but with a slight twist. I would like to add the user that added that particular comment. Something like:

    bpm_allComments += “rn” + current_task_user + token.comments.get(i).getMessage();

    I’ve been messing for quite a while, but for the life of me, I cannot get at this user. Quite annoying since I do see this information when doing desc task as “{http://www.alfresco.org/model/content/1.0}owner”

    Thanks,
    Marijn.

  2. Sebastian Wenzky on January 2nd, 2009 11:40 pm

    looks like following for me:

    bpm_allComments += “rn” +
    bpm_assignee.properties[”cm:userName”] + token.comments.get(i).getMessage();

Leave a Reply




Security Code: