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.fp.document.validation.impl;
017
018import org.kuali.ole.fp.document.ProcurementCardDocument;
019import org.kuali.ole.sys.OLEPropertyConstants;
020import org.kuali.ole.sys.businessobject.AccountingLine;
021import org.kuali.ole.sys.document.validation.GenericValidation;
022import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
023import org.kuali.rice.krad.util.GlobalVariables;
024import org.kuali.rice.krad.util.MessageMap;
025import org.kuali.rice.krad.util.ObjectUtils;
026
027/**
028 * Validates that an accounting line does not have a capital object object code 
029 */
030public class ProcurementCardAccountNumberValidation extends GenericValidation {
031    private AccountingLine accountingLineForValidation;
032
033    /**
034     * Validates that an accounting line does not have a capital object object code
035     * <strong>Expects an accounting line as the first a parameter</strong>
036     * @see org.kuali.ole.sys.document.validation.Validation#validate(java.lang.Object[])
037     */
038    public boolean validate(AttributedDocumentEvent event) {
039        ProcurementCardDocument pcDocument = (ProcurementCardDocument) event.getDocument();
040        AccountingLine accountingLine = getAccountingLineForValidation();
041        MessageMap errors = GlobalVariables.getMessageMap();
042
043        String errorKey = OLEPropertyConstants.ACCOUNT_NUMBER;
044        boolean accountNumberAllowed = true;
045
046        /* account exist and object exist done in super, check we have a valid object */
047        if (ObjectUtils.isNull(accountingLine.getAccount()) || ObjectUtils.isNull(accountingLine.getObjectCode())) {
048            return false;
049        }
050
051        return accountNumberAllowed;
052    }
053
054
055    /**
056     * Gets the accountingLineForValidation attribute. 
057     * @return Returns the accountingLineForValidation.
058     */
059    public AccountingLine getAccountingLineForValidation() {
060        return accountingLineForValidation;
061    }
062
063    /**
064     * Sets the accountingLineForValidation attribute value.
065     * @param accountingLineForValidation The accountingLineForValidation to set.
066     */
067    public void setAccountingLineForValidation(AccountingLine accountingLineForValidation) {
068        this.accountingLineForValidation = accountingLineForValidation;
069    }
070}