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