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  
 import org.kuali.rice.kns.bo.Inactivateable
 29  
 import org.kuali.rice.kns.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  
 
 36  
 @IdClass(PostalCodeId.class)
 37  
 @Entity
 38  
 @Table(name = "KRLC_PSTL_CD_T")
 39  
 class PostalCodeBo extends PersistableBusinessObjectBase implements PostalCodeContract, Inactivateable {
 40  
 
 41  
     @Id
 42  
     @Column(name = "POSTAL_CD")
 43  
     def String code;
 44  
 
 45  
     @Id
 46  
     @Column(name = "POSTAL_CNTRY_CD")
 47  
     def String countryCode;
 48  
 
 49  
     @Column(name = "POSTAL_CITY_NM")
 50  
     def String cityName;
 51  
 
 52  
     @Column(name = "POSTAL_STATE_NM")
 53  
     def String stateCode;
 54  
 
 55  
     @Column(name = "COUNTY_NM")
 56  
     def String countyCode;
 57  
 
 58  
     @Type(type = "yes_no")
 59  
     @Column(name = "ACTV_IND")
 60  
     def boolean active;
 61  
 
 62  
     @ManyToOne(targetEntity = CountryBo.class, fetch = FetchType.EAGER)
 63  
     @JoinColumn(name = "POSTAL_CNTRY_CD", insertable = false, updatable = false)
 64  
     def CountryBo country;
 65  
 
 66  
     @ManyToOne(targetEntity = CountryBo.class, fetch = FetchType.EAGER)
 67  
     @JoinColumn(name = "POSTAL_STATE_NM", insertable = false, updatable = false)
 68  
     def StateBo state;
 69  
 
 70  
 
 71  
     @ManyToOne(targetEntity = CountryBo.class, fetch = FetchType.EAGER)
 72  
     @JoinColumn(name = "COUNTY_NM", insertable = false, updatable = false)
 73  
     def CountyBo county;
 74  
 
 75  
     /**
 76  
      * Converts a mutable bo to its immutable counterpart
 77  
      * @param bo the mutable business object
 78  
      * @return An immutable PostalCode if the passed in mutable is not null.  If the mutable reference was null, then
 79  
      * null is returned.
 80  
      */
 81  
     static PostalCode to(PostalCodeBo bo) {
 82  9
         if (bo == null) {
 83  5
             return null
 84  
         }
 85  
 
 86  4
         return PostalCode.Builder.create(bo).build();
 87  
     }
 88  
 
 89  
     /**
 90  
      * Converts a immutable object to its mutable counterpart
 91  
      * @param im immutable object
 92  
      * @return a new mutable PostalCodeBo if the passed in mutable is not null.  If the immutable reference was null,
 93  
      * then null is returned.
 94  
      */
 95  
     static PostalCodeBo from(PostalCode im) {
 96  1
         if (im == null) {
 97  0
             return null
 98  
         }
 99  
 
 100  1
         PostalCodeBo bo = new PostalCodeBo()
 101  1
         bo.code = im.code
 102  1
         bo.countryCode = im.countryCode
 103  1
         bo.cityName = im.cityName
 104  1
         bo.active = im.active
 105  1
         bo.stateCode = im.stateCode
 106  1
         bo.cityName = im.cityName
 107  1
         bo.versionNumber = im.versionNumber
 108  
 
 109  1
         return bo
 110  
     }
 111  
 }