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.fp.document.validation.impl;
017
018 import org.kuali.kfs.fp.document.ProcurementCardDocument;
019 import org.kuali.kfs.sys.KFSPropertyConstants;
020 import org.kuali.kfs.sys.businessobject.AccountingLine;
021 import org.kuali.kfs.sys.document.validation.GenericValidation;
022 import org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent;
023 import org.kuali.rice.kns.util.GlobalVariables;
024 import org.kuali.rice.kns.util.MessageMap;
025 import org.kuali.rice.kns.util.ObjectUtils;
026
027 /**
028 * Validates that an accounting line does not have a capital object object code
029 */
030 public 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.kfs.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 = KFSPropertyConstants.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 }