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