Coverage Report - org.kuali.rice.kim.bo.role.impl.RoleMemberImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
RoleMemberImpl
0%
0/50
0%
0/20
1.769
 
 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.GenericGenerator;
 19  
 import org.hibernate.annotations.Parameter;
 20  
 import org.kuali.rice.core.util.AttributeSet;
 21  
 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
 22  
 import org.kuali.rice.kim.api.type.KimType;
 23  
 import org.kuali.rice.kim.api.type.KimTypeAttribute;
 24  
 import org.kuali.rice.kim.api.type.KimTypeInfoService;
 25  
 import org.kuali.rice.kim.bo.impl.KimAbstractMemberImpl;
 26  
 import org.kuali.rice.kim.bo.role.dto.KimRoleInfo;
 27  
 import org.kuali.rice.kim.bo.role.dto.RoleMemberCompleteInfo;
 28  
 import org.kuali.rice.kim.bo.role.dto.RoleResponsibilityActionInfo;
 29  
 import org.kuali.rice.kim.service.RoleService;
 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.JoinColumn;
 39  
 import javax.persistence.OneToMany;
 40  
 import javax.persistence.Table;
 41  
 import javax.persistence.Transient;
 42  
 import java.util.ArrayList;
 43  
 import java.util.List;
 44  
 
 45  
 /**
 46  
  * This is a description of what this class does - kellerj don't forget to fill this in. 
 47  
  * 
 48  
  * @author Kuali Rice Team (kuali-rice@googleroles.com)
 49  
  *
 50  
  */
 51  
 @Entity
 52  
 @Table(name="KRIM_ROLE_MBR_T")
 53  0
 public class RoleMemberImpl extends KimAbstractMemberImpl {
 54  
 
 55  
         private static final long serialVersionUID = 1L;
 56  
 
 57  
         @Id
 58  
         @GeneratedValue(generator="KRIM_ROLE_MBR_ID_S")
 59  
         @GenericGenerator(name="KRIM_ROLE_MBR_ID_S",strategy="org.kuali.rice.core.jpa.spring.RiceNumericStringSequenceStyleGenerator",parameters={
 60  
                         @Parameter(name="sequence_name",value="KRIM_ROLE_MBR_ID_S"),
 61  
                         @Parameter(name="value_column",value="id")
 62  
                 })        
 63  
         @Column(name="ROLE_MBR_ID")
 64  
         protected String roleMemberId;
 65  
         
 66  
         @Column(name="ROLE_ID")
 67  
         protected String roleId;
 68  
         
 69  
         @OneToMany(targetEntity=RoleMemberAttributeDataImpl.class,cascade={CascadeType.ALL},fetch=FetchType.EAGER)
 70  
     @JoinColumn(name="ROLE_MBR_ID", insertable=false, updatable=false)
 71  
     protected List<RoleMemberAttributeDataImpl> attributes; // = new AutoPopulatingList(RoleMemberAttributeDataImpl.class);
 72  
         
 73  
         @Transient
 74  
         protected List <RoleResponsibilityActionImpl> roleRspActions;
 75  
         
 76  
         public String getRoleMemberId() {
 77  0
                 return this.roleMemberId;
 78  
         }
 79  
         public void setRoleMemberId(String roleMemberId) {
 80  0
                 this.roleMemberId = roleMemberId;
 81  0
         }
 82  
         public String getRoleId() {
 83  0
                 return this.roleId;
 84  
         }
 85  
         public void setRoleId(String roleId) {
 86  0
                 this.roleId = roleId;
 87  0
         }
 88  
 
 89  
         public List<RoleMemberAttributeDataImpl> getAttributes() {
 90  0
                 if (this.attributes == null) {
 91  0
                         return new AutoPopulatingList(RoleMemberAttributeDataImpl.class);
 92  
                 }
 93  0
                 return this.attributes;
 94  
         }
 95  
 
 96  
         public void setAttributes(List<RoleMemberAttributeDataImpl> attributes) {
 97  0
                 this.attributes = attributes;
 98  0
         }
 99  
 
 100  0
         protected transient AttributeSet qualifierAsAttributeSet = null;
 101  
 
 102  
         public AttributeSet getQualifier() {
 103  0
                 if ( qualifierAsAttributeSet == null ) {
 104  0
                         KimRoleInfo role = getRoleService().getRole(roleId);
 105  0
                         KimType kimType = getTypeInfoService().getKimType( role.getKimTypeId() );
 106  0
                         AttributeSet m = new AttributeSet();
 107  0
                         for ( RoleMemberAttributeDataImpl data : getAttributes() ) {
 108  0
                                 KimTypeAttribute attribute = null;
 109  0
                                 if ( kimType != null ) {
 110  0
                                         attribute = kimType.getAttributeDefinitionById( data.getKimAttributeId() );
 111  
                                 }
 112  0
                                 if ( attribute != null ) {
 113  0
                                         m.put( attribute.getKimAttribute().getAttributeName(), data.getAttributeValue() );
 114  
                                 } else {
 115  0
                                         m.put( data.getKimAttribute().getAttributeName(), data.getAttributeValue() );
 116  
                                 }
 117  0
                         }
 118  0
                         qualifierAsAttributeSet = m;
 119  
                 }
 120  0
                 return qualifierAsAttributeSet;
 121  
         }
 122  
         
 123  
         public boolean hasQualifier() {
 124  0
                 return !getAttributes().isEmpty();
 125  
         }
 126  
         
 127  
         /**
 128  
          * @return the roleRspActions
 129  
          */
 130  
         public List<RoleResponsibilityActionImpl> getRoleRspActions() {
 131  0
                 return this.roleRspActions;
 132  
         }
 133  
         /**
 134  
          * @param roleRspActions the roleRspActions to set
 135  
          */
 136  
         public void setRoleRspActions(List<RoleResponsibilityActionImpl> roleRspActions) {
 137  0
                 this.roleRspActions = roleRspActions;
 138  0
         }
 139  
 
 140  
         private transient static KimTypeInfoService kimTypeInfoService;
 141  
         protected KimTypeInfoService getTypeInfoService() {
 142  0
                 if(kimTypeInfoService == null){
 143  0
                         kimTypeInfoService = KimApiServiceLocator.getKimTypeInfoService();
 144  
                 }
 145  0
                 return kimTypeInfoService;
 146  
         }
 147  
         private transient static RoleService roleService;
 148  
         protected RoleService getRoleService() {
 149  0
                 if(roleService == null){
 150  0
                         roleService = KimApiServiceLocator.getRoleManagementService();
 151  
                 }
 152  0
                 return roleService;
 153  
         }
 154  
 
 155  
         public RoleMemberCompleteInfo toSimpleInfo(){
 156  0
                 RoleMemberCompleteInfo roleMemberCompleteInfo = new RoleMemberCompleteInfo();
 157  0
                 roleMemberCompleteInfo.setRoleId(roleId);
 158  0
                 roleMemberCompleteInfo.setRoleMemberId(roleMemberId);
 159  0
                 roleMemberCompleteInfo.setActiveFromDate(activeFromDate);
 160  0
                 roleMemberCompleteInfo.setActiveToDate(activeToDate);
 161  0
                 roleMemberCompleteInfo.setMemberId(memberId);
 162  0
                 roleMemberCompleteInfo.setMemberTypeCode(memberTypeCode);
 163  0
                 roleMemberCompleteInfo.setQualifier(getQualifier());
 164  0
                 roleMemberCompleteInfo.setRoleRspActions(new ArrayList<RoleResponsibilityActionInfo>());
 165  0
                 if(roleRspActions!=null){
 166  0
                         for(RoleResponsibilityActionImpl roleResponsibilityActionImpl: roleRspActions){
 167  0
                                 roleMemberCompleteInfo.getRoleRspActions().add(roleResponsibilityActionImpl.toSimpleInfo());
 168  
                         }
 169  
                 }
 170  0
                 return roleMemberCompleteInfo;
 171  
         }
 172  
 
 173  
 }