Source Code Cross Referenced for LoaderGenerator.java in  » Database-JDBC-Connection-Pool » octopus » org » webdocwf » util » loader » generator » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database JDBC Connection Pool » octopus » org.webdocwf.util.loader.generator 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         LoaderGenerator - tool for generated xml, sql and doml file needed for Octopus.
0003:
0004:
0005:         Copyright (C) 2003  Together
0006:
0007:         This library is free software; you can redistribute it and/or
0008:         modify it under the terms of the GNU Lesser General Public
0009:         License as published by the Free Software Foundation; either
0010:         version 2.1 of the License, or (at your option) any later version.
0011:
0012:         This library is distributed in the hope that it will be useful,
0013:         but WITHOUT ANY WARRANTY; without even the implied warranty of
0014:         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015:         Lesser General Public License for more details.
0016:
0017:         You should have received a copy of the GNU Lesser General Public
0018:         License along with this library; if not, write to the Free Software
0019:         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
0020:         */
0021:
0022:        package org.webdocwf.util.loader.generator;
0023:
0024:        import java.util.Vector;
0025:
0026:        import org.webdocwf.util.loader.BufferOctopusClass;
0027:        import org.webdocwf.util.loader.LoaderException;
0028:        import org.webdocwf.util.loader.TimeWatch;
0029:        import org.webdocwf.util.loader.logging.StandardLogger;
0030:
0031:        /**
0032:         * LoaderGenerator class dinamicly generates the xml files (LoaderJob.xml and ImportDefinition.xml)
0033:         * from the input data and source database.
0034:         * Also LoaderGenerator creates SQL statements for building and loading an SQL target database.
0035:         * @author Radoslav Dutina
0036:         * @version 1.0
0037:         */
0038:        public class LoaderGenerator {
0039:
0040:            private InputParameters generatorParameters;
0041:            private StandardLogger logger;
0042:            private String strLogDirName = "";
0043:            private String strLogFileName = "defaultGenerator";
0044:            private String logMode = "normal";
0045:            private TimeWatch timeCounter;
0046:            private String strLoggerParam = "";
0047:            private boolean standardLogger;
0048:
0049:            /**
0050:             * This method set sourceDataBase
0051:             * @param sourceDataBase
0052:             * @throws LoaderException
0053:             */
0054:            public void setSourceDataBase(String sourceDataBase)
0055:                    throws LoaderException {
0056:                this .generatorParameters.setSourceDataBase(sourceDataBase);
0057:            }
0058:
0059:            /**
0060:             * This method return sourceDataBase
0061:             * @return sourceDataBase
0062:             * @throws LoaderException
0063:             */
0064:
0065:            public String getSourceDataBase() throws LoaderException {
0066:                return this .generatorParameters.getSourceDataBase();
0067:            }
0068:
0069:            /**
0070:             * This method set targetDataBase
0071:             * @param targetDataBase
0072:             * @throws LoaderException
0073:             */
0074:
0075:            public void setTargetDataBase(String targetDataBase)
0076:                    throws LoaderException {
0077:                this .generatorParameters.setTargetDataBase(targetDataBase);
0078:            }
0079:
0080:            /**
0081:             * This method return targetDataBase
0082:             * @return targetDataBase
0083:             * @throws LoaderException
0084:             */
0085:            public String getTargetDataBase() throws LoaderException {
0086:                return this .generatorParameters.getTargetDataBase();
0087:            }
0088:
0089:            /**
0090:             * This method set sourceType
0091:             * @param sourceType
0092:             * @throws LoaderException
0093:             */
0094:            public void setSourceType(String sourceType) throws LoaderException {
0095:                this .generatorParameters.setSourceType(sourceType);
0096:            }
0097:
0098:            /**
0099:             * This method return sourceType
0100:             * @return sourceType
0101:             * @throws LoaderException
0102:             */
0103:            public String getSourceType() throws LoaderException {
0104:                return this .generatorParameters.getSourceType();
0105:            }
0106:
0107:            /**
0108:             * This method set targetType
0109:             * @param targetType
0110:             * @throws LoaderException
0111:             */
0112:            public void setTargetType(String targetType) throws LoaderException {
0113:                this .generatorParameters.setTargetType(targetType);
0114:            }
0115:
0116:            /**
0117:             * This method return targetType
0118:             * @return String which is target type
0119:             * @throws LoaderException
0120:             */
0121:            public String getTargetType() throws LoaderException {
0122:                return this .generatorParameters.getTargetType();
0123:            }
0124:
0125:            /**
0126:             * This method set sourceDriverName
0127:             * @param sourceDriverName
0128:             * @throws LoaderException
0129:             */
0130:            public void setSourceDriverName(String sourceDriverName)
0131:                    throws LoaderException {
0132:                this .generatorParameters.setSourceDriverName(sourceDriverName);
0133:            }
0134:
0135:            /**
0136:             * This method return sourceDriverName
0137:             * @return sourceDriverName
0138:             * @throws LoaderException
0139:             */
0140:            public String getSourceDriverName() throws LoaderException {
0141:                return this .generatorParameters.getSourceDriverName();
0142:            }
0143:
0144:            /**
0145:             * This method set targetDriverName
0146:             * @param targetDriverName
0147:             * @throws LoaderException
0148:             */
0149:            public void setTargetDriverName(String targetDriverName)
0150:                    throws LoaderException {
0151:                this .generatorParameters.setTargetDriverName(targetDriverName);
0152:            }
0153:
0154:            /**
0155:             * This method return targetDriverName
0156:             * @return targetDriverName
0157:             * @throws LoaderException
0158:             */
0159:            public String getTargetDriverName() throws LoaderException {
0160:                return this .generatorParameters.getTargetDriverName();
0161:            }
0162:
0163:            /**
0164:             * This method set valueMode
0165:             * @param valueMode
0166:             * @throws LoaderException
0167:             */
0168:            public void setValueMode(String valueMode) throws LoaderException {
0169:                this .generatorParameters.setValueMode(valueMode);
0170:            }
0171:
0172:            /**
0173:             * This method returns valueMode
0174:             * @return String which is value mode
0175:             * @throws LoaderException
0176:             */
0177:            public String getValueMode() throws LoaderException {
0178:                return this .generatorParameters.getValueMode();
0179:            }
0180:
0181:            /**
0182:             * This method set generatorOutput
0183:             * @param generatorOutput
0184:             * @throws LoaderException
0185:             */
0186:            public void setGeneratorOutput(String generatorOutput)
0187:                    throws LoaderException {
0188:                this .generatorParameters.setGeneratorOutput(generatorOutput);
0189:            }
0190:
0191:            /**
0192:             * This method return generatorOutput
0193:             * @return generatorOutput
0194:             * @throws LoaderException
0195:             */
0196:            public String getGeneratorOutput() throws LoaderException {
0197:                return this .generatorParameters.getGeneratorOutput();
0198:            }
0199:
0200:            /**
0201:             * This method set sourceUser
0202:             * @param sourceUser
0203:             * @throws LoaderException
0204:             */
0205:            public void setSourceUser(String sourceUser) throws LoaderException {
0206:                this .generatorParameters.setSourceUser(sourceUser);
0207:            }
0208:
0209:            /**
0210:             * This method return sourceUser
0211:             * @return sourceUser
0212:             * @throws LoaderException
0213:             */
0214:            public String getSourceUser() throws LoaderException {
0215:                return this .generatorParameters.getSourceUser();
0216:            }
0217:
0218:            /**
0219:             * This method set targetUser
0220:             * @param targetUser
0221:             * @throws LoaderException
0222:             */
0223:            public void setTargetUser(String targetUser) throws LoaderException {
0224:                this .generatorParameters.setTargetUser(targetUser);
0225:            }
0226:
0227:            /**
0228:             * This method return targetUser
0229:             * @return targetUser
0230:             * @throws LoaderException
0231:             */
0232:            public String getTargetUser() throws LoaderException {
0233:                return this .generatorParameters.getTargetUser();
0234:            }
0235:
0236:            /**
0237:             * This method set sourcePassword
0238:             * @param sourcePassword
0239:             * @throws LoaderException
0240:             */
0241:            public void setSourcePassword(String sourcePassword)
0242:                    throws LoaderException {
0243:                this .generatorParameters.setSourcePassword(sourcePassword);
0244:            }
0245:
0246:            /**
0247:             * This method return sourcePassword
0248:             * @return sourcePassword
0249:             * @throws LoaderException
0250:             */
0251:            public String getSourcePassword() throws LoaderException {
0252:                return this .generatorParameters.getSourcePassword();
0253:            }
0254:
0255:            /**
0256:             * This method set targetPassword
0257:             * @param targetPassword
0258:             * @throws LoaderException
0259:             */
0260:            public void setTargetPassword(String targetPassword)
0261:                    throws LoaderException {
0262:                this .generatorParameters.setTargetPassword(targetPassword);
0263:            }
0264:
0265:            /**
0266:             * This method set targetPassword
0267:             * @return targetPassword
0268:             * @throws LoaderException
0269:             */
0270:            public String getTargetPassword() throws LoaderException {
0271:                return this .generatorParameters.getTargetPassword();
0272:            }
0273:
0274:            /**
0275:             * This method set domlPath
0276:             * @param domlPath
0277:             * @throws LoaderException
0278:             */
0279:            public void setDomlPath(String domlPath) throws LoaderException {
0280:                this .generatorParameters.setDomlPath(domlPath);
0281:            }
0282:
0283:            /**
0284:             * This method return domlPath
0285:             * @return domlPath
0286:             * @throws LoaderException
0287:             */
0288:            public String getDomlPath() throws LoaderException {
0289:                return this .generatorParameters.getDomlPath();
0290:            }
0291:
0292:            /**
0293:             * This method set packageName
0294:             * @param packageName
0295:             * @throws LoaderException
0296:             */
0297:            public void setPackageName(String packageName)
0298:                    throws LoaderException {
0299:                this .generatorParameters.setPackageName(packageName);
0300:            }
0301:
0302:            /**
0303:             * This method return packageName
0304:             * @return packageName
0305:             * @throws LoaderException
0306:             */
0307:            public String getPackageName() throws LoaderException {
0308:                return this .generatorParameters.getPackageName();
0309:            }
0310:
0311:            /**
0312:             * This method set generateDropTableStmt
0313:             * @param generateDropTableStmt
0314:             * @throws LoaderException
0315:             */
0316:            public void setGenerateDropTableStmt(boolean generateDropTableStmt)
0317:                    throws LoaderException {
0318:                this .generatorParameters.setSqlStmtDropTable(new Boolean(
0319:                        generateDropTableStmt).toString());
0320:            }
0321:
0322:            /**
0323:             * This method return generateDropTableStmt
0324:             * @return generateDropTableStmt
0325:             * @throws LoaderException
0326:             */
0327:            public boolean getGenerateDropTableStmt() throws LoaderException {
0328:                Vector tempVector = this .generatorParameters.getSqlToGenerate();
0329:                String dropTables = (String) tempVector.elementAt(1);
0330:                if (dropTables.equalsIgnoreCase("DropTables")) {
0331:                    return true;
0332:                } else {
0333:                    return false;
0334:                }
0335:
0336:            }
0337:
0338:            /**
0339:             * This method set generateCreateTableStmt
0340:             * @param generateCreateTableStmt
0341:             * @throws LoaderException
0342:             */
0343:            public void setGenerateCreateTableStmt(
0344:                    boolean generateCreateTableStmt) throws LoaderException {
0345:                this .generatorParameters.setSqlStmtCreateTable(new Boolean(
0346:                        generateCreateTableStmt).toString());
0347:            }
0348:
0349:            /**
0350:             * This method will return boolean which represents if user set "Create Tables" or not
0351:             * @return boolean value
0352:             * @throws LoaderException
0353:             */
0354:            public boolean getGenerateCreateTableStmt() throws LoaderException {
0355:                Vector tempVector = this .generatorParameters.getSqlToGenerate();
0356:                String createTables = (String) tempVector.elementAt(2);
0357:                if (createTables.equalsIgnoreCase("CreateTables")) {
0358:                    return true;
0359:                } else {
0360:                    return false;
0361:                }
0362:            }
0363:
0364:            /**
0365:             * This method set generateDropIntegrityStmt
0366:             * @param generateDropIntegrityStmt
0367:             * @throws LoaderException
0368:             */
0369:
0370:            public void setGenerateDropIntegrityStmt(
0371:                    boolean generateDropIntegrityStmt) throws LoaderException {
0372:                this .generatorParameters.setSqlStmtDropIntegrity(new Boolean(
0373:                        generateDropIntegrityStmt).toString());
0374:            }
0375:
0376:            /**
0377:             * This method return generateDropIntegrityStmt
0378:             * @return generateDropIntegrityStmt
0379:             * @throws LoaderException
0380:             */
0381:            public boolean getGenerateDropIntegrityStmt()
0382:                    throws LoaderException {
0383:                Vector tempVector = this .generatorParameters.getSqlToGenerate();
0384:                String dropIntegrity = (String) tempVector.elementAt(0);
0385:                if (dropIntegrity.equalsIgnoreCase("DropIntegrity")) {
0386:                    return true;
0387:                } else {
0388:                    return false;
0389:                }
0390:            }
0391:
0392:            /**
0393:             * This method set generateCreatePKStmt
0394:             * @param generateCreatePKStmt
0395:             * @throws LoaderException
0396:             */
0397:            public void setGenerateCreatePKStmt(boolean generateCreatePKStmt)
0398:                    throws LoaderException {
0399:                this .generatorParameters.setSqlStmtCreatePK(new Boolean(
0400:                        generateCreatePKStmt).toString());
0401:            }
0402:
0403:            /**
0404:             * This method return generateCreatePKStmt
0405:             * @return GenerateCreatePKStmt
0406:             * @throws LoaderException
0407:             */
0408:            public boolean getGenerateCreatePKStmt() throws LoaderException {
0409:                Vector tempVector = this .generatorParameters.getSqlToGenerate();
0410:                String createPrimary = (String) tempVector.elementAt(4);
0411:                if (createPrimary.equalsIgnoreCase("CreatePrimary")) {
0412:                    return true;
0413:                } else {
0414:                    return false;
0415:                }
0416:            }
0417:
0418:            /**
0419:             * This method set generateCreateFKStmt
0420:             * @param generateCreateFKStmt
0421:             * @throws LoaderException
0422:             */
0423:            public void setGenerateCreateFKStmt(boolean generateCreateFKStmt)
0424:                    throws LoaderException {
0425:                this .generatorParameters.setSqlStmtCreateFK(new Boolean(
0426:                        generateCreateFKStmt).toString());
0427:            }
0428:
0429:            /**
0430:             * This method return generateCreateFKStmt
0431:             * @return generateCreateFKStmt
0432:             * @throws LoaderException
0433:             */
0434:            public boolean getGenerateCreateFKStmt() throws LoaderException {
0435:                Vector tempVector = this .generatorParameters.getSqlToGenerate();
0436:                String createForeign = (String) tempVector.elementAt(5);
0437:                if (createForeign.equalsIgnoreCase("CreateForeigin")) {
0438:                    return true;
0439:                } else {
0440:                    return false;
0441:                }
0442:            }
0443:
0444:            /**
0445:             * This method set generateCreateIndexStmt
0446:             * @param generateCreateIndexStmt
0447:             * @throws LoaderException
0448:             */
0449:            public void setGenerateCreateIndexStmt(
0450:                    boolean generateCreateIndexStmt) throws LoaderException {
0451:                this .generatorParameters.setSqlStmtCreateIndex(new Boolean(
0452:                        generateCreateIndexStmt).toString());
0453:            }
0454:
0455:            /**
0456:             * This method return generateCreateIndexStmt
0457:             * @return CreateIndexes
0458:             * @throws LoaderException
0459:             */
0460:            public boolean getGenerateCreateIndexStmt() throws LoaderException {
0461:                Vector tempVector = this .generatorParameters.getSqlToGenerate();
0462:                String createIndexes = (String) tempVector.elementAt(3);
0463:                if (createIndexes.equalsIgnoreCase("CreateIndexes")) {
0464:                    return true;
0465:                } else {
0466:                    return false;
0467:                }
0468:            }
0469:
0470:            /**
0471:             * This method set generateSqlForAllVendors
0472:             * @param generateSqlForAllVendors
0473:             * @throws LoaderException
0474:             */
0475:            public void setGenerateSqlForAllVendors(
0476:                    boolean generateSqlForAllVendors) throws LoaderException {
0477:                this .generatorParameters.setAllVendors(new Boolean(
0478:                        generateSqlForAllVendors).toString());
0479:            }
0480:
0481:            /**
0482:             * This method return GenerateSqlForAllVendors
0483:             * @return GenerateSqlForAllVendors
0484:             * @throws LoaderException
0485:             */
0486:            public boolean getGenerateSqlForAllVendors() throws LoaderException {
0487:                return this .generatorParameters.getSqlForAllVendors();
0488:            }
0489:
0490:            /**
0491:             * This method set generateXml
0492:             * @param generateXml
0493:             * @throws LoaderException
0494:             */
0495:            public void setGenerateXml(boolean generateXml)
0496:                    throws LoaderException {
0497:                this .generatorParameters
0498:                        .setGenerateXml(new Boolean(generateXml).toString());
0499:            }
0500:
0501:            /**
0502:             * This method return generateXml
0503:             * @return boolean 
0504:             * @throws LoaderException
0505:             */
0506:            public boolean getGenerateXml() throws LoaderException {
0507:                String tempGenerateXml = this .generatorParameters
0508:                        .getGenerateXml();
0509:                return (new Boolean(tempGenerateXml)).booleanValue();
0510:
0511:            }
0512:
0513:            /**
0514:             * This method set generateDoml
0515:             * @param generateDoml
0516:             * @throws LoaderException
0517:             */
0518:            public void setGenerateDoml(boolean generateDoml)
0519:                    throws LoaderException {
0520:                this .generatorParameters.setGenerateDoml(new Boolean(
0521:                        generateDoml).toString());
0522:            }
0523:
0524:            /**
0525:             * This method return generateDoml
0526:             * @return boolean with value for generateDoml
0527:             * @throws LoaderException
0528:             */
0529:            public boolean getGenerateDoml() throws LoaderException {
0530:                String tempGenerateDoml = this .generatorParameters
0531:                        .getGenerateDoml();
0532:                return (new Boolean(tempGenerateDoml)).booleanValue();
0533:            }
0534:
0535:            /**
0536:             * This method return generateSQL
0537:             * @return bollean with value for generateSQL
0538:             * @throws LoaderException
0539:             */
0540:            public boolean getGenerateSQL() throws LoaderException {
0541:                boolean tempGenerateSQL = this .generatorParameters
0542:                        .isGenerateSql();
0543:                return tempGenerateSQL;
0544:            }
0545:
0546:            /**
0547:             * This method set fullMode
0548:             * @param fullMode
0549:             * @throws LoaderException
0550:             */
0551:            public void setFullMode(boolean fullMode) throws LoaderException {
0552:                this .generatorParameters.setFullMode(new Boolean(fullMode)
0553:                        .toString());
0554:            }
0555:
0556:            /**
0557:             * This method return fullMode
0558:             * @return boolean with value for fullMode
0559:             * @throws LoaderException
0560:             */
0561:            public boolean getFullMode() throws LoaderException {
0562:                return this .generatorParameters.getFullMode();
0563:            }
0564:
0565:            /**
0566:             * This method set includeTableList
0567:             * @param includeTableList
0568:             * @throws LoaderException
0569:             */
0570:            public void setIncludeTableList(String includeTableList)
0571:                    throws LoaderException {
0572:                this .generatorParameters.setIncludeTableList(includeTableList);
0573:            }
0574:
0575:            /**
0576:             * This method return includeTableList
0577:             * @return String which is list with included tables
0578:             * @throws LoaderException
0579:             */
0580:            public String getIncludeTableList() throws LoaderException {
0581:                Vector tmpIncludeTableList = this .generatorParameters
0582:                        .getIncludeTableList();
0583:                return tmpIncludeTableList.toString();
0584:            }
0585:
0586:            /**
0587:             * This method set confJarStructure
0588:             * @param confJarStructure
0589:             * @throws LoaderException
0590:             */
0591:            public void setConfJarStructure(String confJarStructure)
0592:                    throws LoaderException {
0593:                this .generatorParameters.setConfJarStructure(confJarStructure);
0594:            }
0595:
0596:            /**
0597:             * This method get confJarStructure
0598:             * @return ConfJarStructure
0599:             * @throws LoaderException
0600:             */
0601:            public String getConfJarStructure() throws LoaderException {
0602:                return this .generatorParameters.getConfJarStructure();
0603:            }
0604:
0605:            /**
0606:             * This method set restoreMode
0607:             * @param restoreMode
0608:             * @throws LoaderException
0609:             */
0610:            public void setRestoreMode(String restoreMode)
0611:                    throws LoaderException {
0612:                this .generatorParameters.setRestoreMode(restoreMode);
0613:            }
0614:
0615:            /**
0616:             * This method return restoreMode
0617:             * @return restoreMode
0618:             * @throws LoaderException
0619:             */
0620:            public String getRestoreMode() throws LoaderException {
0621:                return this .generatorParameters.getRestoreMode();
0622:            }
0623:
0624:            /**
0625:             * This method return logMode
0626:             * @return logMode
0627:             */
0628:            public String getLogMode() {
0629:                return logMode;
0630:            }
0631:
0632:            /**
0633:             * This method return strLogDirName
0634:             * @return strLogDirName
0635:             */
0636:            public String getStrLogDirName() {
0637:                return strLogDirName;
0638:            }
0639:
0640:            /**
0641:             * This method return strLogFileName
0642:             * @return strLogFileName
0643:             */
0644:            public String getStrLogFileName() {
0645:                return strLogFileName;
0646:            }
0647:
0648:            /**
0649:             * This method set logMode
0650:             * @param logMode
0651:             */
0652:            public void setLogMode(String logMode) {
0653:                this .logMode = logMode;
0654:            }
0655:
0656:            /**
0657:             * This method set strLogDirName
0658:             * @param strLogDirName
0659:             */
0660:            public void setStrLogDirName(String strLogDirName) {
0661:                this .strLogDirName = strLogDirName;
0662:            }
0663:
0664:            /**
0665:             * This method set strLogFileName
0666:             * @param strLogFileName
0667:             */
0668:            public void setStrLogFileName(String strLogFileName) {
0669:                this .strLogFileName = strLogFileName;
0670:            }
0671:
0672:            /**
0673:             * This method write values for all input parameters to System out
0674:             * @throws LoaderException
0675:             */
0676:            public String inputToString() throws LoaderException {
0677:                String resString = "";
0678:                try {
0679:
0680:                    resString = "Source type=" + getSourceType() + "\n"
0681:                            + "Source driver=" + getSourceDriverName() + "\n"
0682:                            + "Source URL=" + getSourceDataBase() + "\n"
0683:                            + "Source user=" + getSourceUser() + "\n"
0684:                            + "Source password=" + getSourcePassword() + "\n"
0685:                            + "Target type=" + getTargetType() + "\n"
0686:                            + "Target driver=" + getTargetDriverName() + "\n"
0687:                            + "Target URL=" + getTargetDataBase() + "\n"
0688:                            + "Target user=" + getTargetUser() + "\n"
0689:                            + "Target password=" + getTargetPassword() + "\n"
0690:                            + "Conf file in jar=" + getConfJarStructure()
0691:                            + "\n" + "Doml path=" + getDomlPath() + "\n"
0692:                            + "Ouput directory=" + getGeneratorOutput() + "\n"
0693:                            + "Include table list=" + getIncludeTableList()
0694:                            + "\n" + "Restore mode=" + getRestoreMode() + "\n"
0695:                            + "Value mode=" + getValueMode() + "\n"
0696:                            + "Generate create foreign keys ="
0697:                            + getGenerateCreateFKStmt() + "\n"
0698:                            + "Generate create indexes ="
0699:                            + getGenerateCreateIndexStmt() + "\n"
0700:                            + "Generate create primary keys ="
0701:                            + getGenerateCreatePKStmt() + "\n"
0702:                            + "Generate create tables ="
0703:                            + getGenerateCreateTableStmt() + "\n"
0704:                            + "Generate drop foreign keys ="
0705:                            + getGenerateDropIntegrityStmt() + "\n"
0706:                            + "Generate drop tables ="
0707:                            + getGenerateDropTableStmt() + "\n"
0708:                            + "Generate sql for all vendors ="
0709:                            + getGenerateSqlForAllVendors() + "\n"
0710:                            + "Generate doml =" + getGenerateDoml() + "\n"
0711:                            + "Package name=" + getPackageName() + "\n"
0712:                            + "Generate xml =" + getGenerateXml() + "\n"
0713:                            + "Full mode=" + getFullMode() + "\n" + "Log mode="
0714:                            + getLogMode() + "\n" + "Log directory name="
0715:                            + getStrLogDirName() + "\n" + "Log file name="
0716:                            + getStrLogFileName() + "\n";
0717:
0718:                    return resString;
0719:                } catch (Exception e) {
0720:                    throw new LoaderException("Exception:" + e.getMessage(), e);
0721:                }
0722:            }
0723:
0724:            /**
0725:             * Construct object LoaderGenerator with associated parameters.
0726:             * @param sourceType defines the type of the source data.
0727:             * @param targetType defines the type of the target data.
0728:             * @param sourceDriverName is driver of defined source database.
0729:             * @param targetDriverName is driver of defined  target database.
0730:             * @param sourceDataBase defines the place where you're put the database tables.
0731:             * @param targetDataBase defines the place where the target database tables are.
0732:             * @param valueMode defines the difference from overwrite and update attribute.
0733:             * Default valueMode is Overwrite.
0734:             * @param generatorOutput is optional. That represents the directory, where the
0735:             * Octopus place created files. If this argument don't exists, Octopus place
0736:             * created files in to current directory!
0737:             * @param sourceUser defines the user of the source database.
0738:             * @param sourcePassword defines user password for the source database.
0739:             * @param targetUser defines the user of the target database.
0740:             * @param targetPassword defines user password for the target database.
0741:             * @param domlPath defines if the doml file exists. Default value is false
0742:             * all, application generates xml, sql and doml files as ouput files. If the generateDoc has value
0743:             * doml, application generates only the doml file, and if generateDoc has the value wdoml, application
0744:             * generates xml and sql files.
0745:             * @param packageName defines the package name for the generated doml file.
0746:             * @param generateDropTableStmt defines if you want to generate only Sql statement for DROP TABLE
0747:             * @param generateCreateTableStmt defines if you want to generate only Sql statement for CREATE TABLE
0748:             * @param generateCreatePKStmt defines if you want to generate only Sql statement for ALTER TABLE
0749:             * @param generateCreateFKStmt defines if you want to generate only Sql statement for ALTER TABLE
0750:             * @param generateCreateIndexStmt defines if you want to generate only Sql statement for ALTER TABLE
0751:             * @param generateSqlForAllVendors defines if you want to generate Sql statements for all named
0752:             * database vendors
0753:             * @param generateXml defines if you want to generate xml file as output files
0754:             * @param generateDoml defines if you want to generate doml file as output file
0755:             * @param fullMode defines in which mode you want to generate xml files.
0756:             * @param includeTableList defines the list of tables which you want to include into
0757:             * Generator process
0758:             * @param confJarStructure defines the structure of jar file in which are conf
0759:             * files placed
0760:             * @throws LoaderException
0761:             */
0762:
0763:            public LoaderGenerator(String sourceType, String sourceDataBase,
0764:                    String valueMode, String generatorOutput,
0765:                    String sourceDriverName, String targetDriverName,
0766:                    String targetDataBase, String targetType,
0767:                    String sourceUser, String sourcePassword,
0768:                    String targetUser, String targetPassword, String domlPath,
0769:                    String packageName, String generateDropTableStmt,
0770:                    String generateDropIntegrityStmt,
0771:                    String generateCreateTableStmt,
0772:                    String generateCreatePKStmt, String generateCreateFKStmt,
0773:                    String generateCreateIndexStmt,
0774:                    String generateSqlForAllVendors, String generateXml,
0775:                    String generateDoml, String fullMode,
0776:                    String includeTableList, String confJarStructure)
0777:                    throws LoaderException {
0778:
0779:                this (sourceType, sourceDataBase, valueMode, generatorOutput,
0780:                        sourceDriverName, targetDriverName, targetDataBase,
0781:                        targetType, sourceUser, sourcePassword, targetUser,
0782:                        targetPassword, domlPath, packageName,
0783:                        generateDropTableStmt, generateDropIntegrityStmt,
0784:                        generateCreateTableStmt, generateCreatePKStmt,
0785:                        generateCreateFKStmt, generateCreateIndexStmt,
0786:                        generateSqlForAllVendors, generateXml, generateDoml,
0787:                        fullMode, "false", includeTableList, confJarStructure);
0788:
0789:            }
0790:
0791:            /**
0792:             * Construct object LoaderGenerator with associated parameters.
0793:             * @param sourceType defines the type of the source data.
0794:             * @param targetType defines the type of the target data.
0795:             * @param sourceDriverName is driver of defined source database.
0796:             * @param targetDriverName is driver of defined  target database.
0797:             * @param sourceDataBase defines the place where you're put the database tables.
0798:             * @param targetDataBase defines the place where the target database tables are.
0799:             * @param valueMode defines the difference from overwrite and update attribute.
0800:             * Default valueMode is Overwrite.
0801:             * @param generatorOutput is optional. That represents the directory, where the
0802:             * Octopus place created files. If this argument don't exists, Octopus place
0803:             * created files in to current directory!
0804:             * @param sourceUser defines the user of the source database.
0805:             * @param sourcePassword defines user password for the source database.
0806:             * @param targetUser defines the user of the target database.
0807:             * @param targetPassword defines user password for the target database.
0808:             * @param domlPath defines if the doml file exists. Default value is false
0809:             * all, application generates xml, sql and doml files as ouput files. If the generateDoc has value
0810:             * doml, application generates only the doml file, and if generateDoc has the value wdoml, application
0811:             * generates xml and sql files.
0812:             * @param packageName defines the package name for the generated doml file.
0813:             * @param generateDropTableStmt defines if you want to generate only Sql statement for DROP TABLE
0814:             * @param generateCreateTableStmt defines if you want to generate only Sql statement for CREATE TABLE
0815:             * @param generateCreatePKStmt defines if you want to generate only Sql statement for ALTER TABLE
0816:             * @param generateCreateFKStmt defines if you want to generate only Sql statement for ALTER TABLE
0817:             * @param generateCreateIndexStmt defines if you want to generate only Sql statement for ALTER TABLE
0818:             * @param generateSqlForAllVendors defines if you want to generate Sql statements for all named
0819:             * database vendors
0820:             * @param generateXml defines if you want to generate xml file as output files
0821:             * @param generateDoml defines if you want to generate doml file as output file
0822:             * @param fullMode defines in which mode you want to generate xml files.
0823:             * @param restoreMode defines if we use application for restoring the database
0824:             * @param includeTableList defines the list of tables which you want to include into
0825:             * Generator process
0826:             * @param confJarStructure defines the structure of jar file in which are conf files
0827:             * placed.
0828:             * @throws LoaderException
0829:             */
0830:
0831:            public LoaderGenerator(String sourceType, String sourceDataBase,
0832:                    String valueMode, String generatorOutput,
0833:                    String sourceDriverName, String targetDriverName,
0834:                    String targetDataBase, String targetType,
0835:                    String sourceUser, String sourcePassword,
0836:                    String targetUser, String targetPassword, String domlPath,
0837:                    String packageName, String generateDropTableStmt,
0838:                    String generateDropIntegrityStmt,
0839:                    String generateCreateTableStmt,
0840:                    String generateCreatePKStmt, String generateCreateFKStmt,
0841:                    String generateCreateIndexStmt,
0842:                    String generateSqlForAllVendors, String generateXml,
0843:                    String generateDoml, String fullMode, String restoreMode,
0844:                    String includeTableList, String confJarStructure)
0845:                    throws LoaderException {
0846:
0847:                generatorParameters = new InputParameters(confJarStructure);
0848:                generatorParameters.setConfJarStructure(confJarStructure);
0849:
0850:                generatorParameters.setSourceType(sourceType);
0851:                //target and source driver name must goes frist, because alterTablePrimaryKey...
0852:                generatorParameters.setTargetDriverName(targetDriverName);
0853:                generatorParameters.setSourceDriverName(sourceDriverName);
0854:                generatorParameters.setTargetType(targetType);
0855:                generatorParameters.setSourceDataBase(sourceDataBase);
0856:                generatorParameters.setTargetDataBase(targetDataBase);
0857:                generatorParameters.setValueMode(valueMode);
0858:                generatorParameters.setGeneratorOutput(generatorOutput);
0859:                generatorParameters.setSourceUser(sourceUser);
0860:                generatorParameters.setSourcePassword(sourcePassword);
0861:                generatorParameters.setTargetUser(targetUser);
0862:                generatorParameters.setTargetPassword(targetPassword);
0863:
0864:                if (generateDropTableStmt != null)
0865:                    generatorParameters
0866:                            .setSqlStmtDropTable(generateDropTableStmt);
0867:                if (generateDropIntegrityStmt != null)
0868:                    generatorParameters
0869:                            .setSqlStmtDropIntegrity(generateDropIntegrityStmt);
0870:                if (generateCreateTableStmt != null)
0871:                    generatorParameters
0872:                            .setSqlStmtCreateTable(generateCreateTableStmt);
0873:                if (generateCreatePKStmt != null)
0874:                    generatorParameters
0875:                            .setSqlStmtCreatePK(generateCreatePKStmt);
0876:                if (generateCreateFKStmt != null)
0877:                    generatorParameters
0878:                            .setSqlStmtCreateFK(generateCreateFKStmt);
0879:                if (generateCreateIndexStmt != null)
0880:                    generatorParameters
0881:                            .setSqlStmtCreateIndex(generateCreateIndexStmt);
0882:                if (generateSqlForAllVendors != null)
0883:                    generatorParameters.setAllVendors(generateSqlForAllVendors);
0884:
0885:                generatorParameters.setDomlPath(domlPath);
0886:                if (generateXml != null)
0887:                    generatorParameters.setGenerateXml(generateXml);
0888:                if (generateDoml != null)
0889:                    generatorParameters.setGenerateDoml(generateDoml);
0890:                generatorParameters.setPackageName(packageName);
0891:                if (fullMode != null)
0892:                    generatorParameters.setFullMode(fullMode);
0893:                if (restoreMode != null)
0894:                    generatorParameters.setRestoreMode(restoreMode);
0895:                if (includeTableList != null)
0896:                    generatorParameters.setIncludeTableList(includeTableList);
0897:
0898:                generatorParameters.setSourceDriverProperties();
0899:                generatorParameters.setTargetDriverProperties();
0900:                generatorParameters.setOidAndVersionColumnName();
0901:                generatorParameters.setHasSize();
0902:                generatorParameters.setIsDecimal();
0903:                //setLogger();
0904:
0905:            }
0906:
0907:            /**
0908:             * Construct object LoaderGenerator with associated parameters.
0909:             * @param sourceType defines the type of the source data.
0910:             * @param targetType defines the type of the target data.
0911:             * @param sourceDriverName is driver of defined source database.
0912:             * @param targetDriverName is driver of defined  target database.
0913:             * @param sourceDataBase defines the place where you're put the database tables.
0914:             * @param targetDataBase defines the place where the target database tables are.
0915:             * @param valueMode defines the difference from overwrite and update attribute.
0916:             * Default valueMode is Overwrite.
0917:             * @param generatorOutput is optional. That represents the directory, where the
0918:             * Octopus place created files. If this argument don't exists, Octopus place
0919:             * created files in to current directory!
0920:             * @param sourceUser defines the user of the source database.
0921:             * @param sourcePassword defines user password for the source database.
0922:             * @param targetUser defines the user of the target database.
0923:             * @param targetPassword defines user password for the target database.
0924:             * @param domlPath defines if the doml file exists. Default value is false
0925:             * all, application generates xml, sql and doml files as ouput files. If the generateDoc has value
0926:             * doml, application generates only the doml file, and if generateDoc has the value wdoml, application
0927:             * generates xml and sql files.
0928:             * @param packageName defines the package name for the generated doml file.
0929:             * @param generateDropTableStmt defines if you want to generate only Sql statement for DROP TABLE
0930:             * @param generateCreateTableStmt defines if you want to generate only Sql statement for CREATE TABLE
0931:             * @param generateCreatePKStmt defines if you want to generate only Sql statement for ALTER TABLE
0932:             * @param generateCreateFKStmt defines if you want to generate only Sql statement for ALTER TABLE
0933:             * @param generateCreateIndexStmt defines if you want to generate only Sql statement for ALTER TABLE
0934:             * @param generateSqlForAllVendors defines if you want to generate Sql statements for all named
0935:             * database vendors
0936:             * @param generateXml defines if you want to generate xml file as output files
0937:             * @param generateDoml defines if you want to generate doml file as output file
0938:             * @param fullMode defines in which mode you want to generate xml files.
0939:             * @param restoreMode defines if we use application for restoring the database
0940:             * @param includeTableList defines the list of tables which you want to include into
0941:             * Generator process
0942:             * @param confJarStructure defines the structure of jar file in which are conf files
0943:             * @param logMode defines logging level
0944:             * @param logDirName defines logging directory
0945:             * @param logFileName defines logging file name
0946:             * placed.
0947:             * @throws LoaderException
0948:             */
0949:
0950:            public LoaderGenerator(String sourceType, String sourceDataBase,
0951:                    String valueMode, String generatorOutput,
0952:                    String sourceDriverName, String targetDriverName,
0953:                    String targetDataBase, String targetType,
0954:                    String sourceUser, String sourcePassword,
0955:                    String targetUser, String targetPassword, String domlPath,
0956:                    String packageName, String generateDropTableStmt,
0957:                    String generateDropIntegrityStmt,
0958:                    String generateCreateTableStmt,
0959:                    String generateCreatePKStmt, String generateCreateFKStmt,
0960:                    String generateCreateIndexStmt,
0961:                    String generateSqlForAllVendors, String generateXml,
0962:                    String generateDoml, String fullMode, String restoreMode,
0963:                    String includeTableList, String confJarStructure,
0964:                    String logMode, String logDirName, String logFileName)
0965:                    throws LoaderException {
0966:
0967:                generatorParameters = new InputParameters(confJarStructure);
0968:                generatorParameters.setConfJarStructure(confJarStructure);
0969:
0970:                generatorParameters.setSourceType(sourceType);
0971:                //target and source driver name must goes frist, because alterTablePrimaryKey...
0972:                generatorParameters.setTargetDriverName(targetDriverName);
0973:                generatorParameters.setSourceDriverName(sourceDriverName);
0974:                generatorParameters.setTargetType(targetType);
0975:                generatorParameters.setSourceDataBase(sourceDataBase);
0976:                generatorParameters.setTargetDataBase(targetDataBase);
0977:                generatorParameters.setValueMode(valueMode);
0978:                generatorParameters.setGeneratorOutput(generatorOutput);
0979:                generatorParameters.setSourceUser(sourceUser);
0980:                generatorParameters.setSourcePassword(sourcePassword);
0981:                generatorParameters.setTargetUser(targetUser);
0982:                generatorParameters.setTargetPassword(targetPassword);
0983:
0984:                if (generateDropTableStmt != null)
0985:                    generatorParameters
0986:                            .setSqlStmtDropTable(generateDropTableStmt);
0987:                if (generateDropIntegrityStmt != null)
0988:                    generatorParameters
0989:                            .setSqlStmtDropIntegrity(generateDropIntegrityStmt);
0990:                if (generateCreateTableStmt != null)
0991:                    generatorParameters
0992:                            .setSqlStmtCreateTable(generateCreateTableStmt);
0993:                if (generateCreatePKStmt != null)
0994:                    generatorParameters
0995:                            .setSqlStmtCreatePK(generateCreatePKStmt);
0996:                if (generateCreateFKStmt != null)
0997:                    generatorParameters
0998:                            .setSqlStmtCreateFK(generateCreateFKStmt);
0999:                if (generateCreateIndexStmt != null)
1000:                    generatorParameters
1001:                            .setSqlStmtCreateIndex(generateCreateIndexStmt);
1002:                if (generateSqlForAllVendors != null)
1003:                    generatorParameters.setAllVendors(generateSqlForAllVendors);
1004:
1005:                generatorParameters.setDomlPath(domlPath);
1006:                if (generateXml != null)
1007:                    generatorParameters.setGenerateXml(generateXml);
1008:                if (generateDoml != null)
1009:                    generatorParameters.setGenerateDoml(generateDoml);
1010:                generatorParameters.setPackageName(packageName);
1011:                if (fullMode != null)
1012:                    generatorParameters.setFullMode(fullMode);
1013:                if (restoreMode != null)
1014:                    generatorParameters.setRestoreMode(restoreMode);
1015:                if (includeTableList != null)
1016:                    generatorParameters.setIncludeTableList(includeTableList);
1017:                if (logMode != null) {
1018:                    this .logMode = logMode;
1019:                }
1020:                if (logDirName != null) {
1021:                    this .strLogDirName = logDirName;
1022:                }
1023:                if (logFileName != null) {
1024:                    this .strLogFileName = logFileName;
1025:                }
1026:                generatorParameters.setSourceDriverProperties();
1027:                generatorParameters.setTargetDriverProperties();
1028:                generatorParameters.setOidAndVersionColumnName();
1029:                generatorParameters.setHasSize();
1030:                generatorParameters.setIsDecimal();
1031:
1032:            }
1033:
1034:            /**
1035:             * Public constructor of LoaderGenerator class. Constructor set value for sourceDataBase and
1036:             * targetDataBase attribute. Class set all other attributes to the default values.
1037:             * @param sourceDataBase defines the place where you're put the database tables.
1038:             * @param targetDataBase defines the place where the target database tables are.
1039:             * @param sourceType defines the type of the source database.
1040:             * @param targetType defines the type of the target database.
1041:             * @throws LoaderException
1042:             */
1043:            public LoaderGenerator(String sourceDataBase,
1044:                    String targetDataBase, String sourceType, String targetType)
1045:                    throws LoaderException {
1046:
1047:                this (sourceDataBase, targetDataBase, sourceType, targetType,
1048:                        null);
1049:
1050:            }
1051:
1052:            /**
1053:             * Public constructor of LoaderGenerator class. Constructor set value for sourceDataBase and
1054:             * targetDataBase attribute. Class set all other attributes to the default values.
1055:             * @param sourceDataBase defines the place where you're put the database tables.
1056:             * @param targetDataBase defines the place where the target database tables are.
1057:             * @param sourceType defines the type of the source database.
1058:             * @param targetType defines the type of the target database.
1059:             * @throws LoaderException
1060:             */
1061:            public LoaderGenerator(String sourceDataBase,
1062:                    String targetDataBase, String sourceType,
1063:                    String targetType, String confJarStructure)
1064:                    throws LoaderException {
1065:
1066:                generatorParameters = new InputParameters("");
1067:                generatorParameters.setConfJarStructure(confJarStructure);
1068:                generatorParameters.setSourceDataBase(sourceDataBase);
1069:
1070:                generatorParameters.setTargetDataBase(targetDataBase);
1071:                generatorParameters.setSourceType(sourceType);
1072:                generatorParameters.setTargetType(targetType);
1073:                generatorParameters.setSourceDriverProperties();
1074:                generatorParameters.setTargetDriverProperties();
1075:                generatorParameters.setOidAndVersionColumnName();
1076:                generatorParameters.setHasSize();
1077:                generatorParameters.setIsDecimal();
1078:                //setLogger();
1079:            }
1080:
1081:            /**
1082:             * Main method controls parameters, it they are OK starts load method, but if they aren't makes alert.
1083:             * @param args represents the input parameters
1084:             *
1085:             * Usage: java org.webdocwf.util.loader.generator.Generator [options]
1086:             * Options:
1087:             * -st sourceType, defines the type of the source database.
1088:             * -tt targetType, defines the type of the target database.
1089:             * -sdn sourceDriverName, defines the driver of defined source database.
1090:             * -tdn targetDriverName, defines the driver of defined  target database.
1091:             * -sdb sourceDataBase, defines the place where you're put the source database tables.
1092:             * -tdb targetDataBase, defines the place where you're put the target database tables.
1093:             * -m valueMode, defines the difference from overwrite and update attribute. If the valueMode
1094:             * has value 'copy', attribute has value 'Overwrite', or if the valueMode has value 'sync', attribute
1095:             * has value 'Update'. Default value of valueMode is 'copy'.
1096:             * -o generatorOutput, is optional. That represent the directory, where the Octopus place created files.
1097:             * If this argument don't exists, Octopus place created files in to current directory!
1098:             * -su sourceUser, defines the user of the source database.
1099:             * -sp sourcePassword, defines the user password for the source database.
1100:             * -tu targetUser, defines the user of the target database.
1101:             * -tp targetPassword, defines the user password for the target database.
1102:             * -doml domlUrl, defines the place where the doml file is placed.
1103:             * -pack packageName, defines the package name for the generated doml file.
1104:             * -xml -xml generateXml, defines if you want to generate xml files as output files
1105:             * -gdoml generateDoml, defines if you want to generate doml file as output file.
1106:             * -sqlCT generateCreateTables defines if you want to generate only Sql statement for CREATE TABLE.
1107:             * -sqlDT generateDropTableStmt defines if you want to generate only Sql statement for DROP TABLE.
1108:             * -sqlCPK generateCreatePrimaryKeys defines if you want to generate only Sql statement for ALTER TABLE ADD CONSTRAINT (PRIMARY KEY).
1109:             * -sqlCFK generateCreateForeigKeys defines if you want to generate only Sql statement for ALTER TABLE ADD CONSTRAINT (FOREIGN KEY).
1110:             * -sqlCI generateCreateIndex defines if you want to generate only Sql statement for CREATE INDEX.
1111:             * -sqlAll generateSqlForAllVendors defines if you want to generate sql statements for all named database vendors.
1112:             * -fm fullMode defines the mode of output xml files. Possible values are true and false.
1113:             * -lm logMode defines logging level
1114:             * -l logDirName defines logging directory
1115:             * -f logFileName defines logging file name
1116:             **/
1117:
1118:            public static void main(String args[]) {
1119:
1120:                String generatorOutput = null;
1121:                String valueMode = null;
1122:                String domlUrl = null;
1123:                String packageName = null;
1124:
1125:                String sourceType = null;
1126:                String sourceDataBase = null;
1127:                String sourceDriverName = null;
1128:                String sourceUser = null;
1129:                String sourcePassword = null;
1130:
1131:                String targetType = null;
1132:                String targetDataBase = null;
1133:                String targetDriverName = null;
1134:                String targetUser = null;
1135:                String targetPassword = null;
1136:
1137:                //logging
1138:                String logDirName = null;
1139:                String logFileName = null;
1140:                String logMode = null;
1141:
1142:                //Output mode
1143:                //main
1144:                String generateXml = null;
1145:                String generateDoml = null;
1146:                //for generate sql
1147:                String generateDropTableStmt = null;
1148:                String generateDropIntegrityStmt = null;
1149:                String generateCreateTableStmt = null;
1150:                String generateCreatePKStmt = null;
1151:                String generateCreateFKStmt = null;
1152:                String generateCreateIndexStmt = null;
1153:
1154:                //for genrate sql for all vendors
1155:                String generateSqlForAllVendors = null;
1156:                //optimized modes
1157:                String fullMode = null;
1158:                String restoreMode = null;
1159:                String includeTableList = null;
1160:                String confJarStructure = null;
1161:
1162:                if (args.length > 8 && args.length < 53) {
1163:                    for (int i = 0; i < args.length - 1; i = i + 1) {
1164:                        if (args[i].equalsIgnoreCase("-st"))
1165:                            sourceType = args[++i];
1166:                        else if (args[i].equalsIgnoreCase("-sdb"))
1167:                            sourceDataBase = args[++i];
1168:                        else if (args[i].equalsIgnoreCase("-m"))
1169:                            valueMode = args[++i];
1170:                        else if (args[i].equalsIgnoreCase("-o"))
1171:                            generatorOutput = args[++i];
1172:                        else if (args[i].equalsIgnoreCase("-sdn"))
1173:                            sourceDriverName = args[++i];
1174:                        else if (args[i].equalsIgnoreCase("-tdn"))
1175:                            targetDriverName = args[++i];
1176:                        else if (args[i].equalsIgnoreCase("-tdb"))
1177:                            targetDataBase = args[++i];
1178:                        if (args[i].equalsIgnoreCase("-tt"))
1179:                            targetType = args[++i];
1180:                        if (args[i].equalsIgnoreCase("-su"))
1181:                            sourceUser = args[++i];
1182:                        if (args[i].equalsIgnoreCase("-sp"))
1183:                            sourcePassword = args[++i];
1184:                        if (args[i].equalsIgnoreCase("-tu"))
1185:                            targetUser = args[++i];
1186:                        if (args[i].equalsIgnoreCase("-tp"))
1187:                            targetPassword = args[++i];
1188:                        if (args[i].equalsIgnoreCase("-doml"))
1189:                            domlUrl = args[++i];
1190:                        if (args[i].equalsIgnoreCase("-pack"))
1191:                            packageName = args[++i];
1192:                        if (args[i].equalsIgnoreCase("-xml"))
1193:                            generateXml = args[++i];
1194:                        if (args[i].equalsIgnoreCase("-gdoml"))
1195:                            generateDoml = args[++i];
1196:                        if (args[i].equalsIgnoreCase("-sqlCT"))
1197:                            generateCreateTableStmt = args[++i];
1198:                        if (args[i].equalsIgnoreCase("-sqlDT"))
1199:                            generateDropTableStmt = args[++i];
1200:                        if (args[i].equalsIgnoreCase("-sqlDI"))
1201:                            generateDropIntegrityStmt = args[++i];
1202:                        if (args[i].equalsIgnoreCase("-sqlCPK"))
1203:                            generateCreatePKStmt = args[++i];
1204:                        if (args[i].equalsIgnoreCase("-sqlCFK"))
1205:                            generateCreateFKStmt = args[++i];
1206:                        if (args[i].equalsIgnoreCase("-sqlCI"))
1207:                            generateCreateIndexStmt = args[++i];
1208:                        if (args[i].equalsIgnoreCase("-sqlAll"))
1209:                            generateSqlForAllVendors = args[++i];
1210:                        if (args[i].equalsIgnoreCase("-fm"))
1211:                            fullMode = args[++i];
1212:                        if (args[i].equalsIgnoreCase("-rm"))
1213:                            restoreMode = args[++i];
1214:                        if (args[i].equalsIgnoreCase("-it"))
1215:                            includeTableList = args[++i];
1216:                        if (args[i].equalsIgnoreCase("-cjs"))
1217:                            confJarStructure = args[++i];
1218:                        if (args[i].equalsIgnoreCase("-lm"))
1219:                            logMode = args[++i];
1220:                        else if (args[i].equalsIgnoreCase("-l"))
1221:                            logDirName = args[++i];
1222:                        else if (args[i].equalsIgnoreCase("-f"))
1223:                            logFileName = args[++i];
1224:                    }
1225:                } else {
1226:                    System.out
1227:                            .println("You didn't enter all required parameters, for running the application!");
1228:                    BufferOctopusClass
1229:                            .getInstance()
1230:                            .writeToBuffer(
1231:                                    "You didn't enter all required parameters, for running the application!");
1232:                    printUsage();
1233:                    System.exit(1);
1234:                }
1235:                try {
1236:
1237:                    LoaderGenerator generator = new LoaderGenerator(sourceType,
1238:                            sourceDataBase, valueMode, generatorOutput,
1239:                            sourceDriverName, targetDriverName, targetDataBase,
1240:                            targetType, sourceUser, sourcePassword, targetUser,
1241:                            targetPassword, domlUrl, packageName,
1242:                            generateDropTableStmt, generateDropIntegrityStmt,
1243:                            generateCreateTableStmt, generateCreatePKStmt,
1244:                            generateCreateFKStmt, generateCreateIndexStmt,
1245:                            generateSqlForAllVendors, generateXml,
1246:                            generateDoml, fullMode, restoreMode,
1247:                            includeTableList, confJarStructure, logMode,
1248:                            logDirName, logFileName);
1249:
1250:                    generator.generate();
1251:                    System.exit(0);
1252:
1253:                } catch (LoaderException le) {
1254:                    System.out.println(le.getStackTraceAsString());
1255:                    BufferOctopusClass.getInstance().writeToBuffer(
1256:                            le.getStackTraceAsString());
1257:                    return;
1258:                } catch (Throwable th) {
1259:                    BufferOctopusClass.getInstance().writeToBuffer(
1260:                            th.getMessage());
1261:                    th.printStackTrace(System.out);
1262:                    return;
1263:                }
1264:            }
1265:
1266:            static void printUsage() {
1267:                //System.out.println("Usage: java org.webdocwf.util.loader.generator.Generator [options] ");
1268:                BufferOctopusClass
1269:                        .getInstance()
1270:                        .writeToBuffer(
1271:                                "Usage: java org.webdocwf.util.loader.generator.Generator [options] ");
1272:                //System.out.println(" Options:");
1273:                BufferOctopusClass.getInstance().writeToBuffer(" Options:");
1274:                //System.out.println(" -st sourceType, defines the type of the source database.");
1275:                BufferOctopusClass
1276:                        .getInstance()
1277:                        .writeToBuffer(
1278:                                " -st sourceType, defines the type of the source database.");
1279:                //System.out.println(" -tt targetType, defines the type of the target database.");
1280:                BufferOctopusClass
1281:                        .getInstance()
1282:                        .writeToBuffer(
1283:                                " -tt targetType, defines the type of the target database.");
1284:                //System.out.println(" -sdn sourceDriverName, represents driver of defined source database.");
1285:                BufferOctopusClass
1286:                        .getInstance()
1287:                        .writeToBuffer(
1288:                                " -sdn sourceDriverName, represents driver of defined source database.");
1289:                //    System.out.println(" -tdn targetDriverName, represents driver of defined target database.");
1290:                BufferOctopusClass
1291:                        .getInstance()
1292:                        .writeToBuffer(
1293:                                " -tdn targetDriverName, represents driver of defined target database.");
1294:                //    System.out.println(" -sdb sourceDatabase, defines the place where you're put the database tables");
1295:                BufferOctopusClass
1296:                        .getInstance()
1297:                        .writeToBuffer(
1298:                                " -sdb sourceDatabase, defines the place where you're put the database tables");
1299:                //    System.out.println(" -tdb targetDataBase defines the place where the target database tables are.");
1300:                BufferOctopusClass
1301:                        .getInstance()
1302:                        .writeToBuffer(
1303:                                " -tdb targetDataBase defines the place where the target database tables are.");
1304:                //    System.out.println(" -m valueMode, is the difference from overwrite and update attribute");
1305:                BufferOctopusClass
1306:                        .getInstance()
1307:                        .writeToBuffer(
1308:                                " -m valueMode, is the difference from overwrite and update attribute");
1309:                //    System.out.println(" -su sourceUser, defines the user of the source database.");
1310:                BufferOctopusClass
1311:                        .getInstance()
1312:                        .writeToBuffer(
1313:                                " -su sourceUser, defines the user of the source database.");
1314:                //    System.out.println(" -sp sourcePassword, defines user password for the source database.");
1315:                BufferOctopusClass
1316:                        .getInstance()
1317:                        .writeToBuffer(
1318:                                " -sp sourcePassword, defines user password for the source database.");
1319:                //    System.out.println(" -tu targetUser, defines the user of the target database.");
1320:                BufferOctopusClass
1321:                        .getInstance()
1322:                        .writeToBuffer(
1323:                                " -tu targetUser, defines the user of the target database.");
1324:                //    System.out.println(" -tp targetPassword, defines user password for the target database.");
1325:                BufferOctopusClass
1326:                        .getInstance()
1327:                        .writeToBuffer(
1328:                                " -tp targetPassword, defines user password for the target database.");
1329:                //    System.out.println(" -doml domlUrl, defines the place where the doml file is placed.");
1330:                BufferOctopusClass
1331:                        .getInstance()
1332:                        .writeToBuffer(
1333:                                " -doml domlUrl, defines the place where the doml file is placed.");
1334:                //    System.out.println(" -o generatorOutput, is optional. That represent the directory, where the Together Data Transformer place"+
1335:                //                       " created files. If this argument dont exists, Together Data Transformer place created files in to current direcory!");
1336:                BufferOctopusClass
1337:                        .getInstance()
1338:                        .writeToBuffer(
1339:                                " -o generatorOutput, is optional. That represent the directory, where the Together Data Transformer place"
1340:                                        + " created files. If this argument dont exists, Together Data Transformer place created files in to current direcory!");
1341:                //    System.out.println(" -pack packageName, defines the package name for the generated doml file.");
1342:                BufferOctopusClass
1343:                        .getInstance()
1344:                        .writeToBuffer(
1345:                                " -pack packageName, defines the package name for the generated doml file.");
1346:
1347:                //    System.out.println(" -xml generateXml, defines if you want to generate xml files as output files. "+
1348:                //                  "    Possible values are true and false.");
1349:                BufferOctopusClass
1350:                        .getInstance()
1351:                        .writeToBuffer(
1352:                                " -xml generateXml, defines if you want to generate xml files as output files. "
1353:                                        + "    Possible values are true and false.");
1354:                //    System.out.println(" -gdoml generateDoml, defines if you want to generate doml file as output file. "+
1355:                //                      "    Possible values are true and false.");
1356:                BufferOctopusClass
1357:                        .getInstance()
1358:                        .writeToBuffer(
1359:                                " -gdoml generateDoml, defines if you want to generate doml file as output file. "
1360:                                        + "    Possible values are true and false.");
1361:                //    System.out.println(" -sqlCT generateCreateTables, defines if you want to generate only Sql statement for CREATE TABLE.");
1362:                BufferOctopusClass
1363:                        .getInstance()
1364:                        .writeToBuffer(
1365:                                " -sqlCT generateCreateTables, defines if you want to generate only Sql statement for CREATE TABLE.");
1366:
1367:                //    System.out.println(" -sqlDT generateDropTableStmt, defines if you want to generate only Sql statement for DROP TABLE.");
1368:                BufferOctopusClass
1369:                        .getInstance()
1370:                        .writeToBuffer(
1371:                                " -sqlDT generateDropTableStmt, defines if you want to generate only Sql statement for DROP TABLE.");
1372:
1373:                //    System.out.println(" -sqlCPK generateCreatePrimaryKeys, defines if you want to generate only Sql statement for ALTER TABLE ADD CONSTRAINT (PRIMARY KEY).");
1374:                BufferOctopusClass
1375:                        .getInstance()
1376:                        .writeToBuffer(
1377:                                " -sqlCPK generateCreatePrimaryKeys, defines if you want to generate only Sql statement for ALTER TABLE ADD CONSTRAINT (PRIMARY KEY).");
1378:
1379:                //    System.out.println(" -sqlCFK generateCreateForeigKeys, defines if you want to generate only Sql statement for ALTER TABLE ADD CONSTRAINT (FOREIGN KEY).");
1380:                BufferOctopusClass
1381:                        .getInstance()
1382:                        .writeToBuffer(
1383:                                " -sqlCFK generateCreateForeigKeys, defines if you want to generate only Sql statement for ALTER TABLE ADD CONSTRAINT (FOREIGN KEY).");
1384:
1385:                //    System.out.println(" -sqlCI generateCreateIndex, defines if you want to generate only Sql statement for CREATE INDEX.");
1386:                BufferOctopusClass
1387:                        .getInstance()
1388:                        .writeToBuffer(
1389:                                " -sqlCI generateCreateIndex, defines if you want to generate only Sql statement for CREATE INDEX.");
1390:
1391:                //    System.out.println(" -sqlAll generateSqlForAllVendors, defines if you want to generate sql statements for all named database vendors.");
1392:                BufferOctopusClass
1393:                        .getInstance()
1394:                        .writeToBuffer(
1395:                                " -sqlAll generateSqlForAllVendors, defines if you want to generate sql statements for all named database vendors.");
1396:
1397:                //    System.out.println(" -fm fullMode, defines the mode of output xml files. Possible values are true and false.");
1398:                BufferOctopusClass
1399:                        .getInstance()
1400:                        .writeToBuffer(
1401:                                "  -fm fullMode, defines the mode of output xml files. Possible values are true and false.");
1402:
1403:                //    System.out.println(" -it includeTableList, defines tables which you want to incude into Generator process.");
1404:                BufferOctopusClass
1405:                        .getInstance()
1406:                        .writeToBuffer(
1407:                                "  -it includeTableList, defines tables which you want to incude into Generator process.");
1408:
1409:                //    System.out.println("For more details, see documentation.");
1410:                BufferOctopusClass.getInstance().writeToBuffer(
1411:                        "For more details, see documentation.");
1412:                //System.out.println(" -lm defines the default logmode. Possible values are 'none', 'normal' (is the default) and 'full'.");
1413:                BufferOctopusClass
1414:                        .getInstance()
1415:                        .writeToBuffer(
1416:                                " -lm defines the default logmode. Possible values are 'none', 'normal' (is the default) and 'full'.");
1417:
1418:                //System.out.println(" -l defines the logfile directory. The default is the current working directory.   \n");
1419:                BufferOctopusClass.getInstance().writeToBuffer(
1420:                        " -v defines variables used in variable columns.  \n");
1421:
1422:                //System.out.println(" -f defines the logfile name. The default is 'GeneratorLog-YYYY-MM-DD-HH-mm-SS.txt'. \n");
1423:                BufferOctopusClass
1424:                        .getInstance()
1425:                        .writeToBuffer(
1426:                                " -f defines the logfile name. The default is 'GeneratorLog-YYYY-MM-DD-HH-mm-SS.txt'. \n");
1427:
1428:            }
1429:
1430:            /**
1431:             * This method init logger
1432:             * @throws LoaderException
1433:             */
1434:            private void setLogger() throws LoaderException {
1435:
1436:                this .timeCounter = new TimeWatch();
1437:                this .timeCounter.setStartJobTime();
1438:
1439:                try {
1440:
1441:                    this .logger = new StandardLogger();
1442:                    this .strLoggerParam = this .strLogDirName + ";"
1443:                            + this .strLogFileName;
1444:                    this .standardLogger = true;
1445:                    this .logger.configure(strLoggerParam);
1446:                    this .logger.setEnabledLogLevels(this .logMode);
1447:                } catch (Exception e) {
1448:
1449:                    LoaderException le = new LoaderException(
1450:                            "Error while instantiate StandardLogger!", e);
1451:                    throw le;
1452:                }
1453:            }
1454:
1455:            /**
1456:             *
1457:             * Method generate is main method in class LoaderGenerator. It is used to load data from the source
1458:             * table, and starts LoadJobWriter,CreateIncludeFiles and CreateIncludeDomlFiles methods.
1459:             * @throws LoaderException
1460:             */
1461:            public void generate() throws LoaderException {
1462:
1463:                try {
1464:                    LoadJobWriter loadJobWriter;
1465:                    GenerateSqlForAllVendors generateSqlForAllVendors;
1466:                    //Zk added for logging
1467:                    this .setLogger();
1468:
1469:                    if (standardLogger == true) {
1470:                        this .logger.write("normal",
1471:                                "Default (Standard) Logger is load.");
1472:                        this .logger
1473:                                .write("normal", "OctopusGenerator started.");
1474:                    }
1475:                    if (generatorParameters.getSqlForAllVendors() == true) {
1476:
1477:                        generateSqlForAllVendors = new GenerateSqlForAllVendors(
1478:                                generatorParameters);
1479:
1480:                    } else {
1481:                        if (generatorParameters.getDomlPath() == null
1482:                                || generatorParameters.getDomlPath()
1483:                                        .equalsIgnoreCase("")) {
1484:                            CreateIncludeFiles createIncludeFiles = new CreateIncludeFiles(
1485:                                    generatorParameters);
1486:                        } else {
1487:                            CreateIncludeDomlFiles createIncludeDomlFiles;
1488:                            createIncludeDomlFiles = new CreateIncludeDomlFiles(
1489:                                    generatorParameters);
1490:                        }
1491:                        if (generatorParameters.getGenerateXml()
1492:                                .equalsIgnoreCase("true"))
1493:                            loadJobWriter = new LoadJobWriter(
1494:                                    generatorParameters);
1495:                    }
1496:                    if (this .standardLogger == true) {
1497:                        this .logger.write("normal", "Duration: "
1498:                                + this .timeCounter.getTotalTime());
1499:                        this .logger.write("normal",
1500:                                "OctopusGenerator finished.");
1501:                    }
1502:                } catch (Exception e) {
1503:                    String msg = "Exception in method generate() in LoaderGenerator class!";
1504:                    LoaderException le = new LoaderException(msg + "\n"
1505:                            + e.getMessage(), (Throwable) e);
1506:                    if (standardLogger == true) {
1507:                        this .logger.write("full",
1508:                                "Exception in method generate() in LoaderGenerator class!"
1509:                                        + "\n" + le.getStackTraceAsString());
1510:                    }
1511:                    throw le;
1512:
1513:                }
1514:
1515:            }
1516:
1517:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.