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