@@ -0,0 +1,1700 @@
+package org.ohdsi.webapi;%0A%0Aimport org.springframework.batch.core.BatchStatus;%0Aimport org.springframework.batch.core.ExitStatus;%0Aimport org.springframework.batch.core.explore.JobExplorer;%0Aimport org.springframework.batch.core.repository.JobRepository;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.stereotype.Component;%0Aimport org.springframework.transaction.support.TransactionTemplate;%0A%0Aimport javax.annotation.PostConstruct;%0Aimport java.util.Calendar;%0A%0A@Component%0Apublic class JobInvalidator %7B%0A%0A    private final JobExplorer jobExplorer;%0A    private final JobRepository jobRepository;%0A    private final TransactionTemplate transactionTemplateRequiresNew;%0A%0A    @Autowired%0A    public JobInvalidator(JobExplorer explorer, JobRepository repository, TransactionTemplate transactionTemplateRequiresNew) %7B%0A%0A        this.jobExplorer = explorer;%0A        this.jobRepository = repository;%0A        this.transactionTemplateRequiresNew = transactionTemplateRequiresNew;%0A    %7D%0A%0A    @PostConstruct%0A    private void invalidateGenerations() %7B%0A        transactionTemplateRequiresNew.execute(s -%3E %7B%0A            jobExplorer.getJobNames().forEach(%0A                    name -%3E jobExplorer.findRunningJobExecutions(name)%0A                            .forEach(job -%3E %7B%0A                                job.setStatus(BatchStatus.FAILED);%0A                                job.setExitStatus(new ExitStatus(ExitStatus.FAILED.getExitCode(), %22Invalidated by system%22));%0A                                job.setEndTime(Calendar.getInstance().getTime());%0A                                jobRepository.update(job);%0A                            %7D));%0A            return null;%0A        %7D);%0A    %7D%0A%7D%0A

Add job invalidation (#646)