View Javadoc
1   /*
2    * Copyright 2008-2009 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.module.purap.document.authorization;
17  
18  import org.kuali.ole.module.purap.PurapAuthorizationConstants;
19  import org.kuali.ole.module.purap.document.BulkReceivingDocument;
20  import org.kuali.ole.module.purap.document.PurchasingAccountsPayableDocument;
21  import org.kuali.rice.krad.document.Document;
22  import org.kuali.rice.krad.util.ObjectUtils;
23  
24  import java.util.Set;
25  
26  
27  public class BulkReceivingDocumentPresentationController extends PurchasingAccountsPayableDocumentPresentationController {
28  
29      @Override
30      public boolean canSave(Document document) {
31          if (((PurchasingAccountsPayableDocument) document).getFinancialSystemDocumentHeader().getWorkflowDocument().isInitiated()) {
32              return false;
33          }
34          return super.canSave(document);
35      }
36  
37      @Override
38      public boolean canCancel(Document document) {
39          if (((PurchasingAccountsPayableDocument) document).getFinancialSystemDocumentHeader().getWorkflowDocument().isInitiated()) {
40              return false;
41          }
42          return super.canCancel(document);
43      }
44  
45      @Override
46      public boolean canClose(Document document) {
47          if (((PurchasingAccountsPayableDocument) document).getFinancialSystemDocumentHeader().getWorkflowDocument().isInitiated()) {
48              return false;
49          }
50          return super.canClose(document);
51      }
52  
53      @Override
54      public Set<String> getEditModes(Document document) {
55          Set<String> editModes = super.getEditModes(document);
56          BulkReceivingDocument bulkReceivingDocument = (BulkReceivingDocument) document;
57  
58          // if vendor has been selected from DB, certain vendor fields are not allowed to be edited
59          if (ObjectUtils.isNotNull(bulkReceivingDocument.getVendorHeaderGeneratedIdentifier())) {
60              editModes.add(PurapAuthorizationConstants.BulkReceivingEditMode.LOCK_VENDOR_ENTRY);
61          }
62  
63          if (((PurchasingAccountsPayableDocument) document).getFinancialSystemDocumentHeader().getWorkflowDocument().isInitiated()) {
64              editModes.add(PurapAuthorizationConstants.BulkReceivingEditMode.DISPLAY_INIT_TAB);
65          }
66  
67          return editModes;
68      }
69  }