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,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.DefaultWidgetControllerThis 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 Summary
Fields Modifier and Type Field Description protected static intCOLUMN_INDEX_REALLOCATION_COMMENTprotected static intCOLUMN_INDEX_REALLOCATION_LOCATIONprotected static intCOLUMN_INDEX_REALLOCATION_QUANTITYprotected static intCOLUMN_INDEX_REALLOCATION_REASONprotected static java.lang.ObjectCOMPLETEDprotected static java.lang.StringCONSIGNMENT_ACTION_EVENT_NAMEprotected static java.lang.StringDECLINE_ENTRIESprotected static java.lang.StringIN_SOCKETprotected static java.lang.StringOUT_CONFIRMprotected static java.lang.StringREALLOCATE_CONSIGNMENT_CHOICE
-
Constructor Summary
Constructors Constructor Description ConsignmentToReallocateController()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddListeners()Add listeners on Intbox, Combobox and Textbox so that when a change happens on one of these components, we are catching it.protected voidapplyToCheckboxRow(java.lang.Object data, org.zkoss.zk.ui.Component component)Applies a specific change if the current element is a checkboxprotected voidapplyToComboboxRow(java.lang.Object data, org.zkoss.zk.ui.Component component)Applies a specific change if the current element is a comboboxprotected voidapplyToGrid(java.lang.Object data, int childrenIndex)Apply a value to the elements contained in the gridprotected voidapplyToRow(java.lang.Object data, int childrenIndex, org.zkoss.zk.ui.Component row)Apply a specific change to a specific row of the gridprotected voidautoSelect(org.zkoss.zk.ui.event.Event event)Automatically select the checkbox in front of the rowprotected voidbuildDeclineParam(ConsignmentProcessModel processModel, java.util.Collection<DeclineEntry> entriesToReallocate)Build and save the context parameter for decline entries and set it into the given processprotected voidcleanDeclineParam(ConsignmentProcessModel processModel)Removes the old decline entries fromBusinessProcessModel.CONTEXTPARAMETERS(if any exists), before attempting to declinevoidconfirmReallocation()Confirm the reallocation requestprotected voidcreateDeclineEntry(java.util.Collection<DeclineEntry> entriesToReallocate, org.zkoss.zk.ui.Component component)Creates a decline entry for the current rowprotected com.hybris.cockpitng.core.events.CockpitEventQueuegetCockpitEventQueue()protected BackofficeLocaleServicegetCockpitLocaleService()protected ConsignmentModelgetConsignment()protected WarehousingBusinessProcessService<ConsignmentModel>getConsignmentBusinessProcessService()protected org.zkoss.zul.GridgetConsignmentEntries()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 Comboboxprotected EnumerationServicegetEnumerationService()protected intgetLocationIndex(WarehouseModel location)Gets the location index within the combobox modelprotected ModelServicegetModelService()protected com.hybris.backoffice.widgets.notificationarea.NotificationServicegetNotificationService()protected intgetReasonIndex(DeclineReason declineReason)Gets the reason index within the combobox modelprotected 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 existingprotected WarehouseModelgetSelectedLocation(org.zkoss.zk.ui.event.Event event)Get the corresponding warehouse location according to the selected item in the combobox if anything is selectedprotected DefaultWarehouseStockServicegetWarehouseStockService()protected voidhandleGlobalComment(org.zkoss.zk.ui.event.Event event)Updates all entries with the selected global commentprotected voidhandleGlobalLocation(org.zkoss.zk.ui.event.Event event)Updates all entries with the selected global locationprotected voidhandleGlobalReason(org.zkoss.zk.ui.event.Event event)Updates all entries with the selected global reasonprotected voidhandleIndividualLocation(org.zkoss.zk.ui.event.Event event)Updates an individual entry with the selected locationprotected voidhandleIndividualReason(org.zkoss.zk.ui.event.Event event)Updates an individual entry with the selected reasonprotected voidhandleRow(org.zkoss.zul.Row row)Set or Reset the given row with the appropriate default informationsvoidinitReallocationConsignmentForm(ConsignmentModel inputObject)Initialize the popup to reallocate consignment entriesprotected booleanisDeclinedQuantityCorrect(ConsignmentModel latestConsignmentModel, DeclineEntry declineEntry)Check if the declined quantity of the passed consignment model matches the expected quantity to be declined.protected booleanisDeclineProcessDone(ConsignmentModel latestConsignmentModel, java.util.Collection<DeclineEntry> entriesToReallocate)Check if the decline process is done or not.protected java.util.Optional<DeclineReason>matchingComboboxDeclineReason(java.lang.String declineReasonLabel)Retrieve theDeclineReasonaccording to the selected label in the comboboxvoidreset()Reinitialize the popup.protected voidselectAllEntries()Select or unselect all the rows of the grid and sets the default values for each of them.voidsetConsignment(ConsignmentModel consignment)protected org.zkoss.zk.ui.ComponenttargetFieldToApplyValidation(java.lang.String stringToValidate, int indexLabelToCheck, int indexTargetComponent)Retrieve the row who needs to apply a validation messageprotected voidvalidateConsignmentEntry(ConsignmentEntryToReallocateDto entry)Validate each consignment entry and throw aWrongValueExceptionif it fails any checkprotected voidvalidateRequest()Check if the data provided by the form are compliant with the validation rules-
Methods inherited from class com.hybris.cockpitng.util.DefaultWidgetController
doAfterCompose, doBeforeCompose, doBeforeComposeChildren, executeOperation, getDragAndDropStrategy, getLabel, getLabel, getModel, getValue, getWidgetDragAndDropStrategyRepository, getWidgetInstanceManager, getWidgetRoot, getWidgetSettings, getWidgetslot, getWidgetTitle, getWidgetUtils, initDragAndDropAwareness, initialize, initWidgetSetting, initWidgetSetting, initWidgetSetting, initWidgetSetting, initWidgetSetting, invokeListenerMethod, onSocketInput, preInitialize, sendOutput, sendOutputAfterOperation, sendOutputAfterOperation, sendOutputAfterOperation, setValue, setWidgetInstanceManager, setWidgetTitle
-
Methods inherited from class com.hybris.cockpitng.util.ViewAnnotationAwareComposer
scanEventListeners
-
Methods inherited from class org.zkoss.zk.ui.util.GenericAutowireComposer
alert, didActivate, getPage, willClone, willPassivate
-
-
-
-
Field Detail
-
IN_SOCKET
protected static final java.lang.String IN_SOCKET
- See Also:
- Constant Field Values
-
OUT_CONFIRM
protected static final java.lang.String OUT_CONFIRM
- See Also:
- Constant Field Values
-
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
-
-
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.InterruptedExceptionConfirm 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 tocomponent- 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 gridchildrenIndex- 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 setchildrenIndex- the index of the component in the gridrow- 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 appliedcomponent- 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 appliedcomponent- 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 registerentriesToReallocate- the entries to be reallocated
-
cleanDeclineParam
protected void cleanDeclineParam(ConsignmentProcessModel processModel)
Removes the old decline entries fromBusinessProcessModel.CONTEXTPARAMETERS(if any exists), before attempting to decline- Parameters:
processModel- theConsignmentProcessModelfor 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 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 modelentriesToReallocate- 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 theDeclineReasonaccording to the selected label in the combobox- Parameters:
declineReasonLabel- aString- 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 gridindexLabelToCheck- the index of the label to which we want to compare the passed stringindexTargetComponent- the index of the grid where the target component is located
-
validateConsignmentEntry
protected void validateConsignmentEntry(ConsignmentEntryToReallocateDto entry)
Validate each consignment entry and throw aWrongValueExceptionif 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()
-
-