KickJava   Java API By Example, From Geeks To Geeks.

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


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  * RestoreTask Task class extends jakarta-ant Task class and uses to start
28  * @author Radoslav Dutina
29  * @version 1.0
30  */

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

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

134   public void setConfJarStructure(String JavaDoc confJarStructure) {
135     this.confJarStructure = confJarStructure;
136   }
137
138   /**
139    * This method read value of confJarStructure parameter
140    * @return value of parameter
141    */

142   public String JavaDoc getConfJarStructure() {
143     return this.confJarStructure;
144   }
145
146
147   /**
148    * This method set value of includeTableList parameter
149    * @param includeTableList is value of parameter
150    */

151   public void setIncludeTableList(String JavaDoc 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 JavaDoc getIncludeTableList() {
160     return this.includeTableList;
161   }
162
163
164
165   /**
166    * This method set value of generatorOutput parameter
167    * @param generatorOutput is value of parameter
168    */

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

353   public String JavaDoc getOctopusHome() {
354     return this.octopusHome;
355   }
356
357 }
Popular Tags