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