Class ConsignmentToReallocateController

  • 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 ConsignmentToReallocateController
    extends com.hybris.cockpitng.util.DefaultWidgetController
    This controller creates a pop-up to reallocate part or entire consignment. It offers to select manually the new location where to reallocate. If not specified, the reallocation will be automatic. It also offers to set the reason for the decline as well as an optional comment.
    See Also:
    Serialized Form
    • Field Detail

      • COMPLETED

        protected static final java.lang.Object COMPLETED
      • CONSIGNMENT_ACTION_EVENT_NAME

        protected static final java.lang.String CONSIGNMENT_ACTION_EVENT_NAME
        See Also:
        Constant Field Values
      • REALLOCATE_CONSIGNMENT_CHOICE

        protected static final java.lang.String REALLOCATE_CONSIGNMENT_CHOICE
        See Also:
        Constant Field Values
      • DECLINE_ENTRIES

        protected static final java.lang.String DECLINE_ENTRIES
        See Also:
        Constant Field Values
      • COLUMN_INDEX_REALLOCATION_QUANTITY

        protected static final int COLUMN_INDEX_REALLOCATION_QUANTITY
        See Also:
        Constant Field Values
      • COLUMN_INDEX_REALLOCATION_REASON

        protected static final int COLUMN_INDEX_REALLOCATION_REASON
        See Also:
        Constant Field Values
      • COLUMN_INDEX_REALLOCATION_LOCATION

        protected static final int COLUMN_INDEX_REALLOCATION_LOCATION
        See Also:
        Constant Field Values
      • COLUMN_INDEX_REALLOCATION_COMMENT

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

      • ConsignmentToReallocateController

        public ConsignmentToReallocateController()
    • Method Detail

      • initReallocationConsignmentForm

        public void initReallocationConsignmentForm​(ConsignmentModel inputObject)
        Initialize the popup to reallocate consignment entries
        Parameters:
        inputObject - the consignment for which we want to ask for one or several reallocation(s)
      • confirmReallocation

        public void confirmReallocation()
                                 throws java.lang.InterruptedException
        Confirm the reallocation request
        Throws:
        java.lang.InterruptedException
      • createDeclineEntry

        protected void createDeclineEntry​(java.util.Collection<DeclineEntry> entriesToReallocate,
                                          org.zkoss.zk.ui.Component component)
        Creates a decline entry for the current row
        Parameters:
        entriesToReallocate - the list to which the newly created decline entry will be added to
        component - the current row from which the decline entry will be created
      • 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
      • applyToComboboxRow

        protected void applyToComboboxRow​(java.lang.Object data,
                                          org.zkoss.zk.ui.Component component)
        Applies a specific change if the current element is a combobox
        Parameters:
        data - the element for which the change has to be applied
        component - the component which will have the change applied
      • applyToCheckboxRow

        protected void applyToCheckboxRow​(java.lang.Object data,
                                          org.zkoss.zk.ui.Component component)
        Applies a specific change if the current element is a checkbox
        Parameters:
        data - the element for which the change has to be applied
        component - the component which will have the change 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
      • buildDeclineParam

        protected void buildDeclineParam​(ConsignmentProcessModel processModel,
                                         java.util.Collection<DeclineEntry> entriesToReallocate)
        Build and save the context parameter for decline entries and set it into the given process
        Parameters:
        processModel - the process model for which the context parameters has to be register
        entriesToReallocate - the entries to be reallocated
      • getLocationIndex

        protected int getLocationIndex​(WarehouseModel location)
        Gets the location index within the combobox model
        Parameters:
        location - the location which the item(s) will be reallocated to
        Returns:
        the index of the given location
      • getReasonIndex

        protected int getReasonIndex​(DeclineReason declineReason)
        Gets the reason index within the combobox model
        Parameters:
        declineReason - the reason for which we want to know the index
        Returns:
        the index of the given decline reason
      • getSelectedDeclineReason

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

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

        protected WarehouseModel getSelectedLocation​(org.zkoss.zk.ui.event.Event event)
        Get the corresponding warehouse location according to the selected item in the combobox if anything is selected
        Parameters:
        event - the select event on the combobox
        Returns:
        the corresponding warehouse location
      • handleGlobalComment

        protected void handleGlobalComment​(org.zkoss.zk.ui.event.Event event)
        Updates all entries with the selected global comment
        Parameters:
        event - the event that triggered the change
      • handleGlobalLocation

        protected void handleGlobalLocation​(org.zkoss.zk.ui.event.Event event)
        Updates all entries with the selected global location
        Parameters:
        event - the event that triggered the change
      • handleGlobalReason

        protected void handleGlobalReason​(org.zkoss.zk.ui.event.Event event)
        Updates all entries with the selected global reason
        Parameters:
        event - the event that triggered the change
      • handleIndividualReason

        protected void handleIndividualReason​(org.zkoss.zk.ui.event.Event event)
        Updates an individual entry with the selected reason
        Parameters:
        event - the event that triggered the change
      • handleIndividualLocation

        protected void handleIndividualLocation​(org.zkoss.zk.ui.event.Event event)
        Updates an individual entry with the selected location
        Parameters:
        event - the event that triggered the change
      • handleRow

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

        protected boolean isDeclineProcessDone​(ConsignmentModel latestConsignmentModel,
                                               java.util.Collection<DeclineEntry> entriesToReallocate)
        Check if the decline process is done or not.
        Parameters:
        latestConsignmentModel - the updated consignment model
        entriesToReallocate - the entries to be reallocated
        Returns:
        true if the process is done. Otherwise false
      • isDeclinedQuantityCorrect

        protected boolean isDeclinedQuantityCorrect​(ConsignmentModel latestConsignmentModel,
                                                    DeclineEntry declineEntry)
        Check if the declined quantity of the passed consignment model matches the expected quantity to be declined.
        Parameters:
        latestConsignmentModel -
        declineEntry -
        Returns:
        true if the declined quantity is matching the expected declined quantity. Otherwise, returns false.
      • matchingComboboxDeclineReason

        protected java.util.Optional<DeclineReason> matchingComboboxDeclineReason​(java.lang.String declineReasonLabel)
        Retrieve the DeclineReason according to the selected label in the combobox
        Parameters:
        declineReasonLabel - a String
        Returns:
        the decline reason corresponding to the label
      • selectAllEntries

        protected void selectAllEntries()
        Select or unselect all the rows of the grid and sets the default values for each of them.
      • 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
      • validateConsignmentEntry

        protected void validateConsignmentEntry​(ConsignmentEntryToReallocateDto entry)
        Validate each consignment 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
      • getConsignmentEntries

        protected org.zkoss.zul.Grid getConsignmentEntries()
      • getModelService

        protected ModelService getModelService()
      • getCockpitEventQueue

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

        protected com.hybris.backoffice.widgets.notificationarea.NotificationService getNotificationService()