Coverage Report - org.kuali.rice.location.impl.state.StateBo
 
Classes in this File Line Coverage Branch Coverage Complexity
StateBo
0%
0/12
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.state
 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  
 import org.kuali.rice.core.api.mo.common.active.MutableInactivatable
 28  
 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase
 29  
 import org.kuali.rice.location.api.state.State
 30  
 import org.kuali.rice.location.api.state.StateContract
 31  
 import org.kuali.rice.location.impl.country.CountryBo
 32  
 
 33  
 @IdClass(StateId.class)
 34  
 @Entity
 35  
 @Table(name = "KRLC_ST_T")
 36  
 class StateBo extends PersistableBusinessObjectBase implements StateContract, MutableInactivatable {
 37  
 
 38  
     @Id
 39  
     @Column(name = "POSTAL_STATE_CD")
 40  
     def String code;
 41  
 
 42  
     @Id
 43  
     @Column(name = "POSTAL_CNTRY_CD")
 44  
     def String countryCode;
 45  
 
 46  
     @Column(name = "POSTAL_STATE_NM")
 47  
     def String name;
 48  
 
 49  
     @Type(type = "yes_no")
 50  
     @Column(name = "ACTV_IND")
 51  
     def boolean active;
 52  
 
 53  
     @ManyToOne(targetEntity = CountryBo.class, fetch = FetchType.EAGER)
 54  
     @JoinColumn(name = "POSTAL_CNTRY_CD", insertable = false, updatable = false)
 55  
     def CountryBo country;
 56  
 
 57  
     /**
 58  
      * Converts a mutable bo to its immutable counterpart
 59  
      * @param bo the mutable business object
 60  
      * @return An immutable State if the passed in mutable is not null.  If the mutable reference was null, then null
 61  
      * is returned.
 62  
      */
 63  
     static State to(StateBo bo) {
 64  0
         if (bo == null) {
 65  0
             return null
 66  
         }
 67  
 
 68  0
         return State.Builder.create(bo).build();
 69  
     }
 70  
 
 71  
     /**
 72  
      * Converts a immutable object to its mutable counterpart
 73  
      * @param im immutable object
 74  
      * @return a new mutable CountryBo if the passed in immutable is not null.  If the immutable reference was null,
 75  
      * then null is returned.
 76  
      */
 77  
     static StateBo from(State im) {
 78  0
         if (im == null) {
 79  0
             return null
 80  
         }
 81  
 
 82  0
         StateBo bo = new StateBo()
 83  0
         bo.code = im.code
 84  0
         bo.countryCode = im.countryCode
 85  0
         bo.name = im.name
 86  0
         bo.active = im.active
 87  0
         bo.versionNumber = im.versionNumber
 88  
 
 89  0
         return bo
 90  
     }
 91  
 }