Class CancelOrderController

  • All Implemented Interfaces:
    com.hybris.cockpitng.core.WidgetController, com.hybris.cockpitng.dnd.WidgetDragAndDropAware, com.hybris.cockpitng.engine.WidgetInstanceManagerAware, java.io.Serializable, org.zkoss.zk.ui.event.EventListener, org.zkoss.zk.ui.event.SerializableEventListener, org.zkoss.zk.ui.util.ComponentActivationListener, org.zkoss.zk.ui.util.ComponentCloneListener, org.zkoss.zk.ui.util.Composer<org.zkoss.zk.ui.Component>, org.zkoss.zk.ui.util.ComposerExt<org.zkoss.zk.ui.Component>

    public class CancelOrderController
    extends com.hybris.cockpitng.util.DefaultWidgetController
    This controller creates a pop-up to cancel an order or its entries.
    See Also:
    Serialized Form
    • Field Detail

      • COMPLETED

        protected static final java.lang.Object COMPLETED
      • CUSTOMERSUPPORTBACKOFFICE_CANCELORDER_PICKUP

        protected static final java.lang.String CUSTOMERSUPPORTBACKOFFICE_CANCELORDER_PICKUP
        See Also:
        Constant Field Values
      • CUSTOMERSUPPORTBACKOFFICE_CANCELORDER_CONFIRM_TITLE

        protected static final java.lang.String CUSTOMERSUPPORTBACKOFFICE_CANCELORDER_CONFIRM_TITLE
        See Also:
        Constant Field Values
      • CUSTOMERSUPPORTBACKOFFICE_CANCELORDER_CONFIRM_ERROR

        protected static final java.lang.String CUSTOMERSUPPORTBACKOFFICE_CANCELORDER_CONFIRM_ERROR
        See Also:
        Constant Field Values
      • CUSTOMERSUPPORTBACKOFFICE_CANCELORDER_CONFIRM_MSG

        protected static final java.lang.String CUSTOMERSUPPORTBACKOFFICE_CANCELORDER_CONFIRM_MSG
        See Also:
        Constant Field Values
      • CUSTOMERSUPPORTBACKOFFICE_CANCELORDER_ERROR_QTYCANCELLED_INVALID

        protected static final java.lang.String CUSTOMERSUPPORTBACKOFFICE_CANCELORDER_ERROR_QTYCANCELLED_INVALID
        See Also:
        Constant Field Values
      • CUSTOMERSUPPORTBACKOFFICE_CANCELORDER_MISSING_QUANTITY

        protected static final java.lang.String CUSTOMERSUPPORTBACKOFFICE_CANCELORDER_MISSING_QUANTITY
        See Also:
        Constant Field Values
      • CUSTOMERSUPPORTBACKOFFICE_CANCELORDER_ERROR_REASON

        protected static final java.lang.String CUSTOMERSUPPORTBACKOFFICE_CANCELORDER_ERROR_REASON
        See Also:
        Constant Field Values
      • CUSTOMERSUPPORTBACKOFFICE_CANCELORDER_MISSING_SELECTED_LINE

        protected static final java.lang.String CUSTOMERSUPPORTBACKOFFICE_CANCELORDER_MISSING_SELECTED_LINE
        See Also:
        Constant Field Values
      • CANCELORDER_CONFIRM_ICON

        protected static final java.lang.String CANCELORDER_CONFIRM_ICON
        See Also:
        Constant Field Values
      • COLUMN_INDEX_PENDING_QUANTITY

        protected static final int COLUMN_INDEX_PENDING_QUANTITY
        See Also:
        Constant Field Values
      • COLUMN_INDEX_CANCEL_QUANTITY

        protected static final int COLUMN_INDEX_CANCEL_QUANTITY
        See Also:
        Constant Field Values
      • COLUMN_INDEX_CANCEL_REASON

        protected static final int COLUMN_INDEX_CANCEL_REASON
        See Also:
        Constant Field Values
      • COLUMN_INDEX_CANCEL_COMMENT

        protected static final int COLUMN_INDEX_CANCEL_COMMENT
        See Also:
        Constant Field Values
    • Constructor Detail

      • CancelOrderController

        public CancelOrderController()
    • Method Detail

      • confirmCancellation

        public void confirmCancellation()
        Confirm the cancel order request
      • initCancellationOrderForm

        public void initCancellationOrderForm​(OrderModel inputObject)
        Initialize the popup to cancel orders
        Parameters:
        inputObject - the order for which we want to cancel several entries
      • determineDeliveryMode

        protected java.lang.String determineDeliveryMode​(AbstractOrderEntryModel orderEntry)
        determines the delivery mode for a given orderEntry. A pick up Entry is an entry that have a DeliveryPointOfService, other wise we take the value from Entry DeliveryMode if not null, other wise we take the value from DeliveryMode on order level.
        Parameters:
        orderEntry - the AbstractOrderEntryModel for which to determine the delivery mode
        Returns:
        the delivery mode name for a given orderEntry
      • reset

        public void reset()
        Reinitialize the popup
      • addListeners

        protected void addListeners()
        Add listeners on Intbox, Combobox and Textbox so that when a change happens on one of these components, we are catching it.
      • applyToGrid

        protected void applyToGrid​(java.lang.Object data,
                                   int childrenIndex)
        Apply a value to the elements contained in the grid
        Parameters:
        data - the value to pass to the grid
        childrenIndex - the index indicating where to find the right component in the grid
      • applyToRow

        protected void applyToRow​(java.lang.Object data,
                                  int childrenIndex,
                                  org.zkoss.zk.ui.Component row)
        Apply a specific change to a specific row of the grid
        Parameters:
        data - the new value to set
        childrenIndex - the index of the component in the grid
        row - the row to which the change needs to be applied
      • autoSelect

        protected void autoSelect​(org.zkoss.zk.ui.event.Event event)
        Automatically select the checkbox in front of the row
        Parameters:
        event - the event that triggered the autoselect
      • buildCancelRequest

        protected OrderCancelRequest buildCancelRequest()
        Build the context parameter to cancel an order and return the given process
        Returns:
        a cancel request with the selected fields
      • getReasonIndex

        protected int getReasonIndex​(CancelReason cancelReason)
        Gets the reason index within the combobox model
        Parameters:
        cancelReason - the reason for which we want to know the index
        Returns:
        the index of the given cancel reason
      • getSelectedCancelReason

        protected java.util.Optional<CancelReason> getSelectedCancelReason​(org.zkoss.zk.ui.event.Event event)
        get the corresponding cancel reason according to the selected item in the combobox if existing
        Parameters:
        event - the select event on the combobox
        Returns:
        the corresponding cancel reason
      • handleGlobalCancelComment

        protected void handleGlobalCancelComment​(org.zkoss.zk.ui.event.Event event)
        Applies a global comment to all individual entries after an event is triggered
        Parameters:
        event - the on changing event that was triggered by the user
      • handleGlobalCancelReason

        protected void handleGlobalCancelReason​(org.zkoss.zk.ui.event.Event event)
        Applies a global reason to all individual entries after an event is triggered
        Parameters:
        event - the on select event that was triggered by the user
      • handleIndividualCancelReason

        protected void handleIndividualCancelReason​(org.zkoss.zk.ui.event.Event event)
        Applies a cancel reason to an individual entry after an event is triggered
        Parameters:
        event - the on select event that was triggered by the user
      • handleRow

        protected void handleRow​(org.zkoss.zul.Row row)
        Set or Reset the given row with the appropriate default information
        Parameters:
        row - the row to set/reset
      • getCustomSelectedCancelReason

        protected java.util.Optional<CancelReason> getCustomSelectedCancelReason​(org.zkoss.zk.ui.event.Event event)
        Gets the label for the selected cancel reason in case the event has a target of Combobox
        Parameters:
        event - the event that was fired
        Returns:
        the CancelReason corresponding to the label.
      • matchingComboboxCancelReason

        protected java.util.Optional<CancelReason> matchingComboboxCancelReason​(java.lang.String cancelReasonLabel)
        Retrieve the CancelReason according to the selected label in the combobox
        Parameters:
        cancelReasonLabel - a String representation of the reason
        Returns:
        the CancelReason corresponding to the label
      • processCancellation

        protected void processCancellation​(org.zkoss.zk.ui.event.Event obj)
        Process the cancellation Check if the user confirm the cancellation, then it sends the information to the service.
        Parameters:
        obj - the Event
      • selectAllEntries

        protected void selectAllEntries()
        Select or unselect all the rows of the grid and set the default values for each of them
      • showMessageBox

        protected void showMessageBox()
        Displays a message box whether the user wants to cancel the order
      • targetFieldToApplyValidation

        protected org.zkoss.zk.ui.Component targetFieldToApplyValidation​(java.lang.String stringToValidate,
                                                                         int indexLabelToCheck,
                                                                         int indexTargetComponent)
        Retrieve the row who needs to apply a validation message
        Parameters:
        stringToValidate - the string to compare to identify a specific row in the grid
        indexLabelToCheck - the index of the label to which we want to compare the passed string
        indexTargetComponent - the index of the grid where the target component is located
      • validateOrderEntry

        protected void validateOrderEntry​(OrderEntryToCancelDto entry)
        Validate each order entry and throw a WrongValueException if it fails any check
        Parameters:
        entry - the individual entry to validate
      • validateRequest

        protected void validateRequest()
        Check if the data provided by the form are compliant with the validation rules
      • getOrderEntriesGridRows

        protected java.util.List<org.zkoss.zk.ui.Component> getOrderEntriesGridRows()
      • getLocale

        protected java.util.Locale getLocale()
      • getOrderEntries

        protected org.zkoss.zul.Grid getOrderEntries()
      • getOrderModel

        protected OrderModel getOrderModel()
      • setOrderModel

        public void setOrderModel​(OrderModel orderModel)
      • getModelService

        protected ModelService getModelService()
      • getCockpitEventQueue

        protected com.hybris.cockpitng.core.events.CockpitEventQueue getCockpitEventQueue()
      • getUserService

        protected UserService getUserService()
      • getNotificationService

        protected com.hybris.cockpitng.util.notifications.NotificationService getNotificationService()