001: /**
002: Copyright (C) 2002-2003 Together
003:
004: This library is free software; you can redistribute it and/or
005: modify it under the terms of the GNU Lesser General Public
006: License as published by the Free Software Foundation; either
007: version 2.1 of the License, or (at your option) any later version.
008:
009: This library is distributed in the hope that it will be useful,
010: but WITHOUT ANY WARRANTY; without even the implied warranty of
011: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: Lesser General Public License for more details.
013:
014: You should have received a copy of the GNU Lesser General Public
015: License along with this library; if not, write to the Free Software
016: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017:
018: */package org.webdocwf.util.loader;
019:
020: import java.util.*;
021: import java.sql.*;
022:
023: /**
024: * Class used while building relations in target tables
025: *
026: * @author Radoslav Dutina
027: * @version 1.1
028: */
029: public class QueryRelationSet {
030:
031: private String strQueryRelations = "";
032: private Vector indexDummyRelationNull = new Vector();
033: private Vector indexDummyRelationOver = new Vector();
034: private Vector vecTempRelationSourceType = new Vector();
035: private String tableName = null;
036: private String tableID = null;
037:
038: /**
039: * Construct object of QueryRelationSet class with an associated parameters.
040: * @param iRelationColumns defines number of relation column
041: * @param vecRelationColumnSourceTableName defines source table name for relations
042: * @param vecRelationColumnSourceTableID defines source table ID for relations
043: * @param vecVariableUseIDTableName defines variable ID name
044: * @param vecVariableUseIDTableID defines variable ID
045: * @param vecRelationColumnSourceColumnName defines cource column names for relations
046: * @param iTargetFirstColumnResult defines parameter of ResultSet object
047: * @param stmtTarget defines statement object for target table
048: * @param tableID is table ID
049: * @param vecRelationColumnTargetTableID defines target table ID for relations
050: * @param tableName is name of the current table
051: */
052: public QueryRelationSet(int iRelationColumns,
053: Vector vecRelationColumnSourceTableName,
054: Vector vecRelationColumnSourceTableID,
055: Vector vecVariableUseIDTableName,
056: Vector vecVariableUseIDTableID,
057: Vector vecRelationColumnSourceColumnName,
058: int iTargetFirstColumnResult, Statement stmtTarget,
059: String tableID, Vector vecRelationColumnTargetTableID,
060: String tableName) {
061:
062: ResultSet rsetTarget;
063: this .tableName = tableName;
064: this .tableID = tableID;
065: for (int i = 0; i < iRelationColumns; i++) {
066: outLoop: if (vecRelationColumnSourceTableName.get(i)
067: .toString().equalsIgnoreCase(tableName)
068: && vecRelationColumnSourceTableID.get(i).toString()
069: .equalsIgnoreCase(tableID)) {
070: for (int m = 0; m < vecVariableUseIDTableName.size(); m++) {
071: if (vecRelationColumnSourceTableName.get(i)
072: .toString().equalsIgnoreCase(
073: vecVariableUseIDTableName.get(m)
074: .toString())
075: && vecRelationColumnSourceTableID.get(i)
076: .toString().equalsIgnoreCase(
077: vecVariableUseIDTableID
078: .get(m).toString())) {
079: String strQueryRelations = "select "
080: + vecRelationColumnSourceColumnName
081: .get(i).toString()
082: + " from "
083: + vecRelationColumnSourceTableName.get(
084: i).toString();
085: try {
086: rsetTarget = stmtTarget
087: .executeQuery(strQueryRelations);
088: rsetTarget.next();
089: if (iTargetFirstColumnResult == 1) {
090: this .vecTempRelationSourceType
091: .add(rsetTarget.getMetaData()
092: .getColumnTypeName(1));
093: } else {
094: this .vecTempRelationSourceType
095: .add(rsetTarget.getMetaData()
096: .getColumnTypeName(0));
097: }
098: rsetTarget.close();
099: break outLoop;
100: } catch (Exception e) {
101: e.getMessage();
102: }
103: }
104: }
105: String strQueryRelations = "select "
106: + vecRelationColumnSourceColumnName.get(i)
107: .toString()
108: + " from "
109: + vecRelationColumnSourceTableName.get(i)
110: .toString();
111: try {
112: rsetTarget = stmtTarget
113: .executeQuery(strQueryRelations);
114: rsetTarget.next();
115: if (iTargetFirstColumnResult == 1) {
116: vecTempRelationSourceType.add(rsetTarget
117: .getMetaData().getColumnTypeName(1));
118: } else {
119: vecTempRelationSourceType.add(rsetTarget
120: .getMetaData().getColumnTypeName(0));
121: rsetTarget.next();
122: }
123: } catch (Exception e) {
124: e.getMessage();
125: }
126: }
127: }
128: }
129:
130: /**
131: * This method read value of vecTempRelationSourceType parameter
132: * @return value of parameter
133: */
134: public Vector getRelationSourceType() {
135: return vecTempRelationSourceType;
136: }
137:
138: /**
139: * This method read value of strQueryRelations parameter
140: * @return value of parameter
141: */
142: public String getQueryRelations() {
143: return strQueryRelations;
144: }
145:
146: /**
147: * This method read value of indexDummyRelationNull parameter
148: * @return value of parameter
149: */
150: public Vector getIndexDummyRelationNull() {
151: return indexDummyRelationNull;
152: }
153:
154: /**
155: * This method read value of indexDummyRelationOver parameter
156: * @return value of parameter
157: */
158: public Vector getIndexDummyRelationOver() {
159: return indexDummyRelationOver;
160: }
161:
162: }
|