Coverage Report - org.kuali.rice.kim.impl.identity.citizenship.EntityCitizenshipBo
 
Classes in this File Line Coverage Branch Coverage Complexity
EntityCitizenshipBo
76%
20/26
50%
7/14
0
 
 1  
 package org.kuali.rice.kim.impl.identity.citizenship
 2  
 
 3  
 import javax.persistence.Table
 4  
 import javax.persistence.Entity
 5  
 import javax.persistence.Id
 6  
 import javax.persistence.Column
 7  
 import java.sql.Timestamp
 8  
 import javax.persistence.ManyToOne
 9  
 import javax.persistence.JoinColumn
 10  
 import javax.persistence.FetchType
 11  
 import org.kuali.rice.kim.api.identity.citizenship.EntityCitizenship
 12  
 import org.hibernate.annotations.Type
 13  
 import org.kuali.rice.kim.api.identity.citizenship.EntityCitizenshipContract
 14  
 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase
 15  
 import org.joda.time.DateTime
 16  
 
 17  
 @Entity
 18  
 @Table(name = "KRIM_ENTITY_CTZNSHP_T")
 19  
 class EntityCitizenshipBo extends PersistableBusinessObjectBase implements EntityCitizenshipContract {
 20  
     private static final long serialVersionUID = 1L;
 21  
 
 22  
         @Id
 23  
         @Column(name = "ENTITY_CTZNSHP_ID")
 24  
         String id;
 25  
 
 26  
         @Column(name = "ENTITY_ID")
 27  
         String entityId;
 28  
         
 29  
         @Column(name = "POSTAL_CNTRY_CD")
 30  
         String countryCode;
 31  
 
 32  
         @Column(name = "CTZNSHP_STAT_CD")
 33  
         String statusCode;
 34  
 
 35  
         @Column(name = "strt_dt")
 36  
         Timestamp startDateValue;
 37  
 
 38  
         @Column(name = "end_dt")
 39  
         Timestamp endDateValue;
 40  
 
 41  
         @ManyToOne(targetEntity=EntityCitizenshipStatusBo.class, fetch=FetchType.EAGER, cascade=[])
 42  
         @JoinColumn(name = "CTZNSHP_STAT_CD", insertable = false, updatable = false)
 43  
         EntityCitizenshipStatusBo status;
 44  
 
 45  
     @Type(type="yes_no")
 46  
         @Column(name="ACTV_IND")
 47  
     boolean active;
 48  
     
 49  
   /*
 50  
    * Converts a mutable EntityCitizenshipBo to an immutable EntityCitizenship representation.
 51  
    * @param bo
 52  
    * @return an immutable EntityCitizenship
 53  
    */
 54  
   static EntityCitizenship to(EntityCitizenshipBo bo) {
 55  1
     if (bo == null) { return null }
 56  1
     return EntityCitizenship.Builder.create(bo).build()
 57  
   }
 58  
 
 59  
   /**
 60  
    * Creates a EntityCitizenshipBo business object from an immutable representation of a EntityCitizenship.
 61  
    * @param an immutable EntityCitizenship
 62  
    * @return a EntityCitizenshipBo
 63  
    */
 64  
   static EntityCitizenshipBo from(EntityCitizenship immutable) {
 65  1
     if (immutable == null) {return null}
 66  
 
 67  1
     EntityCitizenshipBo bo = new EntityCitizenshipBo()
 68  1
     bo.active = immutable.active
 69  1
     if (immutable.status != null) {
 70  0
             bo.statusCode = immutable.status.code
 71  0
         bo.status = EntityCitizenshipStatusBo.from(immutable.status)
 72  
           }
 73  1
     bo.id = immutable.id
 74  1
     bo.entityId = immutable.entityId
 75  1
     bo.countryCode = immutable.countryCode
 76  1
     if (immutable.startDate != null) {
 77  0
         bo.startDateValue = immutable.startDate.toDate().toTimestamp()
 78  
     }
 79  1
     if (immutable.endDate != null) {
 80  0
         bo.endDateValue = immutable.endDate.toDate().toTimestamp()
 81  
     }
 82  1
     bo.active = immutable.active
 83  1
     bo.versionNumber = immutable.versionNumber
 84  1
     bo.objectId = immutable.objectId
 85  
 
 86  1
     return bo;
 87  
   }
 88  
 
 89  
     @Override
 90  
     DateTime getStartDate() {
 91  1
         if (this.startDateValue != null) {
 92  0
             return new DateTime(this.startDateValue)
 93  
         }
 94  1
         return null
 95  
     }
 96  
 
 97  
     @Override
 98  
     DateTime getEndDate() {
 99  1
         if (this.endDateValue != null) {
 100  0
             return new DateTime(this.endDateValue)
 101  
         }
 102  1
         return null
 103  
     }
 104  
 
 105  
     @Override
 106  
     EntityCitizenshipStatusBo getStatus() {
 107  1
         return this.status
 108  
     }
 109  
 }