1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.timesheet;
17
18 import java.text.ParseException;
19 import java.text.SimpleDateFormat;
20 import java.util.Map;
21
22 import org.apache.commons.lang.StringUtils;
23 import org.kuali.rice.kns.document.MaintenanceDocument;
24 import org.kuali.rice.kns.maintenance.KualiMaintainableImpl;
25
26 public class TimeSheetInitiateMaintainableImpl extends KualiMaintainableImpl {
27
28
29
30 private static final long serialVersionUID = 1L;
31
32 @Override
33 public void saveBusinessObject() {
34 super.saveBusinessObject();
35 }
36
37
38 @Override
39 public Map populateBusinessObject(Map<String, String> fieldValues,
40 MaintenanceDocument maintenanceDocument, String methodToCall) {
41 if(StringUtils.equals(getMaintenanceAction(),"New")){
42 if (!fieldValues.containsKey("documentId") || StringUtils.isEmpty(fieldValues.get("documentId"))) {
43 TimeSheetInitiate tsi = (TimeSheetInitiate) this.getBusinessObject();
44 fieldValues.put("documentId", tsi.getDocumentId());
45 }
46 }
47 if (fieldValues.containsKey("endPeriodDateTime") && !StringUtils.isEmpty(fieldValues.get("endPeriodDateTime"))) {
48 try {
49 if(fieldValues.get("endPeriodDateTime").length() > 10) {
50 SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM d HH:mm:ss z yyyy");
51 java.util.Date aDate = dateFormat.parse(fieldValues.get("endPeriodDateTime"));
52 dateFormat = new SimpleDateFormat("MM/dd/yyyy");
53 fieldValues.put("endPeriodDateTime", dateFormat.format(aDate));
54 }
55 } catch (ParseException e) {
56
57 e.printStackTrace();
58 }
59 }
60 return super.populateBusinessObject(fieldValues, maintenanceDocument, methodToCall);
61 }
62
63 }