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