View Javadoc

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.SQLException;
25  import java.util.List;
26  
27  import org.apache.torque.engine.database.model.Domain;
28  import org.apache.torque.engine.database.model.SchemaType;
29  import org.kuali.common.impex.service.SqlProducer;
30  
31  /**
32   * Interface for RDBMS platform specific behaviour.
33   *
34   * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
35   * @version $Id: Platform.java,v 1.1.6.2 2008-04-18 17:04:37 jkeller Exp $
36   */
37  public interface Platform {
38  	/** constant for native id method */
39  	String IDENTITY = "identity";
40  	/** constant for native id method */
41  	String SEQUENCE = "sequence";
42  
43  	/**
44  	 * Given a JDBC url return a url that can connect directly to the database server itself. ie no database specified
45  	 */
46  	String getServerUrl(String url);
47  
48  	/**
49  	 * Given an artifact id, return a string a schema name based on the artifact id that is allowed by the db vendor
50  	 */
51  	String getSchemaName(String artifactId);
52  
53  	/**
54  	 * Returns the native IdMethod (sequence|identity)
55  	 *
56  	 * @return the native IdMethod
57  	 */
58  	String getNativeIdMethod();
59  
60  	/**
61  	 * Returns the max column length supported by the db.
62  	 *
63  	 * @return the max column length
64  	 */
65  	int getMaxColumnNameLength();
66  
67  	/**
68  	 * Returns the db specific domain for a jdbcType.
69  	 *
70  	 * @param jdbcType
71  	 *            the jdbcType name
72  	 * @return the db specific domain
73  	 */
74  	Domain getDomainForSchemaType(SchemaType jdbcType);
75  
76  	/**
77  	 * @return The RDBMS-specific SQL fragment for <code>NULL</code> or <code>NOT NULL</code>.
78  	 */
79  	String getNullString(boolean notNull);
80  
81  	/**
82  	 * @return The RDBMS-specific SQL fragment for autoincrement.
83  	 */
84  	String getAutoIncrement();
85  
86  	/**
87  	 * Returns if the RDBMS-specific SQL type has a size attribute.
88  	 *
89  	 * @param sqlType
90  	 *            the SQL type
91  	 * @return true if the type has a size attribute
92  	 */
93  	boolean hasSize(String sqlType);
94  
95  	/**
96  	 * Returns if the RDBMS-specific SQL type has a scale attribute.
97  	 *
98  	 * @param sqlType
99  	 *            the SQL type
100 	 * @return true if the type has a scale attribute
101 	 */
102 	boolean hasScale(String sqlType);
103 
104 	/**
105 	 * Returns whether the "not null part" of the definition of a column should be generated before the "autoincrement part" in a
106 	 * "create table" statement.
107 	 *
108 	 * @return true if the "not null part" should be first, false if the "autoincrement part" should be first in a "create table" statement.
109 	 */
110 	boolean createNotNullBeforeAutoincrement();
111 
112 	String filterInvalidDefaultValues(String defaultValue);
113 
114 	public boolean isSpecialDefault(String defaultValue);
115 
116 	String getViewDefinition(Connection con, String schema, String viewName);
117 
118 	Long getSequenceNextVal(Connection con, String schema, String sequenceName);
119 
120 	public List<String> getPrimaryKeys(DatabaseMetaData dbMeta, String dbSchema, String tableName) throws SQLException;
121 
122 	public List<String> getTableNames(DatabaseMetaData dbMeta, String databaseSchema) throws SQLException;
123 
124 	/**
125 	 * Get the list of sequences defined in the database schema given.
126 	 *
127 	 * @param dbMetaData
128 	 * @param databaseSchema
129 	 * @return A list of sequences that exist in the database.
130 	 * @throws SQLException
131 	 */
132 	public List<String> getSequenceNames(DatabaseMetaData dbMetaData, String databaseSchema) throws SQLException;
133 
134 	SqlProducer getSqlProducer();
135 }