Coverage Report - org.kuali.rice.kim.impl.role.RoleMemberBo
 
Classes in this File Line Coverage Branch Coverage Complexity
RoleMemberBo
30%
3/10
12%
1/8
0
RoleMemberBo$_from_closure1
0%
0/1
N/A
0
 
 1  
 /*
 2  
  * Copyright 2006-2011 The Kuali Foundation
 3  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 4  
  * you may not use this file except in compliance with the License.
 5  
  * You may obtain a copy of the License at
 6  
  *
 7  
  * http://www.opensource.org/licenses/ecl2.php
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing, software
 10  
  * distributed under the License is distributed on an "AS IS" BASIS,
 11  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12  
  * See the License for the specific language governing permissions and
 13  
  * limitations under the License.
 14  
  */
 15  
 
 16  
 package org.kuali.rice.kim.impl.role;
 17  
 
 18  
 
 19  
 import javax.persistence.CascadeType
 20  
 import javax.persistence.Column
 21  
 import javax.persistence.Entity
 22  
 import javax.persistence.FetchType
 23  
 import javax.persistence.GeneratedValue
 24  
 import javax.persistence.Id
 25  
 import javax.persistence.JoinColumn
 26  
 import javax.persistence.OneToMany
 27  
 import javax.persistence.Table
 28  
 import javax.persistence.Transient
 29  
 import org.hibernate.annotations.GenericGenerator
 30  
 import org.hibernate.annotations.Parameter
 31  
 import org.kuali.rice.kim.api.role.Role
 32  
 import org.kuali.rice.kim.api.role.RoleMember
 33  
 import org.kuali.rice.kim.api.role.RoleMemberContract
 34  
 import org.kuali.rice.kim.api.services.KimApiServiceLocator
 35  
 import org.kuali.rice.kim.api.type.KimTypeInfoService
 36  
 import org.kuali.rice.kim.impl.common.attribute.KimAttributeDataBo
 37  
 import org.kuali.rice.kim.impl.membership.AbstractMemberBo
 38  
 import org.springframework.util.AutoPopulatingList
 39  
 
 40  
 @Entity
 41  
 @Table(name = "KRIM_ROLE_MBR_T")
 42  
 public class RoleMemberBo extends AbstractMemberBo implements RoleMemberContract {
 43  
 
 44  
     private static final long serialVersionUID = 1L;
 45  
 
 46  
     @Id
 47  
     @GeneratedValue(generator = "KRIM_ROLE_MBR_ID_S")
 48  
     @GenericGenerator(name = "KRIM_ROLE_MBR_ID_S", strategy = "org.kuali.rice.core.jpa.spring.RiceNumericStringSequenceStyleGenerator", parameters = [
 49  
     @Parameter(name = "sequence_name", value = "KRIM_ROLE_MBR_ID_S"),
 50  
     @Parameter(name = "value_column", value = "id")
 51  
     ])
 52  
     @Column(name = "ROLE_MBR_ID")
 53  
     String roleMemberId;
 54  
 
 55  
     @Column(name = "ROLE_ID")
 56  
     String roleId;
 57  
 
 58  
     @Column(name = "MBR_TYP_CD")
 59  
     String memberTypeCode
 60  
 
 61  
     @OneToMany(targetEntity = RoleMemberAttributeDataBo.class, cascade = [CascadeType.ALL], fetch = FetchType.EAGER)
 62  
     @JoinColumn(name = "ROLE_MBR_ID", insertable = false, updatable = false)
 63  
     List<RoleMemberAttributeDataBo> attributeDetails; // = new AutoPopulatingList(RoleMemberAttributeDataBo.class);
 64  
 
 65  
     @Transient
 66  
     List<RoleResponsibilityActionBo> roleRspActions;
 67  
 
 68  
     @Transient
 69  
     Map<String,String> attributes
 70  
 
 71  
 
 72  
     List<RoleMemberAttributeDataBo> getAttributeDetails() {
 73  0
         if (this.attributeDetails == null) {
 74  0
             return new AutoPopulatingList(RoleMemberAttributeDataBo.class);
 75  
         }
 76  0
         return this.attributeDetails;
 77  
     }
 78  
 
 79  
     void setAttributeDetails(List<RoleMemberAttributeDataBo> attributeDetails) {
 80  0
         this.attributeDetails = attributeDetails;
 81  
     }
 82  
 
 83  
     Map<String,String> getAttributes() {
 84  0
         return attributeDetails != null ? KimAttributeDataBo.toAttributes(attributeDetails) : attributes
 85  
     }
 86  
 
 87  
     /*Map<String,String> getAttributes() {
 88  
         if (qualifier == null) {
 89  
             Role role = getRoleService().getRole(roleId);
 90  
             KimType kimType = getTypeInfoService().getKimType(role.getKimTypeId());
 91  
             Map<String, String> m = new HashMap<String, String>();
 92  
             for (RoleMemberAttributeDataBo data: getAttributes()) {
 93  
                 KimTypeAttribute attribute = null;
 94  
                 if (kimType != null) {
 95  
                     attribute = kimType.getAttributeDefinitionById(data.getKimAttributeId());
 96  
                 }
 97  
                 if (attribute != null) {
 98  
                     m.put(attribute.getKimAttribute().getAttributeName(), data.getAttributeValue());
 99  
                 } else {
 100  
                     m.put(data.getKimAttribute().getAttributeName(), data.getAttributeValue());
 101  
                 }
 102  
             }
 103  
             qualifier = m;
 104  
         }
 105  
         return qualifier;
 106  
     }*/
 107  
     public static RoleMember to(RoleMemberBo bo) {
 108  0
         if (bo == null) {return null;}
 109  0
         return RoleMember.Builder.create(bo).build();
 110  
     }
 111  
 
 112  
     public static RoleMemberBo from(RoleMember immutable) {
 113  2
         if (immutable == null) { return null; }
 114  
 
 115  2
         return new RoleMemberBo(
 116  
                 roleMemberId: immutable.roleMemberId,
 117  
                 roleId: immutable.roleId,
 118  2
                 roleRspActions: immutable.roleRspActions.collect { RoleResponsibilityActionBo.from(it) },
 119  
                 memberId: immutable.memberId,
 120  
                 memberTypeCode: immutable.memberTypeCode,
 121  
                 activeFromDate: immutable.activeFromDate,
 122  
                 activeToDate: immutable.activeToDate,
 123  
         )
 124  
     }
 125  
 }