View Javadoc

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