1 /*
2 * Copyright 2006-2007 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package org.springframework.batch.core.repository.dao;
18
19 import java.util.List;
20 import java.util.Set;
21
22 import org.springframework.batch.core.JobExecution;
23 import org.springframework.batch.core.JobInstance;
24
25 /**
26 * Data Access Object for job executions.
27 *
28 * @author Lucas Ward
29 * @author Robert Kasanicky
30 */
31 public interface JobExecutionDao {
32
33 /**
34 * Save a new JobExecution.
35 *
36 * Preconditions: jobInstance the jobExecution belongs to must have a
37 * jobInstanceId.
38 *
39 * @param jobExecution
40 */
41 void saveJobExecution(JobExecution jobExecution);
42
43 /**
44 * Update and existing JobExecution.
45 *
46 * Preconditions: jobExecution must have an Id (which can be obtained by the
47 * save method) and a jobInstanceId.
48 *
49 * @param jobExecution
50 */
51 void updateJobExecution(JobExecution jobExecution);
52
53 /**
54 * Return all {@link JobExecution} for given {@link JobInstance}, sorted
55 * backwards by creation order (so the first element is the most recent).
56 */
57 List<JobExecution> findJobExecutions(JobInstance jobInstance);
58
59 /**
60 * Find the last {@link JobExecution} to have been created for a given
61 * {@link JobInstance}.
62 * @param jobInstance the {@link JobInstance}
63 * @return the last {@link JobExecution} to execute for this instance
64 */
65 JobExecution getLastJobExecution(JobInstance jobInstance);
66
67 /**
68 * @return all {@link JobExecution} that are still running (or indeterminate
69 * state), i.e. having null end date, for the specified job name.
70 */
71 Set<JobExecution> findRunningJobExecutions(String jobName);
72
73 /**
74 * @return the {@link JobExecution} for given identifier.
75 */
76 JobExecution getJobExecution(Long executionId);
77
78 /**
79 * Because it may be possible that the status of a JobExecution is updated
80 * while running, the following method will synchronize only the status and
81 * version fields.
82 *
83 * @param jobExecution to be updated.
84 */
85 void synchronizeStatus(JobExecution jobExecution);
86
87 }