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 javax.xml.parsers.DocumentBuilder;
25 import javax.xml.parsers.DocumentBuilderFactory;
26 import javax.xml.parsers.ParserConfigurationException;
27
28 import org.w3c.dom.Document;
29 import org.w3c.dom.Element;
30
31 import org.webdocwf.util.loader.LoaderException;
32 import org.webdocwf.util.loader.logging.Logger;
33 import org.webdocwf.util.loader.logging.StandardLogger;
34
35 /***
36 * CreateIncludeDomlFiles class creates Xml(ImportDefinition.xml) and Sql( CreateTables.sql,
37 * CreateIntegrity.sql, CreateOisAdminData.sql, CreatePrimary.sql and CreateIndex.sql) files,
38 * if the input data is doml file.
39 * @author Radoslav Dutina
40 * @version 1.0
41 */
42 public class CreateIncludeDomlFiles {
43
44 private Document document;
45 private Logger logger;
46 private InputParameters generatorParameters;
47
48 /***
49 * Construct object CreateIncludeDomlFiles with associated parameter.
50 * @param generatorParameters represents the references to InputParameter object.
51 * @throws LoaderException
52 */
53 public CreateIncludeDomlFiles(InputParameters generatorParameters) throws LoaderException {
54
55 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
56 try {
57 setLogger();
58 this.logger.write("normal", "CreateIncludeDomlFiles is started.");
59 createIncludeDomlFiles(generatorParameters, factory);
60 this.logger.write("normal", "CreateIncludeDomlFiles is finished.");
61
62 } catch (Exception e) {
63 String msg = "Exception in class CreateIncludeDomlFiles.";
64 LoaderException le = new LoaderException(msg + e.getMessage(), (Throwable) e);
65 throw le;
66 }
67
68 }
69 /***
70 * This method will generate doml file
71 * @param generatorParameters
72 * @param factory
73 * @throws ParserConfigurationException
74 * @throws LoaderException
75 */
76 private void createIncludeDomlFiles(InputParameters generatorParameters, DocumentBuilderFactory factory) throws ParserConfigurationException, LoaderException {
77
78 this.logger.write("normal", "\tcreateIncludeDomlFiles method is started.");
79 DocumentBuilder builder = factory.newDocumentBuilder();
80 document = builder.newDocument(); // Create from whole cloth
81 Element root = (Element) document.createElement("definitionInclude");
82 document.appendChild(root);
83 DomlDesignReader domlDesignReader = new DomlDesignReader(document, root, generatorParameters);
84 WriteXmlFile writeXmlFile;
85 if (generatorParameters.getGenerateXml().equalsIgnoreCase("true"))
86 writeXmlFile = new WriteXmlFile(document, generatorParameters);
87 this.logger.write("normal", "\tcreateIncludeDomlFiles method is finished.");
88 }
89 /***
90 * This method will set logger object
91 * @param logger
92 */
93 private void setLogger() {
94 this.logger = StandardLogger.getCentralLogger();
95 }
96
97 }
This page was automatically generated by Maven