Class CollectedProductPersistedDomainContext
java.lang.Object
com.broadleafcommerce.catalog.service.product.mapper.CollectedProductPersistedDomainContext
Thread-local used by
ProductPersistedDomainCollectingMapperMember to store the persisted
domain instances.- Since:
- Catalog Service 2.3.0, Release Train 2.3.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidclear()static <V> VdoWithCollectionEnabled(Supplier<V> supplier) get()protected InstantgetLastUpdateOrCreateAuditTime(com.broadleafcommerce.data.tracking.core.Trackable trackable) voidputIfMissingOrNewerAuditTime(com.broadleafcommerce.data.tracking.core.Trackable trackable) This component is only intended to track the persisted domain instances after they've been successfully created/updated in the system (ex: after repository.save()).voidsetCollectionEnabled(boolean collectionEnabled)
-
Constructor Details
-
CollectedProductPersistedDomainContext
public CollectedProductPersistedDomainContext()
-
-
Method Details
-
get
-
clear
public static void clear() -
doWithCollectionEnabled
-
setCollectionEnabled
public void setCollectionEnabled(boolean collectionEnabled) -
putIfMissingOrNewerAuditTime
public void putIfMissingOrNewerAuditTime(com.broadleafcommerce.data.tracking.core.Trackable trackable) This component is only intended to track the persisted domain instances after they've been successfully created/updated in the system (ex: after repository.save()). However, during any standard create/update/etc flow, there may be multiple attempts to read the same product instance (ex: for validation against the existing state, etc). BecauseProductPersistedDomainCollectingMapperMemberruns on all 'fromRepositoryDomain' requests, we don't want to collect the instances from those extra reads. Thus, we only collect an instance if it was either already missing in the map, or if it has a higher last-created/last-updated audit time than the existing collected value. The create/update flows naturally assign these updated audit values on the persisted domain instance, so it's a fairly reliable way to know we're dealing with the latest state of the item.- Parameters:
trackable- the candidate instance to collect
-
getLastUpdateOrCreateAuditTime
@Nullable protected Instant getLastUpdateOrCreateAuditTime(com.broadleafcommerce.data.tracking.core.Trackable trackable) -
getCollectedInstancesByContextId
-