View Javadoc

1   /*
2    * Copyright 2007-2009 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.rule;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import org.kuali.rice.kew.identity.Id;
22  import org.kuali.rice.kew.identity.PrincipalId;
23  
24  /**
25   * A generic Role Attribute that can be used to route to a Principal ID. Can
26   * take as configuration the label to use for the element name in the XML. This
27   * allows for re-use of this component in different contexts.
28   * 
29   * @author Kuali Rice Team (rice.collab@kuali.org)
30   */
31  public class PrincipalIdRoleAttribute extends AbstractIdRoleAttribute {
32  
33  	private static final long serialVersionUID = 8784036641718163820L;
34  
35  	private static final String PRINCIPAL_ID_ROLE_NAME = "principalId";
36  	private static final String ATTRIBUTE_ELEMENT = "PrincipalIdRoleAttribute";
37  	private static final String PRINCIPAL_ID_ELEMENT = "principalId";
38  
39  	public List<Role> getRoleNames() {
40  		List<Role> roleNames = new ArrayList<Role>();
41  		roleNames.add(new Role(getClass(), PRINCIPAL_ID_ROLE_NAME, "Principal ID"));
42  		return roleNames;
43  	}
44  
45  	protected String getAttributeElementName() {
46  		return ATTRIBUTE_ELEMENT;
47  	}
48  
49  	protected Id resolveId(String id) {
50  		return id == null ? null : new PrincipalId(id);
51  	}
52  
53  	protected String getIdName() {
54  		return PRINCIPAL_ID_ELEMENT;
55  	}
56  
57  	public String getPrincipalId() {
58  		return getIdValue();
59  	}
60  
61  	public void setPrincipalId(String principalId) {
62  		setIdValue(principalId);
63  	}
64  
65  }