View Javadoc
1   /*
2    * Copyright 2008 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.web.struts;
17  
18  import org.apache.log4j.Logger;
19  import org.kuali.ole.module.purap.PurapAuthorizationConstants;
20  import org.kuali.ole.module.purap.PurapKeyConstants;
21  import org.kuali.ole.module.purap.document.BulkReceivingDocument;
22  import org.kuali.ole.sys.OLEConstants;
23  import org.kuali.ole.sys.document.web.struts.FinancialSystemTransactionalDocumentFormBase;
24  import org.kuali.rice.kns.web.ui.ExtraButton;
25  import org.kuali.rice.krad.util.KRADConstants;
26  import org.kuali.rice.krad.util.ObjectUtils;
27  
28  import javax.servlet.http.HttpServletRequest;
29  import java.util.List;
30  
31  public class BulkReceivingForm extends FinancialSystemTransactionalDocumentFormBase {
32  
33      protected static final Logger LOG = Logger.getLogger(BulkReceivingForm.class);
34      protected Integer purchaseOrderId;
35  
36      public BulkReceivingForm() {
37          super();
38      }
39  
40      @Override
41      protected String getDefaultDocumentTypeName() {
42          return "RCVB";
43      }
44  
45      public BulkReceivingDocument getBulkReceivingDocument() {
46          return (BulkReceivingDocument) getDocument();
47      }
48  
49      public void setBulkReceivingDocument(BulkReceivingDocument bulkReceivingDocument) {
50          setDocument(bulkReceivingDocument);
51      }
52  
53      public Integer getPurchaseOrderId() {
54          return purchaseOrderId;
55      }
56  
57      public void setPurchaseOrderId(Integer purchaseOrderId) {
58          this.purchaseOrderId = purchaseOrderId;
59      }
60  
61      /**
62       * Override the superclass method to add appropriate buttons for
63       * BulkReceivingDocument.
64       *
65       * @see org.kuali.rice.kns.web.struts.form.KualiForm#getExtraButtons()
66       *      <p/>
67       *      KRAD Conversion: Performs customization of extra buttons.
68       *      <p/>
69       *      No data dictionary is involved.
70       */
71      @Override
72      public List<ExtraButton> getExtraButtons() {
73          extraButtons.clear();
74  
75          String displayInitTab = (String) getEditingMode().get(PurapAuthorizationConstants.BulkReceivingEditMode.DISPLAY_INIT_TAB);
76          if (ObjectUtils.isNotNull(displayInitTab) && displayInitTab.equalsIgnoreCase("true")) {
77              extraButtons.add(createBulkReceivingContinueButton());
78              extraButtons.add(createClearInitFieldsButton());
79          } else if (getBulkReceivingDocument().getDocumentHeader().getWorkflowDocument().isEnroute() ||
80                  getBulkReceivingDocument().getDocumentHeader().getWorkflowDocument().isProcessed() ||
81                  getBulkReceivingDocument().getDocumentHeader().getWorkflowDocument().isFinal()) {
82              extraButtons.add(createPrintReceivingTicketButton());
83          }
84  
85          return extraButtons;
86      }
87  
88      /**
89       * KRAD Conversion: Performs customization of an extra button.
90       * <p/>
91       * No data dictionary is involved.
92       */
93      protected ExtraButton createBulkReceivingContinueButton() {
94          ExtraButton continueButton = new ExtraButton();
95          continueButton.setExtraButtonProperty("methodToCall.continueBulkReceiving");
96          continueButton.setExtraButtonSource("${" + OLEConstants.RICE_EXTERNALIZABLE_IMAGES_URL_KEY + "}buttonsmall_continue.gif");
97          continueButton.setExtraButtonAltText("Continue");
98          return continueButton;
99      }
100 
101     /**
102      * KRAD Conversion: Performs customization of an extra button.
103      * <p/>
104      * No data dictionary is involved.
105      */
106     protected ExtraButton createClearInitFieldsButton() {
107         ExtraButton clearButton = new ExtraButton();
108         clearButton.setExtraButtonProperty("methodToCall.clearInitFields");
109         clearButton.setExtraButtonSource("${" + OLEConstants.RICE_EXTERNALIZABLE_IMAGES_URL_KEY + "}buttonsmall_clear.gif");
110         clearButton.setExtraButtonAltText("Clear");
111         return clearButton;
112     }
113 
114     /**
115      * KRAD Conversion: Performs customization of an extra button.
116      * <p/>
117      * No data dictionary is involved.
118      */
119     protected ExtraButton createPrintReceivingTicketButton() {
120         ExtraButton printButton = new ExtraButton();
121         printButton.setExtraButtonProperty("methodToCall.printReceivingTicketPDF");
122         printButton.setExtraButtonSource("${" + OLEConstants.EXTERNALIZABLE_IMAGES_URL_KEY + "}buttonsmall_print.gif");
123         printButton.setExtraButtonAltText("Print");
124         return printButton;
125     }
126 
127     public String getGoodsDeliveredByLabel() {
128         return PurapKeyConstants.MESSAGE_BULK_RECEIVING_GOODSDELIVEREDBY_LABEL;
129     }
130 
131 
132     @Override
133     public boolean shouldMethodToCallParameterBeUsed(String methodToCallParameterName, String methodToCallParameterValue, HttpServletRequest request) {
134         if (KRADConstants.DISPATCH_REQUEST_PARAMETER.equals(methodToCallParameterName) && "printReceivingTicket".equals(methodToCallParameterValue)) {
135             return true;
136         }
137         return super.shouldMethodToCallParameterBeUsed(methodToCallParameterName, methodToCallParameterValue, request);
138     }
139 }