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.util;
18  
19  import java.io.Serializable;
20  
21  import org.kuali.rice.kew.actionrequest.ActionRequestValue;
22  
23  
24  /**
25   * A user, workgroup, or role who is responsible for an Action Request.
26   * 
27   * @see ActionRequestValue
28   *
29   * @author Kuali Rice Team (rice.collab@kuali.org)
30   */
31  public class ResponsibleParty implements Serializable {
32  
33  	private static final long serialVersionUID = 6788236688949489851L;
34  
35  	private String principalId;
36      private String groupId;
37      private String roleName;
38  
39      public ResponsibleParty() {
40      }
41  
42      public static ResponsibleParty fromGroupId(String groupId) {
43  		ResponsibleParty responsibleParty = new ResponsibleParty();
44  		responsibleParty.setGroupId(groupId);
45  		return responsibleParty;
46  	}
47  	
48  	public static ResponsibleParty fromPrincipalId(String principalId) {
49  		ResponsibleParty responsibleParty = new ResponsibleParty();
50  		responsibleParty.setPrincipalId(principalId);
51  		return responsibleParty;
52  	}
53  	
54  	public static ResponsibleParty fromRoleName(String roleName) {
55  		ResponsibleParty responsibleParty = new ResponsibleParty();
56  		responsibleParty.setRoleName(roleName);
57  		return responsibleParty;
58  	}
59  
60      public String toString() {
61          StringBuffer sb = new StringBuffer("[");
62          if (principalId != null) {
63              sb.append("user=");
64              sb.append(principalId.toString());
65          } else if (groupId != null) {
66              sb.append("groupID=");
67              sb.append(groupId.toString());
68          } else if (roleName != null) {
69              sb.append("roleName=");
70              sb.append(roleName);
71          }
72          sb.append("]");
73          return sb.toString();
74      }
75  
76      public String getGroupId() {
77          return groupId;
78      }
79  
80      public String getPrincipalId() {
81          return principalId;
82      }
83      
84      public void setPrincipalId(String principalId) {
85          this.principalId = principalId;
86      }
87  
88      public String getRoleName() {
89          return roleName;
90      }
91  
92      public void setGroupId(String groupId) {
93          this.groupId = groupId;
94      }
95  
96      public void setRoleName(String roleName) {
97          this.roleName = roleName;
98      }
99  
100     public boolean isPrincipal() {
101         return getPrincipalId() != null;
102     }
103 
104     public boolean isGroup() {
105         return getGroupId() != null;
106     }
107 
108     public boolean isRole() {
109         return getRoleName() != null;
110     }
111     
112 }