Clover Coverage Report - Impex Parent 1.0.21-SNAPSHOT (Aggregated)
Coverage timestamp: Tue Feb 8 2011 11:33:53 EST
../../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
57   156   18   5.18
6   102   0.32   11
11     1.64  
1    
 
  PlatformOracleImpl       Line # 38 57 0% 18 74 0% 0.0
 
No Tests
 
1    package org.apache.torque.engine.platform;
2   
3    /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements. See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership. The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10    * with the License. You may obtain a copy of the License at
11    *
12    * http://www.apache.org/licenses/LICENSE-2.0
13    *
14    * Unless required by applicable law or agreed to in writing,
15    * software distributed under the License is distributed on an
16    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17    * KIND, either express or implied. See the License for the
18    * specific language governing permissions and limitations
19    * under the License.
20    */
21   
22    import java.sql.Connection;
23    import java.sql.DatabaseMetaData;
24    import java.sql.PreparedStatement;
25    import java.sql.ResultSet;
26    import java.sql.SQLException;
27    import java.util.List;
28   
29    import org.apache.torque.engine.database.model.Domain;
30    import org.apache.torque.engine.database.model.SchemaType;
31   
32    /**
33    * Oracle Platform implementation.
34    *
35    * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
36    * @version $Id: PlatformOracleImpl.java,v 1.1.6.1 2008-04-18 17:04:37 jkeller Exp $
37    */
 
38    public class PlatformOracleImpl extends PlatformDefaultImpl {
39    /**
40    * Default constructor.
41    */
 
42  0 toggle public PlatformOracleImpl() {
43  0 super();
44  0 initialize();
45    }
46   
47    /**
48    * Initializes db specific domain mapping.
49    */
 
50  0 toggle private void initialize() {
51  0 setSchemaDomainMapping(new Domain(SchemaType.TINYINT, "NUMBER", "3", "0"));
52  0 setSchemaDomainMapping(new Domain(SchemaType.SMALLINT, "NUMBER", "5", "0"));
53  0 setSchemaDomainMapping(new Domain(SchemaType.INTEGER, "NUMBER", "10", "0"));
54  0 setSchemaDomainMapping(new Domain(SchemaType.BOOLEANINT, "NUMBER", "1", "0"));
55  0 setSchemaDomainMapping(new Domain(SchemaType.BIGINT, "NUMBER", "20", "0"));
56  0 setSchemaDomainMapping(new Domain(SchemaType.REAL, "NUMBER"));
57  0 setSchemaDomainMapping(new Domain(SchemaType.DOUBLE, "FLOAT"));
58  0 setSchemaDomainMapping(new Domain(SchemaType.DECIMAL, "NUMBER"));
59  0 setSchemaDomainMapping(new Domain(SchemaType.NUMERIC, "NUMBER"));
60  0 setSchemaDomainMapping(new Domain(SchemaType.VARCHAR, "VARCHAR2"));
61  0 setSchemaDomainMapping(new Domain(SchemaType.LONGVARCHAR, "VARCHAR2", "2000"));
62  0 setSchemaDomainMapping(new Domain(SchemaType.TIME, "DATE"));
63  0 setSchemaDomainMapping(new Domain(SchemaType.TIMESTAMP, "TIMESTAMP"));
64  0 setSchemaDomainMapping(new Domain(SchemaType.BINARY, "LONG RAW"));
65  0 setSchemaDomainMapping(new Domain(SchemaType.VARBINARY, "BLOB"));
66  0 setSchemaDomainMapping(new Domain(SchemaType.LONGVARBINARY, "LONG RAW"));
67    }
68   
 
69  0 toggle @Override
70    public String getSchemaName(String artifactId) {
71  0 String s = super.getSchemaName(artifactId);
72  0 return s.toUpperCase();
73    }
74   
75    /**
76    * @see Platform#getMaxColumnNameLength()
77    */
 
78  0 toggle public int getMaxColumnNameLength() {
79  0 return 30;
80    }
81   
82    /**
83    * @see Platform#getNativeIdMethod()
84    */
 
85  0 toggle public String getNativeIdMethod() {
86  0 return Platform.SEQUENCE;
87    }
88   
89    /**
90    * @see Platform#getAutoIncrement()
91    */
 
92  0 toggle public String getAutoIncrement() {
93  0 return "";
94    }
95   
 
96  0 toggle @Override
97    public List<String> getPrimaryKeys(DatabaseMetaData dbMeta, String dbSchema, String tableName) throws SQLException {
98  0 return super.getPrimaryKeys(dbMeta, dbSchema.toUpperCase(), tableName);
99    }
100   
 
101  0 toggle public List<String> getTableNames(DatabaseMetaData dbMeta, String databaseSchema) throws SQLException {
102  0 return super.getTableNames(dbMeta, databaseSchema.toUpperCase());
103    }
104   
 
105  0 toggle @Override
106    public boolean isSpecialDefault(String defaultValue) {
107  0 defaultValue = defaultValue.toUpperCase();
108  0 if (defaultValue.contains("SYS_GUID()") || defaultValue.contains("SYSDATE") || defaultValue.contains("USERENV(\'SESSIONID\')")) {
109  0 return true;
110    }
111  0 return false;
112    }
113   
 
114  0 toggle @Override
115    public Long getSequenceNextVal(Connection con, String schema, String sequenceName) {
116  0 try {
117  0 PreparedStatement ps = con.prepareStatement("SELECT last_number FROM all_sequences WHERE sequence_owner = ? AND sequence_name = ?");
118  0 Long nextVal = 0L;
119  0 ps.setString(1, schema.toUpperCase());
120  0 ps.setString(2, sequenceName.toUpperCase());
121  0 ResultSet rs = ps.executeQuery();
122  0 if (rs.next()) {
123  0 nextVal = rs.getLong(1);
124    }
125  0 rs.close();
126  0 ps.close();
127  0 return nextVal;
128    } catch (SQLException ex) {
129  0 System.err.println("Unable to extract sequence definition: " + schema + "." + sequenceName);
130  0 ex.printStackTrace();
131  0 return 0L;
132    }
133    }
134   
 
135  0 toggle @Override
136    public String getViewDefinition(Connection con, String schema, String viewName) {
137  0 try {
138  0 PreparedStatement ps = con.prepareStatement("SELECT text FROM all_views WHERE owner = ? AND view_name = ?");
139  0 String definition = "";
140  0 ps.setString(1, schema.toUpperCase());
141  0 ps.setString(2, viewName.toUpperCase());
142  0 ResultSet rs = ps.executeQuery();
143  0 if (rs.next()) {
144  0 definition = rs.getString(1);
145    }
146  0 rs.close();
147  0 ps.close();
148  0 return definition;
149    } catch (SQLException ex) {
150  0 System.err.println("Unable to extract view definition: " + schema + "." + viewName);
151  0 ex.printStackTrace();
152  0 return "";
153    }
154    }
155   
156    }