KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > webdocwf > util > loader > task > BackupTask


1 /*
2      LoaderGenerator - tool for generated xml, sql and doml file needed for Octopus.
3     Copyright (C) 2003 Together
4     This library is free software; you can redistribute it and/or
5     modify it under the terms of the GNU Lesser General Public
6     License as published by the Free Software Foundation; either
7     version 2.1 of the License, or (at your option) any later version.
8     This library is distributed in the hope that it will be useful,
9     but WITHOUT ANY WARRANTY; without even the implied warranty of
10     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11     Lesser General Public License for more details.
12     You should have received a copy of the GNU Lesser General Public
13     License along with this library; if not, write to the Free Software
14     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15  */

16
17
18 package org.webdocwf.util.loader.task;
19
20 import org.apache.tools.ant.BuildException;
21 import org.apache.tools.ant.Task;
22 import org.webdocwf.util.loader.generator.LoaderGenerator;
23 import org.webdocwf.util.loader.Loader;
24 import java.io.File JavaDoc;
25
26 /**
27  * BackupTask Task class extends jakarta-ant Task class and uses to start
28  * @author Radoslav Dutina
29  * @version 1.0
30  */

31 public class BackupTask
32     extends Task {
33
34   protected String JavaDoc generatorOutput = null;
35   protected String JavaDoc sourceDatabase = null;
36   protected String JavaDoc sourceUser = "";
37   protected String JavaDoc sourcePassword = "";
38   protected String JavaDoc sourceType = null;
39   protected String JavaDoc sourceDriverName = "";
40
41   protected String JavaDoc targetDatabase = null;
42   protected String JavaDoc targetUser = "";
43   protected String JavaDoc targetPassword = "";
44   protected String JavaDoc targetType = null;
45   protected String JavaDoc targetDriverName = "";
46
47   protected String JavaDoc octopusHome = null;
48
49   //sql statements
50
protected String JavaDoc generateDropTableStmt = "true";
51   protected String JavaDoc generateDropIntegrityStmt = "true";
52   protected String JavaDoc generateCreateTableStmt = "true";
53   protected String JavaDoc generateCreatePKStmt = "true";
54   protected String JavaDoc generateCreateFKStmt = "true";
55   protected String JavaDoc generateCreateIndexStmt = "true";
56   protected String JavaDoc generateSqlForAllVendors = "true";
57
58   //xml files
59
protected String JavaDoc fullMode = "true";
60   protected String JavaDoc generateXml = "false";
61   protected String JavaDoc generateDoml = "false";
62   protected String JavaDoc restoreMode = "false";
63
64   protected String JavaDoc valueMode = "copy";
65   protected String JavaDoc includeTableList="";
66   protected String JavaDoc confJarStructure="";
67
68   public BackupTask() {
69   }
70
71   /**
72    *
73    * @throws org.apache.tools.ant.BuildException
74    */

75   public void execute() throws org.apache.tools.ant.BuildException {
76     if (sourceDatabase == null) {
77       throw new BuildException("sourceDatabase attribute must be set!");
78     }
79     if (sourceType == null) {
80       throw new BuildException("sourceDatabaseType attribute must be set!");
81     }
82     if (targetDatabase == null) {
83       throw new BuildException("targetDatabase attribute must be set!");
84     }
85     if (targetType == null) {
86       throw new BuildException("targetDatabaseType attribute must be set!");
87     }
88     if (octopusHome != null)
89       System.setProperty("OCTOPUS_HOME", octopusHome);
90
91     try { //for All Vendors
92
LoaderGenerator loaderGenerator = new LoaderGenerator(sourceType,
93           sourceDatabase,valueMode, generatorOutput, sourceDriverName,
94           targetDriverName, targetDatabase, targetType, sourceUser,
95           sourcePassword, targetUser, targetPassword, null, null,
96           generateDropTableStmt,generateDropIntegrityStmt, generateCreateTableStmt,
97           generateCreatePKStmt,generateCreateFKStmt,generateCreateIndexStmt,
98           generateSqlForAllVendors, generateXml,generateDoml,
99           fullMode, restoreMode, includeTableList,confJarStructure);
100
101       loaderGenerator.generate();
102     }
103     catch (Exception JavaDoc ex) {
104       ex.printStackTrace();
105     }
106
107     try { //for specific vendor
108
this.generateSqlForAllVendors = "false";
109       this.generateXml = "true";
110       this.fullMode = "false";
111
112       LoaderGenerator loaderGenerator = new LoaderGenerator(
113           sourceType, sourceDatabase,
114           "copy", generatorOutput, sourceDriverName,
115           targetDriverName, targetDatabase, targetType, sourceUser,
116           sourcePassword, targetUser, targetPassword, null, null,
117           generateDropTableStmt,generateDropIntegrityStmt ,generateCreateTableStmt,
118           generateCreatePKStmt, generateCreateFKStmt,
119           generateCreateIndexStmt, generateSqlForAllVendors, generateXml,
120           generateDoml,fullMode, "false", includeTableList,confJarStructure);
121
122       loaderGenerator.generate();
123
124     }
125     catch (Exception JavaDoc ex) {
126       ex.printStackTrace();
127     }
128     try { //Octopus loader
129
String JavaDoc loadJobFileName = "";
130       if (!generatorOutput.equalsIgnoreCase("")) {
131         File JavaDoc file = new File JavaDoc(this.generatorOutput);
132         generatorOutput = file.getAbsolutePath();
133         loadJobFileName = generatorOutput +
134             System.getProperty("file.separator") +"LoaderJob.olj";
135       }
136       else {
137         loadJobFileName = "LoaderJob.olj";
138       }
139       Loader octopusLoader = new Loader(loadJobFileName,confJarStructure);
140       octopusLoader.load();
141     }
142     catch (Exception JavaDoc ex) {
143       ex.printStackTrace();
144     }
145
146   }
147
148   /**
149    * This method set value of confJarStructure parameter
150    * @param confJarStructure is value of parameter
151    */

152   public void setConfJarStructure(String JavaDoc confJarStructure) {
153     this.confJarStructure = confJarStructure;
154   }
155
156   /**
157    * This method read value of confJarStructure parameter
158    * @return value of parameter
159    */

160   public String JavaDoc getConfJarStructure() {
161     return this.confJarStructure;
162   }
163
164
165   /**
166    * This method set value of includeTableList parameter
167    * @param includeTableList is value of parameter
168    */

169   public void setIncludeTableList(String JavaDoc includeTableList) {
170     this.includeTableList = includeTableList;
171   }
172
173   /**
174    * This method read value of includeTableList parameter
175    * @return value of parameter
176    */

177   public String JavaDoc getIncludeTableList() {
178     return this.includeTableList;
179   }
180
181
182   /**
183    * This method set value of generatorOutput parameter
184    * @param generatorOutput is value of parameter
185    */

186   public void setGeneratorOutput(String JavaDoc generatorOutput) {
187     this.generatorOutput = generatorOutput;
188   }
189
190   /**
191    * This method read value of generatorOutput parameter
192    * @return value of parameter
193    */

194   public String JavaDoc getGeneratorOutput() {
195     return this.generatorOutput;
196   }
197
198   /**
199    * This method set value of sourceDatabase parameter
200    * @param sourceDatabase is value of parameter
201    */

202   public void setSourceDatabase(String JavaDoc sourceDatabase) {
203     this.sourceDatabase = sourceDatabase;
204   }
205
206   /**
207    * This method read value of sourceDatabase parameter
208    * @return value of parameter
209    */

210   public String JavaDoc getSourceDatabase() {
211     return this.sourceDatabase;
212   }
213
214   /**
215    * This method set value of sourceUser parameter
216    * @param sourceUser is value of parameter
217    */

218   public void setSourceUser(String JavaDoc sourceUser) {
219     this.sourceUser = sourceUser;
220   }
221
222   /**
223    * This method read value of sourceUser parameter
224    * @return value of parameter
225    */

226   public String JavaDoc getSourceUser() {
227     return this.sourceUser;
228   }
229
230   /**
231    * This method set value of sourcePassword parameter
232    * @param sourcePassword is value of parameter
233    */

234   public void setSourcePassword(String JavaDoc sourcePassword) {
235     this.sourcePassword = sourcePassword;
236   }
237
238   /**
239    * This method read value of sourcePassword parameter
240    * @return value of parameter
241    */

242   public String JavaDoc getSourcePassword() {
243     return this.sourcePassword;
244   }
245
246   /**
247    * This method set value of sourceType parameter
248    * @param sourceType is value of parameter
249    */

250   public void setSourceType(String JavaDoc sourceType) {
251     this.sourceType = sourceType;
252   }
253
254   /**
255    * This method read value of sourceType parameter
256    * @return value of parameter
257    */

258   public String JavaDoc getSourceType() {
259     return this.sourceType;
260   }
261
262   /**
263    * This method set value of sourceDriverName parameter
264    * @param sourceDriverName is value of parameter
265    */

266   public void setSourceDriverName(String JavaDoc sourceDriverName) {
267     this.sourceDriverName = sourceDriverName;
268   }
269
270   /**
271    * This method read value of sourceDriverName parameter
272    * @return value of parameter
273    */

274   public String JavaDoc getSourceDriverName() {
275     return this.sourceDriverName;
276   }
277
278   /**
279    * This method set value of targetDatabase parameter
280    * @param targetDatabase is value of parameter
281    */

282   public void setTargetDatabase(String JavaDoc targetDatabase) {
283     this.targetDatabase = targetDatabase;
284   }
285
286   /**
287    * This method read value of targetDatabase parameter
288    * @return value of parameter
289    */

290   public String JavaDoc getTargetDatabase() {
291     return this.targetDatabase;
292   }
293
294   /**
295    * This method set value of targetUser parameter
296    * @param targetUser is value of parameter
297    */

298   public void setTargetUser(String JavaDoc targetUser) {
299     this.targetUser = targetUser;
300   }
301
302   /**
303    * This method read value of targetDatabase parameter
304    * @return value of parameter
305    */

306   public String JavaDoc getTargetUser() {
307     return this.targetUser;
308   }
309
310   /**
311    * This method set value of targetPassword parameter
312    * @param targetPassword is value of parameter
313    */

314   public void setTargetPassword(String JavaDoc targetPassword) {
315     this.targetPassword = targetPassword;
316   }
317
318   /**
319    * This method read value of targetPassword parameter
320    * @return value of parameter
321    */

322   public String JavaDoc getTargetPassword() {
323     return this.targetPassword;
324   }
325
326   /**
327    * This method set value of targetType parameter
328    * @param targetType is value of parameter
329    */

330   public void setTargetType(String JavaDoc targetType) {
331     this.targetType = targetType;
332   }
333
334   /**
335    * This method read value of targetType parameter
336    * @return value of parameter
337    */

338   public String JavaDoc getTargetType() {
339     return this.targetType;
340   }
341
342   /**
343    * This method set value of targetDriverName parameter
344    * @param targetDriverName is value of parameter
345    */

346   public void setTargetDriverName(String JavaDoc targetDriverName) {
347     this.targetDriverName = targetDriverName;
348   }
349
350   /**
351    * This method read value of targetDriverName parameter
352    * @return value of parameter
353    */

354   public String JavaDoc getTargetDriverName() {
355     return this.targetDriverName;
356   }
357
358   /**
359    * This method set value of octopusHome parameter
360    * @param octopusHome is value of parameter
361    */

362   public void setOctopusHome(String JavaDoc octopusHome) {
363     this.octopusHome = octopusHome;
364   }
365
366   /**
367    * This method read value of octopusHome parameter
368    * @return value of parameter
369    */

370   public String JavaDoc getOctopusHome() {
371     return this.octopusHome;
372   }
373
374 }
Popular Tags