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.dept.lunch.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.dept.lunch.DeptLunchRule;
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  public class DeptLunchRuleMaintainableImpl extends HrBusinessObjectMaintainableImpl {
29  
30  	/**
31  	 * 
32  	 */
33  	private static final long serialVersionUID = 1L;
34  
35  	@Override
36  	public void processAfterPost(MaintenanceDocument document,
37  			Map<String, String[]> parameters) {
38  		DeptLunchRule deptLunchRule = (DeptLunchRule) document
39  				.getDocumentBusinessObject();
40  		deptLunchRule.setUserPrincipalId(GlobalVariables.getUserSession()
41  				.getPrincipalId());
42  		super.processAfterPost(document, parameters);
43  	}
44  
45  	@Override
46  	public void processAfterEdit(MaintenanceDocument document,
47  			Map<String, String[]> parameters) {
48  		DeptLunchRule deptLunchRule = (DeptLunchRule) document
49  				.getDocumentBusinessObject();
50  		deptLunchRule.setUserPrincipalId(GlobalVariables.getUserSession()
51  				.getPrincipalId());
52  		super.processAfterEdit(document, parameters);
53  	}
54  
55  	@Override
56  	public Map populateBusinessObject(Map<String, String> fieldValues,
57  			MaintenanceDocument maintenanceDocument, String methodToCall) {
58  		if (fieldValues.containsKey("workArea")
59  				&& StringUtils.equals(fieldValues.get("workArea"), "%")) {
60  			fieldValues.put("workArea", "-1");
61  		}
62  		if (fieldValues.containsKey("jobNumber")
63  				&& StringUtils.equals(fieldValues.get("jobNumber"), "%")) {
64  			fieldValues.put("jobNumber", "-1");
65  		}
66  		return super.populateBusinessObject(fieldValues, maintenanceDocument,
67  				methodToCall);
68  	}
69  
70  	@Override
71  	public HrBusinessObject getObjectById(String id) {
72  		return TkServiceLocator.getDepartmentLunchRuleService().getDepartmentLunchRule(id);
73  	}
74  }