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 Summary
ConstructorsConstructorDescriptionJpaCustomizedScheduledJobRepository(com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.broadleafcommerce.common.jpa.RepositoryEntityTypeManager repositoryEntityTypeManager) -
Method Summary
Modifier and TypeMethodDescriptionprotected jakarta.persistence.criteria.PredicatebuildContextIdFilter(String scheduledJobContextId, jakarta.persistence.criteria.Root<D> scheduledJobEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) protected jakarta.persistence.criteria.PredicatebuildExecutedNotFilter(boolean executedNot, jakarta.persistence.criteria.Root<D> scheduledJobEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) establishTriggerStateIfApplicable(String contextId) Establish theNotificationStateAwarecontract forTriggeredJobEventProducer.TYPE.findByContextIdIgnoringNarrowing(String contextId) Retrieves the job whoseScheduledJob#contextIdmatches the one supplied.protected ScheduledJobDetailValueConverterprotected ScheduledJobRepository<D>protected com.broadleafcommerce.common.jpa.RepositoryEntityTypeManagerprotected com.broadleafcommerce.common.extension.TypeFactoryprotected voidinitializeNotificationState(D entity, String notificationStateName, Instant changeTimestamp) markJobAsExecuted(String contextId, TimingType timingType) Mark a job as executed viaScheduledJob.isExecuted().resetNotificationStateByNameAndJobDetailsContaining(String notificationStateToReset, String detailName, Object detailValue) Finds the job whoseScheduledJob.detailscontains aScheduledJobDetailwith the givenScheduledJobDetail.nameandScheduledJobDetail#value, and resets the notification state with the matching name.voidsetRepository(ScheduledJobRepository<D> repository) streamAll(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Read a stream of all ScheduledJobs in the data store.
-
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:CustomizedScheduledJobRepositoryRead a stream of all ScheduledJobs in the data store.- Specified by:
streamAllin interfaceCustomizedScheduledJobRepository<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:CustomizedScheduledJobRepositoryEstablish theNotificationStateAwarecontract forTriggeredJobEventProducer.TYPE. This should initialize the basic support for a trigger typeNotificationStateitem in theNotificationStateAware.getNotificationStates()list. This state is generally completed during theCustomizedScheduledJobRepository.markJobAsExecuted(String, TimingType)lifecycle.- Specified by:
establishTriggerStateIfApplicablein interfaceCustomizedScheduledJobRepository<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:CustomizedScheduledJobRepositoryMark a job as executed viaScheduledJob.isExecuted(). As part of an atomic operation, this method should also set theScheduledJob.getLastExecuted()field and disable the job viaScheduledJob.isEnabled()if the job is ofTimingType.TARGET_DATE. Finally, theNotificationStateof typeTriggeredJobEventProducer.TYPEshould be configured to start the resiliency lifecycle. SeeNotificationStatefor more information on the fields there related to messaging resiliency.- Specified by:
markJobAsExecutedin interfaceCustomizedScheduledJobRepository<D extends JpaScheduledJob>- Parameters:
contextId- The tracking identifier for the scheduled jobtimingType- 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
-
buildExecutedNotFilter
-
initializeNotificationState
-
resetNotificationStateByNameAndJobDetailsContaining
@NonNull @Transactional(transactionManager="scheduledJobTransactionManager") public Optional<D> resetNotificationStateByNameAndJobDetailsContaining(@NonNull String notificationStateToReset, String detailName, Object detailValue) Description copied from interface:CustomizedScheduledJobRepositoryFinds the job whoseScheduledJob.detailscontains aScheduledJobDetailwith the givenScheduledJobDetail.nameandScheduledJobDetail#value, and resets the notification state with the matching name.- Specified by:
resetNotificationStateByNameAndJobDetailsContainingin interfaceCustomizedScheduledJobRepository<D extends JpaScheduledJob>detailName- theScheduledJobDetail.namethat the detail should havedetailValue- theScheduledJobDetail#valuethat the detail should have- Returns:
- an
Optionalcontaining the updated job if updated,Optional.empty()otherwise
-
findByContextIdIgnoringNarrowing
Description copied from interface:CustomizedScheduledJobRepositoryRetrieves the job whoseScheduledJob#contextIdmatches the one supplied. UnlikeTrackableRepository.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:
findByContextIdIgnoringNarrowingin interfaceCustomizedScheduledJobRepository<D extends JpaScheduledJob>- Parameters:
contextId- the context ID of the job to find- Returns:
- an
Optionalcontaining the job if found,Optional.empty()otherwise
-
getManagedType
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getRepositoryEntityTypeManager
protected com.broadleafcommerce.common.jpa.RepositoryEntityTypeManager getRepositoryEntityTypeManager() -
getRepository
-
setRepository
-
getDetailValueConverter
-