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