KickJava   Java API By Example, From Geeks To Geeks.

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


1
2 /*
3 LoaderGenerator - tool for generated xml, sql and doml file needed for Octopus.
4
5
6     Copyright (C) 2003 Together
7
8     This library is free software; you can redistribute it and/or
9     modify it under the terms of the GNU Lesser General Public
10     License as published by the Free Software Foundation; either
11     version 2.1 of the License, or (at your option) any later version.
12
13     This library is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16     Lesser General Public License for more details.
17
18     You should have received a copy of the GNU Lesser General Public
19     License along with this library; if not, write to the Free Software
20     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */

22
23 package org.webdocwf.util.loader.generator;
24
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  *
32  * MappingTypeData class mapping the type of data, which depends on the type of database.
33  * @author Radoslav Dutina
34  * @version 1.0
35  */

36 public class MappingTypeData {
37
38     private String JavaDoc jdbcType = null;
39     private String JavaDoc sqlType = null;
40     private String JavaDoc msg = null;
41     private Logger logger;
42
43     /**
44      * Construct object MappingTypeData with associated parameters.
45      * @param dataType is the type which you wont to map.
46      * @param generatorParameters represents the references to InputParameter object.
47      * @throws LoaderException
48      */

49
50     public MappingTypeData(String JavaDoc dataType, InputParameters generatorParameters) throws LoaderException {
51                 setLogger();
52                 this.logger.write("full", "MappingTypeData is started.");
53         SearchXmlFile searchXmlFileSource = new SearchXmlFile("absolute", generatorParameters.getPathToSourceConf(), generatorParameters.getConfJarStructure());
54         //for cource conf file.
55
jdbcType = searchXmlFileSource.getJDBCFromSQLType(dataType);
56
57         SearchXmlFile searchXmlFileTarget = new SearchXmlFile("absolute", generatorParameters.getPathToTargetConf(), generatorParameters.getConfJarStructure());
58         //for target conf file.
59
if (!searchXmlFileTarget.getSQLFromJDBCType(jdbcType).equalsIgnoreCase("none")) {
60             setSQLType(searchXmlFileTarget.getSQLFromJDBCType(jdbcType));
61         } else {
62             msg = "You must adjust " + generatorParameters.getPathToTargetConf() + " file." + " This type of data (" + jdbcType + ") from source database don't have mapping in target database!";
63                         LoaderException le = new LoaderException("Exception:", new Exception JavaDoc(msg));
64                         this.logger.write("full", "Exception in class MappingJavaData."+"\n"+le.getStackTraceAsString());
65             throw le;
66         }
67                 this.logger.write("full", "dataType is " + dataType);
68                 this.logger.write("full", "jdbcType is " + jdbcType);
69                 this.logger.write("full", "SQLType is " + searchXmlFileTarget.getSQLFromJDBCType(jdbcType));
70                 this.logger.write("full", "MappingTypeData is finished.");
71     }
72
73     /**
74      * This method read the value of sqlType parameter.
75      * @return value of parameter.
76      */

77     public String JavaDoc getSQLType() {
78         return this.sqlType;
79     }
80
81     /**
82      * This method sets the value of sqlType parameter.
83      * @param sql_Type is the value of parameter.
84      */

85     public void setSQLType(String JavaDoc sql_Type) {
86         sqlType = sql_Type;
87     }
88     /**
89               * This method will set logger object
90               * @param logger
91               */

92     private void setLogger() {
93         this.logger = StandardLogger.getCentralLogger();
94     }
95 }
96
Popular Tags