protected Set<Assignment> buildAssigments(String kaleoClassName, long kaleoClassPK) throws PortalException, SystemException { List<KaleoTaskAssignment> kaleoTaskAssignments = kaleoTaskAssignmentLocalService.getKaleoTaskAssignments(kaleoClassName, kaleoClassPK); Set<Assignment> assignments = new HashSet<Assignment>(kaleoTaskAssignments.size()); for (KaleoTaskAssignment kaleoTaskAssignment : kaleoTaskAssignments) { String assigneeClassName = kaleoTaskAssignment.getAssigneeClassName(); long assigneeClassPK = kaleoTaskAssignment.getAssigneeClassPK(); Assignment assignment = null; if (assigneeClassName.equals(AssignmentType.SCRIPT.name())) { assignment = new ScriptAssignment( kaleoTaskAssignment.getAssigneeScript(), kaleoTaskAssignment.getAssigneeScriptLanguage(), kaleoTaskAssignment.getAssigneeScriptRequiredContexts()); } else if (assigneeClassName.equals(ResourceAction.class.getName())) { assignment = new ResourceActionAssignment(kaleoTaskAssignment.getAssigneeActionId()); } else if (assigneeClassName.equals(Role.class.getName())) { Role role = _roleLocalService.fetchRole(assigneeClassPK); assignment = new RoleAssignment(role.getName(), role.getTypeLabel()); } else if (assigneeClassName.equals(User.class.getName())) { if (assigneeClassPK == 0) { assignment = new UserAssignment(); } else { User user = _userLocalService.getUser(assigneeClassPK); assignment = new UserAssignment(user.getUserId(), user.getScreenName(), user.getEmailAddress()); } } assignments.add(assignment); } return assignments; }
protected void addNotificationRecipients( KaleoNotification kaleoNotification, Notification notification) throws PortalException, SystemException { List<KaleoNotificationRecipient> kaleoNotificationRecipients = kaleoNotificationRecipientLocalService.getKaleoNotificationRecipients( kaleoNotification.getKaleoNotificationId()); for (KaleoNotificationRecipient kaleoNotificationRecipient : kaleoNotificationRecipients) { String recipientClassName = kaleoNotificationRecipient.getRecipientClassName(); long recipientClassPK = kaleoNotificationRecipient.getRecipientClassPK(); Recipient recipient = null; if (recipientClassName.equals(RecipientType.ADDRESS.name())) { recipient = new AddressRecipient(kaleoNotificationRecipient.getAddress()); } else if (recipientClassName.equals(RecipientType.ASSIGNEES.name())) { recipient = new AssigneesRecipient(); } else if (recipientClassName.equals(Role.class.getName())) { Role role = _roleLocalService.fetchRole(recipientClassPK); recipient = new RoleRecipient(role.getName(), role.getTypeLabel()); } else if (recipientClassName.equals(User.class.getName())) { if (recipientClassPK > 0) { User user = _userLocalService.getUser(recipientClassPK); recipient = new UserRecipient(user.getUserId(), user.getScreenName(), user.getEmailAddress()); } else { recipient = new UserRecipient(); } } notification.addRecipients(recipient); } }
public RoleResponseElement(Role role) { _name = role.getName(); _description = role.getDescription(); _type = role.getTypeLabel(); }