Coverage Report - org.kuali.rice.core.impl.parameter.ParameterBo
 
Classes in this File Line Coverage Branch Coverage Complexity
ParameterBo
95%
19/20
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  
 package org.kuali.rice.core.impl.parameter;
 17  
 
 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.OneToOne
 27  
 import javax.persistence.Table
 28  
 import org.kuali.rice.core.api.parameter.EvaluationOperator
 29  
 import org.kuali.rice.core.api.parameter.ParameterContract
 30  
 import org.kuali.rice.core.impl.component.ComponentBo
 31  
 import org.kuali.rice.core.impl.namespace.NamespaceBo
 32  
 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase
 33  
 
 34  
 @IdClass(ParameterId.class)
 35  
 @Entity
 36  
 @Table(name = "KRCR_PARM_T")
 37  
 public class ParameterBo extends PersistableBusinessObjectBase implements ParameterContract {
 38  
 
 39  
     private static final long serialVersionUID = 1L;
 40  
 
 41  
     @Id
 42  
     @Column(name = "NMSPC_CD")
 43  
     def String namespaceCode
 44  
 
 45  
     @Id
 46  
     @Column(name = "PARM_DTL_TYP_CD")
 47  
     def String componentCode
 48  
 
 49  
     @Id
 50  
     @Column(name = "PARM_NM")
 51  
     def String name
 52  
 
 53  
     @Id
 54  
     @Column(name = "APPL_ID")
 55  
     def String applicationId
 56  
 
 57  
     @Column(name = "TXT")
 58  
     def String value
 59  
 
 60  
     @Column(name = "PARM_DESC_TXT", length = 2048)
 61  
     def String description
 62  
 
 63  
     @Column(name = "PARM_TYP_CD")
 64  
     def String parameterTypeCode
 65  
 
 66  
     @Column(name = "CONS_CD")
 67  
     def String evaluationOperatorCode
 68  
 
 69  
     @ManyToOne(fetch = FetchType.LAZY)
 70  
     @JoinColumn(name = "NMSPC_CD", insertable = false, updatable = false)
 71  
     def NamespaceBo namespace
 72  
 
 73  
     @OneToOne(fetch = FetchType.LAZY)
 74  
     @JoinColumn(name = "PARM_TYP_CD", insertable = false, updatable = false)
 75  
     def ParameterTypeBo parameterType
 76  
 
 77  
     @OneToOne(fetch = FetchType.LAZY)
 78  
     @JoinColumn(name = "PARM_TYP_CD", insertable = false, updatable = false)
 79  
     def ComponentBo component
 80  
 
 81  
     /**
 82  
      * Converts a mutable bo to its immutable counterpart
 83  
      * @param bo the mutable business object
 84  
      * @return the immutable object
 85  
      */
 86  
     static org.kuali.rice.core.api.parameter.Parameter to(ParameterBo bo) {
 87  25
         if (bo == null) {
 88  8
             return null
 89  
         }
 90  
 
 91  17
         return org.kuali.rice.core.api.parameter.Parameter.Builder.create(bo).build();
 92  
     }
 93  
 
 94  
     /**
 95  
      * Converts a immutable object to its mutable counterpart
 96  
      * @param im immutable object
 97  
      * @return the mutable bo
 98  
      */
 99  
     static ParameterBo from(org.kuali.rice.core.api.parameter.Parameter im) {
 100  38
         if (im == null) {
 101  0
             return null
 102  
         }
 103  
 
 104  38
         ParameterBo bo = new ParameterBo()
 105  38
         bo.namespaceCode = im.namespaceCode
 106  38
         bo.componentCode = im.componentCode
 107  38
         bo.name = im.name
 108  38
         bo.applicationId = im.applicationId
 109  38
         bo.value = im.value
 110  38
         bo.description = im.description
 111  38
         bo.parameterTypeCode = im.parameterType.code
 112  38
         bo.evaluationOperatorCode = im.evaluationOperator.code
 113  
 
 114  38
         bo.parameterType = ParameterTypeBo.from(im.parameterType)
 115  38
         bo.versionNumber = im.versionNumber
 116  38
                 bo.objectId = im.objectId;
 117  
 
 118  38
         return bo
 119  
     }
 120  
 
 121  
     @Override
 122  
     ParameterTypeBo getParameterType() {
 123  17
         return parameterType
 124  
     }
 125  
         
 126  
         @Override
 127  
         EvaluationOperator getEvaluationOperator() {
 128  17
                 return EvaluationOperator.fromCode(evaluationOperatorCode);
 129  
         }
 130  
 }
 131