1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.student.lum.lu.ui.course.keyvalues;
18
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.KewApiServiceLocator;
22 import org.kuali.rice.kew.api.document.WorkflowDocumentService;
23 import org.kuali.rice.krad.uif.control.UifKeyValuesFinderBase;
24 import org.kuali.rice.krad.uif.view.ViewModel;
25 import org.kuali.rice.krad.web.form.MaintenanceDocumentForm;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
28
29 import java.util.ArrayList;
30 import java.util.List;
31
32
33
34
35
36
37
38 public class PreviousNodeNamesValuesFinder extends UifKeyValuesFinderBase {
39
40 private static final Logger LOG = LoggerFactory.getLogger(PreviousNodeNamesValuesFinder.class);
41 private WorkflowDocumentService workflowDocumentService;
42
43 @Override
44 public List<KeyValue> getKeyValues(ViewModel model) {
45 List<KeyValue> nodeNames = new ArrayList<KeyValue>();
46 final MaintenanceDocumentForm form = (MaintenanceDocumentForm) model;
47
48 for (String nodeName : getWorkflowDocumentService().getPreviousRouteNodeNames(form.getDocument().getDocumentNumber())) {
49
50 nodeNames.add(new ConcreteKeyValue(nodeName, nodeName));
51 }
52 return nodeNames;
53 }
54
55 public WorkflowDocumentService getWorkflowDocumentService() {
56 if (workflowDocumentService == null) {
57 workflowDocumentService = KewApiServiceLocator.getWorkflowDocumentService();
58 }
59 if (null == workflowDocumentService) {
60 throw new RuntimeException("Workflow Document Service is unavailable");
61 }
62 return workflowDocumentService;
63 }
64
65 }