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.generator;
023:
024: import java.util.Vector;
025:
026: import org.webdocwf.util.loader.LoaderException;
027: import org.webdocwf.util.loader.logging.Logger;
028: import org.webdocwf.util.loader.logging.StandardLogger;
029:
030: /**
031: * GenerateSqlForAllVendors class is used for generating all sql statements for
032: * all named database Vendors
033: * @author Radoslav Dutina
034: * @version 1.0
035: */
036: public class GenerateSqlForAllVendors {
037:
038: private Logger logger;
039:
040: /**
041: * Public constructor of GenerateSqlForAllVendors class. Construct object with an
042: * associated parameters
043: * @param generatorParameters defines object of InputParameters class
044: * @throws LoaderException
045: */
046:
047: public GenerateSqlForAllVendors(InputParameters generatorParameters)
048: throws LoaderException {
049:
050: setLogger();
051: this .logger.write("normal",
052: "GenerateSqlForAllVendors is started.");
053: generateParameters(generatorParameters);
054: this .logger.write("normal",
055: "GenerateSqlForAllVendors is finished.");
056: }
057:
058: /**
059: * this method will genarate files for all vendors
060: * @param generatorParameters
061: * @throws LoaderException
062: */
063: private void generateParameters(InputParameters generatorParameters)
064: throws LoaderException {
065: Vector allVendors = generatorParameters.getAllVendors();
066:
067: try {
068: for (int i = 0; i < allVendors.size(); i++) {
069: String vendorName = allVendors.get(i).toString();
070:
071: //System.out.println("Working.... SQL Statements for " + vendorName + " Vendor");
072: //if (this.logger != null) {
073: this .logger.write("normal",
074: "Working.... SQL Statements for " + vendorName
075: + " Vendor");
076: //}
077: //BufferOctopusClass.getInstance().writeToBuffer("Working.... SQL Statements for " + vendorName + " Vendor");
078:
079: generatorParameters.setTargetDriverName("");
080: generatorParameters.setTargetType(vendorName);
081: generatorParameters.setSqlToGenerate();
082: String generatorOutputOld = generatorParameters
083: .getGeneratorOutput();
084: if (generatorOutputOld.equalsIgnoreCase("")
085: || generatorOutputOld == null)
086: generatorParameters
087: .setGeneratorOutput("SQLForAllVendors/"
088: + vendorName);
089: else
090: generatorParameters
091: .setGeneratorOutput(generatorOutputOld
092: + "/SQLForAllVendors/" + vendorName);
093:
094: if (generatorParameters.getDomlPath() == null
095: || generatorParameters.getDomlPath()
096: .equalsIgnoreCase("")) {
097: CreateIncludeFiles createIncludeFiles = new CreateIncludeFiles(
098: generatorParameters);
099: } else {
100: CreateIncludeDomlFiles createIncludeDomlFiles = new CreateIncludeDomlFiles(
101: generatorParameters);
102: }
103: if (generatorParameters.getGenerateXml()
104: .equalsIgnoreCase("true")) {
105: LoadJobWriter loadJobWriter = new LoadJobWriter(
106: generatorParameters);
107: }
108: generatorParameters
109: .setGeneratorOutput(generatorOutputOld);
110: }
111: } catch (LoaderException e) {
112:
113: LoaderException le = new LoaderException(
114: "Error while generate sql statements for all vendors.",
115: e);
116: //if (this.logger != null) {
117: this .logger.write("full",
118: "Error while generate sql statements for all vendors."
119: + le.getStackTraceAsString());
120: //}
121: throw le;
122: }
123: }
124:
125: /**
126: * This method will set logger object
127: * @param logger
128: */
129: private void setLogger() {
130: this.logger = StandardLogger.getCentralLogger();
131: }
132: }
|