001: /*
002: LoaderGenerator - tool for generated xml, sql and doml file needed for Octopus.
003:
004:
005: Copyright (C) 2003 Together
006:
007: This library is free software; you can redistribute it and/or
008: modify it under the terms of the GNU Lesser General Public
009: License as published by the Free Software Foundation; either
010: version 2.1 of the License, or (at your option) any later version.
011:
012: This library is distributed in the hope that it will be useful,
013: but WITHOUT ANY WARRANTY; without even the implied warranty of
014: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: Lesser General Public License for more details.
016:
017: You should have received a copy of the GNU Lesser General Public
018: License along with this library; if not, write to the Free Software
019: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: */
021:
022: package org.webdocwf.util.loader.wizard;
023:
024: import java.util.Vector;
025: import org.webdocwf.util.loader.generator.SearchXmlFile;
026: import org.webdocwf.util.loader.LoaderException;
027:
028: //import org.webdocwf.util.loader.Utils;
029:
030: /**
031: *
032: * LoaderGeneratorEntry class sets the input parameters
033: * @author Radoslav Dutina
034: * @version 1.0
035: */
036: public class OctopusGeneratorData {
037:
038: private static String[] logModes = { "none", "normal", "full" };
039: private String logMode = "";
040: private String logFileDirectory = "";
041: private String logFileName = "";
042:
043: private String sourceType = "";
044: private String targetType = "";
045: private String sourceDatabase = "";
046: private String targetDatabase = "";
047: private String sourceDriverName = "";
048: private String targetDriverName = "";
049: private String valueMode = "";
050: private String generatorOutput = "";
051: // private String generatedDoc = "";
052: private String packageName = "";
053: private String domlPath = "";
054: private String sourceUser = "";
055: private String sourcePassword = "";
056: private String targetUser = "";
057: private String targetPassword = "";
058: private String additonalPaths = "";
059: private String includeTableList = "";
060: private String confJarStructure = "";
061:
062: //Output Mode
063: //main
064: private String xmlGenerate = "true";
065: private String sqlGenerate = "true";
066: private String domlGenerate = "";
067: //for generate sql statements
068: private String sqlStmtDropTable = "true";
069: private String sqlStmtDropIntegrity = "true";
070: private String sqlStmtCreateTable = "true";
071: private String sqlStmtCreatePK = "true";
072: private String sqlStmtCreateFK = "true";
073: private String sqlStmtCreateIndex = "true";
074: //optimized modes
075: private String fullMode = "false";
076:
077: //for generate sql statements for all vendors
078: private String sqlStmtForAllVendors = "";
079: private static Vector targetVendors = new Vector();
080: private static Vector sourceVendors = new Vector();
081: private static Vector allVendorsPath = new Vector();
082: private static Vector sourceDrivers = new Vector();
083: private static Vector targetDrivers = new Vector();
084:
085: private static String[] targetDatabaseTypes;
086: private static String[] sourceDatabaseTypes;
087: private static String[] sourceDriverNames;
088: private static String[] targetDriverNames;
089: private static final String[] valueModes = { "copy" };
090:
091: /**
092: * Constuctor of LoaderGeneratorEntry class
093: * @throws LoaderException
094: */
095: public OctopusGeneratorData(String confJarStructure)
096: throws LoaderException {
097: SearchXmlFile searchXmlFile = new SearchXmlFile("relative",
098: "OctopusDBVendors.xml", confJarStructure);
099: this .confJarStructure = confJarStructure;
100: this .targetVendors = searchXmlFile.getAllVendors();
101: this .allVendorsPath = searchXmlFile.getAllVendorsPath();
102: setAllVendorsAndDrivers(targetVendors, allVendorsPath);
103: }
104:
105: /**
106: * This method set value of targetDrivers and sourceDrivers parameters
107: * @param all_Vendors is vector which represents all named vendors
108: * @param all_VendorsPath is vector which represents all vendors path
109: * @throws LoaderException
110: */
111: public void setAllVendorsAndDrivers(Vector all_Vendors,
112: Vector all_VendorsPath) throws LoaderException {
113: for (int i = 0; i < all_VendorsPath.size(); i++) {
114: Vector targetDriversTemp = new Vector();
115: Vector sourceDriversTemp = new Vector();
116: String path = all_VendorsPath.get(i).toString();
117: SearchXmlFile searchXmlFile = new SearchXmlFile("absolute",
118: path, confJarStructure);
119: Vector drivers = searchXmlFile.getAllDriversForVendor();
120: targetDriversTemp = (Vector) drivers.get(0);
121: sourceDriversTemp = (Vector) drivers.get(1);
122: String isSourceVendor = (String) drivers.get(2);
123:
124: if (isSourceVendor.equalsIgnoreCase("true")) {
125: if (!sourceVendors.contains(all_Vendors.get(i)))
126: sourceVendors.add(all_Vendors.get(i));
127: }
128:
129: boolean repeatTarget = false;
130: boolean repeatSource = false;
131: for (int j = 0; j < targetDriversTemp.size(); j++) {
132: String targetDriverName = targetDriversTemp.get(j)
133: .toString();
134: for (int k = 0; k < targetDrivers.size(); k++) {
135: if (targetDrivers.get(k).toString()
136: .equalsIgnoreCase(targetDriverName)) {
137: repeatTarget = true;
138: break;
139: }
140: }
141: if (repeatTarget == false)
142: this .targetDrivers.add(targetDriverName);
143: }
144: for (int j = 0; j < sourceDriversTemp.size(); j++) {
145: String sourceDriverName = sourceDriversTemp.get(j)
146: .toString();
147: for (int k = 0; k < sourceDrivers.size(); k++) {
148: if (sourceDrivers.get(k).toString()
149: .equalsIgnoreCase(sourceDriverName)) {
150: repeatSource = true;
151: break;
152: }
153: }
154: if (repeatSource == false)
155: this .sourceDrivers.add(sourceDriverName);
156: }
157: }
158: }
159:
160: /**
161: * This method read the value of targetDatabaseTypes parameter
162: * @return value of parameter
163: */
164: public static String[] getTargetDatabaseTypes() {
165: targetDatabaseTypes = new String[targetVendors.size()];
166: for (int i = 0; i < targetVendors.size(); i++) {
167: targetDatabaseTypes[i] = targetVendors.get(i).toString();
168: }
169: return targetDatabaseTypes;
170: }
171:
172: /**
173: * This method read the value of sourceDatabaseTypes parameter
174: * @return value of parameter
175: */
176: public static String[] getSourceDatabaseTypes() {
177: sourceDatabaseTypes = new String[sourceVendors.size()];
178: for (int i = 0; i < sourceVendors.size(); i++) {
179: sourceDatabaseTypes[i] = sourceVendors.get(i).toString();
180: }
181: return sourceDatabaseTypes;
182: }
183:
184: /**
185: * This method read the value of sourceDriverNames parameter
186: * @return value of parameter
187: */
188: public static String[] getSourceDriverNames() {
189: sourceDriverNames = new String[sourceDrivers.size()];
190: for (int i = 0; i < sourceDrivers.size(); i++) {
191: sourceDriverNames[i] = sourceDrivers.get(i).toString();
192: }
193: return sourceDriverNames;
194: }
195:
196: /**
197: * This method read the value of sourceDriverNames parameter
198: * @return value of parameter
199: */
200: public static String[] getTargetDriverNames() {
201: targetDriverNames = new String[targetDrivers.size()];
202: for (int i = 0; i < targetDrivers.size(); i++) {
203: targetDriverNames[i] = targetDrivers.get(i).toString();
204: }
205: return targetDriverNames;
206: }
207:
208: /**
209: * This method read the value of valueModes parameter
210: * @return value of parameter
211: */
212: public static String[] getValueModes() {
213: return valueModes;
214: }
215:
216: /**
217: * This method sets the additionalPaths parameter
218: * @param additonal_Paths is the value of paramter
219: */
220: public void setAdditionalPaths(String additonal_Paths) {
221: if (additonal_Paths.startsWith(";")) {
222: if (additonal_Paths.endsWith(";"))
223: additonalPaths = additonal_Paths.substring(1,
224: additonal_Paths.length() - 1);
225: else
226: additonalPaths = additonal_Paths.substring(1);
227: } else if (additonal_Paths.endsWith(";")) {
228: additonalPaths = additonal_Paths.substring(0,
229: additonal_Paths.length() - 1);
230: } else {
231: additonalPaths = additonal_Paths;
232: }
233: }
234:
235: /**
236: * This method read value of logMod parameter
237: * @return value of parameter
238: */
239: public static String[] getLogModes() {
240: return logModes;
241: }
242:
243: /**
244: * This mehod set value of logMode parameter
245: * @param log_Mode is value of parameter
246: */
247: public void setLogMode(String log_Mode) {
248: this .logMode = log_Mode;
249: }
250:
251: /**
252: * This method read value of logMods parameter
253: * @return value of parameter
254: */
255: public String getLogMode() {
256: return logMode;
257: }
258:
259: /**
260: * This method set value of logFileDirectory parameter
261: * @param log_FileDirectory is value of parameter
262: */
263: public void setLogFileDir(String log_FileDirectory) {
264: this .logFileDirectory = log_FileDirectory;
265: }
266:
267: /**
268: * This method read value of logFileDirectory parameter
269: * @return value of parameter
270: */
271: public String getLogFileDir() {
272: return this .logFileDirectory;
273: }
274:
275: /**
276: * This method set value of logFileName parameter
277: * @param log_FileName is value of parameter
278: */
279: public void setLogFileName(String log_FileName) {
280: this .logFileName = log_FileName;
281: }
282:
283: /**
284: * This method read value of logFileName parameter
285: * @return value of parameter
286: */
287: public String getLogFileName() {
288: return this .logFileName;
289: }
290:
291: /**
292: * This method read the value of additonalPaths parameter
293: * @return value of parameter
294: */
295: public String getAdditionalPaths() {
296: return additonalPaths;
297: }
298:
299: /**
300: * This method sets the value of sourceType parameter
301: * @param source_Type is value of parameter
302: */
303: public void setSourceType(String source_Type) {
304: sourceType = source_Type;
305: }
306:
307: /**
308: * This method read value of sourceType parameter
309: * @return value of parameter
310: */
311: public String getSourceType() {
312: return sourceType;
313: }
314:
315: /**
316: * This method sets value of targetType parameter
317: * @param target_Type is value of parameter
318: */
319: public void setTargetType(String target_Type) {
320: targetType = target_Type;
321: }
322:
323: /**
324: * This method read value of targetType parameter
325: * @return value of parameter
326: */
327: public String getTargetType() {
328: return targetType;
329: }
330:
331: /**
332: * This method sets value of sourceDatabase parameter
333: * @param source_Database is value of parameter
334: */
335: public void setSourceDatabase(String source_Database) {
336: sourceDatabase = source_Database;
337: }
338:
339: /**
340: * This method read value of sourceDatabase parameter
341: * @return value of parameter
342: */
343: public String getSourceDatabase() {
344: return sourceDatabase;
345: }
346:
347: /**
348: * This method sets value of targetDatabase parameter
349: * @param target_Database is value of parameter
350: */
351: public void setTargetDatabase(String target_Database) {
352: targetDatabase = target_Database;
353: }
354:
355: /**
356: * This method read value of targetDatabase parameter
357: * @return value of parameter
358: */
359: public String getTargetDatabase() {
360: return targetDatabase;
361: }
362:
363: /**
364: * This method sets value of valueMode parameter
365: * @param value_Mode is value of parameter
366: */
367: public void setValueMode(String value_Mode) {
368: valueMode = value_Mode;
369: }
370:
371: /**
372: * This method read value of valueMode parameter
373: * @return value of parameter
374: */
375: public String getValueMode() {
376: return valueMode;
377: }
378:
379: /**
380: * This method sets value of generatorOutput parameter
381: * @param generator_Output is value of parameter
382: */
383: public void setGeneratorOutput(String generator_Output) {
384: generatorOutput = generator_Output;
385: }
386:
387: /**
388: * This method read value of generatorOutput parameter
389: * @return value of parameter
390: */
391: public String getGeneratorOutput() {
392: return generatorOutput;
393: }
394:
395: /**
396: * This method sets value of sourceUser parameter
397: * @param source_User is value of parameter
398: */
399: public void setSourceUser(String source_User) {
400: sourceUser = source_User;
401: }
402:
403: /**
404: * This method read value of sourceUser parameter
405: * @return value of parameter
406: */
407: public String getSourceUser() {
408: return sourceUser;
409: }
410:
411: /**
412: * This method sets value of sourcePassword parameter
413: * @param source_Password is value of paramter
414: */
415: public void setSourcePassword(String source_Password) {
416: sourcePassword = source_Password;
417: }
418:
419: /**
420: * This method read value of sourcePassword parameter
421: * @return value of parameter
422: */
423: public String getSourcePassword() {
424: return sourcePassword;
425: }
426:
427: /**
428: * This method sets value of targetUser parameter
429: * @param target_User is value of parameter
430: */
431: public void setTargetUser(String target_User) {
432: targetUser = target_User;
433: }
434:
435: /**
436: * This method read value of targetUser parameter
437: * @return value of parameter
438: */
439: public String getTargetUser() {
440: return targetUser;
441: }
442:
443: /**
444: * This method sets value of targetPassword parameter
445: * @param target_Password is value of parameter
446: */
447: public void setTargetPassword(String target_Password) {
448: targetPassword = target_Password;
449: }
450:
451: /**
452: * This method read value of targetPassword parameter
453: * @return value of parameter
454: */
455: public String getTargetPassword() {
456: return targetPassword;
457: }
458:
459: /**
460: * This method read value of generatedDoc parameter
461: * @return value of parameter
462: */
463: // public String getGeneratedDoc() {
464: // return generatedDoc;
465: // }
466: /**
467: * This method sets value of packageName parameter
468: * @param package_Name is value of parameter
469: */
470: public void setPackageName(String package_Name) {
471: packageName = package_Name;
472: }
473:
474: /**
475: * This method read value of packageName parameter
476: * @return value of parameter
477: */
478: public String getPackageName() {
479: return packageName;
480: }
481:
482: /**
483: * This method sets value of domlPath parameter
484: * @param doml_Path is value of parameter
485: */
486: public void setDomlPath(String doml_Path) {
487: domlPath = doml_Path;
488: }
489:
490: /**
491: * This method read value of domlPath parameter
492: * @return value of parameter
493: */
494: public String getDomlPath() {
495: return domlPath;
496: }
497:
498: /**
499: * This method sets value of sourceDriverName parameter
500: * @param source_DriverName is value of parameter
501: */
502: public void setSourceDriverName(String source_DriverName) {
503: sourceDriverName = source_DriverName;
504: }
505:
506: /**
507: * This method read value of sourceDriverName parameter
508: * @return value of parameter
509: */
510: public String getSourceDriverName() {
511: return sourceDriverName;
512: }
513:
514: /**
515: * This method sets value of targetDriverName parameter
516: * @param target_DriverName is value of parameter
517: */
518: public void setTargetDriverName(String target_DriverName) {
519: targetDriverName = target_DriverName;
520: }
521:
522: /**
523: * This method read value of targetDriverName parameter
524: * @return value of parameter
525: */
526: public String getTargetDriverName() {
527: return targetDriverName;
528: }
529:
530: /**
531: * This method sets value of sqlStmtDropTable parameter
532: * @param sqlStmt_DropTable is value of parameter
533: */
534: public void setSqlStmtDropTable(String sqlStmt_DropTable) {
535: sqlStmtDropTable = sqlStmt_DropTable;
536: }
537:
538: /**
539: * This method read value of sqlStmtDropTable parameter
540: * @return value of parameter
541: */
542: public String getSqlStmtDropTable() {
543: return sqlStmtDropTable;
544: }
545:
546: /**
547: * This method sets value of sqlStmtDropIntegrity parameter
548: * @param sqlStmt_DropIntegrity is value of parameter
549: */
550: public void setSqlStmtDropIntegrity(String sqlStmt_DropIntegrity) {
551: sqlStmtDropIntegrity = sqlStmt_DropIntegrity;
552: }
553:
554: /**
555: * This method read value of sqlStmtDropIntegrity parameter
556: * @return value of parameter
557: */
558: public String getSqlStmtDropIntegrity() {
559: return sqlStmtDropIntegrity;
560: }
561:
562: /**
563: * This method sets value of sqlStmtCreateTable parameter
564: * @param sqlStmt_CreateTable is value of parameter
565: */
566: public void setSqlStmtCreateTable(String sqlStmt_CreateTable) {
567: sqlStmtCreateTable = sqlStmt_CreateTable;
568: }
569:
570: /**
571: * This method read value of sqlStmtCreateTable parameter
572: * @return value of parameter
573: */
574: public String getSqlStmtCreateTable() {
575: return sqlStmtCreateTable;
576: }
577:
578: /**
579: * This method sets value of sqlStmtCreatePK parameter
580: * @param sqlStmt_CreatePK is value of parameter
581: */
582: public void setSqlStmtCreatePK(String sqlStmt_CreatePK) {
583: sqlStmtCreatePK = sqlStmt_CreatePK;
584: }
585:
586: /**
587: * This method read value of sqlStmtCreatePK parameter
588: * @return value of parameter
589: */
590: public String getSqlStmtCreatePK() {
591: return sqlStmtCreatePK;
592: }
593:
594: /**
595: * This method sets value of sqlStmtCreateFK parameter
596: * @param sqlStmt_CreateFK is value of parameter
597: */
598: public void setSqlStmtCreateFK(String sqlStmt_CreateFK) {
599: sqlStmtCreateFK = sqlStmt_CreateFK;
600: }
601:
602: /**
603: * This method read value of sqlStmtCreateFK parameter
604: * @return value of parameter
605: */
606: public String getSqlStmtCreateFK() {
607: return sqlStmtCreateFK;
608: }
609:
610: /**
611: * This method sets value of sqlStmtCreateIndex parameter
612: * @param sqlStmt_CreateIndex is value of parameter
613: */
614: public void setSqlStmtCreateIndex(String sqlStmt_CreateIndex) {
615: sqlStmtCreateIndex = sqlStmt_CreateIndex;
616: }
617:
618: /**
619: * This method read value of sqlStmtCreateIndex parameter
620: * @return value of parameter
621: */
622: public String getSqlStmtCreateIndex() {
623: return sqlStmtCreateIndex;
624: }
625:
626: /**
627: * This method sets value of sqlStmtForAllVendors parameter
628: * @param sqlStmt_ForAllVendors is value of parameter
629: */
630: public void setSqlStmtForAllVendors(String sqlStmt_ForAllVendors) {
631: sqlStmtForAllVendors = sqlStmt_ForAllVendors;
632: }
633:
634: /**
635: * This method read value of sqlStmtForAllVendors parameter
636: * @return value of parameter
637: */
638: public String getSqlStmtForAllVendors() {
639: return sqlStmtForAllVendors;
640: }
641:
642: /**
643: * This method read value of xmlGenerate parameter
644: * @return value of parameter
645: */
646: public String getXmlGenerate() {
647: return xmlGenerate;
648: }
649:
650: /**
651: * This method sets value of xmlenerate parameter
652: * @param xml_Generate is value of parameter
653: */
654: public void setXmlGenerate(String xml_Generate) {
655: xmlGenerate = xml_Generate;
656: }
657:
658: /**
659: * This method read value of sqlGenerate parameter
660: * @return value of parameter
661: */
662: public String getSqlGenerate() {
663: return sqlGenerate;
664: }
665:
666: /**
667: * This method sets value of sqlGenerate parameter
668: * @param sql_Generate is value of parameter
669: */
670: public void setSqlGenerate(String sql_Generate) {
671: sqlGenerate = sql_Generate;
672: }
673:
674: /**
675: * This method read value of domlGenerate parameter
676: * @return value of parameter
677: */
678: public String getDomlGenerate() {
679: return domlGenerate;
680: }
681:
682: /**
683: * This method sets value of domlGenerate parameter
684: * @param doml_Generate is value of parameter
685: */
686: public void setDomlGenerate(String doml_Generate) {
687: domlGenerate = doml_Generate;
688: }
689:
690: /**
691: * This method set value of fullMode parameter
692: * @param full_mode is value of parameter
693: */
694: public void setFullMode(String full_mode) {
695: fullMode = full_mode;
696: }
697:
698: /**
699: * This methos read value of fullMode parameter
700: * @return value of parameter
701: */
702: public String getFullMode() {
703: return fullMode;
704: }
705:
706: /**
707: * This method set value of includeTableList parameter
708: * @param incude_table_list is value of parameter
709: */
710: public void setIncludeTableList(String incude_table_list) {
711: includeTableList = incude_table_list;
712: }
713:
714: /**
715: * This methos read value of includeTableList parameter
716: * @return value of parameter
717: */
718: public String getIncludeTableList() {
719: return includeTableList;
720: }
721:
722: /**
723: * This method set value of confJarStructure parameter
724: * @param conf_jar_structure is value of parameter
725: */
726: public void setConfJarStructure(String conf_jar_structure) {
727: confJarStructure = conf_jar_structure;
728: }
729:
730: /**
731: * This methos read value of confJarStructure parameter
732: * @return value of parameter
733: */
734: public String getConfJarStructure() {
735: return confJarStructure;
736: }
737:
738: public String toConfString() {
739: String retVal = "";
740: retVal += "\nGenerator.AdditionalPaths="
741: + this .getAdditionalPaths();
742: retVal += "\nGenerator.ConfJarStructure="
743: + this .getConfJarStructure();
744: retVal += "\nGenerator.DomlGenerate=" + this .getDomlGenerate();
745: retVal += "\nGenerator.DomlPath=" + this .getDomlPath();
746: retVal += "\nGenerator.FullMode=" + this .getFullMode();
747: retVal += "\nGenerator.GeneratorOutput="
748: + this .getGeneratorOutput();
749: retVal += "\nGenerator.IncludeTableList="
750: + this .getIncludeTableList();
751: retVal += "\nGenerator.PackageName=" + this .getPackageName();
752: retVal += "\nGenerator.SourceDatabase="
753: + this .getSourceDatabase();
754: retVal += "\nGenerator.SourceDriverName="
755: + this .getSourceDriverName();
756: retVal += "\nGenerator.SourcePassword="
757: + this .getSourcePassword();
758: retVal += "\nGenerator.SourceType=" + this .getSourceType();
759: retVal += "\nGenerator.SourceUser=" + this .getSourceUser();
760: retVal += "\nGenerator.SqlGenerate=" + this .getSqlGenerate();
761: retVal += "\nGenerator.SqlStmtCreateFK="
762: + this .getSqlStmtCreateFK();
763: retVal += "\nGenerator.SqlStmtCreateIndex="
764: + this .getSqlStmtCreateIndex();
765: retVal += "\nGenerator.SqlStmtCreatePK="
766: + this .getSqlStmtCreatePK();
767: retVal += "\nGenerator.SqlStmtCreateTable="
768: + this .getSqlStmtCreateTable();
769: retVal += "\nGenerator.SqlStmtDropIntegrity="
770: + this .getSqlStmtDropIntegrity();
771: retVal += "\nGenerator.SqlStmtDropTable="
772: + this .getSqlStmtDropTable();
773: retVal += "\nGenerator.SqlStmtForAllVendors="
774: + this .getSqlStmtForAllVendors();
775: retVal += "\nGenerator.TargetDatabase="
776: + this .getTargetDatabase();
777: retVal += "\nGenerator.TargetDriverName="
778: + this .getTargetDriverName();
779:
780: retVal += "\nGenerator.TargetPassword="
781: + this .getTargetPassword();
782: retVal += "\nGenerator.TargetType=" + this .getTargetType();
783: retVal += "\nGenerator.TargetUser=" + this .getTargetUser();
784: retVal += "\nGenerator.ValueMode=" + this .getValueMode();
785: retVal += "\nGenerator.XmlGenerate=" + this .getXmlGenerate();
786:
787: retVal += "\nGenerator.LogMode=" + this .getLogMode();
788: retVal += "\nGenerator.LogFileName=" + this .getLogFileName();
789: retVal += "\nGenerator.LogFileDir=" + this.getLogFileDir();
790: return retVal;
791: }
792:
793: }
|