public void setNotificationRecipientEvaluators( Map<String, NotificationRecipientEvaluator> notificationRecipientEvaluators) { for (Map.Entry<String, NotificationRecipientEvaluator> entry : notificationRecipientEvaluators.entrySet()) { ScriptLanguage scriptLanguage = ScriptLanguage.parse(entry.getKey()); _notificationRecipientEvaluators.put(scriptLanguage, entry.getValue()); } }
@Override public Map<String, ?> evaluate( KaleoNotificationRecipient kaleoNotificationRecipient, ExecutionContext executionContext) throws PortalException { ScriptLanguage scriptLanguage = ScriptLanguage.parse(kaleoNotificationRecipient.getRecipientScriptLanguage()); NotificationRecipientEvaluator notificationRecipientEvaluator = _notificationRecipientEvaluators.get(scriptLanguage); if (notificationRecipientEvaluator == null) { throw new IllegalArgumentException( "No notification recipient evaluator for script language " + scriptLanguage); } return notificationRecipientEvaluator.evaluate(kaleoNotificationRecipient, executionContext); }
protected void setAssignee( KaleoTaskAssignment kaleoTaskAssignment, Assignment assignment, ServiceContext serviceContext) throws PortalException, SystemException { AssignmentType assignmentType = assignment.getAssignmentType(); if (assignmentType.equals(AssignmentType.RESOURCE_ACTION)) { kaleoTaskAssignment.setAssigneeClassName(ResourceAction.class.getName()); ResourceActionAssignment resourceActionAssignment = (ResourceActionAssignment) assignment; String actionId = resourceActionAssignment.getActionId(); kaleoTaskAssignment.setAssigneeActionId(actionId); } else if (assignmentType.equals(AssignmentType.ROLE)) { kaleoTaskAssignment.setAssigneeClassName(Role.class.getName()); RoleAssignment roleAssignment = (RoleAssignment) assignment; Role role = null; if (Validator.isNotNull(roleAssignment.getRoleName())) { int roleType = RoleUtil.getRoleType(roleAssignment.getRoleType()); role = RoleUtil.getRole( roleAssignment.getRoleName(), roleType, roleAssignment.isAutoCreate(), serviceContext); } else { role = roleLocalService.getRole(roleAssignment.getRoleId()); } kaleoTaskAssignment.setAssigneeClassPK(role.getRoleId()); } else if (assignmentType.equals(AssignmentType.SCRIPT)) { kaleoTaskAssignment.setAssigneeClassName(AssignmentType.SCRIPT.name()); ScriptAssignment scriptAssignment = (ScriptAssignment) assignment; kaleoTaskAssignment.setAssigneeScript(scriptAssignment.getScript()); ScriptLanguage scriptLanguage = scriptAssignment.getScriptLanguage(); kaleoTaskAssignment.setAssigneeScriptLanguage(scriptLanguage.getValue()); kaleoTaskAssignment.setAssigneeScriptRequiredContexts( scriptAssignment.getScriptRequiredContexts()); } else if (assignmentType.equals(AssignmentType.USER)) { kaleoTaskAssignment.setAssigneeClassName(User.class.getName()); UserAssignment userAssignment = (UserAssignment) assignment; User user = null; if (userAssignment.getUserId() > 0) { user = userLocalService.getUser(userAssignment.getUserId()); } else if (Validator.isNotNull(userAssignment.getEmailAddress())) { user = userLocalService.getUserByEmailAddress( serviceContext.getCompanyId(), userAssignment.getEmailAddress()); } else if (Validator.isNotNull(userAssignment.getScreenName())) { user = userLocalService.getUserByScreenName( serviceContext.getCompanyId(), userAssignment.getScreenName()); } if (user != null) { kaleoTaskAssignment.setAssigneeClassPK(user.getUserId()); } else { kaleoTaskAssignment.setAssigneeClassPK(0); } } }