Class DefaultExportService<P extends Export>
- java.lang.Object
-
- com.broadleafcommerce.data.tracking.core.service.BaseMappableCrudEntityService<P>
-
- com.broadleafcommerce.data.tracking.core.service.BaseRsqlMappableCrudEntityService<P>
-
- com.broadleafcommerce.common.dataexport.service.DefaultExportService<P>
-
- All Implemented Interfaces:
ExportService<P>,com.broadleafcommerce.data.tracking.core.service.MappableCrudEntityService<P>,com.broadleafcommerce.data.tracking.core.service.RsqlMappableCrudEntityService<P>
public class DefaultExportService<P extends Export> extends com.broadleafcommerce.data.tracking.core.service.BaseRsqlMappableCrudEntityService<P> implements ExportService<P>
- Author:
- Samarth Dhruva (samarthd)
-
-
Constructor Summary
Constructors Constructor Description DefaultExportService(ExportRepository<com.broadleafcommerce.data.tracking.core.Identifiable> repository, com.broadleafcommerce.data.tracking.core.service.RsqlMappableCrudEntityHelper helper, com.broadleafcommerce.common.messaging.notification.NotificationManager notificationManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <D,R extends org.springframework.data.repository.CrudRepository<D,String> & com.broadleafcommerce.common.extension.DomainTypeAware>
Pcreate(P businessInstance)Overriding to add notification behavior.protected com.broadleafcommerce.common.messaging.notification.NotificationManagergetNotificationManager()protected ExportRepository<com.broadleafcommerce.data.tracking.core.Identifiable>getRepository()org.springframework.data.domain.Page<P>readByTargetAndApplicationIdAndTenantId(String target, String applicationId, @NonNull String tenantId, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable)Reads the exports with the givenExport.targetandExport.applicationId.org.springframework.data.domain.Page<P>readByTargetAndAuthorAndApplicationIdAndTenantId(String target, String author, String applicationId, @NonNull String tenantId, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable)org.springframework.data.domain.Page<P>readByTargetAndAuthorAndApplicationIdAndTenantIdAndParentId(String target, String author, String applicationId, @NonNull String tenantId, @NonNull String parentId, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable)List<P>readIncompleteLastUpdatedBefore(Instant cutoff)Reads the exports which are incomplete (those with statusExportStatus.REQUESTEDorExportStatus.PROCESSING) whoseExport.lastUpdatedis before the givencutoff.List<P>readIncompleteLastUpdatedBeforeAndTenantId(Instant cutoff, String tenantId)Reads the exports which are incomplete (those with statusExportStatus.REQUESTEDorExportStatus.PROCESSING) whoseExport.lastUpdatedis before the givencutoff, within the specified tenant.booleansetError(String exportId, String errorMessage)Atomically finds and updates the given export: finds the export with the ID matching the givenexport, sets the export'sExport.errorMessageto the given value, setsExport.statustoExportStatus.ERROR, and renewsExport.lastUpdated.booleansetFileLocationAndFinishedStatus(String exportId, String fileLocation)Atomically finds and updates the export with the givenexportId: sets theExport.statustoExportStatus.FINISHED, sets theExport.fileLocationtofileLocation, and renewsExport.lastUpdated.booleansetNumberOfRecordsProcessed(String exportId, long numberOfRecordsProcessed)Atomically finds and updates the export with the givenexportId: setsExport.numberOfRecordsProcessedto the given value and renewsExport.lastUpdated.PsetProcessingStatus(String exportId)Atomically finds and updates the export with the givenexportId, setting theExport.statustoExportStatus.PROCESSINGand renewingExport.lastUpdated.-
Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseRsqlMappableCrudEntityService
getRsqlHelper, readAll, readAll, readAll, readAll
-
Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseMappableCrudEntityService
convertFromPersistentDomain, createAll, createAllAllowingPartialSuccess, delete, getHelper, readAll, readAll, readAll, readAllByIds, readById, replace, replaceAll, replaceAllAllowingPartialSuccess, update, updateAll, updateAllAllowingPartialSuccess
-
Methods 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.service.MappableCrudEntityService
createAll, createAllAllowingPartialSuccess, delete, readAll, readAll, readAll, readAllByIds, readById, replace, replaceAll, replaceAllAllowingPartialSuccess, update, updateAll, updateAllAllowingPartialSuccess
-
-
-
-
Constructor Detail
-
DefaultExportService
public DefaultExportService(ExportRepository<com.broadleafcommerce.data.tracking.core.Identifiable> repository, com.broadleafcommerce.data.tracking.core.service.RsqlMappableCrudEntityHelper helper, com.broadleafcommerce.common.messaging.notification.NotificationManager notificationManager)
-
-
Method Detail
-
create
public <D,R extends org.springframework.data.repository.CrudRepository<D,String> & com.broadleafcommerce.common.extension.DomainTypeAware> P create(P businessInstance)
Overriding to add notification behavior.Will create the
Exportand emit anProcessExportRequestmessage.
-
setProcessingStatus
@Nullable public P setProcessingStatus(String exportId)
Description copied from interface:ExportServiceAtomically finds and updates the export with the givenexportId, setting theExport.statustoExportStatus.PROCESSINGand renewingExport.lastUpdated.The update is applied only if the export is found to have a
Export.statusofExportStatus.REQUESTED.- Specified by:
setProcessingStatusin interfaceExportService<P extends Export>- Parameters:
exportId- the ID of the export to find and update- Returns:
- the updated
Exportif successfully found and updated,nullotherwise
-
setError
public boolean setError(String exportId, String errorMessage)
Description copied from interface:ExportServiceAtomically finds and updates the given export: finds the export with the ID matching the givenexport, sets the export'sExport.errorMessageto the given value, setsExport.statustoExportStatus.ERROR, and renewsExport.lastUpdated.The update is applied only if the export is found to have a
Export.statusofExportStatus.REQUESTEDorExportStatus.PROCESSING.- Specified by:
setErrorin interfaceExportService<P extends Export>- Parameters:
exportId- the ID of the export to find and updateerrorMessage- the error message to set on the export- Returns:
- true if the export update was successfully performed, false otherwise
-
setNumberOfRecordsProcessed
public boolean setNumberOfRecordsProcessed(String exportId, long numberOfRecordsProcessed)
Description copied from interface:ExportServiceAtomically finds and updates the export with the givenexportId: setsExport.numberOfRecordsProcessedto the given value and renewsExport.lastUpdated.The update is applied only if the export is found to have a
Export.statusofExportStatus.PROCESSING- Specified by:
setNumberOfRecordsProcessedin interfaceExportService<P extends Export>- Parameters:
exportId- the ID of the export to find and updatenumberOfRecordsProcessed- the new value to set forExport.numberOfRecordsProcessed- Returns:
- true if the update was successfully performed, false otherwise
-
setFileLocationAndFinishedStatus
public boolean setFileLocationAndFinishedStatus(String exportId, String fileLocation)
Description copied from interface:ExportServiceAtomically finds and updates the export with the givenexportId: sets theExport.statustoExportStatus.FINISHED, sets theExport.fileLocationtofileLocation, and renewsExport.lastUpdated.The update is applied only if the export is found to have a
Export.statusofExportStatus.PROCESSING- Specified by:
setFileLocationAndFinishedStatusin interfaceExportService<P extends Export>- Parameters:
exportId- the ID of the export to modifyfileLocation- the file location to set on the export- Returns:
- true if the update was successfully performed, false otherwise
-
readByTargetAndApplicationIdAndTenantId
public org.springframework.data.domain.Page<P> readByTargetAndApplicationIdAndTenantId(String target, @Nullable String applicationId, @NonNull @NonNull String tenantId, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable)
Description copied from interface:ExportServiceReads the exports with the givenExport.targetandExport.applicationId.- Specified by:
readByTargetAndApplicationIdAndTenantIdin interfaceExportService<P extends Export>- Parameters:
target- theExport.targetto filter byapplicationId- theExport.applicationIdto filter by. Note that if this isnull, only exports with null application IDs will be returned.tenantId- theExport.tenantIdto filter bypageable- information about which page of results to return from the database- Returns:
- the exports with the given
Export.targetandExport.applicationId
-
readByTargetAndAuthorAndApplicationIdAndTenantId
public org.springframework.data.domain.Page<P> readByTargetAndAuthorAndApplicationIdAndTenantId(String target, String author, @Nullable String applicationId, @NonNull @NonNull String tenantId, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable)
Description copied from interface:ExportService- Specified by:
readByTargetAndAuthorAndApplicationIdAndTenantIdin interfaceExportService<P extends Export>- Parameters:
target- the target to filter results byauthor- the author to filter results byapplicationId- theExport.applicationIdto filter by. Note that if this isnull, only exports with null application IDs will be returned.tenantId- theExport.tenantIdto filter byfilters- additional filters to apply, must not be nullpageable- information about which page of results to return from the database- Returns:
- the exports matching the given criteria
-
readIncompleteLastUpdatedBefore
public List<P> readIncompleteLastUpdatedBefore(Instant cutoff)
Description copied from interface:ExportServiceReads the exports which are incomplete (those with statusExportStatus.REQUESTEDorExportStatus.PROCESSING) whoseExport.lastUpdatedis before the givencutoff.- Specified by:
readIncompleteLastUpdatedBeforein interfaceExportService<P extends Export>- Parameters:
cutoff- the results will be filtered to only include those exports whoseExport.lastUpdatedis before this value- Returns:
- the exports which are incomplete and have a
Export.lastUpdatedbefore the givencutoff
-
readIncompleteLastUpdatedBeforeAndTenantId
public List<P> readIncompleteLastUpdatedBeforeAndTenantId(Instant cutoff, String tenantId)
Description copied from interface:ExportServiceReads the exports which are incomplete (those with statusExportStatus.REQUESTEDorExportStatus.PROCESSING) whoseExport.lastUpdatedis before the givencutoff, within the specified tenant.- Specified by:
readIncompleteLastUpdatedBeforeAndTenantIdin interfaceExportService<P extends Export>- Parameters:
cutoff- the results will be filtered to only include those exports whoseExport.lastUpdatedis before this valuetenantId- the tenant id that this export operation was initiated from- Returns:
- the exports which are incomplete and have a
Export.lastUpdatedbefore the givencutoff
-
readByTargetAndAuthorAndApplicationIdAndTenantIdAndParentId
public org.springframework.data.domain.Page<P> readByTargetAndAuthorAndApplicationIdAndTenantIdAndParentId(String target, String author, @Nullable String applicationId, @NonNull @NonNull String tenantId, @NonNull @NonNull String parentId, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable)
Description copied from interface:ExportService- Specified by:
readByTargetAndAuthorAndApplicationIdAndTenantIdAndParentIdin interfaceExportService<P extends Export>- Parameters:
target- the target to filter results byauthor- the author to filter results byapplicationId- theExport.applicationIdto filter by. Note that if this isnull, only exports with null application IDs will be returned.tenantId- theExport.tenantIdto filter byparentId- theExport.parentIdto filter byfilters- additional filters to apply, must not be nullpageable- information about which page of results to return from the database- Returns:
- the exports matching the given criteria
-
getRepository
@NonNull protected ExportRepository<com.broadleafcommerce.data.tracking.core.Identifiable> getRepository()
-
getNotificationManager
@NonNull protected com.broadleafcommerce.common.messaging.notification.NotificationManager getNotificationManager()
-
-