001/**
002 * Copyright 2005-2015 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.krad.service.impl;
017
018import org.kuali.rice.core.api.util.ClassLoaderUtils;
019import org.kuali.rice.krad.service.KualiModuleService;
020import org.kuali.rice.krad.service.ModuleService;
021
022import java.util.List;
023
024/**
025 * Module service that adds support for the kfs Step class.
026 */
027public class KFSModuleServiceImpl implements KualiModuleService {
028
029    //inject with the rice service
030    private KualiModuleService kualiModuleService;
031
032    private static final Class<?> STEP_CLASS;
033    static {
034        Class<?> clazz;
035        try {
036            ClassLoader cl = ClassLoaderUtils.getDefaultClassLoader();
037            //once this is pushed into kfs should not use class token directly
038            clazz =  Class.forName("org.kuali.kfs.sys.batch.Step", true, cl);
039        } catch (Exception e) {
040            throw new RuntimeException(e);
041        }
042        STEP_CLASS = clazz;
043    }
044
045
046    @Override
047    public List<ModuleService> getInstalledModuleServices() {
048        return kualiModuleService.getInstalledModuleServices();
049    }
050
051    @Override
052    public ModuleService getModuleService(String moduleId) {
053        return kualiModuleService.getModuleService(moduleId);
054    }
055
056    @Override
057    public ModuleService getModuleServiceByNamespaceCode(String namespaceCode) {
058        return kualiModuleService.getModuleServiceByNamespaceCode(namespaceCode);
059    }
060
061    @Override
062    public boolean isModuleServiceInstalled(String namespaceCode) {
063        return kualiModuleService.isModuleServiceInstalled(namespaceCode);
064    }
065
066    @Override
067    public ModuleService getResponsibleModuleService(Class boClass) {
068        return kualiModuleService.getResponsibleModuleService(boClass);
069    }
070
071    @Override
072    public ModuleService getResponsibleModuleServiceForJob(String jobName) {
073        return kualiModuleService.getResponsibleModuleServiceForJob(jobName);
074    }
075
076    @Override
077    public void setInstalledModuleServices(List<ModuleService> moduleServices) {
078        kualiModuleService.setInstalledModuleServices(moduleServices);
079    }
080
081    @Override
082    public List<String> getDataDictionaryPackages() {
083        return kualiModuleService.getDataDictionaryPackages();
084    }
085
086    @Override
087    public String getNamespaceName(String namespaceCode) {
088        return kualiModuleService.getNamespaceName(namespaceCode);
089    }
090
091    @Override
092    public String getNamespaceCode(Class<?> documentOrStepClass) {
093        if (STEP_CLASS != null && STEP_CLASS.isAssignableFrom(documentOrStepClass)) {
094            return documentOrStepClass.getSimpleName();
095        }
096
097        return kualiModuleService.getNamespaceCode(documentOrStepClass);
098    }
099
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}