Class UiStatusSync
- java.lang.Object
-
- de.hybris.platform.sap.productconfig.frontend.util.impl.UiStatusSync
-
public class UiStatusSync extends java.lang.ObjectUsed to sync the configuration DTO (which has request scope) with the UIStatus which we store in the session
-
-
Constructor Summary
Constructors Constructor Description UiStatusSync()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplyUiStatusToConfiguration(ConfigurationData configData, UiStatus uiStatus)Updates the configuration DTO with the UI state (e.g.voidapplyUiStatusToConfiguration(ConfigurationData configData, UiStatus uiStatus, java.lang.String selectedGroup)Updates the configuration DTO with the UI state (e.g.protected voidapplyUiStatusToCstic(UiCsticStatus uiCsticStatus, CsticData csticData)protected <T,K>
voidapplyUiStatusToData(java.util.List<T> uiStatusList, java.util.List<K> dataList, java.util.function.BiPredicate<T,K> idMatch, java.util.function.BiConsumer<T,K> applyMethod)protected voidapplyUiStatusToUiGroup(java.util.List<UiGroupStatus> uiGroupsStatus, java.util.List<UiGroupData> uiGroups)protected voidexpandGroupAndCollapseOther(ConfigurationData configData, java.lang.String selectedGroup)protected voidexpandGroupAndCollapseOther(java.lang.String selectedGroup, java.util.List<UiGroupStatus> groups)protected voidexpandGroupInSpecTreeAndExpandGroup(UiStatus uiStatus)Expand the group in spec tree and expand the group itselfUiStatusextractUiStatusFromConfiguration(ConfigurationData configData)Updates UI status with the current state of the configuration DTOprotected java.util.List<UiCsticStatus>extractUiStatusFromCstic(java.util.List<CsticData> cstics)protected java.util.List<UiCsticValueStatus>extractUiStatusFromCsticValue(java.util.List<CsticValueData> domainvalues)protected java.util.List<UiPromoMessageStatus>extractUiStatusFromMessages(java.util.List<ProductConfigMessageData> messages)protected voidextractUiStatusFromUiGroup(java.util.List<UiGroupData> uiGroups, java.util.List<UiGroupStatus> uiGroupsStatus, ConfigurationData configData)protected UiGroupStatusfindStatusGroup(java.util.List<UiGroupStatus> uiStatusGroups, UiGroupData requestGroup, int groupIdx)protected UiGroupStatusfindStatusGroupForExisting(java.util.List<UiGroupStatus> uiSateGroups, UiGroupData requestGroup, int groupIdx)protected <T> java.util.Optional<T>findStatusValue(@NotNull java.util.List<T> statusValues, java.util.function.Predicate<T> idMatch)protected <T> java.util.Optional<T>findStatusValue(@NotNull java.util.List<T> statusValues, java.util.function.Predicate<T> idMatch, int index)protected java.lang.StringgetMessageId(ProductConfigMessageData message)protected java.util.List<UiPromoMessageStatus>getMessgesForCsticValue(java.lang.String csticValueKey, java.util.List<UiCsticValueStatus> uiCsticValueStatuses)intgetNumberOfConflicts(ConfigurationData configData)Determine number of conflicts by calculating the conflict groupsprotected voidhandleCPQAction(ConfigurationData requestData, UiStatus oldUiState, UiTrackingRecorder uiTrackingRecorder)protected booleanhasCstics(UiGroupData uiGroup)protected booleanhasCsticValues(CsticData cstic)protected booleanhasSubGroups(UiGroupData uiGroup)protected booleanisNavigationAction(CPQActionType cpqAction)protected booleannotNullAndNotEmpty(java.lang.String id)protected booleannotNullAndNotEmpty(java.util.List subGroups)protected java.lang.StringreplaceNewLineForLog(java.lang.String str)protected voidsetInitialCsticStatus(java.util.List<CsticData> cstics)protected voidsetInitialGroupStatus(java.util.List<UiGroupData> uiGroups, int level)voidsetInitialStatus(ConfigurationData configData)Provides the configuration DTO with UI relevant settings valid in its initial stateprotected voidstoreLastNoneConflictGroupId(UiStatus newUiState, ConfigurationData requestData)protected UiGroupStatustoggleGroup(java.lang.String groupIdToToggle, java.util.List<UiGroupStatus> groups, boolean forceExpand)Recursively checks a group hierarchy.protected UiGroupStatustoggleGroupInSpecTree(java.lang.String groupIdToToggle, java.util.List<UiGroupStatus> groups, boolean forceExpand)protected voidtoggleParentGroupInSpecTreeIfNeeded(UiGroupStatus toggledGroup, UiGroupStatus parentGroup)protected booleantoggleParentIfNeeded(UiGroupStatus toggledGroup, UiGroupStatus parentGroup)protected voidtoggleShowExtendedMessageOnStatusCstics(java.lang.String csticKey, java.lang.String csticValueKey, java.lang.String messageKey, java.util.List<UiCsticStatus> uiCsticsStatus)voidtoggleShowExtendedMessageOnUIStatusGroups(java.lang.String csticKey, java.lang.String csticValueKey, java.lang.String messageKey, java.util.List<UiGroupStatus> uiStatusGroups)protected booleanuiStatusGroupMatchesUiGroup(UiGroupData uiGroup, UiGroupStatus uiStatusGroup)protected voidupdateCsticUIStatusFromRequestData(java.util.List<UiCsticStatus> statusCstics, java.util.List<CsticData> requestCstics)protected voidupdateCsticValueUIStatusFromRequestData(java.util.List<UiCsticValueStatus> statusCsticValues, java.util.List<CsticValueData> requestCsticValues)protected voidupdateGroupUIStatusFromRequestData(java.util.List<UiGroupStatus> uiSateGroups, java.util.List<UiGroupData> requestGroups)protected voidupdateMessagesUiStatusFromRequestData(java.util.List<UiPromoMessageStatus> statusMessages, java.util.List<ProductConfigMessageData> requestMessages)voidupdateNewUiStateFromOld(UiStatus oldUiStatus, UiStatus uiStatus)Update old UI statusprotected voidupdateShowFullLongTextInUiStatusCstics(java.lang.String csticKey, boolean showFullLongText, java.util.List<UiCsticStatus> uiCsticsStatus)voidupdateShowFullLongTextinUIStatusGroups(java.lang.String csticKey, boolean showFullLongText, java.util.List<UiGroupStatus> uiStatusGroups)Update the flag of the show long full text in UI status groupsprotected voidupdateSingleStatusGroupFromRequest(UiGroupData requestGroup, UiGroupStatus statusGroup)UiStatusupdateUIStatusFromRequest(ConfigurationData requestData, UiStatus oldUiState, UiTrackingRecorder uiTrackingRecorder)Apply user changes to the UI status (session) object.
-
-
-
Method Detail
-
applyUiStatusToConfiguration
public void applyUiStatusToConfiguration(ConfigurationData configData, UiStatus uiStatus, java.lang.String selectedGroup)
Updates the configuration DTO with the UI state (e.g. which group is collapsed/opened, which has been visited already). Takes care of the currently selected group and expands it- Parameters:
configData-uiStatus- UI status (session scope)selectedGroup- ID of the currently selected group
-
expandGroupAndCollapseOther
protected void expandGroupAndCollapseOther(ConfigurationData configData, java.lang.String selectedGroup)
-
applyUiStatusToConfiguration
public void applyUiStatusToConfiguration(ConfigurationData configData, UiStatus uiStatus)
Updates the configuration DTO with the UI state (e.g. which group is collapsed/opened, which has been visited already).- Parameters:
configData-uiStatus- UI status (session scope)
-
isNavigationAction
protected boolean isNavigationAction(CPQActionType cpqAction)
-
expandGroupInSpecTreeAndExpandGroup
protected void expandGroupInSpecTreeAndExpandGroup(UiStatus uiStatus)
Expand the group in spec tree and expand the group itself- Parameters:
uiStatus-
-
applyUiStatusToUiGroup
protected void applyUiStatusToUiGroup(java.util.List<UiGroupStatus> uiGroupsStatus, java.util.List<UiGroupData> uiGroups)
-
updateShowFullLongTextinUIStatusGroups
public void updateShowFullLongTextinUIStatusGroups(java.lang.String csticKey, boolean showFullLongText, java.util.List<UiGroupStatus> uiStatusGroups)Update the flag of the show long full text in UI status groups- Parameters:
csticKey- characteristic keyshowFullLongText- show full long textuiStatusGroups- list of UI status groups
-
toggleShowExtendedMessageOnUIStatusGroups
public void toggleShowExtendedMessageOnUIStatusGroups(java.lang.String csticKey, java.lang.String csticValueKey, java.lang.String messageKey, java.util.List<UiGroupStatus> uiStatusGroups)- Parameters:
csticKey- characteristic keycsticValueKey- characteristic value keymessageKey- message keyuiStatusGroups- list of UI status groups
-
applyUiStatusToData
protected <T,K> void applyUiStatusToData(java.util.List<T> uiStatusList, java.util.List<K> dataList, java.util.function.BiPredicate<T,K> idMatch, java.util.function.BiConsumer<T,K> applyMethod)
-
applyUiStatusToCstic
protected void applyUiStatusToCstic(UiCsticStatus uiCsticStatus, CsticData csticData)
-
updateShowFullLongTextInUiStatusCstics
protected void updateShowFullLongTextInUiStatusCstics(java.lang.String csticKey, boolean showFullLongText, java.util.List<UiCsticStatus> uiCsticsStatus)
-
toggleShowExtendedMessageOnStatusCstics
protected void toggleShowExtendedMessageOnStatusCstics(@Nonnull java.lang.String csticKey, java.lang.String csticValueKey, @Nonnull java.lang.String messageKey, java.util.List<UiCsticStatus> uiCsticsStatus)
-
getMessgesForCsticValue
protected java.util.List<UiPromoMessageStatus> getMessgesForCsticValue(java.lang.String csticValueKey, java.util.List<UiCsticValueStatus> uiCsticValueStatuses)
-
setInitialStatus
public void setInitialStatus(ConfigurationData configData)
Provides the configuration DTO with UI relevant settings valid in its initial state- Parameters:
configData-
-
setInitialGroupStatus
protected void setInitialGroupStatus(java.util.List<UiGroupData> uiGroups, int level)
-
setInitialCsticStatus
protected void setInitialCsticStatus(java.util.List<CsticData> cstics)
-
hasSubGroups
protected boolean hasSubGroups(UiGroupData uiGroup)
-
notNullAndNotEmpty
protected boolean notNullAndNotEmpty(java.util.List subGroups)
-
hasCstics
protected boolean hasCstics(UiGroupData uiGroup)
-
extractUiStatusFromConfiguration
public UiStatus extractUiStatusFromConfiguration(ConfigurationData configData)
Updates UI status with the current state of the configuration DTO- Parameters:
configData-- Returns:
- UI status which we put into the session to persist the currently selected group e.g.
-
getNumberOfConflicts
public int getNumberOfConflicts(ConfigurationData configData)
Determine number of conflicts by calculating the conflict groups- Parameters:
configData-- Returns:
- Number of conflict groups
-
toggleGroup
protected UiGroupStatus toggleGroup(java.lang.String groupIdToToggle, java.util.List<UiGroupStatus> groups, boolean forceExpand)
Recursively checks a group hierarchy. If a group is found that matches the given group id its collapsed state is Toggled. If the toggle was an expand, all parent groups are expanded as well.- Parameters:
groupIdToToggle- id of group to togglegroups- list of groups to checkforceExpand-- Returns:
- the goup that was toggled, or
nullif no group with the given ID was found.
-
toggleParentIfNeeded
protected boolean toggleParentIfNeeded(UiGroupStatus toggledGroup, UiGroupStatus parentGroup)
-
toggleGroupInSpecTree
protected UiGroupStatus toggleGroupInSpecTree(java.lang.String groupIdToToggle, java.util.List<UiGroupStatus> groups, boolean forceExpand)
-
toggleParentGroupInSpecTreeIfNeeded
protected void toggleParentGroupInSpecTreeIfNeeded(UiGroupStatus toggledGroup, UiGroupStatus parentGroup)
-
expandGroupAndCollapseOther
protected void expandGroupAndCollapseOther(java.lang.String selectedGroup, java.util.List<UiGroupStatus> groups)
-
extractUiStatusFromUiGroup
protected void extractUiStatusFromUiGroup(java.util.List<UiGroupData> uiGroups, java.util.List<UiGroupStatus> uiGroupsStatus, ConfigurationData configData)
-
extractUiStatusFromCstic
protected java.util.List<UiCsticStatus> extractUiStatusFromCstic(java.util.List<CsticData> cstics)
-
extractUiStatusFromMessages
protected java.util.List<UiPromoMessageStatus> extractUiStatusFromMessages(java.util.List<ProductConfigMessageData> messages)
-
getMessageId
protected java.lang.String getMessageId(ProductConfigMessageData message)
-
extractUiStatusFromCsticValue
protected java.util.List<UiCsticValueStatus> extractUiStatusFromCsticValue(java.util.List<CsticValueData> domainvalues)
-
hasCsticValues
protected boolean hasCsticValues(CsticData cstic)
-
updateUIStatusFromRequest
public UiStatus updateUIStatusFromRequest(ConfigurationData requestData, UiStatus oldUiState, UiTrackingRecorder uiTrackingRecorder)
Apply user changes to the UI status (session) object. User might e.g. open a group which was not visited before- Parameters:
requestData-oldUiState- Previous version of the UI statusuiTrackingRecorder- recorder for ui activities- Returns:
- New version of the UI status
-
storeLastNoneConflictGroupId
protected void storeLastNoneConflictGroupId(UiStatus newUiState, ConfigurationData requestData)
-
handleCPQAction
protected void handleCPQAction(ConfigurationData requestData, UiStatus oldUiState, UiTrackingRecorder uiTrackingRecorder)
-
notNullAndNotEmpty
protected boolean notNullAndNotEmpty(java.lang.String id)
-
updateGroupUIStatusFromRequestData
protected void updateGroupUIStatusFromRequestData(java.util.List<UiGroupStatus> uiSateGroups, java.util.List<UiGroupData> requestGroups)
-
updateSingleStatusGroupFromRequest
protected void updateSingleStatusGroupFromRequest(UiGroupData requestGroup, UiGroupStatus statusGroup)
-
updateCsticUIStatusFromRequestData
protected void updateCsticUIStatusFromRequestData(java.util.List<UiCsticStatus> statusCstics, java.util.List<CsticData> requestCstics)
-
updateCsticValueUIStatusFromRequestData
protected void updateCsticValueUIStatusFromRequestData(java.util.List<UiCsticValueStatus> statusCsticValues, java.util.List<CsticValueData> requestCsticValues)
-
updateMessagesUiStatusFromRequestData
protected void updateMessagesUiStatusFromRequestData(java.util.List<UiPromoMessageStatus> statusMessages, java.util.List<ProductConfigMessageData> requestMessages)
-
findStatusValue
protected <T> java.util.Optional<T> findStatusValue(@NotNull @NotNull java.util.List<T> statusValues, java.util.function.Predicate<T> idMatch)
-
findStatusValue
protected <T> java.util.Optional<T> findStatusValue(@NotNull @NotNull java.util.List<T> statusValues, java.util.function.Predicate<T> idMatch, int index)
-
findStatusGroup
protected UiGroupStatus findStatusGroup(java.util.List<UiGroupStatus> uiStatusGroups, UiGroupData requestGroup, int groupIdx)
-
findStatusGroupForExisting
protected UiGroupStatus findStatusGroupForExisting(java.util.List<UiGroupStatus> uiSateGroups, UiGroupData requestGroup, int groupIdx)
-
uiStatusGroupMatchesUiGroup
protected boolean uiStatusGroupMatchesUiGroup(UiGroupData uiGroup, UiGroupStatus uiStatusGroup)
-
replaceNewLineForLog
protected java.lang.String replaceNewLineForLog(java.lang.String str)
-
-