Source Code Cross Referenced for QueryWhereSet.java in  » Database-JDBC-Connection-Pool » octopus » org » webdocwf » util » loader » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database JDBC Connection Pool » octopus » org.webdocwf.util.loader 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:        import org.webdocwf.util.loader.logging.*;
027:
028:        /**
029:         *
030:         * QueryWhereSet class creates the where condition in sql statement
031:         * @author Radoslav Dutina
032:         * @version 1.0
033:         */
034:        public class QueryWhereSet {
035:
036:            private String strQueryWhere = " where ";
037:            private Vector vecColumnNames = null;
038:            private Vector vecColumnTypes = null;
039:            private String tableName = null;
040:            private String tableID = null;
041:            private Vector indexDummyValue = new Vector();
042:            private Vector indexDummyRelationValue = new Vector();
043:            private Vector indexDummyConstantValue = new Vector();
044:            private Vector indexDummyVariableValue = new Vector();
045:            private Vector indexDummyTransformationValue = new Vector();
046:
047:            /**
048:             * Construct object of QueryWhereSet class with associated parameters
049:             * @param vecColumnNames is vector which contain column names
050:             * @param vecColumnTypes is vector which contain column types
051:             * @param tableName is the current table name
052:             * @param tableID is ID of current table
053:             */
054:            public QueryWhereSet(Vector vecColumnNames, Vector vecColumnTypes,
055:                    String tableName, String tableID) {
056:                this .vecColumnNames = vecColumnNames;
057:                this .vecColumnTypes = vecColumnTypes;
058:                this .tableName = tableName;
059:                this .tableID = tableID;
060:            }
061:
062:            /**
063:             * This method read the value of vecTempKeyColumns and sets the parameter strQueryWhere
064:             * @param vecTempKeyColumns is the value of parameter
065:             * @param configReaderTarget is ConfigReader object for target database
066:             */
067:            public void getKeyColumns(Vector vecTempKeyColumns,
068:                    ConfigReader configReaderTarget) throws LoaderException {
069:
070:                for (int k = 0; k < vecTempKeyColumns.size(); k++) {
071:                    if (vecColumnNames.size() != 0) {
072:                        for (int l = 0; l < vecColumnNames.size(); l++) {
073:                            if (vecTempKeyColumns.get(k).toString()
074:                                    .equalsIgnoreCase(
075:                                            vecColumnNames.get(l).toString())) {
076:                                //            int counter=l;
077:                                strQueryWhere += vecColumnNames.get(l)
078:                                        .toString();
079:                                //ZK change this from CheckType to configReaderTarget
080:                                try {
081:                                    if (!configReaderTarget
082:                                            .isNumber(vecColumnTypes.get(l)
083:                                                    .toString())) {
084:                                        strQueryWhere += " = '" + "dummyValue"
085:                                                + "' and ";
086:                                        indexDummyValue.add(String.valueOf(l));
087:                                    } else {
088:                                        strQueryWhere += " = " + "dummyValue"
089:                                                + " and ";
090:                                        indexDummyValue.add(String.valueOf(l));
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:                            }
099:                        }
100:                    }
101:                }
102:            }
103:
104:            /**
105:             * This method read the value of vecTempKeyTransformation and sets the parameter strQueryWhere
106:             * @param transformationTargetColumns is Vector with target columns in for this transformation
107:             * @param vecTempKeyTransformation is Vector with key columns
108:             * @param transformationColumnTypes is Vector with target with column types
109:             * @param configReaderTarget is ConfigReader object for target database
110:             */
111:            //ZK added this method for Transformations
112:            public void getTransformationKeyColumns(
113:                    Vector transformationTargetColumns,
114:                    Vector vecTempKeyTransformation,
115:                    Vector transformationColumnTypes,
116:                    ConfigReader configReaderTarget) throws LoaderException {
117:
118:                for (int k = 0; k < vecTempKeyTransformation.size(); k++) {
119:                    if (transformationTargetColumns.size() != 0) {
120:                        for (int l = 0; l < transformationTargetColumns.size(); l++) {
121:                            if (vecTempKeyTransformation.get(k).toString()
122:                                    .equalsIgnoreCase(
123:                                            transformationTargetColumns.get(l)
124:                                                    .toString())) {
125:                                strQueryWhere += transformationTargetColumns
126:                                        .get(l).toString();
127:                                //ZK change this 7.5.2004 from CheckType to configReaderTarget			
128:                                try {
129:                                    if (!configReaderTarget
130:                                            .isNumber(transformationColumnTypes
131:                                                    .get(l).toString())) {
132:                                        strQueryWhere += " = '"
133:                                                + "dummyTransformationValue"
134:                                                + "' and ";
135:                                        indexDummyTransformationValue
136:                                                .add(String.valueOf(l));
137:                                    } else {
138:                                        strQueryWhere += " = "
139:                                                + "dummyTransformationValue"
140:                                                + " and ";
141:                                        indexDummyTransformationValue
142:                                                .add(String.valueOf(l));
143:                                    }
144:                                } catch (LoaderException e) {
145:                                    LoaderException le = new LoaderException(
146:                                            "Exception:Type not present in conf file for target database, add it into conf file.",
147:                                            (Throwable) e);
148:                                    throw le;
149:                                }
150:                            }
151:                        }
152:                    }
153:                }
154:            }
155:
156:            /**
157:             * This method read the input parameters and sets the parameter strQueryWhere
158:             * @param vecRelationKeyColumns is input parameter
159:             * @param iRelationColumns is input parameter
160:             * @param vecRelationColumnTargetTableName is input parameter
161:             * @param vecRelationColumnTargetTableID is input parameter
162:             * @param vecRelationColumnTargetColumnName is input parameter
163:             * @param vecRelationKeyTypes is input parameter
164:             * @param configReaderTarget is input parameter
165:             */
166:            public void getRelationKeyColumns(Vector vecRelationKeyColumns,
167:                    int iRelationColumns,
168:                    Vector vecRelationColumnTargetTableName,
169:                    Vector vecRelationColumnTargetTableID,
170:                    Vector vecRelationColumnTargetColumnName,
171:                    Vector vecRelationKeyTypes, ConfigReader configReaderTarget)
172:                    throws LoaderException {
173:
174:                for (int k = 0; k < vecRelationKeyColumns.size(); k++) {
175:                    int counter = 0;
176:                    int iNumRelation = -1;
177:                    for (int p = 0; p < iRelationColumns; p++) {
178:                        if (vecRelationColumnTargetTableName.get(p).toString()
179:                                .equalsIgnoreCase(tableName)
180:                                && vecRelationColumnTargetTableID.get(p)
181:                                        .toString().equalsIgnoreCase(tableID)
182:                                && vecRelationColumnTargetColumnName.get(p)
183:                                        .toString().equalsIgnoreCase(
184:                                                vecRelationKeyColumns.get(k)
185:                                                        .toString())) {
186:                            iNumRelation = p;
187:                            counter = p;
188:                        }
189:                    }
190:                    strQueryWhere += vecRelationKeyColumns.get(k).toString();
191:                    //ZK change this 7.5.2004 from CheckType to configReaderTarget
192:                    //TODO ZK change 11.6.2004 from vecRelationKeyColumns to vecRelationKeyTypes
193:
194:                    try {
195:                        if (configReaderTarget.isNumber(vecRelationKeyTypes
196:                                .get(k).toString())) {
197:                            strQueryWhere += " = " + "dummyRelationValue "
198:                                    + " and ";
199:                            indexDummyRelationValue
200:                                    .add(String.valueOf(counter));
201:                        } else {
202:                            strQueryWhere += " = '" + "dummyRelationValue"
203:                                    + "' and ";
204:                            indexDummyRelationValue
205:                                    .add(String.valueOf(counter));
206:                        }
207:                    } catch (LoaderException e) {
208:                        LoaderException le = new LoaderException(
209:                                "Exception:Type not present in conf file for target database, add it into conf file.",
210:                                (Throwable) e);
211:                        throw le;
212:                    }
213:                }
214:            }
215:
216:            /**
217:             * This method read the input parameters and sets the parameter strQueryWhere
218:             * @param vecTempConstantColumns is input parameter
219:             * @param vecTempConstantMode is input parameter
220:             * @param vecTempConstantType is input parameter
221:             * @param configReaderTarget is input parameter
222:             */
223:            public void getConstantKeyColumns(Vector vecTempConstantColumns,
224:                    Vector vecTempConstantMode, Vector vecTempConstantType,
225:                    ConfigReader configReaderTarget) throws LoaderException {
226:
227:                int counter = 0;
228:                for (int k = 0; k < vecTempConstantColumns.size(); k++) {
229:                    counter = k;
230:                    if (vecTempConstantMode.get(k).toString().equalsIgnoreCase(
231:                            "Key")) {
232:                        strQueryWhere += vecTempConstantColumns.get(k)
233:                                .toString();
234:                        //ZK change this 7.5.2004 from CheckType to configReaderTarget
235:                        try {
236:                            if (configReaderTarget.isNumber(vecTempConstantType
237:                                    .get(k).toString())) {
238:                                strQueryWhere += " = " + "dummyConstantValue"
239:                                        + " and ";
240:                                indexDummyConstantValue.add(String
241:                                        .valueOf(counter));
242:
243:                            } else {
244:                                strQueryWhere += " = '" + "dummyConstantValue"
245:                                        + "' and ";
246:                                indexDummyConstantValue.add(String
247:                                        .valueOf(counter));
248:
249:                            }
250:                        } catch (LoaderException e) {
251:                            LoaderException le = new LoaderException(
252:                                    "Exception:Type not present in conf file for target database, add it into conf file.",
253:                                    (Throwable) e);
254:                            throw le;
255:                        }
256:                    }
257:                }
258:            }
259:
260:            /**
261:             ** This method read the input parameters and sets the parameter strQueryWhere
262:             * @param vecVariableColumnTargetTableName is input parameter
263:             * @param vecVariableColumnTargetTableID is input parameter
264:             * @param vecVariableColumnValueMode is input parameter
265:             * @param vecVariableName is input parameter
266:             * @param vecVariableColumnName is input parameter
267:             * @param vecVariableColumnTargetColumnName is input parameter
268:             * @param vecVariableColumnTypes is input parameter
269:             * @param logger is input parameter
270:             * @param configReader is input parameter
271:             * @throws LoaderException
272:             */
273:            public void getVariableKeyColumns(
274:                    Vector vecVariableColumnTargetTableName,
275:                    Vector vecVariableColumnTargetTableID,
276:                    Vector vecVariableColumnValueMode, Vector vecVariableName,
277:                    Vector vecVariableColumnName,
278:                    Vector vecVariableColumnTargetColumnName,
279:                    Vector vecVariableColumnTypes, Logger logger,
280:                    ConfigReader configReader) throws LoaderException {
281:
282:                int counter = 0;
283:                for (int i = 0; i < vecVariableColumnTargetTableName.size(); i++) {
284:                    if (vecVariableColumnTargetTableName.get(i).toString()
285:                            .equalsIgnoreCase(tableName)
286:                            && vecVariableColumnTargetTableID.get(i).toString()
287:                                    .equalsIgnoreCase(tableID)
288:                            && vecVariableColumnValueMode.get(i).toString()
289:                                    .equalsIgnoreCase("Key")) {
290:                        int iPositionInVector = vecVariableName
291:                                .indexOf(vecVariableColumnName.get(i)
292:                                        .toString());
293:                        if (iPositionInVector != -1) {
294:                            counter = iPositionInVector;
295:                            strQueryWhere += vecVariableColumnTargetColumnName
296:                                    .get(i).toString();
297:                            //ZK change this 7.5.2004 from CheckType to configReaderTarget        
298:                            if (!configReader.isNumber(vecVariableColumnTypes
299:                                    .get(i).toString())) {
300:                                strQueryWhere += "= '" + "dummyVariableValue"
301:                                        + "' and ";
302:                                indexDummyVariableValue.add(String
303:                                        .valueOf(counter));
304:                            } else {
305:                                strQueryWhere += " = " + "dummyVariableValue"
306:                                        + " and ";
307:                                indexDummyVariableValue.add(String
308:                                        .valueOf(counter));
309:
310:                            }
311:                        } else {
312:                            logger.write("normal",
313:                                    "\tError: Cannot find value for variable column :"
314:                                            + vecVariableColumnName.get(i)
315:                                                    .toString());
316:                            LoaderException le = new LoaderException(
317:                                    "Exception: ",
318:                                    (Throwable) (new Exception(
319:                                            "Error: Cannot find value for variable column :")));
320:                            throw le;
321:                        }
322:                    }
323:                }
324:            }
325:
326:            /**
327:             * This method read the value of strQueryWhere parameter
328:             * @return value of parameter
329:             */
330:            public String getQueryWhere() {
331:                return strQueryWhere;
332:            }
333:
334:            /**
335:             * This method read the value of indexDummyValue parameter
336:             * @return value of parameter
337:             */
338:            public Vector getIndexDummyValue() {
339:                return indexDummyValue;
340:            }
341:
342:            /**
343:             * This method read the value of indexDummyTransformationValue parameter
344:             * @return value of parameter
345:             */
346:            //ZK added this for transformations
347:            public Vector getTransformationKeyColumns() {
348:                return indexDummyTransformationValue;
349:            }
350:
351:            /**
352:             * This method read the value of indexDummyRelationValue parameter
353:             * @return value of parameter
354:             */
355:            public Vector getIndexDummyRelationValue() {
356:                return indexDummyRelationValue;
357:            }
358:
359:            /**
360:             * This method read the value of indexDummyConstantValue parameter
361:             * @return value of parameter
362:             */
363:            public Vector getIndexDummyConstantValue() {
364:                return indexDummyConstantValue;
365:            }
366:
367:            /**
368:             * This method read the value of indexDummyVariableValue parameter
369:             * @return value of parameter
370:             */
371:            public Vector getIndexDummyVariableValue() {
372:                return indexDummyVariableValue;
373:            }
374:
375:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.