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