private boolean executeIfScheduled(final T doc,
                                       final TaskContext parentTaskContext,
                                       final ExecutionSchedule executionSchedule) {
        final Optional<ExecutionSchedule> optionalSchedule = executionScheduleDao
                .fetchScheduleById(executionSchedule.getId());
        if (optionalSchedule.isEmpty()) {
            return false;
        }
        final ExecutionSchedule schedule = optionalSchedule.get();
        if (!schedule.isEnabled()) {
            return false;
        }

        // Reload the rule in case it has changed since last executed.
        final DocRef docRef = doc.asDocRef();
        final T reloaded = load(docRef);

        if (reloaded == null || !AnalyticProcessType.SCHEDULED_QUERY.equals(reloaded.getAnalyticProcessType())) {
            return false;
        }

        return taskContextFactory.childContextResult(
                parentTaskContext,
                "Scheduled " + processType + ": " +
                RuleUtil.getRuleIdentity(reloaded),
                taskContext -> execute(
                        reloaded,
                        schedule,
                        taskContext)).get();
    }
Called at the end of execution to perform any tidy up operations.

@param analyticDocs The list of all known analyticDocs for this executor.
stroom-analytics/stroom-analytics-impl/src/main/java/stroom/analytics/impl/AbstractScheduledQueryExecutor.java