KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > webdocwf > util > loader > generator > LoaderGenerator


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

22
23 package org.webdocwf.util.loader.generator;
24
25 import java.util.Vector JavaDoc;
26
27 import org.webdocwf.util.loader.BufferOctopusClass;
28 import org.webdocwf.util.loader.LoaderException;
29 import org.webdocwf.util.loader.TimeWatch;
30 import org.webdocwf.util.loader.logging.StandardLogger;
31
32 /**
33  * LoaderGenerator class dinamicly generates the xml files (LoaderJob.xml and ImportDefinition.xml)
34  * from the input data and source database.
35  * Also LoaderGenerator creates SQL statements for building and loading an SQL target database.
36  * @author Radoslav Dutina
37  * @version 1.0
38  */

39 public class LoaderGenerator {
40
41     private InputParameters generatorParameters;
42     private StandardLogger logger;
43     private String JavaDoc strLogDirName = "";
44     private String JavaDoc strLogFileName = "defaultGenerator";
45     private String JavaDoc logMode = "normal";
46     private TimeWatch timeCounter;
47     private String JavaDoc strLoggerParam = "";
48     private boolean standardLogger;
49
50     /**
51      * This method set sourceDataBase
52      * @param sourceDataBase
53      * @throws LoaderException
54      */

55     public void setSourceDataBase(String JavaDoc sourceDataBase) throws LoaderException {
56         this.generatorParameters.setSourceDataBase(sourceDataBase);
57     }
58
59     /**
60      * This method return sourceDataBase
61      * @return sourceDataBase
62      * @throws LoaderException
63      */

64
65     public String JavaDoc getSourceDataBase() throws LoaderException {
66         return this.generatorParameters.getSourceDataBase();
67     }
68     /**
69      * This method set targetDataBase
70      * @param targetDataBase
71      * @throws LoaderException
72      */

73
74     public void setTargetDataBase(String JavaDoc targetDataBase) throws LoaderException {
75         this.generatorParameters.setTargetDataBase(targetDataBase);
76     }
77
78     /**
79      * This method return targetDataBase
80      * @return targetDataBase
81      * @throws LoaderException
82      */

83     public String JavaDoc getTargetDataBase() throws LoaderException {
84         return this.generatorParameters.getTargetDataBase();
85     }
86
87     /**
88      * This method set sourceType
89      * @param sourceType
90      * @throws LoaderException
91      */

92     public void setSourceType(String JavaDoc sourceType) throws LoaderException {
93         this.generatorParameters.setSourceType(sourceType);
94     }
95
96     /**
97      * This method return sourceType
98      * @return sourceType
99      * @throws LoaderException
100      */

101     public String JavaDoc getSourceType() throws LoaderException {
102         return this.generatorParameters.getSourceType();
103     }
104
105     /**
106      * This method set targetType
107      * @param targetType
108      * @throws LoaderException
109      */

110     public void setTargetType(String JavaDoc targetType) throws LoaderException {
111         this.generatorParameters.setTargetType(targetType);
112     }
113
114     /**
115      * This method return targetType
116      * @return String which is target type
117      * @throws LoaderException
118      */

119     public String JavaDoc getTargetType() throws LoaderException {
120         return this.generatorParameters.getTargetType();
121     }
122
123     /**
124      * This method set sourceDriverName
125      * @param sourceDriverName
126      * @throws LoaderException
127      */

128     public void setSourceDriverName(String JavaDoc sourceDriverName) throws LoaderException {
129         this.generatorParameters.setSourceDriverName(sourceDriverName);
130     }
131
132     /**
133      * This method return sourceDriverName
134      * @return sourceDriverName
135      * @throws LoaderException
136      */

137     public String JavaDoc getSourceDriverName() throws LoaderException {
138         return this.generatorParameters.getSourceDriverName();
139     }
140
141     /**
142      * This method set targetDriverName
143      * @param targetDriverName
144      * @throws LoaderException
145      */

146     public void setTargetDriverName(String JavaDoc targetDriverName) throws LoaderException {
147         this.generatorParameters.setTargetDriverName(targetDriverName);
148     }
149
150     /**
151      * This method return targetDriverName
152      * @return targetDriverName
153      * @throws LoaderException
154      */

155     public String JavaDoc getTargetDriverName() throws LoaderException {
156         return this.generatorParameters.getTargetDriverName();
157     }
158
159     /**
160      * This method set valueMode
161      * @param valueMode
162      * @throws LoaderException
163      */

164     public void setValueMode(String JavaDoc valueMode) throws LoaderException {
165         this.generatorParameters.setValueMode(valueMode);
166     }
167
168     /**
169      * This method returns valueMode
170      * @return String which is value mode
171      * @throws LoaderException
172      */

173     public String JavaDoc getValueMode() throws LoaderException {
174         return this.generatorParameters.getValueMode();
175     }
176
177     /**
178      * This method set generatorOutput
179      * @param generatorOutput
180      * @throws LoaderException
181      */

182     public void setGeneratorOutput(String JavaDoc generatorOutput) throws LoaderException {
183         this.generatorParameters.setGeneratorOutput(generatorOutput);
184     }
185
186     /**
187      * This method return generatorOutput
188      * @return generatorOutput
189      * @throws LoaderException
190      */

191     public String JavaDoc getGeneratorOutput() throws LoaderException {
192         return this.generatorParameters.getGeneratorOutput();
193     }
194
195     /**
196      * This method set sourceUser
197      * @param sourceUser
198      * @throws LoaderException
199      */

200     public void setSourceUser(String JavaDoc sourceUser) throws LoaderException {
201         this.generatorParameters.setSourceUser(sourceUser);
202     }
203
204     /**
205      * This method return sourceUser
206      * @return sourceUser
207      * @throws LoaderException
208      */

209     public String JavaDoc getSourceUser() throws LoaderException {
210         return this.generatorParameters.getSourceUser();
211     }
212
213     /**
214      * This method set targetUser
215      * @param targetUser
216      * @throws LoaderException
217      */

218     public void setTargetUser(String JavaDoc targetUser) throws LoaderException {
219         this.generatorParameters.setTargetUser(targetUser);
220     }
221
222     /**
223      * This method return targetUser
224      * @return targetUser
225      * @throws LoaderException
226      */

227     public String JavaDoc getTargetUser() throws LoaderException {
228         return this.generatorParameters.getTargetUser();
229     }
230     /**
231      * This method set sourcePassword
232      * @param sourcePassword
233      * @throws LoaderException
234      */

235     public void setSourcePassword(String JavaDoc sourcePassword) throws LoaderException {
236         this.generatorParameters.setSourcePassword(sourcePassword);
237     }
238
239     /**
240      * This method return sourcePassword
241      * @return sourcePassword
242      * @throws LoaderException
243      */

244     public String JavaDoc getSourcePassword() throws LoaderException {
245         return this.generatorParameters.getSourcePassword();
246     }
247
248     /**
249      * This method set targetPassword
250      * @param targetPassword
251      * @throws LoaderException
252      */

253     public void setTargetPassword(String JavaDoc targetPassword) throws LoaderException {
254         this.generatorParameters.setTargetPassword(targetPassword);
255     }
256
257     /**
258      * This method set targetPassword
259      * @return targetPassword
260      * @throws LoaderException
261      */

262     public String JavaDoc getTargetPassword() throws LoaderException {
263         return this.generatorParameters.getTargetPassword();
264     }
265
266     /**
267      * This method set domlPath
268      * @param domlPath
269      * @throws LoaderException
270      */

271     public void setDomlPath(String JavaDoc domlPath) throws LoaderException {
272         this.generatorParameters.setDomlPath(domlPath);
273     }
274
275     /**
276      * This method return domlPath
277      * @return domlPath
278      * @throws LoaderException
279      */

280     public String JavaDoc getDomlPath() throws LoaderException {
281         return this.generatorParameters.getDomlPath();
282     }
283
284     /**
285      * This method set packageName
286      * @param packageName
287      * @throws LoaderException
288      */

289     public void setPackageName(String JavaDoc packageName) throws LoaderException {
290         this.generatorParameters.setPackageName(packageName);
291     }
292
293     /**
294      * This method return packageName
295      * @return packageName
296      * @throws LoaderException
297      */

298     public String JavaDoc getPackageName() throws LoaderException {
299         return this.generatorParameters.getPackageName();
300     }
301     /**
302      * This method set generateDropTableStmt
303      * @param generateDropTableStmt
304      * @throws LoaderException
305      */

306     public void setGenerateDropTableStmt(boolean generateDropTableStmt) throws LoaderException {
307         this.generatorParameters.setSqlStmtDropTable(new Boolean JavaDoc(generateDropTableStmt).toString());
308     }
309     /**
310      * This method return generateDropTableStmt
311      * @return generateDropTableStmt
312      * @throws LoaderException
313      */

314     public boolean getGenerateDropTableStmt() throws LoaderException {
315         Vector JavaDoc tempVector = this.generatorParameters.getSqlToGenerate();
316         String JavaDoc dropTables = (String JavaDoc) tempVector.elementAt(1);
317         if (dropTables.equalsIgnoreCase("DropTables")) {
318             return true;
319         } else {
320             return false;
321         }
322
323     }
324     /**
325      * This method set generateCreateTableStmt
326      * @param generateCreateTableStmt
327      * @throws LoaderException
328      */

329     public void setGenerateCreateTableStmt(boolean generateCreateTableStmt) throws LoaderException {
330         this.generatorParameters.setSqlStmtCreateTable(new Boolean JavaDoc(generateCreateTableStmt).toString());
331     }
332
333     /**
334      * This method will return boolean which represents if user set "Create Tables" or not
335      * @return boolean value
336      * @throws LoaderException
337      */

338     public boolean getGenerateCreateTableStmt() throws LoaderException {
339         Vector JavaDoc tempVector = this.generatorParameters.getSqlToGenerate();
340         String JavaDoc createTables = (String JavaDoc) tempVector.elementAt(2);
341         if (createTables.equalsIgnoreCase("CreateTables")) {
342             return true;
343         } else {
344             return false;
345         }
346     }
347     /**
348      * This method set generateDropIntegrityStmt
349      * @param generateDropIntegrityStmt
350      * @throws LoaderException
351      */

352
353     public void setGenerateDropIntegrityStmt(boolean generateDropIntegrityStmt) throws LoaderException {
354         this.generatorParameters.setSqlStmtDropIntegrity(new Boolean JavaDoc(generateDropIntegrityStmt).toString());
355     }
356     /**
357      * This method return generateDropIntegrityStmt
358      * @return generateDropIntegrityStmt
359      * @throws LoaderException
360      */

361     public boolean getGenerateDropIntegrityStmt() throws LoaderException {
362         Vector JavaDoc tempVector = this.generatorParameters.getSqlToGenerate();
363         String JavaDoc dropIntegrity = (String JavaDoc) tempVector.elementAt(0);
364         if (dropIntegrity.equalsIgnoreCase("DropIntegrity")) {
365             return true;
366         } else {
367             return false;
368         }
369     }
370     /**
371      * This method set generateCreatePKStmt
372      * @param generateCreatePKStmt
373      * @throws LoaderException
374      */

375     public void setGenerateCreatePKStmt(boolean generateCreatePKStmt) throws LoaderException {
376         this.generatorParameters.setSqlStmtCreatePK(new Boolean JavaDoc(generateCreatePKStmt).toString());
377     }
378     /**
379      * This method return generateCreatePKStmt
380      * @return GenerateCreatePKStmt
381      * @throws LoaderException
382      */

383     public boolean getGenerateCreatePKStmt() throws LoaderException {
384         Vector JavaDoc tempVector = this.generatorParameters.getSqlToGenerate();
385         String JavaDoc createPrimary = (String JavaDoc) tempVector.elementAt(4);
386         if (createPrimary.equalsIgnoreCase("CreatePrimary")) {
387             return true;
388         } else {
389             return false;
390         }
391     }
392     /**
393      * This method set generateCreateFKStmt
394      * @param generateCreateFKStmt
395      * @throws LoaderException
396      */

397     public void setGenerateCreateFKStmt(boolean generateCreateFKStmt) throws LoaderException {
398         this.generatorParameters.setSqlStmtCreateFK(new Boolean JavaDoc(generateCreateFKStmt).toString());
399     }
400
401     /**
402      * This method return generateCreateFKStmt
403      * @return generateCreateFKStmt
404      * @throws LoaderException
405      */

406     public boolean getGenerateCreateFKStmt() throws LoaderException {
407         Vector JavaDoc tempVector = this.generatorParameters.getSqlToGenerate();
408         String JavaDoc createForeign = (String JavaDoc) tempVector.elementAt(5);
409         if (createForeign.equalsIgnoreCase("CreateForeigin")) {
410             return true;
411         } else {
412             return false;
413         }
414     }
415     /**
416      * This method set generateCreateIndexStmt
417      * @param generateCreateIndexStmt
418      * @throws LoaderException
419      */

420     public void setGenerateCreateIndexStmt(boolean generateCreateIndexStmt) throws LoaderException {
421         this.generatorParameters.setSqlStmtCreateIndex(new Boolean JavaDoc(generateCreateIndexStmt).toString());
422     }
423     /**
424      * This method return generateCreateIndexStmt
425      * @return CreateIndexes
426      * @throws LoaderException
427      */

428     public boolean getGenerateCreateIndexStmt() throws LoaderException {
429         Vector JavaDoc tempVector = this.generatorParameters.getSqlToGenerate();
430         String JavaDoc createIndexes = (String JavaDoc) tempVector.elementAt(3);
431         if (createIndexes.equalsIgnoreCase("CreateIndexes")) {
432             return true;
433         } else {
434             return false;
435         }
436     }
437     /**
438      * This method set generateSqlForAllVendors
439      * @param generateSqlForAllVendors
440      * @throws LoaderException
441      */

442     public void setGenerateSqlForAllVendors(boolean generateSqlForAllVendors) throws LoaderException {
443         this.generatorParameters.setAllVendors(new Boolean JavaDoc(generateSqlForAllVendors).toString());
444     }
445
446     /**
447      * This method return GenerateSqlForAllVendors
448      * @return GenerateSqlForAllVendors
449      * @throws LoaderException
450      */

451     public boolean getGenerateSqlForAllVendors() throws LoaderException {
452         return this.generatorParameters.getSqlForAllVendors();
453     }
454     /**
455      * This method set generateXml
456      * @param generateXml
457      * @throws LoaderException
458      */

459     public void setGenerateXml(boolean generateXml) throws LoaderException {
460         this.generatorParameters.setGenerateXml(new Boolean JavaDoc(generateXml).toString());
461     }
462
463     /**
464      * This method return generateXml
465      * @return boolean
466      * @throws LoaderException
467      */

468     public boolean getGenerateXml() throws LoaderException {
469         String JavaDoc tempGenerateXml = this.generatorParameters.getGenerateXml();
470         return (new Boolean JavaDoc(tempGenerateXml)).booleanValue();
471
472     }
473     /**
474      * This method set generateDoml
475      * @param generateDoml
476      * @throws LoaderException
477      */

478     public void setGenerateDoml(boolean generateDoml) throws LoaderException {
479         this.generatorParameters.setGenerateDoml(new Boolean JavaDoc(generateDoml).toString());
480     }
481
482     /**
483      * This method return generateDoml
484      * @return boolean with value for generateDoml
485      * @throws LoaderException
486      */

487     public boolean getGenerateDoml() throws LoaderException {
488         String JavaDoc tempGenerateDoml = this.generatorParameters.getGenerateDoml();
489         return (new Boolean JavaDoc(tempGenerateDoml)).booleanValue();
490     }
491
492     /**
493      * This method return generateSQL
494      * @return bollean with value for generateSQL
495      * @throws LoaderException
496      */

497     public boolean getGenerateSQL() throws LoaderException {
498         boolean tempGenerateSQL = this.generatorParameters.isGenerateSql();
499         return tempGenerateSQL;
500     }
501     /**
502      * This method set fullMode
503      * @param fullMode
504      * @throws LoaderException
505      */

506     public void setFullMode(boolean fullMode) throws LoaderException {
507         this.generatorParameters.setFullMode(new Boolean JavaDoc(fullMode).toString());
508     }
509
510     /**
511      * This method return fullMode
512      * @return boolean with value for fullMode
513      * @throws LoaderException
514      */

515     public boolean getFullMode() throws LoaderException {
516         return this.generatorParameters.getFullMode();
517     }
518
519     /**
520      * This method set includeTableList
521      * @param includeTableList
522      * @throws LoaderException
523      */

524     public void setIncludeTableList(String JavaDoc includeTableList) throws LoaderException {
525         this.generatorParameters.setIncludeTableList(includeTableList);
526     }
527
528     /**
529      * This method return includeTableList
530      * @return String which is list with included tables
531      * @throws LoaderException
532      */

533     public String JavaDoc getIncludeTableList() throws LoaderException {
534         Vector JavaDoc tmpIncludeTableList = this.generatorParameters.getIncludeTableList();
535         return tmpIncludeTableList.toString();
536     }
537
538     /**
539      * This method set confJarStructure
540      * @param confJarStructure
541      * @throws LoaderException
542      */

543     public void setConfJarStructure(String JavaDoc confJarStructure) throws LoaderException {
544         this.generatorParameters.setConfJarStructure(confJarStructure);
545     }
546
547     /**
548      * This method get confJarStructure
549      * @return ConfJarStructure
550      * @throws LoaderException
551      */

552     public String JavaDoc getConfJarStructure() throws LoaderException {
553         return this.generatorParameters.getConfJarStructure();
554     }
555
556     /**
557      * This method set restoreMode
558      * @param restoreMode
559      * @throws LoaderException
560      */

561     public void setRestoreMode(String JavaDoc restoreMode) throws LoaderException {
562         this.generatorParameters.setRestoreMode(restoreMode);
563     }
564
565     /**
566      * This method return restoreMode
567      * @return restoreMode
568      * @throws LoaderException
569      */

570     public String JavaDoc getRestoreMode() throws LoaderException {
571         return this.generatorParameters.getRestoreMode();
572     }
573
574     
575     /**
576         * This method return logMode
577         * @return logMode
578         */

579        public String JavaDoc getLogMode() {
580            return logMode;
581        }
582
583        /**
584         * This method return strLogDirName
585         * @return strLogDirName
586         */

587        public String JavaDoc getStrLogDirName() {
588            return strLogDirName;
589        }
590
591        /**
592         * This method return strLogFileName
593         * @return strLogFileName
594         */

595        public String JavaDoc getStrLogFileName() {
596            return strLogFileName;
597        }
598
599        /**
600         * This method set logMode
601         * @param logMode
602         */

603        public void setLogMode(String JavaDoc logMode) {
604            this.logMode = logMode;
605        }
606
607        /**
608         * This method set strLogDirName
609         * @param strLogDirName
610         */

611        public void setStrLogDirName(String JavaDoc strLogDirName) {
612            this.strLogDirName = strLogDirName;
613        }
614
615        /**
616         * This method set strLogFileName
617         * @param strLogFileName
618         */

619        public void setStrLogFileName(String JavaDoc strLogFileName) {
620            this.strLogFileName = strLogFileName;
621        }
622    
623     /**
624      * This method write values for all input parameters to System out
625      * @throws LoaderException
626      */

627     public String JavaDoc inputToString() throws LoaderException {
628         String JavaDoc resString = "";
629         try {
630
631             resString ="Source type="+ getSourceType()+ "\n"
632                         + "Source driver=" + getSourceDriverName()+ "\n"
633                         + "Source URL=" + getSourceDataBase()+ "\n"
634                     + "Source user="+ getSourceUser()+ "\n"
635                     + "Source password="+ getSourcePassword()+ "\n"
636                     + "Target type=" + getTargetType()+ "\n"
637                     + "Target driver=" + getTargetDriverName() + "\n"
638                     + "Target URL=" + getTargetDataBase() + "\n"
639                     + "Target user=" + getTargetUser() + "\n"
640                     + "Target password=" + getTargetPassword() + "\n"
641                     + "Conf file in jar=" + getConfJarStructure() + "\n"
642                     + "Doml path=" + getDomlPath()+ "\n"
643                     + "Ouput directory=" + getGeneratorOutput() + "\n"
644                     + "Include table list=" + getIncludeTableList() + "\n"
645                     + "Restore mode=" + getRestoreMode()+ "\n"
646                     + "Value mode="+ getValueMode()+ "\n"
647                     + "Generate create foreign keys ="+ getGenerateCreateFKStmt()+ "\n"
648                     + "Generate create indexes ="+ getGenerateCreateIndexStmt()+ "\n"
649                     + "Generate create primary keys ="+ getGenerateCreatePKStmt()+ "\n"
650                     + "Generate create tables ="+ getGenerateCreateTableStmt()+ "\n"
651                     + "Generate drop foreign keys ="+ getGenerateDropIntegrityStmt()+ "\n"
652                     + "Generate drop tables ="+ getGenerateDropTableStmt()+ "\n"
653                     + "Generate sql for all vendors ="+ getGenerateSqlForAllVendors()+ "\n"
654                     + "Generate doml ="+ getGenerateDoml()+ "\n"
655                     + "Package name="+ getPackageName()+ "\n"
656                     + "Generate xml ="+ getGenerateXml()+ "\n"
657                     + "Full mode=" + getFullMode() + "\n"
658                                         + "Log mode=" + getLogMode() + "\n"
659                                         + "Log directory name=" + getStrLogDirName() + "\n"
660                                         + "Log file name=" + getStrLogFileName() + "\n";
661
662             return resString;
663         } catch (Exception JavaDoc e) {
664             throw new LoaderException("Exception:" + e.getMessage(), e);
665         }
666     }
667
668     /**
669      * Construct object LoaderGenerator with associated parameters.
670      * @param sourceType defines the type of the source data.
671      * @param targetType defines the type of the target data.
672      * @param sourceDriverName is driver of defined source database.
673      * @param targetDriverName is driver of defined target database.
674      * @param sourceDataBase defines the place where you're put the database tables.
675      * @param targetDataBase defines the place where the target database tables are.
676      * @param valueMode defines the difference from overwrite and update attribute.
677      * Default valueMode is Overwrite.
678      * @param generatorOutput is optional. That represents the directory, where the
679      * Octopus place created files. If this argument don't exists, Octopus place
680      * created files in to current directory!
681      * @param sourceUser defines the user of the source database.
682      * @param sourcePassword defines user password for the source database.
683      * @param targetUser defines the user of the target database.
684      * @param targetPassword defines user password for the target database.
685      * @param domlPath defines if the doml file exists. Default value is false
686      * all, application generates xml, sql and doml files as ouput files. If the generateDoc has value
687      * doml, application generates only the doml file, and if generateDoc has the value wdoml, application
688      * generates xml and sql files.
689      * @param packageName defines the package name for the generated doml file.
690      * @param generateDropTableStmt defines if you want to generate only Sql statement for DROP TABLE
691      * @param generateCreateTableStmt defines if you want to generate only Sql statement for CREATE TABLE
692      * @param generateCreatePKStmt defines if you want to generate only Sql statement for ALTER TABLE
693      * @param generateCreateFKStmt defines if you want to generate only Sql statement for ALTER TABLE
694      * @param generateCreateIndexStmt defines if you want to generate only Sql statement for ALTER TABLE
695      * @param generateSqlForAllVendors defines if you want to generate Sql statements for all named
696      * database vendors
697      * @param generateXml defines if you want to generate xml file as output files
698      * @param generateDoml defines if you want to generate doml file as output file
699      * @param fullMode defines in which mode you want to generate xml files.
700      * @param includeTableList defines the list of tables which you want to include into
701      * Generator process
702      * @param confJarStructure defines the structure of jar file in which are conf
703      * files placed
704      * @throws LoaderException
705      */

706
707     public LoaderGenerator(String JavaDoc sourceType, String JavaDoc sourceDataBase,
708                                                     String JavaDoc valueMode, String JavaDoc generatorOutput, String JavaDoc sourceDriverName,
709                                                     String JavaDoc targetDriverName, String JavaDoc targetDataBase, String JavaDoc targetType,
710                                                     String JavaDoc sourceUser, String JavaDoc sourcePassword, String JavaDoc targetUser,
711                                                     String JavaDoc targetPassword, String JavaDoc domlPath, String JavaDoc packageName, String JavaDoc generateDropTableStmt,
712                                                     String JavaDoc generateDropIntegrityStmt, String JavaDoc generateCreateTableStmt, String JavaDoc generateCreatePKStmt,
713                                                     String JavaDoc generateCreateFKStmt, String JavaDoc generateCreateIndexStmt, String JavaDoc generateSqlForAllVendors,
714                                                     String JavaDoc generateXml, String JavaDoc generateDoml, String JavaDoc fullMode, String JavaDoc includeTableList,
715                                                     String JavaDoc confJarStructure)
716                                                     throws LoaderException {
717
718         this(sourceType, sourceDataBase, valueMode, generatorOutput,
719         sourceDriverName, targetDriverName, targetDataBase, targetType,
720         sourceUser, sourcePassword, targetUser, targetPassword, domlPath,
721         packageName, generateDropTableStmt, generateDropIntegrityStmt,
722         generateCreateTableStmt, generateCreatePKStmt, generateCreateFKStmt,
723         generateCreateIndexStmt, generateSqlForAllVendors, generateXml, generateDoml,
724         fullMode, "false", includeTableList, confJarStructure);
725
726     }
727
728     /**
729      * Construct object LoaderGenerator with associated parameters.
730      * @param sourceType defines the type of the source data.
731      * @param targetType defines the type of the target data.
732      * @param sourceDriverName is driver of defined source database.
733      * @param targetDriverName is driver of defined target database.
734      * @param sourceDataBase defines the place where you're put the database tables.
735      * @param targetDataBase defines the place where the target database tables are.
736      * @param valueMode defines the difference from overwrite and update attribute.
737      * Default valueMode is Overwrite.
738      * @param generatorOutput is optional. That represents the directory, where the
739      * Octopus place created files. If this argument don't exists, Octopus place
740      * created files in to current directory!
741      * @param sourceUser defines the user of the source database.
742      * @param sourcePassword defines user password for the source database.
743      * @param targetUser defines the user of the target database.
744      * @param targetPassword defines user password for the target database.
745      * @param domlPath defines if the doml file exists. Default value is false
746      * all, application generates xml, sql and doml files as ouput files. If the generateDoc has value
747      * doml, application generates only the doml file, and if generateDoc has the value wdoml, application
748      * generates xml and sql files.
749      * @param packageName defines the package name for the generated doml file.
750      * @param generateDropTableStmt defines if you want to generate only Sql statement for DROP TABLE
751      * @param generateCreateTableStmt defines if you want to generate only Sql statement for CREATE TABLE
752      * @param generateCreatePKStmt defines if you want to generate only Sql statement for ALTER TABLE
753      * @param generateCreateFKStmt defines if you want to generate only Sql statement for ALTER TABLE
754      * @param generateCreateIndexStmt defines if you want to generate only Sql statement for ALTER TABLE
755      * @param generateSqlForAllVendors defines if you want to generate Sql statements for all named
756      * database vendors
757      * @param generateXml defines if you want to generate xml file as output files
758      * @param generateDoml defines if you want to generate doml file as output file
759      * @param fullMode defines in which mode you want to generate xml files.
760      * @param restoreMode defines if we use application for restoring the database
761      * @param includeTableList defines the list of tables which you want to include into
762      * Generator process
763      * @param confJarStructure defines the structure of jar file in which are conf files
764      * placed.
765      * @throws LoaderException
766      */

767
768     public LoaderGenerator(String JavaDoc sourceType, String JavaDoc sourceDataBase, String JavaDoc valueMode,
769                                                     String JavaDoc generatorOutput, String JavaDoc sourceDriverName, String JavaDoc targetDriverName,
770                                                     String JavaDoc targetDataBase, String JavaDoc targetType, String JavaDoc sourceUser, String JavaDoc sourcePassword,
771                                                     String JavaDoc targetUser, String JavaDoc targetPassword, String JavaDoc domlPath, String JavaDoc packageName,
772                                                     String JavaDoc generateDropTableStmt, String JavaDoc generateDropIntegrityStmt, String JavaDoc generateCreateTableStmt,
773                                                     String JavaDoc generateCreatePKStmt, String JavaDoc generateCreateFKStmt, String JavaDoc generateCreateIndexStmt,
774                                                     String JavaDoc generateSqlForAllVendors, String JavaDoc generateXml, String JavaDoc generateDoml, String JavaDoc fullMode,
775                                                     String JavaDoc restoreMode, String JavaDoc includeTableList, String JavaDoc confJarStructure)
776                                                     throws LoaderException {
777
778         generatorParameters = new InputParameters(confJarStructure);
779         generatorParameters.setConfJarStructure(confJarStructure);
780
781         generatorParameters.setSourceType(sourceType);
782         //target and source driver name must goes frist, because alterTablePrimaryKey...
783
generatorParameters.setTargetDriverName(targetDriverName);
784         generatorParameters.setSourceDriverName(sourceDriverName);
785         generatorParameters.setTargetType(targetType);
786         generatorParameters.setSourceDataBase(sourceDataBase);
787         generatorParameters.setTargetDataBase(targetDataBase);
788         generatorParameters.setValueMode(valueMode);
789         generatorParameters.setGeneratorOutput(generatorOutput);
790         generatorParameters.setSourceUser(sourceUser);
791         generatorParameters.setSourcePassword(sourcePassword);
792         generatorParameters.setTargetUser(targetUser);
793         generatorParameters.setTargetPassword(targetPassword);
794
795         if (generateDropTableStmt != null)
796             generatorParameters.setSqlStmtDropTable(generateDropTableStmt);
797         if (generateDropIntegrityStmt != null)
798             generatorParameters.setSqlStmtDropIntegrity(generateDropIntegrityStmt);
799         if (generateCreateTableStmt != null)
800             generatorParameters.setSqlStmtCreateTable(generateCreateTableStmt);
801         if (generateCreatePKStmt != null)
802             generatorParameters.setSqlStmtCreatePK(generateCreatePKStmt);
803         if (generateCreateFKStmt != null)
804             generatorParameters.setSqlStmtCreateFK(generateCreateFKStmt);
805         if (generateCreateIndexStmt != null)
806             generatorParameters.setSqlStmtCreateIndex(generateCreateIndexStmt);
807         if (generateSqlForAllVendors != null)
808             generatorParameters.setAllVendors(generateSqlForAllVendors);
809
810         generatorParameters.setDomlPath(domlPath);
811         if (generateXml != null)
812             generatorParameters.setGenerateXml(generateXml);
813         if (generateDoml != null)
814             generatorParameters.setGenerateDoml(generateDoml);
815         generatorParameters.setPackageName(packageName);
816         if (fullMode != null)
817             generatorParameters.setFullMode(fullMode);
818         if (restoreMode != null)
819             generatorParameters.setRestoreMode(restoreMode);
820         if (includeTableList != null)
821             generatorParameters.setIncludeTableList(includeTableList);
822
823         generatorParameters.setSourceDriverProperties();
824         generatorParameters.setTargetDriverProperties();
825         generatorParameters.setOidAndVersionColumnName();
826         generatorParameters.setHasSize();
827         generatorParameters.setIsDecimal();
828         //setLogger();
829

830     }
831
832     /**
833          * Construct object LoaderGenerator with associated parameters.
834          * @param sourceType defines the type of the source data.
835          * @param targetType defines the type of the target data.
836          * @param sourceDriverName is driver of defined source database.
837          * @param targetDriverName is driver of defined target database.
838          * @param sourceDataBase defines the place where you're put the database tables.
839          * @param targetDataBase defines the place where the target database tables are.
840          * @param valueMode defines the difference from overwrite and update attribute.
841          * Default valueMode is Overwrite.
842          * @param generatorOutput is optional. That represents the directory, where the
843          * Octopus place created files. If this argument don't exists, Octopus place
844          * created files in to current directory!
845          * @param sourceUser defines the user of the source database.
846          * @param sourcePassword defines user password for the source database.
847          * @param targetUser defines the user of the target database.
848          * @param targetPassword defines user password for the target database.
849          * @param domlPath defines if the doml file exists. Default value is false
850          * all, application generates xml, sql and doml files as ouput files. If the generateDoc has value
851          * doml, application generates only the doml file, and if generateDoc has the value wdoml, application
852          * generates xml and sql files.
853          * @param packageName defines the package name for the generated doml file.
854          * @param generateDropTableStmt defines if you want to generate only Sql statement for DROP TABLE
855          * @param generateCreateTableStmt defines if you want to generate only Sql statement for CREATE TABLE
856          * @param generateCreatePKStmt defines if you want to generate only Sql statement for ALTER TABLE
857          * @param generateCreateFKStmt defines if you want to generate only Sql statement for ALTER TABLE
858          * @param generateCreateIndexStmt defines if you want to generate only Sql statement for ALTER TABLE
859          * @param generateSqlForAllVendors defines if you want to generate Sql statements for all named
860          * database vendors
861          * @param generateXml defines if you want to generate xml file as output files
862          * @param generateDoml defines if you want to generate doml file as output file
863          * @param fullMode defines in which mode you want to generate xml files.
864          * @param restoreMode defines if we use application for restoring the database
865          * @param includeTableList defines the list of tables which you want to include into
866          * Generator process
867          * @param confJarStructure defines the structure of jar file in which are conf files
868          * @param logMode defines logging level
869          * @param logDirName defines logging directory
870          * @param logFileName defines logging file name
871          * placed.
872          * @throws LoaderException
873          */

874
875     public LoaderGenerator(String JavaDoc sourceType, String JavaDoc sourceDataBase, String JavaDoc valueMode,
876                                                     String JavaDoc generatorOutput, String JavaDoc sourceDriverName, String JavaDoc targetDriverName, String JavaDoc targetDataBase,
877                                                     String JavaDoc targetType, String JavaDoc sourceUser, String JavaDoc sourcePassword, String JavaDoc targetUser,
878                                                     String JavaDoc targetPassword, String JavaDoc domlPath, String JavaDoc packageName, String JavaDoc generateDropTableStmt,
879                                                     String JavaDoc generateDropIntegrityStmt, String JavaDoc generateCreateTableStmt, String JavaDoc generateCreatePKStmt,
880                                                     String JavaDoc generateCreateFKStmt, String JavaDoc generateCreateIndexStmt, String JavaDoc generateSqlForAllVendors,
881                                                     String JavaDoc generateXml, String JavaDoc generateDoml, String JavaDoc fullMode, String JavaDoc restoreMode,
882                                                     String JavaDoc includeTableList, String JavaDoc confJarStructure, String JavaDoc logMode, String JavaDoc logDirName,
883                                                     String JavaDoc logFileName)
884                                                     throws LoaderException {
885
886         generatorParameters = new InputParameters(confJarStructure);
887         generatorParameters.setConfJarStructure(confJarStructure);
888
889         generatorParameters.setSourceType(sourceType);
890         //target and source driver name must goes frist, because alterTablePrimaryKey...
891
generatorParameters.setTargetDriverName(targetDriverName);
892         generatorParameters.setSourceDriverName(sourceDriverName);
893         generatorParameters.setTargetType(targetType);
894         generatorParameters.setSourceDataBase(sourceDataBase);
895         generatorParameters.setTargetDataBase(targetDataBase);
896         generatorParameters.setValueMode(valueMode);
897         generatorParameters.setGeneratorOutput(generatorOutput);
898         generatorParameters.setSourceUser(sourceUser);
899         generatorParameters.setSourcePassword(sourcePassword);
900         generatorParameters.setTargetUser(targetUser);
901         generatorParameters.setTargetPassword(targetPassword);
902
903         if (generateDropTableStmt != null)
904             generatorParameters.setSqlStmtDropTable(generateDropTableStmt);
905         if (generateDropIntegrityStmt != null)
906             generatorParameters.setSqlStmtDropIntegrity(generateDropIntegrityStmt);
907         if (generateCreateTableStmt != null)
908             generatorParameters.setSqlStmtCreateTable(generateCreateTableStmt);
909         if (generateCreatePKStmt != null)
910             generatorParameters.setSqlStmtCreatePK(generateCreatePKStmt);
911         if (generateCreateFKStmt != null)
912             generatorParameters.setSqlStmtCreateFK(generateCreateFKStmt);
913         if (generateCreateIndexStmt != null)
914             generatorParameters.setSqlStmtCreateIndex(generateCreateIndexStmt);
915         if (generateSqlForAllVendors != null)
916             generatorParameters.setAllVendors(generateSqlForAllVendors);
917
918         generatorParameters.setDomlPath(domlPath);
919         if (generateXml != null)
920             generatorParameters.setGenerateXml(generateXml);
921         if (generateDoml != null)
922             generatorParameters.setGenerateDoml(generateDoml);
923         generatorParameters.setPackageName(packageName);
924         if (fullMode != null)
925             generatorParameters.setFullMode(fullMode);
926         if (restoreMode != null)
927             generatorParameters.setRestoreMode(restoreMode);
928         if (includeTableList != null)
929             generatorParameters.setIncludeTableList(includeTableList);
930         if (logMode != null) {
931             this.logMode = logMode;
932         }
933         if (logDirName != null) {
934             this.strLogDirName = logDirName;
935         }
936         if (logFileName != null) {
937             this.strLogFileName = logFileName;
938         }
939         generatorParameters.setSourceDriverProperties();
940         generatorParameters.setTargetDriverProperties();
941         generatorParameters.setOidAndVersionColumnName();
942         generatorParameters.setHasSize();
943         generatorParameters.setIsDecimal();
944
945     }
946
947     /**
948      * Public constructor of LoaderGenerator class. Constructor set value for sourceDataBase and
949      * targetDataBase attribute. Class set all other attributes to the default values.
950      * @param sourceDataBase defines the place where you're put the database tables.
951      * @param targetDataBase defines the place where the target database tables are.
952      * @param sourceType defines the type of the source database.
953      * @param targetType defines the type of the target database.
954      * @throws LoaderException
955      */

956     public LoaderGenerator(String JavaDoc sourceDataBase, String JavaDoc targetDataBase, String JavaDoc sourceType,
957                                                     String JavaDoc targetType) throws LoaderException {
958
959         this(sourceDataBase, targetDataBase, sourceType, targetType, null);
960
961     }
962
963     /**
964     * Public constructor of LoaderGenerator class. Constructor set value for sourceDataBase and
965     * targetDataBase attribute. Class set all other attributes to the default values.
966     * @param sourceDataBase defines the place where you're put the database tables.
967     * @param targetDataBase defines the place where the target database tables are.
968     * @param sourceType defines the type of the source database.
969     * @param targetType defines the type of the target database.
970     * @throws LoaderException
971     */

972     public LoaderGenerator(String JavaDoc sourceDataBase, String JavaDoc targetDataBase, String JavaDoc sourceType,
973                                                 String JavaDoc targetType, String JavaDoc confJarStructure) throws LoaderException {
974
975         generatorParameters = new InputParameters("");
976         generatorParameters.setConfJarStructure(confJarStructure);
977         generatorParameters.setSourceDataBase(sourceDataBase);
978
979         generatorParameters.setTargetDataBase(targetDataBase);
980         generatorParameters.setSourceType(sourceType);
981         generatorParameters.setTargetType(targetType);
982         generatorParameters.setSourceDriverProperties();
983         generatorParameters.setTargetDriverProperties();
984         generatorParameters.setOidAndVersionColumnName();
985         generatorParameters.setHasSize();
986         generatorParameters.setIsDecimal();
987         //setLogger();
988
}
989
990     /**
991      * Main method controls parameters, it they are OK starts load method, but if they aren't makes alert.
992      * @param args represents the input parameters
993      *
994      * Usage: java org.webdocwf.util.loader.generator.Generator [options]
995      * Options:
996      * -st sourceType, defines the type of the source database.
997      * -tt targetType, defines the type of the target database.
998      * -sdn sourceDriverName, defines the driver of defined source database.
999      * -tdn targetDriverName, defines the driver of defined target database.
1000     * -sdb sourceDataBase, defines the place where you're put the source database tables.
1001     * -tdb targetDataBase, defines the place where you're put the target database tables.
1002     * -m valueMode, defines the difference from overwrite and update attribute. If the valueMode
1003     * has value 'copy', attribute has value 'Overwrite', or if the valueMode has value 'sync', attribute
1004     * has value 'Update'. Default value of valueMode is 'copy'.
1005     * -o generatorOutput, is optional. That represent the directory, where the Octopus place created files.
1006     * If this argument don't exists, Octopus place created files in to current directory!
1007     * -su sourceUser, defines the user of the source database.
1008     * -sp sourcePassword, defines the user password for the source database.
1009     * -tu targetUser, defines the user of the target database.
1010     * -tp targetPassword, defines the user password for the target database.
1011     * -doml domlUrl, defines the place where the doml file is placed.
1012     * -pack packageName, defines the package name for the generated doml file.
1013     * -xml -xml generateXml, defines if you want to generate xml files as output files
1014     * -gdoml generateDoml, defines if you want to generate doml file as output file.
1015     * -sqlCT generateCreateTables defines if you want to generate only Sql statement for CREATE TABLE.
1016     * -sqlDT generateDropTableStmt defines if you want to generate only Sql statement for DROP TABLE.
1017     * -sqlCPK generateCreatePrimaryKeys defines if you want to generate only Sql statement for ALTER TABLE ADD CONSTRAINT (PRIMARY KEY).
1018     * -sqlCFK generateCreateForeigKeys defines if you want to generate only Sql statement for ALTER TABLE ADD CONSTRAINT (FOREIGN KEY).
1019     * -sqlCI generateCreateIndex defines if you want to generate only Sql statement for CREATE INDEX.
1020     * -sqlAll generateSqlForAllVendors defines if you want to generate sql statements for all named database vendors.
1021     * -fm fullMode defines the mode of output xml files. Possible values are true and false.
1022     * -lm logMode defines logging level
1023     * -l logDirName defines logging directory
1024     * -f logFileName defines logging file name
1025     **/

1026
1027    public static void main(String JavaDoc args[]) {
1028
1029        String JavaDoc generatorOutput = null;
1030        String JavaDoc valueMode = null;
1031        String JavaDoc domlUrl = null;
1032        String JavaDoc packageName = null;
1033
1034        String JavaDoc sourceType = null;
1035        String JavaDoc sourceDataBase = null;
1036        String JavaDoc sourceDriverName = null;
1037        String JavaDoc sourceUser = null;
1038        String JavaDoc sourcePassword = null;
1039
1040        String JavaDoc targetType = null;
1041        String JavaDoc targetDataBase = null;
1042        String JavaDoc targetDriverName = null;
1043        String JavaDoc targetUser = null;
1044        String JavaDoc targetPassword = null;
1045
1046        //logging
1047
String JavaDoc logDirName = null;
1048        String JavaDoc logFileName = null;
1049        String JavaDoc logMode = null;
1050
1051        //Output mode
1052
//main
1053
String JavaDoc generateXml = null;
1054        String JavaDoc generateDoml = null;
1055        //for generate sql
1056
String JavaDoc generateDropTableStmt = null;
1057        String JavaDoc generateDropIntegrityStmt = null;
1058        String JavaDoc generateCreateTableStmt = null;
1059        String JavaDoc generateCreatePKStmt = null;
1060        String JavaDoc generateCreateFKStmt = null;
1061        String JavaDoc generateCreateIndexStmt = null;
1062
1063        //for genrate sql for all vendors
1064
String JavaDoc generateSqlForAllVendors = null;
1065        //optimized modes
1066
String JavaDoc fullMode = null;
1067        String JavaDoc restoreMode = null;
1068        String JavaDoc includeTableList = null;
1069        String JavaDoc confJarStructure = null;
1070
1071        if (args.length > 8 && args.length < 53) {
1072            for (int i = 0; i < args.length - 1; i = i + 1) {
1073                if (args[i].equalsIgnoreCase("-st"))
1074                    sourceType = args[++i];
1075                else if (args[i].equalsIgnoreCase("-sdb"))
1076                    sourceDataBase = args[++i];
1077                else if (args[i].equalsIgnoreCase("-m"))
1078                    valueMode = args[++i];
1079                else if (args[i].equalsIgnoreCase("-o"))
1080                    generatorOutput = args[++i];
1081                else if (args[i].equalsIgnoreCase("-sdn"))
1082                    sourceDriverName = args[++i];
1083                else if (args[i].equalsIgnoreCase("-tdn"))
1084                    targetDriverName = args[++i];
1085                else if (args[i].equalsIgnoreCase("-tdb"))
1086                    targetDataBase = args[++i];
1087                if (args[i].equalsIgnoreCase("-tt"))
1088                    targetType = args[++i];
1089                if (args[i].equalsIgnoreCase("-su"))
1090                    sourceUser = args[++i];
1091                if (args[i].equalsIgnoreCase("-sp"))
1092                    sourcePassword = args[++i];
1093                if (args[i].equalsIgnoreCase("-tu"))
1094                    targetUser = args[++i];
1095                if (args[i].equalsIgnoreCase("-tp"))
1096                    targetPassword = args[++i];
1097                if (args[i].equalsIgnoreCase("-doml"))
1098                    domlUrl = args[++i];
1099                if (args[i].equalsIgnoreCase("-pack"))
1100                    packageName = args[++i];
1101                if (args[i].equalsIgnoreCase("-xml"))
1102                    generateXml = args[++i];
1103                if (args[i].equalsIgnoreCase("-gdoml"))
1104                    generateDoml = args[++i];
1105                if (args[i].equalsIgnoreCase("-sqlCT"))
1106                    generateCreateTableStmt = args[++i];
1107                if (args[i].equalsIgnoreCase("-sqlDT"))
1108                    generateDropTableStmt = args[++i];
1109                if (args[i].equalsIgnoreCase("-sqlDI"))
1110                    generateDropIntegrityStmt = args[++i];
1111                if (args[i].equalsIgnoreCase("-sqlCPK"))
1112                    generateCreatePKStmt = args[++i];
1113                if (args[i].equalsIgnoreCase("-sqlCFK"))
1114                    generateCreateFKStmt = args[++i];
1115                if (args[i].equalsIgnoreCase("-sqlCI"))
1116                    generateCreateIndexStmt = args[++i];
1117                if (args[i].equalsIgnoreCase("-sqlAll"))
1118                    generateSqlForAllVendors = args[++i];
1119                if (args[i].equalsIgnoreCase("-fm"))
1120                    fullMode = args[++i];
1121                if (args[i].equalsIgnoreCase("-rm"))
1122                    restoreMode = args[++i];
1123                if (args[i].equalsIgnoreCase("-it"))
1124                    includeTableList = args[++i];
1125                if (args[i].equalsIgnoreCase("-cjs"))
1126                    confJarStructure = args[++i];
1127                if (args[i].equalsIgnoreCase("-lm"))
1128                    logMode = args[++i];
1129                else if (args[i].equalsIgnoreCase("-l"))
1130                    logDirName = args[++i];
1131                else if (args[i].equalsIgnoreCase("-f"))
1132                    logFileName = args[++i];
1133            }
1134        } else {
1135            System.out.println("You didn't enter all required parameters, for running the application!");
1136            BufferOctopusClass.getInstance().writeToBuffer("You didn't enter all required parameters, for running the application!");
1137            printUsage();
1138            System.exit(1);
1139        }
1140        try {
1141
1142            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);
1143
1144            generator.generate();
1145            System.exit(0);
1146
1147        } catch (LoaderException le) {
1148            System.out.println(le.getStackTraceAsString());
1149            BufferOctopusClass.getInstance().writeToBuffer(le.getStackTraceAsString());
1150            return;
1151        } catch (Throwable JavaDoc th) {
1152            BufferOctopusClass.getInstance().writeToBuffer(th.getMessage());
1153            th.printStackTrace(System.out);
1154            return;
1155        }
1156    }
1157
1158    static void printUsage() {
1159        //System.out.println("Usage: java org.webdocwf.util.loader.generator.Generator [options] ");
1160
BufferOctopusClass.getInstance().writeToBuffer("Usage: java org.webdocwf.util.loader.generator.Generator [options] ");
1161        //System.out.println(" Options:");
1162
BufferOctopusClass.getInstance().writeToBuffer(" Options:");
1163        //System.out.println(" -st sourceType, defines the type of the source database.");
1164
BufferOctopusClass.getInstance().writeToBuffer(" -st sourceType, defines the type of the source database.");
1165        //System.out.println(" -tt targetType, defines the type of the target database.");
1166
BufferOctopusClass.getInstance().writeToBuffer(" -tt targetType, defines the type of the target database.");
1167        //System.out.println(" -sdn sourceDriverName, represents driver of defined source database.");
1168
BufferOctopusClass.getInstance().writeToBuffer(" -sdn sourceDriverName, represents driver of defined source database.");
1169        // System.out.println(" -tdn targetDriverName, represents driver of defined target database.");
1170
BufferOctopusClass.getInstance().writeToBuffer(" -tdn targetDriverName, represents driver of defined target database.");
1171        // System.out.println(" -sdb sourceDatabase, defines the place where you're put the database tables");
1172
BufferOctopusClass.getInstance().writeToBuffer(" -sdb sourceDatabase, defines the place where you're put the database tables");
1173        // System.out.println(" -tdb targetDataBase defines the place where the target database tables are.");
1174
BufferOctopusClass.getInstance().writeToBuffer(" -tdb targetDataBase defines the place where the target database tables are.");
1175        // System.out.println(" -m valueMode, is the difference from overwrite and update attribute");
1176
BufferOctopusClass.getInstance().writeToBuffer(" -m valueMode, is the difference from overwrite and update attribute");
1177        // System.out.println(" -su sourceUser, defines the user of the source database.");
1178
BufferOctopusClass.getInstance().writeToBuffer(" -su sourceUser, defines the user of the source database.");
1179        // System.out.println(" -sp sourcePassword, defines user password for the source database.");
1180
BufferOctopusClass.getInstance().writeToBuffer(" -sp sourcePassword, defines user password for the source database.");
1181        // System.out.println(" -tu targetUser, defines the user of the target database.");
1182
BufferOctopusClass.getInstance().writeToBuffer(" -tu targetUser, defines the user of the target database.");
1183        // System.out.println(" -tp targetPassword, defines user password for the target database.");
1184
BufferOctopusClass.getInstance().writeToBuffer(" -tp targetPassword, defines user password for the target database.");
1185        // System.out.println(" -doml domlUrl, defines the place where the doml file is placed.");
1186
BufferOctopusClass.getInstance().writeToBuffer(" -doml domlUrl, defines the place where the doml file is placed.");
1187        // System.out.println(" -o generatorOutput, is optional. That represent the directory, where the Octopus place"+
1188
// " created files. If this argument dont exists, Octopus place created files in to current direcory!");
1189
BufferOctopusClass.getInstance().writeToBuffer(" -o generatorOutput, is optional. That represent the directory, where the Octopus place" + " created files. If this argument dont exists, Octopus place created files in to current direcory!");
1190        // System.out.println(" -pack packageName, defines the package name for the generated doml file.");
1191
BufferOctopusClass.getInstance().writeToBuffer(" -pack packageName, defines the package name for the generated doml file.");
1192
1193        // System.out.println(" -xml generateXml, defines if you want to generate xml files as output files. "+
1194
// " Possible values are true and false.");
1195
BufferOctopusClass.getInstance().writeToBuffer(" -xml generateXml, defines if you want to generate xml files as output files. " + " Possible values are true and false.");
1196        // System.out.println(" -gdoml generateDoml, defines if you want to generate doml file as output file. "+
1197
// " Possible values are true and false.");
1198
BufferOctopusClass.getInstance().writeToBuffer(" -gdoml generateDoml, defines if you want to generate doml file as output file. " + " Possible values are true and false.");
1199        // System.out.println(" -sqlCT generateCreateTables, defines if you want to generate only Sql statement for CREATE TABLE.");
1200
BufferOctopusClass.getInstance().writeToBuffer(" -sqlCT generateCreateTables, defines if you want to generate only Sql statement for CREATE TABLE.");
1201
1202        // System.out.println(" -sqlDT generateDropTableStmt, defines if you want to generate only Sql statement for DROP TABLE.");
1203
BufferOctopusClass.getInstance().writeToBuffer(" -sqlDT generateDropTableStmt, defines if you want to generate only Sql statement for DROP TABLE.");
1204
1205        // System.out.println(" -sqlCPK generateCreatePrimaryKeys, defines if you want to generate only Sql statement for ALTER TABLE ADD CONSTRAINT (PRIMARY KEY).");
1206
BufferOctopusClass.getInstance().writeToBuffer(" -sqlCPK generateCreatePrimaryKeys, defines if you want to generate only Sql statement for ALTER TABLE ADD CONSTRAINT (PRIMARY KEY).");
1207
1208        // System.out.println(" -sqlCFK generateCreateForeigKeys, defines if you want to generate only Sql statement for ALTER TABLE ADD CONSTRAINT (FOREIGN KEY).");
1209
BufferOctopusClass.getInstance().writeToBuffer(" -sqlCFK generateCreateForeigKeys, defines if you want to generate only Sql statement for ALTER TABLE ADD CONSTRAINT (FOREIGN KEY).");
1210
1211        // System.out.println(" -sqlCI generateCreateIndex, defines if you want to generate only Sql statement for CREATE INDEX.");
1212
BufferOctopusClass.getInstance().writeToBuffer(" -sqlCI generateCreateIndex, defines if you want to generate only Sql statement for CREATE INDEX.");
1213
1214        // System.out.println(" -sqlAll generateSqlForAllVendors, defines if you want to generate sql statements for all named database vendors.");
1215
BufferOctopusClass.getInstance().writeToBuffer(" -sqlAll generateSqlForAllVendors, defines if you want to generate sql statements for all named database vendors.");
1216
1217        // System.out.println(" -fm fullMode, defines the mode of output xml files. Possible values are true and false.");
1218
BufferOctopusClass.getInstance().writeToBuffer(" -fm fullMode, defines the mode of output xml files. Possible values are true and false.");
1219
1220        // System.out.println(" -it includeTableList, defines tables which you want to incude into Generator process.");
1221
BufferOctopusClass.getInstance().writeToBuffer(" -it includeTableList, defines tables which you want to incude into Generator process.");
1222
1223        // System.out.println("For more details, see documentation.");
1224
BufferOctopusClass.getInstance().writeToBuffer("For more details, see documentation.");
1225        //System.out.println(" -lm defines the default logmode. Possible values are 'none', 'normal' (is the default) and 'full'.");
1226
BufferOctopusClass.getInstance().writeToBuffer(" -lm defines the default logmode. Possible values are 'none', 'normal' (is the default) and 'full'.");
1227
1228        //System.out.println(" -l defines the logfile directory. The default is the current working directory. \n");
1229
BufferOctopusClass.getInstance().writeToBuffer(" -v defines variables used in variable columns. \n");
1230
1231        //System.out.println(" -f defines the logfile name. The default is 'GeneratorLog-YYYY-MM-DD-HH-mm-SS.txt'. \n");
1232
BufferOctopusClass.getInstance().writeToBuffer(" -f defines the logfile name. The default is 'GeneratorLog-YYYY-MM-DD-HH-mm-SS.txt'. \n");
1233
1234    }
1235
1236    /**
1237     * This method init logger
1238     * @throws LoaderException
1239     */

