Coverage Report - org.kuali.rice.kim.bo.role.impl.KimDelegationImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
KimDelegationImpl
0%
0/41
0%
0/10
1.278
 
 1  
 /*
 2  
  * Copyright 2007-2008 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.role.impl;
 17  
 
 18  
 import org.hibernate.annotations.Fetch;
 19  
 import org.hibernate.annotations.FetchMode;
 20  
 import org.hibernate.annotations.Type;
 21  
 import org.kuali.rice.kim.bo.Role;
 22  
 import org.kuali.rice.kim.bo.role.KimDelegation;
 23  
 import org.kuali.rice.kim.bo.role.dto.DelegateMemberCompleteInfo;
 24  
 import org.kuali.rice.kim.bo.role.dto.DelegateTypeInfo;
 25  
 import org.kuali.rice.kim.bo.types.dto.KimTypeInfo;
 26  
 import org.kuali.rice.kns.bo.PersistableBusinessObjectBase;
 27  
 import org.springframework.util.AutoPopulatingList;
 28  
 
 29  
 import javax.persistence.*;
 30  
 import java.util.ArrayList;
 31  
 import java.util.List;
 32  
 
 33  
 /**
 34  
  * This is a description of what this class does - kellerj don't forget to fill this in. 
 35  
  * 
 36  
  * @author Kuali Rice Team (kuali-rice@googleroles.com)
 37  
  *
 38  
  */
 39  
 @Entity
 40  
 @Table(name="KRIM_DLGN_T")
 41  0
 public class KimDelegationImpl extends PersistableBusinessObjectBase implements KimDelegation {
 42  
 
 43  
         private static final long serialVersionUID = 1L;
 44  
         
 45  
         @Id
 46  
         @Column(name="DLGN_ID")
 47  
         protected String delegationId;
 48  
         
 49  
         @Column(name="ROLE_ID")
 50  
         protected String roleId;
 51  
 
 52  0
         @Type(type="yes_no")
 53  
         @Column(name="ACTV_IND")
 54  
         protected boolean active = true;
 55  
 
 56  
         @Column(name="KIM_TYP_ID")
 57  
         protected String kimTypeId;
 58  
 
 59  
         @Column(name="DLGN_TYP_CD")
 60  
         protected String delegationTypeCode;
 61  
         
 62  0
         @OneToMany(targetEntity=KimDelegationMemberImpl.class,cascade={CascadeType.ALL},fetch=FetchType.EAGER)
 63  
         @Fetch(value = FetchMode.SELECT)
 64  
         @JoinColumn(name="DLGN_ID", insertable=false, updatable=false)
 65  
         protected List<KimDelegationMemberImpl> members = new AutoPopulatingList(KimDelegationMemberImpl.class);
 66  
 
 67  
         @Transient
 68  
         protected KimTypeInfo kimType;
 69  
 
 70  
         public String getRoleId() {
 71  0
                 return this.roleId;
 72  
         }
 73  
 
 74  
         public void setRoleId(String roleId) {
 75  0
                 this.roleId = roleId;
 76  0
         }
 77  
 
 78  
         public boolean isActive() {
 79  0
                 return this.active;
 80  
         }
 81  
 
 82  
         public void setActive(boolean active) {
 83  0
                 this.active = active;
 84  0
         }
 85  
 
 86  
         public String getKimTypeId() {
 87  0
                 return this.kimTypeId;
 88  
         }
 89  
 
 90  
         public void setKimTypeId(String typeId) {
 91  0
                 this.kimTypeId = typeId;
 92  0
         }
 93  
 
 94  
         public KimTypeInfo getKimType() {
 95  0
                 return this.kimType;
 96  
         }
 97  
 
 98  
         public String getDelegationTypeCode() {
 99  0
                 return this.delegationTypeCode;
 100  
         }
 101  
 
 102  
         public void setDelegationTypeCode(String delegationTypeCode) {
 103  0
                 this.delegationTypeCode = delegationTypeCode;
 104  0
         }
 105  
 
 106  
         public String getDelegationId() {
 107  0
                 return this.delegationId;
 108  
         }
 109  
 
 110  
         public void setDelegationId(String delegationId) {
 111  0
                 this.delegationId = delegationId;
 112  0
         }
 113  
 
 114  
         public List<String> getMemberGroupIds() {
 115  0
                 return getMembersOfType( Role.GROUP_MEMBER_TYPE );
 116  
         }
 117  
 
 118  
         public List<String> getMemberPrincipalIds() {
 119  0
                 return getMembersOfType( Role.PRINCIPAL_MEMBER_TYPE );
 120  
         }
 121  
 
 122  
         public List<String> getMemberRoleIds() {
 123  0
                 return getMembersOfType( Role.ROLE_MEMBER_TYPE );
 124  
         }
 125  
 
 126  
         protected List<String> getMembersOfType( String memberTypeCode ) {
 127  0
                 List<String> roleMembers = new ArrayList<String>();
 128  0
                 for ( KimDelegationMemberImpl member : getMembers() ) {
 129  0
                         if ( member.getMemberTypeCode().equals ( memberTypeCode )
 130  
                                         && member.isActive() ) {
 131  0
                                 roleMembers.add( member.getMemberId() );
 132  
                         }
 133  
                 }
 134  0
                 return roleMembers;
 135  
         }
 136  
 
 137  
         public List<KimDelegationMemberImpl> getMembers() {
 138  0
                 return this.members;
 139  
         }
 140  
 
 141  
         public void setMembers(List<KimDelegationMemberImpl> members) {
 142  0
                 this.members = members;
 143  0
         }
 144  
         
 145  
         public DelegateTypeInfo toSimpleInfo(){
 146  0
                 DelegateTypeInfo delegateTypeInfo = new DelegateTypeInfo();
 147  0
                 delegateTypeInfo.setActive(active);
 148  0
                 delegateTypeInfo.setDelegationId(delegationId);
 149  0
                 delegateTypeInfo.setDelegationTypeCode(delegationTypeCode);
 150  
                 //delegateTypeInfo.setKimType(kimType);
 151  0
                 delegateTypeInfo.setKimTypeId(kimTypeId);
 152  0
                 delegateTypeInfo.setRoleId(roleId);
 153  0
                 delegateTypeInfo.setMembers(new ArrayList<DelegateMemberCompleteInfo>());
 154  0
                 if(members!=null){
 155  0
                         for(KimDelegationMemberImpl member: members)
 156  0
                                 delegateTypeInfo.getMembers().add(member.toSimpleInfo());
 157  
                 }
 158  0
                 return delegateTypeInfo;
 159  
         }
 160  
 
 161  
 }