View Javadoc
1   /**
2    * Copyright 2005-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kew.actions;
17  
18  import java.util.ArrayList;
19  import java.util.Arrays;
20  import java.util.List;
21  
22  import org.kuali.rice.kew.api.identity.Id;
23  import org.kuali.rice.kew.api.identity.PrincipalName;
24  import org.kuali.rice.kew.api.rule.RoleName;
25  import org.kuali.rice.kew.engine.RouteContext;
26  import org.kuali.rice.kew.routeheader.DocumentContent;
27  import org.kuali.rice.kew.rule.AbstractRoleAttribute;
28  import org.kuali.rice.kew.rule.ResolvedQualifiedRole;
29  
30  /**
31   * Current state of affairs
32   * 
33   * jitrue -> primary recipient
34   * natjohns -> delegate (type dictated by rule setup)
35   * shenl -> delegate (type dictated by rule setup)
36   *
37   */
38  public class BANotificationRoleAttribute extends AbstractRoleAttribute {
39  
40      public List<RoleName> getRoleNames() {
41          return Arrays.asList(new RoleName[] { new RoleName(getClass().getName(), "Notify", "Notify"), new RoleName(getClass().getName(), "Notify2", "Notify2"), new RoleName(getClass().getName(), "NotifyDelegate", "NotifyDelegate") });
42      }
43  
44      public List<String> getQualifiedRoleNames(String roleName, DocumentContent documentContent) {
45          List<String> qualifiedRoleNames = new ArrayList<String>();
46          if (roleName.equals("Notify") || roleName.equals("Notify2")) {
47              qualifiedRoleNames.add("jitrue");    
48          } else throw new RuntimeException("Bad Role " + roleName);        
49          return qualifiedRoleNames;
50      }
51  
52      public ResolvedQualifiedRole resolveQualifiedRole(RouteContext routeContext, String roleName, String qualifiedRole) {
53          if (roleName.equals("Notify") || roleName.equals("Notify2")) {
54              return new ResolvedQualifiedRole(roleName, Arrays.asList(new Id[] { new PrincipalName(qualifiedRole) }));
55          } else if (roleName.equals("NotifyDelegate")) {
56              List<Id> recipients = new ArrayList<Id>();
57              recipients.add(new PrincipalName("natjohns"));
58              recipients.add(new PrincipalName("shenl"));
59              return new ResolvedQualifiedRole(roleName, recipients);
60          }
61          throw new RuntimeException("Bad Role " + roleName);
62      }
63  
64  }