1240    private void setLogger() throws LoaderException {
1241
1242        this.timeCounter = new TimeWatch();
1243        this.timeCounter.setStartJobTime();
1244
1245        try {
1246
1247            this.logger = new StandardLogger();
1248            this.strLoggerParam = this.strLogDirName + ";" + this.strLogFileName;
1249            this.standardLogger = true;
1250            this.logger.configure(strLoggerParam);
1251            this.logger.setEnabledLogLevels(this.logMode);
1252        } catch (Exception JavaDoc e) {
1253
1254            LoaderException le = new LoaderException("Error while instantiate StandardLogger!", e);
1255            throw le;
1256        }
1257    }
1258
1259    /**
1260     *
1261     * Method generate is main method in class LoaderGenerator. It is used to load data from the source
1262     * table, and starts LoadJobWriter,CreateIncludeFiles and CreateIncludeDomlFiles methods.
1263     * @throws LoaderException
1264     */

1265    public void generate() throws LoaderException {
1266
1267        try {
1268            LoadJobWriter loadJobWriter;
1269            GenerateSqlForAllVendors generateSqlForAllVendors;
1270            //Zk added for logging
1271
this.setLogger();
1272
1273            if (standardLogger == true) {
1274                this.logger.write("normal", "Default (Standard) Logger is load.");
1275                this.logger.write("normal", "OctopusGenerator started.");
1276            }
1277            if (generatorParameters.getSqlForAllVendors() == true) {
1278
1279                generateSqlForAllVendors = new GenerateSqlForAllVendors(generatorParameters);
1280
1281            } else {
1282                if (generatorParameters.getDomlPath() == null || generatorParameters.getDomlPath().equalsIgnoreCase("")) {
1283                    CreateIncludeFiles createIncludeFiles = new CreateIncludeFiles(generatorParameters);
1284                } else {
1285                    CreateIncludeDomlFiles createIncludeDomlFiles;
1286                    createIncludeDomlFiles = new CreateIncludeDomlFiles(generatorParameters);
1287                }
1288                if (generatorParameters.getGenerateXml().equalsIgnoreCase("true"))
1289                    loadJobWriter = new LoadJobWriter(generatorParameters);
1290            }
1291            if (this.standardLogger == true) {
1292                this.logger.write("normal", "Duration: " + this.timeCounter.getTotalTime());
1293                this.logger.write("normal", "OctopusGenerator finished.");
1294            }
1295        } catch (Exception JavaDoc e) {
1296            String JavaDoc msg = "Exception in method generate() in LoaderGenerator class!";
1297            LoaderException le = new LoaderException(msg + "\n" + e.getMessage(), (Throwable JavaDoc) e);
1298            if (standardLogger == true) {
1299                this.logger.write("full", "Exception in method generate() in LoaderGenerator class!" + "\n" + le.getStackTraceAsString());
1300            }
1301            throw le;
1302
1303        }
1304
1305    }
1306   
1307}
Popular Tags