001/*
002 * Copyright 2006-2018 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.batch.core.repository.dao;
018
019import java.util.Collection;
020
021import org.springframework.batch.core.JobExecution;
022import org.springframework.batch.core.StepExecution;
023import org.springframework.lang.Nullable;
024
025public interface StepExecutionDao {
026
027        /**
028         * Save the given StepExecution.
029         * 
030         * Preconditions: Id must be null.
031         * 
032         * Postconditions: Id will be set to a unique Long.
033         * 
034         * @param stepExecution {@link StepExecution} instance to be saved.
035         */
036        void saveStepExecution(StepExecution stepExecution);
037
038        /**
039         * Save the given collection of StepExecution as a batch.
040         * 
041         * Preconditions: StepExecution Id must be null.
042         * 
043         * Postconditions: StepExecution Id will be set to a unique Long.
044         * 
045         * @param stepExecutions a collection of {@link JobExecution} instances to be saved.
046         */
047        void saveStepExecutions(Collection<StepExecution> stepExecutions);
048
049        /**
050         * Update the given StepExecution
051         * 
052         * Preconditions: Id must not be null.
053         * 
054         * @param stepExecution {@link StepExecution} instance to be updated.
055         */
056        void updateStepExecution(StepExecution stepExecution);
057
058        /**
059         * Retrieve a {@link StepExecution} from its id.
060         * 
061         * @param jobExecution the parent {@link JobExecution}
062         * @param stepExecutionId the step execution id
063         * @return a {@link StepExecution}
064         */
065        @Nullable
066        StepExecution getStepExecution(JobExecution jobExecution, Long stepExecutionId);
067
068        /**
069         * Retrieve all the {@link StepExecution} for the parent {@link JobExecution}.
070         * 
071         * @param jobExecution the parent job execution
072         */
073        void addStepExecutions(JobExecution jobExecution);
074
075}