1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krms.impl.ui;
17
18
19 import org.kuali.rice.core.api.util.ConcreteKeyValue;
20 import org.kuali.rice.core.api.util.KeyValue;
21 import org.kuali.rice.krad.keyvalues.KeyValuesBase;
22 import org.kuali.rice.krad.service.KRADServiceLocator;
23 import org.kuali.rice.krms.impl.repository.ContextValidTermBo;
24 import org.kuali.rice.krms.impl.repository.TermBo;
25
26 import java.util.ArrayList;
27 import java.util.Collection;
28 import java.util.Collections;
29 import java.util.HashMap;
30 import java.util.Map;
31 import java.util.List;
32
33
34
35
36
37
38 public class ValidTermsValuesFinder extends KeyValuesBase {
39
40 @Override
41 public List<KeyValue> getKeyValues() {
42 List<KeyValue> keyValues = new ArrayList<KeyValue>();
43
44 Collection<ContextValidTermBo> contextValidTerms = KRADServiceLocator.getBusinessObjectService().findAll(ContextValidTermBo.class);
45 List<String> termSpecIds = new ArrayList();
46 for (ContextValidTermBo validTerm : contextValidTerms) {
47 termSpecIds.add(validTerm.getTermSpecificationId());
48 }
49 Map<String,Object> criteria = new HashMap<String,Object>();
50 criteria.put("term_spec_id", termSpecIds);
51 Collection<TermBo> terms = KRADServiceLocator.getBusinessObjectService().findMatching(TermBo.class, criteria);
52
53 for (TermBo term : terms) {
54 keyValues.add(new ConcreteKeyValue(term.getId(), term.getDescription()));
55 }
56 return keyValues;
57 }
58 }