Coverage Report - org.kuali.rice.kim.bo.ui.KimDocumentRoleMember
 
Classes in this File Line Coverage Branch Coverage Complexity
KimDocumentRoleMember
0%
0/72
0%
0/38
1.607
 
 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.GenericGenerator;
 19  
 import org.hibernate.annotations.Parameter;
 20  
 import org.kuali.rice.core.xml.dto.AttributeSet;
 21  
 import org.kuali.rice.kim.bo.entity.dto.KimPrincipalInfo;
 22  
 import org.kuali.rice.kim.bo.group.dto.GroupInfo;
 23  
 import org.kuali.rice.kim.bo.role.dto.KimRoleInfo;
 24  
 import org.kuali.rice.kim.service.KIMServiceLocator;
 25  
 import org.kuali.rice.kim.util.KimConstants;
 26  
 import org.springframework.util.AutoPopulatingList;
 27  
 
 28  
 import javax.persistence.*;
 29  
 import java.util.ArrayList;
 30  
 import java.util.List;
 31  
 
 32  
 /**
 33  
  * This is a description of what this class does - shyu don't forget to fill this in. 
 34  
  * 
 35  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 36  
  *
 37  
  */
 38  
 @IdClass(KimDocumentRoleMemberId.class)
 39  
 @Entity
 40  
 @Table(name="KRIM_PND_ROLE_MBR_MT")
 41  
 public class KimDocumentRoleMember  extends KimDocumentBoActivatableToFromEditableBase {
 42  
         private static final long serialVersionUID = -2463865643038170979L;
 43  
 
 44  
         @Id
 45  
         @GeneratedValue(generator="KRIM_ROLE_MBR_ID_S")
 46  
         @GenericGenerator(name="KRIM_ROLE_MBR_ID_S",strategy="org.kuali.rice.core.jpa.spring.RiceNumericStringSequenceStyleGenerator",parameters={
 47  
                         @Parameter(name="sequence_name",value="KRIM_ROLE_MBR_ID_S"),
 48  
                         @Parameter(name="value_column",value="id")
 49  
                 })
 50  
         @Column(name="ROLE_MBR_ID")
 51  
         protected String roleMemberId;
 52  
         
 53  
         @Column(name="ROLE_ID")
 54  
         protected String roleId;
 55  
         @Column(name="MBR_ID")
 56  
         protected String memberId;
 57  
         
 58  
         //TODO: remove the default
 59  0
         @Column(name="MBR_TYP_CD")
 60  
         protected String memberTypeCode = KimConstants.KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE;
 61  
         @Transient
 62  
         protected String memberName;
 63  
         @Transient
 64  
         protected String memberNamespaceCode;
 65  
         
 66  
         protected String memberFullName;
 67  
 
 68  0
         @OneToMany(fetch=FetchType.LAZY,cascade=CascadeType.ALL)
 69  
         @JoinColumns({
 70  
             @JoinColumn(name="ROLE_MBR_ID", insertable = false, updatable = false), 
 71  
             @JoinColumn(name="FDOC_NBR", insertable = false, updatable = false)
 72  
         })
 73  
         protected List <KimDocumentRoleQualifier> qualifiers = new AutoPopulatingList(KimDocumentRoleQualifier.class);
 74  
         @Transient
 75  
         protected String qualifiersToDisplay;
 76  
         
 77  
         @OneToMany(fetch=FetchType.LAZY,cascade=CascadeType.ALL)
 78  
         @JoinColumns({
 79  
             @JoinColumn(name="ROLE_MBR_ID", insertable = false, updatable = false), 
 80  
             @JoinColumn(name="FDOC_NBR", insertable = false, updatable = false)
 81  
         })
 82  
         private List<KimDocumentRoleResponsibilityAction> roleRspActions;
 83  
 
 84  0
         public KimDocumentRoleMember() {
 85  0
                 qualifiers = new ArrayList <KimDocumentRoleQualifier>();
 86  0
                 roleRspActions = new ArrayList <KimDocumentRoleResponsibilityAction>();
 87  0
         }
 88  
 
 89  
         public int getNumberOfQualifiers(){
 90  0
                 return qualifiers==null?0:qualifiers.size();
 91  
         }
 92  
         
 93  
         /**
 94  
          * @return the memberId
 95  
          */
 96  
         public String getMemberId() {
 97  0
                 return this.memberId;
 98  
         }
 99  
 
 100  
         /**
 101  
          * @param memberId the memberId to set
 102  
          */
 103  
         public void setMemberId(String memberId) {
 104  0
                 this.memberId = memberId;
 105  0
         }
 106  
 
 107  
         public String getRoleMemberId() {
 108  0
                 return this.roleMemberId;
 109  
         }
 110  
 
 111  
         public void setRoleMemberId(String roleMemberId) {
 112  0
                 this.roleMemberId = roleMemberId;
 113  0
         }
 114  
 
 115  
         public String getRoleId() {
 116  0
                 return this.roleId;
 117  
         }
 118  
 
 119  
         public void setRoleId(String roleId) {
 120  0
                 this.roleId = roleId;
 121  0
         }
 122  
 
 123  
         public KimDocumentRoleQualifier getQualifier(String kimAttributeDefnId) {
 124  0
                 for(KimDocumentRoleQualifier qualifier:qualifiers){
 125  0
                         if(qualifier.getKimAttrDefnId().equals(kimAttributeDefnId))
 126  0
                                 return qualifier;
 127  
                 }
 128  0
                 return null;
 129  
         }
 130  
 
 131  
         public List<KimDocumentRoleQualifier> getQualifiers() {
 132  0
                 return this.qualifiers;
 133  
         }
 134  
 
 135  
         public void setQualifiers(List<KimDocumentRoleQualifier> qualifiers) {
 136  0
                 this.qualifiers = qualifiers;
 137  0
         }
 138  
 
 139  
         /**
 140  
          * @return the memberTypeCode
 141  
          */
 142  
         public String getMemberTypeCode() {
 143  0
                 return this.memberTypeCode;
 144  
         }
 145  
 
 146  
         /**
 147  
          * @param memberTypeCode the memberTypeCode to set
 148  
          */
 149  
         public void setMemberTypeCode(String memberTypeCode) {
 150  0
                 this.memberTypeCode = memberTypeCode;
 151  0
         }
 152  
 
 153  
         /**
 154  
          * @return the memberName
 155  
          */
 156  
         public String getMemberName() {
 157  0
                 if ( memberName == null ) {
 158  0
                         populateDerivedValues();
 159  
                 }
 160  0
                 return memberName;
 161  
         }
 162  
 
 163  
         /**
 164  
          * @param memberName the memberName to set
 165  
          */
 166  
         public void setMemberName(String memberName) {
 167  0
                 this.memberName = memberName;
 168  0
         }
 169  
 
 170  
         public List<KimDocumentRoleResponsibilityAction> getRoleRspActions() {
 171  0
                 return this.roleRspActions;
 172  
         }
 173  
 
 174  
         public void setRoleRspActions(
 175  
                         List<KimDocumentRoleResponsibilityAction> roleRspActions) {
 176  0
                 this.roleRspActions = roleRspActions;
 177  0
         }
 178  
 
 179  
         /**
 180  
          * @return the memberNamespaceCode
 181  
          */
 182  
         public String getMemberNamespaceCode() {
 183  0
                 if ( memberNamespaceCode == null ) {
 184  0
                         populateDerivedValues();
 185  
                 }
 186  0
                 return memberNamespaceCode;
 187  
         }
 188  
 
 189  
         /**
 190  
          * @param memberNamespaceCode the memberNamespaceCode to set
 191  
          */
 192  
         public void setMemberNamespaceCode(String memberNamespaceCode) {
 193  0
                 this.memberNamespaceCode = memberNamespaceCode;
 194  0
         }
 195  
 
 196  
         protected void populateDerivedValues() {
 197  0
         if(KimConstants.KimUIConstants.MEMBER_TYPE_PRINCIPAL_CODE.equals(getMemberTypeCode())){
 198  0
                 KimPrincipalInfo principalInfo = null;
 199  0
                 principalInfo = KIMServiceLocator.getIdentityManagementService().getPrincipal(getMemberId());
 200  0
                 if (principalInfo != null) {
 201  0
                         setMemberName(principalInfo.getPrincipalName());
 202  
                 }                                
 203  0
         } else if(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE.equals(getMemberTypeCode())){
 204  0
                 GroupInfo groupInfo = null;
 205  0
                 groupInfo = KIMServiceLocator.getIdentityManagementService().getGroup(getMemberId());
 206  0
                 if (groupInfo != null) {
 207  0
                         setMemberName(groupInfo.getGroupName());
 208  0
                         setMemberNamespaceCode(groupInfo.getNamespaceCode());
 209  
                 }
 210  
                 
 211  0
         } else if(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE.equals(getMemberTypeCode())){
 212  0
                 KimRoleInfo roleInfo = null;
 213  0
                 roleInfo = KIMServiceLocator.getRoleService().getRole(getMemberId());                
 214  0
                 setMemberName(roleInfo.getRoleName());
 215  0
                 setMemberNamespaceCode(roleInfo.getNamespaceCode());
 216  
         }
 217  0
         }
 218  
         
 219  
         public boolean isRole(){
 220  0
                 return getMemberTypeCode()!=null && getMemberTypeCode().equals(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE);
 221  
         }
 222  
         
 223  
         public boolean isGroup(){
 224  0
                 return getMemberTypeCode()!=null && getMemberTypeCode().equals(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE);
 225  
         }
 226  
 
 227  
         public boolean isPrincipal(){
 228  0
                 return getMemberTypeCode()!=null && getMemberTypeCode().equals(KimConstants.KimUIConstants.MEMBER_TYPE_PRINCIPAL_CODE);
 229  
         }
 230  
 
 231  
         public AttributeSet getQualifierAsAttributeSet() {
 232  0
                 AttributeSet m = new AttributeSet();
 233  0
                 for ( KimDocumentRoleQualifier data : getQualifiers() ) {
 234  0
                         if (data.getKimAttribute() == null){
 235  0
                                 data.refreshReferenceObject("kimAttribute");
 236  
                         }
 237  0
                         if (data.getKimAttribute() != null){
 238  0
                                 m.put( data.getKimAttribute().getAttributeName(), data.getAttrVal() );
 239  
                         }
 240  
                 }
 241  0
                 return m;
 242  
         }
 243  
 
 244  
         /**
 245  
          * @return the qualifiersToDisplay
 246  
          */
 247  
         public String getQualifiersToDisplay() {
 248  0
                 return this.qualifiersToDisplay;
 249  
         }
 250  
 
 251  
         /**
 252  
          * @param qualifiersToDisplay the qualifiersToDisplay to set
 253  
          */
 254  
         public void setQualifiersToDisplay(String qualifiersToDisplay) {
 255  0
                 this.qualifiersToDisplay = qualifiersToDisplay;
 256  0
         }
 257  
         
 258  
         /**
 259  
          * @return the memberFullName
 260  
          */
 261  
         public String getMemberFullName() {
 262  0
                 return this.memberFullName;
 263  
         }
 264  
 
 265  
         /**
 266  
          * @param memberFullName the memberFullName to set
 267  
          */
 268  
         public void setMemberFullName(String memberFullName) {
 269  0
                 this.memberFullName = memberFullName;
 270  0
         }
 271  
 
 272  
 }