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