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.LinkedHashMap;
19  import java.util.List;
20  
21  import javax.persistence.Column;
22  import javax.persistence.Entity;
23  import javax.persistence.Id;
24  import javax.persistence.Table;
25  
26  import org.kuali.rice.kim.bo.role.impl.KimResponsibilityImpl;
27  import org.kuali.rice.kim.service.KIMServiceLocator;
28  import org.kuali.rice.kim.service.impl.ResponsibilityServiceImpl;
29  import org.kuali.rice.kns.util.TypedArrayList;
30  
31  /**
32   * @author Kuali Rice Team (rice.collab@kuali.org)
33   */
34  @Entity
35  @Table(name="KRIM_PND_ROLE_RSP_T")
36  public class KimDocumentRoleResponsibility extends KimDocumentBoBase {
37  	
38  	private static final long serialVersionUID = -4465768714850961538L;
39  	@Id
40  	@Column(name="ROLE_RSP_ID")
41  	protected String roleResponsibilityId;
42  	@Column(name="ROLE_ID")
43  	protected String roleId;
44  	@Column(name="RSP_ID")
45  	protected String responsibilityId;
46  	
47  	protected KimResponsibilityImpl kimResponsibility;
48  	
49  	protected List<KimDocumentRoleResponsibilityAction> roleRspActions = new TypedArrayList(KimDocumentRoleResponsibilityAction.class);
50  	
51  	public String getRoleId() {
52  		return roleId;
53  	}
54  
55  	public void setRoleId(String roleId) {
56  		this.roleId = roleId;
57  	}
58  
59  	/**
60  	 * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper()
61  	 */
62  	@SuppressWarnings("unchecked")
63  	@Override
64  	protected LinkedHashMap toStringMapper() {
65  		LinkedHashMap m = new LinkedHashMap();
66  		m.put( "roleResponsibilityId", roleResponsibilityId );
67  		m.put( "roleId", roleId );
68  		m.put( "responsibilityId", responsibilityId );
69  		return m;
70  	}
71  
72  	public void setRoleResponsibilityId(String roleResponsibilityId) {
73  		this.roleResponsibilityId = roleResponsibilityId;
74  	}
75  
76  	/**
77  	 * @return the roleResponsibilityId
78  	 */
79  	public String getRoleResponsibilityId() {
80  		return this.roleResponsibilityId;
81  	}
82  
83  	/**
84  	 * @return the kimResponsibility
85  	 */
86  	public KimResponsibilityImpl getKimResponsibility() {
87  		if ( kimResponsibility == null && responsibilityId != null ) {
88  			//TODO: this needs to be changed to use the KimResponsibilityInfo object
89  			// but the changes are involved in the UiDocumentService based on the copyProperties method used
90  			// to move the data to/from the document/real objects
91  			kimResponsibility = ((ResponsibilityServiceImpl)KIMServiceLocator.getResponsibilityService()).getResponsibilityImpl(getResponsibilityId());
92  		}
93  		return this.kimResponsibility;
94  	}
95  
96  	/**
97  	 * @param responsibilityId the responsibilityId to set
98  	 */
99  	public void setResponsibilityId(String responsibilityId) {
100 		this.responsibilityId = responsibilityId;
101 	}
102 
103 	/**
104 	 * @param kimResponsibility the kimResponsibility to set
105 	 */
106 	public void setKimResponsibility(KimResponsibilityImpl kimResponsibility) {
107 		this.kimResponsibility = kimResponsibility;
108 	}
109 
110 	/**
111 	 * @return the responsibilityId
112 	 */
113 	public String getResponsibilityId() {
114 		return this.responsibilityId;
115 	}
116 
117 	/**
118 	 * @return the roleRspActions
119 	 */
120 	public KimDocumentRoleResponsibilityAction getRoleRspAction() {
121 		if(this.roleRspActions!=null && this.roleRspActions.size()>0)
122 			return this.roleRspActions.get(0);
123 		return null;
124 	}
125 
126 	/**
127 	 * @return the roleRspActions
128 	 */
129 	public List<KimDocumentRoleResponsibilityAction> getRoleRspActions() {
130 		return this.roleRspActions;
131 	}
132 
133 	/**
134 	 * @param roleRspActions the roleRspActions to set
135 	 */
136 	public void setRoleRspActions(
137 			List<KimDocumentRoleResponsibilityAction> roleRspActions) {
138 		this.roleRspActions = roleRspActions;
139 	}
140 
141 	@Override
142 	public boolean isActive() {
143 		return this.active;
144 	}
145 
146 }