1 | |
package org.kuali.student.core.enumerationmanagement.bo.options; |
2 | |
|
3 | |
import java.util.ArrayList; |
4 | |
import java.util.Collection; |
5 | |
import java.util.HashMap; |
6 | |
import java.util.Iterator; |
7 | |
import java.util.List; |
8 | |
import java.util.Map; |
9 | |
|
10 | |
import org.kuali.rice.core.api.util.ConcreteKeyValue; |
11 | |
import org.kuali.rice.core.api.util.KeyValue; |
12 | |
import org.kuali.rice.krad.keyvalues.KeyValuesBase; |
13 | |
import org.kuali.rice.krad.service.BusinessObjectService; |
14 | |
import org.kuali.rice.krad.service.KRADServiceLocator; |
15 | |
import org.kuali.student.core.enumerationmanagement.bo.EnumeratedValue; |
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | 0 | public abstract class EnumerationCodeValuesFinderBase extends KeyValuesBase { |
24 | |
|
25 | |
@SuppressWarnings("unchecked") |
26 | |
@Override |
27 | |
public List<KeyValue> getKeyValues() { |
28 | 0 | List<KeyValue> labels = new ArrayList<KeyValue>(); |
29 | 0 | Map<String, Object> criteria = new HashMap<String,Object>(); |
30 | |
|
31 | 0 | criteria.put(EnumeratedValue.ENUMERATION_KEY, getEnumerationKey()); |
32 | 0 | BusinessObjectService boService = KRADServiceLocator.getBusinessObjectService(); |
33 | 0 | Collection<EnumeratedValue> values = boService.findMatching(EnumeratedValue.class, criteria); |
34 | |
|
35 | 0 | Iterator<EnumeratedValue> iterator = values.iterator(); |
36 | 0 | while(iterator.hasNext()) { |
37 | 0 | EnumeratedValue value = iterator.next(); |
38 | 0 | labels.add(new ConcreteKeyValue(value.getCode(), value.getValue())); |
39 | 0 | } |
40 | |
|
41 | 0 | return labels; |
42 | |
} |
43 | |
|
44 | |
public abstract String getEnumerationKey(); |
45 | |
|
46 | |
} |