View Javadoc

1   /**
2    * Copyright 2004-2013 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.core.calendar.validation;
17  
18  import java.sql.Time;
19  
20  import org.apache.commons.lang.StringUtils;
21  import org.kuali.kpme.core.calendar.Calendar;
22  import org.kuali.rice.kns.document.MaintenanceDocument;
23  import org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase;
24  
25  public class CalendarRule extends MaintenanceDocumentRuleBase {
26  	@Override
27  	protected boolean processCustomRouteDocumentBusinessRules(
28  			MaintenanceDocument document) {
29  		boolean valid = true;
30  
31  		Calendar calendar = (Calendar) this.getNewBo();
32  		if (StringUtils.equals(calendar.getCalendarTypes(), "Pay")){
33  			valid = validateFLSABeginDay(calendar.getFlsaBeginDay());
34  			valid = validateFLSABeginTime(calendar.getFlsaBeginTime());
35  		}
36  		return valid;
37  	}
38  
39  	boolean validateFLSABeginDay(String flsaBeginDay) {
40  		boolean valid = true;
41  		if (StringUtils.isEmpty(flsaBeginDay)) {
42  			this.putFieldError("flsaBeginDay", "error.required",
43  					"FLSA Begin Day");
44  			valid = false;
45  		}
46  		return valid;
47  	}
48  	boolean validateFLSABeginTime(Time flsaBeginTime) {
49  		boolean valid = true;
50  		if (flsaBeginTime == null) {
51  			this.putFieldError("flsaBeginTime", "error.required",
52  					"FLSA Begin Time");
53  			valid = false;
54  		}
55  		return valid;
56  	}
57  
58  }