1 16 17 18 package org.webdocwf.util.loader.task; 19 20 import org.apache.tools.ant.BuildException; 21 import org.apache.tools.ant.Task; 22 import org.webdocwf.util.loader.generator.LoaderGenerator; 23 import org.webdocwf.util.loader.Loader; 24 import java.io.File ; 25 26 31 public class BackupTask 32 extends Task { 33 34 protected String generatorOutput = null; 35 protected String sourceDatabase = null; 36 protected String sourceUser = ""; 37 protected String sourcePassword = ""; 38 protected String sourceType = null; 39 protected String sourceDriverName = ""; 40 41 protected String targetDatabase = null; 42 protected String targetUser = ""; 43 protected String targetPassword = ""; 44 protected String targetType = null; 45 protected String targetDriverName = ""; 46 47 protected String octopusHome = null; 48 49 protected String generateDropTableStmt = "true"; 51 protected String generateDropIntegrityStmt = "true"; 52 protected String generateCreateTableStmt = "true"; 53 protected String generateCreatePKStmt = "true"; 54 protected String generateCreateFKStmt = "true"; 55 protected String generateCreateIndexStmt = "true"; 56 protected String generateSqlForAllVendors = "true"; 57 58 protected String fullMode = "true"; 60 protected String generateXml = "false"; 61 protected String generateDoml = "false"; 62 protected String restoreMode = "false"; 63 64 protected String valueMode = "copy"; 65 protected String includeTableList=""; 66 protected String confJarStructure=""; 67 68 public BackupTask() { 69 } 70 71 75 public void execute() throws org.apache.tools.ant.BuildException { 76 if (sourceDatabase == null) { 77 throw new BuildException("sourceDatabase attribute must be set!"); 78 } 79 if (sourceType == null) { 80 throw new BuildException("sourceDatabaseType attribute must be set!"); 81 } 82 if (targetDatabase == null) { 83 throw new BuildException("targetDatabase attribute must be set!"); 84 } 85 if (targetType == null) { 86 throw new BuildException("targetDatabaseType attribute must be set!"); 87 } 88 if (octopusHome != null) 89 System.setProperty("OCTOPUS_HOME", octopusHome); 90 91 try { LoaderGenerator loaderGenerator = new LoaderGenerator(sourceType, 93 sourceDatabase,valueMode, generatorOutput, sourceDriverName, 94 targetDriverName, targetDatabase, targetType, sourceUser, 95 sourcePassword, targetUser, targetPassword, null, null, 96 generateDropTableStmt,generateDropIntegrityStmt, generateCreateTableStmt, 97 generateCreatePKStmt,generateCreateFKStmt,generateCreateIndexStmt, 98 generateSqlForAllVendors, generateXml,generateDoml, 99 fullMode, restoreMode, includeTableList,confJarStructure); 100 101 loaderGenerator.generate(); 102 } 103 catch (Exception ex) { 104 ex.printStackTrace(); 105 } 106 107 try { this.generateSqlForAllVendors = "false"; 109 this.generateXml = "true"; 110 this.fullMode = "false"; 111 112 LoaderGenerator loaderGenerator = new LoaderGenerator( 113 sourceType, sourceDatabase, 114 "copy", generatorOutput, sourceDriverName, 115 targetDriverName, targetDatabase, targetType, sourceUser, 116 sourcePassword, targetUser, targetPassword, null, null, 117 generateDropTableStmt,generateDropIntegrityStmt ,generateCreateTableStmt, 118 generateCreatePKStmt, generateCreateFKStmt, 119 generateCreateIndexStmt, generateSqlForAllVendors, generateXml, 120 generateDoml,fullMode, "false", includeTableList,confJarStructure); 121 122 loaderGenerator.generate(); 123 124 } 125 catch (Exception ex) { 126 ex.printStackTrace(); 127 } 128 try { String loadJobFileName = ""; 130 if (!generatorOutput.equalsIgnoreCase("")) { 131 File file = new File (this.generatorOutput); 132 generatorOutput = file.getAbsolutePath(); 133 loadJobFileName = generatorOutput + 134 System.getProperty("file.separator") +"LoaderJob.olj"; 135 } 136 else { 137 loadJobFileName = "LoaderJob.olj"; 138 } 139 Loader octopusLoader = new Loader(loadJobFileName,confJarStructure); 140 octopusLoader.load(); 141 } 142 catch (Exception ex) { 143 ex.printStackTrace(); 144 } 145 146 } 147 148 152 public void setConfJarStructure(String confJarStructure) { 153 this.confJarStructure = confJarStructure; 154 } 155 156 160 public String getConfJarStructure() { 161 return this.confJarStructure; 162 } 163 164 165 169 public void setIncludeTableList(String includeTableList) { 170 this.includeTableList = includeTableList; 171 } 172 173 177 public String getIncludeTableList() { 178 return this.includeTableList; 179 } 180 181 182 186 public void setGeneratorOutput(String generatorOutput) { 187 this.generatorOutput = generatorOutput; 188 } 189 190 194 public String getGeneratorOutput() { 195 return this.generatorOutput; 196 } 197 198 202 public void setSourceDatabase(String sourceDatabase) { 203 this.sourceDatabase = sourceDatabase; 204 } 205 206 210 public String getSourceDatabase() { 211 return this.sourceDatabase; 212 } 213 214 218 public void setSourceUser(String sourceUser) { 219 this.sourceUser = sourceUser; 220 } 221 222 226 public String getSourceUser() { 227 return this.sourceUser; 228 } 229 230 234 public void setSourcePassword(String sourcePassword) { 235 this.sourcePassword = sourcePassword; 236 } 237 238 242 public String getSourcePassword() { 243 return this.sourcePassword; 244 } 245 246 250 public void setSourceType(String sourceType) { 251 this.sourceType = sourceType; 252 } 253 254 258 public String getSourceType() { 259 return this.sourceType; 260 } 261 262 266 public void setSourceDriverName(String sourceDriverName) { 267 this.sourceDriverName = sourceDriverName; 268 } 269 270 274 public String getSourceDriverName() { 275 return this.sourceDriverName; 276 } 277 278 282 public void setTargetDatabase(String targetDatabase) { 283 this.targetDatabase = targetDatabase; 284 } 285 286 290 public String getTargetDatabase() { 291 return this.targetDatabase; 292 } 293 294 298 public void setTargetUser(String targetUser) { 299 this.targetUser = targetUser; 300 } 301 302 306 public String getTargetUser() { 307 return this.targetUser; 308 } 309 310 314 public void setTargetPassword(String targetPassword) { 315 this.targetPassword = targetPassword; 316 } 317 318 322 public String getTargetPassword() { 323 return this.targetPassword; 324 } 325 326 330 public void setTargetType(String targetType) { 331 this.targetType = targetType; 332 } 333 334 338 public String getTargetType() { 339 return this.targetType; 340 } 341 342 346 public void setTargetDriverName(String targetDriverName) { 347 this.targetDriverName = targetDriverName; 348 } 349 350 354 public String getTargetDriverName() { 355 return this.targetDriverName; 356 } 357 358 362 public void setOctopusHome(String octopusHome) { 363 this.octopusHome = octopusHome; 364 } 365 366 370 public String getOctopusHome() { 371 return this.octopusHome; 372 } 373 374 } | Popular Tags |