View Javadoc
1   /*
2    * Copyright 2006 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.commons.lang.StringUtils;
19  import org.kuali.ole.integration.purap.CapitalAssetLocation;
20  import org.kuali.ole.module.purap.PurapAuthorizationConstants;
21  import org.kuali.ole.module.purap.PurapConstants;
22  import org.kuali.ole.module.purap.PurapConstants.PaymentRequestStatuses;
23  import org.kuali.ole.module.purap.PurapConstants.PurchaseOrderStatuses;
24  import org.kuali.ole.module.purap.PurapPropertyConstants;
25  import org.kuali.ole.module.purap.businessobject.*;
26  import org.kuali.ole.module.purap.document.PaymentRequestDocument;
27  import org.kuali.ole.module.purap.document.PurchaseOrderAmendmentDocument;
28  import org.kuali.ole.module.purap.document.PurchaseOrderDocument;
29  import org.kuali.ole.module.purap.document.PurchaseOrderSplitDocument;
30  import org.kuali.ole.module.purap.document.service.PaymentRequestService;
31  import org.kuali.ole.module.purap.document.service.PurapService;
32  import org.kuali.ole.module.purap.document.service.PurchaseOrderService;
33  import org.kuali.ole.module.purap.document.service.ReceivingService;
34  import org.kuali.ole.module.purap.util.PurApItemUtils;
35  import org.kuali.ole.sys.OLEConstants;
36  import org.kuali.ole.sys.context.SpringContext;
37  import org.kuali.rice.core.api.datetime.DateTimeService;
38  import org.kuali.rice.kew.api.WorkflowDocument;
39  import org.kuali.rice.kew.api.document.DocumentStatusCategory;
40  import org.kuali.rice.kim.api.KimConstants;
41  import org.kuali.rice.kim.api.services.IdentityManagementService;
42  import org.kuali.rice.kns.document.authorization.DocumentAuthorizer;
43  import org.kuali.rice.kns.service.DataDictionaryService;
44  import org.kuali.rice.kns.service.DocumentHelperService;
45  import org.kuali.rice.kns.web.ui.ExtraButton;
46  import org.kuali.rice.kns.web.ui.HeaderField;
47  import org.kuali.rice.krad.util.GlobalVariables;
48  import org.kuali.rice.krad.util.KRADConstants;
49  import org.kuali.rice.krad.util.ObjectUtils;
50  
51  import javax.servlet.http.HttpServletRequest;
52  import java.math.BigDecimal;
53  import java.util.Arrays;
54  import java.util.HashMap;
55  import java.util.List;
56  import java.util.Map;
57  
58  /**
59   * Struts Action Form for Purchase Order document.
60   */
61  public class PurchaseOrderForm extends PurchasingFormBase {
62      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(PurchaseOrderForm.class);
63  
64      protected PurchaseOrderVendorStipulation newPurchaseOrderVendorStipulationLine;
65      protected PurchaseOrderVendorQuote newPurchaseOrderVendorQuote;
66      protected Long awardedVendorNumber;
67  
68      // Retransmit.
69      protected String[] retransmitItemsSelected = {};
70      protected String retransmitTransmissionMethod;
71      protected String retransmitFaxNumber;
72      protected String retransmitHeader;
73  
74      // Need this for amendment for accounting line only
75      protected Map accountingLineEditingMode;
76  
77      protected String splitNoteText;
78  
79      // Assign Sensitive Data related fields
80      protected String sensitiveDataAssignmentReason = null; // reason for current assignment of sensitive data to the PO
81      protected SensitiveDataAssignment lastSensitiveDataAssignment = null; // last sensitive data assignment info for the PO
82      protected SensitiveData newSensitiveDataLine = null; // new sensitive data entry to be added to the PO
83      protected List<SensitiveData> sensitiveDatasAssigned = null;  // sensitive data entries currently assigned to the PO
84  
85      protected final String PURCHASING_PROCESSOR_ROLE_NAME = "Purchasing Processor";
86  
87      /**
88       * Constructs a PurchaseOrderForm instance and sets up the appropriately casted document.
89       */
90      public PurchaseOrderForm() {
91          super();
92  
93          setNewPurchaseOrderVendorStipulationLine(new PurchaseOrderVendorStipulation());
94          setNewPurchaseOrderVendorQuote(new PurchaseOrderVendorQuote());
95          this.accountingLineEditingMode = new HashMap();
96          //on PO, account distribution should be read only
97          setReadOnlyAccountDistributionMethod(true);
98      }
99  
100     @Override
101     protected String getDefaultDocumentTypeName() {
102         return "OLE_PO";
103     }
104 
105     public Map getAccountingLineEditingMode() {
106         return accountingLineEditingMode;
107     }
108 
109     public void setAccountingLineEditingMode(Map accountingLineEditingMode) {
110         this.accountingLineEditingMode = accountingLineEditingMode;
111     }
112 
113     public Long getAwardedVendorNumber() {
114         return awardedVendorNumber;
115     }
116 
117     public void setAwardedVendorNumber(Long awardedVendorNumber) {
118         this.awardedVendorNumber = awardedVendorNumber;
119     }
120 
121     public PurchaseOrderVendorStipulation getNewPurchaseOrderVendorStipulationLine() {
122         return newPurchaseOrderVendorStipulationLine;
123     }
124 
125     public void setNewPurchaseOrderVendorStipulationLine(PurchaseOrderVendorStipulation newPurchaseOrderVendorStipulationLine) {
126         this.newPurchaseOrderVendorStipulationLine = newPurchaseOrderVendorStipulationLine;
127     }
128 
129     public PurchaseOrderVendorQuote getNewPurchaseOrderVendorQuote() {
130         return newPurchaseOrderVendorQuote;
131     }
132 
133     public void setNewPurchaseOrderVendorQuote(PurchaseOrderVendorQuote newPurchaseOrderVendorQuote) {
134         this.newPurchaseOrderVendorQuote = newPurchaseOrderVendorQuote;
135     }
136 
137     public String[] getRetransmitItemsSelected() {
138         return retransmitItemsSelected;
139     }
140 
141     public void setRetransmitItemsSelected(String[] retransmitItemsSelected) {
142         this.retransmitItemsSelected = retransmitItemsSelected;
143     }
144 
145     public PurchaseOrderDocument getPurchaseOrderDocument() {
146         return (PurchaseOrderDocument) getDocument();
147     }
148 
149     public void setPurchaseOrderDocument(PurchaseOrderDocument purchaseOrderDocument) {
150         setDocument(purchaseOrderDocument);
151     }
152 
153     public String getSplitNoteText() {
154         return splitNoteText;
155     }
156 
157     public void setSplitNoteText(String splitNoteText) {
158         this.splitNoteText = splitNoteText;
159     }
160 
161     public String getSensitiveDataAssignmentReason() {
162         return sensitiveDataAssignmentReason;
163     }
164 
165     public void setSensitiveDataAssignmentReason(String sensitiveDataAssignmentReason) {
166         this.sensitiveDataAssignmentReason = sensitiveDataAssignmentReason;
167     }
168 
169     public SensitiveDataAssignment getLastSensitiveDataAssignment() {
170         return lastSensitiveDataAssignment;
171     }
172 
173     public void setLastSensitiveDataAssignment(SensitiveDataAssignment lastSensitiveDataAssignment) {
174         this.lastSensitiveDataAssignment = lastSensitiveDataAssignment;
175     }
176 
177     public SensitiveData getNewSensitiveDataLine() {
178         return newSensitiveDataLine;
179     }
180 
181     public void setNewSensitiveDataLine(SensitiveData newSensitiveDataLine) {
182         this.newSensitiveDataLine = newSensitiveDataLine;
183     }
184 
185     public List<SensitiveData> getSensitiveDatasAssigned() {
186         return sensitiveDatasAssigned;
187     }
188 
189     public void setSensitiveDatasAssigned(List<SensitiveData> poSensitiveData) {
190         this.sensitiveDatasAssigned = poSensitiveData;
191     }
192 
193     @Override
194     public Class getCapitalAssetLocationClass() {
195         return PurchaseOrderCapitalAssetLocation.class;
196     }
197 
198     @Override
199     public Class getItemCapitalAssetClass() {
200         return PurchaseOrderItemCapitalAsset.class;
201     }
202 
203     @Override
204     public CapitalAssetLocation setupNewPurchasingCapitalAssetLocationLine() {
205         CapitalAssetLocation location = new RequisitionCapitalAssetLocation();
206         return location;
207     }
208 
209     /**
210      * @see org.kuali.ole.module.purap.document.web.struts.PurchasingFormBase#setupNewPurchasingItemLine()
211      */
212     @Override
213     public PurApItem setupNewPurchasingItemLine() {
214         return new PurchaseOrderItem();
215     }
216 
217     /**
218      * @see org.kuali.ole.module.purap.document.web.struts.PurchasingFormBase#setupNewPurchasingAccountingLine()
219      */
220     @Override
221     public PurchaseOrderAccount setupNewPurchasingAccountingLine() {
222         return new PurchaseOrderAccount();
223     }
224 
225     /**
226      * @see org.kuali.ole.module.purap.document.web.struts.PurchasingFormBase#setupNewAccountDistributionAccountingLine()
227      */
228     @Override
229     public PurchaseOrderAccount setupNewAccountDistributionAccountingLine() {
230         PurchaseOrderAccount account = setupNewPurchasingAccountingLine();
231         account.setAccountLinePercent(new BigDecimal(100));
232         return account;
233     }
234 
235     public boolean isReadOnlyReceivingRequired() {
236 
237         PurchaseOrderDocument poDoc = getPurchaseOrderDocument();
238 
239         if (poDoc instanceof PurchaseOrderAmendmentDocument) {
240             if (!poDoc.isReceivingDocumentRequiredIndicator()) {
241                 if (GlobalVariables.getMessageMap().hasNoErrors()) {
242                     // only check whether the PO has active payment requests if there is currently no error in the MessageMap,
243                     // otherwise
244                     // we're going to get WorkflowServiceErrorException("Document Search Validation Errors") in the
245                     // DocumentSearchService
246                     // when this next line execute
247                     return SpringContext.getBean(PaymentRequestService.class).hasActivePaymentRequestsForPurchaseOrder(poDoc.getPurapDocumentIdentifier());
248                 } else {
249                     return true;
250                 }
251             }
252         }
253 
254         return false;
255     }
256 
257     /**
258      * Returns the new Purchase Order Vendor Stipulation Line and resets it.
259      *
260      * @return the new Purchase Order Vendor Stipulation Line.
261      */
262     public PurchaseOrderVendorStipulation getAndResetNewPurchaseOrderVendorStipulationLine() {
263         PurchaseOrderVendorStipulation aPurchaseOrderVendorStipulationLine = getNewPurchaseOrderVendorStipulationLine();
264         setNewPurchaseOrderVendorStipulationLine(new PurchaseOrderVendorStipulation());
265 
266         aPurchaseOrderVendorStipulationLine.setDocumentNumber(getPurchaseOrderDocument().getDocumentNumber());
267         aPurchaseOrderVendorStipulationLine.setVendorStipulationAuthorEmployeeIdentifier(GlobalVariables.getUserSession().getPerson().getPrincipalId());
268         aPurchaseOrderVendorStipulationLine.setVendorStipulationCreateDate(SpringContext.getBean(DateTimeService.class).getCurrentSqlDate());
269 
270         return aPurchaseOrderVendorStipulationLine;
271     }
272 
273     public String getStatusChange() {
274         if (StringUtils.isNotEmpty(getPurchaseOrderDocument().getStatusChange())) {
275             return getPurchaseOrderDocument().getStatusChange();
276         } else {
277             if (StringUtils.equals(getPurchaseOrderDocument().getApplicationDocumentStatus(), PurchaseOrderStatuses.APPDOC_IN_PROCESS)) {
278                 return PurchaseOrderStatuses.APPDOC_IN_PROCESS;
279             } else if (StringUtils.equals(getPurchaseOrderDocument().getApplicationDocumentStatus(), PurchaseOrderStatuses.APPDOC_WAITING_FOR_DEPARTMENT)) {
280                 return PurchaseOrderStatuses.APPDOC_WAITING_FOR_DEPARTMENT;
281             } else if (StringUtils.equals(getPurchaseOrderDocument().getApplicationDocumentStatus(), PurchaseOrderStatuses.APPDOC_WAITING_FOR_VENDOR)) {
282                 return PurchaseOrderStatuses.APPDOC_WAITING_FOR_VENDOR;
283             } else {
284                 return null;
285             }
286         }
287     }
288 
289     public void setStatusChange(String statusChange) {
290         getPurchaseOrderDocument().setStatusChange(statusChange);
291     }
292 
293     /**
294      * @see org.kuali.rice.kns.web.struts.form.KualiDocumentFormBase#shouldMethodToCallParameterBeUsed(java.lang.String, java.lang.String, javax.servlet.http.HttpServletRequest)
295      */
296     @Override
297     public boolean shouldMethodToCallParameterBeUsed(String methodToCallParameterName, String methodToCallParameterValue, HttpServletRequest request) {
298         List<String> methodToCallList = Arrays.asList(new String[]{"printPurchaseOrderPDFOnly", "printingRetransmitPoOnly", "printPoQuoteListOnly"});
299 
300         if (KRADConstants.DISPATCH_REQUEST_PARAMETER.equals(methodToCallParameterName) && methodToCallList.contains(methodToCallParameterValue)) {
301             return true;
302         }
303         return super.shouldMethodToCallParameterBeUsed(methodToCallParameterName, methodToCallParameterValue, request);
304     }
305 
306     @Override
307     public void populateHeaderFields(WorkflowDocument workflowDocument) {
308         super.populateHeaderFields(workflowDocument);
309 
310         String poIDstr = getPurchaseOrderDocument().getPurapDocumentIdentifier().toString();
311 
312         //KFSMI-4576 masking/unmasking PO number...
313         //If the document status is not FINAL then check for permissions
314         if (!workflowDocument.getStatus().getCategory().equals(DocumentStatusCategory.SUCCESSFUL)) {
315             String principalId = GlobalVariables.getUserSession().getPerson().getPrincipalId();
316             String namespaceCode = OLEConstants.ParameterNamespaces.KNS;
317             String permissionTemplateName = KimConstants.PermissionTemplateNames.FULL_UNMASK_FIELD;
318 
319             Map<String, String> roleQualifiers = new HashMap<String, String>();
320 
321             Map<String, String> permissionDetails = new HashMap<String, String>();
322             permissionDetails.put(KimConstants.AttributeConstants.COMPONENT_NAME, PurchaseOrderDocument.class.getSimpleName());
323             permissionDetails.put(KimConstants.AttributeConstants.PROPERTY_NAME, PurapPropertyConstants.PURAP_DOC_ID);
324 
325             IdentityManagementService identityManagementService = SpringContext.getBean(IdentityManagementService.class);
326             Boolean isAuthorized = identityManagementService.isAuthorizedByTemplateName(principalId, namespaceCode, permissionTemplateName, permissionDetails, roleQualifiers);
327 
328             //principalId is not authorized to see the PO number so mask the value.
329             if (!isAuthorized) {
330                 DataDictionaryService dataDictionaryService = SpringContext.getBean(DataDictionaryService.class);
331                 if (ObjectUtils.isNotNull(getPurchaseOrderDocument().getPurapDocumentIdentifier())) {
332                     poIDstr = "";
333                     int strLength = dataDictionaryService.getAttributeMaxLength(PurApGenericAttributes.class.getName(), PurapPropertyConstants.PURAP_DOC_ID);
334                     for (int i = 0; i < strLength; i++) {
335                         poIDstr = poIDstr.concat("*");
336                     }
337                 }
338             }
339         }
340 
341         if (ObjectUtils.isNotNull(getPurchaseOrderDocument().getPurapDocumentIdentifier())) {
342             getDocInfo().add(new HeaderField("DataDictionary.PurchaseOrderDocument.attributes.purapDocumentIdentifier", poIDstr));
343         } else {
344             getDocInfo().add(new HeaderField("DataDictionary.PurchaseOrderDocument.attributes.purapDocumentIdentifier", PurapConstants.PURAP_APPLICATION_DOCUMENT_ID_NOT_AVAILABLE));
345         }
346         if (ObjectUtils.isNotNull(getPurchaseOrderDocument().getApplicationDocumentStatus())) {
347             getDocInfo().add(new HeaderField("DataDictionary.PurchaseOrderDocument.attributes.applicationDocumentStatus", getPurchaseOrderDocument().getApplicationDocumentStatus()));
348         } else {
349             getDocInfo().add(new HeaderField("DataDictionary.PurchaseOrderDocument.attributes.applicationDocumentStatus", PurapConstants.PURAP_APPLICATION_DOCUMENT_STATUS_NOT_AVAILABLE));
350         }
351     }
352 
353     /**
354      * @see org.kuali.ole.sys.web.struts.KualiAccountingDocumentFormBase#populate(javax.servlet.http.HttpServletRequest)
355      */
356 //    @Override
357 //    public void populate(HttpServletRequest request) {
358 //        PurchaseOrderDocument po = (PurchaseOrderDocument) this.getDocument();
359 //
360 //        // call this to make sure it's refreshed from the database if need be since the populate setter doesn't do that
361 //      //  po.getNoteTarget();
362 //
363 //        super.populate(request);
364 //
365 //        /*if (ObjectUtils.isNotNull(po.getPurapDocumentIdentifier())) {
366 //            po.refreshDocumentBusinessObject();
367 //        }
368 //*/
369 //        for (Note note : po.getNotes()) {
370 //            note.refreshReferenceObject("attachment");
371 //        }
372 //    }
373 
374     /**
375      * Processes validation rules having to do with any payment requests that the given purchase order may have. Specifically,
376      * validates that at least one payment request exists, and makes further checks about the status of such payment requests.
377      *
378      * @param document A PurchaseOrderDocument
379      * @return True if the document passes all the validations.
380      */
381     protected boolean processPaymentRequestRulesForCanClose(PurchaseOrderDocument document) {
382         boolean valid = true;
383         // The PO must have at least one PREQ against it.
384         Integer poDocId = document.getPurapDocumentIdentifier();
385         List<PaymentRequestDocument> pReqs = SpringContext.getBean(PaymentRequestService.class).getPaymentRequestsByPurchaseOrderId(poDocId);
386         if (ObjectUtils.isNotNull(pReqs)) {
387             if (pReqs.size() == 0) {
388                 valid = false;
389             } else {
390                 boolean checkInProcess = true;
391                 boolean hasInProcess = false;
392 
393                 for (PaymentRequestDocument pReq : pReqs) {
394                     // skip exception docs
395                     if (pReq.getDocumentHeader().getWorkflowDocument().isException()) {
396                         continue;
397                     }
398                     // TODO NOTE for below, this could/should be changed to look at the first route level after full entry instead of
399                     // being tied to AwaitingFiscal (in case full entry is moved)
400                     // look for a doc that is currently routing, that will probably be the one that called this close if called from
401                     // preq (with close po box)
402                     if (StringUtils.equalsIgnoreCase(pReq.getApplicationDocumentStatus(), PaymentRequestStatuses.APPDOC_AWAITING_FISCAL_REVIEW) && !StringUtils.equalsIgnoreCase(pReq.getDocumentHeader().getWorkflowDocument().getCurrentNodeNames().toString(), PurapConstants.PaymentRequestStatuses.NODE_ACCOUNT_REVIEW)) {
403                         // terminate the search since this close doc is probably being called by this doc, a doc should never be In
404                         // Process and enroute in any other case
405                         checkInProcess = false;
406                         break;
407                     }
408                     if (!SpringContext.getBean(PurapService.class).isFullDocumentEntryCompleted(pReq)) {
409                         hasInProcess = true;
410                     }
411                 }
412                 if (checkInProcess && hasInProcess) {
413                     valid = false;
414                 }
415             }
416         }
417 
418         return valid;
419     }
420 
421     /**
422      * Determines whether to display the amend button for the purchase order document. The document status must be open, and the
423      * purchase order must be current and not pending, and the user must be in purchasing group. These are same as the conditions
424      * for displaying the payment hold button. In addition to these conditions, we also have to check that there is no In Process
425      * Payment Requests nor Credit Memos associated with the PO.
426      *
427      * @return boolean true if the amend button can be displayed.
428      */
429     protected boolean canAmend() {
430         boolean can = SpringContext.getBean(PurchaseOrderService.class).isPurchaseOrderOpenForProcessing(getPurchaseOrderDocument());
431 
432         // check user authorization
433         if (can) {
434             DocumentAuthorizer documentAuthorizer = SpringContext.getBean(DocumentHelperService.class).getDocumentAuthorizer(getPurchaseOrderDocument());
435             can = documentAuthorizer.canInitiate(OLEConstants.FinancialDocumentTypeCodes.PURCHASE_ORDER_AMENDMENT, GlobalVariables.getUserSession().getPerson());
436         }
437 
438         return can;
439     }
440 
441     /**
442      * Determines whether to display the void button for the purchase order document. Conditions:
443      * PO is in Pending Print status, or is in Open status and has no PREQs against it;
444      * PO's current indicator is true and pending indicator is false;
445      * and the user is a member of the purchasing group).
446      *
447      * @return boolean true if the void button can be displayed.
448      */
449     protected boolean canVoid() {
450         LOG.debug("Inside canVoid method   >>>>>>>>>>>>>>>>>");
451 
452         // check PO status etc
453         boolean can = getPurchaseOrderDocument().isPurchaseOrderCurrentIndicator() && !getPurchaseOrderDocument().isPendingActionIndicator();
454 
455         if (can) {
456             boolean pendingPrint = PurchaseOrderStatuses.APPDOC_PENDING_PRINT.equals(getPurchaseOrderDocument().getApplicationDocumentStatus());
457             boolean open = PurchaseOrderStatuses.APPDOC_OPEN.equals(getPurchaseOrderDocument().getApplicationDocumentStatus());
458             boolean errorCxml = PurchaseOrderStatuses.APPDOC_CXML_ERROR.equals(getPurchaseOrderDocument().getApplicationDocumentStatus());
459             boolean errorFax = PurchaseOrderStatuses.APPDOC_FAX_ERROR.equals(getPurchaseOrderDocument().getApplicationDocumentStatus());
460 
461             List<PaymentRequestView> preqViews = getPurchaseOrderDocument().getRelatedViews().getRelatedPaymentRequestViews();
462             List<InvoiceView> invViews = getPurchaseOrderDocument().getRelatedViews().getRelatedInvoiceViews();
463 
464             boolean hasPaymentRequest = preqViews != null && preqViews.size() > 0;
465             boolean hasInvoice = invViews != null && invViews.size() > 0;
466 
467             can = pendingPrint || (open && !hasPaymentRequest) || (open && !hasInvoice) || errorCxml || errorFax;
468 
469         }
470 
471         // check user authorization
472       /*  if (can) {
473             DocumentAuthorizer documentAuthorizer = SpringContext.getBean(DocumentHelperService.class).getDocumentAuthorizer(getPurchaseOrderDocument());
474             can = documentAuthorizer.canInitiate(OLEConstants.FinancialDocumentTypeCodes.PURCHASE_ORDER_VOID, GlobalVariables.getUserSession().getPerson());
475         }*/
476         if (can) {
477             String documentTypeName = OLEConstants.OlePurchaseOrder.POV_DOCUMENT_TYPE;
478             String nameSpaceCode = OLEConstants.OlePurchaseOrder.PO_NAMESPACE;
479             if (LOG.isDebugEnabled()) {
480                 LOG.debug("Inside canVoid documentTypeName   >>>>>>>>>>>>>>>>>" + documentTypeName);
481                 LOG.debug("Inside canVoid nameSpaceCode  >>>>>>>>>>>>>>>>>" + nameSpaceCode);
482             }
483             can = SpringContext.getBean(IdentityManagementService.class).hasPermission(GlobalVariables.getUserSession().getPerson().getPrincipalId(), nameSpaceCode,
484                     OLEConstants.OlePurchaseOrder.EDIT_VOID_DOCUMENT);
485             if (LOG.isDebugEnabled()) {
486                 LOG.debug("Inside canVoid hasPermission   >>>>>>>>>>>>>>>>>" + can);
487             }
488 
489         }
490         return can;
491     }
492 
493     /**
494      * Determines whether to display the close order button to close the purchase order document. Conditions:
495      * PO must be in Open status; must have at least one Payment Request in any status other than "In Process",
496      * and the PO cannot have any Payment Requests in "In Process" status.
497      * This button is available to all faculty/staff.
498      *
499      * @return boolean true if the close order button can be displayed.
500      */
501     protected boolean canClose() {
502         LOG.debug("Inside canClose method   >>>>>>>>>>>>>>>>>");
503 
504         // check PO status etc
505         boolean can = PurchaseOrderStatuses.APPDOC_OPEN.equals(getPurchaseOrderDocument().getApplicationDocumentStatus());
506         can = can && getPurchaseOrderDocument().isPurchaseOrderCurrentIndicator() && !getPurchaseOrderDocument().isPendingActionIndicator();
507         can = can && processPaymentRequestRulesForCanClose(getPurchaseOrderDocument());
508 
509         // check user authorization
510         if (can) {
511             String documentTypeName = OLEConstants.FinancialDocumentTypeCodes.PURCHASE_ORDER_CLOSE;
512             String nameSpaceCode = OLEConstants.CoreModuleNamespaces.SELECT;
513             if (LOG.isDebugEnabled()) {
514                 LOG.debug("Inside canClose documentTypeName   >>>>>>>>>>>>>>>>>" + documentTypeName);
515                 LOG.debug("Inside canClose nameSpaceCode  >>>>>>>>>>>>>>>>>" + nameSpaceCode);
516             }
517 
518             can = SpringContext.getBean(IdentityManagementService.class).hasPermission(GlobalVariables.getUserSession().getPerson().getPrincipalId(), nameSpaceCode,
519                     OLEConstants.OlePaymentRequest.CAN_CLOSE_PO);
520             if (LOG.isDebugEnabled()) {
521                 LOG.debug("Inside canClose hasPermission   >>>>>>>>>>>>>>>>>" + can);
522             }
523 
524         }
525 
526         return can;
527     }
528 
529     /**
530      * Determines whether to display the open order button to reopen the purchase order document.
531      * Conditions: PO status is close, PO is current and not pending, and the user is in purchasing group.
532      *
533      * @return boolean true if the reopen order button can be displayed.
534      */
535     protected boolean canReopen() {
536         LOG.info("Inside canReopen method   >>>>>>>>>>>>>>>>>");
537 
538         // check PO status etc
539         boolean can = PurchaseOrderStatuses.APPDOC_CLOSED.equals(getPurchaseOrderDocument().getApplicationDocumentStatus());
540         can = can && getPurchaseOrderDocument().isPurchaseOrderCurrentIndicator() && !getPurchaseOrderDocument().isPendingActionIndicator();
541 
542         // check user authorization
543         /*if (can) {
544             DocumentAuthorizer documentAuthorizer = SpringContext.getBean(DocumentHelperService.class).getDocumentAuthorizer(getPurchaseOrderDocument());
545             can = documentAuthorizer.canInitiate(OLEConstants.FinancialDocumentTypeCodes.PURCHASE_ORDER_REOPEN, GlobalVariables.getUserSession().getPerson());
546         }*/
547 
548         if (can) {
549             String documentTypeName = OLEConstants.FinancialDocumentTypeCodes.PURCHASE_ORDER_REOPEN;
550             String nameSpaceCode = OLEConstants.OlePurchaseOrder.PO_NAMESPACE;
551             LOG.info("Inside canReopen documentTypeName   >>>>>>>>>>>>>>>>>" + documentTypeName);
552             LOG.info("Inside canReopen nameSpaceCode  >>>>>>>>>>>>>>>>>" + nameSpaceCode);
553             can = SpringContext.getBean(IdentityManagementService.class).hasPermission(GlobalVariables.getUserSession().getPerson().getPrincipalId(), nameSpaceCode,
554                     OLEConstants.OlePurchaseOrder.EDIT_REOPEN_DOCUMENT);
555             LOG.info("Inside canReopen hasPermission   >>>>>>>>>>>>>>>>>" + can);
556 
557         }
558 
559         return can;
560     }
561 
562     /**
563      * Determines whether to display the payment hold buttons for the purchase order document.
564      * Conditions: PO status must be open, must be current and not pending, and the user must be in purchasing group.
565      *
566      * @return boolean true if the payment hold button can be displayed.
567      */
568     protected boolean canHoldPayment() {
569         // check PO status etc
570         boolean can = PurchaseOrderStatuses.APPDOC_OPEN.equals(getPurchaseOrderDocument().getApplicationDocumentStatus());
571         can = can && getPurchaseOrderDocument().isPurchaseOrderCurrentIndicator() && !getPurchaseOrderDocument().isPendingActionIndicator();
572 
573         // check user authorization
574         if (can) {
575             DocumentAuthorizer documentAuthorizer = SpringContext.getBean(DocumentHelperService.class).getDocumentAuthorizer(getPurchaseOrderDocument());
576             can = documentAuthorizer.canInitiate(OLEConstants.FinancialDocumentTypeCodes.PURCHASE_ORDER_PAYMENT_HOLD, GlobalVariables.getUserSession().getPerson());
577         }
578 
579         return can;
580     }
581 
582     /**
583      * Determines whether to display the remove hold button for the purchase order document.
584      * Conditions are: PO status must be payment hold, must be current and not pending, and the user must be in purchasing group.
585      *
586      * @return boolean true if the remove hold button can be displayed.
587      */
588     protected boolean canRemoveHold() {
589         // check PO status etc
590         boolean can = PurchaseOrderStatuses.APPDOC_PAYMENT_HOLD.equals(getPurchaseOrderDocument().getApplicationDocumentStatus());
591         can = can && getPurchaseOrderDocument().isPurchaseOrderCurrentIndicator() && !getPurchaseOrderDocument().isPendingActionIndicator();
592 
593         // check user authorization
594         if (can) {
595             DocumentAuthorizer documentAuthorizer = SpringContext.getBean(DocumentHelperService.class).getDocumentAuthorizer(getPurchaseOrderDocument());
596             can = documentAuthorizer.canInitiate(OLEConstants.FinancialDocumentTypeCodes.PURCHASE_ORDER_REMOVE_HOLD, GlobalVariables.getUserSession().getPerson());
597         }
598 
599         return can;
600     }
601 
602     /**
603      * Determines whether to display the retransmit button. Conditions:
604      * PO status must be open, and must be current and not pending, and the last transmit date must not be null.
605      * If the purchase order is an Automated Purchase Order (APO) and does not have any sensitive data set to true,
606      * then any users can see the retransmit button, otherwise, only users in the purchasing group can see it.
607      *
608      * @return boolean true if the retransmit button can be displayed.
609      */
610     protected boolean canRetransmit() {
611         // check PO status etc
612         boolean can = PurchaseOrderStatuses.APPDOC_OPEN.equals(getPurchaseOrderDocument().getApplicationDocumentStatus());
613         can = can && getPurchaseOrderDocument().isPurchaseOrderCurrentIndicator() && !getPurchaseOrderDocument().isPendingActionIndicator();
614         can = can && getPurchaseOrderDocument().getPurchaseOrderLastTransmitTimestamp() != null;
615         can = can && !PurapConstants.RequisitionSources.B2B.equals(getPurchaseOrderDocument().getRequisitionSourceCode());
616         can = can && !editingMode.containsKey(PurapAuthorizationConstants.PurchaseOrderEditMode.DISPLAY_RETRANSMIT_TAB);
617 
618         if (!can) {
619             return false;
620         }
621 
622         // check user authorization
623         DocumentAuthorizer documentAuthorizer = SpringContext.getBean(DocumentHelperService.class).getDocumentAuthorizer(getPurchaseOrderDocument());
624         if (getPurchaseOrderDocument().getPurchaseOrderAutomaticIndicator()) {
625             // for APO use authorization for PurchaseOrderRetransmitDocument, which is anybody
626             can = documentAuthorizer.canInitiate(OLEConstants.FinancialDocumentTypeCodes.PURCHASE_ORDER_RETRANSMIT, GlobalVariables.getUserSession().getPerson());
627         } else {
628             // for NON_APO use authorization for PurchaseOrderDocument, which is purchasing user
629             can = documentAuthorizer.canInitiate(OLEConstants.FinancialDocumentTypeCodes.PURCHASE_ORDER, GlobalVariables.getUserSession().getPerson());
630         }
631 
632         return can;
633     }
634 
635     /**
636      * Determines whether to display the button to print the pdf on a retransmit document.
637      * We're currently sharing the same button image as the button for creating a retransmit document but this may change someday.
638      * This button should only appear on Retransmit Document. If it is an Automated Purchase Order (APO)
639      * then any users can see this button, otherwise, only users in the purchasing group can see it.
640      *
641      * @return boolean true if the print retransmit button can be displayed.
642      */
643     protected boolean canPrintRetransmit() {
644         // check PO status etc
645         boolean can = getPurchaseOrderDocument().getDocumentHeader().getWorkflowDocument().getDocumentTypeName().equals(PurapConstants.PurchaseOrderDocTypes.PURCHASE_ORDER_RETRANSMIT_DOCUMENT);
646         can = can && editingMode.containsKey(PurapAuthorizationConstants.PurchaseOrderEditMode.DISPLAY_RETRANSMIT_TAB);
647 
648         if (can) {
649             // check user authorization: same as retransmit init, since whoever can init retransmit PO shall be able to print
650             DocumentAuthorizer documentAuthorizer = SpringContext.getBean(DocumentHelperService.class).getDocumentAuthorizer(getPurchaseOrderDocument());
651             if (getPurchaseOrderDocument().getPurchaseOrderAutomaticIndicator()) {
652                 // for APO use authorization for PurchaseOrderRetransmitDocument, which is anybody
653                 can = documentAuthorizer.canInitiate(OLEConstants.FinancialDocumentTypeCodes.PURCHASE_ORDER_RETRANSMIT, GlobalVariables.getUserSession().getPerson());
654             } else {
655                 // for NON_APO use authorization for PurchaseOrderDocument, which is purchasing user
656                 can = documentAuthorizer.canInitiate(OLEConstants.FinancialDocumentTypeCodes.PURCHASE_ORDER, GlobalVariables.getUserSession().getPerson());
657             }
658         }
659 
660         return can;
661     }
662 
663     /**
664      * Determines if a Split PO Document can be created from this purchase order. Conditions:
665      * The parent PO status is either "In Process" or "Awaiting Purchasing Review"; requisition source is not B2B; has at least 2 items,
666      * and PO is not in the process of being split; user must be in purchasing group.
667      *
668      * @return boolean true if the split PO button can be displayed.
669      */
670     protected boolean canSplitPo() {
671         LOG.info("Inside canSplitPo method   >>>>>>>>>>>>>>>>>");
672 
673         // PO must be in either "In Process" or "Awaiting Purchasing Review"
674         boolean can = PurchaseOrderStatuses.APPDOC_IN_PROCESS.equals(getPurchaseOrderDocument().getApplicationDocumentStatus());
675         can = can && !getPurchaseOrderDocument().getDocumentHeader().getWorkflowDocument().isEnroute();
676         can = can || PurchaseOrderStatuses.APPDOC_AWAIT_PURCHASING_REVIEW.equals(getPurchaseOrderDocument().getApplicationDocumentStatus());
677 
678         // can't split a SplitPO Document, according to new specs
679         can = can && !(getPurchaseOrderDocument() instanceof PurchaseOrderSplitDocument);
680 
681         // can't initiate another split during the splitting process.
682         can = can && !editingMode.containsKey(PurapAuthorizationConstants.PurchaseOrderEditMode.SPLITTING_ITEM_SELECTION);
683 
684         // Requisition Source must not be B2B.
685         can = can && !getPurchaseOrderDocument().getRequisitionSourceCode().equals(PurapConstants.RequisitionSources.B2B);
686 
687         // PO must have more than one line item.
688         if (can) {
689             List<PurApItem> items = getPurchaseOrderDocument().getItems();
690             int itemsBelowTheLine = PurApItemUtils.countBelowTheLineItems(items);
691             can = items.size() - itemsBelowTheLine > 1;
692         }
693 
694         // check user authorization
695         /*if (can) {
696             DocumentAuthorizer documentAuthorizer = SpringContext.getBean(DocumentHelperService.class).getDocumentAuthorizer(getPurchaseOrderDocument());
697             can = documentAuthorizer.canInitiate(OLEConstants.FinancialDocumentTypeCodes.PURCHASE_ORDER_SPLIT, GlobalVariables.getUserSession().getPerson());
698         }*/
699 
700         if (can) {
701             String documentTypeName = OLEConstants.OlePurchaseOrder.POSP_DOCUMENT_TYPE;
702             String nameSpaceCode = OLEConstants.OlePurchaseOrder.PO_NAMESPACE;
703             HashMap<String, String> permissionDetails = new HashMap<String, String>();
704             permissionDetails.put(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME, documentTypeName);
705             LOG.info("Inside canSplitPo documentTypeName   >>>>>>>>>>>>>>>>>" + documentTypeName);
706             LOG.info("Inside canSplitPo nameSpaceCode  >>>>>>>>>>>>>>>>>" + nameSpaceCode);
707             can = SpringContext.getBean(IdentityManagementService.class).hasPermission(GlobalVariables.getUserSession().getPerson().getPrincipalId(), nameSpaceCode,
708                     OLEConstants.OlePurchaseOrder.EDIT_SPLIT_DOCUMENT);
709             LOG.info("Inside canSplitPo hasPermission   >>>>>>>>>>>>>>>>>" + can);
710 
711         }
712 
713         return can;
714     }
715 
716     /**
717      * Determines whether the PO is in a status that signifies it has enough information to generate a Split PO.
718      *
719      * @return True if the PO can continue to be split.
720      */
721     protected boolean canContinuePoSplit() {
722         LOG.info("Inside canContinuePoSplit method   >>>>>>>>>>>>>>>>>");
723 
724         boolean can = editingMode.containsKey(PurapAuthorizationConstants.PurchaseOrderEditMode.SPLITTING_ITEM_SELECTION);
725 
726         // check user authorization
727       /*  if (can) {
728             DocumentAuthorizer documentAuthorizer = SpringContext.getBean(DocumentHelperService.class).getDocumentAuthorizer(getPurchaseOrderDocument());
729             can = documentAuthorizer.canInitiate(OLEConstants.FinancialDocumentTypeCodes.PURCHASE_ORDER_SPLIT, GlobalVariables.getUserSession().getPerson());
730         }
731         */
732         if (can) {
733             String documentTypeName = OLEConstants.OlePurchaseOrder.POSP_DOCUMENT_TYPE;
734             String nameSpaceCode = OLEConstants.OlePurchaseOrder.PO_NAMESPACE;
735             LOG.info("Inside canContinuePoSplit documentTypeName   >>>>>>>>>>>>>>>>>" + documentTypeName);
736             LOG.info("Inside canContinuePoSplit nameSpaceCode  >>>>>>>>>>>>>>>>>" + nameSpaceCode);
737             can = SpringContext.getBean(IdentityManagementService.class).hasPermission(GlobalVariables.getUserSession().getPerson().getPrincipalId(), nameSpaceCode,
738                     OLEConstants.OlePurchaseOrder.EDIT_SPLIT_DOCUMENT);
739             LOG.info("Inside canContinuePoSplit hasPermission   >>>>>>>>>>>>>>>>>" + can);
740 
741         }
742 
743         return can;
744     }
745 
746     protected boolean canCancel() {
747         String documentTypeName = OLEConstants.FinancialDocumentTypeCodes.PURCHASE_ORDER_AMENDMENT;
748         String nameSpaceCode = OLEConstants.CoreModuleNamespaces.SELECT;
749 
750         boolean can = SpringContext.getBean(IdentityManagementService.class).hasPermission(GlobalVariables.getUserSession().getPerson().getPrincipalId(), nameSpaceCode,
751                 OLEConstants.MAPPING_CANCEL);
752         return can;
753     }
754 
755     /**
756      * Determines if a line item receiving document can be created for the purchase order.
757      *
758      * @return boolean true if the receiving document button can be displayed.
759      */
760     protected boolean canCreateReceiving() {
761         LOG.info("Inside canCreateReceiving method   >>>>>>>>>>>>>>>>>");
762 
763         // check PO status and item info
764         boolean can = SpringContext.getBean(ReceivingService.class).canCreateLineItemReceivingDocument(getPurchaseOrderDocument());
765 
766         // check user authorization
767         if (can) {
768             DocumentAuthorizer documentAuthorizer = SpringContext.getBean(DocumentHelperService.class).getDocumentAuthorizer(getPurchaseOrderDocument());
769 
770             can = documentAuthorizer.canInitiate(OLEConstants.FinancialDocumentTypeCodes.LINE_ITEM_RECEIVING, GlobalVariables.getUserSession().getPerson());
771 
772         }
773 
774         return can;
775     }
776 
777 
778     /*protected boolean canPrint() {
779         //LOG.info("Inside canPrint method   >>>>>>>>>>>>>>>>>" );
780 
781         boolean hasPermission = false;
782         String documentTypeName = OLEConstants.OlePurchaseOrder.PO_DOCUMENT_TYPE;
783         String nameSpaceCode = OLEConstants.OlePurchaseOrder.PO_NAMESPACE;
784         HashMap<String,String> permissionDetails = new HashMap<String,String>();
785         permissionDetails.put(KimAttributes.DOCUMENT_TYPE_NAME,documentTypeName);
786         LOG.info("Inside canPrint documentTypeName   >>>>>>>>>>>>>>>>>" + documentTypeName);
787         LOG.info("Inside canPrint nameSpaceCode  >>>>>>>>>>>>>>>>>" + nameSpaceCode);
788         hasPermission = KIMServiceLocator.getIdentityManagementService().hasPermission(GlobalVariables.getUserSession().getPerson().getPrincipalId(), nameSpaceCode,
789                 OLEConstants.OlePurchaseOrder.PRINT_PURCHASE_ORDER, permissionDetails);
790         LOG.info("Inside canPrint hasPermission   >>>>>>>>>>>>>>>>>" + hasPermission);
791 
792         return hasPermission;
793     }*/
794 
795     /**
796      * Creates a MAP for all the buttons to appear on the Purchase Order Form, and sets the attributes of these buttons.
797      *
798      * @return the button map created.
799      */
800     protected Map<String, ExtraButton> createButtonsMap() {
801         HashMap<String, ExtraButton> result = new HashMap<String, ExtraButton>();
802 
803         // Retransmit button
804         ExtraButton retransmitButton = new ExtraButton();
805         retransmitButton.setExtraButtonProperty("methodToCall.retransmitPo");
806         retransmitButton.setExtraButtonSource("${" + OLEConstants.EXTERNALIZABLE_IMAGES_URL_KEY + "}buttonsmall_retransmit.gif");
807         retransmitButton.setExtraButtonAltText("Retransmit");
808 
809         // Printing Retransmit button
810         ExtraButton printingRetransmitButton = new ExtraButton();
811         printingRetransmitButton.setExtraButtonProperty("methodToCall.printingRetransmitPo");
812         printingRetransmitButton.setExtraButtonSource("${" + OLEConstants.EXTERNALIZABLE_IMAGES_URL_KEY + "}buttonsmall_retransmit.gif");
813         printingRetransmitButton.setExtraButtonAltText("PrintingRetransmit");
814 
815         // Printing Preview button
816         ExtraButton printingPreviewButton = new ExtraButton();
817         printingPreviewButton.setExtraButtonProperty("methodToCall.printingPreviewPo");
818         printingPreviewButton.setExtraButtonSource("${" + OLEConstants.EXTERNALIZABLE_IMAGES_URL_KEY + "}buttonsmall_previewpf.gif");
819         printingPreviewButton.setExtraButtonAltText("PrintingPreview");
820 
821         // Print button
822         ExtraButton printButton = new ExtraButton();
823         printButton.setExtraButtonProperty("methodToCall.firstTransmitPrintPo");
824         printButton.setExtraButtonSource("${" + OLEConstants.EXTERNALIZABLE_IMAGES_URL_KEY + "}buttonsmall_print.gif");
825         printButton.setExtraButtonAltText("Print");
826 
827         // Reopen PO button
828         ExtraButton reopenButton = new ExtraButton();
829         reopenButton.setExtraButtonProperty("methodToCall.reopenPo");
830         reopenButton.setExtraButtonSource("${" + OLEConstants.EXTERNALIZABLE_IMAGES_URL_KEY + "}buttonsmall_openorder.gif");
831         reopenButton.setExtraButtonAltText("Reopen");
832 
833         // Close PO button
834         ExtraButton closeButton = new ExtraButton();
835         closeButton.setExtraButtonProperty("methodToCall.closePo");
836         closeButton.setExtraButtonSource("${" + OLEConstants.EXTERNALIZABLE_IMAGES_URL_KEY + "}buttonsmall_closeorder.gif");
837         closeButton.setExtraButtonAltText("Close PO");
838 
839         // Void PO button
840         ExtraButton voidButton = new ExtraButton();
841         voidButton.setExtraButtonProperty("methodToCall.voidPo");
842         voidButton.setExtraButtonSource("${" + OLEConstants.EXTERNALIZABLE_IMAGES_URL_KEY + "}buttonsmall_voidorder.gif");
843         voidButton.setExtraButtonAltText("Void PO");
844 
845         // Payment Hold PO button
846         ExtraButton paymentHoldButton = new ExtraButton();
847         paymentHoldButton.setExtraButtonProperty("methodToCall.paymentHoldPo");
848         paymentHoldButton.setExtraButtonSource("${" + OLEConstants.EXTERNALIZABLE_IMAGES_URL_KEY + "}buttonsmall_paymenthold.gif");
849         paymentHoldButton.setExtraButtonAltText("Payment Hold");
850 
851         // Amend button
852         ExtraButton amendButton = new ExtraButton();
853         amendButton.setExtraButtonProperty("methodToCall.amendPo");
854         amendButton.setExtraButtonSource("${" + OLEConstants.EXTERNALIZABLE_IMAGES_URL_KEY + "}buttonsmall_amend.gif");
855         amendButton.setExtraButtonAltText("Amend");
856 
857         // Remove Hold button
858         ExtraButton removeHoldButton = new ExtraButton();
859         removeHoldButton.setExtraButtonProperty("methodToCall.removeHoldPo");
860         removeHoldButton.setExtraButtonSource("${" + OLEConstants.EXTERNALIZABLE_IMAGES_URL_KEY + "}buttonsmall_removehold.gif");
861         removeHoldButton.setExtraButtonAltText("Remove Hold");
862 
863         // Resend PO Cxml button
864         ExtraButton resendPoCxmlButton = new ExtraButton();
865         resendPoCxmlButton.setExtraButtonProperty("methodToCall.resendPoCxml");
866         resendPoCxmlButton.setExtraButtonSource("${" + OLEConstants.EXTERNALIZABLE_IMAGES_URL_KEY + "}buttonsmall_resendpo.gif");
867         resendPoCxmlButton.setExtraButtonAltText("Resend PO CXML");
868 
869         // Receiving button
870         ExtraButton receivingButton = new ExtraButton();
871         receivingButton.setExtraButtonProperty("methodToCall.createReceivingLine");
872         receivingButton.setExtraButtonSource("${" + OLEConstants.EXTERNALIZABLE_IMAGES_URL_KEY + "}buttonsmall_receiving.gif");
873         receivingButton.setExtraButtonAltText("Receiving");
874 
875         // Split PO button
876         ExtraButton splitPoButton = new ExtraButton();
877         splitPoButton.setExtraButtonProperty("methodToCall.splitPo");
878         splitPoButton.setExtraButtonSource("${" + OLEConstants.EXTERNALIZABLE_IMAGES_URL_KEY + "}buttonsmall_splitorder.gif");
879         splitPoButton.setExtraButtonAltText("Split this PO");
880 
881         // Continue button
882         ExtraButton continueButton = new ExtraButton();
883         continueButton.setExtraButtonProperty("methodToCall.continuePurchaseOrderSplit");
884         continueButton.setExtraButtonSource("${" + OLEConstants.RICE_EXTERNALIZABLE_IMAGES_URL_KEY + "}buttonsmall_continue.gif");
885         continueButton.setExtraButtonAltText("Continue");
886 
887         // Cancel Split button
888         ExtraButton cancelSplitButton = new ExtraButton();
889         cancelSplitButton.setExtraButtonProperty("methodToCall.cancelPurchaseOrderSplit");
890         cancelSplitButton.setExtraButtonSource("${" + OLEConstants.EXTERNALIZABLE_IMAGES_URL_KEY + "}buttonsmall_cancelsplit.gif");
891         cancelSplitButton.setExtraButtonAltText("Cancel Splitting the PO");
892 
893         // Assign Sensitive Data button
894         /*ExtraButton assignSensitiveDataButton = new ExtraButton();
895         assignSensitiveDataButton.setExtraButtonProperty("methodToCall.assignSensitiveData");
896         assignSensitiveDataButton.setExtraButtonSource("${" + OLEConstants.EXTERNALIZABLE_IMAGES_URL_KEY + "}buttonsmall_sensitivedata.gif ");
897         assignSensitiveDataButton.setExtraButtonAltText("Assign sensitive data to the PO");
898 */
899         // Submit Sensitive Data Assignment button
900       /*  ExtraButton submitSensitiveDataButton = new ExtraButton();
901         submitSensitiveDataButton.setExtraButtonProperty("methodToCall.submitSensitiveData");
902         submitSensitiveDataButton.setExtraButtonSource("${" + OLEConstants.RICE_EXTERNALIZABLE_IMAGES_URL_KEY + "}buttonsmall_submit.gif");
903         submitSensitiveDataButton.setExtraButtonAltText("Submit sensitive data assignment");
904 */
905         // Cancel Sensitive Data Assignment button
906        /* ExtraButton cancelSensitiveDataButton = new ExtraButton();
907         cancelSensitiveDataButton.setExtraButtonProperty("methodToCall.cancelSensitiveData");
908         cancelSensitiveDataButton.setExtraButtonSource("${" + OLEConstants.RICE_EXTERNALIZABLE_IMAGES_URL_KEY + "}buttonsmall_cancel.gif");
909         cancelSensitiveDataButton.setExtraButtonAltText("Cancel sensitive data assignment");
910 */
911         //Cancel Document button
912         ExtraButton cancelButton = new ExtraButton();
913         cancelButton.setExtraButtonProperty("methodToCall.cancel");
914         cancelButton.setExtraButtonSource("${" + OLEConstants.RICE_EXTERNALIZABLE_IMAGES_URL_KEY + "}buttonsmall_cancel.gif");
915         cancelButton.setExtraButtonAltText("Cancel");
916 
917         result.put(retransmitButton.getExtraButtonProperty(), retransmitButton);
918         result.put(printingRetransmitButton.getExtraButtonProperty(), printingRetransmitButton);
919         result.put(printingPreviewButton.getExtraButtonProperty(), printingPreviewButton);
920         result.put(printButton.getExtraButtonProperty(), printButton);
921         result.put(reopenButton.getExtraButtonProperty(), reopenButton);
922         result.put(closeButton.getExtraButtonProperty(), closeButton);
923         result.put(voidButton.getExtraButtonProperty(), voidButton);
924         result.put(paymentHoldButton.getExtraButtonProperty(), paymentHoldButton);
925         result.put(amendButton.getExtraButtonProperty(), amendButton);
926         result.put(removeHoldButton.getExtraButtonProperty(), removeHoldButton);
927         result.put(receivingButton.getExtraButtonProperty(), receivingButton);
928         result.put(splitPoButton.getExtraButtonProperty(), splitPoButton);
929         result.put(continueButton.getExtraButtonProperty(), continueButton);
930         result.put(cancelSplitButton.getExtraButtonProperty(), cancelSplitButton);
931        // result.put(assignSensitiveDataButton.getExtraButtonProperty(), assignSensitiveDataButton);
932         //result.put(submitSensitiveDataButton.getExtraButtonProperty(), submitSensitiveDataButton);
933         //result.put(cancelSensitiveDataButton.getExtraButtonProperty(), cancelSensitiveDataButton);
934         result.put(resendPoCxmlButton.getExtraButtonProperty(), resendPoCxmlButton);
935         result.put(cancelButton.getExtraButtonProperty(), cancelButton);
936 
937 
938         return result;
939     }
940 
941     /**
942      * Override the superclass method to add appropriate buttons for
943      * PurchaseOrderDocument.
944      *
945      * @see org.kuali.rice.kns.web.struts.form.KualiForm#getExtraButtons()
946      */
947     @Override
948     public List<ExtraButton> getExtraButtons() {
949         super.getExtraButtons();
950         Map buttonsMap = createButtonsMap();
951 
952         if (getEditingMode().containsKey(PurapAuthorizationConstants.PurchaseOrderEditMode.ASSIGN_SENSITIVE_DATA)) {
953             extraButtons.add((ExtraButton) buttonsMap.get("methodToCall.assignSensitiveData"));
954             if (getPurchaseOrderDocument().getAssigningSensitiveData()) {
955                 // no other extra buttons except the following shall appear on "Assign Sensitive Data" page
956                 // and these buttons use the same permissions as the "Assign Sensitive Data" button
957                 extraButtons.clear();
958                 extraButtons.add((ExtraButton) buttonsMap.get("methodToCall.submitSensitiveData"));
959                 extraButtons.add((ExtraButton) buttonsMap.get("methodToCall.cancelSensitiveData"));
960                 return extraButtons;
961             }
962         }
963 
964         if (getEditingMode().containsKey(PurapAuthorizationConstants.PurchaseOrderEditMode.PREVIEW_PRINT_PURCHASE_ORDER)) {
965 
966             LOG.info("Inside PREVIEW_PRINT_PURCHASE_ORDER   >>>>>>>>>>>>>>>>>" + PurapAuthorizationConstants.PurchaseOrderEditMode.PREVIEW_PRINT_PURCHASE_ORDER);
967             // LOG.info("result from canPrint() >>>>>>>>>>>" + canPrint());
968             extraButtons.add((ExtraButton) buttonsMap.get("methodToCall.printingPreviewPo"));
969         }
970 
971         if (getEditingMode().containsKey(PurapAuthorizationConstants.PurchaseOrderEditMode.PRINT_PURCHASE_ORDER)) {
972 
973             extraButtons.add((ExtraButton) buttonsMap.get("methodToCall.firstTransmitPrintPo"));
974         }
975 
976         if (getEditingMode().containsKey(PurapAuthorizationConstants.PurchaseOrderEditMode.RESEND_PURCHASE_ORDER)) {
977             extraButtons.add((ExtraButton) buttonsMap.get("methodToCall.resendPoCxml"));
978         }
979 
980         if (canRetransmit()) {
981             extraButtons.add((ExtraButton) buttonsMap.get("methodToCall.retransmitPo"));
982         }
983 
984         if (canPrintRetransmit()) {
985             extraButtons.add((ExtraButton) buttonsMap.get("methodToCall.printingRetransmitPo"));
986         }
987 
988         if (canReopen()) {
989             extraButtons.add((ExtraButton) buttonsMap.get("methodToCall.reopenPo"));
990         }
991 
992         if (canClose()) {
993             extraButtons.add((ExtraButton) buttonsMap.get("methodToCall.closePo"));
994         }
995 
996         if (canHoldPayment()) {
997             extraButtons.add((ExtraButton) buttonsMap.get("methodToCall.paymentHoldPo"));
998         }
999 
1000         if (canAmend()) {
1001             extraButtons.add((ExtraButton) buttonsMap.get("methodToCall.amendPo"));
1002         }
1003 
1004         if (canVoid()) {
1005             extraButtons.add((ExtraButton) buttonsMap.get("methodToCall.voidPo"));
1006         }
1007 
1008         if (canRemoveHold()) {
1009             extraButtons.add((ExtraButton) buttonsMap.get("methodToCall.removeHoldPo"));
1010         }
1011 
1012         if (canCreateReceiving()) {
1013             extraButtons.add((ExtraButton) buttonsMap.get("methodToCall.createReceivingLine"));
1014         }
1015 
1016         if (canSplitPo()) {
1017             extraButtons.add((ExtraButton) buttonsMap.get("methodToCall.splitPo"));
1018         }
1019 
1020         if (canContinuePoSplit()) {
1021             extraButtons.clear();
1022             extraButtons.add((ExtraButton) buttonsMap.get("methodToCall.continuePurchaseOrderSplit"));
1023             extraButtons.add((ExtraButton) buttonsMap.get("methodToCall.cancelPurchaseOrderSplit"));
1024         }
1025 
1026         if (canCancel()) {
1027             extraButtons.add((ExtraButton) buttonsMap.get("methodToCall.cancel"));
1028         }
1029 
1030         return extraButtons;
1031     }
1032 
1033 }
1034