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.authorization; 017 018 import java.util.Set; 019 020 import org.kuali.kfs.module.purap.PurapAuthorizationConstants; 021 import org.kuali.kfs.module.purap.document.BulkReceivingDocument; 022 import org.kuali.rice.kns.document.Document; 023 import org.kuali.rice.kns.util.ObjectUtils; 024 import org.kuali.rice.kns.workflow.service.KualiWorkflowDocument; 025 026 027 public class BulkReceivingDocumentPresentationController extends PurchasingAccountsPayableDocumentPresentationController { 028 029 @Override 030 protected boolean canSave(Document document) { 031 KualiWorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument(); 032 if (workflowDocument.stateIsInitiated()) { 033 return false; 034 } 035 return super.canSave(document); 036 } 037 038 @Override 039 protected boolean canCancel(Document document) { 040 KualiWorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument(); 041 if (workflowDocument.stateIsInitiated()) { 042 return false; 043 } 044 return super.canCancel(document); 045 } 046 047 @Override 048 protected boolean canClose(Document document) { 049 KualiWorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument(); 050 if (workflowDocument.stateIsInitiated()) { 051 return false; 052 } 053 return super.canClose(document); 054 } 055 056 @Override 057 public Set<String> getEditModes(Document document) { 058 Set<String> editModes = super.getEditModes(document); 059 KualiWorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument(); 060 BulkReceivingDocument bulkReceivingDocument = (BulkReceivingDocument)document; 061 062 // if vendor has been selected from DB, certain vendor fields are not allowed to be edited 063 if (ObjectUtils.isNotNull(bulkReceivingDocument.getVendorHeaderGeneratedIdentifier())) { 064 editModes.add(PurapAuthorizationConstants.BulkReceivingEditMode.LOCK_VENDOR_ENTRY); 065 } 066 067 if (workflowDocument.stateIsInitiated()) { 068 editModes.add(PurapAuthorizationConstants.BulkReceivingEditMode.DISPLAY_INIT_TAB); 069 } 070 071 return editModes; 072 } 073 074 }