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.hr.kpme.tklm.time.rules.validation;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.kuali.kpme.core.bo.HrKeyedBusinessObject;
20  import org.kuali.kpme.core.util.ValidationUtils;
21  import org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase;
22  
23  public abstract class TkKeyedBusinessObjectValidation extends MaintenanceDocumentRuleBase {
24  	
25  	private static final String GROUP_KEY_CODE_PARAM_SUFFIX = "'";
26  	private static final String GROUP_KEY_CODE_PARAM_PREFIX = "Group Key Code '";
27  	private static final String ERROR_EXISTENCE = "error.existence";
28  	private static final String GROUP_KEY_CODE_PROP_NAME = "dataObject.groupKeyCode";
29  
30  	protected boolean validateGroupKeyCode(HrKeyedBusinessObject keyedBo) {
31  		if (StringUtils.isNotEmpty(keyedBo.getGroupKeyCode())) {
32  			if(!ValidationUtils.validateGroupKey(keyedBo.getGroupKeyCode(), keyedBo.getEffectiveLocalDate())){
33  				this.putFieldError(GROUP_KEY_CODE_PROP_NAME, ERROR_EXISTENCE, GROUP_KEY_CODE_PARAM_PREFIX + keyedBo.getGroupKeyCode() + GROUP_KEY_CODE_PARAM_SUFFIX);
34  				return false;
35  			}
36  		}
37  		return true;
38  	}
39  
40  }