Coverage Report - org.kuali.rice.kns.service.impl.KualiConfigurationServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
KualiConfigurationServiceImpl
0%
0/25
0%
0/16
2.5
 
 1  
 /*
 2  
  * Copyright 2005-2007 The Kuali Foundation
 3  
  * 
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in
 5  
  * compliance with the License. You may obtain a copy of the License at
 6  
  * 
 7  
  * http://www.opensource.org/licenses/ecl2.php
 8  
  * 
 9  
  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS
 10  
  * IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
 11  
  * language governing permissions and limitations under the License.
 12  
  */
 13  
 package org.kuali.rice.kns.service.impl;
 14  
 
 15  
 import java.util.Arrays;
 16  
 import java.util.Collections;
 17  
 import java.util.HashMap;
 18  
 import java.util.List;
 19  
 
 20  
 import org.apache.commons.lang.StringUtils;
 21  
 import org.kuali.rice.kns.bo.Parameter;
 22  
 import org.kuali.rice.kns.service.BusinessObjectService;
 23  
 import org.kuali.rice.kns.service.KNSServiceLocator;
 24  
 import org.kuali.rice.kns.service.KualiConfigurationService;
 25  
 
 26  
 //@Transactional
 27  0
 public class KualiConfigurationServiceImpl extends AbstractStaticConfigurationServiceImpl implements KualiConfigurationService {
 28  0
     private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(KualiConfigurationServiceImpl.class);
 29  
 
 30  
     @Deprecated
 31  
     public List<String> getParameterValues(Parameter parameter) {
 32  0
             if (parameter == null || StringUtils.isBlank(parameter.getParameterValue())) {
 33  0
                 return Collections.EMPTY_LIST;
 34  
             }
 35  0
             return Arrays.asList(parameter.getParameterValue().split(";"));
 36  
     }
 37  
 
 38  
     //public boolean constraintIsAllow(Parameter parameter) {
 39  
     //    return KNSConstants.APC_ALLOWED_OPERATOR.equals(parameter.getParameterConstraintCode());
 40  
     //}
 41  
 
 42  
     @Deprecated
 43  
     public Parameter getParameter(String namespaceCode, String detailTypeCode, String parameterName) {
 44  0
             if (StringUtils.isBlank(namespaceCode) || StringUtils.isBlank(detailTypeCode) || StringUtils.isBlank(parameterName)) {
 45  0
                 throw new IllegalArgumentException(
 46  
                         "The getParameter method of KualiConfigurationServiceImpl requires a non-blank namespaceCode, parameterDetailTypeCode, and parameterName");
 47  
             }
 48  0
             Parameter param = getParameterWithoutExceptions(namespaceCode, detailTypeCode, parameterName);
 49  0
             if (param == null) {
 50  0
                 throw new IllegalArgumentException(
 51  
                         "The getParameter method of KualiConfigurationServiceImpl was unable to find parameter: "
 52  
                                 + namespaceCode + " / " + detailTypeCode + " / " + parameterName);
 53  
             }
 54  0
             return param;
 55  
     }
 56  
 
 57  
     //public List<Parameter> getParameters(Map<String, String> criteria) {
 58  
     //        ArrayList<Parameter> parameters = new ArrayList<Parameter>();
 59  
     //        parameters.addAll(getBusinessObjectService().findMatching(Parameter.class, criteria));
 60  
     //        return parameters;
 61  
     //}
 62  
 
 63  
     //public boolean evaluateConstrainedValue(String namespace, String detailType, String parameterName,
 64  
         //    String constrainedValue) {
 65  
     //    return evaluateConstrainedValue(getParameter(namespace, detailType, parameterName), constrainedValue);
 66  
     //}
 67  
 
 68  
    // public boolean evaluateConstrainedValue(Parameter parameter, String constrainedValue) {
 69  
    //         checkParameterArgument(parameter, "evaluateConstrainedValue(Parameter parameter, String constrainedValue)");
 70  
    //         if (constraintIsAllow(parameter)) {
 71  
    //             return getParameterValues(parameter).contains(constrainedValue);
 72  
    //         } else {
 73  
    //             return !getParameterValues(parameter).contains(constrainedValue);
 74  
    //         }
 75  
    // }
 76  
 
 77  
     @Deprecated
 78  
     public List<String> getParameterValues(String namespaceCode, String parameterDetailTypeCode, String parameterName) {
 79  0
         return getParameterValues(getParameter(namespaceCode, parameterDetailTypeCode, parameterName));
 80  
     }
 81  
 
 82  
     @Deprecated
 83  
     public boolean getIndicatorParameter(String namespaceCode, String parameterDetailTypeCode, String parameterName) {
 84  0
         return "Y".equals(getParameterValue(namespaceCode, parameterDetailTypeCode, parameterName));
 85  
     }
 86  
 
 87  
     @Deprecated
 88  
     public String getParameterValue(String namespaceCode, String parameterDetailTypeCode, String parameterName) {
 89  0
             List<String> parameterValues = getParameterValues(getParameter(namespaceCode, parameterDetailTypeCode, parameterName));
 90  0
             return parameterValues.isEmpty() ? "" : parameterValues.iterator().next();
 91  
     }
 92  
 
 93  
     //public boolean parameterExists(String namespaceCode, String parameterDetailTypeCode, String parameterName) {
 94  
     //    return getParameterWithoutExceptions(namespaceCode, parameterDetailTypeCode, parameterName) != null;
 95  
     //}
 96  
 
 97  
     private void checkParameterArgument(Parameter parameter, String methodName) {
 98  0
             if (parameter == null) {
 99  0
                 throw new IllegalArgumentException("The " + methodName
 100  
                         + " method of KualiConfigurationServiceImpl requires a non-null parameter");
 101  
             }
 102  0
     }
 103  
     
 104  
     public Parameter getParameterWithoutExceptions(String namespaceCode, String detailTypeCode, String parameterName) {
 105  0
         HashMap<String, String> crit = new HashMap<String, String>(3);
 106  0
         crit.put("parameterNamespaceCode", namespaceCode);
 107  0
         crit.put("parameterDetailTypeCode", detailTypeCode);
 108  0
         crit.put("parameterName", parameterName);
 109  0
         Parameter param = (Parameter) getBusinessObjectService().findByPrimaryKey(Parameter.class, crit);
 110  0
         return param;
 111  
     }
 112  
     
 113  
     // using this instead of private variable with spring initialization because of recurring issues with circular
 114  
     // references
 115  
     // resulting in this error: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean
 116  
     // with
 117  
     // name 'businessObjectService': Bean with name 'businessObjectService' has been injected into other beans
 118  
     // [kualiConfigurationService]
 119  
     // in its raw version as part of a circular reference, but has eventually been wrapped (for example as part of
 120  
     // auto-proxy creation).
 121  
     // This means that said other beans do not use the final version of the bean. This is often the result of over-eager
 122  
     // type matching
 123  
     // - consider using 'getBeanNamesOfType' with the 'allowEagerInit' flag turned off, for example.
 124  
     private BusinessObjectService getBusinessObjectService() {
 125  0
         return KNSServiceLocator.getBusinessObjectService();
 126  
     }
 127  
 }