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: * BackupTask Task class extends jakarta-ant Task class and uses to start
027: * @author Radoslav Dutina
028: * @version 1.0
029: */
030: public class BackupTask extends Task {
031:
032: protected String generatorOutput = null;
033: protected String sourceDatabase = null;
034: protected String sourceUser = "";
035: protected String sourcePassword = "";
036: protected String sourceType = null;
037: protected String sourceDriverName = "";
038:
039: protected String targetDatabase = null;
040: protected String targetUser = "";
041: protected String targetPassword = "";
042: protected String targetType = null;
043: protected String targetDriverName = "";
044:
045: protected String octopusHome = null;
046:
047: //sql statements
048: protected String generateDropTableStmt = "true";
049: protected String generateDropIntegrityStmt = "true";
050: protected String generateCreateTableStmt = "true";
051: protected String generateCreatePKStmt = "true";
052: protected String generateCreateFKStmt = "true";
053: protected String generateCreateIndexStmt = "true";
054: protected String generateSqlForAllVendors = "true";
055:
056: //xml files
057: protected String fullMode = "true";
058: protected String generateXml = "false";
059: protected String generateDoml = "false";
060: protected String restoreMode = "false";
061:
062: protected String valueMode = "copy";
063: protected String includeTableList = "";
064: protected String confJarStructure = "";
065:
066: public BackupTask() {
067: }
068:
069: /**
070: *
071: * @throws org.apache.tools.ant.BuildException
072: */
073: public void execute() throws org.apache.tools.ant.BuildException {
074: if (sourceDatabase == null) {
075: throw new BuildException(
076: "sourceDatabase attribute must be set!");
077: }
078: if (sourceType == null) {
079: throw new BuildException(
080: "sourceDatabaseType attribute must be set!");
081: }
082: if (targetDatabase == null) {
083: throw new BuildException(
084: "targetDatabase attribute must be set!");
085: }
086: if (targetType == null) {
087: throw new BuildException(
088: "targetDatabaseType attribute must be set!");
089: }
090: if (octopusHome != null)
091: System.setProperty("OCTOPUS_HOME", octopusHome);
092:
093: try { //for All Vendors
094: LoaderGenerator loaderGenerator = new LoaderGenerator(
095: sourceType, sourceDatabase, valueMode,
096: generatorOutput, sourceDriverName,
097: targetDriverName, targetDatabase, targetType,
098: sourceUser, sourcePassword, targetUser,
099: targetPassword, null, null, generateDropTableStmt,
100: generateDropIntegrityStmt, generateCreateTableStmt,
101: generateCreatePKStmt, generateCreateFKStmt,
102: generateCreateIndexStmt, generateSqlForAllVendors,
103: generateXml, generateDoml, fullMode, restoreMode,
104: includeTableList, confJarStructure);
105:
106: loaderGenerator.generate();
107: } catch (Exception ex) {
108: ex.printStackTrace();
109: }
110:
111: try { //for specific vendor
112: this .generateSqlForAllVendors = "false";
113: this .generateXml = "true";
114: this .fullMode = "false";
115:
116: LoaderGenerator loaderGenerator = new LoaderGenerator(
117: sourceType, sourceDatabase, "copy",
118: generatorOutput, sourceDriverName,
119: targetDriverName, targetDatabase, targetType,
120: sourceUser, sourcePassword, targetUser,
121: targetPassword, null, null, generateDropTableStmt,
122: generateDropIntegrityStmt, generateCreateTableStmt,
123: generateCreatePKStmt, generateCreateFKStmt,
124: generateCreateIndexStmt, generateSqlForAllVendors,
125: generateXml, generateDoml, fullMode, "false",
126: includeTableList, confJarStructure);
127:
128: loaderGenerator.generate();
129:
130: } catch (Exception ex) {
131: ex.printStackTrace();
132: }
133: try { //Octopus loader
134: String loadJobFileName = "";
135: if (!generatorOutput.equalsIgnoreCase("")) {
136: File file = new File(this .generatorOutput);
137: generatorOutput = file.getAbsolutePath();
138: loadJobFileName = generatorOutput
139: + System.getProperty("file.separator")
140: + "LoaderJob.olj";
141: } else {
142: loadJobFileName = "LoaderJob.olj";
143: }
144: Loader octopusLoader = new Loader(loadJobFileName,
145: confJarStructure);
146: octopusLoader.load();
147: } catch (Exception ex) {
148: ex.printStackTrace();
149: }
150:
151: }
152:
153: /**
154: * This method set value of confJarStructure parameter
155: * @param confJarStructure is value of parameter
156: */
157: public void setConfJarStructure(String confJarStructure) {
158: this .confJarStructure = confJarStructure;
159: }
160:
161: /**
162: * This method read value of confJarStructure parameter
163: * @return value of parameter
164: */
165: public String getConfJarStructure() {
166: return this .confJarStructure;
167: }
168:
169: /**
170: * This method set value of includeTableList parameter
171: * @param includeTableList is value of parameter
172: */
173: public void setIncludeTableList(String includeTableList) {
174: this .includeTableList = includeTableList;
175: }
176:
177: /**
178: * This method read value of includeTableList parameter
179: * @return value of parameter
180: */
181: public String getIncludeTableList() {
182: return this .includeTableList;
183: }
184:
185: /**
186: * This method set value of generatorOutput parameter
187: * @param generatorOutput is value of parameter
188: */
189: public void setGeneratorOutput(String generatorOutput) {
190: this .generatorOutput = generatorOutput;
191: }
192:
193: /**
194: * This method read value of generatorOutput parameter
195: * @return value of parameter
196: */
197: public String getGeneratorOutput() {
198: return this .generatorOutput;
199: }
200:
201: /**
202: * This method set value of sourceDatabase parameter
203: * @param sourceDatabase is value of parameter
204: */
205: public void setSourceDatabase(String sourceDatabase) {
206: this .sourceDatabase = sourceDatabase;
207: }
208:
209: /**
210: * This method read value of sourceDatabase parameter
211: * @return value of parameter
212: */
213: public String getSourceDatabase() {
214: return this .sourceDatabase;
215: }
216:
217: /**
218: * This method set value of sourceUser parameter
219: * @param sourceUser is value of parameter
220: */
221: public void setSourceUser(String sourceUser) {
222: this .sourceUser = sourceUser;
223: }
224:
225: /**
226: * This method read value of sourceUser parameter
227: * @return value of parameter
228: */
229: public String getSourceUser() {
230: return this .sourceUser;
231: }
232:
233: /**
234: * This method set value of sourcePassword parameter
235: * @param sourcePassword is value of parameter
236: */
237: public void setSourcePassword(String sourcePassword) {
238: this .sourcePassword = sourcePassword;
239: }
240:
241: /**
242: * This method read value of sourcePassword parameter
243: * @return value of parameter
244: */
245: public String getSourcePassword() {
246: return this .sourcePassword;
247: }
248:
249: /**
250: * This method set value of sourceType parameter
251: * @param sourceType is value of parameter
252: */
253: public void setSourceType(String sourceType) {
254: this .sourceType = sourceType;
255: }
256:
257: /**
258: * This method read value of sourceType parameter
259: * @return value of parameter
260: */
261: public String getSourceType() {
262: return this .sourceType;
263: }
264:
265: /**
266: * This method set value of sourceDriverName parameter
267: * @param sourceDriverName is value of parameter
268: */
269: public void setSourceDriverName(String sourceDriverName) {
270: this .sourceDriverName = sourceDriverName;
271: }
272:
273: /**
274: * This method read value of sourceDriverName parameter
275: * @return value of parameter
276: */
277: public String getSourceDriverName() {
278: return this .sourceDriverName;
279: }
280:
281: /**
282: * This method set value of targetDatabase parameter
283: * @param targetDatabase is value of parameter
284: */
285: public void setTargetDatabase(String targetDatabase) {
286: this .targetDatabase = targetDatabase;
287: }
288:
289: /**
290: * This method read value of targetDatabase parameter
291: * @return value of parameter
292: */
293: public String getTargetDatabase() {
294: return this .targetDatabase;
295: }
296:
297: /**
298: * This method set value of targetUser parameter
299: * @param targetUser is value of parameter
300: */
301: public void setTargetUser(String targetUser) {
302: this .targetUser = targetUser;
303: }
304:
305: /**
306: * This method read value of targetDatabase parameter
307: * @return value of parameter
308: */
309: public String getTargetUser() {
310: return this .targetUser;
311: }
312:
313: /**
314: * This method set value of targetPassword parameter
315: * @param targetPassword is value of parameter
316: */
317: public void setTargetPassword(String targetPassword) {
318: this .targetPassword = targetPassword;
319: }
320:
321: /**
322: * This method read value of targetPassword parameter
323: * @return value of parameter
324: */
325: public String getTargetPassword() {
326: return this .targetPassword;
327: }
328:
329: /**
330: * This method set value of targetType parameter
331: * @param targetType is value of parameter
332: */
333: public void setTargetType(String targetType) {
334: this .targetType = targetType;
335: }
336:
337: /**
338: * This method read value of targetType parameter
339: * @return value of parameter
340: */
341: public String getTargetType() {
342: return this .targetType;
343: }
344:
345: /**
346: * This method set value of targetDriverName parameter
347: * @param targetDriverName is value of parameter
348: */
349: public void setTargetDriverName(String targetDriverName) {
350: this .targetDriverName = targetDriverName;
351: }
352:
353: /**
354: * This method read value of targetDriverName parameter
355: * @return value of parameter
356: */
357: public String getTargetDriverName() {
358: return this .targetDriverName;
359: }
360:
361: /**
362: * This method set value of octopusHome parameter
363: * @param octopusHome is value of parameter
364: */
365: public void setOctopusHome(String octopusHome) {
366: this .octopusHome = octopusHome;
367: }
368:
369: /**
370: * This method read value of octopusHome parameter
371: * @return value of parameter
372: */
373: public String getOctopusHome() {
374: return this.octopusHome;
375: }
376:
377: }
|