View Javadoc

1   /**
2    * Copyright 2004-2012 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.hr.time.overtime.daily.rule.service;
17  
18  import java.util.Map;
19  
20  import org.apache.commons.lang.StringUtils;
21  import org.kuali.hr.time.HrBusinessObject;
22  import org.kuali.hr.time.overtime.daily.rule.DailyOvertimeRule;
23  import org.kuali.hr.time.service.base.TkServiceLocator;
24  import org.kuali.hr.time.util.HrBusinessObjectMaintainableImpl;
25  import org.kuali.rice.kns.document.MaintenanceDocument;
26  import org.kuali.rice.krad.util.GlobalVariables;
27  
28  
29  public class DailyOvertimeRuleMaintainableImpl extends HrBusinessObjectMaintainableImpl {
30  
31  	/**
32  	 * 
33  	 */
34  	private static final long serialVersionUID = 1L;
35  
36  	@Override
37  	public void processAfterPost(MaintenanceDocument document,
38  			Map<String, String[]> parameters) {
39  		DailyOvertimeRule dailyOvertimeRule = (DailyOvertimeRule) document
40  				.getDocumentBusinessObject();
41  		dailyOvertimeRule.setUserPrincipalId(GlobalVariables.getUserSession()
42  				.getPrincipalId());
43  		super.processAfterPost(document, parameters);
44  	}
45  
46  	@Override
47  	public void processAfterEdit(MaintenanceDocument document,
48  			Map<String, String[]> parameters) {
49  		DailyOvertimeRule dailyOvertimeRule = (DailyOvertimeRule) document
50  				.getDocumentBusinessObject();
51  		dailyOvertimeRule.setUserPrincipalId(GlobalVariables.getUserSession()
52  				.getPrincipalId());
53  		super.processAfterEdit(document, parameters);
54  	}
55  	
56  	@SuppressWarnings("rawtypes")
57  	@Override
58  	public Map populateBusinessObject(Map<String, String> fieldValues,
59  			MaintenanceDocument maintenanceDocument, String methodToCall) {
60  		if(fieldValues.containsKey("workArea") && StringUtils.equals(fieldValues.get("workArea"),"%")){
61  			fieldValues.put("workArea", "-1");
62  		}
63  		return super.populateBusinessObject(fieldValues, maintenanceDocument,
64  				methodToCall);
65  	}
66  
67  	@Override
68  	public HrBusinessObject getObjectById(String id) {
69  		return TkServiceLocator.getDailyOvertimeRuleService().getDailyOvertimeRule(id);
70  	}
71      
72  
73  }