001/** 002 * Copyright 2005-2015 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.kew.util; 017 018import java.io.Serializable; 019 020import org.kuali.rice.kew.actionrequest.ActionRequestValue; 021 022 023/** 024 * A user, workgroup, or role who is responsible for an Action Request. 025 * 026 * @see ActionRequestValue 027 * 028 * @author Kuali Rice Team (rice.collab@kuali.org) 029 */ 030public class ResponsibleParty implements Serializable { 031 032 private static final long serialVersionUID = 6788236688949489851L; 033 034 private String principalId; 035 private String groupId; 036 private String roleName; 037 038 public ResponsibleParty() { 039 } 040 041 public static ResponsibleParty fromGroupId(String groupId) { 042 ResponsibleParty responsibleParty = new ResponsibleParty(); 043 responsibleParty.setGroupId(groupId); 044 return responsibleParty; 045 } 046 047 public static ResponsibleParty fromPrincipalId(String principalId) { 048 ResponsibleParty responsibleParty = new ResponsibleParty(); 049 responsibleParty.setPrincipalId(principalId); 050 return responsibleParty; 051 } 052 053 public static ResponsibleParty fromRoleName(String roleName) { 054 ResponsibleParty responsibleParty = new ResponsibleParty(); 055 responsibleParty.setRoleName(roleName); 056 return responsibleParty; 057 } 058 059 public String toString() { 060 StringBuffer sb = new StringBuffer("["); 061 if (principalId != null) { 062 sb.append("user="); 063 sb.append(principalId.toString()); 064 } else if (groupId != null) { 065 sb.append("groupID="); 066 sb.append(groupId.toString()); 067 } else if (roleName != null) { 068 sb.append("roleName="); 069 sb.append(roleName); 070 } 071 sb.append("]"); 072 return sb.toString(); 073 } 074 075 public String getGroupId() { 076 return groupId; 077 } 078 079 public String getPrincipalId() { 080 return principalId; 081 } 082 083 public void setPrincipalId(String principalId) { 084 this.principalId = principalId; 085 } 086 087 public String getRoleName() { 088 return roleName; 089 } 090 091 public void setGroupId(String groupId) { 092 this.groupId = groupId; 093 } 094 095 public void setRoleName(String roleName) { 096 this.roleName = roleName; 097 } 098 099 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}