protected void processPeopleAssignments( String peopleAssignmentIds, List<OrganizationalEntity> organizationalEntities, boolean user) { if (peopleAssignmentIds != null && peopleAssignmentIds.trim().length() > 0) { String[] ids = peopleAssignmentIds.split(","); for (String id : ids) { id = id.trim(); boolean exists = false; for (OrganizationalEntity orgEntity : organizationalEntities) { if (orgEntity.getId().equals(id)) { exists = true; } } if (!exists) { OrganizationalEntity organizationalEntity = null; if (user) { organizationalEntity = new User(id); } else { organizationalEntity = new Group(id); } organizationalEntities.add(organizationalEntity); } } } }
private void doCallbackOperationForPotentialOwners(List<OrganizationalEntity> potentialOwners) { List<OrganizationalEntity> nonExistingEntities = new ArrayList<OrganizationalEntity>(); for (OrganizationalEntity orgEntity : potentialOwners) { if (orgEntity instanceof User) { boolean userExists = doCallbackUserOperation(orgEntity.getId()); if (!userExists) { nonExistingEntities.add(orgEntity); } } if (orgEntity instanceof Group) { boolean groupExists = doCallbackGroupOperation(orgEntity.getId()); if (!groupExists) { nonExistingEntities.add(orgEntity); } } } if (!nonExistingEntities.isEmpty()) { potentialOwners.removeAll(nonExistingEntities); } }
public String getDisplayName(OrganizationalEntity entity) { String displayName = displayNames.get(entity); return (displayName != null) ? displayName : entity.getId(); }
private void doCallbackOperationForTaskDeadlines(Deadlines deadlines) { if (deadlines != null) { if (deadlines.getStartDeadlines() != null) { List<Deadline> startDeadlines = deadlines.getStartDeadlines(); for (Deadline startDeadline : startDeadlines) { List<Escalation> escalations = startDeadline.getEscalations(); if (escalations != null) { for (Escalation escalation : escalations) { List<Notification> notifications = escalation.getNotifications(); List<Reassignment> ressignments = escalation.getReassignments(); if (notifications != null) { for (Notification notification : notifications) { List<OrganizationalEntity> recipients = notification.getRecipients(); if (recipients != null) { for (OrganizationalEntity recipient : recipients) { if (recipient instanceof User) { doCallbackUserOperation(recipient.getId()); } if (recipient instanceof Group) { doCallbackGroupOperation(recipient.getId()); } } } List<OrganizationalEntity> administrators = notification.getBusinessAdministrators(); if (administrators != null) { for (OrganizationalEntity administrator : administrators) { if (administrator instanceof User) { doCallbackUserOperation(administrator.getId()); } if (administrator instanceof Group) { doCallbackGroupOperation(administrator.getId()); } } } } } if (ressignments != null) { for (Reassignment reassignment : ressignments) { List<OrganizationalEntity> potentialOwners = reassignment.getPotentialOwners(); if (potentialOwners != null) { for (OrganizationalEntity potentialOwner : potentialOwners) { if (potentialOwner instanceof User) { doCallbackUserOperation(potentialOwner.getId()); } if (potentialOwner instanceof Group) { doCallbackGroupOperation(potentialOwner.getId()); } } } } } } } } } if (deadlines.getEndDeadlines() != null) { List<Deadline> endDeadlines = deadlines.getEndDeadlines(); for (Deadline endDeadline : endDeadlines) { List<Escalation> escalations = endDeadline.getEscalations(); if (escalations != null) { for (Escalation escalation : escalations) { List<Notification> notifications = escalation.getNotifications(); List<Reassignment> ressignments = escalation.getReassignments(); if (notifications != null) { for (Notification notification : notifications) { List<OrganizationalEntity> recipients = notification.getRecipients(); if (recipients != null) { for (OrganizationalEntity recipient : recipients) { if (recipient instanceof User) { doCallbackUserOperation(recipient.getId()); } if (recipient instanceof Group) { doCallbackGroupOperation(recipient.getId()); } } } List<OrganizationalEntity> administrators = notification.getBusinessAdministrators(); if (administrators != null) { for (OrganizationalEntity administrator : administrators) { if (administrator instanceof User) { doCallbackUserOperation(administrator.getId()); } if (administrator instanceof Group) { doCallbackGroupOperation(administrator.getId()); } } } } } if (ressignments != null) { for (Reassignment reassignment : ressignments) { List<OrganizationalEntity> potentialOwners = reassignment.getPotentialOwners(); if (potentialOwners != null) { for (OrganizationalEntity potentialOwner : potentialOwners) { if (potentialOwner instanceof User) { doCallbackUserOperation(potentialOwner.getId()); } if (potentialOwner instanceof Group) { doCallbackGroupOperation(potentialOwner.getId()); } } } } } } } } } } }
private void doCallbackOperationForPeopleAssignments(PeopleAssignments assignments) { List<OrganizationalEntity> nonExistingEntities = new ArrayList<OrganizationalEntity>(); if (assignments != null) { List<OrganizationalEntity> businessAdmins = assignments.getBusinessAdministrators(); if (businessAdmins != null) { for (OrganizationalEntity admin : businessAdmins) { if (admin instanceof User) { boolean userExists = doCallbackUserOperation(admin.getId()); if (!userExists) { nonExistingEntities.add(admin); } } if (admin instanceof Group) { boolean groupExists = doCallbackGroupOperation(admin.getId()); if (!groupExists) { nonExistingEntities.add(admin); } } } if (!nonExistingEntities.isEmpty()) { businessAdmins.removeAll(nonExistingEntities); nonExistingEntities.clear(); } } if (businessAdmins == null || businessAdmins.isEmpty()) { // throw an exception as it should not be allowed to create task without administrator throw new CannotAddTaskException( "There are no known Business Administrators, task cannot be created according to WS-HT specification"); } List<OrganizationalEntity> potentialOwners = assignments.getPotentialOwners(); if (potentialOwners != null) { for (OrganizationalEntity powner : potentialOwners) { if (powner instanceof User) { boolean userExists = doCallbackUserOperation(powner.getId()); if (!userExists) { nonExistingEntities.add(powner); } } if (powner instanceof Group) { boolean groupExists = doCallbackGroupOperation(powner.getId()); if (!groupExists) { nonExistingEntities.add(powner); } } } if (!nonExistingEntities.isEmpty()) { potentialOwners.removeAll(nonExistingEntities); nonExistingEntities.clear(); } } if (assignments.getTaskInitiator() != null && assignments.getTaskInitiator().getId() != null) { doCallbackUserOperation(assignments.getTaskInitiator().getId()); } List<OrganizationalEntity> excludedOwners = assignments.getExcludedOwners(); if (excludedOwners != null) { for (OrganizationalEntity exowner : excludedOwners) { if (exowner instanceof User) { boolean userExists = doCallbackUserOperation(exowner.getId()); if (!userExists) { nonExistingEntities.add(exowner); } } if (exowner instanceof Group) { boolean groupExists = doCallbackGroupOperation(exowner.getId()); if (!groupExists) { nonExistingEntities.add(exowner); } } } if (!nonExistingEntities.isEmpty()) { excludedOwners.removeAll(nonExistingEntities); nonExistingEntities.clear(); } } List<OrganizationalEntity> recipients = assignments.getRecipients(); if (recipients != null) { for (OrganizationalEntity recipient : recipients) { if (recipient instanceof User) { boolean userExists = doCallbackUserOperation(recipient.getId()); if (!userExists) { nonExistingEntities.add(recipient); } } if (recipient instanceof Group) { boolean groupExists = doCallbackGroupOperation(recipient.getId()); if (!groupExists) { nonExistingEntities.add(recipient); } } } if (!nonExistingEntities.isEmpty()) { recipients.removeAll(nonExistingEntities); nonExistingEntities.clear(); } } List<OrganizationalEntity> stakeholders = assignments.getTaskStakeholders(); if (stakeholders != null) { for (OrganizationalEntity stakeholder : stakeholders) { if (stakeholder instanceof User) { boolean userExists = doCallbackUserOperation(stakeholder.getId()); if (!userExists) { nonExistingEntities.add(stakeholder); } } if (stakeholder instanceof Group) { boolean groupExists = doCallbackGroupOperation(stakeholder.getId()); if (!groupExists) { nonExistingEntities.add(stakeholder); } } } if (!nonExistingEntities.isEmpty()) { stakeholders.removeAll(nonExistingEntities); nonExistingEntities.clear(); } } } }
public void testDelayedReassignmentOnDeadline() throws Exception { Map vars = new HashMap(); vars.put("users", users); vars.put("groups", groups); vars.put("now", new Date()); DefaultEscalatedDeadlineHandler notificationHandler = new DefaultEscalatedDeadlineHandler(getConf()); WorkItemManager manager = new DefaultWorkItemManager(null); notificationHandler.setManager(manager); MockUserInfo userInfo = new MockUserInfo(); userInfo.getEmails().put(users.get("tony"), "*****@*****.**"); userInfo.getEmails().put(users.get("luke"), "*****@*****.**"); userInfo.getEmails().put(users.get("bobba"), "*****@*****.**"); userInfo.getEmails().put(users.get("jabba"), "*****@*****.**"); userInfo.getLanguages().put(users.get("tony"), "en-UK"); userInfo.getLanguages().put(users.get("luke"), "en-UK"); userInfo.getLanguages().put(users.get("bobba"), "en-UK"); userInfo.getLanguages().put(users.get("jabba"), "en-UK"); notificationHandler.setUserInfo(userInfo); taskService.setEscalatedDeadlineHandler(notificationHandler); Reader reader = new InputStreamReader( getClass().getResourceAsStream(MvelFilePath.DeadlineWithReassignment)); BlockingAddTaskResponseHandler addTaskResponseHandler = new BlockingAddTaskResponseHandler(); Task task = (Task) eval(reader, vars); client.addTask(task, null, addTaskResponseHandler); long taskId = addTaskResponseHandler.getTaskId(); // Shouldn't have re-assigned yet Thread.sleep(1000); BlockingGetTaskResponseHandler getTaskHandler = new BlockingGetTaskResponseHandler(); client.getTask(taskId, getTaskHandler); task = getTaskHandler.getTask(); List<OrganizationalEntity> potentialOwners = task.getPeopleAssignments().getPotentialOwners(); List<String> ids = new ArrayList<String>(potentialOwners.size()); for (OrganizationalEntity entity : potentialOwners) { ids.add(entity.getId()); } assertTrue(ids.contains(users.get("tony").getId())); assertTrue(ids.contains(users.get("luke").getId())); // should have re-assigned by now long time = 0; while (getWiser().getMessages().size() != 2 && time < 15000) { Thread.sleep(500); time += 500; } getTaskHandler = new BlockingGetTaskResponseHandler(); client.getTask(taskId, getTaskHandler); task = getTaskHandler.getTask(); assertEquals(Status.Ready, task.getTaskData().getStatus()); potentialOwners = task.getPeopleAssignments().getPotentialOwners(); System.out.println(potentialOwners); ids = new ArrayList<String>(potentialOwners.size()); for (OrganizationalEntity entity : potentialOwners) { ids.add(entity.getId()); } assertTrue(ids.contains(users.get("bobba").getId())); assertTrue(ids.contains(users.get("jabba").getId())); }