KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > webdocwf > util > loader > transformation > QueryTransformationSet


1 /**
2 LoaderGenerator - tool for generated xml, sql and doml file needed for Octopus.
3
4
5     Copyright (C) 2003 Together
6
7     This library is free software; you can redistribute it and/or
8     modify it under the terms of the GNU Lesser General Public
9     License as published by the Free Software Foundation; either
10     version 2.1 of the License, or (at your option) any later version.
11
12     This library is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15     Lesser General Public License for more details.
16
17     You should have received a copy of the GNU Lesser General Public
18     License along with this library; if not, write to the Free Software
19     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */

21   
22 package org.webdocwf.util.loader.transformation;
23
24 import java.util.Vector JavaDoc;
25
26 import org.webdocwf.util.loader.ConfigReader;
27 import org.webdocwf.util.loader.LoaderException;
28
29 /**
30  *
31  * QueryTransformationSet class sets the query statement for constant columns
32  * @author unascribed
33  * @version 1.0
34  * @author Zeljko Kovacevic
35  */

36 public class QueryTransformationSet {
37
38     private String JavaDoc strQueryTransformation = null;
39     private Vector JavaDoc indexDummyOverwrite = new Vector JavaDoc();
40     private Vector JavaDoc indexDummyNull = new Vector JavaDoc();
41     private Vector JavaDoc indexDummyUpdate = new Vector JavaDoc();
42     private ConfigReader targetConfigReader;
43     /**
44      * Construct object QueryTransformationSet class with associated parameters
45      * @param tableName current table name
46      * @param vecTransformationColumns vector of tarnsformation column names
47      * @param vecTransformationValueMode vector of tarnsformation column modes
48      * @param vecTransformationType vector of tarnsformation column types
49      * @param targetConfigReader is ConfigReader object for target database
50      */

51     public QueryTransformationSet(
52         String JavaDoc tableName,
53         Vector JavaDoc vecTransformationColumns,
54         Vector JavaDoc vecTransformationValueMode,
55         Vector JavaDoc vecTransformationType, ConfigReader targetConfigReader) throws LoaderException {
56         strQueryTransformation = "update " + tableName + " set ";
57         for (int i = 0; i < vecTransformationColumns.size(); i++) {
58             if (vecTransformationValueMode.get(i).toString().equalsIgnoreCase("Overwrite")) {
59 //ZK change this from CheckType to targetConfigReader
60
try {
61             if (!targetConfigReader.isNumber(vecTransformationType.get(i).toString())) {
62                 strQueryTransformation
63                     += vecTransformationColumns.get(i).toString()
64                     + " = "
65                     + "'dummyTransformationOver'"
66                     + ", ";
67             } else {
68                 strQueryTransformation
69                     += vecTransformationColumns.get(i).toString()
70                     + " = "
71                     + "dummyTransformationOver"
72                     + ", ";
73             }
74             
75         } catch (LoaderException e) {
76                                 LoaderException le = new LoaderException("Exception:Type not present in conf file for target database, add it into conf file.",(Throwable JavaDoc)e);
77                             throw le;
78         }
79                 indexDummyOverwrite.add(String.valueOf(i));
80             } else if (vecTransformationValueMode.get(i).toString().equalsIgnoreCase("SetNull")) {
81                 strQueryTransformation+="dummyTransformationNull, ";
82                 indexDummyNull.add(String.valueOf(i));
83             }else if (vecTransformationValueMode.get(i).toString().equalsIgnoreCase("Update")){
84                 indexDummyUpdate.add(String.valueOf(i));
85             }
86         }
87     }
88
89     /**
90      * This method read value of strQueryTransformation parameter
91      * @return value of parameter
92      */

93     public String JavaDoc getQueryTransformation() {
94         return strQueryTransformation;
95     }
96
97     /**
98      * This method read value from indexDummyOverwrite parameter
99      * @return value of parameter
100      */

101     public Vector JavaDoc getIndexDummyOverwrite() {
102         return indexDummyOverwrite;
103     }
104
105     /**
106      * This method read value from indexDummyNull parameter
107      * @return value of parameter
108      */

109     public Vector JavaDoc getIndexDummyNull() {
110         return indexDummyNull;
111     }
112     /**
113      * This method read value from indexDummyUpdate parameter
114      * @return value of parameter
115      */

116     public Vector JavaDoc getIndexDummyUpdate() {
117         return indexDummyUpdate;
118     }
119 }
Popular Tags