Interface CustomizedImportRepository<D extends com.broadleafcommerce.data.tracking.core.Identifiable>
- All Superinterfaces:
com.broadleafcommerce.common.extension.DomainTypeAware
- All Known Subinterfaces:
ImportRepository<D>
,JpaImportRepository<D>
- All Known Implementing Classes:
JpaCustomizedImportRepository
public interface CustomizedImportRepository<D extends com.broadleafcommerce.data.tracking.core.Identifiable>
extends com.broadleafcommerce.common.extension.DomainTypeAware
- Author:
- Phillip Verheyden (phillipuniverse)
-
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.data.domain.Page<D>
findByAuthor
(String author, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds the imports with the givenImport.getAuthor()
.Finds the specified import byImport.getId()
.incrementSuccessAndErrorCounts
(String importId, long successCount, long errorCount) This will atomically update the following fields: incrementImport.successCount
, incrementImport.errorCount
, and renewImport.lastUpdated
.Atomically initializes theNotificationState
forImportDeleteSandboxRequestProducer.TYPE
on the given import if it is found to have aImport.status
ofImportStatus.FAILED
.initializeForSandboxCreation
(String importId, String importingSandboxId) If the import is found and has aImport.status
ofImportStatus.PROCESSING
, atomically sets theImport.importingSandboxId
to the given value, initializes theNotificationState
forCreateSandboxRequestProducer.TYPE
, and renewsImport.lastUpdated
.markCancelled
(String importId) Atomically marks the given import as cancelled.markCompleted
(String importId) Atomically marks the given import as completed.markErrored
(String importId, String errorMessage) Atomically finds and updates the import'sImport.status
toImportStatus.FAILED
and setsImport.errorMessage
toerrorMessage
.markHanging
(String importId, Instant cutoff, String errorMessage) Atomically updates the import only if itsImport.status
isImportStatus.REQUESTED
and itsImport.lastUpdated
is before the givencutoff
.markProcessing
(String importId) Sets an import with the givenimportId
toImportStatus.PROCESSING
, if and only if it was originallyImportStatus.REQUESTED
.org.springframework.data.domain.Page<D>
readAll
(org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds and returns all imports.org.springframework.data.domain.Page<D>
readByStatus
(String importStatus, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds and returns all imports whoseImport.getStatus()
equals the given value.org.springframework.data.domain.Page<D>
readByStatusNot
(String importStatus, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds and returns all imports whoseImport.getStatus()
is not equal to the given value.setTotalItems
(String importId, long totalItems) Atomically sets theImport.totalItems
of the given import to the specified value and renewsImport.lastUpdated
.Methods inherited from interface com.broadleafcommerce.common.extension.DomainTypeAware
getDomainType
-
Method Details
-
markProcessing
Sets an import with the givenimportId
toImportStatus.PROCESSING
, if and only if it was originallyImportStatus.REQUESTED
. Also atomically renewsImport.lastUpdated
.- Parameters:
importId
- the persisted import to set to processing- Returns:
- the updated import or
null
if nothing found with a status ofImportStatus.PROCESSING
or by the givenimportId
-
initializeForSandboxCreation
If the import is found and has aImport.status
ofImportStatus.PROCESSING
, atomically sets theImport.importingSandboxId
to the given value, initializes theNotificationState
forCreateSandboxRequestProducer.TYPE
, and renewsImport.lastUpdated
.- Parameters:
importId
- the ID of the import to modifyimportingSandboxId
- the ID of the sandbox to create- Returns:
- the updated
Import
if found and updated,null
otherwise
-
markErrored
Atomically finds and updates the import'sImport.status
toImportStatus.FAILED
and setsImport.errorMessage
toerrorMessage
.- Parameters:
importId
- the ID of the import to updateerrorMessage
- error message to set asImport.errorMessage
- Returns:
- the updated import if found and updated,
null
otherwise
-
markHanging
Atomically updates the import only if itsImport.status
isImportStatus.REQUESTED
and itsImport.lastUpdated
is before the givencutoff
.The update will set the
Import.status
toImportStatus.FAILED
and set the error message.- Parameters:
importId
- the ID of the import to updatecutoff
- the value that the import'sImport.lastUpdated
must be beforeerrorMessage
- error message to set asImport.errorMessage
- Returns:
- the updated import if found and updated,
null
otherwise
-
setTotalItems
Atomically sets theImport.totalItems
of the given import to the specified value and renewsImport.lastUpdated
.- Parameters:
importId
- the ID of the import to updatetotalItems
- the value to set for the total item count- Returns:
- the updated import if found and updated,
null
otherwise
-
incrementSuccessAndErrorCounts
This will atomically update the following fields: incrementImport.successCount
, incrementImport.errorCount
, and renewImport.lastUpdated
.- Parameters:
importId
- the ID of the import to updatesuccessCount
- the value to add to the existing value ofImport.successCount
errorCount
- the value to add to the existing value ofImport.errorCount
- Returns:
- the updated import if found and updated,
null
otherwise
-
markCompleted
Atomically marks the given import as completed. The update will only be performed if the import currently does not currently have a status ofImportStatus.CANCELLED
,ImportStatus.FAILED
, orImportStatus.COMPLETED
.- Parameters:
importId
- the ID of the import to update- Returns:
- the updated import if found and updated,
null
otherwise
-
markCancelled
Atomically marks the given import as cancelled. The update will only be performed if the import currently does not currently have a status ofImportStatus.CANCELLED
,ImportStatus.FAILED
, orImportStatus.COMPLETED
.- Parameters:
importId
- the ID of the import to update- Returns:
- the updated import if found and updated,
null
otherwise
-
findById
Optional<D> findById(String id, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds the specified import byImport.getId()
.- Parameters:
id
- the ID of the import to findcontextInfo
- context information surrounding multitenant state. Results will be filtered such that only results exactly matching theContextRequest.getApplication()
andContextRequest.getTenantId()
will be returned (unlessContextInfo.isIgnoreNarrowing()
).- Returns:
- an optional containing the requested import matching the given ID if found,
Optional.empty()
otherwise
-
readByStatus
org.springframework.data.domain.Page<D> readByStatus(String importStatus, org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds and returns all imports whoseImport.getStatus()
equals the given value.- Parameters:
importStatus
- the status which imports should have in order to be included in the resultspageable
- information about which page of results should be returned from the databasecontextInfo
- context information surrounding multitenant state. Results will be filtered such that only results exactly matching theContextRequest.getApplication()
andContextRequest.getTenantId()
will be returned (unlessContextInfo.isIgnoreNarrowing()
).- Returns:
- all imports whose status equals
importStatus
-
readByStatusNot
org.springframework.data.domain.Page<D> readByStatusNot(String importStatus, org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds and returns all imports whoseImport.getStatus()
is not equal to the given value.- Parameters:
importStatus
- the status which imports should not have in order to be included in the resultspageable
- information about which page of results should be returned from the databasecontextInfo
- context information surrounding multitenant state. Results will be filtered such that only results exactly matching theContextRequest.getApplication()
andContextRequest.getTenantId()
will be returned (unlessContextInfo.isIgnoreNarrowing()
).- Returns:
- all imports whose status equals
importStatus
-
readAll
org.springframework.data.domain.Page<D> readAll(org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds and returns all imports.- Parameters:
pageable
- information about which page of results should be returned from the databasecontextInfo
- context information surrounding multitenant state. Results will be filtered such that only results exactly matching theContextRequest.getApplication()
andContextRequest.getTenantId()
will be returned (unlessContextInfo.isIgnoreNarrowing()
).- Returns:
- all imports in the datastore
-
findByAuthor
org.springframework.data.domain.Page<D> findByAuthor(String author, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds the imports with the givenImport.getAuthor()
.- Parameters:
author
- theImport.getAuthor()
to filter results byfilters
- additional filters to apply, must not be nullpageable
- information about which page of results to return from the databasecontextInfo
- context information surrounding multitenant state. Results will be filtered such that only results exactly matching theContextRequest.getApplication()
andContextRequest.getTenantId()
will be returned (unlessContextInfo.isIgnoreNarrowing()
).- Returns:
- the imports matching the given criteria
-
initializeDeleteSandboxNotificationState
Atomically initializes theNotificationState
forImportDeleteSandboxRequestProducer.TYPE
on the given import if it is found to have aImport.status
ofImportStatus.FAILED
.- Parameters:
importId
- the ID of the import to modify- Returns:
- the updated
Import
if found and updated,null
otherwise
-