Search in sources :

Example 11 with Reassignment

use of org.kie.internal.task.api.model.Reassignment in project jbpm by kiegroup.

the class UserTaskAdminServiceImpl method reassign.

protected Long reassign(String deploymentId, long taskId, String timeExpression, DeadlineType type, OrganizationalEntity... orgEntities) throws TaskNotFoundException {
    UserTaskInstanceDesc task = runtimeDataService.getTaskById(taskId);
    validateTask(deploymentId, taskId, task);
    if (timeExpression == null || timeExpression.isEmpty()) {
        throw new IllegalArgumentException("Invalid time expression");
    }
    if (orgEntities == null || orgEntities.length <= 0) {
        throw new IllegalArgumentException("Invalid org entity");
    }
    List<Escalation> escalations = new ArrayList<Escalation>();
    Deadline taskDeadline = TaskModelProvider.getFactory().newDeadline();
    taskDeadline.setEscalations(escalations);
    Escalation escalation = TaskModelProvider.getFactory().newEscalation();
    escalations.add(escalation);
    escalation.setName("Admin reassignment for task " + taskId);
    List<Reassignment> reassignments = new ArrayList<Reassignment>();
    Reassignment reassignment = TaskModelProvider.getFactory().newReassignment();
    reassignment.setPotentialOwners(new ArrayList<>(Arrays.asList(orgEntities)));
    reassignments.add(reassignment);
    escalation.setReassignments(reassignments);
    return userTaskService.execute(task.getDeploymentId(), ProcessInstanceIdContext.get(task.getProcessInstanceId()), new ScheduleTaskDeadlineCommand(identityProvider.getName(), taskId, type, taskDeadline, timeExpression));
}
Also used : Escalation(org.kie.internal.task.api.model.Escalation) Deadline(org.kie.internal.task.api.model.Deadline) ArrayList(java.util.ArrayList) ScheduleTaskDeadlineCommand(org.jbpm.kie.services.impl.admin.commands.ScheduleTaskDeadlineCommand) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc) TaskReassignment(org.jbpm.services.api.admin.TaskReassignment) Reassignment(org.kie.internal.task.api.model.Reassignment)

Example 12 with Reassignment

use of org.kie.internal.task.api.model.Reassignment in project jbpm by kiegroup.

the class CollectionUtils method readReassignmentList.

public static List<Reassignment> readReassignmentList(ObjectInput in) throws IOException, ClassNotFoundException {
    int size = in.readInt();
    List<Reassignment> list = new ArrayList<Reassignment>(size);
    for (int i = 0; i < size; i++) {
        Reassignment item = new ReassignmentImpl();
        item.readExternal(in);
        list.add(item);
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) Reassignment(org.kie.internal.task.api.model.Reassignment) ReassignmentImpl(org.jbpm.services.task.impl.model.ReassignmentImpl)

Aggregations

Reassignment (org.kie.internal.task.api.model.Reassignment)12 Deadlines (org.kie.internal.task.api.model.Deadlines)7 WorkItem (org.drools.core.process.instance.WorkItem)6 WorkItemImpl (org.drools.core.process.instance.impl.WorkItemImpl)6 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)5 OrganizationalEntity (org.kie.api.task.model.OrganizationalEntity)3 Deadline (org.kie.internal.task.api.model.Deadline)3 Escalation (org.kie.internal.task.api.model.Escalation)3 TaskReassignment (org.jbpm.services.api.admin.TaskReassignment)2 Group (org.kie.api.task.model.Group)2 Task (org.kie.api.task.model.Task)2 User (org.kie.api.task.model.User)2 InternalOrganizationalEntity (org.kie.internal.task.api.model.InternalOrganizationalEntity)2 Notification (org.kie.internal.task.api.model.Notification)2 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1