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:
022: import org.webdocwf.util.loader.LoaderException;
023: import org.webdocwf.util.loader.generator.LoaderGenerator;
024:
025: /**
026: * LoaderGenerator Task class extends jakarta-ant Task class and uses to start
027: * LoaderGenerator application as a jakarta-ant task in build.xml file.
028: *
029: * <p><br>
030: * sourceType, defines the type of the source database. Default value is 'msql'.<br>
031: * targetType, defines the type of the target database. Default value is 'msql'.<br>
032: * sourceDriverName, defines the driver of defined source database.<br>
033: * targetDriverName, defines the driver of defined target database.<br>
034: * sourceDataBase, defines the place where you're put the source database tables.<br>
035: * targetDataBase, defines the place where you're put the target database tables.<br>
036: * valueMode, defines the difference from overwrite and update attribute. If the valueMode<br>
037: * has value 'copy', attribute has value 'Overwrite', or if the valueMode has value 'sync', attribute<br>
038: * has value 'Update'. Default value of valueMode is 'copy'.<br>
039: * generatorOutput, is optional. That represent the directory, where the Octopus place created files.<br>
040: * If this argument don't exists, Octopus place created files in to current directory!<br>
041: * sourceUser, defines the user of the source database.<br>
042: * sourcePassword, defines the user password for the source database.<br>
043: * targetUser, defines the user of the target database.<br>
044: * targetPassword, defines the user password for the target database.<br>
045: * domlUrl, defines the place where the doml file is placed.<br>
046: * outputMode, defines which document you wont to generate. If the generateDoc has value<br>
047: * all, application generates xml, sql and doml files as ouput files. If the generateDoc has value<br>
048: * doml, application generates only the doml file, and if generateDoc has the value wdoml, application<br>
049: * generates xml and sql files.<br>
050: * packageName, defines the package name for the generated doml file.<br>
051: * generateDropTableStmt, defines if you want to generate only Sql statement for DROP TABLE.<br>
052: * <br></p>
053: *
054: * @author Radoslav Dutina
055: * @version 1.0
056: */
057: public class LoadGeneratorTask extends Task {
058:
059: protected String sourceType = null;
060: protected String targetType = null;
061: protected String sourceDriverName = null;
062: protected String targetDriverName = null;
063: protected String sourceDataBase = null;
064: protected String targetDataBase = null;
065: protected String valueMode = null;
066: protected String generatorOutput = null;
067: protected String sourceUser = null;
068: protected String sourcePassword = null;
069: protected String targetUser = null;
070: protected String targetPassword = null;
071: protected String domlUrl = null;
072: protected String packageName = null;
073: protected String octopusHome = null;
074: //for generate Sql only
075: protected String generateDropTableStmt = null;
076: protected String generateDropIntegrityStmt = null;
077: protected String generateCreateTableStmt = null;
078: protected String generateCreatePKStmt = null;
079: protected String generateCreateFKStmt = null;
080: protected String generateCreateIndexStmt = null;
081: protected String generateXml = null;
082: protected String generateDoml = null;
083: protected String fullMode = null;
084: protected String includeTableList = null;
085: protected String confJarStructure = null;
086: protected String logMode = null;
087: protected String logDirName = null;
088: protected String logFileName = null;
089: protected String restoreMode = "false";
090: //for generate sql for all vendors
091: protected String generateSqlForAllVendors = null;
092:
093: /**
094: * Construct object LoadGeneratorTask.
095: */
096: public LoadGeneratorTask() {
097: }
098:
099: /**
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(
106: "sourceDataBase attribute must be set!");
107: }
108: if (targetDataBase == null) {
109: throw new BuildException(
110: "targetDataBase directory attribute must be set!");
111: }
112:
113: if (sourceType == null) {
114: throw new BuildException(
115: "sourceType directory attribute must be set!");
116: }
117:
118: if (targetType == null) {
119: throw new BuildException(
120: "targetType directory attribute must be set!");
121: }
122:
123: try {
124: if (octopusHome != null)
125: System.setProperty("OCTOPUS_HOME", octopusHome);
126:
127: LoaderGenerator generator = new LoaderGenerator(sourceType,
128: sourceDataBase, valueMode, generatorOutput,
129: sourceDriverName, targetDriverName, targetDataBase,
130: targetType, sourceUser, sourcePassword, targetUser,
131: targetPassword, domlUrl, packageName,
132: generateDropTableStmt, generateDropIntegrityStmt,
133: generateCreateTableStmt, generateCreatePKStmt,
134: generateCreateFKStmt, generateCreateIndexStmt,
135: generateSqlForAllVendors, generateXml,
136: generateDoml, fullMode, restoreMode,
137: includeTableList, confJarStructure, logMode,
138: logDirName, logFileName);
139: try {
140: generator.generate();
141:
142: } catch (Exception e) {
143: //e.printStackTrace();
144: LoaderException le = new LoaderException("Exception:",
145: e);
146: throw le;
147: }
148:
149: } catch (Exception e) {
150: throw new BuildException(e);
151: }
152: }
153:
154: /**
155: * This method sets the value of includeTableList parameter.
156: * @param includeTableList is the value of parameter.
157: */
158: public void setIncludeTableList(String includeTableList) {
159: this .includeTableList = includeTableList;
160: }
161:
162: /**
163: * This method sets the value of generateDropIntegrityStmt parameter.
164: * @param generateDropIntegrityStmt is the value of parameter.
165: */
166: public void setGenerateDropIntegrityStmt(
167: String generateDropIntegrityStmt) {
168: this .generateDropIntegrityStmt = generateDropIntegrityStmt;
169: }
170:
171: /**
172: * This method sets the value of octopusHome parameter.
173: * @param octopusHome is the value of parameter.
174: */
175: public void setOctopusHome(String octopusHome) {
176: this .octopusHome = octopusHome;
177: }
178:
179: /**
180: * This method sets the value of sourceType parameter.
181: * @param sourceType is the value of parameter.
182: */
183: public void setSourceType(String sourceType) {
184: this .sourceType = sourceType;
185: }
186:
187: /**
188: * This method sets the value of targetType parameter.
189: * @param targetType is the value of parameter.
190: */
191: public void setTargetType(String targetType) {
192: this .targetType = targetType;
193: }
194:
195: /**
196: * This method read the value of sourceDriverName parameter.
197: * @param sourceDriverName is the value of parameter.
198: */
199: public void setSourceDriverName(String sourceDriverName) {
200: this .sourceDriverName = sourceDriverName;
201: }
202:
203: /**
204: * This method read the value of targetDriverName parameter.
205: * @param targetDriverName is the value of parameter.
206: */
207: public void setTargetDriverName(String targetDriverName) {
208: this .targetDriverName = targetDriverName;
209: }
210:
211: /**
212: * This method read the value of sourceDataBase parameter.
213: * @param sourceDataBase is the value of parameter.
214: */
215: public void setSourceDataBase(String sourceDataBase) {
216: this .sourceDataBase = sourceDataBase;
217: }
218:
219: /**
220: ** This method read the value of targetDataBase parameter.
221: * @param targetDataBase is the value of parameter.
222: */
223: public void setTargetDataBase(String targetDataBase) {
224: this .targetDataBase = targetDataBase;
225: }
226:
227: /**
228: * This method read the value of valueMode parameter.
229: * @param valueMode is the value of parameter.
230: */
231: public void setValueMode(String valueMode) {
232: this .valueMode = valueMode;
233: }
234:
235: /**
236: * This method read the value of generatorOutput parameter.
237: * @param generatorOutput is the value of parameter.
238: */
239: public void setGeneratorOutput(String generatorOutput) {
240: this .generatorOutput = generatorOutput;
241: }
242:
243: /**
244: * This method read the value of sourceUser parameter.
245: * @param sourceUser is the value of parameter.
246: */
247: public void setSourceUser(String sourceUser) {
248: this .sourceUser = sourceUser;
249: }
250:
251: /**
252: * This method read the value of sourcePassword parameter.
253: * @param sourcePassword is the value of parameter.
254: */
255: public void setSourcePassword(String sourcePassword) {
256: this .sourcePassword = sourcePassword;
257: }
258:
259: /**
260: * This method read the value of targetUser parameter.
261: * @param targetUser is the value of parameter.
262: */
263: public void setTargetUser(String targetUser) {
264: this .targetUser = targetUser;
265: }
266:
267: /**
268: * This method read the value of targetPassword parameter.
269: * @param targetPassword is the value of parameter.
270: */
271: public void setTargetPassword(String targetPassword) {
272: this .targetPassword = targetPassword;
273: }
274:
275: /**
276: * This method read the value of domlPath parameter.
277: * @param domlUrl is the value of parameter.
278: */
279: public void setDomlUrl(String domlUrl) {
280: this .domlUrl = domlUrl;
281: }
282:
283: /**
284: * This method read the value of packageName parameter.
285: * @param packageName is the value of parameter.
286: */
287: public void setPackageName(String packageName) {
288: this .packageName = packageName;
289: }
290:
291: /**
292: * This method set value of generateDropTableStmt parameter
293: * @param generateDropTableStmt is value of parameter
294: */
295: public void setGenerateDropTableStmt(String generateDropTableStmt) {
296: this .generateDropTableStmt = generateDropTableStmt;
297: }
298:
299: /**
300: * This method set value of generateCreateTableStmt parameter
301: * @param generateCreateTableStmt is value of parameter
302: */
303: public void setGenerateCreateTableStmt(
304: String generateCreateTableStmt) {
305: this .generateCreateTableStmt = generateCreateTableStmt;
306: }
307:
308: /**
309: * This method set value of generateCreatePKStmt parameter
310: * @param generateCreatePKStmt is value of parameter
311: */
312: public void setGenerateCreatePKStmt(String generateCreatePKStmt) {
313: this .generateCreatePKStmt = generateCreatePKStmt;
314: }
315:
316: /**
317: * This method set value of generateCreateFKStmt parameter
318: * @param generateCreateFKStmt is value of parameter
319: */
320: public void setGenerateCreateFKStmt(String generateCreateFKStmt) {
321: this .generateCreateFKStmt = generateCreateFKStmt;
322: }
323:
324: /**
325: * This method set value of generateCreateIndexStmt parameter
326: * @param generateCreateIndexStmt is value of parameter
327: */
328: public void setGenerateCreateIndexStmt(
329: String generateCreateIndexStmt) {
330: this .generateCreateIndexStmt = generateCreateIndexStmt;
331: }
332:
333: /**
334: * This method set value of generateXml parameter
335: * @param generateXml is value of parameter
336: */
337: public void setGenerateXml(String generateXml) {
338: this .generateXml = generateXml;
339: }
340:
341: /**
342: * This method sets the value of generateDoml parameter.
343: * @param generateDoml is the value of parameter.
344: */
345: public void setGenerateDoml(String generateDoml) {
346: this .generateDoml = generateDoml;
347: }
348:
349: /**
350: * This method set value of fullMode parameter
351: * @param fullMode is value of parameter
352: */
353: public void setFullMode(String fullMode) {
354: this .fullMode = fullMode;
355: }
356:
357: // /**
358: // * This method set value of confJarStructure parameter
359: // * @param confFileStructure is value of parameter
360: // */
361: // public void setConfFileStructure(String confFileStructure) {
362: // this.confJarStructure = confFileStructure;
363: // }
364:
365: /**
366: * This method set value of logMode parameter
367: * @param logMode is value of parameter
368: */
369: public void setLogMode(String logMode) {
370: this .logMode = logMode;
371: }
372:
373: /**
374: * This method set value of logDirName parameter
375: * @param logDirName is value of parameter
376: */
377: public void setLogDirName(String logDirName) {
378: this .logDirName = logDirName;
379: }
380:
381: /**
382: * This method set value of logFileName parameter
383: * @param logFileName is value of parameter
384: */
385: public void setLogFileName(String logFileName) {
386: this .logFileName = logFileName;
387: }
388:
389: /**
390: * This method set value for generateSqlForAllVendors
391: * @param generateSqlForAllVendors
392: */
393: public void setGenerateSqlForAllVendors(
394: String generateSqlForAllVendors) {
395: this .generateSqlForAllVendors = generateSqlForAllVendors;
396: }
397:
398: /**
399: * This method set value of confJarStructure parameter
400: * @param confJarStructure is value of parameter
401: */
402: public void setConfJarStructure(String confJarStructure) {
403: this.confJarStructure = confJarStructure;
404: }
405:
406: }
|