1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krms.impl.repository;
17
18 import org.apache.commons.collections.CollectionUtils;
19 import org.apache.cxf.common.util.StringUtils;
20 import org.kuali.rice.core.api.util.ConcreteKeyValue;
21 import org.kuali.rice.core.api.util.KeyValue;
22 import org.kuali.rice.core.impl.namespace.NamespaceBo;
23 import org.kuali.rice.krad.service.KRADServiceLocator;
24 import org.kuali.rice.krad.uif.control.UifKeyValuesFinderBase;
25 import org.kuali.rice.krad.uif.view.ViewModel;
26 import org.kuali.rice.krad.web.form.MaintenanceForm;
27 import org.kuali.rice.krms.impl.ui.AgendaEditor;
28
29 import java.util.ArrayList;
30 import java.util.Collection;
31 import java.util.Collections;
32 import java.util.HashMap;
33 import java.util.HashSet;
34 import java.util.List;
35 import java.util.Map;
36 import java.util.Set;
37
38
39
40
41 public class AgendaNamespaceValuesFinder extends UifKeyValuesFinderBase {
42
43 @Override
44 public List<KeyValue> getKeyValues(ViewModel model) {
45 List<KeyValue> keyValues = new ArrayList<KeyValue>();
46
47
48
49 Collection<ContextBo> contexts = KRADServiceLocator.getBusinessObjectService().findAll(ContextBo.class);
50
51 Collection<NamespaceBo> namespaceBos = KRADServiceLocator.getBusinessObjectService().findAll(NamespaceBo.class);
52 Map<String, String> namespaceCodeToName = new HashMap<String, String>();
53 if (!CollectionUtils.isEmpty(namespaceBos)) for (NamespaceBo namespaceBo : namespaceBos) {
54 namespaceCodeToName.put(namespaceBo.getCode(), namespaceBo.getName());
55 }
56
57 List<String> namespaceCodes = new ArrayList<String>();
58
59 if (!CollectionUtils.isEmpty(contexts)) for (ContextBo context : contexts) {
60 if (!namespaceCodes.contains(context.getNamespace())) {
61
62 namespaceCodes.add(context.getNamespace());
63 }
64 }
65
66 Collections.sort(namespaceCodes);
67
68 for (String namespaceCode : namespaceCodes) {
69 String namespaceName = namespaceCode;
70 if (namespaceCodeToName.containsKey(namespaceCode)) { namespaceName = namespaceCodeToName.get(namespaceCode); }
71 keyValues.add(new ConcreteKeyValue(namespaceCode, namespaceName));
72 }
73
74 return keyValues;
75 }
76 }