Class ConsignmentToReallocateController

java.lang.Object
org.zkoss.zk.ui.event.GenericEventListener
org.zkoss.zk.ui.util.GenericComposer<T>
org.zkoss.zk.ui.util.GenericAutowireComposer<T>
org.zkoss.zk.ui.util.GenericForwardComposer<org.zkoss.zk.ui.Component>
com.hybris.cockpitng.util.ViewAnnotationAwareComposer
com.hybris.cockpitng.util.DefaultWidgetController
de.hybris.platform.warehousingbackoffice.widgets.consignment.ConsignmentToReallocateController
All Implemented Interfaces:
com.hybris.cockpitng.core.WidgetController, com.hybris.cockpitng.dnd.WidgetDragAndDropAware, com.hybris.cockpitng.engine.WidgetInstanceManagerAware, 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:
  • Field Details

  • Constructor Details

    • ConsignmentToReallocateController

      public ConsignmentToReallocateController()
  • Method Details

    • 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 InterruptedException
      Confirm the reallocation request
      Throws:
      InterruptedException
    • createDeclineEntry

      protected void createDeclineEntry(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(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(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(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(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, 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
    • cleanDeclineParam

      protected void cleanDeclineParam(ConsignmentProcessModel processModel)
      Removes the old decline entries from BusinessProcessModel.CONTEXTPARAMETERS(if any exists), before attempting to decline
      Parameters:
      processModel - the ConsignmentProcessModel for the consignment to be declined
    • 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 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 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, 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 Optional<DeclineReason> matchingComboboxDeclineReason(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(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
    • getConsignment

      protected ConsignmentModel getConsignment()
    • setConsignment

      public void setConsignment(ConsignmentModel consignment)
    • getEnumerationService

      protected EnumerationService getEnumerationService()
    • getConsignmentEntries

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

      protected WarehousingBusinessProcessService<ConsignmentModel> getConsignmentBusinessProcessService()
    • getModelService

      protected ModelService getModelService()
    • getCockpitLocaleService

      protected BackofficeLocaleService getCockpitLocaleService()
    • getCockpitEventQueue

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

      protected DefaultWarehouseStockService getWarehouseStockService()
    • getNotificationService

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