Coverage Report - org.kuali.rice.kim.impl.common.delegate.DelegateMemberBo
 
Classes in this File Line Coverage Branch Coverage Complexity
DelegateMemberBo
0%
0/13
0%
0/18
0
 
 1  
 /**
 2  
  * Copyright 2005-2011 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.impl.common.delegate
 17  
 
 18  
 import javax.persistence.CascadeType
 19  
 import javax.persistence.Column
 20  
 import javax.persistence.Entity
 21  
 import javax.persistence.FetchType
 22  
 import javax.persistence.Id
 23  
 import javax.persistence.JoinColumn
 24  
 import javax.persistence.OneToMany
 25  
 import javax.persistence.Table
 26  
 import org.kuali.rice.kim.api.common.delegate.DelegateMember
 27  
 import org.kuali.rice.kim.api.common.delegate.DelegateMemberContract
 28  
 import org.kuali.rice.kim.impl.membership.AbstractMemberBo
 29  
 import org.springframework.util.AutoPopulatingList
 30  
 import java.sql.Timestamp
 31  
 
 32  
 @Entity
 33  
 @Table(name = "KRIM_DLGN_MBR_T")
 34  
 public class DelegateMemberBo extends AbstractMemberBo implements DelegateMemberContract {
 35  
 
 36  
     @Id
 37  
     @Column(name = "DLGN_MBR_ID")
 38  
     String delegationMemberId;
 39  
     @Column(name = "DLGN_ID")
 40  
     String delegationId;
 41  
     @Column(name = "ROLE_MBR_ID")
 42  
     String roleMemberId;
 43  
 
 44  
     @OneToMany(targetEntity = DelegateMemberAttributeDataBo.class, cascade = [CascadeType.ALL], fetch = FetchType.EAGER)
 45  
     @JoinColumn(name = "DLGN_MBR_ID", referencedColumnName = "DLGN_MBR_ID", insertable = false, updatable = false)
 46  0
     List<DelegateMemberAttributeDataBo> attributes = new AutoPopulatingList(DelegateMemberAttributeDataBo.class);
 47  
 
 48  
     /**
 49  
      * Returns Attributes derived from the internal List of DelegateMemberAttributeDataBos.  This field is
 50  
      * not exposed in the DelegateMemberContract as it is not a required field in the DelegateMember DTO
 51  
      * @return
 52  
      */
 53  
     public Map<String,String> getQualifier() {
 54  0
         Map<String,String> attribs = new HashMap<String,String>();
 55  
 
 56  0
         if (attributes == null) {
 57  0
             return attribs;
 58  
         }
 59  0
         for (DelegateMemberAttributeDataBo attr: attributes) {
 60  0
             attribs.put(attr.getKimAttribute().getAttributeName(), attr.getAttributeValue());
 61  
         }
 62  0
         return attribs
 63  
     }
 64  
 
 65  
 
 66  
     public static DelegateMember to(DelegateMemberBo bo) {
 67  0
         if (bo == null) {return null;}
 68  0
         return DelegateMember.Builder.create(bo).build();
 69  
     }
 70  
 
 71  
     public static DelegateMemberBo from(DelegateMember immutable) {
 72  0
         if (immutable == null) { return null; }
 73  
 
 74  0
         return new DelegateMemberBo(
 75  
                 delegationMemberId: immutable.delegationMemberId,
 76  0
                 activeFromDateValue: immutable.activeFromDate == null ? null : new Timestamp(immutable.activeFromDate.getMillis()),
 77  0
                 activeToDateValue: immutable.activeToDate == null ? null : new Timestamp(immutable.activeToDate.getMillis()),
 78  
                 delegationId: immutable.delegationId,
 79  
                 memberId: immutable.memberId,
 80  
                 roleMemberId: immutable.roleMemberId,
 81  
                 typeCode: immutable.typeCode,
 82  
         )
 83  
     }
 84  
 }