1 /*
2 * Copyright 2008 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.ole.sys.document.validation;
17
18 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
19
20 /**
21 * An interface that represents a generic validation.
22 */
23 public abstract class GenericValidation extends ParameterizedValidation implements Validation {
24 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(GenericValidation.class);
25 private boolean quitOnFail = false;
26
27 /**
28 * This version of validate actually sets up the parameter list and then calls validate(Object[] parameters)
29 * @param event the event that requested this validation
30 * @return true if validation succeeded and the process required validation should continue, false otherwise
31 */
32 public boolean stageValidation(AttributedDocumentEvent event) {
33 if (LOG.isDebugEnabled()) {
34 LOG.debug("Staging validation for: "+getClass().getName()+" for event "+event.getClass().getName());
35 }
36 populateParametersFromEvent(event);
37 return validate(event);
38 }
39
40 /**
41 * Returns whether the validation process should quit on the failure of this validation
42 * @return true if the validation process should quit, false otherwise
43 */
44 public boolean shouldQuitOnFail() {
45 return quitOnFail;
46 }
47
48 /**
49 * Sets whether this rule should quit on fail or not
50 * @param quitOnFail true if the validation process should end if this rule fails, false otherwise
51 */
52 public void setQuitOnFail(boolean quitOnFail) {
53 this.quitOnFail = quitOnFail;
54 }
55 }