Coverage Report - org.kuali.rice.kim.impl.common.delegate.DelegateTypeBo
 
Classes in this File Line Coverage Branch Coverage Complexity
DelegateTypeBo
0%
0/5
N/A
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.hibernate.annotations.Fetch
 27  
 import org.hibernate.annotations.FetchMode
 28  
 import org.hibernate.annotations.Type
 29  
 import org.kuali.rice.kim.api.common.delegate.DelegateType
 30  
 import org.kuali.rice.kim.api.common.delegate.DelegateTypeContract
 31  
 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase
 32  
 import org.springframework.util.AutoPopulatingList
 33  
 import org.kuali.rice.core.api.delegation.DelegationType
 34  
 
 35  
 @Entity
 36  
 @Table(name = "KRIM_DLGN_T")
 37  
 public class DelegateTypeBo extends PersistableBusinessObjectBase implements DelegateTypeContract {
 38  
     private static final long serialVersionUID = 1L;
 39  
 
 40  
     @Id
 41  
     @Column(name = "DLGN_ID")
 42  
     String delegationId;
 43  
 
 44  
     @Column(name = "ROLE_ID")
 45  
     String roleId;
 46  
 
 47  
     @Type(type = "yes_no")
 48  
     @Column(name = "ACTV_IND")
 49  
     boolean active = true;
 50  
 
 51  
     @Column(name = "KIM_TYP_ID")
 52  
     String kimTypeId;
 53  
 
 54  
     @Column(name = "DLGN_TYP_CD")
 55  
     String delegationTypeCode;
 56  
 
 57  
     @OneToMany(targetEntity = DelegateMemberBo.class, cascade = [CascadeType.ALL], fetch = FetchType.EAGER)
 58  
     @Fetch(value = FetchMode.SELECT)
 59  
     @JoinColumn(name = "DLGN_ID", insertable = false, updatable = false)
 60  0
     List<DelegateMemberBo> members = new AutoPopulatingList(DelegateMemberBo.class);
 61  
 
 62  
     public void setDelegationType(DelegationType type) {
 63  0
         this.delegationTypeCode = type.getCode();
 64  
     }
 65  
 
 66  
     public DelegationType getDelegationType() {
 67  0
         return DelegationType.fromCode(this.delegationTypeCode);
 68  
     }
 69  
 
 70  
     public static DelegateType to(DelegateTypeBo bo) {
 71  0
         return DelegateType.Builder.create(bo).build()
 72  
     }
 73  
 
 74  
     public static DelegateTypeBo from(DelegateType immutable) {
 75  0
         return new DelegateTypeBo(
 76  
                 delegationId: immutable.delegationId,
 77  
                 roleId: immutable.roleId,
 78  
                 active: immutable.active,
 79  
                 kimTypeId: immutable.kimTypeId,
 80  
                 delegationTypeCode: immutable.delegationTypeCode,
 81  
         );
 82  
     }
 83  
 }