View Javadoc

1   /**
2    * Copyright 2005-2011 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.engine;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import org.kuali.rice.kew.api.identity.Id;
22  import org.kuali.rice.kew.api.identity.PrincipalName;
23  import org.kuali.rice.kew.engine.node.NodeState;
24  import org.kuali.rice.kew.routeheader.DocumentContent;
25  import org.kuali.rice.kew.rule.AbstractRoleAttribute;
26  import org.kuali.rice.kew.rule.ResolvedQualifiedRole;
27  
28  
29  public class DynamicSubRoleAttribute extends AbstractRoleAttribute {
30  
31      private static final long serialVersionUID = 5147874690575620616L;
32  	private List<String> roleNames = new ArrayList<String>();
33      
34      public DynamicSubRoleAttribute() {
35          roleNames.add("DynamicSub");
36      }
37  
38      public List getRoleNames() {
39          return roleNames;
40      }
41  
42      public List getQualifiedRoleNames(String roleName, DocumentContent documentContent) {
43          List<String> qualifiedRoleNames = new ArrayList<String>();
44          qualifiedRoleNames.add(roleName);
45          return qualifiedRoleNames;
46      }
47  
48      public ResolvedQualifiedRole resolveQualifiedRole(RouteContext routeContext, String roleName, String qualifiedRole) {
49          NodeState nodeState = routeContext.getNodeInstance().getNodeState("role");
50          if (nodeState == null) {
51              return new ResolvedQualifiedRole();
52          }
53          String networkId = nodeState.getValue();
54          String label = "role " + networkId;
55          List<Id> recipients = new ArrayList<Id>();
56          recipients.add(new PrincipalName(networkId));
57          return new ResolvedQualifiedRole(label, recipients);
58      }   
59  }