Java Code Examples for org.springframework.batch.core.JobExecution#getId()

The following examples show how to use org.springframework.batch.core.JobExecution#getId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JobExecutionThinResource.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
public JobExecutionThinResource(TaskJobExecution taskJobExecution, TimeZone timeZone) {
	Assert.notNull(taskJobExecution, "taskJobExecution must not be null");
	this.taskExecutionId = taskJobExecution.getTaskId();
	JobExecution jobExecution = taskJobExecution.getJobExecution();
	this.timeZone = timeZone;
	this.executionId = jobExecution.getId();
	this.jobId = jobExecution.getJobId();
	this.stepExecutionCount = taskJobExecution.getStepExecutionCount();
	this.jobParameters =converter.getProperties(jobExecution.getJobParameters());
	this.jobParametersString = fromJobParameters(
			this.argumentSanitizer.sanitizeJobParameters(jobExecution.getJobParameters()));
	this.defined = taskJobExecution.isTaskDefined();
	JobInstance jobInstance = jobExecution.getJobInstance();
	this.status = taskJobExecution.getJobExecution().getStatus();
	if (jobInstance != null) {
		this.name = jobInstance.getJobName();
		this.restartable = JobUtils.isJobExecutionRestartable(jobExecution);
		this.abandonable = JobUtils.isJobExecutionAbandonable(jobExecution);
		this.stoppable = JobUtils.isJobExecutionStoppable(jobExecution);
		this.instanceId = jobExecution.getJobInstance().getInstanceId();
	}
	else {
		this.name = "?";
	}

	// Duration is always in GMT
	durationFormat.setTimeZone(TimeUtils.getDefaultTimeZone());
	// The others can be localized
	timeFormat.setTimeZone(timeZone);
	dateFormat.setTimeZone(timeZone);
	if (jobExecution.getStartTime() != null) {
		this.startDate = dateFormat.format(jobExecution.getStartTime());
		this.startTime = timeFormat.format(jobExecution.getStartTime());
		Date endTime = jobExecution.getEndTime() != null ? jobExecution.getEndTime() : new Date();
		this.duration = durationFormat.format(new Date(endTime.getTime() - jobExecution.getStartTime().getTime()));
		this.startDateTime = jobExecution.getStartTime();
	}

}
 
Example 2
Source File: JobStepExecutionsDocumentation.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
private void createJobExecution(String name, BatchStatus status) {
	TaskExecution taskExecution = this.dao.createTaskExecution(name, new Date(), new ArrayList<>(), null);
	JobExecution jobExecution = this.jobRepository.createJobExecution(this.jobRepository.createJobInstance(name, new JobParameters()), new JobParameters(), null);
	StepExecution stepExecution = new StepExecution(name + "_STEP", jobExecution, jobExecution.getId());
	stepExecution.setId(null);
	jobRepository.add(stepExecution);
	this.taskBatchDao.saveRelationship(taskExecution, jobExecution);
	jobExecution.setStatus(status);
	jobExecution.setStartTime(new Date());
	this.jobRepository.update(jobExecution);
}
 
Example 3
Source File: CommonControllerIT.java    From spring-batch-lightmin with Apache License 2.0 5 votes vote down vote up
protected void launchSimpleJob() {
    try {
        final JobExecution execution = this.jobLauncher.run(this.simpleJob, new JobParametersBuilder().addDate("date", new
                Date()).toJobParameters());
        this.launchedJobExecutionId = execution.getId();
        this.launchedJobInstanceId = execution.getJobInstance().getId();
        this.launchedStepExecutionId = execution.getStepExecutions().iterator().next().getId();
    } catch (final Exception e) {
        fail(e.getMessage());
    }
}
 
Example 4
Source File: AbstractServiceDocumentation.java    From spring-batch-lightmin with Apache License 2.0 5 votes vote down vote up
protected void launchSimpleJob() {
    try {
        final JobExecution execution = this.jobLauncher.run(this.simpleJob, new JobParametersBuilder().addDate("date", new
                Date()).toJobParameters());
        this.launchedJobExecutionId = execution.getId();
        this.launchedJobInstanceId = execution.getJobInstance().getId();
        this.launchedStepExecutionId = execution.getStepExecutions().iterator().next().getId();
    } catch (final Exception e) {
        fail(e.getMessage());
    }
}
 
Example 5
Source File: AbstractServiceDocumentation.java    From spring-batch-lightmin with Apache License 2.0 5 votes vote down vote up
protected void launchSimpleJobWithOutParameters() {
    try {
        final JobExecution execution = this.jobLauncher.run(this.simpleJob, new JobParametersBuilder().toJobParameters());
        this.launchedJobExecutionId = execution.getId();
        this.launchedJobInstanceId = execution.getJobInstance().getId();
        this.launchedStepExecutionId = execution.getStepExecutions().iterator().next().getId();
    } catch (final Exception e) {
        fail(e.getMessage());
    }
}
 
Example 6
Source File: AbstractServiceDocumentation.java    From spring-batch-lightmin with Apache License 2.0 5 votes vote down vote up
protected void launchSimpleBlockingJob() {
    try {
        this.myThread = new MyThread(this.jobLauncher, this.simpleBlockingJob);
        this.myThread.start();
        Thread.sleep(500);
        final Set<JobExecution> jobExecutions = this.jobExplorer.findRunningJobExecutions(this.simpleBlockingJob.getName());
        final JobExecution execution = jobExecutions.iterator().next();
        this.launchedJobExecutionId = execution.getId();
        this.launchedJobInstanceId = execution.getJobInstance().getId();
        this.launchedStepExecutionId = execution.getStepExecutions().iterator().next().getId();
    } catch (final Exception e) {
        fail(e.getMessage());
    }
}
 
Example 7
Source File: JobExecutionMapper.java    From batchers with Apache License 2.0 4 votes vote down vote up
private String getDescription(JobExecution jobExec) {
    return jobExec.getJobParameters().getLong(JobStartParams.MONTH) + "/" + jobExec.getJobParameters().getLong(JobStartParams.YEAR)
            + ", id :" + jobExec.getId();
}