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.module.ar.document.validation.impl;
017
018 import static org.kuali.kfs.sys.document.validation.impl.AccountingDocumentRuleBaseConstants.ERROR_PATH.DOCUMENT_ERROR_PREFIX;
019
020 import java.util.List;
021
022 import org.apache.commons.lang.StringUtils;
023 import org.kuali.kfs.module.ar.ArConstants;
024 import org.kuali.kfs.module.ar.ArKeyConstants;
025 import org.kuali.kfs.module.ar.ArPropertyConstants;
026 import org.kuali.kfs.module.ar.document.CashControlDocument;
027 import org.kuali.kfs.sys.KFSConstants;
028 import org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry;
029 import org.kuali.kfs.sys.context.SpringContext;
030 import org.kuali.kfs.sys.document.validation.GenericValidation;
031 import org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent;
032 import org.kuali.rice.kns.service.ParameterService;
033 import org.kuali.rice.kns.util.GlobalVariables;
034 import org.kuali.rice.kns.util.ObjectUtils;
035
036 public class CashControlCheckGLPEsNotGeneratedValidation extends GenericValidation {
037
038 private CashControlDocument cashControlDocument;
039
040 public boolean validate(AttributedDocumentEvent event) {
041
042 boolean success = true;
043 List<GeneralLedgerPendingEntry> glpes = cashControlDocument.getGeneralLedgerPendingEntries();
044
045 if (glpes != null && !glpes.isEmpty()) {
046 success = false;
047 GlobalVariables.getMessageMap().putError(KFSConstants.GENERAL_LEDGER_PENDING_ENTRIES_TAB_ERRORS, ArKeyConstants.ERROR_DELETE_ADD_APP_DOCS_NOT_ALLOWED_AFTER_GLPES_GEN);
048 }
049 return success;
050
051 }
052
053 public CashControlDocument getCashControlDocument() {
054 return cashControlDocument;
055 }
056
057 public void setCashControlDocument(CashControlDocument cashControlDocument) {
058 this.cashControlDocument = cashControlDocument;
059 }
060
061 }