| 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.core.xml.dto.AttributeSet; |
| 24 |
|
import org.kuali.rice.kim.bo.Group; |
| 25 |
|
import org.kuali.rice.kim.bo.Person; |
| 26 |
|
import org.kuali.rice.kim.bo.group.dto.GroupInfo; |
| 27 |
|
import org.kuali.rice.kim.bo.group.impl.GroupAttributeDataImpl; |
| 28 |
|
import org.kuali.rice.kim.bo.group.impl.GroupMemberImpl; |
| 29 |
|
import org.kuali.rice.kim.bo.types.dto.KimTypeInfo; |
| 30 |
|
import org.kuali.rice.kim.service.KIMServiceLocator; |
| 31 |
|
import org.kuali.rice.kim.service.KIMServiceLocatorWeb; |
| 32 |
|
import org.kuali.rice.kim.util.KimConstants.KimGroupMemberTypes; |
| 33 |
|
import org.kuali.rice.kns.bo.PersistableBusinessObjectBase; |
| 34 |
|
import org.springframework.util.AutoPopulatingList; |
| 35 |
|
|
| 36 |
|
import javax.persistence.*; |
| 37 |
|
import java.util.ArrayList; |
| 38 |
|
import java.util.List; |
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
@author |
| 44 |
|
|
| 45 |
|
|
| 46 |
|
@Entity |
| 47 |
|
@Table(name="KRIM_GRP_T") |
|
|
|
| 0% |
Uncovered Elements: 115 (115) |
Complexity: 45 |
Complexity Density: 0.71 |
|
| 48 |
|
public class GroupImpl extends PersistableBusinessObjectBase implements Group { |
| 49 |
|
|
| 50 |
|
private static final long serialVersionUID = 1L; |
| 51 |
|
|
| 52 |
|
@Id |
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
| 57 |
|
|
| 58 |
|
@Column(name="GRP_ID") |
| 59 |
|
protected String groupId; |
| 60 |
|
@Column(name="GRP_NM") |
| 61 |
|
protected String groupName; |
| 62 |
|
@Column(name="GRP_DESC",length=4000) |
| 63 |
|
protected String groupDescription; |
| 64 |
|
|
| 65 |
|
@Column(name="ACTV_IND") |
| 66 |
|
@Type(type="yes_no") |
| 67 |
|
protected boolean active; |
| 68 |
|
|
| 69 |
|
@Column(name="KIM_TYP_ID") |
| 70 |
|
protected String kimTypeId; |
| 71 |
|
@Column(name="NMSPC_CD") |
| 72 |
|
protected String namespaceCode; |
| 73 |
|
|
| 74 |
|
@OneToMany(targetEntity=GroupMemberImpl.class,cascade={CascadeType.ALL},fetch=FetchType.EAGER,mappedBy="groupId") |
| 75 |
|
@Fetch(value = FetchMode.SELECT) |
| 76 |
|
|
| 77 |
|
protected List<GroupMemberImpl> members; |
| 78 |
|
|
| 79 |
|
@OneToMany(targetEntity=GroupAttributeDataImpl.class,cascade={CascadeType.ALL},fetch=FetchType.EAGER,mappedBy="groupId") |
| 80 |
|
@Fetch(value = FetchMode.SELECT) |
| 81 |
|
|
| 82 |
|
protected List<GroupAttributeDataImpl> groupAttributes = new AutoPopulatingList(GroupAttributeDataImpl.class); |
| 83 |
|
|
| 84 |
|
@Transient |
| 85 |
|
private List<Person> memberPersons; |
| 86 |
|
@Transient |
| 87 |
|
private List<GroupInfo> memberGroups; |
| 88 |
|
@Transient |
| 89 |
|
protected AttributeSet attributes; |
| 90 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 91 |
0
|
public String getKimTypeId() {... |
| 92 |
0
|
return this.kimTypeId; |
| 93 |
|
} |
| 94 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 95 |
0
|
public void setKimTypeId(String kimTypeId) {... |
| 96 |
0
|
this.kimTypeId = kimTypeId; |
| 97 |
|
} |
| 98 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 99 |
0
|
public String getNamespaceCode() {... |
| 100 |
0
|
return this.namespaceCode; |
| 101 |
|
} |
| 102 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 103 |
0
|
public void setNamespaceCode(String namespaceCode) {... |
| 104 |
0
|
this.namespaceCode = namespaceCode; |
| 105 |
|
} |
| 106 |
|
|
| 107 |
|
|
| 108 |
|
@return |
| 109 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 110 |
0
|
public String getGroupId() {... |
| 111 |
0
|
return this.groupId; |
| 112 |
|
} |
| 113 |
|
|
| 114 |
|
|
| 115 |
|
@param |
| 116 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 117 |
0
|
public void setGroupId(String groupId) {... |
| 118 |
0
|
this.groupId = groupId; |
| 119 |
|
} |
| 120 |
|
|
| 121 |
|
|
| 122 |
|
@return |
| 123 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 124 |
0
|
public String getGroupName() {... |
| 125 |
0
|
return this.groupName; |
| 126 |
|
} |
| 127 |
|
|
| 128 |
|
|
| 129 |
|
@param |
| 130 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 131 |
0
|
public void setGroupName(String groupName) {... |
| 132 |
0
|
this.groupName = groupName; |
| 133 |
|
} |
| 134 |
|
|
| 135 |
|
|
| 136 |
|
@return |
| 137 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 138 |
0
|
public String getGroupDescription() {... |
| 139 |
0
|
return this.groupDescription; |
| 140 |
|
} |
| 141 |
|
|
| 142 |
|
|
| 143 |
|
@param |
| 144 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 145 |
0
|
public void setGroupDescription(String groupDescription) {... |
| 146 |
0
|
this.groupDescription = groupDescription; |
| 147 |
|
} |
| 148 |
|
|
| 149 |
|
|
| 150 |
|
@return |
| 151 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 152 |
0
|
public boolean isActive() {... |
| 153 |
0
|
return this.active; |
| 154 |
|
} |
| 155 |
|
|
| 156 |
|
|
| 157 |
|
@param |
| 158 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 159 |
0
|
public void setActive(boolean active) {... |
| 160 |
0
|
this.active = active; |
| 161 |
|
} |
| 162 |
|
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 163 |
0
|
public AttributeSet getAttributes() {... |
| 164 |
0
|
AttributeSet attributes = new AttributeSet( groupAttributes.size() ); |
| 165 |
0
|
for ( GroupAttributeDataImpl attr : groupAttributes ) { |
| 166 |
0
|
if ( attr.getKimAttribute() != null ) { |
| 167 |
0
|
attributes.put(attr.getKimAttribute().getAttributeName(), attr.getAttributeValue()); |
| 168 |
|
} else { |
| 169 |
0
|
attributes.put("Unknown Attribute ID: " + attr.getKimAttributeId(), attr.getAttributeValue()); |
| 170 |
|
} |
| 171 |
|
} |
| 172 |
|
|
| 173 |
0
|
return attributes; |
| 174 |
|
} |
| 175 |
|
|
| 176 |
|
|
| 177 |
|
@param |
| 178 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 179 |
0
|
public void setAttributes(AttributeSet attributes) {... |
| 180 |
0
|
this.attributes = attributes; |
| 181 |
|
} |
| 182 |
|
|
| 183 |
|
|
| 184 |
|
@return |
| 185 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 186 |
0
|
public List<GroupAttributeDataImpl> getGroupAttributes() {... |
| 187 |
0
|
return this.groupAttributes; |
| 188 |
|
} |
| 189 |
|
|
| 190 |
|
|
| 191 |
|
@param |
| 192 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 193 |
0
|
public void setGroupAttributes(List<GroupAttributeDataImpl> groupAttributes) {... |
| 194 |
0
|
this.groupAttributes = groupAttributes; |
| 195 |
|
} |
| 196 |
|
|
| 197 |
|
|
| 198 |
|
@return |
| 199 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 200 |
0
|
public List<GroupInfo> getMemberGroups() {... |
| 201 |
0
|
return this.memberGroups; |
| 202 |
|
} |
| 203 |
|
|
| 204 |
|
|
| 205 |
|
@param |
| 206 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 207 |
0
|
protected void setMemberGroups(List<GroupInfo> memberGroups) {... |
| 208 |
0
|
this.memberGroups = memberGroups; |
| 209 |
|
} |
| 210 |
|
|
| 211 |
|
|
| 212 |
|
@return |
| 213 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 214 |
0
|
public List<Person> getMemberPersons() {... |
| 215 |
0
|
return this.memberPersons; |
| 216 |
|
} |
| 217 |
|
|
| 218 |
|
|
| 219 |
|
@param |
| 220 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 221 |
0
|
protected void setMemberPersons(List<Person> memberPersons) {... |
| 222 |
0
|
this.memberPersons = memberPersons; |
| 223 |
|
} |
| 224 |
|
|
| 225 |
|
|
| 226 |
|
@return |
| 227 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 228 |
0
|
public List<GroupMemberImpl> getMembers() {... |
| 229 |
0
|
return this.members; |
| 230 |
|
} |
| 231 |
|
|
| 232 |
|
|
| 233 |
|
@param |
| 234 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 235 |
0
|
public void setMembers(List<GroupMemberImpl> members) {... |
| 236 |
0
|
this.members = members; |
| 237 |
|
} |
| 238 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 4 |
Complexity Density: 0.67 |
|
| 239 |
0
|
public List<String> getMemberGroupIds() {... |
| 240 |
0
|
List<String> groupMembers = new ArrayList<String>(); |
| 241 |
0
|
if (getMembers() != null) { |
| 242 |
0
|
for ( GroupMemberImpl groupMemberImpl : getMembers() ) { |
| 243 |
0
|
if ( groupMemberImpl.getMemberTypeCode().equals ( KimGroupMemberTypes.GROUP_MEMBER_TYPE ) |
| 244 |
|
&& groupMemberImpl.isActive() ) { |
| 245 |
0
|
groupMembers.add( groupMemberImpl.getMemberId() ); |
| 246 |
|
} |
| 247 |
|
} |
| 248 |
|
} |
| 249 |
0
|
return groupMembers; |
| 250 |
|
} |
| 251 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 4 |
Complexity Density: 0.67 |
|
| 252 |
0
|
public List<String> getMemberPrincipalIds() {... |
| 253 |
0
|
List<String> groupMembers = new ArrayList<String>(); |
| 254 |
0
|
if (getMembers() != null) { |
| 255 |
0
|
for ( GroupMemberImpl groupMemberImpl : getMembers() ) { |
| 256 |
0
|
if ( groupMemberImpl.getMemberTypeCode().equals ( KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE ) |
| 257 |
|
&& groupMemberImpl.isActive() ) { |
| 258 |
0
|
groupMembers.add( groupMemberImpl.getMemberId() ); |
| 259 |
|
} |
| 260 |
|
} |
| 261 |
|
} |
| 262 |
0
|
return groupMembers; |
| 263 |
|
} |
| 264 |
|
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 6 |
Complexity Density: 0.6 |
|
| 265 |
0
|
public void setMemberPersonsAndGroups() {... |
| 266 |
0
|
List<Person> personMembers = new ArrayList<Person>(); |
| 267 |
0
|
List<GroupInfo> groupMembers = new ArrayList<GroupInfo>(); |
| 268 |
0
|
if (getMembers() != null) { |
| 269 |
0
|
for ( GroupMemberImpl groupMemberImpl : getMembers() ) { |
| 270 |
0
|
if ( groupMemberImpl.getMemberTypeCode().equals ( KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE ) |
| 271 |
|
&& groupMemberImpl.isActive() ) { |
| 272 |
0
|
personMembers.add( KIMServiceLocator.getPersonService().getPerson(groupMemberImpl.getMemberId()) ); |
| 273 |
0
|
} else if (groupMemberImpl.getMemberTypeCode().equals ( KimGroupMemberTypes.GROUP_MEMBER_TYPE ) |
| 274 |
|
&& groupMemberImpl.isActive() ) { |
| 275 |
0
|
groupMembers.add( |
| 276 |
|
KIMServiceLocator.getIdentityManagementService().getGroup(groupMemberImpl.getMemberId()) ); |
| 277 |
|
} |
| 278 |
|
} |
| 279 |
|
} |
| 280 |
0
|
setMemberPersons(personMembers); |
| 281 |
0
|
setMemberGroups(groupMembers); |
| 282 |
|
} |
| 283 |
|
|
| 284 |
|
|
| 285 |
|
@see |
| 286 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 287 |
0
|
public boolean equals(Object object) {... |
| 288 |
0
|
if ( !(object instanceof Group) ) { |
| 289 |
0
|
return false; |
| 290 |
|
} |
| 291 |
0
|
Group rhs = (Group)object; |
| 292 |
0
|
return new EqualsBuilder().append( this.groupId, rhs.getGroupId() ).isEquals(); |
| 293 |
|
} |
| 294 |
|
|
| 295 |
|
|
| 296 |
|
@see |
| 297 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 298 |
0
|
public int hashCode() {... |
| 299 |
0
|
return new HashCodeBuilder( -460627871, 746615189 ).append( this.groupId ).toHashCode(); |
| 300 |
|
} |
| 301 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 302 |
0
|
public GroupAttributeDataImpl getGroupAttributeById(String attributeId) {... |
| 303 |
0
|
for (GroupAttributeDataImpl gad : getGroupAttributes()) { |
| 304 |
0
|
if (gad.getAttributeValue().equals(attributeId.trim())) { |
| 305 |
0
|
return gad; |
| 306 |
|
} |
| 307 |
|
} |
| 308 |
0
|
return null; |
| 309 |
|
} |
| 310 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 311 |
0
|
public String getGroupAttributeValueById(String attributeId) {... |
| 312 |
0
|
for (GroupAttributeDataImpl gad : getGroupAttributes()) { |
| 313 |
0
|
if (gad.getKimAttributeId().equals(attributeId.trim())) { |
| 314 |
0
|
return gad.getAttributeValue(); |
| 315 |
|
} |
| 316 |
|
} |
| 317 |
0
|
return null; |
| 318 |
|
} |
| 319 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 320 |
0
|
public KimTypeInfo getKimTypeInfo() {... |
| 321 |
0
|
return KIMServiceLocatorWeb.getTypeInfoService().getKimType(this.kimTypeId); |
| 322 |
|
} |
| 323 |
|
|
| 324 |
|
} |