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;
023:
024: import java.util.*;
025: import java.sql.*;
026:
027: /**
028: *
029: * QueryConstantSet class sets the query statement for constant columns
030: * @author unascribed
031: * @version 1.0
032: */
033: public class QueryConstantSet {
034:
035: private String strQueryConstant = null;
036: private Vector indexDummyOverwrite = new Vector();
037: private Vector indexDummyNull = new Vector();
038:
039: /**
040: * Construct object QueryConstantSet class with associated parameters
041: * @param tableName current table name
042: * @param vecConstantColumns vector of constant column names
043: * @param vecConstantMode vector of constant column modes
044: * @param vecConstantType vector of constant column types
045: */
046: public QueryConstantSet(String tableName,
047: Vector vecConstantColumns, Vector vecConstantMode,
048: Vector vecConstantType, ConfigReader configReaderTarget)
049: throws LoaderException {
050:
051: strQueryConstant = "update " + tableName + " set ";
052: for (int i = 0; i < vecConstantColumns.size(); i++) {
053: if (vecConstantMode.get(i).toString().equalsIgnoreCase(
054: "Overwrite")
055: || vecConstantMode.get(i).toString()
056: .equalsIgnoreCase("Key")) {
057: //ZK change this 7.5 2004 from CheckType to configReaderTarget
058: try {
059: if (!configReaderTarget.isNumber(vecConstantType
060: .get(i).toString())) {
061: strQueryConstant += vecConstantColumns.get(i)
062: .toString()
063: + " = " + "'dummyConstantOver'" + ", ";
064: } else {
065: strQueryConstant += vecConstantColumns.get(i)
066: .toString()
067: + " = " + "dummyConstantOver" + ", ";
068: }
069: } catch (LoaderException e) {
070: LoaderException le = new LoaderException(
071: "Exception:Type not present in conf file for target database, add it into conf file.",
072: (Throwable) e);
073: throw le;
074: }
075: indexDummyOverwrite.add(String.valueOf(i));
076: } else if (vecConstantMode.get(i).toString()
077: .equalsIgnoreCase("Update")
078: || vecConstantMode.get(i).toString()
079: .equalsIgnoreCase("SetNull")) {
080: //ZK change this 7.5 2004 from CheckType to configReaderTarget
081: try {
082: if (!configReaderTarget.isNumber(vecConstantType
083: .get(i).toString())) {
084: strQueryConstant += vecConstantColumns.get(i)
085: .toString()
086: + " = " + "'dummyConstantNull'" + ", ";
087: } else {
088: strQueryConstant += vecConstantColumns.get(i)
089: .toString()
090: + " = " + "dummyConstantNull" + ", ";
091: }
092: } catch (LoaderException e) {
093: LoaderException le = new LoaderException(
094: "Exception:Type not present in conf file for target database, add it into conf file.",
095: (Throwable) e);
096: throw le;
097: }
098: indexDummyNull.add(String.valueOf(i));
099: }
100: }
101: }
102:
103: /**
104: * This method read value of strQueryConstant parameter
105: * @return value of parameter
106: */
107: public String getQueryConstant() {
108: return strQueryConstant;
109: }
110:
111: /**
112: * This method read value from indexDummyOverwrite parameter
113: * @return value of parameter
114: */
115: public Vector getIndexDummyOverwrite() {
116: return indexDummyOverwrite;
117: }
118:
119: /**
120: * This method read value from indexDummyNull parameter
121: * @return value of parameter
122: */
123: public Vector getIndexDummyNull() {
124: return indexDummyNull;
125: }
126:
127: }
|