1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.timecollection.rule.service;
17
18 import java.sql.Timestamp;
19 import java.util.Map;
20
21 import org.apache.commons.lang.StringUtils;
22 import org.kuali.hr.core.cache.CacheUtils;
23 import org.kuali.hr.time.HrBusinessObject;
24 import org.kuali.hr.time.collection.rule.TimeCollectionRule;
25 import org.kuali.hr.time.service.base.TkServiceLocator;
26 import org.kuali.hr.time.util.HrBusinessObjectMaintainableImpl;
27 import org.kuali.hr.time.util.TKUtils;
28 import org.kuali.rice.kns.document.MaintenanceDocument;
29 import org.kuali.rice.kns.maintenance.KualiMaintainableImpl;
30 import org.kuali.rice.krad.service.KRADServiceLocator;
31 import org.kuali.rice.krad.util.GlobalVariables;
32
33 public class TimeCollectionRuleMaintainableImpl extends HrBusinessObjectMaintainableImpl {
34
35
36
37 private static final long serialVersionUID = 1L;
38
39 @Override
40 public HrBusinessObject getObjectById(String id) {
41 return TkServiceLocator.getTimeCollectionRuleService().getTimeCollectionRule(id);
42 }
43
44 @Override
45 public void processAfterNew(MaintenanceDocument document, Map<String, String[]> parameters) {
46 super.processAfterNew(document, parameters);
47 }
48
49 @Override
50 public void processAfterPost(MaintenanceDocument document, Map<String, String[]> parameters) {
51 TimeCollectionRule timeCollectionRule = (TimeCollectionRule) document.getNewMaintainableObject().getBusinessObject();
52 timeCollectionRule.setUserPrincipalId(GlobalVariables.getUserSession().getPrincipalId());
53 super.processAfterPost(document, parameters);
54 }
55
56 @Override
57 public void processAfterEdit(MaintenanceDocument document, Map<String, String[]> parameters) {
58 TimeCollectionRule timeCollectionRule = (TimeCollectionRule) document.getNewMaintainableObject().getBusinessObject();
59 timeCollectionRule.setUserPrincipalId(GlobalVariables.getUserSession().getPrincipalId());
60 super.processAfterEdit(document, parameters);
61 }
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90 @Override
91 public Map populateBusinessObject(Map<String, String> fieldValues, MaintenanceDocument maintenanceDocument, String methodToCall) {
92 if (fieldValues.containsKey("workArea") && StringUtils.equals(fieldValues.get("workArea"), "%")) {
93 fieldValues.put("workArea", "-1");
94 }
95 if (fieldValues.containsKey("jobNumber") && StringUtils.equals(fieldValues.get("jobNumber"), "%")) {
96 fieldValues.put("jobNumber", "-1");
97 }
98 return super.populateBusinessObject(fieldValues, maintenanceDocument, methodToCall);
99 }
100 }