1 21 22 package org.webdocwf.util.loader.backup; 23 24 import org.webdocwf.util.loader.generator.LoaderGenerator; 25 import org.webdocwf.util.loader.Loader; 26 import java.io.File ; 27 28 33 public class Backup { 34 35 private String generatorOutput = ""; 36 private String sourceDatabase = ""; 37 private String sourceUser = ""; 38 private String sourcePassword = ""; 39 private String sourceDatabaseType = ""; 40 private String sourceDriverName = ""; 41 42 private String targetDatabase = ""; 43 private String targetUser = ""; 44 private String targetPassword = ""; 45 private String targetDatabaseType = ""; 46 private String targetDriverName = ""; 47 48 private String generateDropTableStmt = "true"; 50 private String generateDropIntegrityStmt="true"; 51 private String generateCreateTableStmt = "true"; 52 private String generateCreatePKStmt = "true"; 53 private String generateCreateFKStmt = "true"; 54 private String generateCreateIndexStmt = "true"; 55 private String generateSqlForAllVendors = "true"; 56 57 private String fullMode = "true"; 59 private String generateXml = "false"; 60 private String generateDoml = "false"; 61 private String restoreMode="false"; 62 63 private String valueMode="copy"; 64 private String includeTableList=""; 65 private String confJarStructure=""; 66 67 82 public Backup(String sourceDatabaseType, String sourceDatabase, 83 String generatorOutput,String sourceDriverName, 84 String targetDriverName, String targetDatabase, 85 String targetDatabaseType, String sourceUser, 86 String sourcePassword, String targetUser, String targetPassword, 87 String includeTableList, String strConfJarStructure) { 88 89 this.generatorOutput = generatorOutput; 90 this.sourceDatabase = sourceDatabase; 91 this.sourceUser = sourceUser; 92 this.sourcePassword = sourcePassword; 93 this.sourceDatabaseType = sourceDatabase; 94 this.sourceDriverName = sourceDriverName; 95 96 this.targetDatabase = targetDatabase; 97 this.targetUser = targetUser; 98 this.targetPassword = targetPassword; 99 this.targetDatabaseType = targetDatabaseType; 100 this.targetDriverName = targetDriverName; 101 102 this.generateDropTableStmt = generateDropTableStmt; 103 this.generateDropIntegrityStmt = generateDropIntegrityStmt; 104 this.generateCreateTableStmt = generateCreateTableStmt; 105 this.generateCreatePKStmt = generateCreatePKStmt; 106 this.generateCreateFKStmt = generateCreateFKStmt; 107 this.generateCreateIndexStmt = generateCreateIndexStmt; 108 109 this.generateSqlForAllVendors = generateSqlForAllVendors; 110 this.fullMode = fullMode; 112 113 this.generateXml = generateXml; 114 this.generateDoml = generateDoml; 115 116 this.includeTableList=includeTableList; 117 this.confJarStructure=confJarStructure; 118 119 try { LoaderGenerator loaderGenerator = new LoaderGenerator(sourceDatabaseType, 121 sourceDatabase,valueMode, generatorOutput, sourceDriverName, 122 targetDriverName, targetDatabase, targetDatabaseType, sourceUser, 123 sourcePassword, targetUser, targetPassword, null, null, 124 generateDropTableStmt,generateDropIntegrityStmt ,generateCreateTableStmt, generateCreatePKStmt, 125 generateCreateFKStmt,generateCreateIndexStmt, generateSqlForAllVendors, 126 generateXml,generateDoml,fullMode, restoreMode, includeTableList,confJarStructure); 127 128 loaderGenerator.generate(); 129 130 } 131 catch (Exception ex) { 132 ex.printStackTrace(); 133 } 134 135 try { 137 this.generateSqlForAllVendors = "false"; 138 this.generateXml = "true"; 139 this.fullMode = "false"; 140 141 LoaderGenerator loaderGenerator = new LoaderGenerator( 142 sourceDatabaseType, sourceDatabase,valueMode, generatorOutput, 143 sourceDriverName,targetDriverName, targetDatabase, targetDatabaseType, 144 sourceUser,sourcePassword, targetUser, targetPassword, null, null, 145 generateDropTableStmt, generateDropIntegrityStmt,generateCreateTableStmt, 146 generateCreatePKStmt, generateCreateFKStmt, 147 generateCreateIndexStmt, generateSqlForAllVendors, generateXml, 148 generateDoml,fullMode, "false", includeTableList,confJarStructure); 149 150 loaderGenerator.generate(); 151 } 152 catch (Exception ex) { 153 ex.printStackTrace(); 154 } 155 156 try { String loadJobFileName = ""; 158 if (!generatorOutput.equalsIgnoreCase("")) { 159 File file = new File (this.generatorOutput); 160 generatorOutput = file.getAbsolutePath(); 161 loadJobFileName = generatorOutput + 162 System.getProperty("file.separator") + "LoaderJob.olj"; 163 } 164 else { 165 loadJobFileName = "LoaderJob.olj"; 166 } 167 Loader octopusLoader = new Loader(loadJobFileName,confJarStructure); 168 octopusLoader.load(); 169 } 170 catch (Exception ex) { 171 ex.printStackTrace(); 172 } 173 174 } 175 176 180 public static void main(String argv[]) { 181 String strGeneratorOutput = ""; 182 String strSourceDatabase = ""; 183 String strSourceUser = ""; 184 String strSourcePassword = ""; 185 String strSourceDatabaseType = ""; 186 String strSourceDriverName = ""; 187 188 String strTargetDatabase = ""; 189 String strTargetUser = ""; 190 String strTargetPassword = ""; 191 String strTargetDatabaseType = ""; 192 String strTargetDriverName = ""; 193 194 String strIncludeTableList=""; 195 String strConfJarStructure=""; 196 197 if (argv.length > 0 && argv.length < 28) { 198 for (int i = 0; i < argv.length - 1; i = i + 1) { 199 if (argv[i].equalsIgnoreCase("-o")) 200 strGeneratorOutput = argv[++i]; 201 else if (argv[i].equalsIgnoreCase("-sdb")) 202 strSourceDatabase = argv[++i]; 203 else if (argv[i].equalsIgnoreCase("-su")) 204 strSourceUser = argv[++i]; 205 else if (argv[i].equalsIgnoreCase("-sp")) 206 strSourcePassword = argv[++i]; 207 else if (argv[i].equalsIgnoreCase("-st")) 208 strSourceDatabaseType = argv[++i]; 209 else if (argv[i].equalsIgnoreCase("-sdn")) 210 strSourceDriverName = argv[++i]; 211 else if (argv[i].equalsIgnoreCase("-tdb")) 212 strTargetDatabase = argv[++i]; 213 else if (argv[i].equalsIgnoreCase("-tu")) 214 strTargetUser = argv[++i]; 215 else if (argv[i].equalsIgnoreCase("-tp")) 216 strTargetPassword = argv[++i]; 217 else if (argv[i].equalsIgnoreCase("-tt")) 218 strTargetDatabaseType = argv[++i]; 219 else if (argv[i].equalsIgnoreCase("-tdn")) 220 strTargetDriverName = argv[++i]; 221 else if (argv[i].equalsIgnoreCase("-it")) 222 strIncludeTableList= argv[++i]; 223 else if (argv[i].equalsIgnoreCase("-cjs")) 224 strConfJarStructure = argv[++i]; 225 226 } 227 228 try { 229 Backup backup = new Backup(strSourceDatabaseType, 230 strSourceDatabase, 231 strGeneratorOutput, 232 strSourceDriverName, 233 strTargetDriverName, 234 strTargetDatabase, 235 strTargetDatabaseType, 236 strSourceUser, 237 strSourcePassword, 238 strTargetUser, 239 strTargetPassword, 240 strIncludeTableList, 241 strConfJarStructure); 242 243 } 244 catch (Exception ex) { 245 ex.printStackTrace(); 246 } 247 } 248 } 249 250 254 public void setConfJarStructure(String confJarStructure) { 255 this.confJarStructure = confJarStructure; 256 } 257 258 262 public String getConfJarStructure() { 263 return this.confJarStructure; 264 } 265 266 267 271 public void setGeneratorOutput(String generatorOutput) { 272 this.generatorOutput = generatorOutput; 273 } 274 275 279 public String getGeneratorOutput() { 280 return this.generatorOutput; 281 } 282 283 287 public void setSourceDatabase(String sourceDatabase) { 288 this.sourceDatabase = sourceDatabase; 289 } 290 291 295 public String getSourceDatabase() { 296 return this.sourceDatabase; 297 } 298 299 303 public void setSourceUser(String sourceUser) { 304 this.sourceUser = sourceUser; 305 } 306 307 311 public String getSourceUser() { 312 return this.sourceUser; 313 } 314 315 319 public void setSourcePassword(String sourcePassword) { 320 this.sourcePassword = sourcePassword; 321 } 322 323 327 public String getSourcePassword() { 328 return this.sourcePassword; 329 } 330 331 335 public void setSourceDatabaseType(String sourceDatabaseType) { 336 this.sourceDatabaseType = sourceDatabaseType; 337 } 338 339 343 public String getSourceDatabaseType() { 344 return this.sourceDatabaseType; 345 } 346 347 351 public void setSourceDriverName(String sourceDriverName) { 352 this.sourceDriverName = sourceDriverName; 353 } 354 355 359 public String getSourceDriverName() { 360 return this.sourceDriverName; 361 } 362 363 367 public void setTargetDatabase(String targetDatabase) { 368 this.targetDatabase = targetDatabase; 369 } 370 371 375 public String getTargetDatabase() { 376 return this.targetDatabase; 377 } 378 379 383 public void setTargetUser(String targetUser) { 384 this.targetUser = targetUser; 385 } 386 387 391 public String getTargetUser() { 392 return this.targetUser; 393 } 394 395 399 public void setTargetPassword(String targetPassword) { 400 this.targetPassword = targetPassword; 401 } 402 403 407 public String getTargetPassword() { 408 return this.targetPassword; 409 } 410 411 415 public void setTargetDatabaseType(String targetDatabaseType) { 416 this.targetDatabaseType = targetDatabaseType; 417 } 418 419 423 public String getTargetDatabaseType() { 424 return this.targetDatabaseType; 425 } 426 427 431 public void setTargetDriverName(String targetDriverName) { 432 this.targetDriverName = targetDriverName; 433 } 434 435 439 public String getTargetDriverName() { 440 return this.targetDriverName; 441 } 442 443 } | Popular Tags |