Coverage Report - org.kuali.rice.krms.impl.repository.TermBo
 
Classes in this File Line Coverage Branch Coverage Complexity
TermBo
0%
0/25
0%
0/18
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.krms.impl.repository
 17  
 
 18  
 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase
 19  
 
 20  
 import org.kuali.rice.krms.api.repository.term.TermDefinition;
 21  
 import org.kuali.rice.krms.api.repository.term.TermDefinitionContract
 22  
 import java.util.Map.Entry
 23  
 import org.kuali.rice.krms.api.repository.term.TermParameterDefinition;
 24  
 
 25  
 
 26  
 public class TermBo extends PersistableBusinessObjectBase implements TermDefinitionContract {
 27  
 
 28  
         def String id
 29  
         def String specificationId
 30  
     def String description
 31  
 
 32  
     // new-ing up an empty one allows the TermBo lookup to work on fields in the term specification:
 33  0
         def TermSpecificationBo specification = new TermSpecificationBo()
 34  
 
 35  
         def List<TermParameterBo> parameters
 36  0
     def Map<String, String> parametersMap = new HashMap<String, String>()
 37  
 
 38  
         /**
 39  
         * Converts a mutable bo to it's immutable counterpart
 40  
         * @param bo the mutable business object
 41  
         * @return the immutable object
 42  
         */
 43  
    static TermDefinition to(TermBo bo) {
 44  0
            if (bo == null) { return null }
 45  0
            return org.kuali.rice.krms.api.repository.term.TermDefinition.Builder.create(bo).build()
 46  
    }
 47  
 
 48  
    /**
 49  
         * Converts a immutable object to it's mutable bo counterpart
 50  
         * @param im immutable object
 51  
         * @return the mutable bo
 52  
         */
 53  
    static TermBo from(TermDefinition im) {
 54  0
            if (im == null) { return null }
 55  
 
 56  0
            TermBo bo = new TermBo()
 57  0
            bo.id = im.id
 58  0
            bo.specificationId = im.specification.id
 59  0
        bo.description = im.description
 60  0
            bo.specification = TermSpecificationBo.from(im.specification)
 61  0
            bo.parameters = new ArrayList<TermParameterBo>()
 62  0
            for (parm in im.parameters){
 63  0
                    bo.parameters.add ( TermParameterBo.from(parm) )
 64  
            }
 65  0
            bo.versionNumber = im.versionNumber
 66  0
            return bo
 67  
    }
 68  
 
 69  
    public TermSpecificationBo getSpecification(){
 70  0
            return specification
 71  
    }
 72  
 
 73  
    public List<TermParameterBo> getParameters(){
 74  0
            return parameters
 75  
    }
 76  
 
 77  
    public void exportToParametersMap() {
 78  
 
 79  
        // merge in TermParameterBo values
 80  0
        if (parameters != null) for (TermParameterBo param : parameters) {
 81  0
            parametersMap.put(param.name, param.value);
 82  
        }
 83  
 
 84  
    }
 85  
 
 86  
    public void importFromParametersMap() {
 87  
 
 88  0
        if (parameters == null) {
 89  0
            parameters = new ArrayList<TermParameterBo>()
 90  
        } else {
 91  0
            parameters.clear();
 92  
        }
 93  
 
 94  0
        for (Entry<String, String> paramEntry : parametersMap.entrySet()) {
 95  0
            TermParameterDefinition termDef = TermParameterDefinition.Builder.create(null, id, paramEntry.key, paramEntry.value).build();
 96  0
            parameters.add(TermParameterBo.from(termDef));
 97  
        }
 98  
 
 99  
    }
 100  
 
 101  
 }