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

    Modifier and Type
    Method
    Description
    <D, R extends org.springframework.data.repository.CrudRepository<D, String> & com.broadleafcommerce.common.extension.DomainTypeAware>
    P
    create(P businessInstance)
    Overriding to add notification behavior.
    protected com.broadleafcommerce.common.messaging.notification.NotificationManager
     
    protected ExportRepository<com.broadleafcommerce.data.tracking.core.Identifiable>
     
    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 given Export.target and Export.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)
    Reads the exports with the given Export.target, Export.author, and Export.applicationId.
    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)
    Reads the exports with the given Export.target, Export.author, and Export.applicationId.
    Reads the exports which are incomplete (those with status ExportStatus.REQUESTED or ExportStatus.PROCESSING) whose Export.lastUpdated is before the given cutoff.
    Reads the exports which are incomplete (those with status ExportStatus.REQUESTED or ExportStatus.PROCESSING) whose Export.lastUpdated is before the given cutoff, within the specified tenant.
    boolean
    setError(String exportId, String errorMessage)
    Atomically finds and updates the given export: finds the export with the ID matching the given export, sets the export's Export.errorMessage to the given value, sets Export.status to ExportStatus.ERROR, and renews Export.lastUpdated.
    boolean
    Atomically finds and updates the export with the given exportId: sets the Export.status to ExportStatus.FINISHED, sets the Export.fileLocation to fileLocation, and renews Export.lastUpdated.
    boolean
    setNumberOfRecordsProcessed(String exportId, long numberOfRecordsProcessed)
    Atomically finds and updates the export with the given exportId: sets Export.numberOfRecordsProcessed to the given value and renews Export.lastUpdated.
    Atomically finds and updates the export with the given exportId, setting the Export.status to ExportStatus.PROCESSING and renewing Export.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

    Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.RsqlMappableCrudEntityService

    readAll, readAll, readAll, readAll
  • Constructor Details

    • 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 Details

    • 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 Export and emit an ProcessExportRequest message.

      Specified by:
      create in interface com.broadleafcommerce.data.tracking.core.service.MappableCrudEntityService<P extends Export>
      Overrides:
      create in class com.broadleafcommerce.data.tracking.core.service.BaseMappableCrudEntityService<P extends Export>
    • setProcessingStatus

      @Nullable public P setProcessingStatus(String exportId)
      Description copied from interface: ExportService
      Atomically finds and updates the export with the given exportId, setting the Export.status to ExportStatus.PROCESSING and renewing Export.lastUpdated.

      The update is applied only if the export is found to have a Export.status of ExportStatus.REQUESTED.

      Specified by:
      setProcessingStatus in interface ExportService<P extends Export>
      Parameters:
      exportId - the ID of the export to find and update
      Returns:
      the updated Export if successfully found and updated, null otherwise
    • setError

      public boolean setError(String exportId, String errorMessage)
      Description copied from interface: ExportService
      Atomically finds and updates the given export: finds the export with the ID matching the given export, sets the export's Export.errorMessage to the given value, sets Export.status to ExportStatus.ERROR, and renews Export.lastUpdated.

      The update is applied only if the export is found to have a Export.status of ExportStatus.REQUESTED or ExportStatus.PROCESSING.

      Specified by:
      setError in interface ExportService<P extends Export>
      Parameters:
      exportId - the ID of the export to find and update
      errorMessage - 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: ExportService
      Atomically finds and updates the export with the given exportId: sets Export.numberOfRecordsProcessed to the given value and renews Export.lastUpdated.

      The update is applied only if the export is found to have a Export.status of ExportStatus.PROCESSING

      Specified by:
      setNumberOfRecordsProcessed in interface ExportService<P extends Export>
      Parameters:
      exportId - the ID of the export to find and update
      numberOfRecordsProcessed - the new value to set for Export.numberOfRecordsProcessed
      Returns:
      true if the update was successfully performed, false otherwise
    • setFileLocationAndFinishedStatus

      public boolean setFileLocationAndFinishedStatus(String exportId, String fileLocation)
      Description copied from interface: ExportService
      Atomically finds and updates the export with the given exportId: sets the Export.status to ExportStatus.FINISHED, sets the Export.fileLocation to fileLocation, and renews Export.lastUpdated.

      The update is applied only if the export is found to have a Export.status of ExportStatus.PROCESSING

      Specified by:
      setFileLocationAndFinishedStatus in interface ExportService<P extends Export>
      Parameters:
      exportId - the ID of the export to modify
      fileLocation - 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: ExportService
      Reads the exports with the given Export.target and Export.applicationId.
      Specified by:
      readByTargetAndApplicationIdAndTenantId in interface ExportService<P extends Export>
      Parameters:
      target - the Export.target to filter by
      applicationId - the Export.applicationId to filter by. Note that if this is null, only exports with null application IDs will be returned.
      tenantId - the Export.tenantId to filter by
      pageable - information about which page of results to return from the database
      Returns:
      the exports with the given Export.target and Export.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
      Reads the exports with the given Export.target, Export.author, and Export.applicationId.
      Specified by:
      readByTargetAndAuthorAndApplicationIdAndTenantId in interface ExportService<P extends Export>
      Parameters:
      target - the target to filter results by
      author - the author to filter results by
      applicationId - the Export.applicationId to filter by. Note that if this is null, only exports with null application IDs will be returned.
      tenantId - the Export.tenantId to filter by
      filters - additional filters to apply, must not be null
      pageable - 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: ExportService
      Reads the exports which are incomplete (those with status ExportStatus.REQUESTED or ExportStatus.PROCESSING) whose Export.lastUpdated is before the given cutoff.
      Specified by:
      readIncompleteLastUpdatedBefore in interface ExportService<P extends Export>
      Parameters:
      cutoff - the results will be filtered to only include those exports whose Export.lastUpdated is before this value
      Returns:
      the exports which are incomplete and have a Export.lastUpdated before the given cutoff
    • readIncompleteLastUpdatedBeforeAndTenantId

      public List<P> readIncompleteLastUpdatedBeforeAndTenantId(Instant cutoff, String tenantId)
      Description copied from interface: ExportService
      Reads the exports which are incomplete (those with status ExportStatus.REQUESTED or ExportStatus.PROCESSING) whose Export.lastUpdated is before the given cutoff, within the specified tenant.
      Specified by:
      readIncompleteLastUpdatedBeforeAndTenantId in interface ExportService<P extends Export>
      Parameters:
      cutoff - the results will be filtered to only include those exports whose Export.lastUpdated is before this value
      tenantId - the tenant id that this export operation was initiated from
      Returns:
      the exports which are incomplete and have a Export.lastUpdated before the given cutoff
    • 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
      Reads the exports with the given Export.target, Export.author, and Export.applicationId.
      Specified by:
      readByTargetAndAuthorAndApplicationIdAndTenantIdAndParentId in interface ExportService<P extends Export>
      Parameters:
      target - the target to filter results by
      author - the author to filter results by
      applicationId - the Export.applicationId to filter by. Note that if this is null, only exports with null application IDs will be returned.
      tenantId - the Export.tenantId to filter by
      parentId - the Export.parentId to filter by
      filters - additional filters to apply, must not be null
      pageable - 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()
      Overrides:
      getRepository in class com.broadleafcommerce.data.tracking.core.service.BaseMappableCrudEntityService<P extends Export>
    • getNotificationManager

      @NonNull protected com.broadleafcommerce.common.messaging.notification.NotificationManager getNotificationManager()