KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.webdocwf.util.loader.task;
18
19 import org.apache.tools.ant.BuildException;
20 import org.apache.tools.ant.Task;
21
22 import org.webdocwf.util.loader.LoaderException;
23 import org.webdocwf.util.loader.generator.LoaderGenerator;
24
25 /**
26  * LoaderGenerator Task class extends jakarta-ant Task class and uses to start
27  * LoaderGenerator application as a jakarta-ant task in build.xml file.
28  *
29  * <p><br>
30  * sourceType, defines the type of the source database. Default value is 'msql'.<br>
31  * targetType, defines the type of the target database. Default value is 'msql'.<br>
32  * sourceDriverName, defines the driver of defined source database.<br>
33  * targetDriverName, defines the driver of defined target database.<br>
34  * sourceDataBase, defines the place where you're put the source database tables.<br>
35  * targetDataBase, defines the place where you're put the target database tables.<br>
36  * valueMode, defines the difference from overwrite and update attribute. If the valueMode<br>
37  * has value 'copy', attribute has value 'Overwrite', or if the valueMode has value 'sync', attribute<br>
38  * has value 'Update'. Default value of valueMode is 'copy'.<br>
39  * generatorOutput, is optional. That represent the directory, where the Octopus place created files.<br>
40  * If this argument don't exists, Octopus place created files in to current directory!<br>
41  * sourceUser, defines the user of the source database.<br>
42  * sourcePassword, defines the user password for the source database.<br>
43  * targetUser, defines the user of the target database.<br>
44  * targetPassword, defines the user password for the target database.<br>
45  * domlUrl, defines the place where the doml file is placed.<br>
46  * outputMode, defines which document you wont to generate. If the generateDoc has value<br>
47  * all, application generates xml, sql and doml files as ouput files. If the generateDoc has value<br>
48  * doml, application generates only the doml file, and if generateDoc has the value wdoml, application<br>
49  * generates xml and sql files.<br>
50  * packageName, defines the package name for the generated doml file.<br>
51  * generateDropTableStmt, defines if you want to generate only Sql statement for DROP TABLE.<br>
52  * <br></p>
53  *
54  * @author Radoslav Dutina
55  * @version 1.0
56  */

