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.purap.document.validation.impl; 017 018 import java.util.Arrays; 019 import java.util.List; 020 021 import org.kuali.kfs.module.purap.PurapWorkflowConstants.PurchaseOrderDocument.NodeDetailEnum; 022 import org.kuali.kfs.module.purap.document.PurchaseOrderDocument; 023 import org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent; 024 import org.kuali.kfs.sys.document.validation.impl.AccountingLineAccessibleValidation; 025 import org.kuali.rice.kew.exception.WorkflowException; 026 import org.kuali.rice.kns.workflow.service.KualiWorkflowDocument; 027 028 /** 029 * A validation that checks whether the given accounting line is accessible to the given user or not 030 */ 031 public class PurchaseOrderAccountingLineAccessibleValidation extends PurchasingAccountsPayableAccountingLineAccessibleValidation { 032 033 /** 034 * Validates that the given accounting line is accessible for editing by the current user. 035 * <strong>This method expects a document as the first parameter and an accounting line as the second</strong> 036 * @see org.kuali.kfs.sys.document.validation.Validation#validate(java.lang.Object[]) 037 */ 038 public boolean validate(AttributedDocumentEvent event) { 039 PurchaseOrderDocument financialDocument = (PurchaseOrderDocument)event.getDocument(); 040 KualiWorkflowDocument workflowDocument = financialDocument.getDocumentHeader().getWorkflowDocument(); 041 List currentRouteLevels = getCurrentRouteLevels(workflowDocument); 042 043 if (financialDocument.isDocumentStoppedInRouteNode(NodeDetailEnum.INTERNAL_PURCHASING_REVIEW)) { 044 // DO NOTHING: do not check that user owns acct lines; at this level, approvers can edit all detail on PO 045 return true; 046 } 047 else { 048 049 return super.validate(event); 050 } 051 } 052 053 } 054