Coverage Report - org.kuali.rice.core.web.component.ComponentInquirableImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ComponentInquirableImpl
0%
0/31
0%
0/24
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.inquiry.KualiInquirableImpl;
 21  
 import org.kuali.rice.krad.bo.BusinessObject;
 22  
 import org.kuali.rice.krad.datadictionary.DataDictionaryException;
 23  
 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
 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.krad.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  
         @Override
 41  
         public Object retrieveDataObject(Map fieldValues){
 42  0
                 BusinessObject result = (BusinessObject)super.retrieveDataObject(fieldValues);
 43  
 
 44  0
                 if (result == null) {
 45  
 
 46  0
                         String parameterDetailTypeCode = (String)fieldValues.get(PARAMETER_DETAIL_TYPE_CODE);
 47  0
                 String parameterNamespaceCode = (String)fieldValues.get(PARAMETER_NAMESPACE_CODE);
 48  
                         
 49  0
                 if (parameterDetailTypeCode == null) throw new RuntimeException(PARAMETER_DETAIL_TYPE_CODE + 
 50  
                                 " is a required key for this inquiry");
 51  0
                 if (parameterNamespaceCode == null) throw new RuntimeException(PARAMETER_NAMESPACE_CODE + 
 52  
                                 " is a required key for this inquiry");
 53  
 
 54  
                         List<Component> components;
 55  
                 try {
 56  0
                         components = KRADServiceLocatorWeb.getRiceApplicationConfigurationMediationService().getNonDatabaseComponents();
 57  0
                 } catch (DataDictionaryException ex) {
 58  0
                     throw new RuntimeException(
 59  
                                     "Problem parsing data dictionary during full load required for inquiry to function: " + 
 60  
                                     ex.getMessage(), ex);
 61  0
                 }
 62  
                 
 63  0
                 for (Component pdt : components) {
 64  0
                         if (parameterDetailTypeCode.equals(pdt.getCode()) &&
 65  
                                         parameterNamespaceCode.equals(pdt.getNamespaceCode())) {
 66  0
                                 result = ComponentBo.from(pdt);
 67  0
                                 break;
 68  
                         }
 69  
                 }
 70  
                 }
 71  
                 
 72  0
                 return result; 
 73  
     }
 74  
         
 75  
         /**
 76  
          * This overridden method gets the BO for inquiries on {@link org.kuali.rice.core.impl.component.ComponentBo}
 77  
          * 
 78  
          * @see org.kuali.rice.krad.inquiry.KualiInquirableImpl#getBusinessObject(java.util.Map)
 79  
          */
 80  
         @Override
 81  
         public BusinessObject getBusinessObject(Map fieldValues) {
 82  0
                 BusinessObject result = super.getBusinessObject(fieldValues);
 83  
 
 84  0
                 if (result == null) {
 85  
 
 86  0
                         String parameterDetailTypeCode = (String)fieldValues.get(PARAMETER_DETAIL_TYPE_CODE);
 87  0
                 String parameterNamespaceCode = (String)fieldValues.get(PARAMETER_NAMESPACE_CODE);
 88  
                         
 89  0
                 if (parameterDetailTypeCode == null) throw new RuntimeException(PARAMETER_DETAIL_TYPE_CODE + 
 90  
                                 " is a required key for this inquiry");
 91  0
                 if (parameterNamespaceCode == null) throw new RuntimeException(PARAMETER_NAMESPACE_CODE + 
 92  
                                 " is a required key for this inquiry");
 93  
 
 94  
                         List<Component> components;
 95  
                 try {
 96  0
                         components = KRADServiceLocatorWeb.getRiceApplicationConfigurationMediationService().getNonDatabaseComponents();
 97  0
                 } catch (DataDictionaryException ex) {
 98  0
                     throw new RuntimeException(
 99  
                                     "Problem parsing data dictionary during full load required for inquiry to function: " + 
 100  
                                     ex.getMessage(), ex);
 101  0
                 }
 102  
                 
 103  0
                 for (Component pdt : components) {
 104  0
                         if (parameterDetailTypeCode.equals(pdt.getCode()) &&
 105  
                                         parameterNamespaceCode.equals(pdt.getNamespaceCode())) {
 106  0
                                 result = ComponentBo.from(pdt);
 107  0
                                 break;
 108  
                         }
 109  
                 }
 110  
                 }
 111  
                 
 112  0
                 return result; 
 113  
         }
 114  
         
 115  
 }