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