Coverage Report - org.kuali.rice.shareddata.impl.postalcode.PostalCodeBo
 
Classes in this File Line Coverage Branch Coverage Complexity
PostalCodeBo
92%
13/14
75%
3/4
0
 
 1  
 /*
 2  
  * Copyright 2006-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  
 
 17  
 package org.kuali.rice.shareddata.impl.postalcode
 18  
 
 19  
 import javax.persistence.Column
 20  
 import javax.persistence.Entity
 21  
 import javax.persistence.FetchType
 22  
 import javax.persistence.Id
 23  
 import javax.persistence.IdClass
 24  
 import javax.persistence.JoinColumn
 25  
 import javax.persistence.ManyToOne
 26  
 import javax.persistence.Table
 27  
 import org.hibernate.annotations.Type
 28  
 
 29  
 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase
 30  
 import org.kuali.rice.shareddata.api.postalcode.PostalCode
 31  
 import org.kuali.rice.shareddata.api.postalcode.PostalCodeContract
 32  
 import org.kuali.rice.shareddata.impl.country.CountryBo
 33  
 import org.kuali.rice.shareddata.impl.county.CountyBo
 34  
 import org.kuali.rice.shareddata.impl.state.StateBo
 35  
 import org.kuali.rice.krad.bo.MutableInactivatable
 36  
 
 37  
 @IdClass(PostalCodeId.class)
 38  
 @Entity
 39  
 @Table(name = "KRLC_PSTL_CD_T")
 40  
 class PostalCodeBo extends PersistableBusinessObjectBase implements PostalCodeContract, MutableInactivatable {
 41  
 
 42  
     @Id
 43  
     @Column(name = "POSTAL_CD")
 44  
     def String code;
 45  
 
 46  
     @Id
 47  
     @Column(name = "POSTAL_CNTRY_CD")
 48  
     def String countryCode;
 49  
 
 50  
     @Column(name = "POSTAL_CITY_NM")
 51  
     def String cityName;
 52  
 
 53  
     @Column(name = "POSTAL_STATE_NM")
 54  
     def String stateCode;
 55  
 
 56  
     @Column(name = "COUNTY_NM")
 57  
     def String countyCode;
 58  
 
 59  
     @Type(type = "yes_no")
 60  
     @Column(name = "ACTV_IND")
 61  
     def boolean active;
 62  
 
 63  
     @ManyToOne(targetEntity = CountryBo.class, fetch = FetchType.EAGER)
 64  
     @JoinColumn(name = "POSTAL_CNTRY_CD", insertable = false, updatable = false)
 65  
     def CountryBo country;
 66  
 
 67  
     @ManyToOne(targetEntity = CountryBo.class, fetch = FetchType.EAGER)
 68  
     @JoinColumn(name = "POSTAL_STATE_NM", insertable = false, updatable = false)
 69  
     def StateBo state;
 70  
 
 71  
 
 72  
     @ManyToOne(targetEntity = CountryBo.class, fetch = FetchType.EAGER)
 73  
     @JoinColumn(name = "COUNTY_NM", insertable = false, updatable = false)
 74  
     def CountyBo county;
 75  
 
 76  
     /**
 77  
      * Converts a mutable bo to its immutable counterpart
 78  
      * @param bo the mutable business object
 79  
      * @return An immutable PostalCode if the passed in mutable is not null.  If the mutable reference was null, then
 80  
      * null is returned.
 81  
      */
 82  
     static PostalCode to(PostalCodeBo bo) {
 83  9
         if (bo == null) {
 84  5
             return null
 85  
         }
 86  
 
 87  4
         return PostalCode.Builder.create(bo).build();
 88  
     }
 89  
 
 90  
     /**
 91  
      * Converts a immutable object to its mutable counterpart
 92  
      * @param im immutable object
 93  
      * @return a new mutable PostalCodeBo if the passed in mutable is not null.  If the immutable reference was null,
 94  
      * then null is returned.
 95  
      */
 96  
     static PostalCodeBo from(PostalCode im) {
 97  1
         if (im == null) {
 98  0
             return null
 99  
         }
 100  
 
 101  1
         PostalCodeBo bo = new PostalCodeBo()
 102  1
         bo.code = im.code
 103  1
         bo.countryCode = im.countryCode
 104  1
         bo.cityName = im.cityName
 105  1
         bo.active = im.active
 106  1
         bo.stateCode = im.stateCode
 107  1
         bo.cityName = im.cityName
 108  1
         bo.versionNumber = im.versionNumber
 109  
 
 110  1
         return bo
 111  
     }
 112  
 }