Coverage Report - org.kuali.rice.kim.bo.ui.RoleDocumentDelegationMember
 
Classes in this File Line Coverage Branch Coverage Complexity
RoleDocumentDelegationMember
0%
0/71
0%
0/26
1.289
 
 1  
 /**
 2  
  * Copyright 2005-2011 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 org.hibernate.annotations.Fetch;
 19  
 import org.hibernate.annotations.FetchMode;
 20  
 import org.hibernate.annotations.GenericGenerator;
 21  
 import org.hibernate.annotations.Parameter;
 22  
 import org.kuali.rice.core.api.delegation.DelegationType;
 23  
 import org.kuali.rice.core.api.membership.MemberType;
 24  
 import org.kuali.rice.kim.api.KimConstants;
 25  
 import org.kuali.rice.kim.api.group.Group;
 26  
 import org.kuali.rice.kim.api.role.Role;
 27  
 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
 28  
 import org.kuali.rice.kim.impl.role.RoleBo;
 29  
 import org.kuali.rice.kim.impl.type.KimTypeAttributesHelper;
 30  
 import org.kuali.rice.kim.impl.type.KimTypeBo;
 31  
 import org.springframework.util.AutoPopulatingList;
 32  
 
 33  
 import javax.persistence.CascadeType;
 34  
 import javax.persistence.Column;
 35  
 import javax.persistence.Entity;
 36  
 import javax.persistence.FetchType;
 37  
 import javax.persistence.GeneratedValue;
 38  
 import javax.persistence.Id;
 39  
 import javax.persistence.IdClass;
 40  
 import javax.persistence.JoinColumn;
 41  
 import javax.persistence.JoinColumns;
 42  
 import javax.persistence.OneToMany;
 43  
 import javax.persistence.Table;
 44  
 import javax.persistence.Transient;
 45  
 import java.util.List;
 46  
 
 47  
 /**
 48  
  * This is a description of what this class does - kellerj don't forget to fill this in. 
 49  
  * 
 50  
  * @author Kuali Rice Team (kuali-rice@googleroles.com)
 51  
  *
 52  
  */
 53  
 @IdClass(RoleDocumentDelegationMemberId.class)
 54  
 @Entity
 55  
 @Table(name="KRIM_PND_DLGN_MBR_T")
 56  0
 public class RoleDocumentDelegationMember extends KimDocumentBoActivatableToFromBase {
 57  
 
 58  
         private static final long serialVersionUID = 1L;
 59  
         
 60  
         @Id
 61  
         @GeneratedValue(generator="KRIM_DLGN_MBR_ID_S")
 62  
         @GenericGenerator(name="KRIM_DLGN_MBR_ID_S",strategy="org.kuali.rice.core.jpa.spring.RiceNumericStringSequenceStyleGenerator",parameters={
 63  
                         @Parameter(name="sequence_name",value="KRIM_DLGN_MBR_ID_S"),
 64  
                         @Parameter(name="value_column",value="id")
 65  
                 })
 66  
         @Column(name="DLGN_MBR_ID")
 67  
         protected String delegationMemberId;
 68  
         
 69  
         @Column(name="ROLE_MBR_ID")
 70  
         protected String roleMemberId;
 71  
         @Transient
 72  
         protected String roleMemberMemberId;
 73  
         @Transient
 74  
         protected String roleMemberMemberTypeCode;
 75  
         @Transient
 76  
         protected String roleMemberName;
 77  
         @Transient
 78  
         protected String roleMemberNamespaceCode;
 79  
 
 80  
         @Transient
 81  
         private KimTypeAttributesHelper attributesHelper;
 82  
         //For Person Document UI - flattening the delegation - delegation member hierarchy
 83  0
         @Transient
 84  
         protected RoleBo roleBo = new RoleBo();
 85  
         
 86  
         @Column(name="DLGN_ID")
 87  
         protected String delegationId;
 88  
         
 89  
         @Column(name="MBR_ID")
 90  
         protected String memberId;
 91  
 
 92  0
         @Column(name="MBR_TYP_CD")
 93  
         protected String memberTypeCode = KimConstants.KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE.getCode();
 94  
         
 95  
         @Transient
 96  
         protected String memberNamespaceCode;
 97  
         
 98  
         @Column(name="MBR_NM")
 99  
         protected String memberName;
 100  0
         @OneToMany(targetEntity=RoleDocumentDelegationMemberQualifier.class, fetch=FetchType.EAGER, cascade={CascadeType.ALL})
 101  
     @Fetch(value = FetchMode.SELECT)
 102  
         @JoinColumns({
 103  
                 @JoinColumn(name="dlgn_id",insertable=false,updatable=false),
 104  
                 @JoinColumn(name="fdoc_nbr", insertable=false, updatable=false)
 105  
         })
 106  
         protected List <RoleDocumentDelegationMemberQualifier> qualifiers = new AutoPopulatingList(RoleDocumentDelegationMemberQualifier.class);
 107  
         
 108  
         @Transient
 109  
         protected String delegationTypeCode;
 110  
         
 111  
         /**
 112  
          * @return the delegationTypeCode
 113  
          */
 114  
         public String getDelegationTypeCode() {
 115  0
                 return this.delegationTypeCode;
 116  
         }
 117  
 
 118  
         /**
 119  
          * @param delegationTypeCode the delegationTypeCode to set
 120  
          */
 121  
         public void setDelegationTypeCode(String delegationTypeCode) {
 122  0
                 this.delegationTypeCode = delegationTypeCode;
 123  0
         }
 124  
 
 125  
         public String getDelegationId() {
 126  0
                 return this.delegationId;
 127  
         }
 128  
 
 129  
         public void setDelegationId(String delegationId) {
 130  0
                 this.delegationId = delegationId;
 131  0
         }
 132  
 
 133  
         /**
 134  
          * @return the qualifiers
 135  
          */
 136  
         public List<RoleDocumentDelegationMemberQualifier> getQualifiers() {
 137  0
                 return this.qualifiers;
 138  
         }
 139  
 
 140  
         public RoleDocumentDelegationMemberQualifier getQualifier(String kimAttributeDefnId) {
 141  0
                 for(RoleDocumentDelegationMemberQualifier qualifier:qualifiers){
 142  0
                         if(qualifier.getKimAttrDefnId().equals(kimAttributeDefnId)) {
 143  0
                                 return qualifier;
 144  
             }
 145  
                 }
 146  0
                 return null;
 147  
         }
 148  
 
 149  
         /**
 150  
          * @param qualifiers the qualifiers to set
 151  
          */
 152  
         public void setQualifiers(List<RoleDocumentDelegationMemberQualifier> qualifiers) {
 153  0
                 this.qualifiers = qualifiers;
 154  0
         }
 155  
 
 156  
         public int getNumberOfQualifiers(){
 157  0
                 return qualifiers==null?0:qualifiers.size();
 158  
         }
 159  
 
 160  
         /**
 161  
          * @return the memberId
 162  
          */
 163  
         public String getMemberId() {
 164  0
                 return this.memberId;
 165  
         }
 166  
 
 167  
         /**
 168  
          * @param memberId the memberId to set
 169  
          */
 170  
         public void setMemberId(String memberId) {
 171  0
                 this.memberId = memberId;
 172  0
         }
 173  
 
 174  
         /**
 175  
          * @return the memberName
 176  
          */
 177  
         public String getMemberName() {
 178  0
                 return this.memberName;
 179  
         }
 180  
 
 181  
         /**
 182  
          * @param memberName the memberName to set
 183  
          */
 184  
         public void setMemberName(String memberName) {
 185  0
                 this.memberName = memberName;
 186  0
         }
 187  
 
 188  
         /**
 189  
          * @return the assignedToId
 190  
          */
 191  
         public String getDelegationMemberId() {
 192  0
                 return this.delegationMemberId;
 193  
         }
 194  
 
 195  
         /**
 196  
          * @param delegationMemberId the assignedToId to set
 197  
          */
 198  
         public void setDelegationMemberId(String delegationMemberId) {
 199  0
                 this.delegationMemberId = delegationMemberId;
 200  0
         }
 201  
 
 202  
         /**
 203  
          * @return the memberTypeCode
 204  
          */
 205  
         public String getMemberTypeCode() {
 206  0
                 return this.memberTypeCode;
 207  
         }
 208  
 
 209  
         /**
 210  
          * @param memberTypeCode the memberTypeCode to set
 211  
          */
 212  
         public void setMemberTypeCode(String memberTypeCode) {
 213  0
                 this.memberTypeCode = memberTypeCode;
 214  0
         }
 215  
 
 216  
 
 217  
         public boolean isDelegationPrimary(){
 218  0
                 return DelegationType.PRIMARY.getCode().equals(getDelegationTypeCode());
 219  
         }
 220  
 
 221  
         public boolean isDelegationSecondary(){
 222  0
                 return DelegationType.SECONDARY.getCode().equals(getDelegationTypeCode());
 223  
         }
 224  
 
 225  
         /**
 226  
          * @return the memberNamespaceCode
 227  
          */
 228  
         public String getMemberNamespaceCode() {
 229  0
                 if ( memberNamespaceCode == null ) {
 230  0
                         populateDerivedValues();
 231  
                 }
 232  0
                 return this.memberNamespaceCode;
 233  
         }
 234  
 
 235  
         /**
 236  
          * @param memberNamespaceCode the memberNamespaceCode to set
 237  
          */
 238  
         public void setMemberNamespaceCode(String memberNamespaceCode) {
 239  0
                 this.memberNamespaceCode = memberNamespaceCode;
 240  0
         }
 241  
 
 242  
         protected void populateDerivedValues() {
 243  0
                 if(MemberType.GROUP.getCode().equals(getMemberTypeCode())){
 244  0
                 Group groupInfo = null;
 245  0
                 groupInfo = KimApiServiceLocator.getGroupService().getGroup(getMemberId());
 246  0
                 if (groupInfo != null) {
 247  0
                         setMemberNamespaceCode(groupInfo.getNamespaceCode());
 248  
                 }                
 249  0
         } else if(MemberType.ROLE.getCode().equals(getMemberTypeCode())){
 250  
                 Role role;
 251  0
                 role = KimApiServiceLocator.getRoleService().getRole(getMemberId());
 252  0
                 setMemberNamespaceCode(role.getNamespaceCode());
 253  
         }
 254  0
         }
 255  
         
 256  
         /**
 257  
          * @return the roleMemberId
 258  
          */
 259  
         public String getRoleMemberId() {
 260  0
                 return this.roleMemberId;
 261  
         }
 262  
 
 263  
         /**
 264  
          * @param roleMemberId the roleMemberId to set
 265  
          */
 266  
         public void setRoleMemberId(String roleMemberId) {
 267  0
                 this.roleMemberId = roleMemberId;
 268  0
         }
 269  
 
 270  
         public boolean isRole(){
 271  0
                 return getMemberTypeCode()!=null && getMemberTypeCode().equals(MemberType.ROLE.getCode());
 272  
         }
 273  
         
 274  
         public boolean isGroup(){
 275  0
                 return getMemberTypeCode()!=null && getMemberTypeCode().equals(MemberType.GROUP.getCode());
 276  
         }
 277  
 
 278  
         public boolean isPrincipal(){
 279  0
                 return getMemberTypeCode()!=null && getMemberTypeCode().equals(MemberType.PRINCIPAL.getCode());
 280  
         }
 281  
 
 282  
         /**
 283  
          * @return the roleMemberName
 284  
          */
 285  
         public String getRoleMemberName() {
 286  0
                 return this.roleMemberName;
 287  
         }
 288  
 
 289  
         /**
 290  
          * @param roleMemberName the roleMemberName to set
 291  
          */
 292  
         public void setRoleMemberName(String roleMemberName) {
 293  0
                 this.roleMemberName = roleMemberName;
 294  0
         }
 295  
 
 296  
         /**
 297  
          * @return the roleMemberNamespaceCode
 298  
          */
 299  
         public String getRoleMemberNamespaceCode() {
 300  0
                 return this.roleMemberNamespaceCode;
 301  
         }
 302  
 
 303  
         /**
 304  
          * @param roleMemberNamespaceCode the roleMemberNamespaceCode to set
 305  
          */
 306  
         public void setRoleMemberNamespaceCode(String roleMemberNamespaceCode) {
 307  0
                 this.roleMemberNamespaceCode = roleMemberNamespaceCode;
 308  0
         }
 309  
 
 310  
         /**
 311  
          * @return the roleBo
 312  
          */
 313  
         public RoleBo getRoleBo() {
 314  0
                 return this.roleBo;
 315  
         }
 316  
 
 317  
         /**
 318  
          * @param roleBo the roleBo to set
 319  
          */
 320  
         public void setRoleBo(RoleBo roleBo) {
 321  0
                 this.roleBo = roleBo;
 322  0
                 setAttributesHelper(new KimTypeAttributesHelper(KimTypeBo.to(roleBo.getKimRoleType())));
 323  0
         }
 324  
 
 325  
         /**
 326  
          * @return the attributesHelper
 327  
          */
 328  
         public KimTypeAttributesHelper getAttributesHelper() {
 329  0
                 return this.attributesHelper;
 330  
         }
 331  
 
 332  
         /**
 333  
          * @param attributesHelper the attributesHelper to set
 334  
          */
 335  
         public void setAttributesHelper(KimTypeAttributesHelper attributesHelper) {
 336  0
                 this.attributesHelper = attributesHelper;
 337  0
         }
 338  
 
 339  
         /**
 340  
          * @return the roleMemberMemberId
 341  
          */
 342  
         public String getRoleMemberMemberId() {
 343  0
                 return this.roleMemberMemberId;
 344  
         }
 345  
 
 346  
         /**
 347  
          * @param roleMemberMemberId the roleMemberMemberId to set
 348  
          */
 349  
         public void setRoleMemberMemberId(String roleMemberMemberId) {
 350  0
                 this.roleMemberMemberId = roleMemberMemberId;
 351  0
         }
 352  
 
 353  
         /**
 354  
          * @return the roleMemberMemberTypeCode
 355  
          */
 356  
         public String getRoleMemberMemberTypeCode() {
 357  0
                 return this.roleMemberMemberTypeCode;
 358  
         }
 359  
 
 360  
         /**
 361  
          * @param roleMemberMemberTypeCode the roleMemberMemberTypeCode to set
 362  
          */
 363  
         public void setRoleMemberMemberTypeCode(String roleMemberMemberTypeCode) {
 364  0
                 this.roleMemberMemberTypeCode = roleMemberMemberTypeCode;
 365  0
         }
 366  
 }