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 java.util.List;
019
020 import org.kuali.kfs.fp.document.PreEncumbranceDocument;
021 import org.kuali.kfs.sys.KFSKeyConstants;
022 import org.kuali.kfs.sys.document.validation.GenericValidation;
023 import org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent;
024 import org.kuali.rice.kns.util.GlobalVariables;
025
026 /**
027 * Validates that an accounting line does not have a capital object object code
028 */
029 public class PreEncumbranceRequiredAccountingLinesCountValidation extends GenericValidation {
030 private PreEncumbranceDocument accountingDocumentForValidation;
031
032 /**
033 * Validates that an accounting line does not have a capital object object code
034 * <strong>Expects an accounting line as the first a parameter</strong>
035 * @see org.kuali.kfs.sys.document.validation.Validation#validate(java.lang.Object[])
036 */
037 public boolean validate(AttributedDocumentEvent event) {
038 List sourceAccountingLineList = this.accountingDocumentForValidation.getSourceAccountingLines();
039 List targetAccountingLineList = this.accountingDocumentForValidation.getTargetAccountingLines();
040 if (sourceAccountingLineList.size() == 0 && targetAccountingLineList.size() == 0 ) {
041 GlobalVariables.getMessageMap().putError("sourceAccountingLines", KFSKeyConstants.ERROR_DOCUMENT_PRE_ENCUMBRANCE_SINGLE_SECTION_NO_ACCOUNTING_LINES, new String[] { null });
042 return false;
043 }
044
045 return true;
046 }
047
048 /**
049 * Gets the accountingDocumentForValidation attribute.
050 * @return Returns the accountingDocumentForValidation.
051 */
052 public PreEncumbranceDocument getAccountingDocumentForValidation() {
053 return accountingDocumentForValidation;
054 }
055
056 /**
057 * Sets the accountingDocumentForValidation attribute value.
058 * @param accountingDocumentForValidation The accountingDocumentForValidation to set.
059 */
060 public void setAccountingDocumentForValidation(PreEncumbranceDocument accountingDocumentForValidation) {
061 this.accountingDocumentForValidation = accountingDocumentForValidation;
062 }
063
064
065
066 }