1 package org.kuali.ole.select.keyvalue;
2
3 import org.kuali.ole.select.document.OLEEResourceRecordDocument;
4 import org.kuali.ole.sys.context.SpringContext;
5 import org.kuali.rice.core.api.util.ConcreteKeyValue;
6 import org.kuali.rice.core.api.util.KeyValue;
7 import org.kuali.rice.kew.api.WorkflowDocument;
8 import org.kuali.rice.kew.api.exception.WorkflowException;
9 import org.kuali.rice.kim.api.identity.Person;
10 import org.kuali.rice.kim.api.identity.PersonService;
11 import org.kuali.rice.krad.keyvalues.KeyValuesBase;
12 import org.kuali.rice.krad.service.KRADServiceLocator;
13 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
14 import org.kuali.rice.krad.util.GlobalVariables;
15
16 import java.util.ArrayList;
17 import java.util.Collection;
18 import java.util.List;
19
20
21
22
23 public class OLEEResourceRecordDocumentKeyValues extends KeyValuesBase {
24
25 @Override
26 public List<KeyValue> getKeyValues() {
27 List<KeyValue> keyValues = new ArrayList<KeyValue>();
28 Person principalPerson = SpringContext.getBean(PersonService.class).getPerson(GlobalVariables.getUserSession().getPerson().getPrincipalId());
29 Collection<OLEEResourceRecordDocument> oleeResourceRecordDocuments = (List) KRADServiceLocator.getBusinessObjectService().findAll(OLEEResourceRecordDocument.class);
30 keyValues.add(new ConcreteKeyValue("", ""));
31 for (OLEEResourceRecordDocument oleeResourceRecordDocument : oleeResourceRecordDocuments) {
32 try {
33 WorkflowDocument workflowDocument = KRADServiceLocatorWeb.getWorkflowDocumentService().loadWorkflowDocument(oleeResourceRecordDocument.getDocumentNumber(), principalPerson);
34 if (workflowDocument != null) {
35 keyValues.add(new ConcreteKeyValue(oleeResourceRecordDocument.getOleERSIdentifier(), oleeResourceRecordDocument.getTitle()));
36 }
37 } catch (WorkflowException e) {
38 e.printStackTrace();
39 }
40 }
41 return keyValues;
42 }
43 }
44