1 /***
2 ConfigReader - Read vales from config files for specified database.
3 Copyright (C) 2002-2003 Together
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Lesser General Public License for more details.
12 You should have received a copy of the GNU Lesser General Public
13 License along with this library; if not, write to the Free Software
14 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15 ConfigReader.java
16 Date: 20.5.2003.
17 */
18
19 package org.webdocwf.util.loader;
20
21 import java.io.*;
22
23 import javax.xml.parsers.*;
24 import org.w3c.dom.*;
25 import org.webdocwf.util.loader.logging.*;
26 import java.util.Hashtable;
27
28 /***
29 * Class read configuration parameters from configuration XML file.
30 *
31 * @author Zoran Milakovic, Radoslav Dutina
32 * @version 1.1
33 */
34 public class ConfigReader {
35
36 private Logger logger;
37 private String strVendorFileName = null;
38 private String strDriverClassName = "";
39 private int iFirstColumnResult = 1;
40 private boolean bRequiredUser = false;
41 private boolean bEnableJumpResult = false;
42 private boolean bAfterLastRow = true;
43 private boolean bEnableOrderBy = false;
44 private boolean bRowCountEnabled = false;
45 private boolean bSetFetchSizeEnabled = false;
46 private String oidDbType = "";
47 private String versionDbType = "";
48 private String oidColumnName = "oid";
49 private String versionColumnName = "version";
50 //This is default date format.
51 //private String dateFormat = "MM/dd/yyyy hh:mm:ss";
52 private String dateFormat = "yyyy-MM-dd";
53
54 private boolean bSetCursorNameEnabled = false;
55 private boolean bSetEmptyStringAsNull = false;
56 private boolean bReadingOrderRelevant = false;
57 private boolean bGetColumnsSupported = false;
58 private boolean bSetMaxRowsSupported = false;
59 private String bConnectionPrefix = "";
60 private boolean bFileSystemDatabase = false;
61 private String confJarStructure = "";
62 private boolean useSeparateConfFiles = false;
63 private Hashtable javaTypeMapp = new Hashtable();
64 //ZK added this 6.5.2004
65 private Hashtable isNumberMapp = new Hashtable();
66 private Hashtable isBinaryObjectMap = new Hashtable();
67 private Hashtable isDateMap = new Hashtable();
68 private Hashtable isWithNMap = new Hashtable();
69 //end
70 private String currentDriverName = "";
71 private String currentDatabaseName = "";
72
73 private static final String BYTE_ARRAY="1";
74 private static final String JAVA_MATH_BIGDECIMAL="2";
75 private static final String JAVA_LANG_DOUBLE="3";
76 private static final String JAVA_LANG_FLOAT="4";
77 private static final String JAVA_LANG_INTEGER="5";
78 private static final String JAVA_LANG_LONG="6";
79 private static final String JAVA_LANG_SHORT="7";
80 private static final String JAVA_LANG_STRING="8";
81 private static final String JAVA_SQL_DATE="9";
82 private static final String JAVA_SQL_TIME="10";
83 private static final String JAVA_SQL_TIMESTAMP="11";
84 private static final String JAVA_LANG_BOOLEAN="12";
85 private static final String JAVA_LANG_BYTE="13";
86 private static final String JAVA_LANG_OBJECT="14";
87
88
89 public static final String SPACE_ESCAPE = "__";
90
91 /***Method readConfigValues read specific values for desired database(dbVendor) and
92 * puts them into global variables. Third parameter in this method describes which database is analysed (target or source)
93 * Method reads values from Loader.conf configuration file (XML format).
94 * @param dbVendor - String - type of source database (table);
95 * @param strType - String - type of Loader database (source or target);
96 * @param driverName is name of the driver
97 * @throws LoaderException
98 */
99 public void readConfigValues(String dbVendor, String driverName,
100 String strType) throws LoaderException {
101 Document doc = null;
102 this.logger.write("full", "\treadConfigValues method is started.");
103 if(this.javaTypeMapp.size()>0)
104 this.javaTypeMapp.clear();
105 try {
106 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
107 DocumentBuilder db = null;
108 db = dbf.newDocumentBuilder();
109
110 String OCTOPUS_HOME = System.getProperty("OCTOPUS_HOME");
111 String databaseConfFile = null;
112 InputStream confFile = null;
113 File configFile = null;
114
115 //sinisa - Octopus supports mssql and msql values for dbVendor element
116 if (dbVendor.equalsIgnoreCase("mssql"))
117 dbVendor = "MSQL";
118 if (dbVendor.equalsIgnoreCase("Hsqldb"))
119 dbVendor = "HypersonicSQL";
120
121 if (this.strVendorFileName != null && !this.strVendorFileName.equals("")) {
122 configFile = new File(this.strVendorFileName);
123 if (configFile.exists()) {
124 doc = db.parse(configFile);
125 }
126 } else {
127 if (OCTOPUS_HOME != null) {
128 if (! (OCTOPUS_HOME.endsWith("//") || OCTOPUS_HOME.endsWith("/")))
129 OCTOPUS_HOME += "/";
130 configFile = new File(OCTOPUS_HOME + "conf/OctopusDBVendors.xml");
131 if (configFile.exists())
132 doc = db.parse(configFile);
133 } else {
134 if (this.useSeparateConfFiles) {
135 confFile = this.getClass().getClassLoader().getResourceAsStream(
136 this.confJarStructure + "/OctopusDBVendors.xml");
137 } else {
138 confFile = this.getClass().getClassLoader().getResourceAsStream(
139 "xml/conf/OctopusDBVendors.xml");
140 }
141 if (confFile != null)
142 doc = db.parse(confFile);
143 }
144 }
145 if (doc != null) {
146 NodeList tagConfFile = doc.getElementsByTagName("Vendor");
147 out:for (int i = 0; i < tagConfFile.getLength(); i++) {
148 Node nodeMain = tagConfFile.item(i);
149 NamedNodeMap attrs = nodeMain.getAttributes();
150 Node nodeDriver = attrs.getNamedItem("name");
151 if (nodeDriver != null &&
152 nodeDriver.getFirstChild().getNodeValue().
153 equalsIgnoreCase(dbVendor)) {
154 databaseConfFile = nodeMain.getFirstChild().getNodeValue();
155 break out;
156 }
157 }
158 } else {
159 //if driver name don't exists use default for source i target
160 if (strType.equalsIgnoreCase("source"))
161 databaseConfFile = "CsvConf.xml";
162 else
163 databaseConfFile = "MSQLConf.xml";
164 }
165
166 doc = null;
167 if (OCTOPUS_HOME == null) {
168 if (this.useSeparateConfFiles) {
169 confFile = getClass().getClassLoader().getResourceAsStream(
170 this.confJarStructure + "/" + databaseConfFile);
171 } else {
172 confFile = getClass().getClassLoader().getResourceAsStream(
173 "xml/conf/" + databaseConfFile);
174 }
175 if (confFile != null)
176 doc = db.parse(confFile);
177 } else {
178
179 if (databaseConfFile != null) {
180 configFile = new File(databaseConfFile);
181 // check if absolute databaseConfigFile path exist,and if not try to find it in current directory
182 if(!configFile.exists()) {
183 configFile = new File( OCTOPUS_HOME + "/conf/" + databaseConfFile );
184 }
185 }
186 else {
187 //just to prevent NullPointerException,if configFile == null
188 configFile = new File("null");
189 }
190
191 if (configFile.exists()) {
192 doc = db.parse(configFile);
193 }
194 }
195
196 if (doc == null) {
197 if (strType.equalsIgnoreCase("source")) {
198 this.logger.write("normal",
199 "Failed to load config file for source database, load default configuration.");
200 this.strDriverClassName = "org.relique.jdbc.csv.CsvDriver";
201 this.iFirstColumnResult = 1;
202 this.bRequiredUser = false;
203 this.bEnableJumpResult = false;
204 this.bAfterLastRow = true;
205 this.bEnableOrderBy = false;
206 if (driverName == null || driverName.equals(""))
207 driverName = "csv";
208 this.bFileSystemDatabase = true;
209 } else {
210 this.logger.write("normal",
211 "Failed to load config file for target database, load default configuration.");
212 this.strDriverClassName = "com.newatlanta.jturbo.driver.Driver";
213 this.iFirstColumnResult = 1;
214 this.bRequiredUser = true;
215 if (driverName == null || driverName.equals(""))
216 driverName = "jTurbo";
217 }
218 }
219 }
220 catch (Exception e) {
221 this.logger.write("normal", "Sorry, an error occurred: " + e.getMessage());
222 LoaderException le = new LoaderException("Exception: ", (Throwable)e);
223 throw le;
224 }
225
226 String strDriverName = "";
227 if (doc != null) {
228 if (driverName == null || driverName.equalsIgnoreCase("")) {
229 if (dbVendor.equalsIgnoreCase("MSQL"))
230 driverName = "jTurbo";
231 }
232
233
234 //read values from tag OidDbType
235 if (doc.getElementsByTagName("OidDbType").getLength()!=0){
236 NodeList tagOidDbType = doc.getElementsByTagName("OidDbType");
237 Node tempChildNode = tagOidDbType.item(0).getFirstChild();
238 if (tempChildNode != null){
239 this.oidDbType = tagOidDbType.item(0).getFirstChild().getNodeValue();
240 }else{
241 LoaderException le = new LoaderException("You must set data in tag <OidDbType> in conf file for database vendor!");
242 throw le;
243 }
244 }else{
245 LoaderException le = new LoaderException("Tag <OidDbType> doesn't exist in conf file for database vendor. You must set this tag with appropriate value.");
246 throw le;
247 }
248
249 //read values from tag VersionDbType
250 if (doc.getElementsByTagName("VersionDbType").getLength()!=0){
251 NodeList tagVersionDbType = doc.getElementsByTagName("VersionDbType");
252 Node tempChildNode = tagVersionDbType.item(0).getFirstChild();
253 if (tempChildNode != null){
254 this.versionDbType = tagVersionDbType.item(0).getFirstChild().getNodeValue();
255 }else{
256 LoaderException le = new LoaderException("You must set data in tag <VersionDbType>in conf file for database vendor!");
257 throw le;
258 }
259 }else{
260 LoaderException le = new LoaderException("Tag <VersionDbType> doesn't exist in conf file for database vendor. You must set this tag with appropriate value.");
261 throw le;
262 }
263
264 //read values from tag OidDbColumnName
265 if(doc.getElementsByTagName("OidDbColumnName").getLength()!=0){
266 NodeList tagOidColumnName = doc.getElementsByTagName("OidDbColumnName");
267 Node tempChildNode = tagOidColumnName.item(0).getFirstChild();
268 if (tempChildNode != null ){
269 this.oidColumnName = tagOidColumnName.item(0).getFirstChild().getNodeValue();
270 }else{
271 LoaderException le = new LoaderException("You must set data in tag <OidDbColumnName> in conf file for database vendor.");
272 throw le;
273 }
274 }else{
275 LoaderException le = new LoaderException("Tag <OidDbColumnName> doesn't exist in conf file for database vendor.You must set this tag with appropriate value.");
276 throw le;
277 }
278
279 //read values from tag VersionDbColumnName
280 if(doc.getElementsByTagName("VersionDbColumnName").getLength()!=0){
281 NodeList tagVersionColumnName = doc.getElementsByTagName("VersionDbColumnName");
282 Node tempChildNode = tagVersionColumnName.item(0).getFirstChild();
283 if (tempChildNode != null ){
284 this.versionColumnName = tagVersionColumnName.item(0).getFirstChild().getNodeValue();
285 }else{
286 LoaderException le = new LoaderException("You must set data in tag <VersionDbColumnName> in conf file for database vendor.");
287 throw le;
288 }
289 }else{
290 LoaderException le = new LoaderException("Tag <VersionDbColumnName> doesn't exist in conf file for database vendor. You must set this tag with appropriate value.");
291 throw le;
292 }
293
294 //read values from tag DateFormat
295 if (doc.getElementsByTagName("DateFormat").getLength()!=0){
296 NodeList tagDateFormat = doc.getElementsByTagName("DateFormat");
297 Node tempChildNode = tagDateFormat.item(0).getFirstChild();
298 if (tempChildNode != null ){
299 this.dateFormat =tagDateFormat.item(0).getFirstChild().getNodeValue();
300 }
301 }else{
302 LoaderException le = new LoaderException("Tag <DateFormat> doesn't exist in conf file for database vendor. You must set this tag with appropriate value.");
303 throw le;
304 }
305
306 //if(strType.equalsIgnoreCase("target")){
307 NodeList tagJavaType = doc.getElementsByTagName("SQLType");
308 Node nodeJavaTMain = tagJavaType.item(0);
309 NodeList dataTypeNodes = nodeJavaTMain.getChildNodes();
310 String nodeAttrIsNumber = "";
311 String nodeAttrIsBinary = "";
312 String nodeAttrIsDate = "";
313 String nodeAttrIsWithN = "";
314 for (int i = 0; i < dataTypeNodes.getLength(); i++) {
315 if (dataTypeNodes.item(i).getNodeType() == Node.ELEMENT_NODE) {
316 String nodeName = dataTypeNodes.item(i).getNodeName();
317 String nodeAttr = dataTypeNodes.item(i).getAttributes()
318 .getNamedItem("javaType").getNodeValue();
319 //ZK added this 6.5.2004
320 if (dataTypeNodes.item(i).getAttributes().getNamedItem("isNumber")!=null){
321 nodeAttrIsNumber = dataTypeNodes.item(i).getAttributes().getNamedItem("isNumber").getNodeValue();
322 }else{
323 nodeAttrIsNumber = "false";
324 }
325
326 if (dataTypeNodes.item(i).getAttributes().getNamedItem("isBinary")!=null){
327 nodeAttrIsBinary = dataTypeNodes.item(i).getAttributes().getNamedItem("isBinary").getNodeValue();
328 }else{
329 nodeAttrIsBinary = "false";
330 }
331
332 if (dataTypeNodes.item(i).getAttributes().getNamedItem("isDate")!=null){
333 nodeAttrIsDate = dataTypeNodes.item(i).getAttributes().getNamedItem("isDate").getNodeValue();
334 }else{
335 nodeAttrIsDate = "false";
336 }
337
338 if (dataTypeNodes.item(i).getAttributes().getNamedItem("isWithN")!=null){
339 nodeAttrIsWithN = dataTypeNodes.item(i).getAttributes().getNamedItem("isWithN").getNodeValue();
340 }else{
341 nodeAttrIsWithN = "false";
342 }
343
344
345 //end
346 String nodeAttrInt;
347 if (nodeAttr.equalsIgnoreCase("byte[]"))
348 nodeAttrInt = BYTE_ARRAY;
349 else if (nodeAttr.equalsIgnoreCase("java.math.BigDecimal"))
350 nodeAttrInt = JAVA_MATH_BIGDECIMAL;
351 else if (nodeAttr.equalsIgnoreCase("java.lang.Double"))
352 nodeAttrInt = JAVA_LANG_DOUBLE;
353 else if (nodeAttr.equalsIgnoreCase("java.lang.Float"))
354 nodeAttrInt = JAVA_LANG_FLOAT;
355 else if (nodeAttr.equalsIgnoreCase("java.lang.Integer"))
356 nodeAttrInt = JAVA_LANG_INTEGER;
357 else if (nodeAttr.equalsIgnoreCase("java.lang.Long"))
358 nodeAttrInt = JAVA_LANG_LONG;
359 else if (nodeAttr.equalsIgnoreCase("java.lang.Short"))
360 nodeAttrInt = JAVA_LANG_SHORT;
361 else if (nodeAttr.equalsIgnoreCase("java.lang.String"))
362 nodeAttrInt = JAVA_LANG_STRING;
363 else if (nodeAttr.equalsIgnoreCase("java.sql.Date"))
364 nodeAttrInt = JAVA_SQL_DATE;
365 else if (nodeAttr.equalsIgnoreCase("java.sql.Time"))
366 nodeAttrInt = JAVA_SQL_TIME;
367 else if (nodeAttr.equalsIgnoreCase("java.sql.Timestamp"))
368 nodeAttrInt = JAVA_SQL_TIMESTAMP;
369 else if (nodeAttr.equalsIgnoreCase("java.lang.Boolean"))
370 nodeAttrInt = JAVA_LANG_BOOLEAN;
371 else if (nodeAttr.equalsIgnoreCase("java.lang.Byte"))
372 nodeAttrInt = JAVA_LANG_BYTE;
373 else
374 nodeAttrInt = JAVA_LANG_OBJECT;
375
376 //REPLACE ALL __ WITH SPACES
377 nodeName = Utils.replaceAll(nodeName,ConfigReader.SPACE_ESCAPE," ");
378
379 isNumberMapp.put(nodeName.toLowerCase(), nodeAttrIsNumber);
380
381 isBinaryObjectMap.put(nodeName.toLowerCase(), nodeAttrIsBinary);
382
383 isDateMap.put(nodeName.toLowerCase(), nodeAttrIsDate);
384
385 isWithNMap.put(nodeName.toLowerCase(), nodeAttrIsWithN);
386
387 javaTypeMapp.put(nodeName, nodeAttrInt);
388 }
389 }
390 //}
391 NodeList tagDbVendor = doc.getElementsByTagName("Driver");
392 out:for (int i = 0; i < tagDbVendor.getLength(); i++) {
393 Node nodeMain = tagDbVendor.item(i);
394 NamedNodeMap attrs = nodeMain.getAttributes();
395 Node nodeDriver = attrs.getNamedItem("name");
396 if (nodeDriver != null) {
397 strDriverName = nodeDriver.getNodeValue();
398 if (driverName == null || driverName.equalsIgnoreCase(""))
399 driverName = strDriverName;
400 if (! (driverName == null || driverName.equalsIgnoreCase(""))) {
401 if (strDriverName.equalsIgnoreCase(driverName)) {
402 NodeList configNodes = nodeMain.getChildNodes();
403 for (int j = 0; j < configNodes.getLength(); j++) {
404 if (configNodes.item(j).getNodeName().equalsIgnoreCase("FirstColumnResult")) {
405 NamedNodeMap configAttributes = null;
406 Node nodeValue = null;
407 configAttributes = configNodes.item(j).getAttributes();
408 if (configAttributes != null) {
409 if ( (nodeValue = configAttributes.getNamedItem("value")) != null) {
410 this.iFirstColumnResult = Integer.parseInt(nodeValue.getNodeValue());
411 }
412 }
413 } else if (configNodes.item(j).getNodeName().equalsIgnoreCase("RequiredUser")) {
414 NamedNodeMap configAttributes = null;
415 Node nodeValue = null;
416 configAttributes = configNodes.item(j).getAttributes();
417 if (configAttributes != null) {
418 if ( (nodeValue = configAttributes.getNamedItem("value")) != null) {
419 this.bRequiredUser = (new Boolean(nodeValue.getNodeValue())).booleanValue();
420 }
421 }
422 } else if (configNodes.item(j).getNodeName().equalsIgnoreCase(
423 "EnableJumpInResult")) {
424 NamedNodeMap configAttributes = null;
425 Node nodeValue = null;
426 configAttributes = configNodes.item(j).getAttributes();
427 if (configAttributes != null) {
428 if ( (nodeValue = configAttributes.getNamedItem("value"))
429 != null) {
430 this.bEnableJumpResult = (new Boolean(nodeValue.
431 getNodeValue())).booleanValue();
432 }
433 }
434 } else if (configNodes.item(j).getNodeName().equalsIgnoreCase( //
435 "Connection")) {
436 NamedNodeMap configAttributes = null;
437 Node nodeValue = null;
438 configAttributes = configNodes.item(j).getAttributes();
439 if (configAttributes != null) {
440 if ( (nodeValue = configAttributes.getNamedItem("value"))
441 != null) {
442 this.bConnectionPrefix = nodeValue.getNodeValue();
443 }
444 }
445 } else if (configNodes.item(j).getNodeName().equalsIgnoreCase( //
446 "AfterLastRow")) {
447 NamedNodeMap configAttributes = null;
448 Node nodeValue = null;
449 configAttributes = configNodes.item(j).getAttributes();
450 if (configAttributes != null) {
451 if ( (nodeValue = configAttributes.getNamedItem("value"))
452 != null) {
453 this.bAfterLastRow = (new Boolean(nodeValue.getNodeValue())).
454 booleanValue();
455 }
456 }
457 } else if (configNodes.item(j).getNodeName().equalsIgnoreCase(
458 "EnableOrderBy")) {
459 NamedNodeMap configAttributes = null;
460 Node nodeValue = null;
461 configAttributes = configNodes.item(j).getAttributes();
462 if (configAttributes != null) {
463 if ( (nodeValue = configAttributes.getNamedItem("value"))
464 != null) {
465 this.bEnableOrderBy = (new Boolean(nodeValue.getNodeValue())).
466 booleanValue();
467 }
468 }
469 } else if (configNodes.item(j).getNodeName().equalsIgnoreCase(
470 "ClassName")) {
471 NamedNodeMap configAttributes = null;
472 Node nodeValue = null;
473 configAttributes = configNodes.item(j).getAttributes();
474 if (configAttributes != null) {
475 if ( (nodeValue = configAttributes.getNamedItem("value"))
476 != null) {
477 this.strDriverClassName = (nodeValue.getNodeValue()).
478 toString();
479 }
480 }
481 } else if (configNodes.item(j).getNodeName().equalsIgnoreCase( //
482 "RowCountEnabled")) {
483 NamedNodeMap configAttributes = null;
484 Node nodeValue = null;
485 configAttributes = configNodes.item(j).getAttributes();
486 if (configAttributes != null) {
487 if ( (nodeValue = configAttributes.getNamedItem("value"))
488 != null) {
489 this.bRowCountEnabled = (new Boolean(nodeValue.
490 getNodeValue())).booleanValue();
491 }
492 }
493 } else if (configNodes.item(j).getNodeName().equalsIgnoreCase( //
494 "SetFetchSizeEnabled")) {
495 NamedNodeMap configAttributes = null;
496 Node nodeValue = null;
497 configAttributes = configNodes.item(j).getAttributes();
498 if (configAttributes != null) {
499 if ( (nodeValue = configAttributes.getNamedItem("value"))
500 != null) {
501 this.bSetFetchSizeEnabled = (new Boolean(nodeValue.
502 getNodeValue())).booleanValue();
503 }
504 }
505 } else if (configNodes.item(j).getNodeName().equalsIgnoreCase( //
506 "SetCursorNameEnabled")) {
507 NamedNodeMap configAttributes = null;
508 Node nodeValue = null;
509 configAttributes = configNodes.item(j).getAttributes();
510 if (configAttributes != null) {
511 if ( (nodeValue = configAttributes.getNamedItem("value"))
512 != null) {
513 this.bSetCursorNameEnabled = (new Boolean(nodeValue.
514 getNodeValue())).booleanValue();
515 }
516 }
517 } else if (configNodes.item(j).getNodeName().equalsIgnoreCase( //
518 "SetEmptyStringAsNull")) {
519 NamedNodeMap configAttributes = null;
520 Node nodeValue = null;
521 configAttributes = configNodes.item(j).getAttributes();
522 if (configAttributes != null) {
523 if ( (nodeValue = configAttributes.getNamedItem("value"))
524 != null) {
525 this.bSetEmptyStringAsNull = (new Boolean(nodeValue.
526 getNodeValue())).booleanValue();
527 }
528 }
529 } else if (configNodes.item(j).getNodeName().equalsIgnoreCase( //
530 "ReadingOrderRelevant")) {
531 NamedNodeMap configAttributes = null;
532 Node nodeValue = null;
533 configAttributes = configNodes.item(j).getAttributes();
534 if (configAttributes != null) {
535 if ( (nodeValue = configAttributes.getNamedItem("value"))
536 != null) {
537 this.bReadingOrderRelevant = (new Boolean(nodeValue.
538 getNodeValue())).booleanValue();
539 }
540 }
541 } else if (configNodes.item(j).getNodeName().equalsIgnoreCase( //
542 "FileSystemDatabase")) {
543 NamedNodeMap configAttributes = null;
544 Node nodeValue = null;
545 configAttributes = configNodes.item(j).getAttributes();
546 if (configAttributes != null) {
547 if ( (nodeValue = configAttributes.getNamedItem("value"))
548 != null) {
549 this.bFileSystemDatabase = (new Boolean(nodeValue.
550 getNodeValue())).booleanValue();
551 }
552 }
553 } else if (configNodes.item(j).getNodeName().equalsIgnoreCase( //
554 "GetColumnsSupported")) {
555 NamedNodeMap configAttributes = null;
556 Node nodeValue = null;
557 configAttributes = configNodes.item(j).getAttributes();
558 if (configAttributes != null) {
559 if ( (nodeValue = configAttributes.getNamedItem("value"))
560 != null) {
561 this.bGetColumnsSupported = (new Boolean(nodeValue.
562 getNodeValue())).booleanValue();
563 }
564 }
565 } else if (configNodes.item(j).getNodeName().equalsIgnoreCase( //
566 "SetMaxRowsSupported")) {
567 NamedNodeMap configAttributes = null;
568 Node nodeValue = null;
569 configAttributes = configNodes.item(j).getAttributes();
570 if (configAttributes != null) {
571 if ( (nodeValue = configAttributes.getNamedItem("value"))
572 != null) {
573 this.bSetMaxRowsSupported = (new Boolean(nodeValue.
574 getNodeValue())).booleanValue();
575 }
576 }
577 }
578
579 } //configNodes.getLength()
580 break out;
581 }
582 }
583 }
584 }
585 }
586 this.logger.write("full", "\treadConfigValues method is finished.");
587 }
588
589 /***
590 * This method read value of javaTypeMapp parameter
591 * @return value of javaTypeMapp attribute.
592 */
593 public Hashtable getJavaTypeMapings() {
594 return this.javaTypeMapp;
595 }
596 /***
597 * This method read value of isNumberMapp parameter
598 * @return value of javaTypeMapp attribute.
599 */
600 public Hashtable getIsNumberMapp() {
601 return this.isNumberMapp;
602 }
603
604 /***
605 * Method isNumber is used for checking column type.
606 * @param s String that represents column type.
607 * @return true if it is numeric and false if it is not.
608 */
609 public boolean isNumber(String s) throws LoaderException{
610 if( s != null )
611 s = s.toLowerCase();
612 boolean isNumber = false;
613 // TODO TEST THIS!!!ZK added next line because of problems with LONG VARCHAR on DB2
614 //s = Utils.replaceAll(s," ","_");
615 // TODO ZK added next line because of problems with LONG VARCHAR on DB2
616 // if (s.equalsIgnoreCase("LONG VARCHAR")){
617 // s = "long_varchar";
618 // }
619 if (this.isNumberMapp.containsKey(s)){
620 Object bValue = this.isNumberMapp.get(s);
621 if( bValue != null && (bValue.toString()).equalsIgnoreCase("true")) {
622 //return (new Boolean(bValue.toString()).booleanValue());
623 return true;
624 }
625 }else{
626 LoaderException le = new LoaderException("Exception:",new Exception("Type "+s+" is not supported. You must add it in conf file for this database vendor."));
627 throw le;
628 }
629 return isNumber;
630
631 }
632
633 /***
634 * Method isNumber is used for checking column type.
635 * @param s String that represents column type.
636 * @return true if it is numeric and false if it is not.
637 */
638 public boolean isBinaryObject(String s) throws LoaderException{
639 if( s != null )
640 s = s.toLowerCase();
641 boolean isBinaryObject = false;
642 //TODO TEST THIS!!!ZK added next line because of problems with LONG VARCHAR on DB2
643 //s = Utils.replaceAll(s," ","_");
644 //TODO ZK added next line because of problems with LONG VARCHAR on DB2
645 // if (s.equalsIgnoreCase("LONG VARCHAR")){
646 // s = "long_varchar";
647 // }
648 //end
649 if (this.isBinaryObjectMap.containsKey(s)){
650
651 Object bValue = this.isBinaryObjectMap.get(s);
652 if( bValue != null && (bValue.toString()).equalsIgnoreCase("true")) {
653 //return (new Boolean(bValue.toString()).booleanValue());
654 return true;
655 }
656 }else{
657 LoaderException le = new LoaderException("Exception:",new Exception("Type "+s+" is not supported. You must add it in conf file for this database vendor."));
658 throw le;
659 }
660 return isBinaryObject;
661
662 }
663 /***
664 * Method isDate is used for checking column type.
665 * @param s String that represents column type.
666 * @return true if it is numeric and false if it is not.
667 */
668 public boolean isDate(String s) throws LoaderException{
669 if (s != null)
670 s = s.toLowerCase();
671 boolean isDate = false;
672 //TODO TEST THIS!!!ZK added next line because of problems with LONG VARCHAR on DB2
673 //s = Utils.replaceAll(s," ","_");
674 //TODO ZK added next line because of problems with LONG VARCHAR on DB2
675 // if (s.equalsIgnoreCase("LONG VARCHAR")){
676 // s = "long_varchar";
677 // }
678 //end
679 if (this.isDateMap.containsKey(s)){
680 Object dValue = this.isDateMap.get(s);
681 if ((dValue != null) && (dValue.toString()).equalsIgnoreCase("true")){
682 //return (new Boolean(dValue.toString()).booleanValue());
683 return true;
684 }
685
686 }else{
687 LoaderException le = new LoaderException("Exception:",new Exception("Type "+s+" is not supported. You must add it in conf file for this database vendor."));
688 throw le;
689 }
690 return isDate;
691
692 }
693
694 /***
695 * Method isWithN is used for checking column type.
696 * @param s String that represents column type.
697 * @return true if it is numeric and false if it is not.
698 */
699 public boolean isWithN(String s) throws LoaderException{
700 if( s != null )
701 s = s.toLowerCase();
702 boolean isWithN = false;
703 // if (s.equalsIgnoreCase("LONG VARCHAR")){
704 // s = "long_varchar";
705 // }
706 if (this.isWithNMap.containsKey(s)){
707 Object bValue = this.isWithNMap.get(s);
708 if( bValue != null && (bValue.toString()).equalsIgnoreCase("true")) {
709 return true;
710 }
711 }else{
712 LoaderException le = new LoaderException("Exception:",new Exception("Type "+s+" is not supported. You must add it in conf file for this database vendor."));
713 throw le;
714 }
715 return isWithN;
716
717 }
718
719
720 /***
721 * This method read value of bGetColumnsSupported parameter
722 * @return value of bGetColumnsSupported attribute.
723 */
724 public boolean getColumnsSupported() {
725 return this.bGetColumnsSupported;
726 }
727 /***
728 * This method read value of bSetMaxRowsSupported parameter
729 * @return value of bSetMaxRowsSupported attribute.
730 */
731 public boolean getMaxRowsSupported() {
732 return this.bSetMaxRowsSupported;
733 }
734
735 /***
736 * This method read value of oidColumnName parameter
737 * @return value of oidColumnName attribute.
738 */
739 public String getOidColumnName() {
740 return this.oidColumnName;
741 }
742
743 /***
744 * This method read value of versionColumnName parameter
745 * @return value of versionColumnName attribute.
746 */
747 public String getVersionColumnName() {
748 return this.versionColumnName;
749 }
750
751 /***
752 * This method read value of bConnectionPrefix parameter
753 * @return value of bConnectionPrefix attribute.
754 */
755 public String getConnectionPrefix() {
756 return this.bConnectionPrefix;
757 }
758
759 /***
760 * This method read value of bReadingOrderRelevant parameter
761 * @return value of bReadingOrderRelevant attribute.
762 */
763 public boolean getReadingOrderRelevant() {
764 return this.bReadingOrderRelevant;
765 }
766
767 /***
768 * This method read value of bSetEmptyStringAsNull parameter
769 * @return value of bSetEmptyStringAsNull attribute.
770 */
771 public boolean getSetEmptyStringAsNull() {
772 return this.bSetEmptyStringAsNull;
773 }
774
775 /***
776 * This method read value of bSetCursorNameEnabled parameter
777 * @return value of bSetCursorNameEnabled attribute.
778 */
779 public boolean getSetCursorNameEnabled() {
780 return this.bSetCursorNameEnabled;
781 }
782
783 /***
784 * This method read value of bSetFetchSizeEnabled parameter
785 * @return value of bSetFetchSizeEnabled attribute.
786 */
787 public boolean getSetFetchSizeEnabled() {
788 return this.bSetFetchSizeEnabled;
789 }
790
791 /***
792 * This method read value of bRowCountEnabled parameter
793 * @return value of bRowCountEnabled attribute.
794 */
795 public boolean getRowCountEnabled() {
796 return this.bRowCountEnabled;
797 }
798
799 /***
800 * This method read value of bEnableOrderBy parameter
801 * @return value of EnableOrderBy attribute.
802 */
803 public boolean getEnableOrderBy() {
804 return this.bEnableOrderBy;
805 }
806
807 /***
808 * This method read value of bAfterLastRow parameter
809 * @return value of AfterLastRow attribute.
810 */
811 public boolean getAfterLastRow() {
812 return this.bAfterLastRow;
813 }
814
815 /***
816 * This method read value of bFileSystemDatabase parameter
817 * @return value of bFileSystemDatabase attribute.
818 */
819 public boolean getFileSystemDatabase() {
820 return this.bFileSystemDatabase;
821 }
822
823 /***
824 * This method read value of bEnableJumpResult parameter
825 * @return value of EnableJumpResult attribute.
826 */
827 public boolean getEnableJumpResult() {
828 return this.bEnableJumpResult;
829 }
830
831 /***
832 * This method read value of bRequiredUser parameter
833 * @return value of RequiredUser attribute.
834 */
835 public boolean getRequiredUser() {
836 return this.bRequiredUser;
837 }
838
839 /***
840 * This method read value of iFirstColumnResult parameter
841 * @return value of FirstColumnResult attribute.
842 */
843 public int getFirstColumnResult() {
844 return this.iFirstColumnResult;
845 }
846
847 /***
848 * This method read value of strDriverClassName parameter
849 * @return value of SourceDriverClassName attribute.
850 */
851 public String getDriverClassName() {
852 return this.strDriverClassName;
853 }
854
855 /***
856 * This method read value of strVendorFileName parameter
857 * @return value of VendorFileName attribute.
858 */
859 public String getVendorFileName() {
860 return this.strVendorFileName;
861 }
862
863 /***
864 * This method set value of strVendorFileName parameter
865 * @param fileName set dbVendorFileName which is used for reading separated database conf files.
866 */
867 public void setVendorFileName(String fileName) {
868 this.strVendorFileName = fileName;
869 }
870
871 /***
872 * This method set value of echo parameter
873 * @param logger set Logger which is used for log file.
874 */
875 public void setLogger(Logger logger) {
876 this.logger = logger;
877 }
878
879 /***
880 * This method read value from parameter
881 * @return value of parameter
882 */
883 public String getOidDbType() {
884 return this.oidDbType;
885 }
886
887 /***
888 * This method read value from parameter
889 * @return value of parameter
890 */
891 public String getVersionDbType() {
892 return this.versionDbType;
893 }
894
895 /***
896 * This method read value from parameter
897 * @return value of parameter
898 */
899 public String getDateFormat() {
900 return this.dateFormat;
901 }
902
903 /***
904 * This method set value of confJarStructure parameter
905 * @param confJarStructure is value of parameter
906 */
907 public void setConfJarStructure(String confJarStructure) {
908 if (confJarStructure != null && !confJarStructure.equalsIgnoreCase("")) {
909 if (confJarStructure.endsWith("/") || confJarStructure.endsWith("//"))
910 confJarStructure = confJarStructure.substring(0,
911 confJarStructure.length() - 1);
912
913 this.confJarStructure = confJarStructure;
914 this.useSeparateConfFiles = true;
915 }
916 }
917
918 }
This page was automatically generated by Maven