jBPM 6.2 How to add an user that can execute all tasks?

非 Y 不嫁゛ 提交于 2019-12-10 11:55:29

问题


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:


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 BusinessAdministrator. 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 behaviour 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>



来源:https://stackoverflow.com/questions/30535502/jbpm-6-2-how-to-add-an-user-that-can-execute-all-tasks

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!