0
votes

In jBPM 6.2, we can assign an user task to either an actor or a group such that they are the potential owners of these tasks. Is there an user that we can define in code or bpmn file so that he can execute all the user tasks regardless of the fact that the task is assigned to him or not?

1

1 Answers

3
votes

Create a user with the username "Administrator", or use one of your existing users and add it to the group "Administrators". This gives the user(s) in question access to the task as Business Administrator. This should work for most of your requirements.

If you experience any challenges with this approach, another option could be to implement your own custom task assignment behavior in the 'Human Task' WorkItemHandler, but let's first try the approach mentioned above.

As requested a code example of this approach would be:

  1. Implement a class test.CustomHTWorkItemHandler that extends LocalHTWorkItemHandler (https://github.com/droolsjbpm/jbpm/blob/master/jbpm-human-task/jbpm-human-task-workitems/src/main/java/org/jbpm/services/task/wih/LocalHTWorkItemHandler.java).
  2. Give it a new consuctor:

    public CustomHTWorkItemHandler(RuntimeManager runtimeManager){
           super.setRuntimeManager(runtimeManager);
    }
    
  3. Override method createTaskBasedOnWorkItemParams:

    protected Task createTaskBasedOnWorkItemParams(KieSession session, WorkItem workItem) {
           InternalTask task =(InternalTask)super.createTaskBasedOnWorkItemParams(session,workItem);
           Group adminGroup = TaskModelProvider.getFactory().newGroup();
           ((InternalOrganizationalEntity) adminGroup).setId("MySpecialAdminGroup");        
           task.getPeopleAssignments().getBusinessAdministrators().add(adminGroup);
           return task;
    }     
    
  4. in your deployment descriptor XML file, register your new CustomHTWorkItemHandler:

    <work-item-handler>
           <resolver>mvel</resolver>
           <identifier>new test.CustomHTWorkItemHandler(runtimeManager)</identifier>
             <name>Human Task</name>
    </work-item-handler>