|  1 |     | 
     | 
  |  2 |     | 
     | 
  |  3 |     | 
     | 
  |  4 |     | 
     | 
  |  5 |     | 
     | 
  |  6 |     | 
     | 
  |  7 |     | 
     | 
  |  8 |     | 
     | 
  |  9 |     | 
     | 
  |  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 |     | 
     | 
  |  28 |     | 
     | 
  |  29 |     | 
     | 
  |  30 |     | 
     | 
  |  31 |     | 
     | 
  |  32 |     | 
     | 
  |  33 |     | 
     | 
  |  34 |     | 
     | 
  |  35 |     | 
     | 
  |  36 |    0 |    public class ViewDictionaryServiceImpl implements ViewDictionaryService { | 
  |  37 |     | 
     | 
  |  38 |     | 
       private DataDictionaryService dataDictionaryService;  | 
  |  39 |     | 
     | 
  |  40 |     | 
         | 
  |  41 |     | 
     | 
  |  42 |     | 
     | 
  |  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 |     | 
     | 
  |  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 |     | 
     | 
  |  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 |     | 
     | 
  |  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 |     | 
   }  |