View Javadoc

1   /**
2    * Copyright 2005-2012 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.impl;
17  
18  import org.kuali.rice.core.api.util.ClassLoaderUtils;
19  import org.kuali.rice.krad.service.KualiModuleService;
20  import org.kuali.rice.krad.service.ModuleService;
21  
22  import java.util.List;
23  
24  /**
25   * Module service that adds support for the kfs Step class.
26   */
27  public class KFSModuleServiceImpl implements KualiModuleService {
28  
29      //inject with the rice service
30      private KualiModuleService kualiModuleService;
31  
32      private static final Class<?> STEP_CLASS;
33      static {
34          Class<?> clazz;
35          try {
36              ClassLoader cl = ClassLoaderUtils.getDefaultClassLoader();
37              //once this is pushed into kfs should not use class token directly
38              clazz =  Class.forName("org.kuali.kfs.sys.batch.Step", true, cl);
39          } catch (Exception e) {
40              throw new RuntimeException(e);
41          }
42          STEP_CLASS = clazz;
43      }
44  
45  
46      @Override
47      public List<ModuleService> getInstalledModuleServices() {
48          return kualiModuleService.getInstalledModuleServices();
49      }
50  
51      @Override
52      public ModuleService getModuleService(String moduleId) {
53          return kualiModuleService.getModuleService(moduleId);
54      }
55  
56      @Override
57      public ModuleService getModuleServiceByNamespaceCode(String namespaceCode) {
58          return kualiModuleService.getModuleServiceByNamespaceCode(namespaceCode);
59      }
60  
61      @Override
62      public boolean isModuleServiceInstalled(String namespaceCode) {
63          return kualiModuleService.isModuleServiceInstalled(namespaceCode);
64      }
65  
66      @Override
67      public ModuleService getResponsibleModuleService(Class boClass) {
68          return kualiModuleService.getResponsibleModuleService(boClass);
69      }
70  
71      @Override
72      public ModuleService getResponsibleModuleServiceForJob(String jobName) {
73          return kualiModuleService.getResponsibleModuleServiceForJob(jobName);
74      }
75  
76      @Override
77      public void setInstalledModuleServices(List<ModuleService> moduleServices) {
78          kualiModuleService.setInstalledModuleServices(moduleServices);
79      }
80  
81      @Override
82      public List<String> getDataDictionaryPackages() {
83          return kualiModuleService.getDataDictionaryPackages();
84      }
85  
86      @Override
87      public String getNamespaceName(String namespaceCode) {
88          return kualiModuleService.getNamespaceName(namespaceCode);
89      }
90  
91      @Override
92      public String getNamespaceCode(Class<?> documentOrStepClass) {
93          if (STEP_CLASS != null && STEP_CLASS.isAssignableFrom(documentOrStepClass)) {
94              return documentOrStepClass.getSimpleName();
95          }
96  
97          return kualiModuleService.getNamespaceCode(documentOrStepClass);
98      }
99  
100     @Override
101     public String getComponentCode(Class<?> documentOrStepClass) {
102         return kualiModuleService.getComponentCode(documentOrStepClass);
103     }
104 
105     public void setKualiModuleService(KualiModuleService kualiModuleService) {
106         this.kualiModuleService = kualiModuleService;
107     }
108 }