📄 querywhereset.java
字号:
/*
LoaderGenerator - tool for generated xml, sql and doml file needed for Octopus.
Copyright (C) 2003 Together
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.webdocwf.util.loader;
import java.util.*;
import java.sql.*;
import org.webdocwf.util.loader.logging.*;
/**
*
* QueryWhereSet class creates the where condition in sql statement
* @author Radoslav Dutina
* @version 1.0
*/
public class QueryWhereSet {
private String strQueryWhere=" where ";
private Vector vecColumnNames=null;
private Vector vecColumnTypes=null;
private String tableName=null;
private String tableID=null;
private Vector indexDummyValue=new Vector();
private Vector indexDummyRelationValue=new Vector();
private Vector indexDummyConstantValue=new Vector();
private Vector indexDummyVariableValue=new Vector();
private Vector indexDummyTransformationValue=new Vector();
/**
* Construct object of QueryWhereSet class with associated parameters
* @param vecColumnNames is vector which contain column names
* @param vecColumnTypes is vector which contain column types
* @param tableName is the current table name
* @param tableID is ID of current table
*/
public QueryWhereSet(Vector vecColumnNames,Vector vecColumnTypes,
String tableName, String tableID ) {
this.vecColumnNames=vecColumnNames;
this.vecColumnTypes=vecColumnTypes;
this.tableName=tableName;
this.tableID=tableID;
}
/**
* This method read the value of vecTempKeyColumns and sets the parameter strQueryWhere
* @param vecTempKeyColumns is the value of parameter
* @param configReaderTarget is ConfigReader object for target database
*/
public void getKeyColumns(Vector vecTempKeyColumns,ConfigReader configReaderTarget) throws LoaderException{
for (int k = 0; k < vecTempKeyColumns.size(); k++) {
if (vecColumnNames.size() != 0) {
for (int l = 0; l < vecColumnNames.size(); l++) {
if (vecTempKeyColumns.get(k).toString().equalsIgnoreCase(vecColumnNames.get(l).toString())) {
// int counter=l;
strQueryWhere += vecColumnNames.get(l).toString();
//ZK change this from CheckType to configReaderTarget
try {
if (!configReaderTarget.isNumber(vecColumnTypes.get(l).toString())) {
strQueryWhere += " = '" + "dummyValue"
+ "' and ";
indexDummyValue.add(String.valueOf(l));
}else {
strQueryWhere += " = " + "dummyValue"
+ " and ";
indexDummyValue.add(String.valueOf(l));
}
} catch (LoaderException e) {
LoaderException le = new LoaderException("Exception:Type not present in conf file for target database, add it into conf file.",(Throwable)e);
throw le;
}
}
}
}
}
}
/**
* This method read the value of vecTempKeyTransformation and sets the parameter strQueryWhere
* @param transformationTargetColumns is Vector with target columns in for this transformation
* @param vecTempKeyTransformation is Vector with key columns
* @param transformationColumnTypes is Vector with target with column types
* @param configReaderTarget is ConfigReader object for target database
*/
//ZK added this method for Transformations
public void getTransformationKeyColumns(Vector transformationTargetColumns, Vector vecTempKeyTransformation,
Vector transformationColumnTypes, ConfigReader configReaderTarget) throws LoaderException{
for (int k = 0; k < vecTempKeyTransformation.size(); k++) {
if (transformationTargetColumns.size() != 0) {
for (int l = 0; l < transformationTargetColumns.size(); l++) {
if (vecTempKeyTransformation.get(k).toString().equalsIgnoreCase(transformationTargetColumns.get(l).toString())) {
strQueryWhere += transformationTargetColumns.get(l).toString();
//ZK change this 7.5.2004 from CheckType to configReaderTarget
try {
if (!configReaderTarget.isNumber(transformationColumnTypes.get(l).toString())) {
strQueryWhere += " = '" + "dummyTransformationValue"
+ "' and ";
indexDummyTransformationValue.add(String.valueOf(l));
}else {
strQueryWhere += " = " + "dummyTransformationValue"
+ " and ";
indexDummyTransformationValue.add(String.valueOf(l));
}
} catch (LoaderException e) {
LoaderException le = new LoaderException("Exception:Type not present in conf file for target database, add it into conf file.",(Throwable)e);
throw le;
}
}
}
}
}
}
/**
* This method read the input parameters and sets the parameter strQueryWhere
* @param vecRelationKeyColumns is input parameter
* @param iRelationColumns is input parameter
* @param vecRelationColumnTargetTableName is input parameter
* @param vecRelationColumnTargetTableID is input parameter
* @param vecRelationColumnTargetColumnName is input parameter
* @param vecRelationKeyTypes is input parameter
* @param configReaderTarget is input parameter
*/
public void getRelationKeyColumns(Vector vecRelationKeyColumns,int iRelationColumns,
Vector vecRelationColumnTargetTableName,Vector vecRelationColumnTargetTableID,
Vector vecRelationColumnTargetColumnName,Vector vecRelationKeyTypes,
ConfigReader configReaderTarget) throws LoaderException{
for (int k = 0; k < vecRelationKeyColumns.size(); k++) {
int counter=0;
int iNumRelation = -1;
for (int p = 0; p < iRelationColumns; p++) {
if (vecRelationColumnTargetTableName.get(p).toString().equalsIgnoreCase(
tableName)
&& vecRelationColumnTargetTableID.get(p).toString().equalsIgnoreCase(
tableID)
&& vecRelationColumnTargetColumnName.get(p).toString().equalsIgnoreCase(
vecRelationKeyColumns.get(k).toString())) {
iNumRelation = p;
counter=p;
}
}
strQueryWhere += vecRelationKeyColumns.get(k).toString();
//ZK change this 7.5.2004 from CheckType to configReaderTarget
//TODO ZK change 11.6.2004 from vecRelationKeyColumns to vecRelationKeyTypes
try {
if (configReaderTarget.isNumber(vecRelationKeyTypes.get(k).toString())){
strQueryWhere += " = " + "dummyRelationValue "
+" and ";
indexDummyRelationValue.add(String.valueOf(counter));
}else{
strQueryWhere += " = '" + "dummyRelationValue"
+"' and ";
indexDummyRelationValue.add(String.valueOf(counter));
}
} catch (LoaderException e) {
LoaderException le = new LoaderException("Exception:Type not present in conf file for target database, add it into conf file.",(Throwable)e);
throw le;
}
}
}
/**
* This method read the input parameters and sets the parameter strQueryWhere
* @param vecTempConstantColumns is input parameter
* @param vecTempConstantMode is input parameter
* @param vecTempConstantType is input parameter
* @param configReaderTarget is input parameter
*/
public void getConstantKeyColumns(Vector vecTempConstantColumns, Vector vecTempConstantMode,
Vector vecTempConstantType, ConfigReader configReaderTarget) throws LoaderException{
int counter=0;
for (int k = 0; k < vecTempConstantColumns.size(); k++) {
counter=k;
if (vecTempConstantMode.get(k).toString().equalsIgnoreCase("Key")) {
strQueryWhere += vecTempConstantColumns.get(k).toString();
//ZK change this 7.5.2004 from CheckType to configReaderTarget
try {
if (configReaderTarget.isNumber(vecTempConstantType.get(k).toString())){
strQueryWhere += " = "+ "dummyConstantValue"
+ " and ";
indexDummyConstantValue.add(String.valueOf(counter));
}else{
strQueryWhere += " = '"+ "dummyConstantValue"
+"' and ";
indexDummyConstantValue.add(String.valueOf(counter));
}
} catch (LoaderException e) {
LoaderException le = new LoaderException("Exception:Type not present in conf file for target database, add it into conf file.",(Throwable)e);
throw le;
}
}
}
}
/**
** This method read the input parameters and sets the parameter strQueryWhere
* @param vecVariableColumnTargetTableName is input parameter
* @param vecVariableColumnTargetTableID is input parameter
* @param vecVariableColumnValueMode is input parameter
* @param vecVariableName is input parameter
* @param vecVariableColumnName is input parameter
* @param vecVariableColumnTargetColumnName is input parameter
* @param vecVariableColumnTypes is input parameter
* @param logger is input parameter
* @param configReader is input parameter
* @throws LoaderException
*/
public void getVariableKeyColumns(Vector vecVariableColumnTargetTableName,
Vector vecVariableColumnTargetTableID, Vector vecVariableColumnValueMode,
Vector vecVariableName, Vector vecVariableColumnName,
Vector vecVariableColumnTargetColumnName,
Vector vecVariableColumnTypes, Logger logger,
ConfigReader configReader) throws LoaderException{
int counter=0;
for (int i = 0; i < vecVariableColumnTargetTableName.size(); i++) {
if (vecVariableColumnTargetTableName.get(i).toString().equalsIgnoreCase(
tableName)
&& vecVariableColumnTargetTableID.get(i).toString().equalsIgnoreCase(
tableID)
&& vecVariableColumnValueMode.get(i).toString().equalsIgnoreCase("Key")) {
int iPositionInVector = vecVariableName.indexOf(vecVariableColumnName.get(i).toString());
if (iPositionInVector != -1) {
counter=iPositionInVector;
strQueryWhere += vecVariableColumnTargetColumnName.get(i).toString();
//ZK change this 7.5.2004 from CheckType to configReaderTarget
if (!configReader.isNumber(vecVariableColumnTypes.get(i).toString())){
strQueryWhere += "= '" + "dummyVariableValue"
+"' and ";
indexDummyVariableValue.add(String.valueOf(counter));
}else{
strQueryWhere += " = "+ "dummyVariableValue"
+ " and ";
indexDummyVariableValue.add(String.valueOf(counter));
}
}else {
logger.write("normal", "\tError: Cannot find value for variable column :"
+ vecVariableColumnName.get(i).toString());
LoaderException le = new LoaderException("Exception: ",
(Throwable)(new Exception("Error: Cannot find value for variable column :")));
throw le;
}
}
}
}
/**
* This method read the value of strQueryWhere parameter
* @return value of parameter
*/
public String getQueryWhere(){
return strQueryWhere;
}
/**
* This method read the value of indexDummyValue parameter
* @return value of parameter
*/
public Vector getIndexDummyValue(){
return indexDummyValue;
}
/**
* This method read the value of indexDummyTransformationValue parameter
* @return value of parameter
*/
//ZK added this for transformations
public Vector getTransformationKeyColumns(){
return indexDummyTransformationValue;
}
/**
* This method read the value of indexDummyRelationValue parameter
* @return value of parameter
*/
public Vector getIndexDummyRelationValue(){
return indexDummyRelationValue;
}
/**
* This method read the value of indexDummyConstantValue parameter
* @return value of parameter
*/
public Vector getIndexDummyConstantValue(){
return indexDummyConstantValue;
}
/**
* This method read the value of indexDummyVariableValue parameter
* @return value of parameter
*/
public Vector getIndexDummyVariableValue(){
return indexDummyVariableValue;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -