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
21 import org.springframework.batch.core.JobExecution;
22 import org.springframework.batch.core.JobInstance;
23 import org.springframework.batch.core.JobParameters;
24
25 /**
26 * Data Access Object for job instances.
27 *
28 * @author Lucas Ward
29 * @author Robert Kasanicky
30 *
31 */
32 public interface JobInstanceDao {
33
34 /**
35 * Create a JobInstance with given name and parameters.
36 *
37 * PreConditions: JobInstance for given name and parameters must not already
38 * exist
39 *
40 * PostConditions: A valid job instance will be returned which has been
41 * persisted and contains an unique Id.
42 *
43 * @param jobName
44 * @param jobParameters
45 * @return JobInstance
46 */
47 JobInstance createJobInstance(String jobName, JobParameters jobParameters);
48
49 /**
50 * Find the job instance that matches the given name and parameters. If no
51 * matching job instances are found, then returns null.
52 *
53 * @param jobName the name of the job
54 * @param jobParameters the parameters with which the job was executed
55 * @return {@link JobInstance} object matching the job name and
56 * {@link JobParameters} or null
57 */
58 JobInstance getJobInstance(String jobName, JobParameters jobParameters);
59
60 /**
61 * Fetch the job instance with the provided identifier.
62 *
63 * @param instanceId the job identifier
64 * @return the job instance with this identifier or null if it doesn't exist
65 */
66 JobInstance getJobInstance(Long instanceId);
67
68 /**
69 * Fetch the JobInstance for the provided JobExecution.
70 *
71 * @param jobExecution the JobExecution
72 * @return the JobInstance for the provided execution or null if it doesn't exist.
73 */
74 JobInstance getJobInstance(JobExecution jobExecution);
75
76 /**
77 * Fetch the last job instances with the provided name, sorted backwards by
78 * primary key.
79 *
80 *
81 * @param jobName the job name
82 * @param start the start index of the instances to return
83 * @param count the maximum number of objects to return
84 * @return the job instances with this name or empty if none
85 */
86 List<JobInstance> getJobInstances(String jobName, int start, int count);
87
88 /**
89 * Retrieve the names of all job instances sorted alphabetically - i.e. jobs
90 * that have ever been executed.
91 * @return the names of all job instances
92 */
93 List<String> getJobNames();
94
95 }