01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.kfs.lookup;
17:
18: import java.util.ArrayList;
19: import java.util.List;
20: import java.util.Map;
21:
22: import org.apache.commons.lang.StringUtils;
23: import org.kuali.core.KualiModule;
24: import org.kuali.core.bo.BusinessObject;
25: import org.kuali.core.lookup.KualiLookupableHelperServiceImpl;
26: import org.kuali.core.service.BusinessObjectDictionaryService;
27: import org.kuali.core.service.KualiConfigurationService;
28: import org.kuali.core.service.KualiModuleService;
29: import org.kuali.kfs.KFSConstants;
30: import org.kuali.kfs.bo.KualiModuleBO;
31: import org.kuali.kfs.context.SpringContext;
32:
33: public class ModuleLookupableHelperServiceImpl extends
34: KualiLookupableHelperServiceImpl {
35:
36: private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
37: .getLogger(BatchJobStatusLookupableHelperServiceImpl.class);
38:
39: private KualiConfigurationService configService;
40: private Map fieldConversions;
41:
42: @Override
43: public List<? extends BusinessObject> getSearchResults(
44: Map<String, String> fieldValues) {
45: super .setBackLocation((String) fieldValues
46: .get(KFSConstants.BACK_LOCATION));
47: super .setDocFormKey((String) fieldValues
48: .get(KFSConstants.DOC_FORM_KEY));
49: List<KualiModule> modules = SpringContext.getBean(
50: KualiModuleService.class).getInstalledModules();
51: String codeValue = fieldValues.get("moduleCode");
52: String nameValue = fieldValues.get("moduleName");
53: List<KualiModuleBO> boModules = new ArrayList();
54: for (KualiModule mod : modules) {
55: if (!StringUtils.isEmpty(nameValue)
56: && !StringUtils.containsIgnoreCase(mod
57: .getModuleName(), nameValue)) {
58: continue;
59: }
60: if (!StringUtils.isEmpty(codeValue)
61: && !StringUtils.containsIgnoreCase(mod
62: .getModuleCode(), codeValue)) {
63: continue;
64: }
65: boModules.add(new KualiModuleBO(mod.getModuleCode(), mod
66: .getModuleId(), mod.getModuleName()));
67: }
68: return boModules;
69: }
70:
71: public void setConfigService(KualiConfigurationService configService) {
72: this .configService = configService;
73: }
74:
75: public List getReturnKeys() {
76: List returnKeys;
77:
78: if (fieldConversions != null && !fieldConversions.isEmpty()) {
79: returnKeys = new ArrayList(fieldConversions.keySet());
80: } else {
81: returnKeys = SpringContext.getBean(
82: BusinessObjectDictionaryService.class)
83: .getLookupFieldNames(
84: org.kuali.kfs.bo.KualiModuleBO.class);
85: }
86:
87: return returnKeys;
88: }
89:
90: public void setFieldConversions(Map fieldConversions) {
91: this.fieldConversions = fieldConversions;
92: }
93:
94: }
|