1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.impl.document.search;
17
18 import org.kuali.rice.core.api.util.ConcreteKeyValue;
19 import org.kuali.rice.core.api.util.KeyValue;
20 import org.kuali.rice.kew.api.document.DocumentStatus;
21 import org.kuali.rice.kew.api.document.DocumentStatusCategory;
22 import org.kuali.rice.krad.keyvalues.KeyValuesBase;
23
24 import java.util.ArrayList;
25 import java.util.List;
26 import java.util.Set;
27
28
29
30
31
32
33
34 public class DocumentStatusValuesFinder extends KeyValuesBase {
35
36 private static final String CATEGORY_CODE_PREFIX = "category:";
37
38 @Override
39 public List<KeyValue> getKeyValues() {
40 List<KeyValue> statuses = new ArrayList<KeyValue>();
41 addCategory(statuses, DocumentStatusCategory.PENDING);
42 addCategory(statuses, DocumentStatusCategory.SUCCESSFUL);
43 addCategory(statuses, DocumentStatusCategory.UNSUCCESSFUL);
44 return statuses;
45 }
46
47 private void addCategory(List<KeyValue> statuses, DocumentStatusCategory category) {
48 statuses.add(new ConcreteKeyValue(CATEGORY_CODE_PREFIX + category.getCode(), category.getLabel() + " Statuses"));
49 Set<DocumentStatus> documentStatuses = DocumentStatus.getStatusesForCategory(category);
50 for (DocumentStatus documentStatus : documentStatuses) {
51 statuses.add(new ConcreteKeyValue(documentStatus.getCode(), "- " + documentStatus.getLabel()));
52 }
53 }
54 }