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.earncodesec.service;
17  
18  import org.kuali.hr.earncodesec.EarnCodeSecurity;
19  import org.kuali.hr.time.HrBusinessObject;
20  import org.kuali.hr.time.service.base.TkServiceLocator;
21  import org.kuali.hr.time.util.HrBusinessObjectMaintainableImpl;
22  import org.kuali.hr.time.util.ValidationUtils;
23  import org.kuali.rice.kns.document.MaintenanceDocument;
24  import org.kuali.rice.krad.util.GlobalVariables;
25  import org.kuali.rice.krad.util.KRADConstants;
26  
27  import java.util.Map;
28  
29  public class EarnCodeSecurityMaintainableImpl extends HrBusinessObjectMaintainableImpl {
30  	/**
31  	 * 
32  	 */
33  	private static final long serialVersionUID = 1L;
34  
35  	
36  	@Override
37      public void processAfterEdit( MaintenanceDocument document, Map<String,String[]> parameters ) {
38  		EarnCodeSecurity departmentEarnCode = (EarnCodeSecurity) this.getBusinessObject();
39  		int count = TkServiceLocator.getEarnCodeSecurityService().getNewerEarnCodeSecurityCount(departmentEarnCode.getEarnCode(), departmentEarnCode.getEffectiveDate());
40  		if(count > 0) {
41  			GlobalVariables.getMessageMap().putWarningWithoutFullErrorPath(
42  					KRADConstants.MAINTENANCE_NEW_MAINTAINABLE + "effectiveDate", 
43  					"deptEarncode.effectiveDate.newer.exists");
44  		}
45  		
46  		if(ValidationUtils.duplicateDeptEarnCodeExists(departmentEarnCode)) {
47  			GlobalVariables.getMessageMap().putWarningWithoutFullErrorPath(
48  					KRADConstants.MAINTENANCE_NEW_MAINTAINABLE + "dept", 
49  					"deptEarncode.duplicate.exists");
50  		}
51      }
52  
53  	@Override
54  	public HrBusinessObject getObjectById(String id) {
55  		return TkServiceLocator.getEarnCodeSecurityService().getEarnCodeSecurity(id);
56  	}
57  }