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 * BackupTask Task class extends jakarta-ant Task class and uses to start
28 * @author Radoslav Dutina
29 * @version 1.0
30 */
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 //sql statements
50 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 //xml files
59 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 /***
72 *
73 * @throws org.apache.tools.ant.BuildException
74 */
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 { //for All Vendors
92 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 { //for specific vendor
108 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 { //Octopus loader
129 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 /***
149 * This method set value of confJarStructure parameter
150 * @param confJarStructure is value of parameter
151 */
152 public void setConfJarStructure(String confJarStructure) {
153 this.confJarStructure = confJarStructure;
154 }
155
156 /***
157 * This method read value of confJarStructure parameter
158 * @return value of parameter
159 */
160 public String getConfJarStructure() {
161 return this.confJarStructure;
162 }
163
164
165 /***
166 * This method set value of includeTableList parameter
167 * @param includeTableList is value of parameter
168 */
169 public void setIncludeTableList(String includeTableList) {
170 this.includeTableList = includeTableList;
171 }
172
173 /***
174 * This method read value of includeTableList parameter
175 * @return value of parameter
176 */
177 public String getIncludeTableList() {
178 return this.includeTableList;
179 }
180
181
182 /***
183 * This method set value of generatorOutput parameter
184 * @param generatorOutput is value of parameter
185 */
186 public void setGeneratorOutput(String generatorOutput) {
187 this.generatorOutput = generatorOutput;
188 }
189
190 /***
191 * This method read value of generatorOutput parameter
192 * @return value of parameter
193 */
194 public String getGeneratorOutput() {
195 return this.generatorOutput;
196 }
197
198 /***
199 * This method set value of sourceDatabase parameter
200 * @param sourceDatabase is value of parameter
201 */
202 public void setSourceDatabase(String sourceDatabase) {
203 this.sourceDatabase = sourceDatabase;
204 }
205
206 /***
207 * This method read value of sourceDatabase parameter
208 * @return value of parameter
209 */
210 public String getSourceDatabase() {
211 return this.sourceDatabase;
212 }
213
214 /***
215 * This method set value of sourceUser parameter
216 * @param sourceUser is value of parameter
217 */
218 public void setSourceUser(String sourceUser) {
219 this.sourceUser = sourceUser;
220 }
221
222 /***
223 * This method read value of sourceUser parameter
224 * @return value of parameter
225 */
226 public String getSourceUser() {
227 return this.sourceUser;
228 }
229
230 /***
231 * This method set value of sourcePassword parameter
232 * @param sourcePassword is value of parameter
233 */
234 public void setSourcePassword(String sourcePassword) {
235 this.sourcePassword = sourcePassword;
236 }
237
238 /***
239 * This method read value of sourcePassword parameter
240 * @return value of parameter
241 */
242 public String getSourcePassword() {
243 return this.sourcePassword;
244 }
245
246 /***
247 * This method set value of sourceType parameter
248 * @param sourceType is value of parameter
249 */
250 public void setSourceType(String sourceType) {
251 this.sourceType = sourceType;
252 }
253
254 /***
255 * This method read value of sourceType parameter
256 * @return value of parameter
257 */
258 public String getSourceType() {
259 return this.sourceType;
260 }
261
262 /***
263 * This method set value of sourceDriverName parameter
264 * @param sourceDriverName is value of parameter
265 */
266 public void setSourceDriverName(String sourceDriverName) {
267 this.sourceDriverName = sourceDriverName;
268 }
269
270 /***
271 * This method read value of sourceDriverName parameter
272 * @return value of parameter
273 */
274 public String getSourceDriverName() {
275 return this.sourceDriverName;
276 }
277
278 /***
279 * This method set value of targetDatabase parameter
280 * @param targetDatabase is value of parameter
281 */
282 public void setTargetDatabase(String targetDatabase) {
283 this.targetDatabase = targetDatabase;
284 }
285
286 /***
287 * This method read value of targetDatabase parameter
288 * @return value of parameter
289 */
290 public String getTargetDatabase() {
291 return this.targetDatabase;
292 }
293
294 /***
295 * This method set value of targetUser parameter
296 * @param targetUser is value of parameter
297 */
298 public void setTargetUser(String targetUser) {
299 this.targetUser = targetUser;
300 }
301
302 /***
303 * This method read value of targetDatabase parameter
304 * @return value of parameter
305 */
306 public String getTargetUser() {
307 return this.targetUser;
308 }
309
310 /***
311 * This method set value of targetPassword parameter
312 * @param targetPassword is value of parameter
313 */
314 public void setTargetPassword(String targetPassword) {
315 this.targetPassword = targetPassword;
316 }
317
318 /***
319 * This method read value of targetPassword parameter
320 * @return value of parameter
321 */
322 public String getTargetPassword() {
323 return this.targetPassword;
324 }
325
326 /***
327 * This method set value of targetType parameter
328 * @param targetType is value of parameter
329 */
330 public void setTargetType(String targetType) {
331 this.targetType = targetType;
332 }
333
334 /***
335 * This method read value of targetType parameter
336 * @return value of parameter
337 */
338 public String getTargetType() {
339 return this.targetType;
340 }
341
342 /***
343 * This method set value of targetDriverName parameter
344 * @param targetDriverName is value of parameter
345 */
346 public void setTargetDriverName(String targetDriverName) {
347 this.targetDriverName = targetDriverName;
348 }
349
350 /***
351 * This method read value of targetDriverName parameter
352 * @return value of parameter
353 */
354 public String getTargetDriverName() {
355 return this.targetDriverName;
356 }
357
358 /***
359 * This method set value of octopusHome parameter
360 * @param octopusHome is value of parameter
361 */
362 public void setOctopusHome(String octopusHome) {
363 this.octopusHome = octopusHome;
364 }
365
366 /***
367 * This method read value of octopusHome parameter
368 * @return value of parameter
369 */
370 public String getOctopusHome() {
371 return this.octopusHome;
372 }
373
374 }
This page was automatically generated by Maven