1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.tklm.time.rules.timecollection.web;
17
18 import java.util.Map;
19
20 import org.apache.commons.lang.StringUtils;
21 import org.kuali.kpme.core.bo.HrBusinessObject;
22 import org.kuali.kpme.core.bo.HrBusinessObjectMaintainableImpl;
23 import org.kuali.kpme.tklm.time.rules.timecollection.TimeCollectionRule;
24 import org.kuali.kpme.tklm.time.service.TkServiceLocator;
25 import org.kuali.rice.kns.document.MaintenanceDocument;
26 import org.kuali.rice.krad.util.GlobalVariables;
27
28 public class TimeCollectionRuleMaintainableImpl extends HrBusinessObjectMaintainableImpl {
29
30
31
32 private static final long serialVersionUID = 1L;
33
34 @Override
35 public HrBusinessObject getObjectById(String id) {
36 return TkServiceLocator.getTimeCollectionRuleService().getTimeCollectionRule(id);
37 }
38
39 @Override
40 public void processAfterNew(MaintenanceDocument document, Map<String, String[]> parameters) {
41 super.processAfterNew(document, parameters);
42 }
43
44 @Override
45 public void processAfterPost(MaintenanceDocument document, Map<String, String[]> parameters) {
46 TimeCollectionRule timeCollectionRule = (TimeCollectionRule) document.getNewMaintainableObject().getBusinessObject();
47 timeCollectionRule.setUserPrincipalId(GlobalVariables.getUserSession().getPrincipalId());
48 super.processAfterPost(document, parameters);
49 }
50
51 @Override
52 public void processAfterEdit(MaintenanceDocument document, Map<String, String[]> parameters) {
53 TimeCollectionRule timeCollectionRule = (TimeCollectionRule) document.getNewMaintainableObject().getBusinessObject();
54 timeCollectionRule.setUserPrincipalId(GlobalVariables.getUserSession().getPrincipalId());
55 super.processAfterEdit(document, parameters);
56 }
57
58
59
60 @Override
61 public Map populateBusinessObject(Map<String, String> fieldValues, MaintenanceDocument maintenanceDocument, String methodToCall) {
62 if (fieldValues.containsKey("workArea") && StringUtils.equals(fieldValues.get("workArea"), "%")) {
63 fieldValues.put("workArea", "-1");
64 }
65 if (fieldValues.containsKey("jobNumber") && StringUtils.equals(fieldValues.get("jobNumber"), "%")) {
66 fieldValues.put("jobNumber", "-1");
67 }
68 return super.populateBusinessObject(fieldValues, maintenanceDocument, methodToCall);
69 }
70 }