001/*
002 * Copyright 2008 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 */
016package org.kuali.ole.sys.document.validation.impl;
017
018import org.kuali.ole.sys.businessobject.AccountingLine;
019import org.kuali.ole.sys.document.service.AccountingLineRuleHelperService;
020import org.kuali.ole.sys.document.validation.GenericValidation;
021import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
022
023/**
024 * A validation which uses the AccountingLineRuleHelperService to validate the values on an accounting line
025 */
026public class AccountingLineDataDictionaryValidation extends GenericValidation {
027    protected AccountingLineRuleHelperService ruleHelperService; 
028    private AccountingLine accountingLineForValidation;
029
030    /**
031     * Okay, okay, so yeah, I could have handled this through a bunch of DD validations.  But it's late Thursday afternoon
032     * and someone has already written this code for me...
033     * <strong>Expects an accounting line as the first parameter</strong>
034     * @see org.kuali.ole.sys.document.validation.Validation#validate(java.lang.Object[])
035     */
036    public boolean validate(AttributedDocumentEvent event) {
037        return ruleHelperService.validateAccountingLine(accountingLineForValidation);
038    }
039
040    /**
041     * Sets the ruleHelperService attribute value.
042     * @param ruleHelperService The ruleHelperService to set.
043     */
044    public void setAccountingLineRuleHelperService(AccountingLineRuleHelperService ruleHelperService) {
045        this.ruleHelperService = ruleHelperService;
046    }
047
048    /**
049     * Gets the accountingLineForValidation attribute. 
050     * @return Returns the accountingLineForValidation.
051     */
052    public AccountingLine getAccountingLineForValidation() {
053        return accountingLineForValidation;
054    }
055
056    /**
057     * Sets the accountingLineForValidation attribute value.
058     * @param accountingLineForValidation The accountingLineForValidation to set.
059     */
060    public void setAccountingLineForValidation(AccountingLine accountingLineForValidation) {
061        this.accountingLineForValidation = accountingLineForValidation;
062    }
063}