[jBPM] - Is it possible to create task with multiple groupId constraint?
by Thomas Setiabudi
Thomas Setiabudi [https://community.jboss.org/people/thomas.setiabudi] created the discussion
"Is it possible to create task with multiple groupId constraint?"
To view the discussion, visit: https://community.jboss.org/message/778524#778524
--------------------------------------------------------------
Hi,
Lets say we have two user grouping tables:
1. UserDepartment -> this table maps user with department like Accounting, Human Resource, or Marketing. sample record would be: (thomas, Accounting)
2. UserJobTitle -> this table maps user with job title like staff, supervisor, or manager. sample record would be: (thomas, Supervisor)
Now, we have a human task in our process, the human task can be done by any Supervisor in Accounting department.
How do we do it?
Based on IRC chat with Maciej: By Default Group Assignment is based on OR operator
The only workaround that I can use for now is to manipulate the group name, concatenate it to one single String like this:
"Accounting|Supervisor"
That works, but it adds more complication as we have more and more group combination, lets say instead of those two groups, we have three more tables.
Any idea?
Is it a good candidate to ask a feature request for this requirement?
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/778524#778524]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
11 years, 12 months
[jBPM] - Re: Could not getting tasks for business administrators through task client
by Maciej Swiderski
Maciej Swiderski [https://community.jboss.org/people/swiderski.maciej] created the discussion
"Re: Could not getting tasks for business administrators through task client"
To view the discussion, visit: https://community.jboss.org/message/778258#778258
--------------------------------------------------------------
No, it fact the problem was that you used getTasksAssignedAsPotentialOwner method instead of one dedicated to get tasks assigned as business user, see in bold:
> tom sebastian wrote:
>
> This was my class.
>
> public class BusinessAdminTest {
>
>
> private static final long DEFAULT_WAIT_TIME = 10000l;
> private TaskClient client;
> private WorkItemManager manager;
> private String ipAddress="192.168.1.111";
> private int port=9123;
>
> private void createClient() {
> if (client == null) {
> client = new TaskClient(new MinaTaskClientConnector("com.task.BusinessAdminTest",
> new MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));
> boolean connected = client.connect(ipAddress, port);
> if (!connected) {
> throw new IllegalArgumentException("Could not connect task client");
> }
> }
> }
> public void test() throws Throwable{
>
>
>
> // Create the task
> //assumed testGroup contain 'Mary','John' users
> Task task1 = createTask("TaskName", "Comment","Tom","testGroup");
> BlockingTaskOperationResponseHandler operationResponseHandler = new BlockingTaskOperationResponseHandler();
> client.addTask(task1, null, null);
>
>
> Thread.sleep(500);
>
> // Test if the task is successfully created
> BlockingTaskSummaryResponseHandler responseHandler = new BlockingTaskSummaryResponseHandler();
> client.getTasksAssignedAsPotentialOwner("Tom", "en-UK",
> responseHandler);
> responseHandler.waitTillDone(DEFAULT_WAIT_TIME);
> List tasks = responseHandler.getResults();
> if(tasks!=null){
> System.out.println(tasks.size());
> TaskSummary summary=(TaskSummary) tasks.get(0);
> System.out.println(summary.getStatus().toString());//will be 'Ready'
>
> }
> //Try to get task as business administrator
> responseHandler = new BlockingTaskSummaryResponseHandler();
> * client.getTasksAssignedAsPotentialOwner("administrator", "en-UK",*
> * responseHandler);*
> responseHandler.waitTillDone(DEFAULT_WAIT_TIME);
> tasks = responseHandler.getResults();
> if(tasks!=null){// according to WS specification, we expect to get task
> System.out.println(tasks.size());
> TaskSummary summary=(TaskSummary) tasks.get(0);
> System.out.println(summary.getStatus().toString());
>
> }
>
> }
> public TaskClient getClient() {
> return client;
> }
> public void setClient(TaskClient client) {
> this.client = client;
> }
> private Task createTask(String taskName, String comment, String actorId,String groupId) {
> Task task = new Task();
> if (taskName != null) {
> List names = new ArrayList();
> names.add(new I18NText("en-UK", taskName));
> task.setNames(names);
> }
> if (comment != null) {
> List descriptions = new ArrayList();
> descriptions.add(new I18NText("en-UK", comment));
> task.setDescriptions(descriptions);
> List subjects = new ArrayList();
> subjects.add(new I18NText("en-UK", comment));
> task.setSubjects(subjects);
> }
> task.setPriority(10);
>
>
> TaskData taskData = new TaskData();
>
>
>
> PeopleAssignments assignments = new PeopleAssignments();
> List potentialOwners = new ArrayList();
>
>
> if (actorId != null && actorId.trim().length() > 0) {
>
> potentialOwners.add(new User(actorId.trim()));
> }
> if (groupId != null && groupId.trim().length() > 0) {
>
> potentialOwners.add(new Group(groupId.trim()));
>
> }
> // Set the first user as creator ID??? hmmm might be wrong
> if (potentialOwners.size() > 0) {
> taskData.setCreatedBy((User) potentialOwners.get(0));
> }
>
> assignments.setPotentialOwners(potentialOwners);
> List businessAdministrators = new ArrayList();
> businessAdministrators.add(new User("administrator"));
> assignments.setBusinessAdministrators(businessAdministrators);
> task.setPeopleAssignments(assignments);
>
> taskData.setSkipable(true);
>
> task.setTaskData(taskData);
>
> return task;
> }
>
> public void setManager(WorkItemManager manager) {
> this.manager = manager;
> }
> public WorkItemManager getManager() {
> return manager;
> }
>
> public static void main(String[] a){
> BusinessAdminTest baTest = new BusinessAdminTest();
> baTest.createClient();
> try {
> baTest.test();
> } catch (Throwable e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> }
> }
>
>
>
>
>
>
> When i run this ,the output was(the first 2 lines indicate the number of tasks and its status as potential owner, while the remaining as business admin for the same task)
>
> 1
> Ready
> 0
> java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/778258#778258]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
11 years, 12 months