use of org.kie.internal.task.api.TaskDeadlinesService.DeadlineType in project jbpm by kiegroup.
the class CancelTaskDeadlineCommand method execute.
@Override
public Void execute(Context cntxt) {
TaskContext context = (TaskContext) cntxt;
Task task = context.getTaskQueryService().getTaskInstanceById(taskId);
if (!isBusinessAdmin(userId, task.getPeopleAssignments().getBusinessAdministrators(), context)) {
throw new PermissionDeniedException("User " + userId + " is not business admin of task " + taskId);
}
logger.debug("About to cancel deadline {} on a task {}", deadlineId, task);
Deadlines deadlines = ((InternalTask) task).getDeadlines();
DeadlineType type = DeadlineType.START;
Deadline deadline = deadlines.getStartDeadlines().stream().filter(d -> deadlineId.equals(d.getId())).findFirst().orElse(null);
if (deadline == null) {
deadline = deadlines.getEndDeadlines().stream().filter(d -> deadlineId.equals(d.getId())).findFirst().orElse(null);
type = DeadlineType.END;
}
TaskPersistenceContext persistenceContext = context.getPersistenceContext();
TaskDeadlinesService deadlinesService = context.getTaskDeadlinesService();
deadlinesService.unschedule(taskId, deadline, type);
persistenceContext.removeDeadline(deadline);
return null;
}
Aggregations