1 /*
2 Restore - class which enables you to restore database of you're choice.
3
4
5 Copyright (C) 2003 Together
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
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 /***
30 * Restore class is used for restore database of your choice.
31 * @author Radoslav Dutina
32 * @version 1.0
33 */
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 //optimized modes
58 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 /***
68 * Construct object Restore with associated parameters.
69 * @param sourceDatabaseType defines type of source database
70 * @param sourceDatabase defines url to source database
71 * @param generatorOutput defines output directory
72 * @param sourceDriverName defines name of source driver name
73 * @param targetDriverName defines name of target driver name
74 * @param targetDatabase defines url to target database
75 * @param targetDatabaseType defines type of target database
76 * @param sourceUser defines user name for source database
77 * @param sourcePassword defines user password for source database
78 * @param targetUser defines user name for target database
79 * @param targetPassword defines user password for target database
80 * @param includeTableList defines the list of tables which you want to include
81 */
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 //optimized modes
111 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 { //Octopus loader
137 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 /***
156 *
157 * @param argv represents input parameters
158 */
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 /***
221 * This method set value of confJarStructure parameter
222 * @param confJarStructure is value of parameter
223 */
224 public void setConfJarStructure(String confJarStructure) {
225 this.confJarStructure = confJarStructure;
226 }
227
228 /***
229 * This method read value of confJarStructure parameter
230 * @return value of parameter
231 */
232 public String getConfJarStructure() {
233 return this.confJarStructure;
234 }
235
236 /***
237 * This method set value of generatorOutput parameter
238 * @param generatorOutput is value of parameter
239 */
240 public void setGeneratorOutput(String generatorOutput) {
241 this.generatorOutput = generatorOutput;
242 }
243
244 /***
245 * This method read value of generatorOutput parameter
246 * @return value of parameter
247 */
248 public String getGeneratorOutput() {
249 return this.generatorOutput;
250 }
251
252 /***
253 * This method set value of sourceDatabase parameter
254 * @param sourceDatabase is value of parameter
255 */
256 public void setSourceDatabase(String sourceDatabase) {
257 this.sourceDatabase = sourceDatabase;
258 }
259
260 /***
261 * This method read value of sourceDatabase parameter
262 * @return value of parameter
263 */
264 public String getSourceDatabase() {
265 return this.sourceDatabase;
266 }
267
268 /***
269 * This method set value of sourceUser parameter
270 * @param sourceUser is value of parameter
271 */
272 public void setSourceUser(String sourceUser) {
273 this.sourceUser = sourceUser;
274 }
275
276 /***
277 * This method read value of sourceUser parameter
278 * @return value of parameter
279 */
280 public String getSourceUser() {
281 return this.sourceUser;
282 }
283
284 /***
285 * This method set value of sourcePassword parameter
286 * @param sourcePassword is value of parameter
287 */
288 public void setSourcePassword(String sourcePassword) {
289 this.sourcePassword = sourcePassword;
290 }
291
292 /***
293 * This method read value of sourcePassword parameter
294 * @return value of parameter
295 */
296 public String getSourcePassword() {
297 return this.sourcePassword;
298 }
299
300 /***
301 * This method set value of sourceDatabaseType parameter
302 * @param sourceDatabaseType is value of parameter
303 */
304 public void setSourceDatabaseType(String sourceDatabaseType) {
305 this.sourceDatabaseType = sourceDatabaseType;
306 }
307
308 /***
309 * This method read value of sourceDatabaseType parameter
310 * @return value of parameter
311 */
312 public String getSourceDatabaseType() {
313 return this.sourceDatabaseType;
314 }
315
316 /***
317 * This method set value of sourceDriverName parameter
318 * @param sourceDriverName is value of parameter
319 */
320 public void setSourceDriverName(String sourceDriverName) {
321 this.sourceDriverName = sourceDriverName;
322 }
323
324 /***
325 * This method read value of sourceDriverName parameter
326 * @return value of parameter
327 */
328 public String getSourceDriverName() {
329 return this.sourceDriverName;
330 }
331
332 /***
333 * This method set value of targetDatabase parameter
334 * @param targetDatabase is value of parameter
335 */
336 public void setTargetDatabase(String targetDatabase) {
337 this.targetDatabase = targetDatabase;
338 }
339
340 /***
341 * This method read value of targetDatabase parameter
342 * @return value of parameter
343 */
344 public String getTargetDatabase() {
345 return this.targetDatabase;
346 }
347
348 /***
349 * This method set value of targetUser parameter
350 * @param targetUser is value of parameter
351 */
352 public void setTargetUser(String targetUser) {
353 this.targetUser = targetUser;
354 }
355
356 /***
357 * This method read value of targetDatabase parameter
358 * @return value of parameter
359 */
360 public String getTargetUser() {
361 return this.targetUser;
362 }
363
364 /***
365 * This method set value of targetPassword parameter
366 * @param targetPassword is value of parameter
367 */
368 public void setTargetPassword(String targetPassword) {
369 this.targetPassword = targetPassword;
370 }
371
372 /***
373 * This method read value of targetPassword parameter
374 * @return value of parameter
375 */
376 public String getTargetPassword() {
377 return this.targetPassword;
378 }
379
380 /***
381 * This method set value of targetDatabaseType parameter
382 * @param targetDatabaseType is value of parameter
383 */
384 public void setTargetDatabaseType(String targetDatabaseType) {
385 this.targetDatabaseType = targetDatabaseType;
386 }
387
388 /***
389 * This method read value of targetDatabaseType parameter
390 * @return value of parameter
391 */
392 public String getTargetDatabaseType() {
393 return this.targetDatabaseType;
394 }
395
396 /***
397 * This method set value of targetDriverName parameter
398 * @param targetDriverName is value of parameter
399 */
400 public void setTargetDriverName(String targetDriverName) {
401 this.targetDriverName = targetDriverName;
402 }
403
404 /***
405 * This method read value of targetDriverName parameter
406 * @return value of parameter
407 */
408 public String getTargetDriverName() {
409 return this.targetDriverName;
410 }
411
412
413
414 }
This page was automatically generated by Maven