Coverage Report - org.kuali.rice.location.impl.postalcode.PostalCodeBo
 
Classes in this File Line Coverage Branch Coverage Complexity
PostalCodeBo
0%
0/14
0%
0/4
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.location.impl.postalcode
 17  
 
 18  
 import javax.persistence.Column
 19  
 import javax.persistence.Entity
 20  
 import javax.persistence.FetchType
 21  
 import javax.persistence.Id
 22  
 import javax.persistence.IdClass
 23  
 import javax.persistence.JoinColumn
 24  
 import javax.persistence.ManyToOne
 25  
 import javax.persistence.Table
 26  
 import org.hibernate.annotations.Type
 27  
 
 28  
 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase
 29  
 import org.kuali.rice.location.api.postalcode.PostalCode
 30  
 import org.kuali.rice.location.api.postalcode.PostalCodeContract
 31  
 import org.kuali.rice.location.impl.country.CountryBo
 32  
 import org.kuali.rice.location.impl.county.CountyBo
 33  
 import org.kuali.rice.location.impl.state.StateBo
 34  
 import org.kuali.rice.core.api.mo.common.active.MutableInactivatable
 35  
 
 36  
 @IdClass(PostalCodeId.class)
 37  
 @Entity
 38  
 @Table(name = "KRLC_PSTL_CD_T")
 39  
 class PostalCodeBo extends PersistableBusinessObjectBase implements PostalCodeContract, MutableInactivatable {
 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 = CountyBo.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  0
         if (bo == null) {
 83  0
             return null
 84  
         }
 85  
 
 86  0
         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  0
         if (im == null) {
 97  0
             return null
 98  
         }
 99  
 
 100  0
         PostalCodeBo bo = new PostalCodeBo()
 101  0
         bo.code = im.code
 102  0
         bo.countryCode = im.countryCode
 103  0
         bo.cityName = im.cityName
 104  0
         bo.active = im.active
 105  0
         bo.stateCode = im.stateCode
 106  0
         bo.cityName = im.cityName
 107  0
         bo.versionNumber = im.versionNumber
 108  
 
 109  0
         return bo
 110  
     }
 111  
 }