Class UiStatusSync


  • public class UiStatusSync
    extends java.lang.Object
    Used to sync the configuration DTO (which has request scope) with the UIStatus which we store in the session
    • Constructor Detail

      • UiStatusSync

        public UiStatusSync()
    • 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 key
        showFullLongText - show full long text
        uiStatusGroups - 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 key
        csticValueKey - characteristic value key
        messageKey - message key
        uiStatusGroups - 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 toggle
        groups - list of groups to check
        forceExpand -
        Returns:
        the goup that was toggled, or null if no group with the given ID was found.
      • 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)
      • extractUiStatusFromCstic

        protected java.util.List<UiCsticStatus> extractUiStatusFromCstic​(java.util.List<CsticData> cstics)
      • 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 status
        uiTrackingRecorder - recorder for ui activities
        Returns:
        New version of the UI status
      • storeLastNoneConflictGroupId

        protected void storeLastNoneConflictGroupId​(UiStatus newUiState,
                                                    ConfigurationData requestData)
      • 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)
      • 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)
      • uiStatusGroupMatchesUiGroup

        protected boolean uiStatusGroupMatchesUiGroup​(UiGroupData uiGroup,
                                                      UiGroupStatus uiStatusGroup)
      • replaceNewLineForLog

        protected java.lang.String replaceNewLineForLog​(java.lang.String str)
      • updateNewUiStateFromOld

        public void updateNewUiStateFromOld​(UiStatus oldUiStatus,
                                            UiStatus uiStatus)
        Update old UI status
        Parameters:
        oldUiStatus - old UI status
        uiStatus - new UI status