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 32 public class RestoreTask 33 extends Task { 34 35 protected String generatorOutput = null; 36 protected String sourceDatabase = null; 37 protected String sourceUser = ""; 38 protected String sourcePassword = ""; 39 protected String sourceType = null; 40 protected String sourceDriverName = ""; 41 42 protected String targetDatabase = null; 43 protected String targetUser = ""; 44 protected String targetPassword = ""; 45 protected String targetType = null; 46 protected String targetDriverName = ""; 47 48 protected String octopusHome = null; 49 50 protected String generateDropTableStmt = "false"; 52 protected String generateDropIntegrityStmt = "false"; 53 protected String generateCreateTableStmt = "false"; 54 protected String generateCreatePKStmt = "false"; 55 protected String generateCreateFKStmt = "false"; 56 protected String generateCreateIndexStmt = "false"; 57 protected String generateSqlForAllVendors = "false"; 58 59 protected String fullMode = "false"; 61 protected String generateXml = "true"; 62 protected String generateDoml = "false"; 63 protected String restoreMode = "true"; 64 65 protected String valueMode = "copy"; 66 protected String includeTableList=""; 67 protected String confJarStructure=""; 68 69 70 public RestoreTask() { 71 } 72 73 77 public void execute() throws org.apache.tools.ant.BuildException { 78 if (sourceDatabase == null) { 79 throw new BuildException("sourceDatabase attribute must be set!"); 80 } 81 if (sourceType == null) { 82 throw new BuildException("sourceDatabaseType attribute must be set!"); 83 } 84 if (targetDatabase == null) { 85 throw new BuildException("targetDatabase attribute must be set!"); 86 } 87 if (targetType == null) { 88 throw new BuildException("targetDatabaseType attribute must be set!"); 89 } 90 if (octopusHome != null) 91 System.setProperty("OCTOPUS_HOME", octopusHome); 92 93 try { 94 LoaderGenerator loaderGenerator = new LoaderGenerator(sourceType, 95 sourceDatabase, 96 valueMode, generatorOutput, sourceDriverName, 97 targetDriverName, targetDatabase, targetType, sourceUser, 98 sourcePassword, targetUser, targetPassword, null, null, 99 generateDropTableStmt,generateDropIntegrityStmt, generateCreateTableStmt, generateCreatePKStmt, 100 generateCreateFKStmt, 101 generateCreateIndexStmt, generateSqlForAllVendors, generateXml, 102 generateDoml, 103 fullMode, restoreMode, includeTableList,confJarStructure); 104 loaderGenerator.generate(); 105 } 106 catch (Exception ex) { 107 ex.printStackTrace(); 108 } 109 110 try { String loadJobFileName = ""; 112 if (!generatorOutput.equalsIgnoreCase("")) { 113 File file = new File (generatorOutput); 114 generatorOutput = file.getAbsolutePath(); 115 loadJobFileName = generatorOutput + System.getProperty("file.separator") + 116 "LoaderJob.olj"; 117 } 118 else { 119 loadJobFileName = "LoaderJob.olj"; 120 } 121 Loader octopusLoader = new Loader(loadJobFileName,confJarStructure); 122 octopusLoader.load(); 123 } 124 catch (Exception ex) { 125 ex.printStackTrace(); 126 } 127 128 } 129 130 134 public void setConfJarStructure(String confJarStructure) { 135 this.confJarStructure = confJarStructure; 136 } 137 138 142 public String getConfJarStructure() { 143 return this.confJarStructure; 144 } 145 146 147 151 public void setIncludeTableList(String includeTableList) { 152 this.includeTableList = includeTableList; 153 } 154 155 159 public String getIncludeTableList() { 160 return this.includeTableList; 161 } 162 163 164 165 169 public void setGeneratorOutput(String generatorOutput) { 170 this.generatorOutput = generatorOutput; 171 } 172 173 177 public String getGeneratorOutput() { 178 return this.generatorOutput; 179 } 180 181 185 public void setSourceDatabase(String sourceDatabase) { 186 this.sourceDatabase = sourceDatabase; 187 } 188 189 193 public String getSourceDatabase() { 194 return this.sourceDatabase; 195 } 196 197 201 public void setSourceUser(String sourceUser) { 202 this.sourceUser = sourceUser; 203 } 204 205 209 public String getSourceUser() { 210 return this.sourceUser; 211 } 212 213 217 public void setSourcePassword(String sourcePassword) { 218 this.sourcePassword = sourcePassword; 219 } 220 221 225 public String getSourcePassword() { 226 return this.sourcePassword; 227 } 228 229 233 public void setSourceType(String sourceType) { 234 this.sourceType = sourceType; 235 } 236 237 241 public String getSourceType() { 242 return this.sourceType; 243 } 244 245 249 public void setSourceDriverName(String sourceDriverName) { 250 this.sourceDriverName = sourceDriverName; 251 } 252 253 257 public String getSourceDriverName() { 258 return this.sourceDriverName; 259 } 260 261 265 public void setTargetDatabase(String targetDatabase) { 266 this.targetDatabase = targetDatabase; 267 } 268 269 273 public String getTargetDatabase() { 274 return this.targetDatabase; 275 } 276 277 281 public void setTargetUser(String targetUser) { 282 this.targetUser = targetUser; 283 } 284 285 289 public String getTargetUser() { 290 return this.targetUser; 291 } 292 293 297 public void setTargetPassword(String targetPassword) { 298 this.targetPassword = targetPassword; 299 } 300 301 305 public String getTargetPassword() { 306 return this.targetPassword; 307 } 308 309 313 public void setTargetType(String targetType) { 314 this.targetType = targetType; 315 } 316 317 321 public String getTargetType() { 322 return this.targetType; 323 } 324 325 329 public void setTargetDriverName(String targetDriverName) { 330 this.targetDriverName = targetDriverName; 331 } 332 333 337 public String getTargetDriverName() { 338 return this.targetDriverName; 339 } 340 341 345 public void setOctopusHome(String octopusHome) { 346 this.octopusHome = octopusHome; 347 } 348 349 353 public String getOctopusHome() { 354 return this.octopusHome; 355 } 356 357 } | Popular Tags |