1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kim.bo.impl; |
17 | |
|
18 | |
import org.apache.commons.lang.builder.EqualsBuilder; |
19 | |
import org.apache.commons.lang.builder.HashCodeBuilder; |
20 | |
import org.hibernate.annotations.Fetch; |
21 | |
import org.hibernate.annotations.FetchMode; |
22 | |
import org.hibernate.annotations.Type; |
23 | |
import org.kuali.rice.kim.bo.Role; |
24 | |
import org.kuali.rice.kim.bo.role.dto.KimRoleInfo; |
25 | |
import org.kuali.rice.kim.bo.role.impl.RoleMemberImpl; |
26 | |
import org.kuali.rice.kim.bo.types.dto.KimTypeInfo; |
27 | |
import org.kuali.rice.kim.service.KIMServiceLocatorWeb; |
28 | |
import org.kuali.rice.kim.service.KimTypeInfoService; |
29 | |
import org.kuali.rice.kns.bo.PersistableBusinessObjectBase; |
30 | |
import org.springframework.util.AutoPopulatingList; |
31 | |
|
32 | |
import javax.persistence.*; |
33 | |
import java.util.ArrayList; |
34 | |
import java.util.List; |
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
@Entity |
43 | |
@Table(name="KRIM_ROLE_T") |
44 | 0 | public class RoleImpl extends PersistableBusinessObjectBase implements Role { |
45 | |
|
46 | |
private static final long serialVersionUID = 1L; |
47 | |
|
48 | |
@Id |
49 | |
@Column(name="ROLE_ID") |
50 | |
protected String roleId; |
51 | |
@Column(name="ROLE_NM") |
52 | |
protected String roleName; |
53 | |
@Column(name="DESC_TXT",length=4000) |
54 | |
protected String roleDescription; |
55 | |
@Type(type="yes_no") |
56 | |
@Column(name="ACTV_IND") |
57 | |
protected boolean active; |
58 | |
@Column(name="KIM_TYP_ID") |
59 | |
protected String kimTypeId; |
60 | |
@Column(name="NMSPC_CD") |
61 | |
protected String namespaceCode; |
62 | |
|
63 | 0 | @OneToMany(targetEntity=RoleMemberImpl.class,cascade={CascadeType.MERGE, CascadeType.REFRESH},fetch=FetchType.EAGER) |
64 | |
@Fetch(value = FetchMode.SELECT) |
65 | |
@JoinColumn(name="ROLE_ID", insertable=false, updatable=false) |
66 | |
protected List<RoleMemberImpl> members = new AutoPopulatingList(RoleMemberImpl.class); |
67 | |
|
68 | |
@Transient |
69 | |
protected String principalName; |
70 | |
@Transient |
71 | |
protected String groupNamespaceCode; |
72 | |
@Transient |
73 | |
protected String groupName; |
74 | |
@Transient |
75 | |
protected String permNamespaceCode; |
76 | |
@Transient |
77 | |
protected String permName; |
78 | |
@Transient |
79 | |
protected String permTmplNamespaceCode; |
80 | |
@Transient |
81 | |
protected String permTmplName; |
82 | |
@Transient |
83 | |
protected String respNamespaceCode; |
84 | |
@Transient |
85 | |
protected String respName; |
86 | |
@Transient |
87 | |
protected String respTmplNamespaceCode; |
88 | |
@Transient |
89 | |
protected String respTmplName; |
90 | |
|
91 | |
public String getRoleId() { |
92 | 0 | return this.roleId; |
93 | |
} |
94 | |
|
95 | |
public void setRoleId(String roleId) { |
96 | 0 | this.roleId = roleId; |
97 | 0 | } |
98 | |
|
99 | |
public String getRoleName() { |
100 | 0 | return this.roleName; |
101 | |
} |
102 | |
|
103 | |
public void setRoleName(String roleName) { |
104 | 0 | this.roleName = roleName; |
105 | 0 | } |
106 | |
|
107 | |
public String getKimTypeId() { |
108 | 0 | return this.kimTypeId; |
109 | |
} |
110 | |
|
111 | |
public void setKimTypeId(String kimTypeId) { |
112 | 0 | this.kimTypeId = kimTypeId; |
113 | 0 | } |
114 | |
|
115 | |
public String getNamespaceCode() { |
116 | 0 | return this.namespaceCode; |
117 | |
} |
118 | |
|
119 | |
public void setNamespaceCode(String namespaceCode) { |
120 | 0 | this.namespaceCode = namespaceCode; |
121 | 0 | } |
122 | |
|
123 | |
public String getPrincipalName() { |
124 | 0 | return this.principalName; |
125 | |
} |
126 | |
|
127 | |
public void setPrincipalName(String principalName) { |
128 | 0 | this.principalName = principalName; |
129 | 0 | } |
130 | |
|
131 | |
public String getGroupNamespaceCode() { |
132 | 0 | return this.groupNamespaceCode; |
133 | |
} |
134 | |
|
135 | |
public void setGroupNamespaceCode(String groupNamespaceCode) { |
136 | 0 | this.groupNamespaceCode = groupNamespaceCode; |
137 | 0 | } |
138 | |
|
139 | |
public String getGroupName() { |
140 | 0 | return this.groupName; |
141 | |
} |
142 | |
|
143 | |
public void setGroupName(String groupName) { |
144 | 0 | this.groupName = groupName; |
145 | 0 | } |
146 | |
|
147 | |
public String getPermNamespaceCode() { |
148 | 0 | return this.permNamespaceCode; |
149 | |
} |
150 | |
|
151 | |
public void setPermNamespaceCode(String permNamespaceCode) { |
152 | 0 | this.permNamespaceCode = permNamespaceCode; |
153 | 0 | } |
154 | |
|
155 | |
public String getPermName() { |
156 | 0 | return this.permName; |
157 | |
} |
158 | |
|
159 | |
public void setPermName(String permName) { |
160 | 0 | this.permName = permName; |
161 | 0 | } |
162 | |
|
163 | |
public String getRespNamespaceCode() { |
164 | 0 | return this.respNamespaceCode; |
165 | |
} |
166 | |
|
167 | |
public void setRespNamespaceCode(String respNamespaceCode) { |
168 | 0 | this.respNamespaceCode = respNamespaceCode; |
169 | 0 | } |
170 | |
|
171 | |
public String getRespName() { |
172 | 0 | return this.respName; |
173 | |
} |
174 | |
|
175 | |
public void setRespName(String respName) { |
176 | 0 | this.respName = respName; |
177 | 0 | } |
178 | |
|
179 | |
public String getPermTmplNamespaceCode() { |
180 | 0 | return this.permTmplNamespaceCode; |
181 | |
} |
182 | |
|
183 | |
public void setPermTmplNamespaceCode(String permTmplNamespaceCode) { |
184 | 0 | this.permTmplNamespaceCode = permTmplNamespaceCode; |
185 | 0 | } |
186 | |
|
187 | |
public String getPermTmplName() { |
188 | 0 | return this.permTmplName; |
189 | |
} |
190 | |
|
191 | |
public void setPermTmplName(String permTmplName) { |
192 | 0 | this.permTmplName = permTmplName; |
193 | 0 | } |
194 | |
|
195 | |
public String getRespTmplNamespaceCode() { |
196 | 0 | return this.respTmplNamespaceCode; |
197 | |
} |
198 | |
|
199 | |
public void setRespTmplNamespaceCode(String respTmplNamespaceCode) { |
200 | 0 | this.respTmplNamespaceCode = respTmplNamespaceCode; |
201 | 0 | } |
202 | |
|
203 | |
public String getRespTmplName() { |
204 | 0 | return this.respTmplName; |
205 | |
} |
206 | |
|
207 | |
public void setRespTmplName(String respTmplName) { |
208 | 0 | this.respTmplName = respTmplName; |
209 | 0 | } |
210 | |
|
211 | |
|
212 | |
|
213 | |
|
214 | |
public String getRoleDescription() { |
215 | 0 | return this.roleDescription; |
216 | |
} |
217 | |
|
218 | |
|
219 | |
|
220 | |
|
221 | |
public void setRoleDescription(String roleDescription) { |
222 | 0 | this.roleDescription = roleDescription; |
223 | 0 | } |
224 | |
|
225 | |
protected List<String> getMembersOfType( String memberTypeCode ) { |
226 | 0 | List<String> roleMembers = new ArrayList<String>(); |
227 | 0 | for ( RoleMemberImpl member : getMembers() ) { |
228 | 0 | if ( member.getMemberTypeCode().equals ( memberTypeCode ) |
229 | |
&& member.isActive() ) { |
230 | 0 | roleMembers.add( member.getMemberId() ); |
231 | |
} |
232 | |
} |
233 | 0 | return roleMembers; |
234 | |
} |
235 | |
|
236 | |
|
237 | |
|
238 | |
|
239 | |
|
240 | |
public boolean equals(Object object) { |
241 | 0 | if ( !(object instanceof Role) ) { |
242 | 0 | return false; |
243 | |
} |
244 | 0 | Role rhs = (Role)object; |
245 | 0 | return new EqualsBuilder().append( this.roleId, rhs.getRoleId() ).isEquals(); |
246 | |
} |
247 | |
|
248 | |
|
249 | |
|
250 | |
|
251 | |
|
252 | |
public int hashCode() { |
253 | 0 | return new HashCodeBuilder( -460627871, 746615189 ).append( this.roleId ).toHashCode(); |
254 | |
} |
255 | |
|
256 | |
public KimTypeInfo getKimRoleType() { |
257 | 0 | return getTypeInfoService().getKimType(kimTypeId); |
258 | |
} |
259 | |
private transient static KimTypeInfoService kimTypeInfoService; |
260 | |
protected KimTypeInfoService getTypeInfoService() { |
261 | 0 | if(kimTypeInfoService == null){ |
262 | 0 | kimTypeInfoService = KIMServiceLocatorWeb.getTypeInfoService(); |
263 | |
} |
264 | 0 | return kimTypeInfoService; |
265 | |
} |
266 | |
|
267 | |
public KimRoleInfo toSimpleInfo() { |
268 | 0 | KimRoleInfo dto = new KimRoleInfo(); |
269 | |
|
270 | 0 | dto.setRoleId( getRoleId() ); |
271 | 0 | dto.setRoleName( getRoleName() ); |
272 | 0 | dto.setNamespaceCode( getNamespaceCode() ); |
273 | 0 | dto.setRoleDescription( getRoleDescription() ); |
274 | 0 | dto.setKimTypeId( getKimTypeId() ); |
275 | 0 | dto.setActive( isActive() ); |
276 | |
|
277 | 0 | return dto; |
278 | |
} |
279 | |
|
280 | |
public List<RoleMemberImpl> getMembers() { |
281 | 0 | return this.members; |
282 | |
} |
283 | |
|
284 | |
public void setMembers(List<RoleMemberImpl> members) { |
285 | 0 | this.members = members; |
286 | 0 | } |
287 | |
|
288 | |
|
289 | |
|
290 | |
|
291 | |
public boolean isActive() { |
292 | 0 | return this.active; |
293 | |
} |
294 | |
|
295 | |
|
296 | |
|
297 | |
|
298 | |
public void setActive(boolean active) { |
299 | 0 | this.active = active; |
300 | 0 | } |
301 | |
} |