1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.assignment;
17
18 import java.util.ArrayList;
19 import java.util.List;
20 import java.util.Map;
21
22 import org.kuali.hr.time.service.base.TkServiceLocator;
23 import org.kuali.hr.time.timesheet.TimesheetDocument;
24 import org.kuali.hr.time.util.TKContext;
25 import org.kuali.hr.time.util.TkConstants;
26 import org.kuali.rice.core.api.util.ConcreteKeyValue;
27 import org.kuali.rice.core.api.util.KeyValue;
28 import org.kuali.rice.kns.web.struts.form.KualiForm;
29 import org.kuali.rice.kns.web.struts.form.KualiMaintenanceForm;
30 import org.kuali.rice.krad.keyvalues.KeyValuesBase;
31
32
33
34
35
36
37
38 public class AssignmentValuesFinder extends KeyValuesBase {
39
40 @Override
41
42
43
44
45
46
47 public List getKeyValues() {
48 List<KeyValue> labels = new ArrayList<KeyValue>();
49
50
51
52
53
54 String tdocId = TKContext.getCurrentTimesheetDocumentId();
55 if (tdocId == null) {
56 tdocId = TKContext.getHttpServletRequest().getParameter(TkConstants.TIMESHEET_DOCUMENT_ID_REQUEST_NAME);
57 }
58 if(tdocId == null){
59 KualiForm kualiForm = (KualiForm)TKContext.getHttpServletRequest().getAttribute("KualiForm");
60 if(kualiForm instanceof KualiMaintenanceForm){
61 tdocId = ((KualiMaintenanceForm)kualiForm).getDocId();
62 }
63 }
64
65
66 if (tdocId != null) {
67 TimesheetDocument tdoc = TkServiceLocator.getTimesheetService().getTimesheetDocument(tdocId);
68 Map<String,String> adMap = TkServiceLocator.getAssignmentService().getAssignmentDescriptions(tdoc, true);
69
70 for (Map.Entry entry : adMap.entrySet()) {
71 labels.add(new ConcreteKeyValue((String)entry.getKey(), (String)entry.getValue()));
72 }
73 }
74
75 return labels;
76 }
77 }