View Javadoc
1 /* 2 LoaderGenerator - tool for generated xml, sql and doml file needed for Octopus. 3 Copyright (C) 2003 Together 4 This library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Lesser General Public 6 License as published by the Free Software Foundation; either 7 version 2.1 of the License, or (at your option) any later version. 8 This library is distributed in the hope that it will be useful, 9 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 Lesser General Public License for more details. 12 You should have received a copy of the GNU Lesser General Public 13 License along with this library; if not, write to the Free Software 14 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 15 */ 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 /*** 27 * RestoreTask Task class extends jakarta-ant Task class and uses to start 28 * @author Radoslav Dutina 29 * @version 1.0 30 */ 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 //sql statements 51 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 //xml files 60 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 /*** 74 * 75 * @throws org.apache.tools.ant.BuildException 76 */ 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 { //Octopus loader 111 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 /*** 131 * This method set value of confJarStructure parameter 132 * @param confJarStructure is value of parameter 133 */ 134 public void setConfJarStructure(String confJarStructure) { 135 this.confJarStructure = confJarStructure; 136 } 137 138 /*** 139 * This method read value of confJarStructure parameter 140 * @return value of parameter 141 */ 142 public String getConfJarStructure() { 143 return this.confJarStructure; 144 } 145 146 147 /*** 148 * This method set value of includeTableList parameter 149 * @param includeTableList is value of parameter 150 */ 151 public void setIncludeTableList(String includeTableList) { 152 this.includeTableList = includeTableList; 153 } 154 155 /*** 156 * This method read value of includeTableList parameter 157 * @return value of parameter 158 */ 159 public String getIncludeTableList() { 160 return this.includeTableList; 161 } 162 163 164 165 /*** 166 * This method set value of generatorOutput parameter 167 * @param generatorOutput is value of parameter 168 */ 169 public void setGeneratorOutput(String generatorOutput) { 170 this.generatorOutput = generatorOutput; 171 } 172 173 /*** 174 * This method read value of generatorOutput parameter 175 * @return value of parameter 176 */ 177 public String getGeneratorOutput() { 178 return this.generatorOutput; 179 } 180 181 /*** 182 * This method set value of sourceDatabase parameter 183 * @param sourceDatabase is value of parameter 184 */ 185 public void setSourceDatabase(String sourceDatabase) { 186 this.sourceDatabase = sourceDatabase; 187 } 188 189 /*** 190 * This method read value of sourceDatabase parameter 191 * @return value of parameter 192 */ 193 public String getSourceDatabase() { 194 return this.sourceDatabase; 195 } 196 197 /*** 198 * This method set value of sourceUser parameter 199 * @param sourceUser is value of parameter 200 */ 201 public void setSourceUser(String sourceUser) { 202 this.sourceUser = sourceUser; 203 } 204 205 /*** 206 * This method read value of sourceUser parameter 207 * @return value of parameter 208 */ 209 public String getSourceUser() { 210 return this.sourceUser; 211 } 212 213 /*** 214 * This method set value of sourcePassword parameter 215 * @param sourcePassword is value of parameter 216 */ 217 public void setSourcePassword(String sourcePassword) { 218 this.sourcePassword = sourcePassword; 219 } 220 221 /*** 222 * This method read value of sourcePassword parameter 223 * @return value of parameter 224 */ 225 public String getSourcePassword() { 226 return this.sourcePassword; 227 } 228 229 /*** 230 * This method set value of sourceType parameter 231 * @param sourceType is value of parameter 232 */ 233 public void setSourceType(String sourceType) { 234 this.sourceType = sourceType; 235 } 236 237 /*** 238 * This method read value of sourceType parameter 239 * @return value of parameter 240 */ 241 public String getSourceType() { 242 return this.sourceType; 243 } 244 245 /*** 246 * This method set value of sourceDriverName parameter 247 * @param sourceDriverName is value of parameter 248 */ 249 public void setSourceDriverName(String sourceDriverName) { 250 this.sourceDriverName = sourceDriverName; 251 } 252 253 /*** 254 * This method read value of sourceDriverName parameter 255 * @return value of parameter 256 */ 257 public String getSourceDriverName() { 258 return this.sourceDriverName; 259 } 260 261 /*** 262 * This method set value of targetDatabase parameter 263 * @param targetDatabase is value of parameter 264 */ 265 public void setTargetDatabase(String targetDatabase) { 266 this.targetDatabase = targetDatabase; 267 } 268 269 /*** 270 * This method read value of targetDatabase parameter 271 * @return value of parameter 272 */ 273 public String getTargetDatabase() { 274 return this.targetDatabase; 275 } 276 277 /*** 278 * This method set value of targetUser parameter 279 * @param targetUser is value of parameter 280 */ 281 public void setTargetUser(String targetUser) { 282 this.targetUser = targetUser; 283 } 284 285 /*** 286 * This method read value of targetDatabase parameter 287 * @return value of parameter 288 */ 289 public String getTargetUser() { 290 return this.targetUser; 291 } 292 293 /*** 294 * This method set value of targetPassword parameter 295 * @param targetPassword is value of parameter 296 */ 297 public void setTargetPassword(String targetPassword) { 298 this.targetPassword = targetPassword; 299 } 300 301 /*** 302 * This method read value of targetPassword parameter 303 * @return value of parameter 304 */ 305 public String getTargetPassword() { 306 return this.targetPassword; 307 } 308 309 /*** 310 * This method set value of targetType parameter 311 * @param targetType is value of parameter 312 */ 313 public void setTargetType(String targetType) { 314 this.targetType = targetType; 315 } 316 317 /*** 318 * This method read value of targetType parameter 319 * @return value of parameter 320 */ 321 public String getTargetType() { 322 return this.targetType; 323 } 324 325 /*** 326 * This method set value of targetDriverName parameter 327 * @param targetDriverName is value of parameter 328 */ 329 public void setTargetDriverName(String targetDriverName) { 330 this.targetDriverName = targetDriverName; 331 } 332 333 /*** 334 * This method read value of targetDriverName parameter 335 * @return value of parameter 336 */ 337 public String getTargetDriverName() { 338 return this.targetDriverName; 339 } 340 341 /*** 342 * This method set value of octopusHome parameter 343 * @param octopusHome is value of parameter 344 */ 345 public void setOctopusHome(String octopusHome) { 346 this.octopusHome = octopusHome; 347 } 348 349 /*** 350 * This method read value of octopusHome parameter 351 * @return value of parameter 352 */ 353 public String getOctopusHome() { 354 return this.octopusHome; 355 } 356 357 }

This page was automatically generated by Maven