001: /*
002: LoaderGenerator - tool for generated xml, sql and doml file needed for Octopus.
003: Copyright (C) 2003 Together
004: This library is free software; you can redistribute it and/or
005: modify it under the terms of the GNU Lesser General Public
006: License as published by the Free Software Foundation; either
007: version 2.1 of the License, or (at your option) any later version.
008: This library is distributed in the hope that it will be useful,
009: but WITHOUT ANY WARRANTY; without even the implied warranty of
010: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
011: Lesser General Public License for more details.
012: You should have received a copy of the GNU Lesser General Public
013: License along with this library; if not, write to the Free Software
014: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
015: */
016:
017: package org.webdocwf.util.loader.task;
018:
019: import org.apache.tools.ant.BuildException;
020: import org.apache.tools.ant.Task;
021: import org.webdocwf.util.loader.generator.LoaderGenerator;
022: import org.webdocwf.util.loader.Loader;
023: import java.io.File;
024:
025: /**
026: * RestoreTask Task class extends jakarta-ant Task class and uses to start
027: * @author Radoslav Dutina
028: * @version 1.0
029: */
030:
031: public class RestoreTask extends Task {
032:
033: protected String generatorOutput = null;
034: protected String sourceDatabase = null;
035: protected String sourceUser = "";
036: protected String sourcePassword = "";
037: protected String sourceType = null;
038: protected String sourceDriverName = "";
039:
040: protected String targetDatabase = null;
041: protected String targetUser = "";
042: protected String targetPassword = "";
043: protected String targetType = null;
044: protected String targetDriverName = "";
045:
046: protected String octopusHome = null;
047:
048: //sql statements
049: protected String generateDropTableStmt = "false";
050: protected String generateDropIntegrityStmt = "false";
051: protected String generateCreateTableStmt = "false";
052: protected String generateCreatePKStmt = "false";
053: protected String generateCreateFKStmt = "false";
054: protected String generateCreateIndexStmt = "false";
055: protected String generateSqlForAllVendors = "false";
056:
057: //xml files
058: protected String fullMode = "false";
059: protected String generateXml = "true";
060: protected String generateDoml = "false";
061: protected String restoreMode = "true";
062:
063: protected String valueMode = "copy";
064: protected String includeTableList = "";
065: protected String confJarStructure = "";
066:
067: public RestoreTask() {
068: }
069:
070: /**
071: *
072: * @throws org.apache.tools.ant.BuildException
073: */
074: public void execute() throws org.apache.tools.ant.BuildException {
075: if (sourceDatabase == null) {
076: throw new BuildException(
077: "sourceDatabase attribute must be set!");
078: }
079: if (sourceType == null) {
080: throw new BuildException(
081: "sourceDatabaseType attribute must be set!");
082: }
083: if (targetDatabase == null) {
084: throw new BuildException(
085: "targetDatabase attribute must be set!");
086: }
087: if (targetType == null) {
088: throw new BuildException(
089: "targetDatabaseType attribute must be set!");
090: }
091: if (octopusHome != null)
092: System.setProperty("OCTOPUS_HOME", octopusHome);
093:
094: try {
095: LoaderGenerator loaderGenerator = new LoaderGenerator(
096: sourceType, sourceDatabase, valueMode,
097: generatorOutput, sourceDriverName,
098: targetDriverName, targetDatabase, targetType,
099: sourceUser, sourcePassword, targetUser,
100: targetPassword, null, null, generateDropTableStmt,
101: generateDropIntegrityStmt, generateCreateTableStmt,
102: generateCreatePKStmt, generateCreateFKStmt,
103: generateCreateIndexStmt, generateSqlForAllVendors,
104: generateXml, generateDoml, fullMode, restoreMode,
105: includeTableList, confJarStructure);
106: loaderGenerator.generate();
107: } catch (Exception ex) {
108: ex.printStackTrace();
109: }
110:
111: try { //Octopus loader
112: String loadJobFileName = "";
113: if (!generatorOutput.equalsIgnoreCase("")) {
114: File file = new File(generatorOutput);
115: generatorOutput = file.getAbsolutePath();
116: loadJobFileName = generatorOutput
117: + System.getProperty("file.separator")
118: + "LoaderJob.olj";
119: } else {
120: loadJobFileName = "LoaderJob.olj";
121: }
122: Loader octopusLoader = new Loader(loadJobFileName,
123: confJarStructure);
124: octopusLoader.load();
125: } catch (Exception ex) {
126: ex.printStackTrace();
127: }
128:
129: }
130:
131: /**
132: * This method set value of confJarStructure parameter
133: * @param confJarStructure is value of parameter
134: */
135: public void setConfJarStructure(String confJarStructure) {
136: this .confJarStructure = confJarStructure;
137: }
138:
139: /**
140: * This method read value of confJarStructure parameter
141: * @return value of parameter
142: */
143: public String getConfJarStructure() {
144: return this .confJarStructure;
145: }
146:
147: /**
148: * This method set value of includeTableList parameter
149: * @param includeTableList is value of parameter
150: */
151: public void setIncludeTableList(String includeTableList) {
152: this .includeTableList = includeTableList;
153: }
154:
155: /**
156: * This method read value of includeTableList parameter
157: * @return value of parameter
158: */
159: public String getIncludeTableList() {
160: return this .includeTableList;
161: }
162:
163: /**
164: * This method set value of generatorOutput parameter
165: * @param generatorOutput is value of parameter
166: */
167: public void setGeneratorOutput(String generatorOutput) {
168: this .generatorOutput = generatorOutput;
169: }
170:
171: /**
172: * This method read value of generatorOutput parameter
173: * @return value of parameter
174: */
175: public String getGeneratorOutput() {
176: return this .generatorOutput;
177: }
178:
179: /**
180: * This method set value of sourceDatabase parameter
181: * @param sourceDatabase is value of parameter
182: */
183: public void setSourceDatabase(String sourceDatabase) {
184: this .sourceDatabase = sourceDatabase;
185: }
186:
187: /**
188: * This method read value of sourceDatabase parameter
189: * @return value of parameter
190: */
191: public String getSourceDatabase() {
192: return this .sourceDatabase;
193: }
194:
195: /**
196: * This method set value of sourceUser parameter
197: * @param sourceUser is value of parameter
198: */
199: public void setSourceUser(String sourceUser) {
200: this .sourceUser = sourceUser;
201: }
202:
203: /**
204: * This method read value of sourceUser parameter
205: * @return value of parameter
206: */
207: public String getSourceUser() {
208: return this .sourceUser;
209: }
210:
211: /**
212: * This method set value of sourcePassword parameter
213: * @param sourcePassword is value of parameter
214: */
215: public void setSourcePassword(String sourcePassword) {
216: this .sourcePassword = sourcePassword;
217: }
218:
219: /**
220: * This method read value of sourcePassword parameter
221: * @return value of parameter
222: */
223: public String getSourcePassword() {
224: return this .sourcePassword;
225: }
226:
227: /**
228: * This method set value of sourceType parameter
229: * @param sourceType is value of parameter
230: */
231: public void setSourceType(String sourceType) {
232: this .sourceType = sourceType;
233: }
234:
235: /**
236: * This method read value of sourceType parameter
237: * @return value of parameter
238: */
239: public String getSourceType() {
240: return this .sourceType;
241: }
242:
243: /**
244: * This method set value of sourceDriverName parameter
245: * @param sourceDriverName is value of parameter
246: */
247: public void setSourceDriverName(String sourceDriverName) {
248: this .sourceDriverName = sourceDriverName;
249: }
250:
251: /**
252: * This method read value of sourceDriverName parameter
253: * @return value of parameter
254: */
255: public String getSourceDriverName() {
256: return this .sourceDriverName;
257: }
258:
259: /**
260: * This method set value of targetDatabase parameter
261: * @param targetDatabase is value of parameter
262: */
263: public void setTargetDatabase(String targetDatabase) {
264: this .targetDatabase = targetDatabase;
265: }
266:
267: /**
268: * This method read value of targetDatabase parameter
269: * @return value of parameter
270: */
271: public String getTargetDatabase() {
272: return this .targetDatabase;
273: }
274:
275: /**
276: * This method set value of targetUser parameter
277: * @param targetUser is value of parameter
278: */
279: public void setTargetUser(String targetUser) {
280: this .targetUser = targetUser;
281: }
282:
283: /**
284: * This method read value of targetDatabase parameter
285: * @return value of parameter
286: */
287: public String getTargetUser() {
288: return this .targetUser;
289: }
290:
291: /**
292: * This method set value of targetPassword parameter
293: * @param targetPassword is value of parameter
294: */
295: public void setTargetPassword(String targetPassword) {
296: this .targetPassword = targetPassword;
297: }
298:
299: /**
300: * This method read value of targetPassword parameter
301: * @return value of parameter
302: */
303: public String getTargetPassword() {
304: return this .targetPassword;
305: }
306:
307: /**
308: * This method set value of targetType parameter
309: * @param targetType is value of parameter
310: */
311: public void setTargetType(String targetType) {
312: this .targetType = targetType;
313: }
314:
315: /**
316: * This method read value of targetType parameter
317: * @return value of parameter
318: */
319: public String getTargetType() {
320: return this .targetType;
321: }
322:
323: /**
324: * This method set value of targetDriverName parameter
325: * @param targetDriverName is value of parameter
326: */
327: public void setTargetDriverName(String targetDriverName) {
328: this .targetDriverName = targetDriverName;
329: }
330:
331: /**
332: * This method read value of targetDriverName parameter
333: * @return value of parameter
334: */
335: public String getTargetDriverName() {
336: return this .targetDriverName;
337: }
338:
339: /**
340: * This method set value of octopusHome parameter
341: * @param octopusHome is value of parameter
342: */
343: public void setOctopusHome(String octopusHome) {
344: this .octopusHome = octopusHome;
345: }
346:
347: /**
348: * This method read value of octopusHome parameter
349: * @return value of parameter
350: */
351: public String getOctopusHome() {
352: return this.octopusHome;
353: }
354:
355: }
|