use of org.kie.api.task.model.Group in project jbpm by kiegroup.
the class EscalateToAdminSLAViolationListener method afterSLAViolated.
@Override
public void afterSLAViolated(SLAViolatedEvent event) {
CaseFileInstance caseFile = getCaseFile((KieSession) event.getKieRuntime());
if (caseFile != null) {
String caseId = ((WorkflowProcessInstanceImpl) event.getProcessInstance()).getCorrelationKey();
if (caseFile.getCaseId().equals(caseId)) {
try {
Collection<OrganizationalEntity> adminAssignments = ((CaseAssignment) caseFile).getAssignments("admin");
String users = adminAssignments.stream().filter(oe -> oe instanceof User).map(oe -> oe.getId()).collect(Collectors.joining(","));
String groups = adminAssignments.stream().filter(oe -> oe instanceof Group).map(oe -> oe.getId()).collect(Collectors.joining(","));
String taskName = "SLA violation for case " + caseId;
String taskDescription = "Service Level Agreement has been violated for case " + caseId;
if (event.getNodeInstance() != null) {
taskName += "Task (" + event.getNodeInstance().getNodeName() + ") SLA violation for case " + caseId;
taskDescription += " on task " + event.getNodeInstance().getNodeName();
}
logger.debug("Case instance {} has SLA violation, escalating to administrator", caseId);
CaseService caseService = (CaseService) ServiceRegistry.get().service(ServiceRegistry.CASE_SERVICE);
TaskSpecification taskSpec = caseService.newHumanTaskSpec(taskName, taskDescription, users, groups, null);
caseService.addDynamicTask(caseId, taskSpec);
} catch (IllegalArgumentException e) {
logger.debug("There is no admin role defined in case instance {}, unable to escalate SLA violation", caseId);
}
}
}
}
use of org.kie.api.task.model.Group in project jbpm by kiegroup.
the class RoundRobinAssignmentStrategy method getExcludedEntities.
private static List<OrganizationalEntity> getExcludedEntities(Task task, UserInfo userInfo) {
List<OrganizationalEntity> excluded = ((InternalPeopleAssignments) task.getPeopleAssignments()).getExcludedOwners();
List<OrganizationalEntity> excludedUsers = new ArrayList<>();
for (OrganizationalEntity entity : excluded) {
if (entity instanceof Group) {
userInfo.getMembersForGroup((Group) entity).forEachRemaining(excludedUsers::add);
}
}
excluded.addAll(excludedUsers);
return excluded;
}
use of org.kie.api.task.model.Group in project jbpm by kiegroup.
the class UserGroupCallbackTaskCommand method persistIfNotExists.
protected void persistIfNotExists(final OrganizationalEntity entity, TaskContext context) {
TaskPersistenceContext tpc = context.getPersistenceContext();
OrganizationalEntity orgEntity = tpc.findOrgEntity(entity.getId());
if (orgEntity == null || (orgEntity instanceof Group && entity instanceof User) || (orgEntity instanceof User && entity instanceof Group)) {
tpc.persistOrgEntity(entity);
}
}
use of org.kie.api.task.model.Group in project jbpm by kiegroup.
the class UserGroupCallbackTaskCommand method doCallbackOperationForTaskDeadlines.
protected void doCallbackOperationForTaskDeadlines(Deadlines deadlines, TaskContext context) {
if (deadlines != null) {
if (deadlines.getStartDeadlines() != null) {
List<? extends Deadline> startDeadlines = deadlines.getStartDeadlines();
for (Deadline startDeadline : startDeadlines) {
List<? extends Escalation> escalations = startDeadline.getEscalations();
if (escalations != null) {
for (Escalation escalation : escalations) {
List<? extends Notification> notifications = escalation.getNotifications();
List<? extends Reassignment> ressignments = escalation.getReassignments();
if (notifications != null) {
for (Notification notification : notifications) {
List<? extends OrganizationalEntity> recipients = notification.getRecipients();
if (recipients != null) {
for (OrganizationalEntity recipient : recipients) {
if (recipient instanceof User) {
doCallbackUserOperation(recipient.getId(), context);
}
if (recipient instanceof Group) {
doCallbackGroupOperation(recipient.getId(), context);
}
}
}
List<? extends OrganizationalEntity> administrators = notification.getBusinessAdministrators();
if (administrators != null) {
for (OrganizationalEntity administrator : administrators) {
if (administrator instanceof User) {
doCallbackUserOperation(administrator.getId(), context);
}
if (administrator instanceof Group) {
doCallbackGroupOperation(administrator.getId(), context);
}
}
}
}
}
if (ressignments != null) {
for (Reassignment reassignment : ressignments) {
List<? extends OrganizationalEntity> potentialOwners = reassignment.getPotentialOwners();
if (potentialOwners != null) {
for (OrganizationalEntity potentialOwner : potentialOwners) {
if (potentialOwner instanceof User) {
doCallbackUserOperation(potentialOwner.getId(), context);
}
if (potentialOwner instanceof Group) {
doCallbackGroupOperation(potentialOwner.getId(), context);
}
}
}
}
}
}
}
}
}
if (deadlines.getEndDeadlines() != null) {
List<? extends Deadline> endDeadlines = deadlines.getEndDeadlines();
for (Deadline endDeadline : endDeadlines) {
List<? extends Escalation> escalations = endDeadline.getEscalations();
if (escalations != null) {
for (Escalation escalation : escalations) {
List<? extends Notification> notifications = escalation.getNotifications();
List<? extends Reassignment> ressignments = escalation.getReassignments();
if (notifications != null) {
for (Notification notification : notifications) {
List<? extends OrganizationalEntity> recipients = notification.getRecipients();
if (recipients != null) {
for (OrganizationalEntity recipient : recipients) {
if (recipient instanceof User) {
doCallbackUserOperation(recipient.getId(), context);
}
if (recipient instanceof Group) {
doCallbackGroupOperation(recipient.getId(), context);
}
}
}
List<? extends OrganizationalEntity> administrators = notification.getBusinessAdministrators();
if (administrators != null) {
for (OrganizationalEntity administrator : administrators) {
if (administrator instanceof User) {
doCallbackUserOperation(administrator.getId(), context);
}
if (administrator instanceof Group) {
doCallbackGroupOperation(administrator.getId(), context);
}
}
}
}
}
if (ressignments != null) {
for (Reassignment reassignment : ressignments) {
List<? extends OrganizationalEntity> potentialOwners = reassignment.getPotentialOwners();
if (potentialOwners != null) {
for (OrganizationalEntity potentialOwner : potentialOwners) {
if (potentialOwner instanceof User) {
doCallbackUserOperation(potentialOwner.getId(), context);
}
if (potentialOwner instanceof Group) {
doCallbackGroupOperation(potentialOwner.getId(), context);
}
}
}
}
}
}
}
}
}
}
}
use of org.kie.api.task.model.Group in project jbpm by kiegroup.
the class UserGroupCallbackTaskCommand method addGroupFromCallbackOperation.
protected void addGroupFromCallbackOperation(String groupId, TaskContext context) {
Group group = context.getPersistenceContext().findGroup(groupId);
boolean groupExists = group != null;
if (!StringUtils.isEmpty(groupId) && !groupExists) {
group = TaskModelProvider.getFactory().newGroup();
((InternalOrganizationalEntity) group).setId(groupId);
persistIfNotExists(group, context);
}
}
Aggregations