KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > webdocwf > util > loader > generator > GenerateSqlForAllVendors


1 /*
2 LoaderGenerator - tool for generated xml, sql and doml file needed for Octopus.
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.generator;
23
24 import java.util.Vector JavaDoc;
25
26 import org.webdocwf.util.loader.LoaderException;
27 import org.webdocwf.util.loader.logging.Logger;
28 import org.webdocwf.util.loader.logging.StandardLogger;
29
30 /**
31  * GenerateSqlForAllVendors class is used for generating all sql statements for
32  * all named database Vendors
33  * @author Radoslav Dutina
34  * @version 1.0
35  */

36 public class GenerateSqlForAllVendors {
37
38     private Logger logger;
39
40     /**
41      * Public constructor of GenerateSqlForAllVendors class. Construct object with an
42      * associated parameters
43      * @param generatorParameters defines object of InputParameters class
44      * @throws LoaderException
45      */

46
47     public GenerateSqlForAllVendors(InputParameters generatorParameters) throws LoaderException {
48
49         setLogger();
50         this.logger.write("normal", "GenerateSqlForAllVendors is started.");
51         generateParameters(generatorParameters);
52         this.logger.write("normal", "GenerateSqlForAllVendors is finished.");
53     }
54     /**
55      * this method will genarate files for all vendors
56      * @param generatorParameters
57      * @throws LoaderException
58      */

59     private void generateParameters(InputParameters generatorParameters) throws LoaderException {
60         Vector JavaDoc allVendors = generatorParameters.getAllVendors();
61
62         try {
63             for (int i = 0; i < allVendors.size(); i++) {
64                 String JavaDoc vendorName = allVendors.get(i).toString();
65
66                 //System.out.println("Working.... SQL Statements for " + vendorName + " Vendor");
67
//if (this.logger != null) {
68
this.logger.write("normal", "Working.... SQL Statements for " + vendorName + " Vendor");
69                 //}
70
//BufferOctopusClass.getInstance().writeToBuffer("Working.... SQL Statements for " + vendorName + " Vendor");
71

72                 generatorParameters.setTargetDriverName("");
73                 generatorParameters.setTargetType(vendorName);
74                 generatorParameters.setSqlToGenerate();
75                 String JavaDoc generatorOutputOld = generatorParameters.getGeneratorOutput();
76                 if (generatorOutputOld.equalsIgnoreCase("") || generatorOutputOld == null)
77                     generatorParameters.setGeneratorOutput("SQLForAllVendors/" + vendorName);
78                 else
79                     generatorParameters.setGeneratorOutput(generatorOutputOld + "/SQLForAllVendors/" + vendorName);
80
81                 if (generatorParameters.getDomlPath() == null || generatorParameters.getDomlPath().equalsIgnoreCase("")) {
82                     CreateIncludeFiles createIncludeFiles = new CreateIncludeFiles(generatorParameters);
83                 } else {
84                     CreateIncludeDomlFiles createIncludeDomlFiles = new CreateIncludeDomlFiles(generatorParameters);
85                 }
86                 if (generatorParameters.getGenerateXml().equalsIgnoreCase("true")) {
87                     LoadJobWriter loadJobWriter = new LoadJobWriter(generatorParameters);
88                 }
89                 generatorParameters.setGeneratorOutput(generatorOutputOld);
90             }
91         } catch (LoaderException e) {
92
93             LoaderException le = new LoaderException("Error while generate sql statements for all vendors.", e);
94             //if (this.logger != null) {
95
this.logger.write("full", "Error while generate sql statements for all vendors." + le.getStackTraceAsString());
96             //}
97
throw le;
98         }
99     }
100     /**
101        * This method will set logger object
102        * @param logger
103        */

104     private void setLogger() {
105         this.logger = StandardLogger.getCentralLogger();
106     }
107 }
Popular Tags