Search in sources :

Example 1 with ScheduleTaskDeadlineCommand

use of org.jbpm.kie.services.impl.admin.commands.ScheduleTaskDeadlineCommand in project jbpm by kiegroup.

the class UserTaskAdminServiceImpl method notify.

protected Long notify(String deploymentId, long taskId, String timeExpression, DeadlineType type, Notification notification) throws TaskNotFoundException {
    UserTaskInstanceDesc task = runtimeDataService.getTaskById(taskId);
    validateTask(deploymentId, taskId, task);
    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 notification for task " + taskId);
    List<Notification> notifications = new ArrayList<Notification>();
    notifications.add(notification);
    escalation.setNotifications(notifications);
    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) TaskNotification(org.jbpm.services.api.admin.TaskNotification) Notification(org.kie.internal.task.api.model.Notification) EmailNotification(org.kie.internal.task.api.model.EmailNotification)

Example 2 with ScheduleTaskDeadlineCommand

use of org.jbpm.kie.services.impl.admin.commands.ScheduleTaskDeadlineCommand 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)

Aggregations

ArrayList (java.util.ArrayList)2 ScheduleTaskDeadlineCommand (org.jbpm.kie.services.impl.admin.commands.ScheduleTaskDeadlineCommand)2 UserTaskInstanceDesc (org.jbpm.services.api.model.UserTaskInstanceDesc)2 Deadline (org.kie.internal.task.api.model.Deadline)2 Escalation (org.kie.internal.task.api.model.Escalation)2 TaskNotification (org.jbpm.services.api.admin.TaskNotification)1 TaskReassignment (org.jbpm.services.api.admin.TaskReassignment)1 EmailNotification (org.kie.internal.task.api.model.EmailNotification)1 Notification (org.kie.internal.task.api.model.Notification)1 Reassignment (org.kie.internal.task.api.model.Reassignment)1