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.kim.bo.ui;
17  
18  import java.util.List;
19  
20  import javax.persistence.Column;
21  import javax.persistence.Entity;
22  import javax.persistence.Id;
23  import javax.persistence.Table;
24  
25  import org.kuali.rice.kew.util.KEWConstants;
26  import org.kuali.rice.kim.bo.entity.dto.KimPrincipalInfo;
27  import org.kuali.rice.kim.bo.group.dto.GroupInfo;
28  import org.kuali.rice.kim.bo.impl.RoleImpl;
29  import org.kuali.rice.kim.bo.role.dto.KimRoleInfo;
30  import org.kuali.rice.kim.document.KimTypeAttributesHelper;
31  import org.kuali.rice.kim.service.KIMServiceLocator;
32  import org.kuali.rice.kim.util.KimConstants;
33  import org.kuali.rice.kns.bo.BusinessObject;
34  import org.kuali.rice.kns.util.TypedArrayList;
35  
36  /**
37   * This is a description of what this class does - kellerj don't forget to fill this in. 
38   * 
39   * @author Kuali Rice Team (kuali-rice@googleroles.com)
40   *
41   */
42  @Entity
43  @Table(name="KRIM_PND_DLGN_MBR_T")
44  public class RoleDocumentDelegationMember extends KimDocumentBoBase {
45  
46  	private static final long serialVersionUID = 1L;
47  	
48  	@Id
49  	@Column(name="DLGN_MBR_ID")
50  	protected String delegationMemberId;
51  	
52  	@Id
53  	@Column(name="ROLE_MBR_ID")
54  	protected String roleMemberId;
55  	protected String roleMemberMemberId;
56  	protected String roleMemberMemberTypeCode;
57  	protected String roleMemberName;
58  	protected String roleMemberNamespaceCode;
59  
60  	private KimTypeAttributesHelper attributesHelper;
61  	//For Person Document UI - flattening the delegation - delegation member hierarchy
62  	protected RoleImpl roleImpl = new RoleImpl();
63  	
64  	@Id
65  	@Column(name="DLGN_ID")
66  	protected String delegationId;
67  	
68  	@Column(name="MBR_ID")
69  	protected String memberId;
70  
71  	@Column(name="MBR_TYP_CD")
72  	protected String memberTypeCode = KimConstants.KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE;
73  	
74  	protected String memberNamespaceCode;
75  	
76  	@Column(name="MBR_NM")
77  	protected String memberName;
78  	protected List <RoleDocumentDelegationMemberQualifier> qualifiers = new TypedArrayList(RoleDocumentDelegationMemberQualifier.class);
79  	
80  	protected String delegationTypeCode;
81  	
82  	/**
83  	 * @return the delegationTypeCode
84  	 */
85  	public String getDelegationTypeCode() {
86  		return this.delegationTypeCode;
87  	}
88  
89  	/**
90  	 * @param delegationTypeCode the delegationTypeCode to set
91  	 */
92  	public void setDelegationTypeCode(String delegationTypeCode) {
93  		this.delegationTypeCode = delegationTypeCode;
94  	}
95  
96  	public String getDelegationId() {
97  		return this.delegationId;
98  	}
99  
100 	public void setDelegationId(String delegationId) {
101 		this.delegationId = delegationId;
102 	}
103 
104 	/**
105 	 * @return the qualifiers
106 	 */
107 	public List<RoleDocumentDelegationMemberQualifier> getQualifiers() {
108 		return this.qualifiers;
109 	}
110 
111 	public RoleDocumentDelegationMemberQualifier getQualifier(String kimAttributeDefnId) {
112 		for(RoleDocumentDelegationMemberQualifier qualifier:qualifiers){
113 			if(qualifier.getKimAttrDefnId().equals(kimAttributeDefnId))
114 				return qualifier;
115 		}
116 		return null;
117 	}
118 
119 	/**
120 	 * @param qualifiers the qualifiers to set
121 	 */
122 	public void setQualifiers(List<RoleDocumentDelegationMemberQualifier> qualifiers) {
123 		this.qualifiers = qualifiers;
124 	}
125 
126 	public int getNumberOfQualifiers(){
127 		return qualifiers==null?0:qualifiers.size();
128 	}
129 
130 	/**
131 	 * @return the memberId
132 	 */
133 	public String getMemberId() {
134 		return this.memberId;
135 	}
136 
137 	/**
138 	 * @param memberId the memberId to set
139 	 */
140 	public void setMemberId(String memberId) {
141 		this.memberId = memberId;
142 	}
143 
144 	/**
145 	 * @return the memberName
146 	 */
147 	public String getMemberName() {
148 		return this.memberName;
149 	}
150 
151 	/**
152 	 * @param memberName the memberName to set
153 	 */
154 	public void setMemberName(String memberName) {
155 		this.memberName = memberName;
156 	}
157 
158 	/**
159 	 * @return the delegationMemberId
160 	 */
161 	public String getDelegationMemberId() {
162 		return this.delegationMemberId;
163 	}
164 
165 	/**
166 	 * @param delegationMemberId the delegationMemberId to set
167 	 */
168 	public void setDelegationMemberId(String delegationMemberId) {
169 		this.delegationMemberId = delegationMemberId;
170 	}
171 
172 	/**
173 	 * @return the memberTypeCode
174 	 */
175 	public String getMemberTypeCode() {
176 		return this.memberTypeCode;
177 	}
178 
179 	/**
180 	 * @param memberTypeCode the memberTypeCode to set
181 	 */
182 	public void setMemberTypeCode(String memberTypeCode) {
183 		this.memberTypeCode = memberTypeCode;
184 	}
185 
186 
187 	public boolean isDelegationPrimary(){
188 		return KEWConstants.DELEGATION_PRIMARY.equals(getDelegationTypeCode());
189 	}
190 
191 	public boolean isDelegationSecondary(){
192 		return KEWConstants.DELEGATION_SECONDARY.equals(getDelegationTypeCode());
193 	}
194 
195 	/**
196 	 * @return the memberNamespaceCode
197 	 */
198 	public String getMemberNamespaceCode() {
199 		if ( memberNamespaceCode == null ) {
200 			populateDerivedValues();
201 		}
202 		return this.memberNamespaceCode;
203 	}
204 
205 	/**
206 	 * @param memberNamespaceCode the memberNamespaceCode to set
207 	 */
208 	public void setMemberNamespaceCode(String memberNamespaceCode) {
209 		this.memberNamespaceCode = memberNamespaceCode;
210 	}
211 
212 	protected void populateDerivedValues() {
213 		if(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE.equals(getMemberTypeCode())){
214         	GroupInfo groupInfo = null;
215         	groupInfo = KIMServiceLocator.getIdentityManagementService().getGroup(getMemberId());
216         	if (groupInfo != null) {
217         		setMemberNamespaceCode(groupInfo.getNamespaceCode());
218         	}        	
219         } else if(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE.equals(getMemberTypeCode())){
220         	KimRoleInfo roleInfo = null;
221         	roleInfo = KIMServiceLocator.getRoleService().getRole(getMemberId());
222         	setMemberNamespaceCode(roleInfo.getNamespaceCode());
223         }
224 	}
225 	
226 	/**
227 	 * @return the roleMemberId
228 	 */
229 	public String getRoleMemberId() {
230 		return this.roleMemberId;
231 	}
232 
233 	/**
234 	 * @param roleMemberId the roleMemberId to set
235 	 */
236 	public void setRoleMemberId(String roleMemberId) {
237 		this.roleMemberId = roleMemberId;
238 	}
239 
240 	public boolean isRole(){
241 		return getMemberTypeCode()!=null && getMemberTypeCode().equals(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE);
242 	}
243 	
244 	public boolean isGroup(){
245 		return getMemberTypeCode()!=null && getMemberTypeCode().equals(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE);
246 	}
247 
248 	public boolean isPrincipal(){
249 		return getMemberTypeCode()!=null && getMemberTypeCode().equals(KimConstants.KimUIConstants.MEMBER_TYPE_PRINCIPAL_CODE);
250 	}
251 
252 	/**
253 	 * @return the roleMemberName
254 	 */
255 	public String getRoleMemberName() {
256 		return this.roleMemberName;
257 	}
258 
259 	/**
260 	 * @param roleMemberName the roleMemberName to set
261 	 */
262 	public void setRoleMemberName(String roleMemberName) {
263 		this.roleMemberName = roleMemberName;
264 	}
265 
266 	/**
267 	 * @return the roleMemberNamespaceCode
268 	 */
269 	public String getRoleMemberNamespaceCode() {
270 		return this.roleMemberNamespaceCode;
271 	}
272 
273 	/**
274 	 * @param roleMemberNamespaceCode the roleMemberNamespaceCode to set
275 	 */
276 	public void setRoleMemberNamespaceCode(String roleMemberNamespaceCode) {
277 		this.roleMemberNamespaceCode = roleMemberNamespaceCode;
278 	}
279 
280 	/**
281 	 * @return the roleImpl
282 	 */
283 	public RoleImpl getRoleImpl() {
284 		return this.roleImpl;
285 	}
286 
287 	/**
288 	 * @param roleImpl the roleImpl to set
289 	 */
290 	public void setRoleImpl(RoleImpl roleImpl) {
291 		this.roleImpl = roleImpl;
292 		setAttributesHelper(new KimTypeAttributesHelper(roleImpl.getKimRoleType()));
293 	}
294 
295 	/**
296 	 * @return the attributesHelper
297 	 */
298 	public KimTypeAttributesHelper getAttributesHelper() {
299 		return this.attributesHelper;
300 	}
301 
302 	/**
303 	 * @param attributesHelper the attributesHelper to set
304 	 */
305 	public void setAttributesHelper(KimTypeAttributesHelper attributesHelper) {
306 		this.attributesHelper = attributesHelper;
307 	}
308 
309 	/**
310 	 * @return the roleMemberMemberId
311 	 */
312 	public String getRoleMemberMemberId() {
313 		return this.roleMemberMemberId;
314 	}
315 
316 	/**
317 	 * @param roleMemberMemberId the roleMemberMemberId to set
318 	 */
319 	public void setRoleMemberMemberId(String roleMemberMemberId) {
320 		this.roleMemberMemberId = roleMemberMemberId;
321 	}
322 
323 	/**
324 	 * @return the roleMemberMemberTypeCode
325 	 */
326 	public String getRoleMemberMemberTypeCode() {
327 		return this.roleMemberMemberTypeCode;
328 	}
329 
330 	/**
331 	 * @param roleMemberMemberTypeCode the roleMemberMemberTypeCode to set
332 	 */
333 	public void setRoleMemberMemberTypeCode(String roleMemberMemberTypeCode) {
334 		this.roleMemberMemberTypeCode = roleMemberMemberTypeCode;
335 	}
336 }