57 public class LoadGeneratorTask extends Task {
58
59     protected String JavaDoc sourceType = null;
60     protected String JavaDoc targetType = null;
61     protected String JavaDoc sourceDriverName = null;
62     protected String JavaDoc targetDriverName = null;
63     protected String JavaDoc sourceDataBase = null;
64     protected String JavaDoc targetDataBase = null;
65     protected String JavaDoc valueMode = null;
66     protected String JavaDoc generatorOutput = null;
67     protected String JavaDoc sourceUser = null;
68     protected String JavaDoc sourcePassword = null;
69     protected String JavaDoc targetUser = null;
70     protected String JavaDoc targetPassword = null;
71     protected String JavaDoc domlUrl = null;
72     protected String JavaDoc packageName = null;
73     protected String JavaDoc octopusHome = null;
74     //for generate Sql only
75
protected String JavaDoc generateDropTableStmt = null;
76     protected String JavaDoc generateDropIntegrityStmt = null;
77     protected String JavaDoc generateCreateTableStmt = null;
78     protected String JavaDoc generateCreatePKStmt = null;
79     protected String JavaDoc generateCreateFKStmt = null;
80     protected String JavaDoc generateCreateIndexStmt = null;
81     protected String JavaDoc generateXml = null;
82     protected String JavaDoc generateDoml = null;
83     protected String JavaDoc fullMode = null;
84     protected String JavaDoc includeTableList = null;
85     protected String JavaDoc confJarStructure = null;
86     protected String JavaDoc logMode = null;
87     protected String JavaDoc logDirName = null;
88     protected String JavaDoc logFileName = null;
89     protected String JavaDoc restoreMode = "false";
90     //for generate sql for all vendors
91
protected String JavaDoc generateSqlForAllVendors = null;
92
93     /**
94      * Construct object LoadGeneratorTask.
95      */

96     public LoadGeneratorTask() {
97     }
98
99     /**
100      *
101      * @throws org.apache.tools.ant.BuildException
102      */

103     public void execute() throws org.apache.tools.ant.BuildException {
104         if (sourceDataBase == null) {
105             throw new BuildException("sourceDataBase attribute must be set!");
106         }
107         if (targetDataBase == null) {
108             throw new BuildException("targetDataBase directory attribute must be set!");
109         }
110
111         if (sourceType == null) {
112             throw new BuildException("sourceType directory attribute must be set!");
113         }
114
115         if (targetType == null) {
116             throw new BuildException("targetType directory attribute must be set!");
117         }
118
119         try {
120             if (octopusHome != null)
121                 System.setProperty("OCTOPUS_HOME", octopusHome);
122
123             LoaderGenerator generator = new LoaderGenerator(sourceType, sourceDataBase, valueMode, generatorOutput, sourceDriverName, targetDriverName, targetDataBase, targetType, sourceUser, sourcePassword, targetUser, targetPassword, domlUrl, packageName, generateDropTableStmt, generateDropIntegrityStmt, generateCreateTableStmt, generateCreatePKStmt, generateCreateFKStmt, generateCreateIndexStmt, generateSqlForAllVendors, generateXml, generateDoml, fullMode, restoreMode, includeTableList, confJarStructure, logMode, logDirName, logFileName);
124             try {
125                 generator.generate();
126
127             } catch (Exception JavaDoc e) {
128                 //e.printStackTrace();
129
LoaderException le = new LoaderException("Exception:", e);
130                 throw le;
131             }
132
133         } catch (Exception JavaDoc e) {
134             throw new BuildException(e);
135         }
136     }
137
138     /**
139        * This method sets the value of includeTableList parameter.
140        * @param includeTableList is the value of parameter.
141        */

142     public void setIncludeTableList(String JavaDoc includeTableList) {
143         this.includeTableList = includeTableList;
144     }
145
146     /**
147      * This method sets the value of generateDropIntegrityStmt parameter.
148      * @param generateDropIntegrityStmt is the value of parameter.
149      */

150     public void setGenerateDropIntegrityStmt(String JavaDoc generateDropIntegrityStmt) {
151         this.generateDropIntegrityStmt = generateDropIntegrityStmt;
152     }
153
154     /**
155      * This method sets the value of octopusHome parameter.
156      * @param octopusHome is the value of parameter.
157      */

158     public void setOctopusHome(String JavaDoc octopusHome) {
159         this.octopusHome = octopusHome;
160     }
161
162     /**
163      * This method sets the value of sourceType parameter.
164      * @param sourceType is the value of parameter.
165      */

166     public void setSourceType(String JavaDoc sourceType) {
167         this.sourceType = sourceType;
168     }
169
170     /**
171      * This method sets the value of targetType parameter.
172      * @param targetType is the value of parameter.
173      */

174     public void setTargetType(String JavaDoc targetType) {
175         this.targetType = targetType;
176     }
177
178     /**
179      * This method read the value of sourceDriverName parameter.
180      * @param sourceDriverName is the value of parameter.
181      */

182     public void setSourceDriverName(String JavaDoc sourceDriverName) {
183         this.sourceDriverName = sourceDriverName;
184     }
185
186     /**
187      * This method read the value of targetDriverName parameter.
188      * @param targetDriverName is the value of parameter.
189      */

190     public void setTargetDriverName(String JavaDoc targetDriverName) {
191         this.targetDriverName = targetDriverName;
192     }
193
194     /**
195      * This method read the value of sourceDataBase parameter.
196      * @param sourceDataBase is the value of parameter.
197      */

198     public void setSourceDataBase(String JavaDoc sourceDataBase) {
199         this.sourceDataBase = sourceDataBase;
200     }
201
202     /**
203      ** This method read the value of targetDataBase parameter.
204      * @param targetDataBase is the value of parameter.
205      */

206     public void setTargetDataBase(String JavaDoc targetDataBase) {
207         this.targetDataBase = targetDataBase;
208     }
209
210     /**
211      * This method read the value of valueMode parameter.
212      * @param valueMode is the value of parameter.
213      */

214     public void setValueMode(String JavaDoc valueMode) {
215         this.valueMode = valueMode;
216     }
217
218     /**
219      * This method read the value of generatorOutput parameter.
220      * @param generatorOutput is the value of parameter.
221      */

222     public void setGeneratorOutput(String JavaDoc generatorOutput) {
223         this.generatorOutput = generatorOutput;
224     }
225
226     /**
227      * This method read the value of sourceUser parameter.
228      * @param sourceUser is the value of parameter.
229      */

230     public void setSourceUser(String JavaDoc sourceUser) {
231         this.sourceUser = sourceUser;
232     }
233
234     /**
235      * This method read the value of sourcePassword parameter.
236      * @param sourcePassword is the value of parameter.
237      */

238     public void setSourcePassword(String JavaDoc sourcePassword) {
239         this.sourcePassword = sourcePassword;
240     }
241
242     /**
243      * This method read the value of targetUser parameter.
244      * @param targetUser is the value of parameter.
245      */

246     public void setTargetUser(String JavaDoc targetUser) {
247         this.targetUser = targetUser;
248     }
249
250     /**
251      * This method read the value of targetPassword parameter.
252      * @param targetPassword is the value of parameter.
253      */

254     public void setTargetPassword(String JavaDoc targetPassword) {
255         this.targetPassword = targetPassword;
256     }
257
258     /**
259      * This method read the value of domlPath parameter.
260      * @param domlUrl is the value of parameter.
261      */

262     public void setDomlUrl(String JavaDoc domlUrl) {
263         this.domlUrl = domlUrl;
264     }
265
266     /**
267      * This method read the value of packageName parameter.
268      * @param packageName is the value of parameter.
269      */

270     public void setPackageName(String JavaDoc packageName) {
271         this.packageName = packageName;
272     }
273
274     /**
275      * This method set value of generateDropTableStmt parameter
276      * @param generateDropTableStmt is value of parameter
277      */

278     public void setGenerateDropTableStmt(String JavaDoc generateDropTableStmt) {
279         this.generateDropTableStmt = generateDropTableStmt;
280     }
281
282     /**
283      * This method set value of generateCreateTableStmt parameter
284      * @param generateCreateTableStmt is value of parameter
285      */

286     public void setGenerateCreateTableStmt(String JavaDoc generateCreateTableStmt) {
287         this.generateCreateTableStmt = generateCreateTableStmt;
288     }
289
290     /**
291      * This method set value of generateCreatePKStmt parameter
292      * @param generateCreatePKStmt is value of parameter
293      */

294     public void setGenerateCreatePKStmt(String JavaDoc generateCreatePKStmt) {
295         this.generateCreatePKStmt = generateCreatePKStmt;
296     }
297
298     /**
299      * This method set value of generateCreateFKStmt parameter
300      * @param generateCreateFKStmt is value of parameter
301      */

302     public void setGenerateCreateFKStmt(String JavaDoc generateCreateFKStmt) {
303         this.generateCreateFKStmt = generateCreateFKStmt;
304     }
305
306     /**
307      * This method set value of generateCreateIndexStmt parameter
308      * @param generateCreateIndexStmt is value of parameter
309      */

310     public void setGenerateCreateIndexStmt(String JavaDoc generateCreateIndexStmt) {
311         this.generateCreateIndexStmt = generateCreateIndexStmt;
312     }
313
314     /**
315      * This method set value of generateXml parameter
316      * @param generateXml is value of parameter
317      */

318     public void setGenerateXml(String JavaDoc generateXml) {
319         this.generateXml = generateXml;
320     }
321
322     /**
323      * This method sets the value of generateDoml parameter.
324      * @param generateDoml is the value of parameter.
325      */

326     public void setGenerateDoml(String JavaDoc generateDoml) {
327         this.generateDoml = generateDoml;
328     }
329
330     /**
331      * This method set value of fullMode parameter
332      * @param fullMode is value of parameter
333      */

334     public void setFullMode(String JavaDoc fullMode) {
335         this.fullMode = fullMode;
336     }
337
338 // /**
339
// * This method set value of confJarStructure parameter
340
// * @param confFileStructure is value of parameter
341
// */
342
// public void setConfFileStructure(String confFileStructure) {
343
// this.confJarStructure = confFileStructure;
344
// }
345

346     /**
347         * This method set value of logMode parameter
348         * @param logMode is value of parameter
349         */

350     public void setLogMode(String JavaDoc logMode) {
351         this.logMode = logMode;
352     }
353     /**
354           * This method set value of logDirName parameter
355           * @param logDirName is value of parameter
356           */

357     public void setLogDirName(String JavaDoc logDirName) {
358         this.logDirName = logDirName;
359     }
360     /**
361        * This method set value of logFileName parameter
362        * @param logFileName is value of parameter
363        */

364     public void setLogFileName(String JavaDoc logFileName) {
365         this.logFileName = logFileName;
366     }
367
368     /**
369      * This method set value for generateSqlForAllVendors
370      * @param generateSqlForAllVendors
371      */

372     public void setGenerateSqlForAllVendors(String JavaDoc generateSqlForAllVendors) {
373         this.generateSqlForAllVendors = generateSqlForAllVendors;
374     }
375
376
377
378     /**
379      * This method set value of confJarStructure parameter
380      * @param confJarStructure is value of parameter
381      */

382     public void setConfJarStructure(String JavaDoc confJarStructure) {
383         this.confJarStructure = confJarStructure;
384     }
385
386
387
388 }
389
Popular Tags