use of org.kie.internal.task.api.model.Escalation in project jbpm by kiegroup.
the class HumanTaskHandlerHelper method parseDeadlineString.
protected static List<Deadline> parseDeadlineString(String deadlineInfo, List<OrganizationalEntity> businessAdministrators, Environment environment) {
if (deadlineInfo == null || deadlineInfo.length() == 0) {
return new ArrayList<Deadline>();
}
List<Deadline> deadlines = new ArrayList<Deadline>();
String[] allComponents = deadlineInfo.split(COMPONENT_SEPARATOR);
BusinessCalendar businessCalendar = null;
if (environment != null && environment.get("jbpm.business.calendar") != null) {
businessCalendar = (BusinessCalendar) environment.get("jbpm.business.calendar");
}
for (String component : allComponents) {
String[] mainComponents = component.split(ELEMENT_SEPARATOR);
if (mainComponents != null && mainComponents.length == 2) {
String actionComponent = mainComponents[0].substring(1, mainComponents[0].length() - 1);
String expireComponents = mainComponents[1].substring(1, mainComponents[1].length() - 1);
String[] expireElements = expireComponents.split(ATTRIBUTES_ELEMENTS_SEPARATOR);
Deadline taskDeadline = null;
for (String expiresAt : expireElements) {
logger.debug("Expires at is {}", expiresAt);
taskDeadline = TaskModelProvider.getFactory().newDeadline();
if (businessCalendar != null) {
taskDeadline.setDate(businessCalendar.calculateBusinessTimeAsDate(expiresAt));
} else {
taskDeadline.setDate(new Date(System.currentTimeMillis() + TimeUtils.parseTimeString(expiresAt)));
}
logger.debug("Calculated date of execution is {} and current date {}", taskDeadline.getDate(), new Date());
List<Escalation> escalations = new ArrayList<Escalation>();
Escalation escalation = TaskModelProvider.getFactory().newEscalation();
escalations.add(escalation);
escalation.setName("Default escalation");
taskDeadline.setEscalations(escalations);
escalation.setReassignments(parseReassignment(actionComponent));
escalation.setNotifications(parseNotifications(actionComponent, businessAdministrators));
deadlines.add(taskDeadline);
}
} else {
logger.warn("Incorrect syntax of deadline property {}", deadlineInfo);
}
}
return deadlines;
}
use of org.kie.internal.task.api.model.Escalation 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));
}
Aggregations