Class CancelOrderController
- 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.omsbackoffice.widgets.order.cancelorder.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.DefaultWidgetControllerThis controller creates a pop-up to cancel an order or its entries.- See Also:
- Serialized Form
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description CancelOrderController()
-
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 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 OrderCancelRequestbuildCancelRequest()Build the context parameter to cancel an order and return the given processvoidconfirmCancellation()Confirm the cancel order requestprotected voidcreateOrderCancelEntry(java.util.List<OrderCancelEntry> orderCancelEntries, java.lang.Object entry)Creates anOrderCancelEntryprotected java.lang.StringdetermineDeliveryMode(AbstractOrderEntryModel orderEntry)determines the delivery mode for a given orderEntry.protected com.hybris.cockpitng.core.events.CockpitEventQueuegetCockpitEventQueue()protected BackofficeLocaleServicegetCockpitLocaleService()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 Comboboxprotected EnumerationServicegetEnumerationService()protected java.util.LocalegetLocale()protected ModelServicegetModelService()protected com.hybris.cockpitng.util.notifications.NotificationServicegetNotificationService()protected OrderCancelServicegetOrderCancelService()protected org.zkoss.zul.GridgetOrderEntries()protected java.util.List<org.zkoss.zk.ui.Component>getOrderEntriesGridRows()protected OrderModelgetOrderModel()protected intgetReasonIndex(CancelReason cancelReason)Gets the reason index within the combobox modelprotected 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 existingprotected UserServicegetUserService()protected voidhandleGlobalCancelComment(org.zkoss.zk.ui.event.Event event)Applies a global comment to all individual entries after an event is triggeredprotected voidhandleGlobalCancelReason(org.zkoss.zk.ui.event.Event event)Applies a global reason to all individual entries after an event is triggeredprotected voidhandleIndividualCancelReason(org.zkoss.zk.ui.event.Event event)Applies a cancel reason to an individual entry after an event is triggeredprotected voidhandleRow(org.zkoss.zul.Row row)Set or Reset the given row with the appropriate default informationvoidinitCancellationOrderForm(OrderModel inputObject)Initialize the popup to cancel ordersprotected java.util.Optional<CancelReason>matchingComboboxCancelReason(java.lang.String cancelReasonLabel)Retrieve theCancelReasonaccording to the selected label in the comboboxprotected voidprocessCancellation(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.voidreset()Reinitialize the popupprotected voidselectAllEntries()Select or unselect all the rows of the grid and set the default values for each of themvoidsetOrderModel(OrderModel orderModel)protected voidshowMessageBox()Displays a message box whether the user wants to cancel the orderprotected org.zkoss.zk.ui.ComponenttargetFieldToApplyValidation(java.lang.String stringToValidate, int indexLabelToCheck, int indexTargetComponent)Retrieve the row who needs to apply a validation messageprotected voidvalidateOrderEntry(OrderEntryToCancelDto entry)Validate each order 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
-
CONFIRM_ID
protected static final java.lang.String CONFIRM_ID
- See Also:
- Constant Field Values
-
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
-
-
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- theAbstractOrderEntryModelfor 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 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
-
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
-
createOrderCancelEntry
protected void createOrderCancelEntry(java.util.List<OrderCancelEntry> orderCancelEntries, java.lang.Object entry)
Creates anOrderCancelEntry- Parameters:
orderCancelEntries- the list which contains allOrderCancelEntryentry- the entry to be converted into aOrderCancelEntry
-
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 theCancelReasonaccording to the selected label in the combobox- Parameters:
cancelReasonLabel- aStringrepresentation 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- theEvent
-
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 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
-
validateOrderEntry
protected void validateOrderEntry(OrderEntryToCancelDto entry)
Validate each order 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
-
getOrderEntriesGridRows
protected java.util.List<org.zkoss.zk.ui.Component> getOrderEntriesGridRows()
-
getLocale
protected java.util.Locale getLocale()
-
getCockpitLocaleService
protected BackofficeLocaleService getCockpitLocaleService()
-
getOrderEntries
protected org.zkoss.zul.Grid getOrderEntries()
-
getOrderModel
protected OrderModel getOrderModel()
-
setOrderModel
public void setOrderModel(OrderModel orderModel)
-
getOrderCancelService
protected OrderCancelService getOrderCancelService()
-
getEnumerationService
protected EnumerationService getEnumerationService()
-
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()
-
-