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 | 0 | public class AgendaNamespaceValuesFinder extends UifKeyValuesFinderBase { |
42 | |
|
43 | |
@Override |
44 | |
public List<KeyValue> getKeyValues(ViewModel model) { |
45 | 0 | List<KeyValue> keyValues = new ArrayList<KeyValue>(); |
46 | |
|
47 | |
|
48 | |
|
49 | 0 | Collection<ContextBo> contexts = KRADServiceLocator.getBusinessObjectService().findAll(ContextBo.class); |
50 | |
|
51 | 0 | Collection<NamespaceBo> namespaceBos = KRADServiceLocator.getBusinessObjectService().findAll(NamespaceBo.class); |
52 | 0 | Map<String, String> namespaceCodeToName = new HashMap<String, String>(); |
53 | 0 | if (!CollectionUtils.isEmpty(namespaceBos)) for (NamespaceBo namespaceBo : namespaceBos) { |
54 | 0 | namespaceCodeToName.put(namespaceBo.getCode(), namespaceBo.getName()); |
55 | |
} |
56 | |
|
57 | 0 | List<String> namespaceCodes = new ArrayList<String>(); |
58 | |
|
59 | 0 | if (!CollectionUtils.isEmpty(contexts)) for (ContextBo context : contexts) { |
60 | 0 | if (!namespaceCodes.contains(context.getNamespace())) { |
61 | |
|
62 | 0 | namespaceCodes.add(context.getNamespace()); |
63 | |
} |
64 | |
} |
65 | |
|
66 | 0 | Collections.sort(namespaceCodes); |
67 | |
|
68 | 0 | for (String namespaceCode : namespaceCodes) { |
69 | 0 | String namespaceName = namespaceCode; |
70 | 0 | if (namespaceCodeToName.containsKey(namespaceCode)) { namespaceName = namespaceCodeToName.get(namespaceCode); } |
71 | 0 | keyValues.add(new ConcreteKeyValue(namespaceCode, namespaceName)); |
72 | 0 | } |
73 | |
|
74 | 0 | return keyValues; |
75 | |
} |
76 | |
} |