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