Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2010-09-28 22:24:10 -0400
committerRyan D. Brooks2010-09-28 22:24:10 -0400
commita7e8c79fe7385f5bceac77563b1bb9b607204432 (patch)
treee513acc1ce15a79ff347f7ce08de3672956bd2a1 /plugins/org.eclipse.osee.framework.core.datastore
parent11392aa3f5f6a47439c0d92c27cabeac31c185df (diff)
downloadorg.eclipse.osee-a7e8c79fe7385f5bceac77563b1bb9b607204432.tar.gz
org.eclipse.osee-a7e8c79fe7385f5bceac77563b1bb9b607204432.tar.xz
org.eclipse.osee-a7e8c79fe7385f5bceac77563b1bb9b607204432.zip
feature[bgz_326568]: Add H2 Database support
Diffstat (limited to 'plugins/org.eclipse.osee.framework.core.datastore')
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/operations/CreateSchemaOperation.java6
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/H2DataType.java112
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/H2SqlManager.java42
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/SqlFactory.java3
4 files changed, 161 insertions, 2 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/operations/CreateSchemaOperation.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/operations/CreateSchemaOperation.java
index 211a1add07..a4d46bb783 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/operations/CreateSchemaOperation.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/operations/CreateSchemaOperation.java
@@ -41,18 +41,20 @@ public class CreateSchemaOperation extends AbstractDbTxOperation {
@Override
protected void doTxWork(IProgressMonitor monitor, OseeConnection connection) throws OseeCoreException {
DatabaseMetaData metaData = connection.getMetaData();
+ SupportedDatabase dbType = SupportedDatabase.getDatabaseType(metaData);
SqlManager sqlManager = SqlFactory.getSqlManager(metaData);
SchemaSqlUtil dbInit = new SchemaSqlUtil(sqlManager);
Set<String> schemas = userSchema.keySet();
+
dbInit.dropIndices(schemas, userSchema, dbSchema);
dbInit.dropTables(schemas, userSchema, dbSchema);
- if (SupportedDatabase.isDatabaseType(metaData, SupportedDatabase.postgresql)) {
+
+ if (dbType == SupportedDatabase.postgresql || dbType == SupportedDatabase.h2) {
dbInit.dropSchema(schemas);
dbInit.createSchema(schemas);
}
dbInit.addTables(schemas, userSchema);
dbInit.addIndices(schemas, userSchema);
}
-
}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/H2DataType.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/H2DataType.java
new file mode 100644
index 0000000000..d9f74bf1ce
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/H2DataType.java
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.core.datastore.schema.sql;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class H2DataType extends SqlDataType {
+
+ public H2DataType() {
+ super();
+ }
+
+ @Override
+ public String getBooleanType() {
+ return "boolean";
+ }
+
+ @Override
+ public String getBitType() {
+ return "tinyint";
+ }
+
+ @Override
+ public String getIntegerType() {
+ return "int";
+ }
+
+ @Override
+ public String getDecimalType() {
+ return "decimal";
+ }
+
+ @Override
+ public String getFloatType() {
+ return "double";
+ }
+
+ @Override
+ public String getRealType() {
+ return "real";
+ }
+
+ @Override
+ public String getDoubleType() {
+ return "double";
+ }
+
+ @Override
+ public String getDateType() {
+ return "date";
+ }
+
+ @Override
+ public String getCharType() {
+ return "char";
+ }
+
+ @Override
+ public String getVarCharType() {
+ return "varchar";
+ }
+
+ @Override
+ public String getSmallIntType() {
+ return "smallint";
+ }
+
+ @Override
+ protected String getClobType() {
+ return "clob";
+ }
+
+ @Override
+ protected String getTimestamp() {
+ return "timestamp";
+ }
+
+ @Override
+ protected String getTime() {
+ return "time";
+ }
+
+ @Override
+ protected String getBlobType() {
+ return "blob";
+ }
+
+ @Override
+ protected String getBigInt() {
+ return "bigint";
+ }
+
+ @Override
+ protected String getLongVarCharType() {
+ return "varchar";
+ }
+
+ @Override
+ protected String getNumericType() {
+ return "numeric";
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/H2SqlManager.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/H2SqlManager.java
new file mode 100644
index 0000000000..c5505c5d82
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/H2SqlManager.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.core.datastore.schema.sql;
+
+import org.eclipse.osee.framework.core.datastore.schema.data.TableElement;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.database.core.ConnectionHandler;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class H2SqlManager extends SqlManagerImpl {
+
+ public H2SqlManager(SqlDataType sqlDataType) {
+ super(sqlDataType);
+ }
+
+ @Override
+ public void createSchema(String schema) throws OseeCoreException {
+ ConnectionHandler.runPreparedUpdate(String.format("%s SCHEMA IF NOT EXISTS \"%s\"", CREATE_STRING,
+ schema.toUpperCase()));
+ }
+
+ @Override
+ public void dropSchema(String schema) throws OseeCoreException {
+ ConnectionHandler.runPreparedUpdate(String.format("%s SCHEMA IF EXISTS \"%s\"", DROP_STRING, schema.toUpperCase()));
+ }
+
+ @Override
+ public void dropIndex(TableElement tableDef) {
+ // Do Nothing -- Indexes are dropped during table drop
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/SqlFactory.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/SqlFactory.java
index 612aac946c..bbc751a5a8 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/SqlFactory.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/sql/SqlFactory.java
@@ -45,6 +45,9 @@ public class SqlFactory {
case postgresql:
instance = new PostgreSqlManager(new PostgresqlDataType());
break;
+ case h2:
+ instance = new H2SqlManager(new H2DataType());
+ break;
default:
break;
}

Back to the top