001 /**
002 * Copyright 2005-2011 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.rice.kew.actions;
017
018 import java.util.ArrayList;
019 import java.util.Arrays;
020 import java.util.List;
021
022 import org.kuali.rice.kew.api.identity.Id;
023 import org.kuali.rice.kew.api.identity.PrincipalName;
024 import org.kuali.rice.kew.api.rule.RoleName;
025 import org.kuali.rice.kew.engine.RouteContext;
026 import org.kuali.rice.kew.routeheader.DocumentContent;
027 import org.kuali.rice.kew.rule.AbstractRoleAttribute;
028 import org.kuali.rice.kew.rule.ResolvedQualifiedRole;
029
030 /**
031 * Current state of affairs
032 *
033 * jitrue -> primary recipient
034 * natjohns -> delegate (type dictated by rule setup)
035 * shenl -> delegate (type dictated by rule setup)
036 *
037 */
038 public class BANotificationRoleAttribute extends AbstractRoleAttribute {
039
040 public List<RoleName> getRoleNames() {
041 return Arrays.asList(new RoleName[] { new RoleName(getClass().getName(), "Notify", "Notify"), new RoleName(getClass().getName(), "Notify2", "Notify2"), new RoleName(getClass().getName(), "NotifyDelegate", "NotifyDelegate") });
042 }
043
044 public List<String> getQualifiedRoleNames(String roleName, DocumentContent documentContent) {
045 List<String> qualifiedRoleNames = new ArrayList<String>();
046 if (roleName.equals("Notify") || roleName.equals("Notify2")) {
047 qualifiedRoleNames.add("jitrue");
048 } else throw new RuntimeException("Bad Role " + roleName);
049 return qualifiedRoleNames;
050 }
051
052 public ResolvedQualifiedRole resolveQualifiedRole(RouteContext routeContext, String roleName, String qualifiedRole) {
053 if (roleName.equals("Notify") || roleName.equals("Notify2")) {
054 return new ResolvedQualifiedRole(roleName, Arrays.asList(new Id[] { new PrincipalName(qualifiedRole) }));
055 } else if (roleName.equals("NotifyDelegate")) {
056 List<Id> recipients = new ArrayList<Id>();
057 recipients.add(new PrincipalName("natjohns"));
058 recipients.add(new PrincipalName("shenl"));
059 return new ResolvedQualifiedRole(roleName, recipients);
060 }
061 throw new RuntimeException("Bad Role " + roleName);
062 }
063
064 }