1 21 22 package org.webdocwf.util.loader.restore; 23 24 import org.webdocwf.util.loader.generator.LoaderGenerator; 25 import org.webdocwf.util.loader.Loader; 26 import java.io.File ; 27 28 29 34 public class Restore { 35 36 private String generatorOutput = ""; 37 private String sourceDatabase = ""; 38 private String sourceUser = ""; 39 private String sourcePassword = ""; 40 private String sourceDatabaseType = ""; 41 private String sourceDriverName = ""; 42 43 private String targetDatabase = ""; 44 private String targetUser = ""; 45 private String targetPassword = ""; 46 private String targetDatabaseType = ""; 47 private String targetDriverName = ""; 48 49 private String generateDropTableStmt = "false"; 50 private String generateDropIntegrityStmt = "false"; 51 private String generateCreateTableStmt = "false"; 52 private String generateCreatePKStmt = "false"; 53 private String generateCreateFKStmt = "false"; 54 private String generateCreateIndexStmt = "false"; 55 56 private String generateSqlForAllVendors = "false"; 57 private String fullMode = "false"; 59 private String generateXml = "true"; 60 private String generateDoml = "false"; 61 private String restoreMode="true"; 62 63 private String valueMode="copy"; 64 private String includeTableList=""; 65 private String confJarStructure=""; 66 67 82 public Restore(String sourceDatabaseType, String sourceDatabase, 83 String generatorOutput,String sourceDriverName, 84 String targetDriverName,String targetDatabase, 85 String targetDatabaseType, String sourceUser, 86 String sourcePassword,String targetUser, 87 String targetPassword,String includeTableList, 88 String confJarStructure) { 89 90 this.generatorOutput = generatorOutput; 91 this.sourceDatabase = sourceDatabase; 92 this.sourceUser = sourceUser; 93 this.sourcePassword = sourcePassword; 94 this.sourceDatabaseType = sourceDatabase; 95 this.sourceDriverName = sourceDriverName; 96 97 this.targetDatabase = targetDatabase; 98 this.targetUser = targetUser; 99 this.targetPassword = targetPassword; 100 this.targetDatabaseType = targetDatabaseType; 101 this.targetDriverName = targetDriverName; 102 103 this.generateDropTableStmt = generateDropTableStmt; 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 { 120 LoaderGenerator loaderGenerator = new LoaderGenerator(sourceDatabaseType, 121 sourceDatabase, 122 valueMode, generatorOutput, sourceDriverName, 123 targetDriverName, targetDatabase, targetDatabaseType, sourceUser, 124 sourcePassword, targetUser, targetPassword, null, null, 125 generateDropTableStmt,generateDropIntegrityStmt, generateCreateTableStmt, generateCreatePKStmt, 126 generateCreateFKStmt, 127 generateCreateIndexStmt, generateSqlForAllVendors, generateXml, 128 generateDoml, 129 fullMode, restoreMode, includeTableList,confJarStructure); 130 loaderGenerator.generate(); 131 } 132 catch (Exception ex) { 133 ex.printStackTrace(); 134 } 135 136 try { String loadJobFileName = ""; 138 if (!generatorOutput.equalsIgnoreCase("")) { 139 File file = new File (generatorOutput); 140 generatorOutput = file.getAbsolutePath(); 141 loadJobFileName = generatorOutput + System.getProperty("file.separator") + 142 "LoaderJob.olj"; 143 } 144 else { 145 loadJobFileName = "LoaderJob.olj"; 146 } 147 Loader octopusLoader = new Loader(loadJobFileName,confJarStructure); 148 octopusLoader.load(); 149 } 150 catch (Exception ex) { 151 ex.printStackTrace(); 152 } 153 } 154 155 159 public static void main(String argv[]) { 160 String strGeneratorOutput = ""; 161 String strSourceDatabase = ""; 162 String strSourceUser = ""; 163 String strSourcePassword = ""; 164 String strSourceDatabaseType = ""; 165 String strSourceDriverName = ""; 166 167 String strTargetDatabase = ""; 168 String strTargetUser = ""; 169 String strTargetPassword = ""; 170 String strTargetDatabaseType = ""; 171 String strTargetDriverName = ""; 172 173 String strIncludeTableList=""; 174 String strConfJarStructure=""; 175 176 if (argv.length > 0 && argv.length < 26) { 177 for (int i = 0; i < argv.length - 1; i = i + 1) { 178 if (argv[i].equalsIgnoreCase("-o")) 179 strGeneratorOutput = argv[++i]; 180 else if (argv[i].equalsIgnoreCase("-sdb")) 181 strSourceDatabase = argv[++i]; 182 else if (argv[i].equalsIgnoreCase("-su")) 183 strSourceUser = argv[++i]; 184 else if (argv[i].equalsIgnoreCase("-sp")) 185 strSourcePassword = argv[++i]; 186 else if (argv[i].equalsIgnoreCase("-st")) 187 strSourceDatabaseType = argv[++i]; 188 else if (argv[i].equalsIgnoreCase("-sdn")) 189 strSourceDriverName = argv[++i]; 190 else if (argv[i].equalsIgnoreCase("-tdb")) 191 strTargetDatabase = argv[++i]; 192 else if (argv[i].equalsIgnoreCase("-tu")) 193 strTargetUser = argv[++i]; 194 else if (argv[i].equalsIgnoreCase("-tp")) 195 strTargetPassword = argv[++i]; 196 else if (argv[i].equalsIgnoreCase("-tt")) 197 strTargetDatabaseType = argv[++i]; 198 else if (argv[i].equalsIgnoreCase("-tdn")) 199 strTargetDriverName = argv[++i]; 200 else if (argv[i].equalsIgnoreCase("-it")) 201 strIncludeTableList = argv[++i]; 202 else if (argv[i].equalsIgnoreCase("-cjs")) 203 strConfJarStructure = argv[++i]; 204 205 } 206 } 207 208 try { 209 Restore restore=new Restore(strSourceDatabaseType, strSourceDatabase, 210 strGeneratorOutput, strSourceDriverName, 211 strTargetDriverName,strTargetDatabase, strTargetDatabaseType, strSourceUser, 212 strSourcePassword, strTargetUser, strTargetPassword, strIncludeTableList, 213 strConfJarStructure); 214 } 215 catch (Exception ex) { 216 ex.printStackTrace(); 217 } 218 } 219 220 224 public void setConfJarStructure(String confJarStructure) { 225 this.confJarStructure = confJarStructure; 226 } 227 228 232 public String getConfJarStructure() { 233 return this.confJarStructure; 234 } 235 236 240 public void setGeneratorOutput(String generatorOutput) { 241 this.generatorOutput = generatorOutput; 242 } 243 244 248 public String getGeneratorOutput() { 249 return this.generatorOutput; 250 } 251 252 256 public void setSourceDatabase(String sourceDatabase) { 257 this.sourceDatabase = sourceDatabase; 258 } 259 260 264 public String getSourceDatabase() { 265 return this.sourceDatabase; 266 } 267 268 272 public void setSourceUser(String sourceUser) { 273 this.sourceUser = sourceUser; 274 } 275 276 280 public String getSourceUser() { 281 return this.sourceUser; 282 } 283 284 288 public void setSourcePassword(String sourcePassword) { 289 this.sourcePassword = sourcePassword; 290 } 291 292 296 public String getSourcePassword() { 297 return this.sourcePassword; 298 } 299 300 304 public void setSourceDatabaseType(String sourceDatabaseType) { 305 this.sourceDatabaseType = sourceDatabaseType; 306 } 307 308 312 public String getSourceDatabaseType() { 313 return this.sourceDatabaseType; 314 } 315 316 320 public void setSourceDriverName(String sourceDriverName) { 321 this.sourceDriverName = sourceDriverName; 322 } 323 324 328 public String getSourceDriverName() { 329 return this.sourceDriverName; 330 } 331 332 336 public void setTargetDatabase(String targetDatabase) { 337 this.targetDatabase = targetDatabase; 338 } 339 340 344 public String getTargetDatabase() { 345 return this.targetDatabase; 346 } 347 348 352 public void setTargetUser(String targetUser) { 353 this.targetUser = targetUser; 354 } 355 356 360 public String getTargetUser() { 361 return this.targetUser; 362 } 363 364 368 public void setTargetPassword(String targetPassword) { 369 this.targetPassword = targetPassword; 370 } 371 372 376 public String getTargetPassword() { 377 return this.targetPassword; 378 } 379 380 384 public void setTargetDatabaseType(String targetDatabaseType) { 385 this.targetDatabaseType = targetDatabaseType; 386 } 387 388 392 public String getTargetDatabaseType() { 393 return this.targetDatabaseType; 394 } 395 396 400 public void setTargetDriverName(String targetDriverName) { 401 this.targetDriverName = targetDriverName; 402 } 403 404 408 public String getTargetDriverName() { 409 return this.targetDriverName; 410 } 411 412 413 414 } | Popular Tags |