Coverage Report - org.kuali.rice.kns.inquiry.ParameterDetailTypeInquirableImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ParameterDetailTypeInquirableImpl
0%
0/16
0%
0/12
11
 
 1  
 /*
 2  
  * Copyright 2007-2009 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.kns.inquiry;
 17  
 
 18  
 import java.util.List;
 19  
 import java.util.Map;
 20  
 
 21  
 import org.kuali.rice.kns.bo.BusinessObject;
 22  
 import org.kuali.rice.kns.bo.ParameterDetailType;
 23  
 import org.kuali.rice.kns.datadictionary.DataDictionaryException;
 24  
 import org.kuali.rice.kns.service.KNSServiceLocator;
 25  
 
 26  
 /**
 27  
  * Since ParameterDetailType can be either DataDictionary or DB based, we need a custom {@link Inquirable} to
 28  
  * check both.
 29  
  * 
 30  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 31  
  *
 32  
  */
 33  0
 public class ParameterDetailTypeInquirableImpl extends KualiInquirableImpl {
 34  
 
 35  
         private static final String PARAMETER_DETAIL_TYPE_CODE = "parameterDetailTypeCode";
 36  
         private static final String PARAMETER_NAMESPACE_CODE = "parameterNamespaceCode";
 37  
         
 38  
         /**
 39  
          * This overridden method gets the BO for inquiries on {@link ParameterDetailType}
 40  
          * 
 41  
          * @see org.kuali.rice.kns.inquiry.KualiInquirableImpl#getBusinessObject(java.util.Map)
 42  
          */
 43  
         @Override
 44  
         public BusinessObject getBusinessObject(Map fieldValues) {
 45  0
                 BusinessObject result = super.getBusinessObject(fieldValues);
 46  
 
 47  0
                 if (result == null) {
 48  
 
 49  0
                         String parameterDetailTypeCode = (String)fieldValues.get(PARAMETER_DETAIL_TYPE_CODE);
 50  0
                 String parameterNamespaceCode = (String)fieldValues.get(PARAMETER_NAMESPACE_CODE);
 51  
                         
 52  0
                 if (parameterDetailTypeCode == null) throw new RuntimeException(PARAMETER_DETAIL_TYPE_CODE + 
 53  
                                 " is a required key for this inquiry");
 54  0
                 if (parameterNamespaceCode == null) throw new RuntimeException(PARAMETER_NAMESPACE_CODE + 
 55  
                                 " is a required key for this inquiry");
 56  
 
 57  
                         List<ParameterDetailType> components;
 58  
                 try {
 59  0
                         components = KNSServiceLocator.getParameterServerService().getNonDatabaseComponents();
 60  0
                 } catch (DataDictionaryException ex) {
 61  0
                     throw new RuntimeException(
 62  
                                     "Problem parsing data dictionary during full load required for inquiry to function: " + 
 63  
                                     ex.getMessage(), ex);
 64  0
                 }
 65  
                 
 66  0
                 for (ParameterDetailType pdt : components) {
 67  0
                         if (parameterDetailTypeCode.equals(pdt.getParameterDetailTypeCode()) && 
 68  
                                         parameterNamespaceCode.equals(pdt.getParameterNamespaceCode())) {
 69  0
                                 result = pdt;
 70  0
                                 break;
 71  
                         }
 72  
                 }
 73  
                 }
 74  
                 
 75  0
                 return result; 
 76  
         }
 77  
         
 78  
 }