Coverage Report - org.kuali.rice.kns.uif.service.impl.ViewDictionaryServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ViewDictionaryServiceImpl
0%
0/42
0%
0/22
2.571
 
 1  
 /*
 2  
  * Copyright 2011 The Kuali Foundation Licensed under the Educational Community
 3  
  * License, Version 1.0 (the "License"); you may not use this file except in
 4  
  * compliance with the License. You may obtain a copy of the License at
 5  
  * http://www.opensource.org/licenses/ecl1.php Unless required by applicable law
 6  
  * or agreed to in writing, software distributed under the License is
 7  
  * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 8  
  * KIND, either express or implied. See the License for the specific language
 9  
  * governing permissions and limitations under the License.
 10  
  */
 11  
 package org.kuali.rice.kns.uif.service.impl;
 12  
 
 13  
 import java.util.List;
 14  
 
 15  
 import org.apache.commons.lang.StringUtils;
 16  
 import org.kuali.rice.kns.datadictionary.DataDictionary;
 17  
 import org.kuali.rice.kns.inquiry.Inquirable;
 18  
 import org.kuali.rice.kns.service.DataDictionaryService;
 19  
 import org.kuali.rice.kns.uif.UifConstants;
 20  
 import org.kuali.rice.kns.uif.container.InquiryView;
 21  
 import org.kuali.rice.kns.uif.container.LookupView;
 22  
 import org.kuali.rice.kns.uif.container.MaintenanceView;
 23  
 import org.kuali.rice.kns.uif.container.View;
 24  
 import org.kuali.rice.kns.uif.service.ViewDictionaryService;
 25  
 
 26  
 /**
 27  
  * Implementation of <code>ViewDictionaryService</code>
 28  
  * 
 29  
  * <p>
 30  
  * Pulls view entries from the data dictionary to implement the various query
 31  
  * methods
 32  
  * </p>
 33  
  * 
 34  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 35  
  */
 36  0
 public class ViewDictionaryServiceImpl implements ViewDictionaryService {
 37  
 
 38  
     private DataDictionaryService dataDictionaryService;
 39  
 
 40  
     /**
 41  
      * @see org.kuali.rice.kns.uif.service.ViewDictionaryService#getInquirable(java.lang.Class,
 42  
      *      java.lang.String)
 43  
      */
 44  
     public Inquirable getInquirable(Class<?> dataObjectClass, String viewName) {
 45  0
         List<View> inquiryViews = getDataDictionary().getViewsForType(UifConstants.ViewType.INQUIRY);
 46  
 
 47  0
         Inquirable inquirable = null;
 48  0
         for (View view : inquiryViews) {
 49  0
             InquiryView inquiryView = (InquiryView) view;
 50  
 
 51  0
             if (StringUtils.equals(inquiryView.getDataObjectClassName().getName(), dataObjectClass.getName())) {
 52  0
                 if (StringUtils.equals(inquiryView.getViewName(), viewName)
 53  
                         || (StringUtils.isBlank(viewName) && StringUtils.equals(inquiryView.getViewName(),
 54  
                                 UifConstants.DEFAULT_VIEW_NAME))) {
 55  0
                     inquirable = (Inquirable) inquiryView.getViewHelperService();
 56  0
                     break;
 57  
                 }
 58  
             }
 59  0
         }
 60  
 
 61  0
         return inquirable;
 62  
     }
 63  
 
 64  
     /**
 65  
      * @see org.kuali.rice.kns.uif.service.ViewDictionaryService#isInquirable(java.lang.Class)
 66  
      */
 67  
     public boolean isInquirable(Class<?> dataObjectClass) {
 68  0
         boolean inquirable = false;
 69  
 
 70  0
         List<View> inquiryViews = getDataDictionary().getViewsForType(UifConstants.ViewType.INQUIRY);
 71  0
         for (View view : inquiryViews) {
 72  0
             InquiryView inquiryView = (InquiryView) view;
 73  
 
 74  0
             if (StringUtils.equals(inquiryView.getDataObjectClassName().getName(), dataObjectClass.getName())) {
 75  0
                 inquirable = true;
 76  0
                 break;
 77  
             }
 78  0
         }
 79  
 
 80  0
         return inquirable;
 81  
     }
 82  
 
 83  
     /**
 84  
      * @see org.kuali.rice.kns.uif.service.ViewDictionaryService#isLookupable(java.lang.Class)
 85  
      */
 86  
     public boolean isLookupable(Class<?> dataObjectClass) {
 87  0
         boolean lookupable = false;
 88  
 
 89  0
         List<View> lookupViews = getDataDictionary().getViewsForType(UifConstants.ViewType.LOOKUP);
 90  0
         for (View view : lookupViews) {
 91  0
             LookupView lookupView = (LookupView) view;
 92  
 
 93  0
             if (StringUtils.equals(lookupView.getDataObjectClassName().getName(), dataObjectClass.getName())) {
 94  0
                 lookupable = true;
 95  0
                 break;
 96  
             }
 97  0
         }
 98  
 
 99  0
         return lookupable;
 100  
     }
 101  
 
 102  
     /**
 103  
      * @see org.kuali.rice.kns.uif.service.ViewDictionaryService#isMaintainable(java.lang.Class)
 104  
      */
 105  
     public boolean isMaintainable(Class<?> dataObjectClass) {
 106  0
         boolean maintainable = false;
 107  
 
 108  0
         List<View> maintenanceViews = getDataDictionary().getViewsForType(UifConstants.ViewType.MAINTENANCE);
 109  0
         for (View view : maintenanceViews) {
 110  0
             MaintenanceView maintenanceView = (MaintenanceView) view;
 111  
 
 112  0
             if (StringUtils.equals(maintenanceView.getDataObjectClassName().getName(), dataObjectClass.getName())) {
 113  0
                 maintainable = true;
 114  0
                 break;
 115  
             }
 116  0
         }
 117  
 
 118  0
         return maintainable;
 119  
     }
 120  
 
 121  
     protected DataDictionary getDataDictionary() {
 122  0
         return getDataDictionaryService().getDataDictionary();
 123  
     }
 124  
 
 125  
     protected DataDictionaryService getDataDictionaryService() {
 126  0
         return this.dataDictionaryService;
 127  
     }
 128  
 
 129  
     public void setDataDictionaryService(DataDictionaryService dataDictionaryService) {
 130  0
         this.dataDictionaryService = dataDictionaryService;
 131  0
     }
 132  
 }