01: /*
02: * Copyright 2006-2007, Unitils.org
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: package org.unitils.dbmaintainer.script;
17:
18: import org.unitils.dbmaintainer.util.DatabaseTask;
19: import org.unitils.dbmaintainer.version.Version;
20: import org.unitils.dbmaintainer.version.VersionScriptPair;
21:
22: import java.util.List;
23:
24: /**
25: * Defines the contract for a source that provides scripts for updating the database to a given state.<br>
26: * Database update scripts are provided as {@link VersionScriptPair} objects, which indicate which scripts should be
27: * executed, to update the database to a given state.
28: * Code scripts (stored procedures etc) are provides as {@link Script} objects. Database code scripts are regarded to
29: * be repeatably executable on the database. Therefore, all code scripts are always returned as a whole.
30: *
31: * @author Filip Neven
32: * @author Tim Ducheyne
33: */
34: public interface ScriptSource extends DatabaseTask {
35:
36: /**
37: * Returns the current version of the scripts, i.e. the Version object as it would
38: * be returned by a database that is up-to-date with the current script base.
39: *
40: * @return the current version of the scripts
41: */
42: Version getCurrentVersion();
43:
44: /**
45: * This methods returns true if one or more scripts that have a version index equal to or lower than
46: * the index specified by the given version object has been modified since the timestamp specfied by
47: * the given version.
48: *
49: * @param currentVersion The current database version, not null
50: * @return True if an existing script has been modified, false otherwise
51: */
52: boolean existingScriptsModified(Version currentVersion);
53:
54: /**
55: * @param currentVersion The current database version, not null
56: * @return A List containing the scripts that need to be executed to update the database
57: * from the given version to the latest one, not null
58: */
59: List<VersionScriptPair> getNewScripts(Version currentVersion);
60:
61: /**
62: * @return A List containing all available database update scripts. These scripts
63: * can be used to completely recreate the database from scratch, not null
64: */
65: List<VersionScriptPair> getAllScripts();
66:
67: /**
68: * @return The highest timestamp of all the code scripts that are currently available
69: */
70: long getCodeScriptsTimestamp();
71:
72: /**
73: * @return All the code scripts that are currently available, not null
74: */
75: List<Script> getAllCodeScripts();
76:
77: /**
78: * @return All the postprocessing code scripts that are currently available, not null
79: */
80: List<Script> getAllPostProcessingCodeScripts();
81:
82: }
|