Class 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 Detail

      • DecimalSplitSortPositionStrategy

        public DecimalSplitSortPositionStrategy()
    • Method Detail

      • updateSort

        public P updateSort​(SortPositionRequest sortPositionRequest,
                            ContextInfo context,
                            DomainMapperManager mapper,
                            TrackableRepository<Trackable> repository,
                            ChangeNotifier notifier,
                            PropagationIntegrator propagationIntegrator)
        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
        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
      • 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