1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.businessobject.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.ole.sys.OLEConstants;
24 import org.kuali.ole.sys.businessobject.KualiModuleBO;
25 import org.kuali.ole.sys.context.SpringContext;
26 import org.kuali.rice.core.api.config.property.ConfigurationService;
27 import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl;
28 import org.kuali.rice.kns.service.BusinessObjectDictionaryService;
29 import org.kuali.rice.krad.bo.BusinessObject;
30 import org.kuali.rice.krad.service.KualiModuleService;
31 import org.kuali.rice.krad.service.ModuleService;
32
33 public class ModuleLookupableHelperServiceImpl extends KualiLookupableHelperServiceImpl {
34
35 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(BatchJobStatusLookupableHelperServiceImpl.class);
36
37 private ConfigurationService configService;
38 private Map fieldConversions;
39
40 @Override
41 public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {
42 super.setBackLocation((String) fieldValues.get(OLEConstants.BACK_LOCATION));
43 super.setDocFormKey((String) fieldValues.get(OLEConstants.DOC_FORM_KEY));
44 List<ModuleService> modules = SpringContext.getBean(KualiModuleService.class).getInstalledModuleServices();
45 String codeValue = fieldValues.get("moduleCode");
46 String nameValue = fieldValues.get("moduleName");
47 List<KualiModuleBO> boModules = new ArrayList();
48 String tempNamespaceName;
49 for (ModuleService mod : modules) {
50 if (!StringUtils.isEmpty(nameValue) && !StringUtils.containsIgnoreCase(mod.getModuleConfiguration().getNamespaceCode(), nameValue)) {
51 continue;
52 }
53 tempNamespaceName = SpringContext.getBean(KualiModuleService.class).getNamespaceName(mod.getModuleConfiguration().getNamespaceCode());
54 if (!StringUtils.isEmpty(codeValue) && !StringUtils.containsIgnoreCase(tempNamespaceName, codeValue)) {
55 continue;
56 }
57 boModules.add(new KualiModuleBO(mod.getModuleConfiguration().getNamespaceCode(),
58 mod.getModuleConfiguration().getNamespaceCode(), tempNamespaceName));
59 }
60 return boModules;
61 }
62
63
64 public void setConfigService(ConfigurationService configService) {
65 this.configService = configService;
66 }
67
68 public List getReturnKeys() {
69 List returnKeys;
70
71 if (fieldConversions != null && !fieldConversions.isEmpty()) {
72 returnKeys = new ArrayList(fieldConversions.keySet());
73 }
74 else {
75 returnKeys = SpringContext.getBean(BusinessObjectDictionaryService.class).getLookupFieldNames(org.kuali.ole.sys.businessobject.KualiModuleBO.class);
76 }
77
78 return returnKeys;
79 }
80
81 public void setFieldConversions(Map fieldConversions) {
82 this.fieldConversions = fieldConversions;
83 }
84
85
86 }