Class DecimalSplitSortPositionStrategy<P>
java.lang.Object
com.broadleafcommerce.data.tracking.core.sort.DecimalSplitSortPositionStrategy<P>
- All Implemented Interfaces:
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
setSortingAsDifference
(Sortable sortTransfer, Sortable positionBeforeSortable, Sortable positionAfterSortable) protected void
updateAfterPositionSort
(SortPositionRequest sortPositionRequest, ContextInfo context, TrackableRepository<Trackable> repository, Sortable toUpdate, Sortable sortTransfer) Update when theSortPositionRequest.getPositionAfterContextId()
value is available.protected void
updateBeforePositionSort
(SortPositionRequest sortPositionRequest, ContextInfo context, TrackableRepository<Trackable> repository, Sortable toUpdate, Sortable sortTransfer) Update when theSortPositionRequest.getPositionBeforeContextId()
value is available.protected void
updateFirstPositionSort
(ContextInfo context, TrackableRepository<Trackable> repository, Sortable domain, Sortable sortTransfer) Update when theSortPositionRequest.getPositionAfterContextId()
is missing, which indicates that the request is to move the entity to the first position in the sorting group.updateSort
(SortPositionRequest sortPositionRequest, ContextInfo context, DomainMapperManager mapper, TrackableRepository<Trackable> repository, ChangeNotifier notifier, PropagationIntegrator propagationIntegrator, PropagationHelperUtility propagationHelperUtility) Apply a sort field value changeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.broadleafcommerce.data.tracking.core.sort.SortPositionStrategy
updateSort
-
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 interfaceSortPositionStrategy<P>
- Parameters:
sortPositionRequest
- Information about the item being moved and the position to which it's movingcontext
- The current request context viewmapper
- The mapper generally used during updates to apply changes to repository domainrepository
- The repository used to manage persistence of the changing domainnotifier
- Component responsible for notifying the messaging system of the changepropagationIntegrator
- Component responsible for initiating propagation, if applicablepropagationHelperUtility
- 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 theSortPositionRequest.getPositionAfterContextId()
value is available.- Parameters:
sortPositionRequest
- Information about the item being moved and the position to which it's movingcontext
- The current request context viewrepository
- The repository used to manage persistence of the changing domaintoUpdate
- TheSortable
repository domainsortTransfer
- TheSortable
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 theSortPositionRequest.getPositionBeforeContextId()
value is available.- Parameters:
sortPositionRequest
- Information about the item being moved and the position to which it's movingcontext
- The current request context viewrepository
- The repository used to manage persistence of the changing domaintoUpdate
- TheSortable
repository domainsortTransfer
- TheSortable
instance containing the sort field value to transfer to the repository domain
-
setSortingAsDifference
-
updateFirstPositionSort
protected void updateFirstPositionSort(ContextInfo context, TrackableRepository<Trackable> repository, Sortable domain, Sortable sortTransfer) Update when theSortPositionRequest.getPositionAfterContextId()
is missing, which indicates that the request is to move the entity to the first position in the sorting group.
-