View Javadoc
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; 24 25 import java.util.*; 26 import java.sql.*; 27 28 /*** 29 * 30 * QueryUpdateSet class creates the update sql statement 31 * @author Radoslav Dutina 32 * @version 1.0 33 */ 34 public class QueryUpdateSet { 35 36 private String strQueryUpdate=null; 37 private Vector indexDummyOverwrite=new Vector(); 38 // private Vector indexDummyUpdate=new Vector(); 39 private Vector indexDummySetNull=new Vector(); 40 private String versionName="version"; 41 42 /*** 43 * Construct the object of QueryUpdateSet class with associated parameter 44 * @param vecColumnNames is vector which contain column names 45 * @param vecColumnTypes is vector which contain column types 46 * @param vecColumnMode is vector which contain column mode 47 * @param tableName is the current table name 48 * @param oid is boolean parameter 49 */ 50 public QueryUpdateSet(Vector vecColumnNames, Vector vecColumnTypes, Vector vecColumnMode, 51 String tableName, boolean oid, String versionName, ConfigReader configReaderTarget) throws LoaderException { 52 53 this.versionName=versionName; 54 // this.strQueryUpdate=strQueryUpdate; 55 strQueryUpdate="update " + tableName + " set "; 56 int counter=0; 57 for (int j = 0; j < vecColumnNames.size(); j++) { 58 counter=j; 59 if (vecColumnMode.get(j).toString().equalsIgnoreCase("Overwrite")) { 60 indexDummyOverwrite.add(String.valueOf(counter)); 61 strQueryUpdate+=vecColumnNames.get(j).toString()+"="; 62 try { 63 if(!configReaderTarget.isNumber(vecColumnTypes.get(j).toString())){ 64 if(configReaderTarget.isWithN(vecColumnTypes.get(j).toString())){ 65 strQueryUpdate+="N"; 66 } 67 strQueryUpdate+="'dummyOverwrite'"+", "; 68 }else{ 69 strQueryUpdate+="dummyOverwrite"+", "; 70 } 71 } catch (LoaderException e) { 72 LoaderException le = new LoaderException("Exception:Type not present in conf file for target database, add it into conf file.",(Throwable)e); 73 throw le; 74 } 75 }else if (vecColumnMode.get(j).toString().equalsIgnoreCase("SetNull")) { 76 strQueryUpdate +="dummySetNull"+", "; 77 indexDummySetNull.add(String.valueOf(counter)); 78 } 79 } 80 if(oid) 81 strQueryUpdate += " "+this.versionName+" = " + "dummyVersionOverwrite" + " where "; 82 else{ 83 int start=strQueryUpdate.lastIndexOf(","); 84 if(start<strQueryUpdate.length()-1&&start!=-1) 85 strQueryUpdate=strQueryUpdate.substring(0,strQueryUpdate.lastIndexOf(",")); 86 strQueryUpdate += " where "; 87 } 88 } 89 90 /*** 91 * This method read the value of strQueryUpdate parameter 92 * @return value of parameter 93 */ 94 public String getQueryUpdate(){ 95 return this.strQueryUpdate ; 96 } 97 98 /*** 99 * This method read the value of indexDummyOverwrite parameter 100 * @return value of parameter 101 */ 102 public Vector getIndexDummyOverwrite(){ 103 return indexDummyOverwrite; 104 } 105 106 /*** 107 * This method read the value of indexDummySetNull parameter 108 * @return value of parameter 109 */ 110 public Vector getIndexDummySetNull(){ 111 return indexDummySetNull; 112 } 113 114 115 }

This page was automatically generated by Maven