Source Code Cross Referenced for InputParameters.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:            Copyright (C) 2003  Together
0004:            This library is free software; you can redistribute it and/or
0005:            modify it under the terms of the GNU Lesser General Public
0006:            License as published by the Free Software Foundation; either
0007:            version 2.1 of the License, or (at your option) any later version.
0008:            This library is distributed in the hope that it will be useful,
0009:            but WITHOUT ANY WARRANTY; without even the implied warranty of
0010:            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0011:            Lesser General Public License for more details.
0012:            You should have received a copy of the GNU Lesser General Public
0013:            License along with this library; if not, write to the Free Software
0014:            Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
0015:         */
0016:
0017:        package org.webdocwf.util.loader.generator;
0018:
0019:        import java.io.File;
0020:        import java.util.Hashtable;
0021:        import java.util.StringTokenizer;
0022:        import java.util.Vector;
0023:
0024:        import org.webdocwf.util.loader.LoaderException;
0025:        import org.webdocwf.util.loader.logging.Logger;
0026:        import org.webdocwf.util.loader.logging.StandardLogger;
0027:
0028:        /**
0029:         * InputParameters class sets the input parameters.
0030:         * @author Radoslav Dutina
0031:         * @version 1.0
0032:         */
0033:        public class InputParameters {
0034:
0035:            private String sourceType = "msql";
0036:            private String targetType = "msql";
0037:            private String sourceDataBase = null;
0038:            private String targetDataBase = null;
0039:
0040:            private String valueMode = "Overwrite";
0041:            private String generatorOutput = "";
0042:            private String sourceUser = "";
0043:            private String sourcePassword = "";
0044:            private String targetUser = "";
0045:            private String targetPassword = "";
0046:            private String sourceDriverName = "";
0047:            private String targetDriverName = "";
0048:            private String domlPath = "";
0049:
0050:            private String packageName = null;
0051:
0052:            private String alterTablePrimaryKey = null;
0053:            private String pathToSourceConf = null;
0054:            private String pathToTargetConf = null;
0055:
0056:            //  private String path="conf/OctopusDBVendors.xml";
0057:            private String path = "OctopusDBVendors.xml";
0058:            private SearchXmlFile searchXmlFile = null;
0059:
0060:            //sql statements only
0061:            private Vector sqlToGenerate = new Vector();
0062:            private boolean generateSomeSql = false;
0063:            private boolean generateSqlForAllVendors = false;
0064:
0065:            private Vector allVendors = new Vector();
0066:            private String generateXml = "false";
0067:            private String generateDoml = "false";
0068:            private String restoreMode = "false";
0069:
0070:            //optimized modes
0071:            private boolean fullMode = true;
0072:            private String[] excludedTables = null;
0073:
0074:            private Vector includeTableList = new Vector();
0075:
0076:            private String confJarStructure = "";
0077:
0078:            //oid and version columns
0079:            private String oidColumnName = "oid";
0080:            private String versionColumnName = "version";
0081:            private String oidColumnType = "decimal";
0082:            private String versionColumnType = "bigint";
0083:
0084:            private String maxConstraintLength = "";
0085:
0086:            //ZK added for new attribute hasSize
0087:            private Hashtable htHasSize = new Hashtable();
0088:            private Hashtable htIsDecimal = new Hashtable();
0089:            private Logger logger;
0090:
0091:            //ZK end 
0092:
0093:            /**
0094:             * Set hasSize values for db vendor 
0095:             */
0096:
0097:            public void setHasSize() throws LoaderException {
0098:                try {
0099:                    setLogger();
0100:                    //            if (this.logger != null) {
0101:                    //                this.logger.write("full", "\tsetHasSize is started.");
0102:                    //            }
0103:                    SearchXmlFile searchXmlFile = new SearchXmlFile("absolute",
0104:                            getPathToSourceConf(), getConfJarStructure());
0105:                    this .htHasSize = searchXmlFile.getHasSize();
0106:                    //            if (this.logger != null) {
0107:                    //                this.logger.write("full", "\tsetHasSize is finished.");
0108:                    //            }
0109:
0110:                } catch (Exception ex) {
0111:
0112:                    LoaderException le = new LoaderException("Exception:"
0113:                            + ex.getMessage(), ex);
0114:                    if (this .logger != null) {
0115:                        this .logger.write("full", "Exception:"
0116:                                + le.getStackTraceAsString());
0117:                    }
0118:                    throw le;
0119:                }
0120:            }
0121:
0122:            /**
0123:             * Return boolean if size for this type must be defined by user or not
0124:             * @param sqlType
0125:             * @return String which represents is this type has size or not
0126:             * @throws LoaderException
0127:             */
0128:            public String getHasSize(String sqlType) throws LoaderException {
0129:                try {
0130:                    setLogger();
0131:                    // this.logger.write("full", "\tgetHasSize is started.");
0132:                    if (htHasSize.containsKey((sqlType).toUpperCase())) {
0133:                        //                if (this.logger != null) {
0134:                        //                    this.logger.write("full", "\tgetHasSize is finished.");
0135:                        //                }
0136:                        return this .htHasSize.get((sqlType).toUpperCase())
0137:                                .toString();
0138:                    } else {
0139:                        //                if (this.logger != null) {
0140:                        //                    this.logger.write("full", "\tgetHasSize is finished.");
0141:                        //                }
0142:                        return "false";
0143:                    }
0144:
0145:                } catch (Exception e) {
0146:
0147:                    LoaderException le = new LoaderException("Exception:",
0148:                            (Throwable) e);
0149:                    if (this .logger != null) {
0150:                        this .logger.write("full", "Exception:"
0151:                                + le.getStackTraceAsString());
0152:                    }
0153:                    throw le;
0154:                }
0155:
0156:            }
0157:
0158:            /**
0159:             * Set decimal types for this DB vendor
0160:             * @throws LoaderException
0161:             */
0162:            public void setIsDecimal() throws LoaderException {
0163:                try {
0164:                    setLogger();
0165:                    //            if (this.logger != null) {
0166:                    //                this.logger.write("full", "\tsetIsDecimal is started.");
0167:                    //            }
0168:                    SearchXmlFile searchXmlFile = new SearchXmlFile("absolute",
0169:                            getPathToSourceConf(), getConfJarStructure());
0170:                    this .htIsDecimal = searchXmlFile.getIsDecimal();
0171:
0172:                } catch (Exception ex) {
0173:
0174:                    LoaderException le = new LoaderException("Exception"
0175:                            + ex.getMessage(), ex);
0176:                    if (this .logger != null) {
0177:                        this .logger.write("full", "Exception:"
0178:                                + le.getStackTraceAsString());
0179:                    }
0180:                    throw le;
0181:                }
0182:                //        if (this.logger != null) {
0183:                //            this.logger.write("full", "\tsetIsDecimal is finished.");
0184:                //        }
0185:            }
0186:
0187:            /**
0188:             * Return boolean if this string represents decimal type or not
0189:             * @param sqlType
0190:             * @return String which represents is this number decimal or not
0191:             * @throws LoaderException
0192:             */
0193:            public String getIsDecimal(String sqlType) throws LoaderException {
0194:                try {
0195:                    setLogger();
0196:                    //            if (this.logger != null) {
0197:                    //                this.logger.write("full", "\tgetIsDecimal is started.");
0198:                    //            }
0199:                    if (htIsDecimal.containsKey((sqlType).toUpperCase())) {
0200:                        //this.logger.write("full", "\tgetIsDecimal is finished.");
0201:                        return this .htIsDecimal.get((sqlType).toUpperCase())
0202:                                .toString();
0203:                    } else {
0204:                        //                if (this.logger != null) {
0205:                        //                    this.logger.write("full", "\tgetIsDecimal is finished.");
0206:                        //                }
0207:                        return "false";
0208:                    }
0209:                } catch (Exception e) {
0210:                    LoaderException le = new LoaderException("Exception:"
0211:                            + e.getMessage(), e);
0212:                    if (this .logger != null) {
0213:                        this .logger.write("full", "Exception:"
0214:                                + le.getStackTraceAsString());
0215:                    }
0216:                    throw le;
0217:                }
0218:
0219:            }
0220:
0221:            public void setOidAndVersionColumnName() throws LoaderException {
0222:
0223:                try {
0224:                    setLogger();
0225:                    //            if (this.logger != null) {
0226:                    //                this.logger.write("full", "\tsetOidAndVersionColumnName is started.");
0227:                    //            }
0228:                    SearchXmlFile searchXmlFile = new SearchXmlFile("absolute",
0229:                            getPathToTargetConf(), getConfJarStructure());
0230:
0231:                    this .oidColumnName = searchXmlFile.getOidDbColumn();
0232:                    this .versionColumnName = searchXmlFile.getVersionDbColumn();
0233:                    this .oidColumnType = searchXmlFile.getOidDB();
0234:                    this .versionColumnType = searchXmlFile.getVersionDb();
0235:
0236:                } catch (Exception ex) {
0237:                    LoaderException le = new LoaderException("Exception:"
0238:                            + ex.getMessage(), ex);
0239:                    if (this .logger != null) {
0240:                        this .logger.write("full", "Exception:"
0241:                                + le.getStackTraceAsString());
0242:                    }
0243:                    throw le;
0244:                }
0245:                //        if (this.logger != null) {
0246:                //            this.logger.write("full", "\tsetOidAndVersionColumnName is finished.");
0247:                //        }
0248:            }
0249:
0250:            public String getOidColumnName() {
0251:                return this .oidColumnName;
0252:            }
0253:
0254:            public String getVersionColumnName() {
0255:                return this .versionColumnName;
0256:            }
0257:
0258:            public String getOidColumnType() {
0259:                return this .oidColumnType;
0260:            }
0261:
0262:            public String getVersionColumnType() {
0263:                return this .versionColumnType;
0264:            }
0265:
0266:            /**
0267:             * This method set value of includeTableList parameter
0268:             * @param include_table_list is value of parameter
0269:             * @throws LoaderException
0270:             */
0271:            public void setIncludeTableList(String include_table_list)
0272:                    throws LoaderException {
0273:                setLogger();
0274:                //        if (this.logger != null) {
0275:                //            this.logger.write("full", "\tsetIncludeTableList is started.");
0276:                //        }
0277:                if (include_table_list.indexOf(",") != -1) {
0278:                    String msg = "\tDelimiter for tables in 'Include Table List' parameter is ';' and not ','";
0279:                    LoaderException le = new LoaderException("Exception:",
0280:                            new Exception(msg + "\n"));
0281:                    if (this .logger != null) {
0282:                        this .logger
0283:                                .write(
0284:                                        "full",
0285:                                        "Exception:"
0286:                                                + "\tDelimiter for tables in 'Include Table List' parameter is ';' and not ','"
0287:                                                + le.getStackTraceAsString());
0288:                    }
0289:                    throw le;
0290:                }
0291:
0292:                StringTokenizer st = new StringTokenizer(include_table_list,
0293:                        ";");
0294:                while (st.hasMoreTokens()) {
0295:                    String tableName = st.nextElement().toString();
0296:                    if (tableName.length() > 0)
0297:                        this .includeTableList.add(tableName);
0298:                }
0299:                //        if (this.logger != null) {
0300:                //            this.logger.write("full", "\tsetIncludeTableList is finished.");
0301:                //        }
0302:            }
0303:
0304:            /**
0305:             * This method read value from includeTableList parameter
0306:             * @return value of parameter
0307:             */
0308:            public Vector getIncludeTableList() {
0309:                return this .includeTableList;
0310:            }
0311:
0312:            /**
0313:             * This method set value of restroreMode parameter
0314:             * @param restoreMode is value of parameter
0315:             */
0316:            public void setRestoreMode(String restoreMode) {
0317:                this .restoreMode = restoreMode;
0318:            }
0319:
0320:            /**
0321:             * This method read value from restoreMode parameter
0322:             * @return value of parameter
0323:             */
0324:            public String getRestoreMode() {
0325:                return this .restoreMode;
0326:            }
0327:
0328:            /**
0329:             * This method set value of fullMode parameter
0330:             * @param full_mode is value of parameter
0331:             */
0332:            public void setFullMode(String full_mode) {
0333:                if (full_mode.equalsIgnoreCase("true"))
0334:                    fullMode = true;
0335:                else
0336:                    fullMode = false;
0337:            }
0338:
0339:            /**
0340:             * This method read value of fullMode parameter
0341:             * @return value of parameter
0342:             */
0343:            public boolean getFullMode() {
0344:                return fullMode;
0345:            }
0346:
0347:            /**
0348:             * This method set value of generateXml parameter
0349:             * @param generate_Xml is value of parameter
0350:             */
0351:            public void setGenerateXml(String generate_Xml) {
0352:                this .generateXml = generate_Xml;
0353:            }
0354:
0355:            /**
0356:             * This method read value of generateXml parameter
0357:             * @return value of parameter
0358:             */
0359:            public String getGenerateXml() {
0360:                return this .generateXml;
0361:            }
0362:
0363:            /**
0364:             * This method read value of  generateDoml parameter
0365:             * @return value of parameter
0366:             */
0367:            public String getGenerateDoml() {
0368:                return this .generateDoml;
0369:            }
0370:
0371:            /**
0372:             * This method set value of generateDoml parameter
0373:             * @param generate_Doml is value of parameter
0374:             */
0375:            public void setGenerateDoml(String generate_Doml) {
0376:                this .generateDoml = generate_Doml;
0377:            }
0378:
0379:            /**
0380:             * This method read value from generateSqlForAllVendors parameter
0381:             * @return value of parameter
0382:             */
0383:            public boolean getSqlForAllVendors() {
0384:                return generateSqlForAllVendors;
0385:            }
0386:
0387:            /**
0388:             * This method set the value of allVendors parameter
0389:             * @param generate is value of parameter
0390:             */
0391:            public void setAllVendors(String generate) {
0392:                if (generate.equalsIgnoreCase("true")) {
0393:                    generateSqlForAllVendors = true;
0394:                    allVendors = searchXmlFile.getAllVendors();
0395:                }
0396:            }
0397:
0398:            /**
0399:             * This method read value from allVendors parameter
0400:             * @return value of parameter
0401:             */
0402:            public Vector getAllVendors() {
0403:                return allVendors;
0404:            }
0405:
0406:            /**
0407:             * This method read value form generateSqlOnly parameter
0408:             * @return value of parameter
0409:             */
0410:            public boolean isGenerateSql() {
0411:                return generateSomeSql;
0412:            }
0413:
0414:            private void setDefaultSqlStmt() {
0415:                sqlToGenerate.add(0, null);
0416:                sqlToGenerate.add(1, null);
0417:                sqlToGenerate.add(2, null);
0418:                sqlToGenerate.add(3, null);
0419:                sqlToGenerate.add(4, null);
0420:                sqlToGenerate.add(5, null);
0421:            }
0422:
0423:            /**
0424:             * This method sets the value of sqlToGenerate parameter.
0425:             * @param generate_DropTableStmt is value of parameter
0426:             */
0427:            public void setSqlStmtDropTable(String generate_DropTableStmt) {
0428:
0429:                if (generate_DropTableStmt.equalsIgnoreCase("true")) {
0430:                    generateSomeSql = true;
0431:                    sqlToGenerate.setElementAt("DropTables", 1);
0432:                }
0433:            }
0434:
0435:            /**
0436:             * This method sets the value of sqlToGenerate parameter.
0437:             * @param generate_DropIntegrityStmt is value of parameter
0438:             */
0439:            public void setSqlStmtDropIntegrity(
0440:                    String generate_DropIntegrityStmt) {
0441:                if (generate_DropIntegrityStmt.equalsIgnoreCase("true")) {
0442:                    generateSomeSql = true;
0443:                    sqlToGenerate.setElementAt("DropIntegrity", 0);
0444:                }
0445:            }
0446:
0447:            /**
0448:             * This method sets the value of sqlToGenerate parameter.
0449:             * @param generate_CreateTableStmt is value of parameter
0450:             */
0451:            public void setSqlStmtCreateTable(String generate_CreateTableStmt) {
0452:                if (generate_CreateTableStmt.equalsIgnoreCase("true")) {
0453:                    generateSomeSql = true;
0454:                    sqlToGenerate.setElementAt("CreateTables", 2);
0455:                }
0456:            }
0457:
0458:            /**
0459:             * This method sets the value of sqlToGenerate parameter.
0460:             * @param generate_CreatePKStmt is value of parameter
0461:             */
0462:            public void setSqlStmtCreatePK(String generate_CreatePKStmt) {
0463:                if (generate_CreatePKStmt.equalsIgnoreCase("true")) {
0464:                    if (!this .alterTablePrimaryKey.equalsIgnoreCase("false")) {
0465:                        generateSomeSql = true;
0466:                        sqlToGenerate.setElementAt("CreatePrimary", 4);
0467:                    }
0468:                }
0469:            }
0470:
0471:            /**
0472:             * This method sets the value of sqlToGenerate parameter.
0473:             * @param generate_CreateFKStmt is value of parameter
0474:             */
0475:            public void setSqlStmtCreateFK(String generate_CreateFKStmt) {
0476:                if (generate_CreateFKStmt.equalsIgnoreCase("true")) {
0477:                    generateSomeSql = true;
0478:                    sqlToGenerate.setElementAt("CreateForeigin", 5);
0479:                }
0480:            }
0481:
0482:            /**
0483:             * This method sets the value of sqlToGenerate parameter.
0484:             * @param generate_CreateIndexStmt is value of parameter
0485:             */
0486:            public void setSqlStmtCreateIndex(String generate_CreateIndexStmt) {
0487:                if (generate_CreateIndexStmt.equalsIgnoreCase("true")) {
0488:                    generateSomeSql = true;
0489:                    sqlToGenerate.setElementAt("CreateIndexes", 3);
0490:                }
0491:            }
0492:
0493:            /**
0494:             * This method reads value of sqlToGenerate parameter.
0495:             * @return value of parameter.
0496:             */
0497:            public Vector getSqlToGenerate() {
0498:                return sqlToGenerate;
0499:            }
0500:
0501:            /**
0502:             * This method sets value of sqlToGenerate parameter.
0503:             */
0504:            public void setSqlToGenerate() {
0505:
0506:                if (this .alterTablePrimaryKey.equalsIgnoreCase("false")) {
0507:                    sqlToGenerate.setElementAt(null, 4);
0508:                }
0509:            }
0510:
0511:            /**
0512:             * This method reads value of path parameter.
0513:             * @return value of parameter.
0514:             */
0515:            public String getPath() {
0516:                return path;
0517:            }
0518:
0519:            /**
0520:             * Construct object InputParameters, and initialise the default value of input parameters.
0521:             * @throws LoaderException
0522:             */
0523:            public InputParameters(String confJarStructure)
0524:                    throws LoaderException {
0525:                //initialization InputParameters
0526:                setDefaultSqlStmt();
0527:                searchXmlFile = new SearchXmlFile("relative", path,
0528:                        confJarStructure);
0529:            }
0530:
0531:            /**
0532:             * This method sets the value of pathToSourceConf parameter.
0533:             * @param path_ToSourceConf is the value of parameter.
0534:             */
0535:            public void setPathToSourceConf(String path_ToSourceConf) {
0536:                pathToSourceConf = path_ToSourceConf;
0537:            }
0538:
0539:            /**
0540:             * This method read the value of pathToSourceConf parameter.
0541:             * @return the value of parameter.
0542:             */
0543:            public String getPathToSourceConf() {
0544:                return pathToSourceConf;
0545:            }
0546:
0547:            /**
0548:             * This method sets the value of sourceType parameter.
0549:             * @param source_Type is the value of parameter.
0550:             * @throws LoaderException
0551:             */
0552:            public void setSourceType(String source_Type)
0553:                    throws LoaderException {
0554:                setLogger();
0555:                //        if (this.logger != null) {
0556:                //            this.logger.write("full", "\tsetSourceType is started.");
0557:                //        }
0558:                if (source_Type != null) {
0559:                    if (searchXmlFile.getPathToConf(source_Type) != null) {
0560:                        setPathToSourceConf(searchXmlFile
0561:                                .getPathToConf(source_Type));
0562:                        sourceType = source_Type;
0563:                    } else {
0564:                        String msg = "This type of source database ("
0565:                                + source_Type + ") is not supported!"
0566:                                + " See documentation!";
0567:                        LoaderException le = new LoaderException("Exception:",
0568:                                new Exception(msg + "\n"));
0569:                        if (this .logger != null) {
0570:                            this .logger.write("full", "Exception:"
0571:                                    + "This type of source database ("
0572:                                    + source_Type + ") is not supported!"
0573:                                    + " See documentation!"
0574:                                    + le.getStackTraceAsString());
0575:                        }
0576:
0577:                        throw le;
0578:                    }
0579:                }
0580:                //        if (this.logger != null) {
0581:                //            this.logger.write("full", "\tsetSourceType is finished.");
0582:                //        }
0583:            }
0584:
0585:            /**
0586:             * This method read the value of sourceType parameter.
0587:             * @return value of parameter.
0588:             */
0589:            public String getSourceType() {
0590:                return sourceType;
0591:            }
0592:
0593:            /**
0594:             * This method sets the value of pathToTargetConf parameter.
0595:             * @param path_ToTargetConf is the value of parameter.
0596:             */
0597:            public void setPathToTargetConf(String path_ToTargetConf) {
0598:                pathToTargetConf = path_ToTargetConf;
0599:            }
0600:
0601:            /**
0602:             * This method read the value of pathToTargetConf parameter.
0603:             * @return value of parameter.
0604:             */
0605:            public String getPathToTargetConf() {
0606:                return pathToTargetConf;
0607:            }
0608:
0609:            /**
0610:             * This method sets the value of targetType parameter.
0611:             * @param target_Type is the value of parameter.
0612:             * @throws LoaderException
0613:             */
0614:            public void setTargetType(String target_Type)
0615:                    throws LoaderException {
0616:                setLogger();
0617:                //        if (this.logger != null) {
0618:                //            this.logger.write("full", "\tsetTargetType is started.");
0619:                //        }
0620:                if (target_Type != null) {
0621:                    //search the OctopusDBVendors.xml file for defined type of database.
0622:                    if (searchXmlFile.getPathToConf(target_Type) != null) {
0623:                        setPathToTargetConf(searchXmlFile
0624:                                .getPathToConf(target_Type));
0625:                        targetType = target_Type;
0626:                        setAlterTablePrimaryKey2(pathToTargetConf);
0627:                    } else {
0628:                        String msg = "This type of target database ("
0629:                                + target_Type + ") is not supported!"
0630:                                + " See documentation!";
0631:                        LoaderException le = new LoaderException("Exception:",
0632:                                new Exception(msg));
0633:                        if (this .logger != null) {
0634:                            this .logger.write("full", "Exception:"
0635:                                    + "This type of target database ("
0636:                                    + target_Type + ") is not supported!"
0637:                                    + " See documentation!"
0638:                                    + le.getStackTraceAsString());
0639:                        }
0640:                        throw le;
0641:                    }
0642:                }
0643:                //        if (this.logger != null) {
0644:                //            this.logger.write("full", "\tsetTargetType is finished.");
0645:                //        }
0646:            }
0647:
0648:            private void setAlterTablePrimaryKey2(String pathToTargetConf)
0649:                    throws LoaderException {
0650:                SearchXmlFile searchXmlFile = new SearchXmlFile("absolute",
0651:                        getPathToTargetConf(), getConfJarStructure());
0652:                if ((searchXmlFile
0653:                        .getAlterTablePrimaryKey(getTargetDriverName()) != null))
0654:                    setAlterTablePrimaryKey(searchXmlFile
0655:                            .getAlterTablePrimaryKey(getTargetDriverName()));
0656:            }
0657:
0658:            public void setSourceDriverProperties() throws LoaderException {
0659:                setLogger();
0660:                //        if (this.logger != null) {
0661:                //            this.logger.write("full", "\tsetSourceDriverProperties is started.");
0662:                //        }
0663:                SearchXmlFile searchXmlFile = new SearchXmlFile("absolute",
0664:                        getPathToSourceConf(), getConfJarStructure());
0665:                Vector tmpVector = searchXmlFile
0666:                        .getFileSystemDatabase(getSourceDriverName());
0667:                String fileSystemDatabse = tmpVector.get(0).toString();
0668:                String connectionPrefix = tmpVector.get(1).toString();
0669:
0670:                if (fileSystemDatabse.equalsIgnoreCase("true")) {
0671:                    File file = new File(getSourceDataBase());
0672:                    File fileOut = new File(getGeneratorOutput());
0673:                    if (!file.isAbsolute()) {
0674:                        try {
0675:                            String main = "";
0676:                            if (!getGeneratorOutput().equalsIgnoreCase(""))
0677:                                main = fileOut.getCanonicalPath()
0678:                                        + System.getProperty("file.separator")
0679:                                        + getSourceDataBase();
0680:                            else
0681:                                main = getSourceDataBase();
0682:
0683:                            File mainFile = new File(main);
0684:                            setSourceDataBase(mainFile.getCanonicalPath());
0685:                        } catch (Exception ex) {
0686:                            LoaderException le = new LoaderException(
0687:                                    "Exception:" + ex.getMessage(), ex);
0688:                            if (this .logger != null) {
0689:                                this .logger.write("full", "Exception:"
0690:                                        + le.getStackTraceAsString());
0691:                            }
0692:
0693:                            throw le;
0694:                            //ex.printStackTrace();
0695:                        }
0696:                    }
0697:                }
0698:                //        if (this.logger != null) {
0699:                //            this.logger.write("full", "\tsetSourceDriverProperties is finished.");
0700:                //        }
0701:            }
0702:
0703:            public void setTargetDriverProperties() throws LoaderException {
0704:                setLogger();
0705:                //        if (this.logger != null) {
0706:                //            this.logger.write("full", "\tsetTargetDriverProperties is started.");
0707:                //        }
0708:                SearchXmlFile searchXmlFile = new SearchXmlFile("absolute",
0709:                        getPathToTargetConf(), getConfJarStructure());
0710:                try {
0711:                    this .maxConstraintLength = searchXmlFile
0712:                            .getMaxConstraintLength(getTargetDriverName());
0713:                } catch (Exception ex) {
0714:                    LoaderException le = new LoaderException("Exception:"
0715:                            + ex.getMessage(), ex);
0716:                    this .logger.write("full", "Exception:"
0717:                            + le.getStackTraceAsString());
0718:                    throw le;
0719:                }
0720:                //        if (this.logger != null) {
0721:                //            this.logger.write("full", "\tsetTargetDriverProperties is finished.");
0722:                //        }
0723:
0724:            }
0725:
0726:            public String getMaxConstraintLength() {
0727:                return this .maxConstraintLength;
0728:            }
0729:
0730:            /**
0731:             * This method read the value of targetType parameter.
0732:             * @return value of parameter.
0733:             */
0734:            public String getTargetType() {
0735:                return targetType;
0736:            }
0737:
0738:            /**
0739:             * This method sets the value of sourceDataBase parameter.
0740:             * @param source_DataBase is the value of parameter.
0741:             * @throws LoaderException
0742:             */
0743:            public void setSourceDataBase(String source_DataBase)
0744:                    throws LoaderException {
0745:                setLogger();
0746:                //        if (this.logger != null) {
0747:                //            this.logger.write("full", "\tsetSourceDataBase is started.");
0748:                //        }
0749:                if (source_DataBase != null) {
0750:                    if (this .sourceDriverName.equalsIgnoreCase("microsoft")) {
0751:                        int num1 = source_DataBase.indexOf("SelectMethod=");
0752:                        int num2 = source_DataBase.indexOf("selectMethod=");
0753:                        if (num2 != -1) {
0754:                            //           source_DataBase=source_DataBase.replaceFirst("selectMethod=","SelectMethod=");
0755:                            if (source_DataBase.indexOf("selectMethod=") != -1)
0756:                                source_DataBase = Utils.replaceAll(
0757:                                        source_DataBase, "selectMethod=",
0758:                                        "SelectMethod=");
0759:
0760:                            num1 = 0;
0761:                        }
0762:                        if (num1 != -1)
0763:                            sourceDataBase = source_DataBase;
0764:                        else
0765:                            sourceDataBase = source_DataBase
0766:                                    + ";SelectMethod=cursor";
0767:                    } else
0768:                        sourceDataBase = source_DataBase;
0769:                } else {
0770:                    String msg = "You must enter the place where is source database is placed (param -sdb)!";
0771:                    LoaderException le = new LoaderException("Exception:",
0772:                            new Exception(msg));
0773:                    this .logger
0774:                            .write(
0775:                                    "full",
0776:                                    "Exception:"
0777:                                            + "You must enter the place where is source database is placed (param -sdb)!"
0778:                                            + le.getStackTraceAsString());
0779:                    throw le;
0780:                }
0781:                //        if (this.logger != null) {
0782:                //            this.logger.write("full", "\tsetSourceDataBase is finished.");
0783:                //        }
0784:            }
0785:
0786:            /**
0787:             * This method read the value of sourceDataBase parameter.
0788:             * @return value of parameter.
0789:             */
0790:            public String getSourceDataBase() {
0791:                return sourceDataBase;
0792:            }
0793:
0794:            /**
0795:             * This method sets the value of targetDataBase parameter.
0796:             * @param target_DataBase is the value of the parameter.
0797:             * @throws LoaderException
0798:             */
0799:            public void setTargetDataBase(String target_DataBase)
0800:                    throws LoaderException {
0801:                setLogger();
0802:                //        if (this.logger != null) {
0803:                //            this.logger.write("full", "\tsetTargetDataBase is started.");
0804:                //        }
0805:                if (target_DataBase != null) {
0806:                    if (this .targetDriverName.equalsIgnoreCase("microsoft")) {
0807:                        int num1 = target_DataBase.indexOf("SelectMethod=");
0808:                        int num2 = target_DataBase.indexOf("selectMethod=");
0809:                        if (num2 != -1) {
0810:                            //           target_DataBase=target_DataBase.replaceFirst("selectMethod=","SelectMethod=");
0811:                            if (target_DataBase.indexOf("selectMethod=") != -1)
0812:                                target_DataBase = Utils.replaceAll(
0813:                                        target_DataBase, "selectMethod=",
0814:                                        "SelectMethod=");
0815:                            num1 = 0;
0816:                        }
0817:                        if (num1 != -1)
0818:                            targetDataBase = target_DataBase;
0819:                        else
0820:                            targetDataBase = target_DataBase
0821:                                    + ";SelectMethod=cursor";
0822:                    } else
0823:                        targetDataBase = target_DataBase;
0824:                } else {
0825:                    String msg = "You must enter the place where is target database is placed (param -tdb)!";
0826:                    LoaderException le = new LoaderException("Exception:",
0827:                            new Exception(msg));
0828:                    if (this .logger != null) {
0829:                        this .logger
0830:                                .write(
0831:                                        "full",
0832:                                        "Exception:"
0833:                                                + "You must enter the place where is target database is placed (param -tdb)!"
0834:                                                + le.getStackTraceAsString());
0835:                    }
0836:                    throw le;
0837:                }
0838:                //        if (this.logger != null) {
0839:                //            this.logger.write("full", "\tsetTargetDataBase is finished.");
0840:                //        }
0841:            }
0842:
0843:            /**
0844:             * This method read the value of targetDataBase parameter.
0845:             * @return value of parameter.
0846:             */
0847:            public String getTargetDataBase() {
0848:                return targetDataBase;
0849:            }
0850:
0851:            /**
0852:             * This method sets the value of valueMode parameter.
0853:             * @param value_Mode is the value of the parameter.
0854:             * @throws LoaderException
0855:             */
0856:            public void setValueMode(String value_Mode) throws LoaderException {
0857:                setLogger();
0858:                //        if (this.logger != null) {
0859:                //            this.logger.write("full", "\tsetValueMode is started.");
0860:                //        }
0861:                if (value_Mode != null) {
0862:                    if (value_Mode.equalsIgnoreCase("copy")) {
0863:                        valueMode = "Overwrite";
0864:                    } else if (value_Mode.equalsIgnoreCase("sync")) {
0865:                        valueMode = "Update";
0866:                    } else {
0867:                        String msg = "The possible value of value modes (param -m) are 'copy' or 'sync'.!";
0868:                        LoaderException le = new LoaderException("Exception:",
0869:                                new Exception(msg));
0870:                        if (this .logger != null) {
0871:                            this .logger
0872:                                    .write(
0873:                                            "full",
0874:                                            "Exception:"
0875:                                                    + "The possible value of value modes (param -m) are 'copy' or 'sync'.!"
0876:                                                    + le
0877:                                                            .getStackTraceAsString());
0878:                        }
0879:                        throw le;
0880:                    }
0881:                }
0882:                //        if (this.logger != null) {
0883:                //            this.logger.write("full", "\tsetValueMode is finished.");
0884:                //        }
0885:            }
0886:
0887:            /**
0888:             * This method read the value of valueMode parameter.
0889:             * @return value of parameter.
0890:             */
0891:            public String getValueMode() {
0892:                return valueMode;
0893:            }
0894:
0895:            /**
0896:             * This method sets the value of generatorOutput parameter.
0897:             * @param generator_Output is the value of the parameter.
0898:             */
0899:            public void setGeneratorOutput(String generator_Output) {
0900:                if (generator_Output != null)
0901:                    generatorOutput = generator_Output;
0902:            }
0903:
0904:            /**
0905:             * This method read the value of generatorOutput parameter.
0906:             * @return value of parameter.
0907:             */
0908:            public String getGeneratorOutput() {
0909:                return generatorOutput;
0910:            }
0911:
0912:            /**
0913:             * This method sets the value of sourceUser parameter.
0914:             * @param source_User is the value of the parameter.
0915:             */
0916:            public void setSourceUser(String source_User) {
0917:                if (source_User != null)
0918:                    sourceUser = source_User;
0919:            }
0920:
0921:            /**
0922:             * This method read the value of sourceUser parameter.
0923:             * @return value of parameter.
0924:             */
0925:            public String getSourceUser() {
0926:                return sourceUser;
0927:            }
0928:
0929:            /**
0930:             * This method sets the value of sourcePassword parameter.
0931:             * @param source_Password is the value of the parameter.
0932:             */
0933:            public void setSourcePassword(String source_Password) {
0934:                if (source_Password != null)
0935:                    sourcePassword = source_Password;
0936:
0937:            }
0938:
0939:            /**
0940:             * This method read the value of sourcePassword parameter.
0941:             * @return value of parameter.
0942:             */
0943:            public String getSourcePassword() {
0944:                return sourcePassword;
0945:            }
0946:
0947:            /**
0948:             * This method sets the value of targetUser parameter.
0949:             * @param target_User is the value of the parameter.
0950:             */
0951:            public void setTargetUser(String target_User) {
0952:                if (target_User != null)
0953:                    targetUser = target_User;
0954:            }
0955:
0956:            /**
0957:             * This method read the value of targetUser parameter.
0958:             * @return value of parameter.
0959:             */
0960:            public String getTargetUser() {
0961:                return targetUser;
0962:            }
0963:
0964:            /**
0965:             * This method sets the value of targetPassword parameter.
0966:             * @param target_Password is the value of the parameter.
0967:             */
0968:            public void setTargetPassword(String target_Password) {
0969:                if (target_Password != null)
0970:                    targetPassword = target_Password;
0971:            }
0972:
0973:            /**
0974:             * This method read the value of targetPassword parameter.
0975:             * @return value of parameter.
0976:             */
0977:            public String getTargetPassword() {
0978:                return targetPassword;
0979:            }
0980:
0981:            /**
0982:             * This method sets the value of sourceDriverName parameter.
0983:             * @param source_DriverName is the value of parameter.
0984:             */
0985:            public void setSourceDriverName(String source_DriverName) {
0986:                if (source_DriverName != null)
0987:                    sourceDriverName = source_DriverName;
0988:            }
0989:
0990:            /**
0991:             * This method read the value of sourceDriverName parameter.
0992:             * @return value of parameter.
0993:             */
0994:            public String getSourceDriverName() {
0995:                return sourceDriverName;
0996:            }
0997:
0998:            /**
0999:             * This method sets the value of targetDriverName parameter.
1000:             * @param target_DriverName is the value of the parameter.
1001:             */
1002:            public void setTargetDriverName(String target_DriverName) {
1003:                if (target_DriverName != null)
1004:                    targetDriverName = target_DriverName;
1005:            }
1006:
1007:            /**
1008:             * This method read the value of targetDriverName parameter.
1009:             * @return value of parameter.
1010:             */
1011:            public String getTargetDriverName() {
1012:                return targetDriverName;
1013:            }
1014:
1015:            /**
1016:             * This method sets the value of domlPath parameter.
1017:             * @param doml_Path is the value of the parameter.
1018:             */
1019:            public void setDomlPath(String doml_Path) {
1020:                if (doml_Path != null)
1021:                    domlPath = doml_Path;
1022:            }
1023:
1024:            /**
1025:             * This method read the value of domlPath parameter.
1026:             * @return value of parameter.
1027:             */
1028:            public String getDomlPath() {
1029:                return domlPath;
1030:            }
1031:
1032:            /**
1033:             * This method sets the value of packageName parameter.
1034:             * @param package_Name is the value of parameter.
1035:             *  @throws LoaderException
1036:             */
1037:            public void setPackageName(String package_Name)
1038:                    throws LoaderException {
1039:                setLogger();
1040:                //        if (this.logger != null) {
1041:                //            this.logger.write("full", "\tsetPackageName is started.");
1042:                //        }
1043:                if (generateDoml.equalsIgnoreCase("true")) {
1044:                    if (package_Name != null) {
1045:                        packageName = package_Name;
1046:                    } else {
1047:                        String msg = "Sorry, but you must enter the package name (param -pack) for the doml file!";
1048:                        LoaderException le = new LoaderException("Exception",
1049:                                new Exception(msg));
1050:                        if (this .logger != null) {
1051:                            this .logger
1052:                                    .write(
1053:                                            "full",
1054:                                            "Exception:"
1055:                                                    + "Sorry, but you must enter the package name (param -pack) for the doml file!"
1056:                                                    + le
1057:                                                            .getStackTraceAsString());
1058:                        }
1059:                        throw le;
1060:                    }
1061:                }
1062:                //        if (this.logger != null) {
1063:                //            this.logger.write("full", "\tsetPackageName is finished.");
1064:                //        }
1065:            }
1066:
1067:            /**
1068:             * This method read the value of packageName parameter.
1069:             * @return value of parameter.
1070:             */
1071:            public String getPackageName() {
1072:                return packageName;
1073:            }
1074:
1075:            /**
1076:             * This method sets the value of alterTablePrimaryKey parameter.
1077:             * @param alter_TablePrimaryKey is the value of parameter.
1078:             */
1079:            public void setAlterTablePrimaryKey(String alter_TablePrimaryKey) {
1080:                alterTablePrimaryKey = alter_TablePrimaryKey;
1081:            }
1082:
1083:            /**
1084:             * This method read the value of alterTablePrimaryKey parameter.
1085:             * @return value of parameter.ss
1086:             */
1087:            public String getAlterTablePrimaryKey() {
1088:                return alterTablePrimaryKey;
1089:            }
1090:
1091:            /**
1092:             * This method set excluded tables
1093:             * @param value
1094:             */
1095:            public void setExcludedTables(String value) {
1096:                StringTokenizer st = new StringTokenizer(value, ",");
1097:                this .excludedTables = new String[st.countTokens()];
1098:                int i = 0;
1099:                while (st.hasMoreTokens()) {
1100:                    this .excludedTables[i] = st.nextToken();
1101:                    i++;
1102:                }
1103:            }
1104:
1105:            /**
1106:             *This method returns excluded tables
1107:             * @return String[] with excluded tables
1108:             */
1109:            public String[] getExcludedTables() {
1110:                return this .excludedTables;
1111:            }
1112:
1113:            /**
1114:             *This method set parameter confJar
1115:             */
1116:            public void setConfJarStructure(String confJarStructure) {
1117:                if (confJarStructure != null)
1118:                    this .confJarStructure = confJarStructure;
1119:            }
1120:
1121:            /**
1122:             *This method returns string with path to conf in jar
1123:             * @return String
1124:             */
1125:            public String getConfJarStructure() {
1126:                return this .confJarStructure;
1127:            }
1128:
1129:            /**
1130:             * This method will set logger object
1131:             * @param logger
1132:             */
1133:            private void setLogger() {
1134:                this.logger = StandardLogger.getCentralLogger();
1135:            }
1136:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.