Interface ImportService<P extends Import>
- All Superinterfaces:
com.broadleafcommerce.data.tracking.core.service.MappableCrudEntityService<P>
- All Known Implementing Classes:
DefaultImportService
- Author:
- Phillip Verheyden (phillipuniverse)
-
Method Summary
Modifier and TypeMethodDescriptionadjustCountsFromCompletedBatch
(Batch completedBatch) createSandbox
(String importId, String importingSandboxId) If the import is found and has aImport.status
ofImportStatus.PROCESSING
, atomically sets itsImport.importingSandboxId
to the given value, initializes itsNotificationState
forCreateSandboxRequestProducer.TYPE
, and renewsImport.lastUpdated
.deleteImportsById
(List<String> importIds) Delete the imports that match the corresponding idsincrementSuccessAndErrorCounts
(String importId, long successCount, long errorCount) Atomically updates the following fields in the givenImport
(specified inimportId
): incrementImport.successCount
, incrementImport.errorCount
, and renewImport.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
, setsImport.errorMessage
toerrorMessage
, and renewsImport.lastUpdated
.boolean
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 the given import toImportStatus.PROCESSING
if and only if the given import was alreadyImportStatus.REQUESTED
.notifyOfDeleteSandboxRequest
(String importId) Tries to findImport
byImport.id
if found and it has aImport.status
ofImportStatus.FAILED
, atomically initializes itsNotificationState
forImportDeleteSandboxRequestProducer.TYPE
and renewsImport.lastUpdated
.org.springframework.data.domain.Page<P>
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<P>
readByActiveStatus
(boolean isActive, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds and returns all imports whoseImport.getStatus()
satisfies the requirement ofisActive
.org.springframework.data.domain.Page<P>
readByAuthor
(String author, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads the imports with the givenImport.getAuthor()
.org.springframework.data.domain.Page<P>
readByAuthorAndApplicationIdAndTenantId
(String author, String applicationId, String tenantId, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable) Deprecated.Reads the specified import byImport.getId()
.readImportsBeforeDate
(Instant before) Read all imports whoseImport.getLastUpdated()
occurs before the provided timeReads the imports whose status isImportStatus.REQUESTED
and whoseImport.lastUpdated
is before the givencutoff
.readRequestedLastUpdatedBeforeAndTenantId
(Instant cutoff, String tenantId) Reads the imports whose status isImportStatus.REQUESTED
and whoseImport.lastUpdated
is before the givencutoff
, within the specified tenant.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.data.tracking.core.service.MappableCrudEntityService
create, createAll, createAllAllowingPartialSuccess, delete, readAll, readAll, readAll, readAllByIds, readById, replace, replaceAll, replaceAllAllowingPartialSuccess, update, updateAll, updateAllAllowingPartialSuccess
-
Method Details
-
markProcessing
Sets the given import toImportStatus.PROCESSING
if and only if the given import was alreadyImportStatus.REQUESTED
.- Parameters:
importId
- the Import to update- Returns:
- the updated Import with a status of
ImportStatus.PROCESSING
, or null if there was no import found with the given id whose status isImportStatus.REQUESTED
-
markErrored
Atomically finds and updates the import'sImport.status
toImportStatus.FAILED
, setsImport.errorMessage
toerrorMessage
, and renewsImport.lastUpdated
.- 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
, set the error message, and renewImport.lastUpdated
.- 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:
- true if the import was found and updated, false otherwise
-
createSandbox
If the import is found and has aImport.status
ofImportStatus.PROCESSING
, atomically sets itsImport.importingSandboxId
to the given value, initializes itsNotificationState
forCreateSandboxRequestProducer.TYPE
, and renewsImport.lastUpdated
.If the update is successful, calls
NotificationManager.handle(NotificationStateRepository, NotificationStateAware, String)
for theCreateSandboxRequestProducer.TYPE
, which will emit a request to create the sandbox with the given ID.Note: before calling this method, ensure that the
Import.importingSandboxNameToCreate
has been set, asCreateSandboxRequestMessageFactory.createMessage(Object)
will use its value forCreateSandboxRequest.sandboxName
.- Parameters:
importId
- the ID of the import to modifyimportingSandboxId
- the ID of the sandbox which should be created- Returns:
- the updated
Import
if successfully found and updated,null
otherwise
-
readRequestedLastUpdatedBefore
Reads the imports whose status isImportStatus.REQUESTED
and whoseImport.lastUpdated
is before the givencutoff
.- Parameters:
cutoff
- the results will be filtered to only include those imports whoseImport.lastUpdated
is before this value- Returns:
- the imports with status
ImportStatus.REQUESTED
which have aImport.lastUpdated
before the givencutoff
-
readRequestedLastUpdatedBeforeAndTenantId
Reads the imports whose status isImportStatus.REQUESTED
and whoseImport.lastUpdated
is before the givencutoff
, within the specified tenant.- Parameters:
cutoff
- the results will be filtered to only include those imports whoseImport.lastUpdated
is before this valuetenantId
- the tenant id that this import was initiated from- Returns:
- the imports with status
ImportStatus.REQUESTED
which have aImport.lastUpdated
before the givencutoff
-
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
-
adjustCountsFromCompletedBatch
Updates anImport
(specified inBatch.importId
) based upon the information received in aBatch
. Batch must be a completed batch with aBatchStatus.COMPLETED
status.This will atomically update the following fields: increment
Import.successCount
, incrementImport.errorCount
, and renewImport.lastUpdated
.- Parameters:
completedBatch
- must be a batch with aBatchStatus.COMPLETED
status.- Returns:
- the updated import if found and updated,
null
otherwise - See Also:
-
incrementSuccessAndErrorCounts
Atomically updates the following fields in the givenImport
(specified inimportId
): incrementImport.successCount
, incrementImport.errorCount
, and renewImport.lastUpdated
.- Parameters:
importId
- the ID of the import to updatesuccessCount
- the amount to add to theImport.successCount
errorCount
- the amount to add to theImport.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 - See Also:
-
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 - See Also:
-
readById
P readById(String id, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads 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:
- the requested import matching the given ID
- Throws:
com.broadleafcommerce.data.tracking.core.exception.EntityMissingException
- if not found
-
readByActiveStatus
org.springframework.data.domain.Page<P> readByActiveStatus(boolean isActive, org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds and returns all imports whoseImport.getStatus()
satisfies the requirement ofisActive
. IfisActive
is true, only imports withImportStatus.PROCESSING
returned. IfisActive
is false, only imports who do not haveImportStatus.PROCESSING
will be returned.- Parameters:
isActive
- true if only active imports should be returned, false if only inactive imports should be returnedpageable
- 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 satisfies the given
isActive
requirement
-
readAll
org.springframework.data.domain.Page<P> 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
-
readByAuthorAndApplicationIdAndTenantId
@Deprecated org.springframework.data.domain.Page<P> readByAuthorAndApplicationIdAndTenantId(String author, @Nullable String applicationId, String tenantId, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable) Deprecated.since 1.3, replaced byreadByAuthor(String, Node, Pageable, ContextInfo)
Reads the imports with the givenImport.author
andImport.applicationId
.- Parameters:
author
- the author to filter results byapplicationId
- theImport.applicationId
to filter by. Note that if this isnull
, only imports with null application IDs will be returned.tenantId
- theImport.tenantId
to filter byfilters
- additional filters to apply, must not be nullpageable
- information about which page of results to return from the database- Returns:
- the imports matching the given criteria
-
readByAuthor
org.springframework.data.domain.Page<P> readByAuthor(String author, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads the imports with the givenImport.getAuthor()
.- Parameters:
author
- the author 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
-
notifyOfDeleteSandboxRequest
Tries to findImport
byImport.id
if found and it has aImport.status
ofImportStatus.FAILED
, atomically initializes itsNotificationState
forImportDeleteSandboxRequestProducer.TYPE
and renewsImport.lastUpdated
.If the update is successful, calls
NotificationManager.handle(NotificationStateRepository, NotificationStateAware, String)
for theImportDeleteSandboxRequestProducer.TYPE
.- Parameters:
importId
- the ID of the Import to modify- Returns:
- the updated
Import
if successfully found and updated,null
otherwise - Throws:
com.broadleafcommerce.common.messaging.exception.ResourceLockException
- if the lock could not be acquired
-
readImportsBeforeDate
Read all imports whoseImport.getLastUpdated()
occurs before the provided time- Parameters:
before
- the time for which to get all imports older than- Returns:
- all imports whose
Import.getLastUpdated()
occurs before the provided time
-
deleteImportsById
Delete the imports that match the corresponding ids- Parameters:
importIds
- the list of import ids to delete against- Returns:
- the number of imports deleted
-
readByAuthor(String, Node, Pageable, ContextInfo)