View Javadoc
1   /**
2    * Copyright 2004-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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  }