View Javadoc
1   /**
2    * Copyright 2005-2014 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.krad.service;
17  
18  import org.kuali.rice.core.api.CoreConstants;
19  import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
20  import org.kuali.rice.krad.lookup.Lookupable;
21  import org.kuali.rice.krad.messages.MessageService;
22  import org.kuali.rice.krad.uif.lifecycle.ViewLifecyclePhaseBuilder;
23  import org.kuali.rice.krad.uif.service.AttributeQueryService;
24  import org.kuali.rice.krad.uif.service.UifDefaultingService;
25  import org.kuali.rice.krad.uif.service.ViewDictionaryService;
26  import org.kuali.rice.krad.uif.service.ViewService;
27  import org.kuali.rice.krad.uif.view.ExpressionEvaluatorFactory;
28  import org.kuali.rice.krad.web.service.ModelAndViewService;
29  import org.kuali.rice.krad.workflow.service.WorkflowDocumentService;
30  import org.springframework.web.servlet.ModelAndView;
31  
32  /**
33   * Service locator for the KRAD Web module
34   *
35   * @author Kuali Rice Team (rice.collab@kuali.org)
36   */
37  public class KRADServiceLocatorWeb {
38  
39      public static final class Namespaces {
40          public static final String MODULE_NAME = "krad";
41          public static final String KRAD_NAMESPACE_PREFIX =
42                  CoreConstants.Namespaces.ROOT_NAMESPACE_PREFIX + "/" + MODULE_NAME;
43  
44          /**
45           * Namespace for the krad module which is compatible with Kuali Rice 2.0.x.
46           */
47          public static final String KRAD_NAMESPACE_2_0 =
48                  KRAD_NAMESPACE_PREFIX + "/" + CoreConstants.Versions.VERSION_2_0;
49  
50      }
51  
52      public static final String DATA_DICTIONARY_REMOTE_FIELD_SERVICE = "dataDictionaryRemoteFieldService";
53      public static final String DATA_DICTIONARY_COMPONENT_PUBLISHER_SERVICE = "dataDictionaryComponentPublisherService";
54      public static final String DOCUMENT_DICTIONARY_SERVICE = "documentDictionaryService";
55      public static final String DATA_OBJECT_AUTHORIZATION_SERVICE = "dataObjectAuthorizationService";
56      public static final String MAINTENANCE_DOCUMENT_SERVICE = "maintenanceDocumentService";
57      public static final String WORKFLOW_DOCUMENT_SERVICE = "workflowDocumentService";
58      public static final String EXCEPTION_INCIDENT_REPORT_SERVICE = "kradExceptionIncidentService";
59      public static final String FEEDBACK_REPORT_SERVICE = "kradFeedbackService";
60      /* KULRICE-12304: Added a new locator for the new MaintainableXMLConversionService */
61      public static final String MAINTAINABLE_XML_CONVERSION_SERVICE = "kradMaintainableXMLConversionService";
62  
63      public static final String DATA_DICTIONARY_SERVICE = "dataDictionaryService";
64      public static final String PESSIMISTIC_LOCK_SERVICE = "pessimisticLockService";
65      public static final String KUALI_MODULE_SERVICE = "kualiModuleService";
66      public static final String KUALI_RULE_SERVICE = "kualiRuleService";
67      public static final String DOCUMENT_SERVICE = "documentService";
68      public static final String DOCUMENT_HEADER_SERVICE = "documentHeaderService";
69      public static final String DOCUMENT_SERIALIZER_SERVICE = "documentSerializerService";
70      public static final String LOOKUP_SERVICE = "lookupService";
71      public static final String DICTIONARY_VALIDATION_SERVICE = "dictionaryValidationService";
72      public static final String DEFAULT_INACTIVATION_BLOCKING_DETECTION_SERVICE = "inactivationBlockingDetectionService";
73      public static final String VIEW_SERVICE = "viewService";
74      public static final String VIEW_DICTIONARY_SERVICE = "viewDictionaryService";
75      public static final String VIEW_VALIDATION_SERVICE = "viewValidationService";
76      public static final String ATTRIBUTE_QUERY_SERVICE = "attributeQueryService";
77      public static final String MESSAGE_SERVICE = "messageService";
78      public static final String POST_PROCESSOR_SERVICE = "postProcessorService";
79      public static final String INACTIVATION_BLOCKING_DISPLAY_SERVICE = "inactivationBlockingDisplayService";
80      public static final String LEGACY_DATA_ADAPTER = "legacyDataAdapter";
81      public static final String UIF_DEFAULTING_SERVICE = "uifDefaultingService";
82      public static final String EXPRESSION_EVALUATOR_FACTORY = "expressionEvaluatorFactory";
83      public static final String VIEW_LIFECYCLE_PHASE_BUILDER = "viewLifecyclePhaseBuilder";
84      public static final String MODEL_AND_VIEW_SERVICE = "modelAndViewService";
85  
86      public static <T extends Object> T getService(String serviceName) {
87          return GlobalResourceLoader.<T>getService(serviceName);
88      }
89  
90      public static DocumentDictionaryService getDocumentDictionaryService() {
91          return getService(DOCUMENT_DICTIONARY_SERVICE);
92      }
93  
94      public static DataObjectAuthorizationService getDataObjectAuthorizationService() {
95          return getService(DATA_OBJECT_AUTHORIZATION_SERVICE);
96      }
97  
98      public static MaintenanceDocumentService getMaintenanceDocumentService() {
99          return getService(MAINTENANCE_DOCUMENT_SERVICE);
100     }
101 
102     public static WorkflowDocumentService getWorkflowDocumentService() {
103         return getService(WORKFLOW_DOCUMENT_SERVICE);
104     }
105 
106     public static DocumentHeaderService getDocumentHeaderService() {
107         return getService(DOCUMENT_HEADER_SERVICE);
108     }
109 
110     public static final KualiExceptionIncidentService getKualiExceptionIncidentService() {
111         return getService(EXCEPTION_INCIDENT_REPORT_SERVICE);
112     }
113 
114     public static final KualiFeedbackService getKualiFeedbackService() {
115         return getService(FEEDBACK_REPORT_SERVICE);
116     }
117     /* KULRICE-12304:Added a new locator for the new MaintainableXMLConversionService */
118     public static final MaintainableXMLConversionService getMaintainableXMLConversionService() {
119         return getService(MAINTAINABLE_XML_CONVERSION_SERVICE);
120     }
121 
122     public static DataDictionaryService getDataDictionaryService() {
123         return getService(DATA_DICTIONARY_SERVICE);
124     }
125 
126     public static PessimisticLockService getPessimisticLockService() {
127         return getService(PESSIMISTIC_LOCK_SERVICE);
128     }
129 
130     public static Lookupable getLookupable(String lookupableName) {
131         return getService(lookupableName);
132     }
133 
134     public static KualiModuleService getKualiModuleService() {
135         return getService(KUALI_MODULE_SERVICE);
136     }
137 
138     public static KualiRuleService getKualiRuleService() {
139         return getService(KUALI_RULE_SERVICE);
140     }
141 
142     public static DocumentService getDocumentService() {
143         return getService(DOCUMENT_SERVICE);
144     }
145 
146     public static DocumentSerializerService getDocumentSerializerService() {
147         return (DocumentSerializerService) getService(DOCUMENT_SERIALIZER_SERVICE);
148     }
149 
150     public static LookupService getLookupService() {
151         return (LookupService) getService(LOOKUP_SERVICE);
152     }
153 
154     public static DictionaryValidationService getDictionaryValidationService() {
155         return (DictionaryValidationService) getService(DICTIONARY_VALIDATION_SERVICE);
156     }
157 
158     public static InactivationBlockingDetectionService getInactivationBlockingDetectionService(String serviceName) {
159         return (InactivationBlockingDetectionService) getService(serviceName);
160     }
161 
162     public static ViewService getViewService() {
163         return (ViewService) getService(VIEW_SERVICE);
164     }
165 
166     public static ViewDictionaryService getViewDictionaryService() {
167         return (ViewDictionaryService) getService(VIEW_DICTIONARY_SERVICE);
168     }
169 
170     public static ViewValidationService getViewValidationService() {
171         return (ViewValidationService) getService(VIEW_VALIDATION_SERVICE);
172     }
173 
174     public static AttributeQueryService getAttributeQueryService() {
175         return (AttributeQueryService) getService(ATTRIBUTE_QUERY_SERVICE);
176     }
177 
178     public static ModelAndViewService getModelAndViewService() {
179         return (ModelAndViewService) getService(MODEL_AND_VIEW_SERVICE);
180     }
181 
182     public static DataDictionaryRemoteFieldService getDataDictionaryRemoteFieldService() {
183         return (DataDictionaryRemoteFieldService) getService(DATA_DICTIONARY_REMOTE_FIELD_SERVICE);
184     }
185 
186     public static MessageService getMessageService() {
187         return getService(MESSAGE_SERVICE);
188     }
189 
190     public static DataDictionaryComponentPublisherService getDataDictionaryComponentPublisherService() {
191         return getService(DATA_DICTIONARY_COMPONENT_PUBLISHER_SERVICE);
192     }
193 
194     public static PostProcessorService getPostProcessorService() {
195         return (PostProcessorService) getService(POST_PROCESSOR_SERVICE);
196     }
197 
198     public static InactivationBlockingDisplayService getInactivationBlockingDisplayService() {
199     	return (InactivationBlockingDisplayService) getService(INACTIVATION_BLOCKING_DISPLAY_SERVICE);
200     }
201 
202     public static UifDefaultingService getUifDefaultingService() {
203         return getService(UIF_DEFAULTING_SERVICE);
204     }
205 
206     /**
207      * Gets a globally defined instance of {@link org.kuali.rice.krad.uif.view.ExpressionEvaluatorFactory}.
208      *
209      * @return globally defined expression evaluator factory
210      */
211     public static ExpressionEvaluatorFactory getExpressionEvaluatorFactory() {
212         return getService(EXPRESSION_EVALUATOR_FACTORY);
213     }
214 
215     /**
216      * Returns a {@link ViewLifecyclePhaseBuilder} for defining lifecycle phases.
217      * 
218      * @return ViewLifecyclePhaseBuilder
219      */
220     public static ViewLifecyclePhaseBuilder getViewLifecyclePhaseBuilder() {
221         return getService(VIEW_LIFECYCLE_PHASE_BUILDER);
222     }
223     
224     /**
225      * Returns the legacy data adapter for handling legacy KNS and KRAD data and metadata.
226      *
227      * @return the legacy data adapter
228      * @deprecated application code should never use this! Always use KRAD code directly.
229      */
230     @Deprecated
231     public static LegacyDataAdapter getLegacyDataAdapter() {
232         return getService(LEGACY_DATA_ADAPTER);
233     }
234 
235 }