Skip to content

Commit

Permalink
move the H2 platform over to the symmetric-ddl project
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Jun 29, 2010
1 parent 8c42d74 commit 61b6270
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 24 deletions.
Expand Up @@ -30,6 +30,7 @@
import org.jumpmind.symmetric.ddl.platform.db2.Db2v8Platform;
import org.jumpmind.symmetric.ddl.platform.derby.DerbyPlatform;
import org.jumpmind.symmetric.ddl.platform.firebird.FirebirdPlatform;
import org.jumpmind.symmetric.ddl.platform.h2.H2Platform;
import org.jumpmind.symmetric.ddl.platform.hsqldb.HsqlDbPlatform;
import org.jumpmind.symmetric.ddl.platform.hsqldb2.HsqlDb2Platform;
import org.jumpmind.symmetric.ddl.platform.informix.InformixPlatform;
Expand Down Expand Up @@ -186,6 +187,10 @@ public static synchronized void registerPlatform(String platformName, Class<? ex
*/
private static void registerPlatforms()
{
for (String name : H2Platform.DATABASENAMES) {
addPlatform(_platforms, name,
H2Platform.class);
}
addPlatform(_platforms, InformixPlatform.DATABASENAME, InformixPlatform.class);
addPlatform(_platforms, AxionPlatform.DATABASENAME, AxionPlatform.class);
addPlatform(_platforms, CloudscapePlatform.DATABASENAME, CloudscapePlatform.class);
Expand Down
Expand Up @@ -738,19 +738,19 @@ protected boolean isInternalForeignKeyIndex(DatabaseMetaDataWrapper metaData, Ta
* @param tableName The name of the table
* @return The columns
*/
protected Collection readColumns(DatabaseMetaDataWrapper metaData, String tableName) throws SQLException
protected Collection<Column> readColumns(DatabaseMetaDataWrapper metaData, String tableName) throws SQLException
{
ResultSet columnData = null;

try
{
columnData = metaData.getColumns(tableName, getDefaultColumnPattern());

List columns = new ArrayList();
List<Column> columns = new ArrayList<Column>();

while (columnData.next())
{
Map values = readColumns(columnData, getColumnsForColumn());
Map<String,Object> values = readColumns(columnData, getColumnsForColumn());

columns.add(readColumn(metaData, values));
}
Expand All @@ -772,7 +772,7 @@ protected Collection readColumns(DatabaseMetaDataWrapper metaData, String tableN
* @param values The column meta data values as defined by {@link #getColumnsForColumn()}
* @return The column
*/
protected Column readColumn(DatabaseMetaDataWrapper metaData, Map values) throws SQLException
protected Column readColumn(DatabaseMetaDataWrapper metaData, Map<String,Object> values) throws SQLException
{
Column column = new Column();

Expand Down
Expand Up @@ -3,7 +3,7 @@
* and open the template in the editor.
*/

package org.jumpmind.symmetric.ddlutils.h2;
package org.jumpmind.symmetric.ddl.platform.h2;

/*
* Licensed to the Apache Software Foundation (ASF) under one
Expand Down
@@ -1,4 +1,4 @@
package org.jumpmind.symmetric.ddlutils.h2;
package org.jumpmind.symmetric.ddl.platform.h2;

/*
* Licensed to the Apache Software Foundation (ASF) under one
Expand All @@ -24,8 +24,6 @@
import java.util.List;
import java.util.Map;

import org.jumpmind.symmetric.common.logging.ILog;
import org.jumpmind.symmetric.common.logging.LogFactory;
import org.jumpmind.symmetric.ddl.Platform;
import org.jumpmind.symmetric.ddl.model.Column;
import org.jumpmind.symmetric.ddl.model.ForeignKey;
Expand All @@ -43,8 +41,6 @@
*/
public class H2ModelReader extends JdbcModelReader {

final ILog logger = LogFactory.getLog(getClass());

/**
* Creates a new model reader for H2 databases.
*
Expand All @@ -58,8 +54,7 @@ public H2ModelReader(Platform platform) {
}

@Override
@SuppressWarnings("unchecked")
protected Column readColumn(DatabaseMetaDataWrapper metaData, Map values) throws SQLException {
protected Column readColumn(DatabaseMetaDataWrapper metaData, Map<String,Object> values) throws SQLException {
Column column = super.readColumn(metaData, values);
if (values.get("CHARACTER_MAXIMUM_LENGTH") != null) {
column.setSize(values.get("CHARACTER_MAXIMUM_LENGTH").toString());
Expand All @@ -76,10 +71,9 @@ protected Column readColumn(DatabaseMetaDataWrapper metaData, Map values) throws
return column;
}

@SuppressWarnings("unchecked")
@Override
protected List initColumnsForColumn() {
List result = new ArrayList();
protected List<MetaDataColumnDescriptor> initColumnsForColumn() {
List<MetaDataColumnDescriptor> result = new ArrayList<MetaDataColumnDescriptor>();
result.add(new MetaDataColumnDescriptor("COLUMN_DEF", 12));
result.add(new MetaDataColumnDescriptor("COLUMN_DEFAULT", 12));
result.add(new MetaDataColumnDescriptor("TABLE_NAME", 12));
Expand Down
@@ -1,4 +1,4 @@
package org.jumpmind.symmetric.ddlutils.h2;
package org.jumpmind.symmetric.ddl.platform.h2;

/*
* Licensed to the Apache Software Foundation (ASF) under one
Expand Down
Expand Up @@ -29,6 +29,7 @@
import org.jumpmind.symmetric.ddl.platform.db2.Db2Platform;
import org.jumpmind.symmetric.ddl.platform.derby.DerbyPlatform;
import org.jumpmind.symmetric.ddl.platform.firebird.FirebirdPlatform;
import org.jumpmind.symmetric.ddl.platform.h2.H2Platform;
import org.jumpmind.symmetric.ddl.platform.hsqldb.HsqlDbPlatform;
import org.jumpmind.symmetric.ddl.platform.hsqldb2.HsqlDb2Platform;
import org.jumpmind.symmetric.ddl.platform.informix.InformixPlatform;
Expand All @@ -39,7 +40,6 @@
import org.jumpmind.symmetric.ddl.platform.oracle.Oracle9Platform;
import org.jumpmind.symmetric.ddl.platform.postgresql.PostgreSqlPlatform;
import org.jumpmind.symmetric.ddlutils.PlatformFactory;
import org.jumpmind.symmetric.ddlutils.h2.H2Platform;
import org.jumpmind.symmetric.ddlutils.sqlite.SqLitePlatform;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
Expand Down
Expand Up @@ -10,7 +10,6 @@
import org.jumpmind.symmetric.common.logging.LogFactory;
import org.jumpmind.symmetric.ddl.Platform;
import org.jumpmind.symmetric.ddl.platform.mssql.MSSqlPlatform;
import org.jumpmind.symmetric.ddlutils.h2.H2Platform;
import org.jumpmind.symmetric.ddlutils.oracle.OraclePlatform;
import org.jumpmind.symmetric.ddlutils.sqlite.SqLitePlatform;
import org.springframework.dao.DataAccessException;
Expand Down Expand Up @@ -107,10 +106,6 @@ private synchronized static void initPlatforms() {
SqLitePlatform.class);
org.jumpmind.symmetric.ddl.PlatformFactory.registerPlatform(OraclePlatform.DATABASENAME,
OraclePlatform.class);
for (String name : H2Platform.DATABASENAMES) {
org.jumpmind.symmetric.ddl.PlatformFactory.registerPlatform(name,
H2Platform.class);
}
initialized = true;
}
}
Expand Down
@@ -1,4 +1,4 @@
package org.jumpmind.symmetric.db.h2;
package org.jumpmind.symmetric.ddl.platform.h2;

import java.sql.Connection;
import java.sql.DriverManager;
Expand All @@ -11,7 +11,6 @@
import org.jumpmind.symmetric.ddl.model.Column;
import org.jumpmind.symmetric.ddl.model.Database;
import org.jumpmind.symmetric.ddl.model.Table;
import org.jumpmind.symmetric.ddlutils.h2.H2Platform;
import org.junit.Test;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
import org.springframework.jdbc.datasource.SingleConnectionDataSource;
Expand Down

0 comments on commit 61b6270

Please sign in to comment.