Coverage Report - org.kuali.rice.shareddata.impl.county.CountyBo
 
Classes in this File Line Coverage Branch Coverage Complexity
CountyBo
92%
12/13
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.county
 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.county.County
 31  
 import org.kuali.rice.shareddata.api.county.CountyContract
 32  
 import org.kuali.rice.shareddata.impl.country.CountryBo
 33  
 import org.kuali.rice.shareddata.impl.state.StateBo
 34  
 
 35  
 @IdClass(CountyId.class)
 36  
 @Entity
 37  
 @Table(name = "KRLC_CNTY_T")
 38  
 class CountyBo extends PersistableBusinessObjectBase implements CountyContract, Inactivateable {
 39  
 
 40  
     @Id
 41  
     @Column(name = "COUNTY_CD")
 42  
     def String code
 43  
 
 44  
     @Id
 45  
     @Column(name = "POSTAL_CNTRY_CD")
 46  
     def String countryCode
 47  
 
 48  
     @Id
 49  
     @Column(name = "STATE_CD")
 50  
     def String stateCode
 51  
 
 52  
     @Column(name = "COUNTY_NM")
 53  
     def String name
 54  
 
 55  
     @Type(type = "yes_no")
 56  
     @Column(name = "ACTV_IND")
 57  
     def boolean active
 58  
 
 59  
     @ManyToOne(targetEntity = CountryBo.class, fetch = FetchType.EAGER)
 60  
     @JoinColumn(name = "POSTAL_CNTRY_CD", insertable = false, updatable = false)
 61  
     def CountryBo country;
 62  
 
 63  
     @ManyToOne(targetEntity = StateBo.class, fetch = FetchType.EAGER)
 64  
     @JoinColumn(name = "STATE_CD", insertable = false, updatable = false)
 65  
     def StateBo state;
 66  
 
 67  
     /**
 68  
      * Converts a mutable bo to its immutable counterpart
 69  
      * @param bo the mutable business object
 70  
      * @return An immutable County if the passed in mutable is not null.  If the mutable reference was null,
 71  
      * then null is returned.
 72  
      */
 73  
     static County to(CountyBo bo) {
 74  7
         if (bo == null) {
 75  5
             return null
 76  
         }
 77  
 
 78  2
         return County.Builder.create(bo).build();
 79  
     }
 80  
 
 81  
     /**
 82  
      * Converts a immutable object to its mutable counterpart
 83  
      * @param im immutable object
 84  
      * @return a new mutable CountyBo if the passed in immutable is not null.  If the immutable reference was null,
 85  
      * then null is returned.
 86  
      */
 87  
     static CountyBo from(County im) {
 88  1
         if (im == null) {
 89  0
             return null
 90  
         }
 91  
 
 92  1
         CountyBo bo = new CountyBo()
 93  1
         bo.code = im.code
 94  1
         bo.name = im.name
 95  1
         bo.countryCode = im.countryCode
 96  1
         bo.stateCode = im.stateCode
 97  1
         bo.active = im.active
 98  1
         bo.versionNumber = im.versionNumber
 99  
 
 100  1
         return bo
 101  
     }
 102  
 }