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