KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > extractor > oracle > Loader


1 /*
2  * This file belongs to the XQuark distribution.
3  * Copyright (C) 2003 Universite de Versailles Saint-Quentin.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307.
18  * You can also get it at http://www.gnu.org/licenses/lgpl.html
19  *
20  * For more information on this software, see http://www.xquark.org.
21  */

22
23 package org.xquark.extractor.oracle;
24
25 import java.sql.Connection JavaDoc;
26 import java.sql.SQLException JavaDoc;
27 import java.util.ArrayList JavaDoc;
28 import java.util.List JavaDoc;
29
30 import org.xquark.extractor.common.MetaDataException;
31 import org.xquark.extractor.metadata.*;
32 import org.xquark.extractor.runtime.Selection;
33 import org.xquark.jdbc.typing.DBMSInfo;
34 import org.xquark.jdbc.typing.DbType;
35
36 public final class Loader extends org.xquark.extractor.metadata.Loader {
37
38     private static final String JavaDoc RCSRevision = "$Revision: 1.11 $";
39     private static final String JavaDoc RCSName = "$Name: $";
40
41     public Loader(Connection JavaDoc connection, DBMSInfo dbmsInfo, QNameEncoder encoder) throws SQLException JavaDoc {
42         super(connection, dbmsInfo, encoder);
43     }
44
45     protected void loadKeys(String JavaDoc catalogName, String JavaDoc schemaName, Table table, Selection selection) throws MetaDataException {
46         //Trace.enter(this, "loadKeys(String catalogName, String schemaName, Table table, Selection selection)", table.getName());
47
/* load Primary Keys for this table */
48         //Trace.message(this, "loadTable(...)", "creating pseudoAttribute column...");
49
List JavaDoc key = new ArrayList JavaDoc();
50
51         PseudoAttribute rowId = new PseudoAttribute("ROWID");
52         rowId.setMappingInfo(new ExtractorMappingInfo(new DbType(DbType.ORACLE_ROWID), _dbmsInfo.getTypeMap()));
53         key.add(rowId);
54         table.addKey(key);
55         super.loadKeys(catalogName, schemaName, table, selection);
56         //Trace.exit(this, "loadKeys(String catalogName, String schemaName, Table table, Selection selection)", table.getName());
57
}
58
59     protected String JavaDoc createQuery(String JavaDoc catalogName, String JavaDoc schemaName, String JavaDoc origTableName) {
60         StringBuffer JavaDoc retVal = new StringBuffer JavaDoc();
61
62         retVal.append("SELECT * FROM ");
63         if (null != catalogName && 0 < catalogName.trim().length()) {
64             retVal.append('"');
65             retVal.append(catalogName.trim());
66             retVal.append("\".");
67         }
68         if (null != schemaName && 0 < schemaName.trim().length()) {
69             retVal.append('"');
70             retVal.append(schemaName.trim());
71             retVal.append("\".");
72         }
73         if (null != origTableName && 0 < origTableName.trim().length()) {
74             retVal.append('"');
75             retVal.append(origTableName.trim());
76             retVal.append('"');
77         }
78         retVal.append(" WHERE 0=1");
79         return retVal.toString();
80     }
81 }
82
Popular Tags