Class JpaCustomizedScheduledJobRepository<D extends JpaScheduledJob>

java.lang.Object
com.broadleafcommerce.scheduledjob.provider.jpa.repository.JpaCustomizedScheduledJobRepository<D>
All Implemented Interfaces:
CustomizedScheduledJobRepository<D>

public class JpaCustomizedScheduledJobRepository<D extends JpaScheduledJob> extends Object implements CustomizedScheduledJobRepository<D>
Author:
Jeff Fischer
  • Constructor Details

    • JpaCustomizedScheduledJobRepository

      public JpaCustomizedScheduledJobRepository(com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.broadleafcommerce.common.jpa.RepositoryEntityTypeManager repositoryEntityTypeManager)
  • Method Details

    • streamAll

      @NonNull public Stream<D> streamAll(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CustomizedScheduledJobRepository
      Read a stream of all ScheduledJobs in the data store.
      Specified by:
      streamAll in interface CustomizedScheduledJobRepository<D extends JpaScheduledJob>
      Parameters:
      contextInfo - context information surrounding multitenant state
      Returns:
      a stream of all ScheduledJobs in the data store
    • establishTriggerStateIfApplicable

      @Transactional(transactionManager="scheduledJobTransactionManager") public D establishTriggerStateIfApplicable(String contextId)
      Description copied from interface: CustomizedScheduledJobRepository
      Establish the NotificationStateAware contract for TriggeredJobEventProducer.TYPE. This should initialize the basic support for a trigger type NotificationState item in the NotificationStateAware.getNotificationStates() list. This state is generally completed during the CustomizedScheduledJobRepository.markJobAsExecuted(String, TimingType) lifecycle.
      Specified by:
      establishTriggerStateIfApplicable in interface CustomizedScheduledJobRepository<D extends JpaScheduledJob>
      Parameters:
      contextId - The tracking identifier for the scheduled job
      Returns:
      The initialized entity instance
    • markJobAsExecuted

      @Transactional(transactionManager="scheduledJobTransactionManager") @Nullable public D markJobAsExecuted(String contextId, TimingType timingType)
      Description copied from interface: CustomizedScheduledJobRepository
      Mark a job as executed via ScheduledJob.isExecuted(). As part of an atomic operation, this method should also set the ScheduledJob.getLastExecuted() field and disable the job via ScheduledJob.isEnabled() if the job is of TimingType.TARGET_DATE. Finally, the NotificationState of type TriggeredJobEventProducer.TYPE should be configured to start the resiliency lifecycle. See NotificationState for more information on the fields there related to messaging resiliency.
      Specified by:
      markJobAsExecuted in interface CustomizedScheduledJobRepository<D extends JpaScheduledJob>
      Parameters:
      contextId - The tracking identifier for the scheduled job
      timingType - The type of job (e.g. whether it's recurring cron or single use)
      Returns:
      the updated job if found and successfully updated, otherwise null. For example, if another process had already updated the record as being executed, this update would not succeed.
    • buildContextIdFilter

      protected jakarta.persistence.criteria.Predicate buildContextIdFilter(String scheduledJobContextId, jakarta.persistence.criteria.Root<D> scheduledJobEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String,Object> parameterValues)
    • buildExecutedNotFilter

      protected jakarta.persistence.criteria.Predicate buildExecutedNotFilter(boolean executedNot, jakarta.persistence.criteria.Root<D> scheduledJobEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String,Object> parameterValues)
    • initializeNotificationState

      protected void initializeNotificationState(D entity, String notificationStateName, Instant changeTimestamp)
    • resetNotificationStateByNameAndJobDetailsContaining

      @NonNull @Transactional(transactionManager="scheduledJobTransactionManager") public Optional<D> resetNotificationStateByNameAndJobDetailsContaining(@NonNull String notificationStateToReset, String detailName, Object detailValue)
      Description copied from interface: CustomizedScheduledJobRepository
      Finds the job whose ScheduledJob.details contains a ScheduledJobDetail with the given ScheduledJobDetail.name and ScheduledJobDetail#value, and resets the notification state with the matching name.
      Specified by:
      resetNotificationStateByNameAndJobDetailsContaining in interface CustomizedScheduledJobRepository<D extends JpaScheduledJob>
      detailName - the ScheduledJobDetail.name that the detail should have
      detailValue - the ScheduledJobDetail#value that the detail should have
      Returns:
      an Optional containing the updated job if updated, Optional.empty() otherwise
    • findByContextIdIgnoringNarrowing

      @NonNull public Optional<D> findByContextIdIgnoringNarrowing(@NonNull String contextId)
      Description copied from interface: CustomizedScheduledJobRepository
      Retrieves the job whose ScheduledJob#contextId matches the one supplied. Unlike TrackableRepository.findByContextId(String, ContextInfo), the results are not filtered by narrowing and thus even previously "deleted" results can be returned by this method.

      This functionality is useful for DeploymentJobUnschedulingRequestListener, which requires access to the deleted record for proper notification behavior.

      Specified by:
      findByContextIdIgnoringNarrowing in interface CustomizedScheduledJobRepository<D extends JpaScheduledJob>
      Parameters:
      contextId - the context ID of the job to find
      Returns:
      an Optional containing the job if found, Optional.empty() otherwise
    • getManagedType

      protected Class<D> getManagedType()
    • getTypeFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
    • getRepositoryEntityTypeManager

      protected com.broadleafcommerce.common.jpa.RepositoryEntityTypeManager getRepositoryEntityTypeManager()
    • getRepository

      protected ScheduledJobRepository<D> getRepository()
    • setRepository

      @Autowired @Lazy public void setRepository(ScheduledJobRepository<D> repository)
    • getDetailValueConverter

      protected ScheduledJobDetailValueConverter getDetailValueConverter()