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 Details

    • markProcessing

      @Nullable D markProcessing(String importId)
      Sets an import with the given importId to ImportStatus.PROCESSING, if and only if it was originally ImportStatus.REQUESTED. Also atomically renews Import.lastUpdated.
      Parameters:
      importId - the persisted import to set to processing
      Returns:
      the updated import or null if nothing found with a status of ImportStatus.PROCESSING or by the given importId
    • initializeForSandboxCreation

      @Nullable D initializeForSandboxCreation(String importId, String importingSandboxId)
      If the import is found and has a Import.status of ImportStatus.PROCESSING, atomically sets the Import.importingSandboxId to the given value, initializes the NotificationState for CreateSandboxRequestProducer.TYPE, and renews Import.lastUpdated.
      Parameters:
      importId - the ID of the import to modify
      importingSandboxId - the ID of the sandbox to create
      Returns:
      the updated Import if found and updated, null otherwise
    • markErrored

      @Nullable D markErrored(String importId, @Nullable String errorMessage)
      Atomically finds and updates the import's Import.status to ImportStatus.FAILED and sets Import.errorMessage to errorMessage.
      Parameters:
      importId - the ID of the import to update
      errorMessage - error message to set as Import.errorMessage
      Returns:
      the updated import if found and updated, null otherwise
    • markHanging

      @Nullable D markHanging(String importId, Instant cutoff, @Nullable String errorMessage)
      Atomically updates the import only if its Import.status is ImportStatus.REQUESTED and its Import.lastUpdated is before the given cutoff.

      The update will set the Import.status to ImportStatus.FAILED and set the error message.

      Parameters:
      importId - the ID of the import to update
      cutoff - the value that the import's Import.lastUpdated must be before
      errorMessage - error message to set as Import.errorMessage
      Returns:
      the updated import if found and updated, null otherwise
    • setTotalItems

      @Nullable D setTotalItems(String importId, long totalItems)
      Atomically sets the Import.totalItems of the given import to the specified value and renews Import.lastUpdated.
      Parameters:
      importId - the ID of the import to update
      totalItems - the value to set for the total item count
      Returns:
      the updated import if found and updated, null otherwise
    • incrementSuccessAndErrorCounts

      @Nullable D incrementSuccessAndErrorCounts(String importId, long successCount, long errorCount)
      This will atomically update the following fields: increment Import.successCount, increment Import.errorCount, and renew Import.lastUpdated.
      Parameters:
      importId - the ID of the import to update
      successCount - the value to add to the existing value of Import.successCount
      errorCount - the value to add to the existing value of Import.errorCount
      Returns:
      the updated import if found and updated, null otherwise
    • markCompleted

      @Nullable D markCompleted(String importId)
      Atomically marks the given import as completed. The update will only be performed if the import currently does not currently have a status of ImportStatus.CANCELLED, ImportStatus.FAILED, or ImportStatus.COMPLETED.
      Parameters:
      importId - the ID of the import to update
      Returns:
      the updated import if found and updated, null otherwise
    • markCancelled

      @Nullable D markCancelled(String importId)
      Atomically marks the given import as cancelled. The update will only be performed if the import currently does not currently have a status of ImportStatus.CANCELLED, ImportStatus.FAILED, or ImportStatus.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 by Import.getId().
      Parameters:
      id - the ID of the import to find
      contextInfo - context information surrounding multitenant state. Results will be filtered such that only results exactly matching the ContextRequest.getApplication() and ContextRequest.getTenantId() will be returned (unless ContextInfo.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 whose Import.getStatus() equals the given value.
      Parameters:
      importStatus - the status which imports should have in order to be included in the results
      pageable - information about which page of results should be returned from the database
      contextInfo - context information surrounding multitenant state. Results will be filtered such that only results exactly matching the ContextRequest.getApplication() and ContextRequest.getTenantId() will be returned (unless ContextInfo.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 whose Import.getStatus() is not equal to the given value.
      Parameters:
      importStatus - the status which imports should not have in order to be included in the results
      pageable - information about which page of results should be returned from the database
      contextInfo - context information surrounding multitenant state. Results will be filtered such that only results exactly matching the ContextRequest.getApplication() and ContextRequest.getTenantId() will be returned (unless ContextInfo.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 database
      contextInfo - context information surrounding multitenant state. Results will be filtered such that only results exactly matching the ContextRequest.getApplication() and ContextRequest.getTenantId() will be returned (unless ContextInfo.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 given Import.getAuthor().
      Parameters:
      author - the Import.getAuthor() to filter results by
      filters - additional filters to apply, must not be null
      pageable - information about which page of results to return from the database
      contextInfo - context information surrounding multitenant state. Results will be filtered such that only results exactly matching the ContextRequest.getApplication() and ContextRequest.getTenantId() will be returned (unless ContextInfo.isIgnoreNarrowing()).
      Returns:
      the imports matching the given criteria
    • initializeDeleteSandboxNotificationState

      @Nullable D initializeDeleteSandboxNotificationState(String importId)
      Atomically initializes the NotificationState for ImportDeleteSandboxRequestProducer.TYPE on the given import if it is found to have a Import.status of ImportStatus.FAILED.
      Parameters:
      importId - the ID of the import to modify
      Returns:
      the updated Import if found and updated, null otherwise