001 /* 002 * Copyright 2011 The Kuali Foundation. 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.kfs.sys.document.validation; 017 018 import org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent; 019 020 /** 021 * An interface that represents a generic validation. 022 */ 023 public abstract class GenericValidation extends ParameterizedValidation implements Validation { 024 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(GenericValidation.class); 025 private boolean quitOnFail = false; 026 027 /** 028 * This version of validate actually sets up the parameter list and then calls validate(Object[] parameters) 029 * @param event the event that requested this validation 030 * @return true if validation succeeded and the process required validation should continue, false otherwise 031 */ 032 public boolean stageValidation(AttributedDocumentEvent event) { 033 if (LOG.isDebugEnabled()) { 034 LOG.debug("Staging validation for: "+getClass().getName()+" for event "+event.getClass().getName()); 035 } 036 populateParametersFromEvent(event); 037 return validate(event); 038 } 039 040 /** 041 * Returns whether the validation process should quit on the failure of this validation 042 * @return true if the validation process should quit, false otherwise 043 */ 044 public boolean shouldQuitOnFail() { 045 return quitOnFail; 046 } 047 048 /** 049 * Sets whether this rule should quit on fail or not 050 * @param quitOnFail true if the validation process should end if this rule fails, false otherwise 051 */ 052 public void setQuitOnFail(boolean quitOnFail) { 053 this.quitOnFail = quitOnFail; 054 } 055 }