1 2 22 23 package org.webdocwf.util.loader.generator; 24 25 import java.util.Vector ; 26 27 import org.webdocwf.util.loader.BufferOctopusClass; 28 import org.webdocwf.util.loader.LoaderException; 29 import org.webdocwf.util.loader.TimeWatch; 30 import org.webdocwf.util.loader.logging.StandardLogger; 31 32 39 public class LoaderGenerator { 40 41 private InputParameters generatorParameters; 42 private StandardLogger logger; 43 private String strLogDirName = ""; 44 private String strLogFileName = "defaultGenerator"; 45 private String logMode = "normal"; 46 private TimeWatch timeCounter; 47 private String strLoggerParam = ""; 48 private boolean standardLogger; 49 50 55 public void setSourceDataBase(String sourceDataBase) throws LoaderException { 56 this.generatorParameters.setSourceDataBase(sourceDataBase); 57 } 58 59 64 65 public String getSourceDataBase() throws LoaderException { 66 return this.generatorParameters.getSourceDataBase(); 67 } 68 73 74 public void setTargetDataBase(String targetDataBase) throws LoaderException { 75 this.generatorParameters.setTargetDataBase(targetDataBase); 76 } 77 78 83 public String getTargetDataBase() throws LoaderException { 84 return this.generatorParameters.getTargetDataBase(); 85 } 86 87 92 public void setSourceType(String sourceType) throws LoaderException { 93 this.generatorParameters.setSourceType(sourceType); 94 } 95 96 101 public String getSourceType() throws LoaderException { 102 return this.generatorParameters.getSourceType(); 103 } 104 105 110 public void setTargetType(String targetType) throws LoaderException { 111 this.generatorParameters.setTargetType(targetType); 112 } 113 114 119 public String getTargetType() throws LoaderException { 120 return this.generatorParameters.getTargetType(); 121 } 122 123 128 public void setSourceDriverName(String sourceDriverName) throws LoaderException { 129 this.generatorParameters.setSourceDriverName(sourceDriverName); 130 } 131 132 137 public String getSourceDriverName() throws LoaderException { 138 return this.generatorParameters.getSourceDriverName(); 139 } 140 141 146 public void setTargetDriverName(String targetDriverName) throws LoaderException { 147 this.generatorParameters.setTargetDriverName(targetDriverName); 148 } 149 150 155 public String getTargetDriverName() throws LoaderException { 156 return this.generatorParameters.getTargetDriverName(); 157 } 158 159 164 public void setValueMode(String valueMode) throws LoaderException { 165 this.generatorParameters.setValueMode(valueMode); 166 } 167 168 173 public String getValueMode() throws LoaderException { 174 return this.generatorParameters.getValueMode(); 175 } 176 177 182 public void setGeneratorOutput(String generatorOutput) throws LoaderException { 183 this.generatorParameters.setGeneratorOutput(generatorOutput); 184 } 185 186 191 public String getGeneratorOutput() throws LoaderException { 192 return this.generatorParameters.getGeneratorOutput(); 193 } 194 195 200 public void setSourceUser(String sourceUser) throws LoaderException { 201 this.generatorParameters.setSourceUser(sourceUser); 202 } 203 204 209 public String getSourceUser() throws LoaderException { 210 return this.generatorParameters.getSourceUser(); 211 } 212 213 218 public void setTargetUser(String targetUser) throws LoaderException { 219 this.generatorParameters.setTargetUser(targetUser); 220 } 221 222 227 public String getTargetUser() throws LoaderException { 228 return this.generatorParameters.getTargetUser(); 229 } 230 235 public void setSourcePassword(String sourcePassword) throws LoaderException { 236 this.generatorParameters.setSourcePassword(sourcePassword); 237 } 238 239 244 public String getSourcePassword() throws LoaderException { 245 return this.generatorParameters.getSourcePassword(); 246 } 247 248 253 public void setTargetPassword(String targetPassword) throws LoaderException { 254 this.generatorParameters.setTargetPassword(targetPassword); 255 } 256 257 262 public String getTargetPassword() throws LoaderException { 263 return this.generatorParameters.getTargetPassword(); 264 } 265 266 271 public void setDomlPath(String domlPath) throws LoaderException { 272 this.generatorParameters.setDomlPath(domlPath); 273 } 274 275 280 public String getDomlPath() throws LoaderException { 281 return this.generatorParameters.getDomlPath(); 282 } 283 284 289 public void setPackageName(String packageName) throws LoaderException { 290 this.generatorParameters.setPackageName(packageName); 291 } 292 293 298 public String getPackageName() throws LoaderException { 299 return this.generatorParameters.getPackageName(); 300 } 301 306 public void setGenerateDropTableStmt(boolean generateDropTableStmt) throws LoaderException { 307 this.generatorParameters.setSqlStmtDropTable(new Boolean (generateDropTableStmt).toString()); 308 } 309 314 public boolean getGenerateDropTableStmt() throws LoaderException { 315 Vector tempVector = this.generatorParameters.getSqlToGenerate(); 316 String dropTables = (String ) tempVector.elementAt(1); 317 if (dropTables.equalsIgnoreCase("DropTables")) { 318 return true; 319 } else { 320 return false; 321 } 322 323 } 324 329 public void setGenerateCreateTableStmt(boolean generateCreateTableStmt) throws LoaderException { 330 this.generatorParameters.setSqlStmtCreateTable(new Boolean (generateCreateTableStmt).toString()); 331 } 332 333 338 public boolean getGenerateCreateTableStmt() throws LoaderException { 339 Vector tempVector = this.generatorParameters.getSqlToGenerate(); 340 String createTables = (String ) tempVector.elementAt(2); 341 if (createTables.equalsIgnoreCase("CreateTables")) { 342 return true; 343 } else { 344 return false; 345 } 346 } 347 352 353 public void setGenerateDropIntegrityStmt(boolean generateDropIntegrityStmt) throws LoaderException { 354 this.generatorParameters.setSqlStmtDropIntegrity(new Boolean (generateDropIntegrityStmt).toString()); 355 } 356 361 public boolean getGenerateDropIntegrityStmt() throws LoaderException { 362 Vector tempVector = this.generatorParameters.getSqlToGenerate(); 363 String dropIntegrity = (String ) tempVector.elementAt(0); 364 if (dropIntegrity.equalsIgnoreCase("DropIntegrity")) { 365 return true; 366 } else { 367 return false; 368 } 369 } 370 375 public void setGenerateCreatePKStmt(boolean generateCreatePKStmt) throws LoaderException { 376 this.generatorParameters.setSqlStmtCreatePK(new Boolean (generateCreatePKStmt).toString()); 377 } 378 383 public boolean getGenerateCreatePKStmt() throws LoaderException { 384 Vector tempVector = this.generatorParameters.getSqlToGenerate(); 385 String createPrimary = (String ) tempVector.elementAt(4); 386 if (createPrimary.equalsIgnoreCase("CreatePrimary")) { 387 return true; 388 } else { 389 return false; 390 } 391 } 392 397 public void setGenerateCreateFKStmt(boolean generateCreateFKStmt) throws LoaderException { 398 this.generatorParameters.setSqlStmtCreateFK(new Boolean (generateCreateFKStmt).toString()); 399 } 400 401 406 public boolean getGenerateCreateFKStmt() throws LoaderException { 407 Vector tempVector = this.generatorParameters.getSqlToGenerate(); 408 String createForeign = (String ) tempVector.elementAt(5); 409 if (createForeign.equalsIgnoreCase("CreateForeigin")) { 410 return true; 411 } else { 412 return false; 413 } 414 } 415 420 public void setGenerateCreateIndexStmt(boolean generateCreateIndexStmt) throws LoaderException { 421 this.generatorParameters.setSqlStmtCreateIndex(new Boolean (generateCreateIndexStmt).toString()); 422 } 423 428 public boolean getGenerateCreateIndexStmt() throws LoaderException { 429 Vector tempVector = this.generatorParameters.getSqlToGenerate(); 430 String createIndexes = (String ) tempVector.elementAt(3); 431 if (createIndexes.equalsIgnoreCase("CreateIndexes")) { 432 return true; 433 } else { 434 return false; 435 } 436 } 437 442 public void setGenerateSqlForAllVendors(boolean generateSqlForAllVendors) throws LoaderException { 443 this.generatorParameters.setAllVendors(new Boolean (generateSqlForAllVendors).toString()); 444 } 445 446 451 public boolean getGenerateSqlForAllVendors() throws LoaderException { 452 return this.generatorParameters.getSqlForAllVendors(); 453 } 454 459 public void setGenerateXml(boolean generateXml) throws LoaderException { 460 this.generatorParameters.setGenerateXml(new Boolean (generateXml).toString()); 461 } 462 463 468 public boolean getGenerateXml() throws LoaderException { 469 String tempGenerateXml = this.generatorParameters.getGenerateXml(); 470 return (new Boolean (tempGenerateXml)).booleanValue(); 471 472 } 473 478 public void setGenerateDoml(boolean generateDoml) throws LoaderException { 479 this.generatorParameters.setGenerateDoml(new Boolean (generateDoml).toString()); 480 } 481 482 487 public boolean getGenerateDoml() throws LoaderException { 488 String tempGenerateDoml = this.generatorParameters.getGenerateDoml(); 489 return (new Boolean (tempGenerateDoml)).booleanValue(); 490 } 491 492 497 public boolean getGenerateSQL() throws LoaderException { 498 boolean tempGenerateSQL = this.generatorParameters.isGenerateSql(); 499 return tempGenerateSQL; 500 } 501 506 public void setFullMode(boolean fullMode) throws LoaderException { 507 this.generatorParameters.setFullMode(new Boolean (fullMode).toString()); 508 } 509 510 515 public boolean getFullMode() throws LoaderException { 516 return this.generatorParameters.getFullMode(); 517 } 518 519 524 public void setIncludeTableList(String includeTableList) throws LoaderException { 525 this.generatorParameters.setIncludeTableList(includeTableList); 526 } 527 528 533 public String getIncludeTableList() throws LoaderException { 534 Vector tmpIncludeTableList = this.generatorParameters.getIncludeTableList(); 535 return tmpIncludeTableList.toString(); 536 } 537 538 543 public void setConfJarStructure(String confJarStructure) throws LoaderException { 544 this.generatorParameters.setConfJarStructure(confJarStructure); 545 } 546 547 552 public String getConfJarStructure() throws LoaderException { 553 return this.generatorParameters.getConfJarStructure(); 554 } 555 556 561 public void setRestoreMode(String restoreMode) throws LoaderException { 562 this.generatorParameters.setRestoreMode(restoreMode); 563 } 564 565 570 public String getRestoreMode() throws LoaderException { 571 return this.generatorParameters.getRestoreMode(); 572 } 573 574 575 579 public String getLogMode() { 580 return logMode; 581 } 582 583 587 public String getStrLogDirName() { 588 return strLogDirName; 589 } 590 591 595 public String getStrLogFileName() { 596 return strLogFileName; 597 } 598 599 603 public void setLogMode(String logMode) { 604 this.logMode = logMode; 605 } 606 607 611 public void setStrLogDirName(String strLogDirName) { 612 this.strLogDirName = strLogDirName; 613 } 614 615 619 public void setStrLogFileName(String strLogFileName) { 620 this.strLogFileName = strLogFileName; 621 } 622 623 627 public String inputToString() throws LoaderException { 628 String resString = ""; 629 try { 630 631 resString ="Source type="+ getSourceType()+ "\n" 632 + "Source driver=" + getSourceDriverName()+ "\n" 633 + "Source URL=" + getSourceDataBase()+ "\n" 634 + "Source user="+ getSourceUser()+ "\n" 635 + "Source password="+ getSourcePassword()+ "\n" 636 + "Target type=" + getTargetType()+ "\n" 637 + "Target driver=" + getTargetDriverName() + "\n" 638 + "Target URL=" + getTargetDataBase() + "\n" 639 + "Target user=" + getTargetUser() + "\n" 640 + "Target password=" + getTargetPassword() + "\n" 641 + "Conf file in jar=" + getConfJarStructure() + "\n" 642 + "Doml path=" + getDomlPath()+ "\n" 643 + "Ouput directory=" + getGeneratorOutput() + "\n" 644 + "Include table list=" + getIncludeTableList() + "\n" 645 + "Restore mode=" + getRestoreMode()+ "\n" 646 + "Value mode="+ getValueMode()+ "\n" 647 + "Generate create foreign keys ="+ getGenerateCreateFKStmt()+ "\n" 648 + "Generate create indexes ="+ getGenerateCreateIndexStmt()+ "\n" 649 + "Generate create primary keys ="+ getGenerateCreatePKStmt()+ "\n" 650 + "Generate create tables ="+ getGenerateCreateTableStmt()+ "\n" 651 + "Generate drop foreign keys ="+ getGenerateDropIntegrityStmt()+ "\n" 652 + "Generate drop tables ="+ getGenerateDropTableStmt()+ "\n" 653 + "Generate sql for all vendors ="+ getGenerateSqlForAllVendors()+ "\n" 654 + "Generate doml ="+ getGenerateDoml()+ "\n" 655 + "Package name="+ getPackageName()+ "\n" 656 + "Generate xml ="+ getGenerateXml()+ "\n" 657 + "Full mode=" + getFullMode() + "\n" 658 + "Log mode=" + getLogMode() + "\n" 659 + "Log directory name=" + getStrLogDirName() + "\n" 660 + "Log file name=" + getStrLogFileName() + "\n"; 661 662 return resString; 663 } catch (Exception e) { 664 throw new LoaderException("Exception:" + e.getMessage(), e); 665 } 666 } 667 668 706 707 public LoaderGenerator(String sourceType, String sourceDataBase, 708 String valueMode, String generatorOutput, String sourceDriverName, 709 String targetDriverName, String targetDataBase, String targetType, 710 String sourceUser, String sourcePassword, String targetUser, 711 String targetPassword, String domlPath, String packageName, String generateDropTableStmt, 712 String generateDropIntegrityStmt, String generateCreateTableStmt, String generateCreatePKStmt, 713 String generateCreateFKStmt, String generateCreateIndexStmt, String generateSqlForAllVendors, 714 String generateXml, String generateDoml, String fullMode, String includeTableList, 715 String confJarStructure) 716 throws LoaderException { 717 718 this(sourceType, sourceDataBase, valueMode, generatorOutput, 719 sourceDriverName, targetDriverName, targetDataBase, targetType, 720 sourceUser, sourcePassword, targetUser, targetPassword, domlPath, 721 packageName, generateDropTableStmt, generateDropIntegrityStmt, 722 generateCreateTableStmt, generateCreatePKStmt, generateCreateFKStmt, 723 generateCreateIndexStmt, generateSqlForAllVendors, generateXml, generateDoml, 724 fullMode, "false", includeTableList, confJarStructure); 725 726 } 727 728 767 768 public LoaderGenerator(String sourceType, String sourceDataBase, String valueMode, 769 String generatorOutput, String sourceDriverName, String targetDriverName, 770 String targetDataBase, String targetType, String sourceUser, String sourcePassword, 771 String targetUser, String targetPassword, String domlPath, String packageName, 772 String generateDropTableStmt, String generateDropIntegrityStmt, String generateCreateTableStmt, 773 String generateCreatePKStmt, String generateCreateFKStmt, String generateCreateIndexStmt, 774 String generateSqlForAllVendors, String generateXml, String generateDoml, String fullMode, 775 String restoreMode, String includeTableList, String confJarStructure) 776 throws LoaderException { 777 778 generatorParameters = new InputParameters(confJarStructure); 779 generatorParameters.setConfJarStructure(confJarStructure); 780 781 generatorParameters.setSourceType(sourceType); 782 generatorParameters.setTargetDriverName(targetDriverName); 784 generatorParameters.setSourceDriverName(sourceDriverName); 785 generatorParameters.setTargetType(targetType); 786 generatorParameters.setSourceDataBase(sourceDataBase); 787 generatorParameters.setTargetDataBase(targetDataBase); 788 generatorParameters.setValueMode(valueMode); 789 generatorParameters.setGeneratorOutput(generatorOutput); 790 generatorParameters.setSourceUser(sourceUser); 791 generatorParameters.setSourcePassword(sourcePassword); 792 generatorParameters.setTargetUser(targetUser); 793 generatorParameters.setTargetPassword(targetPassword); 794 795 if (generateDropTableStmt != null) 796 generatorParameters.setSqlStmtDropTable(generateDropTableStmt); 797 if (generateDropIntegrityStmt != null) 798 generatorParameters.setSqlStmtDropIntegrity(generateDropIntegrityStmt); 799 if (generateCreateTableStmt != null) 800 generatorParameters.setSqlStmtCreateTable(generateCreateTableStmt); 801 if (generateCreatePKStmt != null) 802 generatorParameters.setSqlStmtCreatePK(generateCreatePKStmt); 803 if (generateCreateFKStmt != null) 804 generatorParameters.setSqlStmtCreateFK(generateCreateFKStmt); 805 if (generateCreateIndexStmt != null) 806 generatorParameters.setSqlStmtCreateIndex(generateCreateIndexStmt); 807 if (generateSqlForAllVendors != null) 808 generatorParameters.setAllVendors(generateSqlForAllVendors); 809 810 generatorParameters.setDomlPath(domlPath); 811 if (generateXml != null) 812 generatorParameters.setGenerateXml(generateXml); 813 if (generateDoml != null) 814 generatorParameters.setGenerateDoml(generateDoml); 815 generatorParameters.setPackageName(packageName); 816 if (fullMode != null) 817 generatorParameters.setFullMode(fullMode); 818 if (restoreMode != null) 819 generatorParameters.setRestoreMode(restoreMode); 820 if (includeTableList != null) 821 generatorParameters.setIncludeTableList(includeTableList); 822 823 generatorParameters.setSourceDriverProperties(); 824 generatorParameters.setTargetDriverProperties(); 825 generatorParameters.setOidAndVersionColumnName(); 826 generatorParameters.setHasSize(); 827 generatorParameters.setIsDecimal(); 828 830 } 831 832 874 875 public LoaderGenerator(String sourceType, String sourceDataBase, String valueMode, 876 String generatorOutput, String sourceDriverName, String targetDriverName, String targetDataBase, 877 String targetType, String sourceUser, String sourcePassword, String targetUser, 878 String targetPassword, String domlPath, String packageName, String generateDropTableStmt, 879 String generateDropIntegrityStmt, String generateCreateTableStmt, String generateCreatePKStmt, 880 String generateCreateFKStmt, String generateCreateIndexStmt, String generateSqlForAllVendors, 881 String generateXml, String generateDoml, String fullMode, String restoreMode, 882 String includeTableList, String confJarStructure, String logMode, String logDirName, 883 String logFileName) 884 throws LoaderException { 885 886 generatorParameters = new InputParameters(confJarStructure); 887 generatorParameters.setConfJarStructure(confJarStructure); 888 889 generatorParameters.setSourceType(sourceType); 890 generatorParameters.setTargetDriverName(targetDriverName); 892 generatorParameters.setSourceDriverName(sourceDriverName); 893 generatorParameters.setTargetType(targetType); 894 generatorParameters.setSourceDataBase(sourceDataBase); 895 generatorParameters.setTargetDataBase(targetDataBase); 896 generatorParameters.setValueMode(valueMode); 897 generatorParameters.setGeneratorOutput(generatorOutput); 898 generatorParameters.setSourceUser(sourceUser); 899 generatorParameters.setSourcePassword(sourcePassword); 900 generatorParameters.setTargetUser(targetUser); 901 generatorParameters.setTargetPassword(targetPassword); 902 903 if (generateDropTableStmt != null) 904 generatorParameters.setSqlStmtDropTable(generateDropTableStmt); 905 if (generateDropIntegrityStmt != null) 906 generatorParameters.setSqlStmtDropIntegrity(generateDropIntegrityStmt); 907 if (generateCreateTableStmt != null) 908 generatorParameters.setSqlStmtCreateTable(generateCreateTableStmt); 909 if (generateCreatePKStmt != null) 910 generatorParameters.setSqlStmtCreatePK(generateCreatePKStmt); 911 if (generateCreateFKStmt != null) 912 generatorParameters.setSqlStmtCreateFK(generateCreateFKStmt); 913 if (generateCreateIndexStmt != null) 914 generatorParameters.setSqlStmtCreateIndex(generateCreateIndexStmt); 915 if (generateSqlForAllVendors != null) 916 generatorParameters.setAllVendors(generateSqlForAllVendors); 917 918 generatorParameters.setDomlPath(domlPath); 919 if (generateXml != null) 920 generatorParameters.setGenerateXml(generateXml); 921 if (generateDoml != null) 922 generatorParameters.setGenerateDoml(generateDoml); 923 generatorParameters.setPackageName(packageName); 924 if (fullMode != null) 925 generatorParameters.setFullMode(fullMode); 926 if (restoreMode != null) 927 generatorParameters.setRestoreMode(restoreMode); 928 if (includeTableList != null) 929 generatorParameters.setIncludeTableList(includeTableList); 930 if (logMode != null) { 931 this.logMode = logMode; 932 } 933 if (logDirName != null) { 934 this.strLogDirName = logDirName; 935 } 936 if (logFileName != null) { 937 this.strLogFileName = logFileName; 938 } 939 generatorParameters.setSourceDriverProperties(); 940 generatorParameters.setTargetDriverProperties(); 941 generatorParameters.setOidAndVersionColumnName(); 942 generatorParameters.setHasSize(); 943 generatorParameters.setIsDecimal(); 944 945 } 946 947 956 public LoaderGenerator(String sourceDataBase, String targetDataBase, String sourceType, 957 String targetType) throws LoaderException { 958 959 this(sourceDataBase, targetDataBase, sourceType, targetType, null); 960 961 } 962 963 972 public LoaderGenerator(String sourceDataBase, String targetDataBase, String sourceType, 973 String targetType, String confJarStructure) throws LoaderException { 974 975 generatorParameters = new InputParameters(""); 976 generatorParameters.setConfJarStructure(confJarStructure); 977 generatorParameters.setSourceDataBase(sourceDataBase); 978 979 generatorParameters.setTargetDataBase(targetDataBase); 980 generatorParameters.setSourceType(sourceType); 981 generatorParameters.setTargetType(targetType); 982 generatorParameters.setSourceDriverProperties(); 983 generatorParameters.setTargetDriverProperties(); 984 generatorParameters.setOidAndVersionColumnName(); 985 generatorParameters.setHasSize(); 986 generatorParameters.setIsDecimal(); 987 } 989 990 1026 1027 public static void main(String args[]) { 1028 1029 String generatorOutput = null; 1030 String valueMode = null; 1031 String domlUrl = null; 1032 String packageName = null; 1033 1034 String sourceType = null; 1035 String sourceDataBase = null; 1036 String sourceDriverName = null; 1037 String sourceUser = null; 1038 String sourcePassword = null; 1039 1040 String targetType = null; 1041 String targetDataBase = null; 1042 String targetDriverName = null; 1043 String targetUser = null; 1044 String targetPassword = null; 1045 1046 String logDirName = null; 1048 String logFileName = null; 1049 String logMode = null; 1050 1051 String generateXml = null; 1054 String generateDoml = null; 1055 String generateDropTableStmt = null; 1057 String generateDropIntegrityStmt = null; 1058 String generateCreateTableStmt = null; 1059 String generateCreatePKStmt = null; 1060 String generateCreateFKStmt = null; 1061 String generateCreateIndexStmt = null; 1062 1063 String generateSqlForAllVendors = null; 1065 String fullMode = null; 1067 String restoreMode = null; 1068 String includeTableList = null; 1069 String confJarStructure = null; 1070 1071 if (args.length > 8 && args.length < 53) { 1072 for (int i = 0; i < args.length - 1; i = i + 1) { 1073 if (args[i].equalsIgnoreCase("-st")) 1074 sourceType = args[++i]; 1075 else if (args[i].equalsIgnoreCase("-sdb")) 1076 sourceDataBase = args[++i]; 1077 else if (args[i].equalsIgnoreCase("-m")) 1078 valueMode = args[++i]; 1079 else if (args[i].equalsIgnoreCase("-o")) 1080 generatorOutput = args[++i]; 1081 else if (args[i].equalsIgnoreCase("-sdn")) 1082 sourceDriverName = args[++i]; 1083 else if (args[i].equalsIgnoreCase("-tdn")) 1084 targetDriverName = args[++i]; 1085 else if (args[i].equalsIgnoreCase("-tdb")) 1086 targetDataBase = args[++i]; 1087 if (args[i].equalsIgnoreCase("-tt")) 1088 targetType = args[++i]; 1089 if (args[i].equalsIgnoreCase("-su")) 1090 sourceUser = args[++i]; 1091 if (args[i].equalsIgnoreCase("-sp")) 1092 sourcePassword = args[++i]; 1093 if (args[i].equalsIgnoreCase("-tu")) 1094 targetUser = args[++i]; 1095 if (args[i].equalsIgnoreCase("-tp")) 1096 targetPassword = args[++i]; 1097 if (args[i].equalsIgnoreCase("-doml")) 1098 domlUrl = args[++i]; 1099 if (args[i].equalsIgnoreCase("-pack")) 1100 packageName = args[++i]; 1101 if (args[i].equalsIgnoreCase("-xml")) 1102 generateXml = args[++i]; 1103 if (args[i].equalsIgnoreCase("-gdoml")) 1104 generateDoml = args[++i]; 1105 if (args[i].equalsIgnoreCase("-sqlCT")) 1106 generateCreateTableStmt = args[++i]; 1107 if (args[i].equalsIgnoreCase("-sqlDT")) 1108 generateDropTableStmt = args[++i]; 1109 if (args[i].equalsIgnoreCase("-sqlDI")) 1110 generateDropIntegrityStmt = args[++i]; 1111 if (args[i].equalsIgnoreCase("-sqlCPK")) 1112 generateCreatePKStmt = args[++i]; 1113 if (args[i].equalsIgnoreCase("-sqlCFK")) 1114 generateCreateFKStmt = args[++i]; 1115 if (args[i].equalsIgnoreCase("-sqlCI")) 1116 generateCreateIndexStmt = args[++i]; 1117 if (args[i].equalsIgnoreCase("-sqlAll")) 1118 generateSqlForAllVendors = args[++i]; 1119 if (args[i].equalsIgnoreCase("-fm")) 1120 fullMode = args[++i]; 1121 if (args[i].equalsIgnoreCase("-rm")) 1122 restoreMode = args[++i]; 1123 if (args[i].equalsIgnoreCase("-it")) 1124 includeTableList = args[++i]; 1125 if (args[i].equalsIgnoreCase("-cjs")) 1126 confJarStructure = args[++i]; 1127 if (args[i].equalsIgnoreCase("-lm")) 1128 logMode = args[++i]; 1129 else if (args[i].equalsIgnoreCase("-l")) 1130 logDirName = args[++i]; 1131 else if (args[i].equalsIgnoreCase("-f")) 1132 logFileName = args[++i]; 1133 } 1134 } else { 1135 System.out.println("You didn't enter all required parameters, for running the application!"); 1136 BufferOctopusClass.getInstance().writeToBuffer("You didn't enter all required parameters, for running the application!"); 1137 printUsage(); 1138 System.exit(1); 1139 } 1140 try { 1141 1142 LoaderGenerator generator = new LoaderGenerator(sourceType, sourceDataBase, valueMode, generatorOutput, sourceDriverName, targetDriverName, targetDataBase, targetType, sourceUser, sourcePassword, targetUser, targetPassword, domlUrl, packageName, generateDropTableStmt, generateDropIntegrityStmt, generateCreateTableStmt, generateCreatePKStmt, generateCreateFKStmt, generateCreateIndexStmt, generateSqlForAllVendors, generateXml, generateDoml, fullMode, restoreMode, includeTableList, confJarStructure, logMode, logDirName, logFileName); 1143 1144 generator.generate(); 1145 System.exit(0); 1146 1147 } catch (LoaderException le) { 1148 System.out.println(le.getStackTraceAsString()); 1149 BufferOctopusClass.getInstance().writeToBuffer(le.getStackTraceAsString()); 1150 return; 1151 } catch (Throwable th) { 1152 BufferOctopusClass.getInstance().writeToBuffer(th.getMessage()); 1153 th.printStackTrace(System.out); 1154 return; 1155 } 1156 } 1157 1158 static void printUsage() { 1159 BufferOctopusClass.getInstance().writeToBuffer("Usage: java org.webdocwf.util.loader.generator.Generator [options] "); 1161 BufferOctopusClass.getInstance().writeToBuffer(" Options:"); 1163 BufferOctopusClass.getInstance().writeToBuffer(" -st sourceType, defines the type of the source database."); 1165 BufferOctopusClass.getInstance().writeToBuffer(" -tt targetType, defines the type of the target database."); 1167 BufferOctopusClass.getInstance().writeToBuffer(" -sdn sourceDriverName, represents driver of defined source database."); 1169 BufferOctopusClass.getInstance().writeToBuffer(" -tdn targetDriverName, represents driver of defined target database."); 1171 BufferOctopusClass.getInstance().writeToBuffer(" -sdb sourceDatabase, defines the place where you're put the database tables"); 1173 BufferOctopusClass.getInstance().writeToBuffer(" -tdb targetDataBase defines the place where the target database tables are."); 1175 BufferOctopusClass.getInstance().writeToBuffer(" -m valueMode, is the difference from overwrite and update attribute"); 1177 BufferOctopusClass.getInstance().writeToBuffer(" -su sourceUser, defines the user of the source database."); 1179 BufferOctopusClass.getInstance().writeToBuffer(" -sp sourcePassword, defines user password for the source database."); 1181 BufferOctopusClass.getInstance().writeToBuffer(" -tu targetUser, defines the user of the target database."); 1183 BufferOctopusClass.getInstance().writeToBuffer(" -tp targetPassword, defines user password for the target database."); 1185 BufferOctopusClass.getInstance().writeToBuffer(" -doml domlUrl, defines the place where the doml file is placed."); 1187 BufferOctopusClass.getInstance().writeToBuffer(" -o generatorOutput, is optional. That represent the directory, where the Octopus place" + " created files. If this argument dont exists, Octopus place created files in to current direcory!"); 1190 BufferOctopusClass.getInstance().writeToBuffer(" -pack packageName, defines the package name for the generated doml file."); 1192 1193 BufferOctopusClass.getInstance().writeToBuffer(" -xml generateXml, defines if you want to generate xml files as output files. " + " Possible values are true and false."); 1196 BufferOctopusClass.getInstance().writeToBuffer(" -gdoml generateDoml, defines if you want to generate doml file as output file. " + " Possible values are true and false."); 1199 BufferOctopusClass.getInstance().writeToBuffer(" -sqlCT generateCreateTables, defines if you want to generate only Sql statement for CREATE TABLE."); 1201 1202 BufferOctopusClass.getInstance().writeToBuffer(" -sqlDT generateDropTableStmt, defines if you want to generate only Sql statement for DROP TABLE."); 1204 1205 BufferOctopusClass.getInstance().writeToBuffer(" -sqlCPK generateCreatePrimaryKeys, defines if you want to generate only Sql statement for ALTER TABLE ADD CONSTRAINT (PRIMARY KEY)."); 1207 1208 BufferOctopusClass.getInstance().writeToBuffer(" -sqlCFK generateCreateForeigKeys, defines if you want to generate only Sql statement for ALTER TABLE ADD CONSTRAINT (FOREIGN KEY)."); 1210 1211 BufferOctopusClass.getInstance().writeToBuffer(" -sqlCI generateCreateIndex, defines if you want to generate only Sql statement for CREATE INDEX."); 1213 1214 BufferOctopusClass.getInstance().writeToBuffer(" -sqlAll generateSqlForAllVendors, defines if you want to generate sql statements for all named database vendors."); 1216 1217 BufferOctopusClass.getInstance().writeToBuffer(" -fm fullMode, defines the mode of output xml files. Possible values are true and false."); 1219 1220 BufferOctopusClass.getInstance().writeToBuffer(" -it includeTableList, defines tables which you want to incude into Generator process."); 1222 1223 BufferOctopusClass.getInstance().writeToBuffer("For more details, see documentation."); 1225 BufferOctopusClass.getInstance().writeToBuffer(" -lm defines the default logmode. Possible values are 'none', 'normal' (is the default) and 'full'."); 1227 1228 BufferOctopusClass.getInstance().writeToBuffer(" -v defines variables used in variable columns. \n"); 1230 1231 BufferOctopusClass.getInstance().writeToBuffer(" -f defines the logfile name. The default is 'GeneratorLog-YYYY-MM-DD-HH-mm-SS.txt'. \n"); 1233 1234 } 1235 1236 1240 private void setLogger() throws LoaderException { 1241 1242 this.timeCounter = new TimeWatch(); 1243 this.timeCounter.setStartJobTime(); 1244 1245 try { 1246 1247 this.logger = new StandardLogger(); 1248 this.strLoggerParam = this.strLogDirName + ";" + this.strLogFileName; 1249 this.standardLogger = true; 1250 this.logger.configure(strLoggerParam); 1251 this.logger.setEnabledLogLevels(this.logMode); 1252 } catch (Exception e) { 1253 1254 LoaderException le = new LoaderException("Error while instantiate StandardLogger!", e); 1255 throw le; 1256 } 1257 } 1258 1259 1265 public void generate() throws LoaderException { 1266 1267 try { 1268 LoadJobWriter loadJobWriter; 1269 GenerateSqlForAllVendors generateSqlForAllVendors; 1270 this.setLogger(); 1272 1273 if (standardLogger == true) { 1274 this.logger.write("normal", "Default (Standard) Logger is load."); 1275 this.logger.write("normal", "OctopusGenerator started."); 1276 } 1277 if (generatorParameters.getSqlForAllVendors() == true) { 1278 1279 generateSqlForAllVendors = new GenerateSqlForAllVendors(generatorParameters); 1280 1281 } else { 1282 if (generatorParameters.getDomlPath() == null || generatorParameters.getDomlPath().equalsIgnoreCase("")) { 1283 CreateIncludeFiles createIncludeFiles = new CreateIncludeFiles(generatorParameters); 1284 } else { 1285 CreateIncludeDomlFiles createIncludeDomlFiles; 1286 createIncludeDomlFiles = new CreateIncludeDomlFiles(generatorParameters); 1287 } 1288 if (generatorParameters.getGenerateXml().equalsIgnoreCase("true")) 1289 loadJobWriter = new LoadJobWriter(generatorParameters); 1290 } 1291 if (this.standardLogger == true) { 1292 this.logger.write("normal", "Duration: " + this.timeCounter.getTotalTime()); 1293 this.logger.write("normal", "OctopusGenerator finished."); 1294 } 1295 } catch (Exception e) { 1296 String msg = "Exception in method generate() in LoaderGenerator class!"; 1297 LoaderException le = new LoaderException(msg + "\n" + e.getMessage(), (Throwable ) e); 1298 if (standardLogger == true) { 1299 this.logger.write("full", "Exception in method generate() in LoaderGenerator class!" + "\n" + le.getStackTraceAsString()); 1300 } 1301 throw le; 1302 1303 } 1304 1305 } 1306 1307} | Popular Tags |