Class DecimalSplitSortPositionStrategy<P>

java.lang.Object
com.broadleafcommerce.data.tracking.core.sort.DecimalSplitSortPositionStrategy<P>
All Implemented Interfaces:
SortPositionStrategy<P>

public class DecimalSplitSortPositionStrategy<P> extends Object implements SortPositionStrategy<P>
Specialized version of SortPositionStrategy that uses a decimal splitting strategy along with a String field representation for collation-based sorting.

The key principals of this implementation are:

  • No resequencing of records is required
  • The sort value is specified as a String, which allows for larger expansion than most database numeric types
  • Unspecified sort fields are expected to have a 'z' value. They will appear last in the sort.
  • Extreme quantity of splitting at the same position can conceivably exceed the amount of space allowed by the database for the large BigDecimal expansion, but it is unlikely to occur.

This implementation uses the DecimalField class to convert a BigDecimal to a lexicographically sortable version (an vice versa). Splitting math is performed with a BigDecimal, and then converted to the String representation for the sort field value.

Author:
Jeff Fischer
  • Constructor Details

    • DecimalSplitSortPositionStrategy

      public DecimalSplitSortPositionStrategy()
  • Method Details

    • updateSort

      public P updateSort(SortPositionRequest sortPositionRequest, ContextInfo context, DomainMapperManager mapper, TrackableRepository<Trackable> repository, ChangeNotifier notifier, @Nullable PropagationIntegrator propagationIntegrator, @Nullable PropagationHelperUtility propagationHelperUtility)
      Description copied from interface: SortPositionStrategy
      Apply a sort field value change
      Specified by:
      updateSort in interface SortPositionStrategy<P>
      Parameters:
      sortPositionRequest - Information about the item being moved and the position to which it's moving
      context - The current request context view
      mapper - The mapper generally used during updates to apply changes to repository domain
      repository - The repository used to manage persistence of the changing domain
      notifier - Component responsible for notifying the messaging system of the change
      propagationIntegrator - Component responsible for initiating propagation, if applicable
      propagationHelperUtility - Component containing common utilities for propagation
      Returns:
      The updated business domain
    • updateAfterPositionSort

      protected void updateAfterPositionSort(SortPositionRequest sortPositionRequest, ContextInfo context, TrackableRepository<Trackable> repository, Sortable toUpdate, Sortable sortTransfer)
      Update when the SortPositionRequest.getPositionAfterContextId() value is available.
      Parameters:
      sortPositionRequest - Information about the item being moved and the position to which it's moving
      context - The current request context view
      repository - The repository used to manage persistence of the changing domain
      toUpdate - The Sortable repository domain
      sortTransfer - The Sortable instance containing the sort field value to transfer to the repository domain
    • updateBeforePositionSort

      protected void updateBeforePositionSort(SortPositionRequest sortPositionRequest, ContextInfo context, TrackableRepository<Trackable> repository, Sortable toUpdate, Sortable sortTransfer)
      Update when the SortPositionRequest.getPositionBeforeContextId() value is available.
      Parameters:
      sortPositionRequest - Information about the item being moved and the position to which it's moving
      context - The current request context view
      repository - The repository used to manage persistence of the changing domain
      toUpdate - The Sortable repository domain
      sortTransfer - The Sortable instance containing the sort field value to transfer to the repository domain
    • setSortingAsDifference

      protected void setSortingAsDifference(Sortable sortTransfer, Sortable positionBeforeSortable, Sortable positionAfterSortable)
    • updateFirstPositionSort

      protected void updateFirstPositionSort(ContextInfo context, TrackableRepository<Trackable> repository, Sortable domain, Sortable sortTransfer)
      Update when the SortPositionRequest.getPositionAfterContextId() is missing, which indicates that the request is to move the entity to the first position in the sorting group.
      Parameters:
      context - The current request context view
      repository - The repository used to manage persistence of the changing domain
      domain - The Sortable repository domain
      sortTransfer - The Sortable instance containing the sort field value to transfer to the repository domain