Coverage Report - org.kuali.rice.kim.impl.identity.employment.EntityEmploymentBo
 
Classes in this File Line Coverage Branch Coverage Complexity
EntityEmploymentBo
70%
19/27
42%
11/26
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.identity.employment
 17  
 
 18  
 import javax.persistence.Column
 19  
 import javax.persistence.FetchType
 20  
 import javax.persistence.Id
 21  
 import javax.persistence.JoinColumn
 22  
 import javax.persistence.ManyToOne
 23  
 import org.hibernate.annotations.Type
 24  
 import org.kuali.rice.core.api.util.type.KualiDecimal
 25  
 import org.kuali.rice.kim.api.identity.employment.EntityEmployment
 26  
 import org.kuali.rice.kim.api.identity.employment.EntityEmploymentContract
 27  
 import org.kuali.rice.kim.impl.identity.affiliation.EntityAffiliationBo
 28  
 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase
 29  
 
 30  
 class EntityEmploymentBo extends PersistableBusinessObjectBase implements EntityEmploymentContract {
 31  
             private static final long serialVersionUID = 1L;
 32  
 
 33  
         @Id
 34  
         @Column(name = "ENTITY_EMP_ID")
 35  
         String id;
 36  
 
 37  
         @Column(name = "ENTITY_ID")
 38  
         String entityId;
 39  
 
 40  
         @Column(name = "EMP_ID")
 41  
         String employeeId;
 42  
 
 43  
         @Column(name = "EMP_REC_ID")
 44  
         String employmentRecordId;
 45  
 
 46  
         @Column(name = "ENTITY_AFLTN_ID")
 47  
         String entityAffiliationId;
 48  
 
 49  
         @Column(name = "EMP_STAT_CD")
 50  
         String employeeStatusCode;
 51  
 
 52  
         @Column(name = "EMP_TYP_CD")
 53  
         String employeeTypeCode;
 54  
 
 55  
         @Column(name = "PRMRY_DEPT_CD")
 56  
         String primaryDepartmentCode;
 57  
         
 58  
         @Type(type="rice_decimal")
 59  
         @Column(name = "BASE_SLRY_AMT")
 60  
         KualiDecimal baseSalaryAmount;
 61  
 
 62  
         @Type(type="yes_no")
 63  
         @Column(name="PRMRY_IND")
 64  
         boolean primary;
 65  
 
 66  
     @Type(type="yes_no")
 67  
     @Column(name="ACTV_IND")
 68  
     boolean active;
 69  
 
 70  
         @ManyToOne(targetEntity=EntityEmploymentTypeBo.class, fetch=FetchType.EAGER, cascade = [])
 71  
         @JoinColumn(name="EMP_TYP_CD", insertable = false, updatable = false)
 72  
         EntityEmploymentTypeBo employeeType;
 73  
 
 74  
         @ManyToOne(targetEntity=EntityEmploymentStatusBo.class, fetch = FetchType.EAGER, cascade = [])
 75  
         @JoinColumn(name="EMP_STAT_CD", insertable = false, updatable = false)
 76  
         EntityEmploymentStatusBo employeeStatus;
 77  
         
 78  
         @ManyToOne(targetEntity=EntityAffiliationBo.class, fetch = FetchType.EAGER, cascade = [])
 79  
         @JoinColumn(name="ENTITY_AFLTN_ID", insertable = false, updatable = false)
 80  
         EntityAffiliationBo entityAffiliation;
 81  
 
 82  
     @Override
 83  
     public EntityAffiliationBo getEntityAffiliation() {
 84  1
         return this.entityAffiliation
 85  
     }
 86  
 
 87  
     @Override
 88  
     public EntityEmploymentStatusBo getEmployeeStatus() {
 89  1
         return this.employeeStatus
 90  
     }
 91  
 
 92  
     @Override
 93  
     public EntityEmploymentTypeBo getEmployeeType() {
 94  1
         return this.employeeType
 95  
     }
 96  
 
 97  
       /*
 98  
        * Converts a mutable EntityEmploymentBo to an immutable EntityEmployment representation.
 99  
        * @param bo
 100  
        * @return an immutable EntityEmployment
 101  
        */
 102  
       static EntityEmployment to(EntityEmploymentBo bo) {
 103  0
         if (bo == null) { return null }
 104  1
         return EntityEmployment.Builder.create(bo).build()
 105  
       }
 106  
 
 107  
       /**
 108  
        * Creates a EntityEmploymentBo business object from an immutable representation of a EntityEmployment.
 109  
        * @param an immutable EntityEmployment
 110  
        * @return a EntityEmploymentBo
 111  
        */
 112  
       static EntityEmploymentBo from(EntityEmployment immutable) {
 113  0
         if (immutable == null) {return null}
 114  
 
 115  1
         EntityEmploymentBo bo = new EntityEmploymentBo()
 116  1
         bo.id = immutable.id
 117  1
         bo.active = immutable.active
 118  
 
 119  1
         bo.entityId = immutable.entityId
 120  1
         if (immutable.employeeType != null) {
 121  0
             bo.employeeTypeCode = immutable.employeeType.code
 122  0
             bo.employeeType = EntityEmploymentTypeBo.from(immutable.employeeType)
 123  
         }
 124  1
         if (immutable.employeeStatus != null) {
 125  0
             bo.employeeStatusCode = immutable.employeeStatus.code
 126  0
             bo.employeeStatus = EntityEmploymentStatusBo.from(immutable.employeeStatus)
 127  
         }
 128  1
         if (immutable.getEntityAffiliation() != null) {
 129  0
             bo.entityAffiliationId = immutable.getEntityAffiliation().getId()
 130  0
             bo.entityAffiliation = EntityAffiliationBo.from(immutable.getEntityAffiliation())
 131  
         }
 132  
 
 133  1
         bo.primaryDepartmentCode = immutable.primaryDepartmentCode
 134  1
         bo.employeeId = immutable.employeeId
 135  1
         bo.employmentRecordId = immutable.employmentRecordId
 136  1
         bo.baseSalaryAmount = immutable.getBaseSalaryAmount()
 137  1
         bo.primary = immutable.primary
 138  
 
 139  1
         bo.versionNumber = immutable.versionNumber
 140  1
         bo.objectId = immutable.objectId
 141  
 
 142  1
         return bo;
 143  
       }
 144  
 }