Search in sources :

Example 1 with JobExecution

use of org.molgenis.jobs.model.JobExecution in project molgenis by molgenis.

the class ProgressImplTest method beforeMethod.

@BeforeMethod
public void beforeMethod() {
    jobExecution = new JobExecution(jobExecutionMeta) {
    };
    jobExecution.setIdentifier("ABCDE");
    jobExecution.setType("Annotator");
    progress = new ProgressImpl(jobExecution, updater, mailSender);
}
Also used : JobExecution(org.molgenis.jobs.model.JobExecution) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with JobExecution

use of org.molgenis.jobs.model.JobExecution in project molgenis by molgenis.

the class JobExecutor method createJobExecution.

private JobExecution createJobExecution(ScheduledJob scheduledJob) {
    JobExecution jobExecution = (JobExecution) entityManager.create(scheduledJob.getType().getJobExecutionType(), POPULATE);
    writePropertyValues(jobExecution, getPropertyValues(scheduledJob.getParameters()));
    jobExecution.setFailureEmail(scheduledJob.getFailureEmail());
    jobExecution.setSuccessEmail(scheduledJob.getSuccessEmail());
    jobExecution.setUser(scheduledJob.getUser());
    jobExecution.setScheduledJobId(scheduledJob.getId());
    return jobExecution;
}
Also used : JobExecution(org.molgenis.jobs.model.JobExecution)

Example 3 with JobExecution

use of org.molgenis.jobs.model.JobExecution in project molgenis by molgenis.

the class JobExecutor method executeScheduledJob.

/**
 * Executes a {@link ScheduledJob} in the current thread.
 *
 * @param scheduledJobId ID of the {@link ScheduledJob} to run
 */
@RunAsSystem
public void executeScheduledJob(String scheduledJobId) {
    ScheduledJob scheduledJob = dataService.findOneById(SCHEDULED_JOB, scheduledJobId, ScheduledJob.class);
    JobExecution jobExecution = createJobExecution(scheduledJob);
    Job molgenisJob = saveExecutionAndCreateJob(jobExecution);
    try {
        runJob(jobExecution, molgenisJob);
    } catch (Exception ex) {
        LOG.error("Error creating job for JobExecution.", ex);
        jobExecution.setStatus(JobExecution.Status.FAILED);
        jobExecution.setProgressMessage(ex.getMessage());
        dataService.update(jobExecution.getEntityType().getId(), jobExecution);
        throw ex;
    }
}
Also used : JobExecution(org.molgenis.jobs.model.JobExecution) ScheduledJob(org.molgenis.jobs.model.ScheduledJob) ScheduledJob(org.molgenis.jobs.model.ScheduledJob) RunAsSystem(org.molgenis.security.core.runas.RunAsSystem)

Aggregations

JobExecution (org.molgenis.jobs.model.JobExecution)3 ScheduledJob (org.molgenis.jobs.model.ScheduledJob)1 RunAsSystem (org.molgenis.security.core.runas.RunAsSystem)1 BeforeMethod (org.testng.annotations.BeforeMethod)1