Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2014-11-14 22:15:52 +0000
committerAngel Avila2014-11-14 22:15:52 +0000
commit5fbc92eafd75f862e5825be4e6a1279b7b722c6e (patch)
tree06cbd412155058d2ccfa6c6f3276c55f9b49f87f /plugins
parent58aee3b10ceeadbe21c1ba539d0b7e5bbbde776a (diff)
downloadorg.eclipse.osee-5fbc92eafd75f862e5825be4e6a1279b7b722c6e.tar.gz
org.eclipse.osee-5fbc92eafd75f862e5825be4e6a1279b7b722c6e.tar.xz
org.eclipse.osee-5fbc92eafd75f862e5825be4e6a1279b7b722c6e.zip
feature[ats_ATS139503]: Remove database.schema bundle
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.database.schema/.classpath7
-rw-r--r--plugins/org.eclipse.osee.database.schema/.project28
-rw-r--r--plugins/org.eclipse.osee.database.schema/META-INF/MANIFEST.MF19
-rw-r--r--plugins/org.eclipse.osee.database.schema/build.properties4
-rw-r--r--plugins/org.eclipse.osee.database.schema/pom.xml34
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/DatabaseCallable.java65
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/DatabaseTxCallable.java96
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/InitializeSchemaCallable.java52
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/SchemaOptions.java50
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/SchemaResource.java28
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/SchemaResourceProvider.java22
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/BackupTableCallable.java94
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/CreateSchemaCallable.java68
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/DatabaseDataExtractorCallable.java248
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/ExtractSchemaCallable.java476
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/ImportDataFromDbCallable.java186
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/LoadUserSchemasCallable.java160
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/PrintTablesCallable.java89
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/RestoreTableDataOperation.java105
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/AppliesToClause.java109
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/ColumnDbData.java37
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/ColumnMetadata.java102
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/ConstraintElement.java180
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/ConstraintFactory.java35
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/ConstraintTypes.java38
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/ForeignKey.java65
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/IndexElement.java153
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/ReferenceClause.java198
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/SchemaData.java280
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/SchemaDataLookup.java77
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/SchemaXmlParser.java224
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/TableElement.java293
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/FoxProDataType.java111
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/H2DataType.java112
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/H2SqlManager.java44
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/HyperSqlDataType.java112
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/HyperSqlManager.java163
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/MySqlDataType.java112
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/MysqlSqlManager.java152
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/OracleSqlDataType.java124
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/OracleSqlManager.java78
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/PostgreSqlManager.java192
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/PostgresqlDataType.java112
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/SchemaSqlUtil.java114
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/SqlDataType.java193
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/SqlFactory.java60
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/SqlManager.java325
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/SqlManagerImpl.java66
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/util/DatabaseDataImporter.java255
-rw-r--r--plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/util/FileUtility.java90
-rw-r--r--plugins/org.eclipse.osee.orcs.parent/pom.xml2
51 files changed, 0 insertions, 6039 deletions
diff --git a/plugins/org.eclipse.osee.database.schema/.classpath b/plugins/org.eclipse.osee.database.schema/.classpath
deleted file mode 100644
index ad32c83a78..0000000000
--- a/plugins/org.eclipse.osee.database.schema/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/plugins/org.eclipse.osee.database.schema/.project b/plugins/org.eclipse.osee.database.schema/.project
deleted file mode 100644
index 1655ce19fd..0000000000
--- a/plugins/org.eclipse.osee.database.schema/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.osee.database.schema</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/plugins/org.eclipse.osee.database.schema/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.database.schema/META-INF/MANIFEST.MF
deleted file mode 100644
index a1c63f7b61..0000000000
--- a/plugins/org.eclipse.osee.database.schema/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,19 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: OSEE Database Schema Utility
-Bundle-SymbolicName: org.eclipse.osee.database.schema
-Bundle-Version: 0.20.0.qualifier
-Bundle-Vendor: Open System Engineering Environment
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Import-Package: org.eclipse.osee.executor.admin,
- org.eclipse.osee.framework.core.data,
- org.eclipse.osee.framework.core.exception,
- org.eclipse.osee.framework.database,
- org.eclipse.osee.framework.database.core,
- org.eclipse.osee.framework.jdk.core.persistence,
- org.eclipse.osee.framework.jdk.core.type,
- org.eclipse.osee.framework.jdk.core.util,
- org.eclipse.osee.framework.jdk.core.util.time,
- org.eclipse.osee.framework.jdk.core.util.xml,
- org.eclipse.osee.logger
-Export-Package: org.eclipse.osee.database.schema
diff --git a/plugins/org.eclipse.osee.database.schema/build.properties b/plugins/org.eclipse.osee.database.schema/build.properties
deleted file mode 100644
index 34d2e4d2da..0000000000
--- a/plugins/org.eclipse.osee.database.schema/build.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .
diff --git a/plugins/org.eclipse.osee.database.schema/pom.xml b/plugins/org.eclipse.osee.database.schema/pom.xml
deleted file mode 100644
index 76269f6845..0000000000
--- a/plugins/org.eclipse.osee.database.schema/pom.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.eclipse.osee</groupId>
- <artifactId>org.eclipse.osee.orcs.parent</artifactId>
- <version>0.20.0-SNAPSHOT</version>
- <relativePath>../../plugins/org.eclipse.osee.orcs.parent</relativePath>
- </parent>
-
- <artifactId>org.eclipse.osee.database.schema</artifactId>
- <packaging>eclipse-plugin</packaging>
- <name>OSEE Database Schema Utility - (Incubation)</name>
-
- <build>
- <!-- workaround for https://issues.sonatype.org/browse/TYCHO-168 -->
- <resources>
- <resource>
- <directory>src</directory>
- <excludes>
- <exclude>**/*.java</exclude>
- </excludes>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.eclipse.tycho</groupId>
- <artifactId>tycho-source-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-</project> \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/DatabaseCallable.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/DatabaseCallable.java
deleted file mode 100644
index 82625a6c83..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/DatabaseCallable.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * 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.database.schema;
-
-import java.util.concurrent.Callable;
-import org.eclipse.osee.executor.admin.CancellableCallable;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.logger.Log;
-
-/**
- * @author Roberto E. Escobar
- */
-public abstract class DatabaseCallable<T> extends CancellableCallable<T> {
-
- private final IOseeDatabaseService service;
- private final Log logger;
- private Callable<?> innerWorker;
-
- protected DatabaseCallable(Log logger, IOseeDatabaseService service) {
- this.logger = logger;
- this.service = service;
- }
-
- protected IOseeDatabaseService getDatabaseService() {
- return service;
- }
-
- protected Log getLogger() {
- return logger;
- }
-
- protected <K> K callAndCheckForCancel(Callable<K> callable) throws Exception {
- checkForCancelled();
- setInnerWorker(callable);
- K result = callable.call();
- setInnerWorker(null);
- return result;
- }
-
- private synchronized void setInnerWorker(Callable<?> callable) {
- innerWorker = callable;
- }
-
- @Override
- public void setCancel(boolean isCancelled) {
- super.setCancel(isCancelled);
- final Callable<?> inner = innerWorker;
- if (inner != null) {
- synchronized (inner) {
- if (inner instanceof CancellableCallable) {
- ((CancellableCallable<?>) inner).setCancel(isCancelled);
- }
- }
- }
- }
-
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/DatabaseTxCallable.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/DatabaseTxCallable.java
deleted file mode 100644
index 76501e76b9..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/DatabaseTxCallable.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * 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.database.schema;
-
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.database.core.DatabaseTransactions;
-import org.eclipse.osee.framework.database.core.IDbTransactionWork;
-import org.eclipse.osee.framework.database.core.OseeConnection;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.logger.Log;
-
-/**
- * @author Roberto E. Escobar
- */
-public abstract class DatabaseTxCallable<T> extends DatabaseCallable<T> {
-
- private final String name;
-
- protected DatabaseTxCallable(Log logger, IOseeDatabaseService dbService, String name) {
- super(logger, dbService);
- this.name = name;
- }
-
- @Override
- public final T call() throws Exception {
- T value = null;
- onExecutionStart();
- try {
- OseeConnection connection = getDatabaseService().getConnection();
- try {
- InternalTxWork work = new InternalTxWork();
- DatabaseTransactions.execute(getDatabaseService(), connection, work);
- value = work.getResult();
- } finally {
- connection.close();
- }
- } finally {
- onExecutionComplete();
- }
- return value;
- }
-
- protected void onExecutionStart() {
- //
- }
-
- protected void onExecutionComplete() {
- //
- }
-
- protected abstract T handleTxWork(OseeConnection connection) throws OseeCoreException;
-
- protected void handleTxException(Exception ex) {
- // Do nothing
- }
-
- protected void handleTxFinally() throws OseeCoreException {
- // Do nothing
- }
-
- private final class InternalTxWork implements IDbTransactionWork {
- private T result;
-
- @Override
- public String getName() {
- return name;
- }
-
- public T getResult() {
- return result;
- }
-
- @Override
- public void handleTxWork(OseeConnection connection) throws OseeCoreException {
- result = DatabaseTxCallable.this.handleTxWork(connection);
- }
-
- @Override
- public void handleTxException(Exception ex) {
- DatabaseTxCallable.this.handleTxException(ex);
- }
-
- @Override
- public void handleTxFinally() throws OseeCoreException {
- DatabaseTxCallable.this.handleTxFinally();
- }
- };
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/InitializeSchemaCallable.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/InitializeSchemaCallable.java
deleted file mode 100644
index bb5ed9cdbe..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/InitializeSchemaCallable.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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.database.schema;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import org.eclipse.osee.database.schema.internal.callable.CreateSchemaCallable;
-import org.eclipse.osee.database.schema.internal.callable.ExtractSchemaCallable;
-import org.eclipse.osee.database.schema.internal.callable.LoadUserSchemasCallable;
-import org.eclipse.osee.database.schema.internal.data.SchemaData;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.logger.Log;
-
-public class InitializeSchemaCallable extends DatabaseCallable<Object> {
-
- private final SchemaResourceProvider schemaProvider;
- private final SchemaOptions options;
-
- public InitializeSchemaCallable(Log logger, IOseeDatabaseService service, SchemaResourceProvider schemaProvider, SchemaOptions options) {
- super(logger, service);
- this.schemaProvider = schemaProvider;
- this.options = options;
- }
-
- @Override
- public Object call() throws Exception {
- Map<String, SchemaData> userSpecifiedConfig = new HashMap<String, SchemaData>();
- Map<String, SchemaData> currentDatabaseConfig = new HashMap<String, SchemaData>();
-
- List<Callable<?>> ops = new ArrayList<Callable<?>>();
- ops.add(new LoadUserSchemasCallable(getLogger(), getDatabaseService(), userSpecifiedConfig, schemaProvider,
- options));
- ops.add(new ExtractSchemaCallable(getLogger(), getDatabaseService(), userSpecifiedConfig.keySet(),
- currentDatabaseConfig));
- ops.add(new CreateSchemaCallable(getLogger(), getDatabaseService(), userSpecifiedConfig, currentDatabaseConfig));
- for (Callable<?> op : ops) {
- op.call();
- }
- return null;
- }
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/SchemaOptions.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/SchemaOptions.java
deleted file mode 100644
index 1c42ab6e9a..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/SchemaOptions.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * 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.database.schema;
-
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-
-/**
- * @author Roberto E. Escobar
- */
-public class SchemaOptions {
-
- private final String tableDataSpace;
- private final String indexDataSpace;
- private final boolean useFileSpecifiedSchemas;
-
- public SchemaOptions(String tableDataSpace, String indexDataSpace, boolean useFileSpecifiedSchemas) {
- super();
- this.tableDataSpace = tableDataSpace;
- this.indexDataSpace = indexDataSpace;
- this.useFileSpecifiedSchemas = useFileSpecifiedSchemas;
- }
-
- public String getTableDataSpace() {
- return tableDataSpace;
- }
-
- public String getIndexDataSpace() {
- return indexDataSpace;
- }
-
- public boolean isUseFileSpecifiedSchemas() {
- return useFileSpecifiedSchemas;
- }
-
- public boolean isIndexDataSpaceValid() {
- return Strings.isValid(getIndexDataSpace());
- }
-
- public boolean isTableDataSpaceValid() {
- return Strings.isValid(getTableDataSpace());
- }
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/SchemaResource.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/SchemaResource.java
deleted file mode 100644
index ac3f99fd9d..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/SchemaResource.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.database.schema;
-
-import java.io.InputStream;
-import java.net.URI;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-
-/**
- * @author Roberto E. Escobar
- */
-public interface SchemaResource {
-
- boolean isApplicable();
-
- InputStream getContent() throws OseeCoreException;
-
- URI getLocation() throws OseeCoreException;
-
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/SchemaResourceProvider.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/SchemaResourceProvider.java
deleted file mode 100644
index cf3ecfcff0..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/SchemaResourceProvider.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.database.schema;
-
-import java.util.Collection;
-
-/**
- * @author Roberto E. Escobar
- */
-public interface SchemaResourceProvider {
-
- Collection<SchemaResource> getSchemaResources();
-
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/BackupTableCallable.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/BackupTableCallable.java
deleted file mode 100644
index 6b3a79a361..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/BackupTableCallable.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.callable;
-
-import java.io.File;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-import org.eclipse.osee.database.schema.DatabaseCallable;
-import org.eclipse.osee.database.schema.internal.data.SchemaData;
-import org.eclipse.osee.database.schema.internal.data.TableElement;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.logger.Log;
-
-public class BackupTableCallable extends DatabaseCallable<Object> {
- private final File backupDirectory;
- private final Set<String> schemas;
- private final Map<String, SchemaData> userSpecifiedConfig;
- private final Map<String, SchemaData> currentDatabaseConfig;
-
- public BackupTableCallable(Log logger, IOseeDatabaseService dbService, String backupDirPath, Set<String> schemas, Map<String, SchemaData> userSpecifiedConfig, Map<String, SchemaData> currentDatabaseConfig) {
- super(logger, dbService);
- this.schemas = schemas;
- this.userSpecifiedConfig = userSpecifiedConfig;
- this.currentDatabaseConfig = currentDatabaseConfig;
- this.backupDirectory = new File("BackupDirectory");
- }
-
- @Override
- public Object call() throws Exception {
- Set<String> dataToBackup = getTablesToBackup();
- if (!dataToBackup.isEmpty()) {
- System.out.println(dataToBackup.toString().replaceAll(", ", "\n"));
- clearBackupDirectory();
- DatabaseDataExtractorCallable dbDataExtractor =
- new DatabaseDataExtractorCallable(getLogger(), getDatabaseService(), schemas, backupDirectory);
- Set<String> backupTables = dataToBackup;
- for (String backupTable : backupTables) {
- dbDataExtractor.addTableNameToExtract(backupTable);
- }
- callAndCheckForCancel(dbDataExtractor);
- dbDataExtractor.waitForWorkerThreads();
- }
- return null;
- }
-
- private Set<String> getTablesToBackup() {
- Set<String> backupTables = new TreeSet<String>();
- Set<String> userSchemas = userSpecifiedConfig.keySet();
- for (String key : userSchemas) {
- // Backup data only if data exists in the current database
- if (currentDatabaseConfig.containsKey(key)) {
- SchemaData schemaDataInDb = currentDatabaseConfig.get(key);
- Map<String, TableElement> currentDbTableMap = schemaDataInDb.getTableMap();
- Set<String> currentDbTableNames = currentDbTableMap.keySet();
-
- SchemaData schemaData = userSpecifiedConfig.get(key);
- Set<String> tableNamesToBackup = schemaData.getTablesToBackup();
- for (String tableName : tableNamesToBackup) {
- // Check that table we want to backup exists in the database
- // before we add it to the list
- if (currentDbTableNames.contains(tableName)) {
- backupTables.add(tableName);
- } else {
- getLogger().error("Table doesn't exist in Db. Unable to backup [%s]", tableName);
- }
- }
- } else {
- getLogger().error("Schema doesn't exist in Db. Unable to backup tables from schema [%s]", key);
- }
- }
- return backupTables;
- }
-
- private void clearBackupDirectory() {
- if (backupDirectory != null && backupDirectory.exists() && backupDirectory.canWrite()) {
- File[] fileList = backupDirectory.listFiles();
- for (File fileToDelete : fileList) {
- fileToDelete.delete();
- }
- backupDirectory.delete();
- backupDirectory.mkdirs();
- }
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/CreateSchemaCallable.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/CreateSchemaCallable.java
deleted file mode 100644
index 1ee09397af..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/CreateSchemaCallable.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.callable;
-
-import java.sql.DatabaseMetaData;
-import java.util.Map;
-import java.util.Set;
-import org.eclipse.osee.database.schema.DatabaseTxCallable;
-import org.eclipse.osee.database.schema.internal.data.SchemaData;
-import org.eclipse.osee.database.schema.internal.sql.SchemaSqlUtil;
-import org.eclipse.osee.database.schema.internal.sql.SqlFactory;
-import org.eclipse.osee.database.schema.internal.sql.SqlManager;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.database.core.OseeConnection;
-import org.eclipse.osee.framework.database.core.SupportedDatabase;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.logger.Log;
-
-/**
- * @author Roberto E. Escobar
- */
-public class CreateSchemaCallable extends DatabaseTxCallable<Object> {
-
- private final Log logger;
- private final Map<String, SchemaData> userSchema;
- private final Map<String, SchemaData> dbSchema;
-
- public CreateSchemaCallable(Log logger, IOseeDatabaseService dbService, Map<String, SchemaData> userSchema, Map<String, SchemaData> dbSchema) {
- super(logger, dbService, "Create Schema");
- this.logger = logger;
- this.userSchema = userSchema;
- this.dbSchema = dbSchema;
- }
-
- @Override
- protected Object handleTxWork(OseeConnection connection) throws OseeCoreException {
- DatabaseMetaData metaData = connection.getMetaData();
-
- SupportedDatabase dbType = SupportedDatabase.getDatabaseType(metaData);
- SqlManager sqlManager = SqlFactory.getSqlManager(logger, getDatabaseService(), metaData);
- SchemaSqlUtil dbInit = new SchemaSqlUtil(sqlManager);
-
- Set<String> schemas = userSchema.keySet();
-
- dbInit.dropIndices(schemas, userSchema, dbSchema);
- dbInit.dropTables(schemas, userSchema, dbSchema);
-
- if (dbType == SupportedDatabase.postgresql || dbType == SupportedDatabase.h2) {
- try {
- dbInit.dropSchema(schemas);
- } catch (Exception ex) {
- //
- }
- dbInit.createSchema(schemas);
- }
- dbInit.addTables(schemas, userSchema);
- dbInit.addIndices(schemas, userSchema);
- return null;
- }
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/DatabaseDataExtractorCallable.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/DatabaseDataExtractorCallable.java
deleted file mode 100644
index 665af38781..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/DatabaseDataExtractorCallable.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.callable;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.OutputStream;
-import java.math.BigDecimal;
-import java.sql.Date;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamWriter;
-import org.eclipse.osee.database.schema.DatabaseCallable;
-import org.eclipse.osee.database.schema.internal.data.SchemaData;
-import org.eclipse.osee.database.schema.internal.data.TableElement;
-import org.eclipse.osee.database.schema.internal.data.TableElement.ColumnFields;
-import org.eclipse.osee.database.schema.internal.data.TableElement.TableDescriptionFields;
-import org.eclipse.osee.database.schema.internal.data.TableElement.TableTags;
-import org.eclipse.osee.database.schema.internal.util.FileUtility;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.database.core.IOseeStatement;
-import org.eclipse.osee.framework.database.core.SQL3DataType;
-import org.eclipse.osee.framework.database.core.SupportedDatabase;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.logger.Log;
-
-/**
- * @author Roberto E. Escobar
- */
-public class DatabaseDataExtractorCallable extends DatabaseCallable<Object> {
-
- private static final String SQL_WILD_QUERY = "SELECT * FROM ";
- private final Set<String> schemas;
- private final File directory;
- private final List<Thread> workerThreads;
- private final Set<String> extractTables;
-
- private class ColumnInfo {
- String name;
- SQL3DataType type;
- }
-
- public DatabaseDataExtractorCallable(Log logger, IOseeDatabaseService dbService, Set<String> schemas, File directory) {
- super(logger, dbService);
- this.schemas = schemas;
- this.directory = directory;
- this.workerThreads = new ArrayList<Thread>();
- this.extractTables = new TreeSet<String>();
- }
-
- public void addTableNameToExtract(String fullyQualifiedTableName) {
- this.extractTables.add(fullyQualifiedTableName);
- }
-
- public void clearFilter() {
- this.extractTables.clear();
- }
-
- @Override
- public Object call() throws Exception {
- FileUtility.setupDirectoryForWrite(directory);
-
- Map<String, SchemaData> schemaDataMap = new HashMap<String, SchemaData>();
- ExtractSchemaCallable operation =
- new ExtractSchemaCallable(getLogger(), getDatabaseService(), schemas, schemaDataMap);
- callAndCheckForCancel(operation);
-
- Set<String> schemaKeys = schemaDataMap.keySet();
- for (String schema : schemaKeys) {
- SchemaData schemaData = schemaDataMap.get(schema);
-
- List<TableElement> tables = schemaData.getTablesOrderedByDependency();
- for (TableElement table : tables) {
-
- boolean extract = true;
- // only extract items in filter since filter was set with data
- if (this.extractTables != null && this.extractTables.size() > 0) {
- extract = extractTables.contains(table.getFullyQualifiedTableName());
- }
-
- if (extract) {
- DataExtractorThread workerThread = new DataExtractorThread(table);
- workerThreads.add(workerThread);
- workerThread.start();
- }
- }
- }
- return null;
- }
-
- private class DataExtractorThread extends Thread {
- private final TableElement table;
-
- public DataExtractorThread(TableElement table) {
- this.table = table;
- setName(table.getName() + " Extractor");
- }
-
- @Override
- public void run() {
- IOseeStatement chStmt = null;
- OutputStream outputStream = null;
- try {
- chStmt = getDatabaseService().getStatement();
- String fileName = table.getFullyQualifiedTableName() + FileUtility.DB_DATA_EXTENSION;
- outputStream = new BufferedOutputStream(new FileOutputStream(new File(directory, fileName)));
-
- try {
- chStmt.runPreparedQuery(SQL_WILD_QUERY + table.getFullyQualifiedTableName());
- } catch (OseeDataStoreException ex) {
- chStmt.runPreparedQuery(SQL_WILD_QUERY + table.getName());
- }
-
- buildXml(chStmt, table, outputStream);
- } catch (Exception ex) {
- getLogger().error(ex, "Error Processing Table [%s.%s] Data ", table.getSchema(), table.getName());
- } finally {
- Lib.close(chStmt);
- Lib.close(outputStream);
- }
- }
- }
-
- public void waitForWorkerThreads() {
- for (Thread worker : workerThreads) {
- try {
- worker.join();
- } catch (InterruptedException ex) {
- getLogger().error(ex, "Thread [%s] was Interrupted.", worker.getName());
- }
- }
- }
-
- private void buildXml(IOseeStatement chStmt, TableElement table, OutputStream outputStream) throws Exception {
- ArrayList<ColumnInfo> columns = new ArrayList<ColumnInfo>();
- int numberOfColumns = chStmt.getColumnCount();
- for (int index = 1; index <= numberOfColumns; index++) {
- ColumnInfo columnInfo = new ColumnInfo();
- columnInfo.name = chStmt.getColumnName(index);
- columnInfo.name = columnInfo.name.toUpperCase();
-
- int dataType = chStmt.getColumnType(index);
- if (chStmt.isDatabaseType(SupportedDatabase.foxpro)) {
- if (dataType == Types.CHAR) {
- dataType = Types.VARCHAR;
- }
- }
- columnInfo.type = SQL3DataType.get(dataType);
- columns.add(columnInfo);
- }
-
- XMLOutputFactory factory = XMLOutputFactory.newInstance();
- XMLStreamWriter writer = factory.createXMLStreamWriter(outputStream);
- writer.writeStartDocument("UTF-8", "1.0");
- writer.writeStartElement(TableTags.Table.name());
- writer.writeAttribute(TableDescriptionFields.schema.name(), table.getSchema());
- writer.writeAttribute(TableDescriptionFields.name.name(), table.getName());
-
- for (ColumnInfo info : columns) {
- writer.writeStartElement(TableTags.ColumnInfo.name());
- writer.writeAttribute(ColumnFields.id.name(), info.name);
- writer.writeAttribute(ColumnFields.type.name(), info.type.name());
- writer.writeEndElement();
- }
-
- while (chStmt.next()) {
- writer.writeStartElement(TableTags.Row.name());
- for (ColumnInfo column : columns) {
- String columnValue;
- switch (column.type) {
- case BIGINT:
- BigDecimal bigD = chStmt.getBigDecimal(column.name);
- columnValue = bigD != null ? bigD.toString() : "";
- break;
- case DATE:
- Date date = chStmt.getDate(column.name);
- columnValue = date != null ? date.toString() : "";
- break;
- case TIME:
- Time time = chStmt.getTime(column.name);
- columnValue = time != null ? time.toString() : "";
- break;
- case TIMESTAMP:
- Timestamp timestamp = chStmt.getTimestamp(column.name);
- columnValue = timestamp != null ? timestamp.toString() : "";
- break;
- default:
- columnValue = chStmt.getString(column.name);
- columnValue = handleSpecialCharacters(columnValue);
- break;
- }
- writer.writeAttribute(column.name, (columnValue != null ? columnValue : ""));
- }
- writer.writeEndElement();
- }
- writer.writeEndElement();
- writer.writeEndDocument();
- writer.flush();
- }
-
- private String handleSpecialCharacters(String value) {
- // \0 An ASCII 0 (NUL) character.
- // '' A single quote character.
- // \b A backspace character.
- // \n A newline (linefeed) character.
- // \r A carriage return character.
- // \t A tab character.
- // \Z ASCII 26 (Control-Z). See note following the table.
-
- if (value != null) {
-
- value = value.replaceAll("\0", "");
- value = value.replaceAll("'", "''");
- // value = value.replaceAll("\"", "\\\\\""); No need to do this.
- Pattern pattern =
- Pattern.compile("[^" + "a-zA-Z0-9" + "!@#$%\\^&*\\(\\)" + "+ _.-=" + "\'\"<>{}\\[\\]|:;,\n\r\t\b?/`~\\\\]+");
- Matcher matcher = pattern.matcher(value);
-
- while (matcher.find()) {
- // System.out.println("Matcher: [" + matcher.group() + "]");
- value = value.replace(matcher.group(), "");
- }
- }
- return value;
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/ExtractSchemaCallable.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/ExtractSchemaCallable.java
deleted file mode 100644
index f6188afff4..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/ExtractSchemaCallable.java
+++ /dev/null
@@ -1,476 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.callable;
-
-import java.sql.DatabaseMetaData;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.eclipse.osee.database.schema.DatabaseCallable;
-import org.eclipse.osee.database.schema.internal.data.AppliesToClause;
-import org.eclipse.osee.database.schema.internal.data.AppliesToClause.OrderType;
-import org.eclipse.osee.database.schema.internal.data.ColumnMetadata;
-import org.eclipse.osee.database.schema.internal.data.ConstraintElement;
-import org.eclipse.osee.database.schema.internal.data.ConstraintFactory;
-import org.eclipse.osee.database.schema.internal.data.ConstraintTypes;
-import org.eclipse.osee.database.schema.internal.data.ForeignKey;
-import org.eclipse.osee.database.schema.internal.data.IndexElement;
-import org.eclipse.osee.database.schema.internal.data.ReferenceClause;
-import org.eclipse.osee.database.schema.internal.data.ReferenceClause.OnDeleteEnum;
-import org.eclipse.osee.database.schema.internal.data.ReferenceClause.OnUpdateEnum;
-import org.eclipse.osee.database.schema.internal.data.SchemaData;
-import org.eclipse.osee.database.schema.internal.data.TableElement;
-import org.eclipse.osee.database.schema.internal.data.TableElement.ColumnFields;
-import org.eclipse.osee.database.schema.internal.data.TableElement.TableDescriptionFields;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.database.core.OseeConnection;
-import org.eclipse.osee.framework.database.core.SQL3DataType;
-import org.eclipse.osee.framework.database.core.SupportedDatabase;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.logger.Log;
-
-/**
- * @author Roberto E. Escobar
- */
-public class ExtractSchemaCallable extends DatabaseCallable<Object> {
- private static final String DEFAULT_FILTER = "BIN.*";
- private static final Pattern sqlPattern = Pattern.compile("SQL\\d+");
-
- private DatabaseMetaData dbData;
- private String dbName;
- private String dbVersion;
- private final Map<String, SchemaData> database;
- private final List<String> filter = new ArrayList<String>();
- private final Set<String> tablesToExtract = new TreeSet<String>();
- private final Set<String> schemas;
- private final Matcher indexMatcher;
-
- public ExtractSchemaCallable(Log logger, IOseeDatabaseService dbService, Set<String> schemas, Map<String, SchemaData> schemaData) {
- super(logger, dbService);
- this.schemas = schemas;
- this.database = schemaData;
- filter.add(DEFAULT_FILTER);
- this.indexMatcher = sqlPattern.matcher("");
- }
-
- @Override
- public Object call() throws Exception {
- OseeConnection connection = getDatabaseService().getConnection();
- try {
- this.dbData = connection.getMetaData();
-
- this.dbName = dbData.getDatabaseProductName();
- this.dbVersion = dbData.getDatabaseProductVersion();
-
- for (String schema : schemas) {
- SchemaData dbTables = getTableInformation(schema);
- database.put(schema, dbTables);
- }
- } finally {
- connection.close();
- }
- return null;
- }
-
- public void addToFilter(String value) {
- filter.add(value);
- }
-
- @Override
- public String toString() {
- StringBuilder buffer = new StringBuilder();
- Set<String> keys = database.keySet();
- for (String schema : keys) {
- SchemaData tableData = database.get(schema);
- buffer.append(" Schema: \n");
- buffer.append(schema);
- buffer.append("\n");
- buffer.append(tableData.toString());
- }
- return String.format("Name: [%s]\tVer: [%s]\n%s", dbName, dbVersion, buffer);
- }
-
- private boolean isFiltered(String value) {
- for (String filterExpression : filter) {
- Pattern searchPattern = Pattern.compile(filterExpression, Pattern.DOTALL);
- Matcher matcher = searchPattern.matcher(value);
- if (matcher.find()) {
- return true;
- }
- }
- return false;
- }
-
- public void addTableToExtract(String fullyqualifiedTableName) {
- this.tablesToExtract.add(fullyqualifiedTableName);
- }
-
- public void clearTableFilter() {
- tablesToExtract.clear();
- }
-
- private SchemaData getTableInformation(String schema) throws Exception {
- SchemaData dbTables = new SchemaData();
- ResultSet resultSet = null;
- try {
- resultSet = dbData.getTables(null, schema, null, new String[] {"TABLE"});
- if (resultSet != null) {
- while (resultSet.next()) {
- String tableName = resultSet.getString("TABLE_NAME").toUpperCase();
- String schemaName = resultSet.getString("TABLE_SCHEM");
- if (tableName != null && !isFiltered(tableName) && schemaName.equalsIgnoreCase(schema)) {
- boolean extract = true;
- if (!tablesToExtract.isEmpty()) {
- extract = tablesToExtract.contains(schema + "." + tableName);
- }
-
- if (extract) {
- TableElement tableEntry = new TableElement();
- tableEntry.addTableDescription(TableDescriptionFields.name, tableName);
- tableEntry.addTableDescription(TableDescriptionFields.schema, schemaName);
- getColumnInformation(tableEntry);
- getColumnPrimaryKey(tableEntry);
-
- if (!(SupportedDatabase.isDatabaseType(dbData, SupportedDatabase.foxpro) || SupportedDatabase.isDatabaseType(
- dbData, SupportedDatabase.postgresql))) {
- getColumnForeignKey(tableEntry);
- }
- getIndexInfo(tableEntry);
- dbTables.addTableDefinition(tableEntry);
- }
- }
- }
- }
- } finally {
- if (resultSet != null) {
- resultSet.close();
- }
- }
- return dbTables;
- }
-
- private void getColumnInformation(TableElement aTable) throws Exception {
- ResultSet columns = null;
- try {
- try {
- columns = dbData.getColumns(null, aTable.getSchema(), aTable.getName(), null);
- } catch (SQLException ex) {
- columns = dbData.getColumns(null, null, aTable.getName(), null);
- }
- while (columns.next()) {
- String id = columns.getString("COLUMN_NAME");
- id = id.toUpperCase();
- ColumnMetadata column = new ColumnMetadata(id);
-
- int dataType = columns.getInt("DATA_TYPE");
- if (SupportedDatabase.isDatabaseType(dbData, SupportedDatabase.foxpro)) {
- if (dataType == Types.CHAR) {
- dataType = Types.VARCHAR;
- }
- }
- String dataTypeName = SQL3DataType.get(dataType).name();
- column.addColumnField(ColumnFields.type, dataTypeName);
-
- String defaultValue = "";
- int defaultType = columns.getInt("NULLABLE");
- switch (defaultType) {
- case java.sql.DatabaseMetaData.columnNoNulls:
- defaultValue = "not null";
- break;
- case java.sql.DatabaseMetaData.columnNullable:
- // Dont specify if Null - Let DB Decide.
- defaultValue = "";
- break;
- case java.sql.DatabaseMetaData.columnNullableUnknown:
- default:
- // Since unknown then don't specify
- defaultValue = "";
- break;
- }
- if (!defaultValue.equals("")) {
- column.addColumnField(ColumnFields.defaultValue, defaultValue);
- }
-
- if (!SupportedDatabase.isDatabaseType(dbData, SupportedDatabase.foxpro)) {
- // int dataType = columns.getInt("DATA_TYPE");
- switch (dataType) {
- case java.sql.Types.CHAR:
- case java.sql.Types.VARCHAR:
- String limits = columns.getString("COLUMN_SIZE");
- if (Strings.isValid(limits)) {
- column.addColumnField(ColumnFields.limits, limits);
- }
- break;
- case java.sql.Types.DECIMAL:
- case java.sql.Types.NUMERIC:
- limits = columns.getString("COLUMN_SIZE");
- String decimal = columns.getString("DECIMAL_DIGITS");
- if (Strings.isValid(decimal)) {
- if (Strings.isValid(limits)) {
- limits += "," + decimal;
- }
- }
- if (Strings.isValid(limits)) {
- column.addColumnField(ColumnFields.limits, limits);
- }
- default:
- break;
- }
- } else {
- switch (dataType) {
- case java.sql.Types.CHAR:
- case java.sql.Types.VARCHAR:
- String limits = "255";
- column.addColumnField(ColumnFields.limits, limits);
- break;
- default:
- break;
- }
- }
- aTable.addColumn(column);
- }
- } finally {
- if (columns != null) {
- columns.close();
- }
- }
- }
-
- private void getColumnPrimaryKey(TableElement aTable) throws SQLException {
- ResultSet primaryKeys = null;
- try {
- try {
- primaryKeys = dbData.getPrimaryKeys(null, aTable.getSchema(), aTable.getName());
- } catch (SQLException ex) {
- primaryKeys = dbData.getPrimaryKeys(null, null, aTable.getName());
- }
- Map<String, Set<String>> constraintKeyMap = new HashMap<String, Set<String>>();
-
- while (primaryKeys.next()) {
- String column = primaryKeys.getString("COLUMN_NAME");
- String keyId = primaryKeys.getString("PK_NAME");
-
- if (!Strings.isValid(keyId)) {
- keyId = column + "_PK";
- }
-
- if (!constraintKeyMap.containsKey(keyId)) {
- Set<String> set = new TreeSet<String>();
- set.add(column);
- constraintKeyMap.put(keyId, set);
- } else {
- Set<String> set = constraintKeyMap.get(keyId);
- if (!set.contains(column)) {
- set.add(column);
- }
- }
- }
-
- Set<String> keys = constraintKeyMap.keySet();
- for (String pk : keys) {
- ConstraintElement constraint =
- ConstraintFactory.getConstraint(ConstraintTypes.PRIMARY_KEY, aTable.getSchema(), pk, false);
- Set<String> columnSet = constraintKeyMap.get(pk);
- for (String column : columnSet) {
- constraint.addColumn(column);
- }
- aTable.addConstraint(constraint);
- }
- } finally {
- if (primaryKeys != null) {
- primaryKeys.close();
- }
- }
- }
-
- private void getColumnForeignKey(TableElement aTable) throws SQLException {
- ResultSet importedKeys = null;
- try {
- importedKeys = dbData.getImportedKeys(null, aTable.getSchema(), aTable.getName());
-
- while (importedKeys.next()) {
-
- String appliesToColumnId = importedKeys.getString("FKCOLUMN_NAME");
- String fkeyId = importedKeys.getString("FK_NAME");
- String fKeyAddress = importedKeys.getString("FKTABLE_SCHEM");
-
- String refersToTable = importedKeys.getString("PKTABLE_NAME");
- String refersToTableAddress = importedKeys.getString("PKTABLE_SCHEM");
- String referencesColumn = importedKeys.getString("PKCOLUMN_NAME");
-
- OnDeleteEnum onDeleteAction = OnDeleteEnum.UNSPECIFIED;
- String onDeleteRule = importedKeys.getString("DELETE_RULE");
- if (Strings.isValid(onDeleteRule)) {
- // System.out.println("onDelete: " + onDeleteRule);
- int type = Integer.parseInt(onDeleteRule);
- switch (type) {
- case java.sql.DatabaseMetaData.importedKeyNoAction:
- onDeleteAction = OnDeleteEnum.NO_ACTION;
- break;
- case java.sql.DatabaseMetaData.importedKeyRestrict:
- onDeleteAction = OnDeleteEnum.RESTRICT;
- break;
- case java.sql.DatabaseMetaData.importedKeyCascade:
- onDeleteAction = OnDeleteEnum.CASCADE;
- break;
- case java.sql.DatabaseMetaData.importedKeySetNull:
- onDeleteAction = OnDeleteEnum.SET_NULL;
- break;
- case java.sql.DatabaseMetaData.importedKeySetDefault:
- default:
- onDeleteAction = OnDeleteEnum.UNSPECIFIED;
- break;
- }
- }
-
- OnUpdateEnum onUpdateAction = OnUpdateEnum.UNSPECIFIED;
- String onUpdateRule = importedKeys.getString("UPDATE_RULE");
- if (Strings.isValid(onUpdateRule)) {
- // System.out.println("onUpdate: " + onUpdateRule);
- int type = Integer.parseInt(onUpdateRule);
- switch (type) {
- case java.sql.DatabaseMetaData.importedKeyNoAction:
- onUpdateAction = OnUpdateEnum.NO_ACTION;
- break;
- case java.sql.DatabaseMetaData.importedKeyRestrict:
- onUpdateAction = OnUpdateEnum.RESTRICT;
- break;
- case java.sql.DatabaseMetaData.importedKeyCascade:
- case java.sql.DatabaseMetaData.importedKeySetNull:
- case java.sql.DatabaseMetaData.importedKeySetDefault:
- default:
- onUpdateAction = OnUpdateEnum.UNSPECIFIED;
- break;
- }
- }
-
- boolean deferrable = false;
- String deferrabilityId = importedKeys.getString("DEFERRABILITY");
- if (Strings.isValid(deferrabilityId)) {
- int type = Integer.parseInt(deferrabilityId);
- switch (type) {
- case java.sql.DatabaseMetaData.importedKeyInitiallyDeferred:
- case java.sql.DatabaseMetaData.importedKeyInitiallyImmediate:
- deferrable = true;
- break;
- case java.sql.DatabaseMetaData.importedKeyNotDeferrable:
- deferrable = false;
- break;
- default:
- deferrable = false;
- break;
- }
- }
-
- if (!Strings.isValid(fKeyAddress)) {
- fKeyAddress = aTable.getSchema();
- }
-
- if (!Strings.isValid(fkeyId)) {
- fkeyId = appliesToColumnId + "_FK";
- }
-
- if (!Strings.isValid(refersToTableAddress)) {
- refersToTableAddress = aTable.getSchema();
- }
-
- ConstraintElement constraint =
- ConstraintFactory.getConstraint(ConstraintTypes.FOREIGN_KEY, fKeyAddress, fkeyId, deferrable);
- constraint.addColumn(appliesToColumnId);
-
- ReferenceClause ref = new ReferenceClause(refersToTableAddress, refersToTable);
- ref.addColumn(referencesColumn);
-
- ref.setOnDeleteAction(onDeleteAction);
- ref.setOnUpdateAction(onUpdateAction);
-
- ((ForeignKey) constraint).addReference(ref);
-
- aTable.addConstraint(constraint);
- }
- } finally {
- if (importedKeys != null) {
- importedKeys.close();
- }
- }
- }
-
- private void getIndexInfo(TableElement aTable) throws SQLException {
- ResultSet indexKeys = null;
- try {
- indexKeys = dbData.getIndexInfo(null, aTable.getSchema(), aTable.getName(), false, false);
-
- Map<String, Map<Integer, AppliesToClause>> indexMap = new HashMap<String, Map<Integer, AppliesToClause>>();
-
- while (indexKeys.next()) {
- String indexName = indexKeys.getString("INDEX_NAME");
-
- if (indexName != null && indexName.length() > 0) {
- Matcher matcher = indexMatcher.reset(indexName);
- if (!matcher.matches()) {
- if (indexKeys.getShort("TYPE") == DatabaseMetaData.tableIndexOther) {
-
- short ordinal = indexKeys.getShort("ORDINAL_POSITION");
- String columnName = indexKeys.getString("COLUMN_NAME");
-
- String orderTypeString = indexKeys.getString("ASC_OR_DESC");
- OrderType orderType = OrderType.Undefined;
- if (orderTypeString != null) {
- if (orderTypeString.equalsIgnoreCase("A")) {
- orderType = OrderType.Ascending;
- } else if (orderTypeString.equalsIgnoreCase("D")) {
- orderType = OrderType.Descending;
- }
- }
-
- Map<Integer, AppliesToClause> appliesTo = null;
- if (indexMap.containsKey(indexName)) {
- appliesTo = indexMap.get(indexName);
- } else {
- appliesTo = new HashMap<Integer, AppliesToClause>();
- indexMap.put(indexName, appliesTo);
- }
- appliesTo.put(new Integer(ordinal), new AppliesToClause(columnName, orderType));
- }
- }
- }
- }
- for (String indexName : indexMap.keySet()) {
- Map<Integer, AppliesToClause> clauseMap = indexMap.get(indexName);
- IndexElement element = new IndexElement(indexName);
-
- Set<Integer> index = clauseMap.keySet();
- Set<Integer> sortedIndex = new TreeSet<Integer>();
- for (Integer val : index) {
- sortedIndex.add(val);
- }
-
- for (Integer val : sortedIndex) {
- AppliesToClause clause = clauseMap.get(val);
- element.addAppliesTo(clause.getColumnName(), clause.getOrderType());
- }
- aTable.addIndexData(element);
- }
- } finally {
- if (indexKeys != null) {
- indexKeys.close();
- }
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/ImportDataFromDbCallable.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/ImportDataFromDbCallable.java
deleted file mode 100644
index 2163959e38..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/ImportDataFromDbCallable.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.callable;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-import org.eclipse.osee.database.schema.DatabaseCallable;
-import org.eclipse.osee.database.schema.internal.data.SchemaData;
-import org.eclipse.osee.database.schema.internal.data.TableElement;
-import org.eclipse.osee.database.schema.internal.util.FileUtility;
-import org.eclipse.osee.framework.core.data.IDatabaseInfo;
-import org.eclipse.osee.framework.database.DatabaseInfoRegistry;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.logger.Log;
-
-/**
- * @author Roberto E. Escobar
- */
-public class ImportDataFromDbCallable extends DatabaseCallable<Object> {
-
- private static final File backupDirectory = new File("BackupDirectory");
-
- private final Map<String, SchemaData> userSpecifiedConfig;
- private final String tableImportSource;
- private final DatabaseInfoRegistry registry;
-
- public ImportDataFromDbCallable(Log logger, DatabaseInfoRegistry registry, IOseeDatabaseService databaseService, Map<String, SchemaData> userSpecifiedConfig, String tableImportSource) {
- super(logger, databaseService);
- this.registry = registry;
- this.userSpecifiedConfig = userSpecifiedConfig;
- this.tableImportSource = tableImportSource;
- }
-
- @Override
- public Object call() throws Exception {
- Set<String> importConnections = getImportConnections();
- for (String importFromDbService : importConnections) {
- getLogger().info("Import Table Data from Db: [%s]", importFromDbService);
-
- IDatabaseInfo dbInfo = registry.getDatabaseInfo(importFromDbService);
- getLogger().info("Gathering information from ... [%s]", importFromDbService);
-
- String userName = dbInfo.getDatabaseLoginName();
- if (Strings.isValid(userName)) {
-
- Set<String> schemasToGet = new TreeSet<String>();
- schemasToGet.add(userName.toUpperCase());
-
- Map<String, Set<String>> dataToImport = getTablesToImport(userName.toUpperCase(), schemasToGet);
- if (dataToImport.size() > 0) {
- getLogger().info(dataToImport.toString().replaceAll(", ", "\n"));
- makeBackupDirectoryIfItDoesntExist();
-
- getLogger().info("Backing up Files to: [%s]", backupDirectory.getAbsolutePath());
- DatabaseDataExtractorCallable dbDataExtractor =
- new DatabaseDataExtractorCallable(getLogger(), getDatabaseService(), schemasToGet, backupDirectory);
-
- Set<String> tablesToImport;
- if (importFromDbService.equals(determineDefaultConnection())) {
- tablesToImport = dataToImport.get(tableImportSource);
- } else {
- tablesToImport = dataToImport.get(importFromDbService);
- }
-
- for (String importTable : tablesToImport) {
- dbDataExtractor.addTableNameToExtract(importTable);
- }
- dbDataExtractor.call();
- dbDataExtractor.waitForWorkerThreads();
-
- prepareFilesForImport();
- }
- }
- }
- return null;
- }
-
- private void prepareFilesForImport() {
- Set<String> keys = userSpecifiedConfig.keySet();
- if (keys.size() == 1) {
- String userName = "";
- for (String temp : keys) {
- userName = temp;
- }
- List<File> files = FileUtility.getDBDataFileList(backupDirectory);
- for (File fileName : files) {
- String filename = fileName.getAbsolutePath().toString();
- filename = filename.substring(filename.lastIndexOf(File.separator) + 1, filename.length());
- filename = filename.substring(filename.indexOf(".") + 1, filename.length());
- fileName.renameTo(new File(backupDirectory + File.separator + userName + "." + filename));
- }
- }
- }
-
- private String determineDefaultConnection() {
- String importFromDbService = System.getProperty(tableImportSource);
- if (!Strings.isValid(importFromDbService)) {
- importFromDbService = "oracle";
- }
- return importFromDbService;
- }
-
- private Set<String> getImportConnections() {
- String defaultConnection = determineDefaultConnection();
- Set<String> userSchemas = userSpecifiedConfig.keySet();
- Set<String> connectionsNeeded = new TreeSet<String>();
- for (String key : userSchemas) {
- SchemaData schemaDataInUserConfig = userSpecifiedConfig.get(key);
- Map<String, Set<String>> tableNamesToImport = schemaDataInUserConfig.getTablesToImport(tableImportSource);
- Set<String> keys = tableNamesToImport.keySet();
- for (String connectionString : keys) {
- if (connectionString.equals(tableImportSource)) {
- connectionsNeeded.add(defaultConnection);
- } else {
- connectionsNeeded.add(connectionString);
- }
- }
- }
- return connectionsNeeded;
- }
-
- private Map<String, SchemaData> getAvailableSchemasFromImportDb(Set<String> schemas) throws Exception {
- Map<String, SchemaData> schemaMap = new HashMap<String, SchemaData>();
- ExtractSchemaCallable schemaExtractor =
- new ExtractSchemaCallable(getLogger(), getDatabaseService(), schemas, schemaMap);
- schemaExtractor.call();
- return schemaMap;
- }
-
- private Map<String, Set<String>> getTablesToImport(String userName, Set<String> schemasToGet) throws Exception {
- Map<String, SchemaData> currentDbSchemas = getAvailableSchemasFromImportDb(schemasToGet);
- Set<String> userSchemas = userSpecifiedConfig.keySet();
-
- SchemaData schemaData = currentDbSchemas.get(userName);
- Map<String, TableElement> tableMap = schemaData.getTableMap();
-
- Map<String, Set<String>> importTables = new HashMap<String, Set<String>>();
- for (String key : userSchemas) {
- SchemaData schemaDataInUserConfig = userSpecifiedConfig.get(key);
- Map<String, Set<String>> tableNamesToImport = schemaDataInUserConfig.getTablesToImport(tableImportSource);
-
- Set<String> keys = tableNamesToImport.keySet();
- for (String importKey : keys) {
- Set<String> namesToImport = tableNamesToImport.get(importKey);
-
- for (String tableName : namesToImport) {
- tableName = tableName.replaceAll(key + "\\.", userName + ".");
-
- if (tableMap.containsKey(tableName)) {
- Set<String> tableSet;
- if (importTables.containsKey(importKey)) {
- tableSet = importTables.get(importKey);
- } else {
- tableSet = new TreeSet<String>();
- }
- tableSet.add(tableName);
- importTables.put(importKey, tableSet);
- }
- }
- }
- }
- return importTables;
- }
-
- private void makeBackupDirectoryIfItDoesntExist() {
- if (backupDirectory != null && backupDirectory.exists() && backupDirectory.canWrite()) {
- return;
- } else {
- backupDirectory.mkdirs();
- }
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/LoadUserSchemasCallable.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/LoadUserSchemasCallable.java
deleted file mode 100644
index 9cc8d63dd4..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/LoadUserSchemasCallable.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.callable;
-
-import java.sql.DatabaseMetaData;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.eclipse.osee.database.schema.DatabaseCallable;
-import org.eclipse.osee.database.schema.SchemaOptions;
-import org.eclipse.osee.database.schema.SchemaResourceProvider;
-import org.eclipse.osee.database.schema.internal.data.ColumnMetadata;
-import org.eclipse.osee.database.schema.internal.data.ConstraintElement;
-import org.eclipse.osee.database.schema.internal.data.ForeignKey;
-import org.eclipse.osee.database.schema.internal.data.IndexElement;
-import org.eclipse.osee.database.schema.internal.data.ReferenceClause;
-import org.eclipse.osee.database.schema.internal.data.SchemaData;
-import org.eclipse.osee.database.schema.internal.data.SchemaXmlParser;
-import org.eclipse.osee.database.schema.internal.data.TableElement;
-import org.eclipse.osee.database.schema.internal.data.TableElement.TableDescriptionFields;
-import org.eclipse.osee.framework.core.exception.OseeExceptions;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.database.core.OseeConnection;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.logger.Log;
-
-/**
- * @author Roberto E. Escobar
- */
-public class LoadUserSchemasCallable extends DatabaseCallable<Object> {
-
- private final Map<String, SchemaData> schemas;
- private final SchemaResourceProvider provider;
- private final SchemaOptions options;
-
- public LoadUserSchemasCallable(Log logger, IOseeDatabaseService dbService, Map<String, SchemaData> schemas, SchemaResourceProvider provider, SchemaOptions options) {
- super(logger, dbService);
- this.schemas = schemas;
- this.provider = provider;
- this.options = options;
- }
-
- private DatabaseMetaData getMetaData() throws OseeCoreException {
- OseeConnection connection = getDatabaseService().getConnection();
- try {
- return connection.getMetaData();
- } finally {
- connection.close();
- }
- }
-
- @Override
- public Object call() throws Exception {
- SchemaXmlParser parser = new SchemaXmlParser(getLogger());
- parser.parse(provider.getSchemaResources(), schemas);
-
- if (!options.isUseFileSpecifiedSchemas()) {
- try {
- DatabaseMetaData meta = getMetaData();
- if (meta != null) {
- String userName = meta.getUserName();
- if (Strings.isValid(userName)) {
- int index = userName.indexOf('@');
- if (index > 1) {
- userName = userName.substring(0, index);
- }
- Map<String, SchemaData> newData = useUserNameAsSchema(userName.toUpperCase(), schemas);
- schemas.clear();
- schemas.putAll(newData);
- }
- }
- } catch (SQLException ex) {
- OseeExceptions.wrapAndThrow(ex);
- }
- }
-
- if (options.isTableDataSpaceValid()) {
- for (SchemaData schemaData : schemas.values()) {
- schemaData.setTableDataSpaceName(options.getTableDataSpace());
- }
- }
-
- if (options.isIndexDataSpaceValid()) {
- for (SchemaData schemaData : schemas.values()) {
- schemaData.setIndexDataSpaceName(options.getIndexDataSpace());
- }
- }
- return null;
- }
-
- private Map<String, SchemaData> useUserNameAsSchema(String userName, Map<String, SchemaData> userSchemas) {
- Map<String, SchemaData> newData = new HashMap<String, SchemaData>();
- SchemaData newSchemaData = new SchemaData();
- Set<String> keys = userSchemas.keySet();
- for (String key : keys) {
- SchemaData schemaData = userSchemas.get(key);
- List<TableElement> tables = schemaData.getTablesOrderedByDependency();
- for (TableElement table : tables) {
- TableElement newTable = useUserNameAsSchemaForTable(userName, table);
- newSchemaData.addTableDefinition(newTable);
- }
- }
- newData.put(userName, newSchemaData);
- return newData;
- }
-
- private TableElement useUserNameAsSchemaForTable(String userName, TableElement table) {
- TableElement newTable = new TableElement();
-
- Map<TableDescriptionFields, String> tableDescription = table.getDescription();
- Map<String, ColumnMetadata> columns = table.getColumns();
- List<ConstraintElement> constraints = table.getConstraints();
- List<ForeignKey> foreignKeys = table.getForeignKeyConstraints();
- List<IndexElement> indexElements = table.getIndexData();
-
- TableDescriptionFields[] descriptors = TableDescriptionFields.values();
- for (TableDescriptionFields field : descriptors) {
- String value = tableDescription.get(field);
- if (field.equals(TableDescriptionFields.schema)) {
- value = userName;
- }
- if (Strings.isValid(value)) {
- newTable.addTableDescription(field, value);
- }
- }
-
- Set<String> columnKeys = columns.keySet();
- for (String key : columnKeys) {
- newTable.addColumn(columns.get(key));
- }
- for (ConstraintElement constraint : constraints) {
- constraint.setSchema(userName);
- newTable.addConstraint(constraint);
- }
- for (ForeignKey constraint : foreignKeys) {
- constraint.setSchema(userName);
- List<ReferenceClause> references = constraint.getReferences();
- for (ReferenceClause clause : references) {
- clause.setSchema(userName);
- }
- newTable.addConstraint(constraint);
- }
- for (IndexElement indexElement : indexElements) {
- newTable.addIndexData(indexElement);
- }
- return newTable;
- }
-
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/PrintTablesCallable.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/PrintTablesCallable.java
deleted file mode 100644
index 01df840d27..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/PrintTablesCallable.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.callable;
-
-import java.io.Writer;
-import java.util.Map;
-import java.util.Set;
-import org.eclipse.osee.database.schema.DatabaseCallable;
-import org.eclipse.osee.database.schema.internal.data.SchemaData;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.database.core.IOseeStatement;
-import org.eclipse.osee.logger.Log;
-
-/**
- * @author Roberto E. Escobar
- */
-public class PrintTablesCallable extends DatabaseCallable<Object> {
-
- private final Map<String, SchemaData> userConfig;
- private final Writer writer;
-
- public PrintTablesCallable(Log logger, IOseeDatabaseService dbService, Map<String, SchemaData> userConfig, Writer writer) {
- super(logger, dbService);
- this.userConfig = userConfig;
- this.writer = writer;
- }
-
- @Override
- public Object call() throws Exception {
- Set<String> keys = userConfig.keySet();
- for (String key : keys) {
- SchemaData schemaData = userConfig.get(key);
- Set<String> tables = schemaData.getTableMap().keySet();
- for (String tableName : tables) {
- printTable(tableName);
- }
- }
- return null;
- }
-
- private void printTable(String tableName) throws Exception {
- IOseeStatement chStmt = getDatabaseService().getStatement();
- try {
- chStmt.runPreparedQuery("select * from " + tableName);
- int numberOfColumns = chStmt.getColumnCount();
-
- StringBuilder builder = new StringBuilder();
-
- builder.append("\nTable:\t");
- builder.append(tableName);
- builder.append("\n");
- builder.append("Columns:\t");
- for (int index = 1; index <= numberOfColumns; index++) {
- builder.append(chStmt.getColumnName(index));
- if (index + 1 <= numberOfColumns) {
- builder.append(", ");
- }
- }
- builder.append("\n");
-
- writer.write(builder.toString());
- builder.delete(0, builder.length());
-
- while (chStmt.next()) {
- builder.append("Data:\t");
- for (int index = 1; index <= numberOfColumns; index++) {
- builder.append(chStmt.getObject(index).toString());
- if (index + 1 <= numberOfColumns) {
- builder.append(", ");
- }
- }
- builder.append("\n");
- writer.write(builder.toString());
- builder.delete(0, builder.length());
- }
- } finally {
- chStmt.close();
- }
- }
-
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/RestoreTableDataOperation.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/RestoreTableDataOperation.java
deleted file mode 100644
index a9d2c3b7f2..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/callable/RestoreTableDataOperation.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.callable;
-
-import java.io.File;
-import java.sql.DatabaseMetaData;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.eclipse.osee.database.schema.DatabaseTxCallable;
-import org.eclipse.osee.database.schema.internal.data.SchemaData;
-import org.eclipse.osee.database.schema.internal.data.TableElement;
-import org.eclipse.osee.database.schema.internal.sql.SqlFactory;
-import org.eclipse.osee.database.schema.internal.sql.SqlManager;
-import org.eclipse.osee.database.schema.internal.util.DatabaseDataImporter;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.database.core.OseeConnection;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.logger.Log;
-
-/**
- * @author Roberto E. Escobar
- */
-public class RestoreTableDataOperation extends DatabaseTxCallable<Object> {
- private static final File backupDirectory = new File("backupDirectory");
-
- private final Set<String> schemas;
- private final Map<String, SchemaData> userSpecifiedConfig;
- private final String importDatabaseSource;
-
- public RestoreTableDataOperation(Log logger, IOseeDatabaseService dbService, Set<String> schemas, Map<String, SchemaData> userSpecifiedConfig, String importDatabaseSource) {
- super(logger, dbService, "Restore Table Data");
- this.schemas = schemas;
- this.userSpecifiedConfig = userSpecifiedConfig;
- this.importDatabaseSource = importDatabaseSource;
- }
-
- @Override
- protected Object handleTxWork(OseeConnection connection) throws OseeCoreException {
- DatabaseMetaData metaData = connection.getMetaData();
- SqlManager sqlManager = SqlFactory.getSqlManager(getLogger(), getDatabaseService(), metaData);
-
- for (String schemaKey : schemas) {
- if (userSpecifiedConfig.containsKey(schemaKey)) {
- DatabaseDataImporter importer = new DatabaseDataImporter(getLogger(), backupDirectory, sqlManager);
- SchemaData schemaData = userSpecifiedConfig.get(schemaKey);
-
- setImportOrder(importer, schemaData);
- setTablesToImport(importer, schemaData);
- importer.setSchemaToImportTo(schemaKey);
-
- importer.importDataIntoDatabase();
- }
- }
-
- clearBackupDirectory();
- return null;
- }
-
- private void setImportOrder(DatabaseDataImporter importer, SchemaData schemaData) {
- List<String> importOrder = new ArrayList<String>();
-
- List<TableElement> tables = schemaData.getTablesOrderedByDependency();
- for (TableElement table : tables) {
- importOrder.add(table.getFullyQualifiedTableName());
- }
- importer.setImportOrder(importOrder);
- }
-
- private void setTablesToImport(DatabaseDataImporter importer, SchemaData schemaData) {
- importer.clearTableFilter();
- Set<String> selectedTables = schemaData.getTablesToBackup();
- for (String tableName : selectedTables) {
- importer.addToTableFilter(tableName);
- }
- Map<String, Set<String>> importedTables = schemaData.getTablesToImport(importDatabaseSource);
- Set<String> keys = importedTables.keySet();
- for (String key : keys) {
- Set<String> tables = importedTables.get(key);
- for (String tableName : tables) {
- importer.addToTableFilter(tableName);
- }
- }
- }
-
- private void clearBackupDirectory() {
- if (backupDirectory != null && backupDirectory.exists() && backupDirectory.canWrite()) {
- File[] fileList = backupDirectory.listFiles();
- for (File fileToDelete : fileList) {
- fileToDelete.delete();
- }
- backupDirectory.delete();
- }
- }
-
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/AppliesToClause.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/AppliesToClause.java
deleted file mode 100644
index 82f5e3d3bc..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/AppliesToClause.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.data;
-
-import org.eclipse.osee.framework.jdk.core.persistence.Xmlizable;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * @author Roberto E. Escobar
- */
-public class AppliesToClause implements Xmlizable {
- public static final String APPLIES_TO_TAG = "AppliesTo";
-
- public enum OrderType {
- Undefined,
- Ascending,
- Descending;
- }
-
- public enum AppliesToEntries {
- id,
- sort;
- }
-
- private String columnName;
- private OrderType orderType;
-
- public AppliesToClause(String columnName, OrderType orderType) {
- this.columnName = columnName;
- this.orderType = orderType;
- }
-
- public String getColumnName() {
- return columnName;
- }
-
- public void setColumnName(String columnName) {
- this.columnName = columnName;
- }
-
- public OrderType getOrderType() {
- return orderType;
- }
-
- public void setOrderType(OrderType orderType) {
- this.orderType = orderType;
- }
-
- @Override
- public String toString() {
- return String.format("%s:[%s]\t%s:[%s]", AppliesToEntries.id.name(), columnName, AppliesToEntries.sort.name(),
- orderType);
- }
-
- @Override
- public Element toXml(Document doc) {
- Element element = doc.createElement(APPLIES_TO_TAG);
- element.setAttribute(AppliesToEntries.id.name(), columnName);
- if (!orderType.equals(OrderType.Undefined)) {
- element.setAttribute(AppliesToEntries.sort.name(), orderType.name());
- }
- return element;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((columnName == null) ? 0 : columnName.hashCode());
- result = prime * result + ((orderType == null) ? 0 : orderType.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- AppliesToClause other = (AppliesToClause) obj;
- if (columnName == null) {
- if (other.columnName != null) {
- return false;
- }
- } else if (!columnName.equals(other.columnName)) {
- return false;
- }
- if (orderType != other.orderType) {
- return false;
- }
- return true;
- }
-
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/ColumnDbData.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/ColumnDbData.java
deleted file mode 100644
index 3a03fd9993..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/ColumnDbData.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.data;
-
-/**
- * @author Roberto E. Escobar
- */
-public class ColumnDbData {
- private final String columnName;
- private final String columnValue;
-
- public ColumnDbData(String columnName, String columnValue) {
- this.columnName = columnName;
- this.columnValue = columnValue;
- }
-
- public String getColumnName() {
- return columnName;
- }
-
- public String getColumnValue() {
- return columnValue;
- }
-
- @Override
- public String toString() {
- return "[" + columnName + ", " + columnValue + "]";
- }
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/ColumnMetadata.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/ColumnMetadata.java
deleted file mode 100644
index 139cf51667..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/ColumnMetadata.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.data;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import org.eclipse.osee.database.schema.internal.data.TableElement.ColumnFields;
-import org.eclipse.osee.database.schema.internal.data.TableElement.TableSections;
-import org.eclipse.osee.framework.jdk.core.persistence.Xmlizable;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * @author Roberto E. Escobar
- */
-public class ColumnMetadata implements Xmlizable {
- private final Map<ColumnFields, String> columnFields;
-
- public ColumnMetadata(String columnId) {
- columnFields = new HashMap<ColumnFields, String>();
- columnFields.put(ColumnFields.id, columnId);
- }
-
- public String getId() {
- return getColumnField(ColumnFields.id);
- }
-
- public Map<ColumnFields, String> getColumnFields() {
- return columnFields;
- }
-
- public void addColumnField(ColumnFields field, String value) {
- columnFields.put(field, value);
- }
-
- public String getColumnField(ColumnFields field) {
- if (columnFields.containsKey(field)) {
- return columnFields.get(field);
- }
- return "";
- }
-
- @Override
- public String toString() {
- String toReturn = TableSections.Column + ": ";
- Set<ColumnFields> keys = columnFields.keySet();
- for (ColumnFields field : keys) {
- String value = columnFields.get(field);
- toReturn += "\t" + field + "[" + value + "]";
- }
- return toReturn;
- }
-
- @Override
- public Element toXml(Document doc) {
- Element columnElement = doc.createElement(TableSections.Column.toString());
- for (ColumnFields key : columnFields.keySet()) {
- columnElement.setAttribute(key.toString(), columnFields.get(key));
- }
- return columnElement;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((columnFields == null) ? 0 : columnFields.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- ColumnMetadata other = (ColumnMetadata) obj;
- if (columnFields == null) {
- if (other.columnFields != null) {
- return false;
- }
- } else if (!columnFields.equals(other.columnFields)) {
- return false;
- }
- return true;
- }
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/ConstraintElement.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/ConstraintElement.java
deleted file mode 100644
index c9d3bbc7fd..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/ConstraintElement.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.data;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.osee.database.schema.internal.data.TableElement.TableSections;
-import org.eclipse.osee.framework.jdk.core.persistence.Xmlizable;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * @author Roberto E. Escobar
- */
-public class ConstraintElement implements Xmlizable {
-
- public enum ConstraintFields {
- id,
- schema,
- type,
- appliesTo,
- deferrable
- };
-
- private final ConstraintTypes constraintType;
- private final boolean deferrable;
- private String schema;
- private String id;
- private final List<String> columns;
-
- public ConstraintElement(ConstraintTypes constraintType, String schema, String id, boolean deferrable) {
- this.schema = schema.toUpperCase();
- this.schema = this.schema.trim();
- this.id = id.toUpperCase();
- this.id = this.id.trim();
- this.deferrable = deferrable;
- this.constraintType = constraintType;
- this.columns = new ArrayList<String>();
- }
-
- public List<String> getColumns() {
- return columns;
- }
-
- public String getId() {
- return id;
- }
-
- public String getSchema() {
- return schema;
- }
-
- public void addColumn(String columnName) {
- columnName = columnName.toUpperCase();
- columnName = columnName.trim();
- this.columns.add(columnName);
- }
-
- public void setId(String id) {
- id = id.toUpperCase();
- id = id.trim();
- this.id = id;
- }
-
- public void setSchema(String schema) {
- schema = schema.toUpperCase();
- schema = schema.trim();
- this.schema = schema;
- }
-
- public String getFullyQualifiedId() {
- if (Strings.isValid(schema)) {
- return schema + "." + id;
- } else {
- return id;
- }
- }
-
- /**
- * @return Returns the deferrable.
- */
- public boolean isDeferrable() {
- return deferrable;
- }
-
- public ConstraintTypes getConstraintType() {
- return constraintType;
- }
-
- public String getCommaSeparatedColumnsList() {
- return org.eclipse.osee.framework.jdk.core.util.Collections.toString(",", columns);
- }
-
- @Override
- public String toString() {
- String toReturn = TableSections.Constraint + ": ";
- toReturn += "\t" + ConstraintFields.schema + "[" + schema + "]";
- toReturn += "\t" + ConstraintFields.id + "[" + id + "]";
- toReturn += "\t" + ConstraintFields.type + "[" + constraintType.toString() + "]";
- toReturn += "\t" + ConstraintFields.appliesTo + "[" + getCommaSeparatedColumnsList() + "]";
- toReturn += "\t" + ConstraintFields.deferrable + "[" + Boolean.toString(deferrable) + "]";
- return toReturn;
- }
-
- @Override
- public Element toXml(Document doc) {
- Element constraintElement = doc.createElement(TableSections.Constraint.toString());
- constraintElement.setAttribute(ConstraintFields.schema.name(), schema);
- constraintElement.setAttribute(ConstraintFields.id.name(), id);
- constraintElement.setAttribute(ConstraintFields.type.name(), constraintType.toString());
- constraintElement.setAttribute(ConstraintFields.appliesTo.name(), getCommaSeparatedColumnsList());
- constraintElement.setAttribute(ConstraintFields.deferrable.name(), Boolean.toString(deferrable));
- return constraintElement;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((columns == null) ? 0 : columns.hashCode());
- result = prime * result + ((constraintType == null) ? 0 : constraintType.hashCode());
- result = prime * result + (deferrable ? 1231 : 1237);
- result = prime * result + ((id == null) ? 0 : id.hashCode());
- result = prime * result + ((schema == null) ? 0 : schema.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- ConstraintElement other = (ConstraintElement) obj;
- if (columns == null) {
- if (other.columns != null) {
- return false;
- }
- } else if (!columns.equals(other.columns)) {
- return false;
- }
- if (constraintType != other.constraintType) {
- return false;
- }
- if (deferrable != other.deferrable) {
- return false;
- }
- if (id == null) {
- if (other.id != null) {
- return false;
- }
- } else if (!id.equals(other.id)) {
- return false;
- }
- if (schema == null) {
- if (other.schema != null) {
- return false;
- }
- } else if (!schema.equals(other.schema)) {
- return false;
- }
- return true;
- }
-
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/ConstraintFactory.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/ConstraintFactory.java
deleted file mode 100644
index 3714df73e3..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/ConstraintFactory.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.data;
-
-/**
- * @author Roberto E. Escobar
- */
-public class ConstraintFactory {
-
- public static ConstraintElement getConstraint(ConstraintTypes constraintType, String schema, String id, boolean deferrable) {
- ConstraintElement element = null;
- if (constraintType != null) {
- switch (constraintType) {
- case FOREIGN_KEY:
- element = new ForeignKey(constraintType, schema, id, deferrable);
- break;
- case PRIMARY_KEY:
- case UNIQUE:
- case CHECK:
- default:
- element = new ConstraintElement(constraintType, schema, id, deferrable);
- break;
- }
- }
- return element;
- }
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/ConstraintTypes.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/ConstraintTypes.java
deleted file mode 100644
index 06844778c8..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/ConstraintTypes.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.data;
-
-/**
- * @author Roberto E. Escobar
- */
-public enum ConstraintTypes {
- PRIMARY_KEY,
- FOREIGN_KEY,
- UNIQUE,
- CHECK;
-
- @Override
- public String toString() {
- String toReturn = super.toString();
- toReturn = toReturn.replaceAll("_", " ");
- return toReturn;
- }
-
- public static ConstraintTypes textToType(String text) {
- ConstraintTypes[] typesArray = ConstraintTypes.values();
- for (ConstraintTypes type : typesArray) {
- if (type.toString().equals(text.toUpperCase())) {
- return type;
- }
- }
- return null;
- }
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/ForeignKey.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/ForeignKey.java
deleted file mode 100644
index 87adbdccd4..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/ForeignKey.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.data;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * @author Roberto E. Escobar
- */
-public class ForeignKey extends ConstraintElement {
-
- List<ReferenceClause> references;
-
- public ForeignKey(ConstraintTypes constraintType, String schema, String id, boolean deferrable) {
- super(constraintType, schema, id, deferrable);
- references = new ArrayList<ReferenceClause>();
- }
-
- public void addReference(ReferenceClause reference) {
- references.add(reference);
- }
-
- public List<ReferenceClause> getReferences() {
- return references;
- }
-
- public Set<String> getReferencedTables() {
- Set<String> refTables = new TreeSet<String>();
- for (ReferenceClause ref : references) {
- refTables.add(ref.getFullyQualifiedTableName());
- }
- return refTables;
- }
-
- @Override
- public String toString() {
- String toReturn = super.toString();
- for (ReferenceClause reference : references) {
- toReturn += "\n\t\t" + reference.toString();
- }
- return toReturn;
- }
-
- @Override
- public Element toXml(Document doc) {
- Element parent = super.toXml(doc);
- for (ReferenceClause reference : references) {
- parent.appendChild(reference.toXml(doc));
- }
- return parent;
- }
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/IndexElement.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/IndexElement.java
deleted file mode 100644
index d0df33441c..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/IndexElement.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.data;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.osee.database.schema.internal.data.AppliesToClause.OrderType;
-import org.eclipse.osee.framework.jdk.core.persistence.Xmlizable;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * @author Roberto E. Escobar
- */
-public class IndexElement implements Xmlizable {
-
- public enum IndexFields {
- id,
- mySqlIgnore,
- type,
- tablespace;
- }
-
- private String id;
- private String indexType;
- private final List<AppliesToClause> appliesToList;
- private boolean ignoreMySql = false;
- private String tablespace;
-
- public IndexElement(String id) {
- this.id = id;
- this.appliesToList = new ArrayList<AppliesToClause>();
- this.indexType = "";
- this.tablespace = "";
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getId() {
- return id;
- }
-
- public void addAppliesTo(String name, OrderType type) {
- appliesToList.add(new AppliesToClause(name, type));
- }
-
- public List<AppliesToClause> getAppliesToList() {
- return appliesToList;
- }
-
- @Override
- public String toString() {
- StringBuilder toReturn = new StringBuilder();
- toReturn.append(" Index: " + id);
- toReturn.append(getAppliesToAsString());
- return toReturn.toString();
- }
-
- @Override
- public Element toXml(Document doc) {
- Element element = doc.createElement(TableElement.TableSections.Index.name());
- element.setAttribute(IndexFields.id.name(), id);
- for (AppliesToClause clause : appliesToList) {
- element.appendChild(clause.toXml(doc));
- }
- return element;
- }
-
- public String getAppliesToAsString() {
- StringBuilder toReturn = new StringBuilder();
- for (int index = 0; index < appliesToList.size(); index++) {
- toReturn.append("\n\t\tApplies to " + appliesToList.get(index));
- }
- return toReturn.toString();
- }
-
- public void setMySqlIgnore(boolean b) {
- this.ignoreMySql = b;
- }
-
- public void setIndexType(String indexType) {
- if (indexType != null) {
- this.indexType = indexType;
- }
- }
-
- public String getIndexType() {
- return indexType;
- }
-
- public boolean ignoreMySql() {
- return this.ignoreMySql;
- }
-
- public String getTablespace() {
- return Strings.isValid(tablespace) ? tablespace : "";
- }
-
- public void setTablespace(String tablespace) {
- this.tablespace = tablespace;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((appliesToList == null) ? 0 : appliesToList.hashCode());
- result = prime * result + ((id == null) ? 0 : id.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- IndexElement other = (IndexElement) obj;
- if (appliesToList == null) {
- if (other.appliesToList != null) {
- return false;
- }
- } else if (!appliesToList.equals(other.appliesToList)) {
- return false;
- }
- if (id == null) {
- if (other.id != null) {
- return false;
- }
- } else if (!id.equals(other.id)) {
- return false;
- }
- return true;
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/ReferenceClause.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/ReferenceClause.java
deleted file mode 100644
index f1a55cd85d..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/ReferenceClause.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.data;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.osee.framework.jdk.core.persistence.Xmlizable;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * @author Roberto E. Escobar
- */
-public class ReferenceClause implements Xmlizable {
- public static final String REFERENCES_TAG = "References";
-
- public enum ReferencesFields {
- schema,
- table,
- column,
- onUpdate,
- onDelete;
- }
-
- public enum OnDeleteEnum {
- NO_ACTION,
- RESTRICT,
- CASCADE,
- SET_NULL,
- UNSPECIFIED;
-
- @Override
- public String toString() {
- String toReturn = super.toString();
- toReturn = toReturn.replaceAll("_", " ");
- return toReturn;
- }
- }
-
- public enum OnUpdateEnum {
- NO_ACTION,
- RESTRICT,
- UNSPECIFIED;
-
- @Override
- public String toString() {
- String toReturn = super.toString();
- toReturn = toReturn.replaceAll("_", " ");
- return toReturn;
- }
- }
-
- private String schema;
- private String table;
- List<String> columns;
- OnDeleteEnum onDeleteAction;
- OnUpdateEnum onUpdateAction;
-
- public ReferenceClause(String schema, String table) {
- this.schema = schema.toUpperCase();
- this.schema = this.schema.trim();
- this.table = table.toUpperCase();
- this.table = this.table.trim();
- this.columns = new ArrayList<String>();
- this.onDeleteAction = OnDeleteEnum.UNSPECIFIED;
- this.onUpdateAction = OnUpdateEnum.UNSPECIFIED;
- }
-
- public void setSchema(String schema) {
- this.schema = schema;
- }
-
- public OnDeleteEnum getOnDeleteAction() {
- return onDeleteAction;
- }
-
- public OnUpdateEnum getOnUpdateAction() {
- return onUpdateAction;
- }
-
- public void setOnDeleteAction(OnDeleteEnum onDeleteAction) {
- this.onDeleteAction = onDeleteAction;
- }
-
- public void setOnUpdateAction(OnUpdateEnum onUpdateAction) {
- this.onUpdateAction = onUpdateAction;
- }
-
- public void addColumn(String column) {
- column = column.toUpperCase();
- column = column.trim();
- columns.add(column);
- }
-
- public String getFullyQualifiedTableName() {
- return schema + "." + table;
- }
-
- public List<String> getColumns() {
- return columns;
- }
-
- public String getCommaSeparatedColumnsList() {
- return org.eclipse.osee.framework.jdk.core.util.Collections.toString(",", columns);
- }
-
- @Override
- public String toString() {
- String toReturn = REFERENCES_TAG + ": " + getFullyQualifiedTableName();
- toReturn += "\t[";
- for (String column : columns) {
- toReturn += column + " ";
- }
- toReturn += "]";
- return toReturn;
- }
-
- @Override
- public Element toXml(Document doc) {
- Element refElement = doc.createElement(REFERENCES_TAG);
- refElement.setAttribute(ReferencesFields.schema.name(), schema);
- refElement.setAttribute(ReferencesFields.table.name(), table);
- refElement.setAttribute(ReferencesFields.column.name(), getCommaSeparatedColumnsList());
-
- if (!onDeleteAction.equals(OnDeleteEnum.UNSPECIFIED)) {
- refElement.setAttribute(ReferencesFields.onDelete.name(), onDeleteAction.toString());
- }
-
- if (!onUpdateAction.equals(OnUpdateEnum.UNSPECIFIED)) {
- refElement.setAttribute(ReferencesFields.onUpdate.name(), onUpdateAction.toString());
- }
- return refElement;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((columns == null) ? 0 : columns.hashCode());
- result = prime * result + ((onDeleteAction == null) ? 0 : onDeleteAction.hashCode());
- result = prime * result + ((onUpdateAction == null) ? 0 : onUpdateAction.hashCode());
- result = prime * result + ((schema == null) ? 0 : schema.hashCode());
- result = prime * result + ((table == null) ? 0 : table.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- ReferenceClause other = (ReferenceClause) obj;
- if (columns == null) {
- if (other.columns != null) {
- return false;
- }
- } else if (!columns.equals(other.columns)) {
- return false;
- }
- if (onDeleteAction != other.onDeleteAction) {
- return false;
- }
- if (onUpdateAction != other.onUpdateAction) {
- return false;
- }
- if (schema == null) {
- if (other.schema != null) {
- return false;
- }
- } else if (!schema.equals(other.schema)) {
- return false;
- }
- if (table == null) {
- if (other.table != null) {
- return false;
- }
- } else if (!table.equals(other.table)) {
- return false;
- }
- return true;
- }
-
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/SchemaData.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/SchemaData.java
deleted file mode 100644
index f2b5466745..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/SchemaData.java
+++ /dev/null
@@ -1,280 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.data;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-import javax.xml.parsers.ParserConfigurationException;
-import org.eclipse.osee.database.schema.internal.data.TableElement.ColumnFields;
-import org.eclipse.osee.framework.jdk.core.persistence.Xmlizable;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.framework.jdk.core.util.xml.Jaxp;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * @author Roberto E. Escobar
- */
-public class SchemaData implements Xmlizable {
-
- public static final String ROOT_TAG = "TableConfig";
- private List<TableElement> tableDefinitions;
- private final SchemaDataLookup schemaLookup;
-
- private final boolean isSorted;
-
- public SchemaData() {
- this.tableDefinitions = new ArrayList<TableElement>();
- this.isSorted = false;
- this.schemaLookup = new SchemaDataLookup(this);
- }
-
- public void setTableDataSpaceName(String tableDataSpace) {
- for (TableElement table : getTableMap().values()) {
- table.setTablespace(tableDataSpace);
- }
- }
-
- public void setIndexDataSpaceName(String indexDataSpace) {
- for (TableElement table : getTableMap().values()) {
- for (IndexElement indexElement : table.getIndexData()) {
- indexElement.setTablespace(indexDataSpace);
- }
- }
- }
-
- public List<TableElement> getTablesOrderedByDependency() {
- sortTablesForConstraints();
- markIdentityColumns();
- return tableDefinitions;
- }
-
- public Set<String> getTablesToBackup() {
- Set<String> backupTables = new TreeSet<String>();
- for (TableElement table : tableDefinitions) {
- if (table.isBackupDataSet()) {
- backupTables.add(table.getFullyQualifiedTableName());
- }
- }
- return backupTables;
- }
-
- public Map<String, Set<String>> getTablesToImport(String defaultSource) {
- Map<String, Set<String>> importTables = new HashMap<String, Set<String>>();
- for (TableElement table : tableDefinitions) {
- if (table.isImportDataSet()) {
- String importFrom = table.getImportFrom();
- if (!Strings.isValid(importFrom)) {
- importFrom = defaultSource;
- }
- Set<String> tableSet;
- if (importTables.containsKey(importFrom)) {
- tableSet = importTables.get(importFrom);
- } else {
- tableSet = new TreeSet<String>();
- }
- tableSet.add(table.getFullyQualifiedTableName());
- importTables.put(importFrom, tableSet);
- }
- }
- return importTables;
- }
-
- public void addTableDefinition(TableElement table) {
- tableDefinitions.add(table);
- }
-
- @Override
- public String toString() {
- String toReturn = "";
- for (TableElement table : tableDefinitions) {
- toReturn += table.toString();
- }
- return toReturn;
- }
-
- public Document getXmlDocument() throws ParserConfigurationException {
- Document doc = Jaxp.newDocumentNamespaceAware();
- Element root = doc.createElement(ROOT_TAG);
- doc.appendChild(root);
- for (TableElement table : tableDefinitions) {
- root.appendChild(table.toXml(doc));
- }
- return doc;
- }
-
- @Override
- public Element toXml(Document doc) {
- return null;
- }
-
- private void sortTablesForConstraints() {
- this.tableDefinitions = sortTablesForConstraints(this.tableDefinitions);
- }
-
- private boolean canCreate(TableElement table, Set<String> canCreate) {
- Set<String> dependencies = table.getTableDependency();
- if (canCreate.containsAll(dependencies)) {
- return true;
- }
- return false;
- }
-
- private void markIdentityColumns() {
- for (TableElement aTable : tableDefinitions) {
- determineIdentityColumns(aTable);
- }
- }
-
- private void determineIdentityColumns(TableElement tableDef) {
- List<String> primaryKeys = new ArrayList<String>();
-
- // first get all of the vars used for the primary key
- List<ConstraintElement> constraints = tableDef.getConstraints();
- for (ConstraintElement constraint : constraints) {
- if (constraint.getConstraintType().equals(ConstraintTypes.PRIMARY_KEY)) {
- List<String> columns = constraint.getColumns();
- for (String column : columns) {
- primaryKeys.add(column);
- }
- }
- }
-
- // now go through and remove any of the primary key vars that are foreign keys
- List<ForeignKey> foreignKeys = tableDef.getForeignKeyConstraints();
- for (ForeignKey fkConstraint : foreignKeys) {
- List<String> columns = fkConstraint.getColumns();
- for (String column : columns) {
- primaryKeys.remove(column);
- }
- }
-
- // now we should only be left with those primary keys that are identities.
- // we set them by setting their corresponding identity column to true, a little hokey but that
- // way we don't have to create special data structures for the column
- Map<String, ColumnMetadata> columns = tableDef.getColumns();
- Set<String> columnKeys = columns.keySet();
- for (String key : columnKeys) {
- ColumnMetadata column = columns.get(key);
- if (primaryKeys.contains(column.getId())) {
- column.addColumnField(ColumnFields.identity, Boolean.TRUE.toString());
- }
- }
- }
-
- private List<TableElement> sortTablesForConstraints(List<TableElement> tables) {
- List<TableElement> sorted = new ArrayList<TableElement>();
- Set<String> canCreate = new HashSet<String>();
-
- Map<TableElement, Boolean> toSort = new HashMap<TableElement, Boolean>();
-
- for (TableElement aTable : tables) {
- if (aTable.hasForeignKey()) {
- toSort.put(aTable, false);
- } else {
- sorted.add(aTable);
- canCreate.add(aTable.getFullyQualifiedTableName());
- }
- }
-
- // Prevent for endless loops caused by
- // foreign/primary key discrepancies
- int guard = toSort.size() * 2;
- int count = 0;
- while (toSort.containsValue(false) && count < guard) {
- Set<TableElement> elements = toSort.keySet();
-
- for (TableElement aTable : elements) {
-
- if (!toSort.get(aTable)) {
- if (canCreate(aTable, canCreate)) {
- canCreate.add(aTable.getFullyQualifiedTableName());
- sorted.add(aTable);
- toSort.put(aTable, true);
- }
- }
- }
- count++;
- }
-
- // If we were stuck in an endless loop copy all unsortable tables
- // to the end of the sorted array and return
- if (toSort.containsValue(false)) {
- Set<TableElement> elements = toSort.keySet();
- for (TableElement aTable : elements) {
- if (!toSort.get(aTable)) {
- canCreate.add(aTable.getFullyQualifiedTableName());
- sorted.add(aTable);
- toSort.put(aTable, true);
- }
- }
- }
-
- return sorted;
- }
-
- public Map<String, TableElement> getTableMap() {
- Map<String, TableElement> tableMap = new HashMap<String, TableElement>();
- for (TableElement table : tableDefinitions) {
- tableMap.put(table.getFullyQualifiedTableName(), table);
- }
- return tableMap;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + (isSorted ? 1231 : 1237);
- result = prime * result + ((schemaLookup == null) ? 0 : schemaLookup.hashCode());
- result = prime * result + ((tableDefinitions == null) ? 0 : tableDefinitions.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- SchemaData other = (SchemaData) obj;
- if (isSorted != other.isSorted) {
- return false;
- }
- if (schemaLookup == null) {
- if (other.schemaLookup != null) {
- return false;
- }
- } else if (!schemaLookup.equals(other.schemaLookup)) {
- return false;
- }
- if (tableDefinitions == null) {
- if (other.tableDefinitions != null) {
- return false;
- }
- } else if (!tableDefinitions.equals(other.tableDefinitions)) {
- return false;
- }
- return true;
- }
-
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/SchemaDataLookup.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/SchemaDataLookup.java
deleted file mode 100644
index db7681943c..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/SchemaDataLookup.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.data;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Roberto E. Escobar
- */
-public class SchemaDataLookup {
-
- private final SchemaData schemaData;
-
- public SchemaDataLookup(SchemaData schemaData) {
- this.schemaData = schemaData;
- }
-
- public ColumnMetadata getColumnDefinition(TableElement table, String columnId) {
- Map<String, ColumnMetadata> columns = table.getColumns();
- return getColumnDefinition(columns, columnId);
- }
-
- public static ColumnMetadata getColumnDefinition(Map<String, ColumnMetadata> columns, String columnId) {
- if (columns.containsKey(columnId)) {
- return columns.get(columnId);
- }
- return null;
- }
-
- public TableElement getTableDefinition(String tableName) {
- List<TableElement> list = schemaData.getTablesOrderedByDependency();
- for (TableElement table : list) {
- return table;
- }
- return null;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((schemaData == null) ? 0 : schemaData.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- SchemaDataLookup other = (SchemaDataLookup) obj;
- if (schemaData == null) {
- if (other.schemaData != null) {
- return false;
- }
- } else if (!schemaData.equals(other.schemaData)) {
- return false;
- }
- return true;
- }
-
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/SchemaXmlParser.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/SchemaXmlParser.java
deleted file mode 100644
index 48dbab83cf..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/SchemaXmlParser.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.data;
-
-import java.io.BufferedInputStream;
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import org.eclipse.osee.database.schema.SchemaResource;
-import org.eclipse.osee.database.schema.internal.data.AppliesToClause.AppliesToEntries;
-import org.eclipse.osee.database.schema.internal.data.AppliesToClause.OrderType;
-import org.eclipse.osee.database.schema.internal.data.ConstraintElement.ConstraintFields;
-import org.eclipse.osee.database.schema.internal.data.IndexElement.IndexFields;
-import org.eclipse.osee.database.schema.internal.data.ReferenceClause.OnDeleteEnum;
-import org.eclipse.osee.database.schema.internal.data.ReferenceClause.OnUpdateEnum;
-import org.eclipse.osee.database.schema.internal.data.ReferenceClause.ReferencesFields;
-import org.eclipse.osee.database.schema.internal.data.TableElement.ColumnFields;
-import org.eclipse.osee.database.schema.internal.data.TableElement.TableDescriptionFields;
-import org.eclipse.osee.database.schema.internal.data.TableElement.TableSections;
-import org.eclipse.osee.database.schema.internal.data.TableElement.TableTags;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.framework.jdk.core.util.xml.Jaxp;
-import org.eclipse.osee.logger.Log;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-
-/**
- * @author Roberto E. Escobar
- */
-public class SchemaXmlParser {
-
- private final Log logger;
-
- public SchemaXmlParser(Log logger) {
- this.logger = logger;
- }
-
- private void parseTableDescription(Element element, TableElement tableEntry) {
- NamedNodeMap attributes = element.getAttributes();
- for (int i = 0; i < attributes.getLength(); i++) {
- Attr attribute = (Attr) attributes.item(i);
- TableDescriptionFields tableField = TableDescriptionFields.valueOf(attribute.getName());
- tableEntry.addTableDescription(tableField, attribute.getValue());
- }
- }
-
- private void parseColumnEntries(Element element, TableElement tableEntry) {
- List<Element> columns = Jaxp.getChildDirects(element, TableSections.Column.name());
- for (Element column : columns) {
- NamedNodeMap attributes = column.getAttributes();
- ColumnMetadata columnMetadata = new ColumnMetadata("");
- for (int i = 0; i < attributes.getLength(); i++) {
- Attr attribute = (Attr) attributes.item(i);
- ColumnFields columnField = ColumnFields.valueOf(attribute.getName());
- columnMetadata.addColumnField(columnField, attribute.getValue().toUpperCase());
- }
- tableEntry.addColumn(columnMetadata);
- }
- }
-
- private void parseConstraintEntries(Element element, TableElement tableEntry) {
- List<Element> constraints = Jaxp.getChildDirects(element, TableSections.Constraint.name());
- for (Element constraint : constraints) {
- Attr type = constraint.getAttributeNode(ConstraintFields.type.name());
- Attr id = constraint.getAttributeNode(ConstraintFields.id.name());
- String schema = constraint.getAttribute(ConstraintFields.schema.name());
- String deferrable = constraint.getAttribute(ConstraintFields.deferrable.name());
- if (type != null && id != null) {
-
- ConstraintElement constraintElement =
- ConstraintFactory.getConstraint(ConstraintTypes.textToType(type.getValue().toUpperCase()),
- schema.toUpperCase(), id.getValue().toUpperCase(),
- deferrable.equalsIgnoreCase(Boolean.toString(true)));
-
- Attr appliesTo = constraint.getAttributeNode(ConstraintFields.appliesTo.name());
- if (appliesTo != null) {
- String[] columns = appliesTo.getValue().split(",");
- for (String column : columns) {
- constraintElement.addColumn(column.toUpperCase());
- }
- }
-
- if (constraintElement instanceof ForeignKey) {
- Element reference = Jaxp.getChildDirect(constraint, ReferenceClause.REFERENCES_TAG);
- if (reference != null) {
- Attr table = reference.getAttributeNode(ReferencesFields.table.name());
- Attr refColumn = reference.getAttributeNode(ReferencesFields.column.name());
- Attr onUpdate = reference.getAttributeNode(ReferencesFields.onUpdate.name());
- Attr onDelete = reference.getAttributeNode(ReferencesFields.onDelete.name());
- String refSchema = reference.getAttribute(ReferencesFields.schema.name());
-
- if (table != null) {
-
- ReferenceClause references =
- new ReferenceClause(refSchema.toUpperCase(), table.getValue().toUpperCase());
- if (refColumn != null) {
- String[] columns = refColumn.getValue().split(",");
- for (String column : columns) {
- references.addColumn(column.toUpperCase());
- }
- }
- if (onUpdate != null) {
- OnUpdateEnum[] values = OnUpdateEnum.values();
- for (OnUpdateEnum value : values) {
- if (value.toString().equals(onUpdate.getValue().toUpperCase())) {
- references.setOnUpdateAction(value);
- }
- }
- }
- if (onDelete != null) {
- OnDeleteEnum[] values = OnDeleteEnum.values();
- for (OnDeleteEnum value : values) {
- if (value.toString().equals(onDelete.getValue().toUpperCase())) {
- references.setOnDeleteAction(value);
- }
- }
- }
- ((ForeignKey) constraintElement).addReference(references);
- }
- }
- }
- tableEntry.addConstraint(constraintElement);
- }
- }
- }
-
- private void parseIndexDataEntries(Element element, TableElement tableEntry) {
- List<Element> indexDataList = Jaxp.getChildDirects(element, TableSections.Index.name());
- for (Element indexDataEntry : indexDataList) {
- String id = indexDataEntry.getAttribute(IndexFields.id.name());
- String ignore = indexDataEntry.getAttribute(IndexFields.mySqlIgnore.name());
- Attr indexType = indexDataEntry.getAttributeNode(IndexFields.type.name());
- String tablespace = indexDataEntry.getAttribute(IndexFields.tablespace.name());
- if (id.length() > 0) {
- IndexElement indexData = new IndexElement(id);
- if (Boolean.parseBoolean(ignore)) {
- indexData.setMySqlIgnore(true);
- }
- if (indexType != null) {
- indexData.setIndexType(indexType.getValue());
- }
- if (tablespace != null) {
- indexData.setTablespace(tablespace);
- }
- parseAppliesToClause(indexDataEntry, indexData);
- tableEntry.addIndexData(indexData);
- }
- }
- }
-
- private void parseAppliesToClause(Element element, IndexElement indexData) {
- List<Element> appliesToList = Jaxp.getChildDirects(element, AppliesToClause.APPLIES_TO_TAG);
- for (Element appliesToElement : appliesToList) {
- String idString = appliesToElement.getAttribute(AppliesToEntries.id.name());
- String sortString = appliesToElement.getAttribute(AppliesToEntries.sort.name());
- if (idString.length() > 0) {
- OrderType orderType = OrderType.Undefined;
- if (sortString.equalsIgnoreCase("Ascending")) {
- orderType = OrderType.Ascending;
- } else if (sortString.equalsIgnoreCase("Descending")) {
- orderType = OrderType.Descending;
- }
- indexData.addAppliesTo(idString, orderType);
- }
- }
- }
-
- public SchemaData parse(InputStream configFile) throws Exception {
- Document document = Jaxp.readXmlDocument(configFile, "UTF-8");
- SchemaData schemaData = new SchemaData();
- List<Element> elements = Jaxp.getChildDirects(document.getDocumentElement(), TableTags.Table.name());
- for (Element element : elements) {
-
- TableElement tableEntry = new TableElement();
-
- parseTableDescription(element, tableEntry);
- parseColumnEntries(element, tableEntry);
- parseConstraintEntries(element, tableEntry);
- parseIndexDataEntries(element, tableEntry);
-
- schemaData.addTableDefinition(tableEntry);
- }
- return schemaData;
- }
-
- public void parse(Collection<SchemaResource> schemaResources, Map<String, SchemaData> schemas) {
- for (SchemaResource schemaResource : schemaResources) {
- SchemaData schemaData;
- InputStream inputStream = null;
- try {
- inputStream = new BufferedInputStream(schemaResource.getContent());
- schemaData = parse(inputStream);
- List<TableElement> tables = schemaData.getTablesOrderedByDependency();
- for (TableElement table : tables) {
- String schemaAddress = table.getSchema();
-
- SchemaData schema = null;
- if (!schemas.containsKey(schemaAddress)) {
- schema = new SchemaData();
- schemas.put(schemaAddress, schema);
- } else {
- schema = schemas.get(schemaAddress);
- }
- schema.addTableDefinition(table);
- }
- } catch (Exception ex) {
- logger.warn(ex, "Problem parsing [%s]", schemaResource);
- } finally {
- Lib.close(inputStream);
- }
- }
- }
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/TableElement.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/TableElement.java
deleted file mode 100644
index d66c87bd35..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/data/TableElement.java
+++ /dev/null
@@ -1,293 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.data;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-import org.eclipse.osee.framework.jdk.core.persistence.Xmlizable;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * @author Roberto E. Escobar
- */
-public class TableElement implements Xmlizable {
-
- public enum TableTags {
- Table,
- ColumnInfo,
- Row;
- }
-
- public enum TableSections {
- Column,
- Constraint,
- Index;
- };
-
- public enum TableDescriptionFields {
- name,
- schema,
- backupData,
- importData,
- importFrom,
- tablespace;
- };
-
- public enum ColumnFields {
- id,
- type,
- limits,
- identity,
- defaultValue;
- ;
- };
-
- private final Map<TableDescriptionFields, String> tableDescription;
- private final Map<String, ColumnMetadata> columns;
- private final List<ConstraintElement> constraints;
- private final List<ForeignKey> foreignKeys;
- private final List<IndexElement> indices;
-
- public TableElement() {
- this.tableDescription = new HashMap<TableDescriptionFields, String>();
- this.columns = new HashMap<String, ColumnMetadata>();
- this.constraints = new ArrayList<ConstraintElement>();
- this.foreignKeys = new ArrayList<ForeignKey>();
- this.indices = new ArrayList<IndexElement>();
- }
-
- public void addColumn(ColumnMetadata column) {
- this.columns.put(column.getId(), column);
- }
-
- public void addConstraint(ConstraintElement constraint) {
- if (constraint instanceof ForeignKey) {
- foreignKeys.add((ForeignKey) constraint);
- } else {
- constraints.add(constraint);
- }
- }
-
- public void addIndexData(IndexElement indexData) {
- indices.add(indexData);
- }
-
- public String getSchema() {
- return this.tableDescription.get(TableDescriptionFields.schema);
- }
-
- public String getName() {
- return this.tableDescription.get(TableDescriptionFields.name);
- }
-
- public boolean isBackupDataSet() {
- if (this.tableDescription.containsKey(TableDescriptionFields.backupData)) {
- return Boolean.parseBoolean(this.tableDescription.get(TableDescriptionFields.backupData));
- }
- return false;
- }
-
- public boolean isImportDataSet() {
- if (this.tableDescription.containsKey(TableDescriptionFields.importData)) {
- return Boolean.parseBoolean(this.tableDescription.get(TableDescriptionFields.importData));
- }
- return false;
- }
-
- public String getImportFrom() {
- if (this.tableDescription.containsKey(TableDescriptionFields.importFrom)) {
- return this.tableDescription.get(TableDescriptionFields.importFrom);
- }
- return null;
- }
-
- public void addTableDescription(TableDescriptionFields field, String value) {
- if (!field.equals(TableDescriptionFields.importFrom)) {
- value = value.toUpperCase();
- }
- value = value.trim();
- this.tableDescription.put(field, value);
- }
-
- public Map<String, ColumnMetadata> getColumns() {
- return this.columns;
- }
-
- public Map<TableDescriptionFields, String> getDescription() {
- return this.tableDescription;
- }
-
- public boolean hasForeignKey() {
- return foreignKeys.size() > 0;
- }
-
- public String getFullyQualifiedTableName() {
- if (getSchema() == null) {
- return getName();
- } else {
- return getSchema() + "." + getName();
- }
- }
-
- public List<ConstraintElement> getConstraints() {
- return constraints;
- }
-
- public List<ForeignKey> getForeignKeyConstraints() {
- return foreignKeys;
- }
-
- public List<IndexElement> getIndexData() {
- return indices;
- }
-
- @Override
- public String toString() {
- StringBuilder toReturn = new StringBuilder();
- toReturn.append(" Table : \n");
- Set<TableDescriptionFields> keys = tableDescription.keySet();
- for (TableDescriptionFields key : keys) {
- toReturn.append(" \t" + key.toString() + ": " + tableDescription.get(key));
- }
- toReturn.append("\n");
- int count = 0;
- Set<String> columnKeys = columns.keySet();
- for (String key : columnKeys) {
- toReturn.append("\t[" + ++count + "] " + columns.get(key).toString() + "\n");
- }
- count = 0;
- for (ConstraintElement constraint : constraints) {
- toReturn.append("\t[" + ++count + "] " + constraint.toString() + "\n");
- }
- for (ForeignKey fkeys : foreignKeys) {
- toReturn.append("\t[" + ++count + "] " + fkeys.toString() + "\n");
- }
- count = 0;
- for (IndexElement iData : indices) {
- toReturn.append("\t[" + ++count + "] " + iData.toString() + "\n");
- }
- return toReturn.toString();
- }
-
- /**
- * @param doc The XML document we're creating the XML for
- * @return The XML Element corresponding to this
- */
- @Override
- public Element toXml(Document doc) {
- Element tableElement = doc.createElement(TableTags.Table.name());
- for (TableDescriptionFields key : tableDescription.keySet()) {
- tableElement.setAttribute(key.toString(), tableDescription.get(key));
- }
- for (String key : columns.keySet()) {
- tableElement.appendChild(columns.get(key).toXml(doc));
- }
- for (ConstraintElement constraint : constraints) {
- tableElement.appendChild(constraint.toXml(doc));
- }
- for (ForeignKey constraint : foreignKeys) {
- tableElement.appendChild(constraint.toXml(doc));
- }
- for (IndexElement iData : indices) {
- tableElement.appendChild(iData.toXml(doc));
- }
- return tableElement;
- }
-
- public Set<String> getTableDependency() {
- Set<String> dependency = new TreeSet<String>();
- for (ForeignKey fk : foreignKeys) {
- Set<String> refTables = fk.getReferencedTables();
- for (String tableName : refTables) {
- dependency.add(tableName);
- }
- }
- return dependency;
- }
-
- public String getTablespace() {
- String toReturn = getDescription().get(TableDescriptionFields.tablespace);
- return Strings.isValid(toReturn) ? toReturn : "";
- }
-
- public void setTablespace(String value) {
- getDescription().put(TableDescriptionFields.tablespace, value);
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((columns == null) ? 0 : columns.hashCode());
- result = prime * result + ((constraints == null) ? 0 : constraints.hashCode());
- result = prime * result + ((foreignKeys == null) ? 0 : foreignKeys.hashCode());
- result = prime * result + ((indices == null) ? 0 : indices.hashCode());
- result = prime * result + ((tableDescription == null) ? 0 : tableDescription.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- TableElement other = (TableElement) obj;
- if (columns == null) {
- if (other.columns != null) {
- return false;
- }
- } else if (!columns.equals(other.columns)) {
- return false;
- }
- if (constraints == null) {
- if (other.constraints != null) {
- return false;
- }
- } else if (!constraints.equals(other.constraints)) {
- return false;
- }
- if (foreignKeys == null) {
- if (other.foreignKeys != null) {
- return false;
- }
- } else if (!foreignKeys.equals(other.foreignKeys)) {
- return false;
- }
- if (indices == null) {
- if (other.indices != null) {
- return false;
- }
- } else if (!indices.equals(other.indices)) {
- return false;
- }
- if (tableDescription == null) {
- if (other.tableDescription != null) {
- return false;
- }
- } else if (!tableDescription.equals(other.tableDescription)) {
- return false;
- }
- return true;
- }
-
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/FoxProDataType.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/FoxProDataType.java
deleted file mode 100644
index ff77b0cf5c..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/FoxProDataType.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.sql;
-
-/**
- * @author Roberto E. Escobar
- */
-public class FoxProDataType extends SqlDataType {
-
- public FoxProDataType() {
- super();
- }
-
- @Override
- public String getBooleanType() {
- return "number";
- }
-
- @Override
- public String getBitType() {
- return "number";
- }
-
- @Override
- public String getIntegerType() {
- return "integer";
- }
-
- @Override
- public String getDecimalType() {
- return "number";
- }
-
- @Override
- public String getFloatType() {
- return "float";
- }
-
- @Override
- public String getDoubleType() {
- return "number";
- }
-
- @Override
- public String getRealType() {
- return "real";
- }
-
- @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 "number";
- }
-
- @Override
- protected String getLongVarCharType() {
- return "long varchar";
- }
-
- @Override
- protected String getNumericType() {
- return "number";
- }
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/H2DataType.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/H2DataType.java
deleted file mode 100644
index 9ffd2127d6..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/H2DataType.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.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.database.schema/src/org/eclipse/osee/database/schema/internal/sql/H2SqlManager.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/H2SqlManager.java
deleted file mode 100644
index 90767f4ee2..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/H2SqlManager.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.sql;
-
-import org.eclipse.osee.database.schema.internal.data.TableElement;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.logger.Log;
-
-/**
- * @author Roberto E. Escobar
- */
-public class H2SqlManager extends SqlManagerImpl {
-
- public H2SqlManager(Log logger, SqlDataType sqlDataType, IOseeDatabaseService dbService) {
- super(logger, sqlDataType, dbService);
- }
-
- @Override
- public void createSchema(String schema) throws OseeCoreException {
- getDatabaseService().runPreparedUpdate(
- String.format("%s SCHEMA IF NOT EXISTS \"%s\"", CREATE_STRING, schema.toUpperCase()));
- }
-
- @Override
- public void dropSchema(String schema) throws OseeCoreException {
- getDatabaseService().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.database.schema/src/org/eclipse/osee/database/schema/internal/sql/HyperSqlDataType.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/HyperSqlDataType.java
deleted file mode 100644
index 8a84ad870b..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/HyperSqlDataType.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.sql;
-
-/**
- * @author Roberto E. Escobar
- */
-public class HyperSqlDataType extends SqlDataType {
-
- public HyperSqlDataType() {
- 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.database.schema/src/org/eclipse/osee/database/schema/internal/sql/HyperSqlManager.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/HyperSqlManager.java
deleted file mode 100644
index b09224f658..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/HyperSqlManager.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.sql;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import org.eclipse.osee.database.schema.internal.data.AppliesToClause;
-import org.eclipse.osee.database.schema.internal.data.ColumnMetadata;
-import org.eclipse.osee.database.schema.internal.data.ConstraintElement;
-import org.eclipse.osee.database.schema.internal.data.ForeignKey;
-import org.eclipse.osee.database.schema.internal.data.IndexElement;
-import org.eclipse.osee.database.schema.internal.data.ReferenceClause;
-import org.eclipse.osee.database.schema.internal.data.ReferenceClause.OnDeleteEnum;
-import org.eclipse.osee.database.schema.internal.data.ReferenceClause.OnUpdateEnum;
-import org.eclipse.osee.database.schema.internal.data.TableElement;
-import org.eclipse.osee.database.schema.internal.data.TableElement.ColumnFields;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.logger.Log;
-
-/**
- * @author Roberto E. Escobar
- */
-public class HyperSqlManager extends SqlManagerImpl {
-
- public HyperSqlManager(Log logger, SqlDataType sqlDataType, IOseeDatabaseService dbService) {
- super(logger, sqlDataType, dbService);
- }
-
- private String handleColumnCreationSection(Map<String, ColumnMetadata> columns) {
- List<String> lines = new ArrayList<String>();
- for (String key : columns.keySet()) {
- Map<ColumnFields, String> column = columns.get(key).getColumnFields();
- lines.add(columnDataToSQL(column));
- }
- return org.eclipse.osee.framework.jdk.core.util.Collections.toString(",\n", lines);
- }
-
- @Override
- protected String handleConstraintCreationSection(List<? extends ConstraintElement> constraints, String tableId) {
- List<String> constraintStatements = new ArrayList<String>();
- for (ConstraintElement constraint : constraints) {
- constraintStatements.add(constraintDataToSQL(constraint, tableId));
- }
- StringBuilder toExecute = new StringBuilder();
- if (constraintStatements.isEmpty()) {
- toExecute.append("");
- } else {
- toExecute.append(",\n");
- }
- toExecute.append(join(constraintStatements, ",\n"));
- return toExecute.toString();
- }
-
- @Override
- public String constraintDataToSQL(ConstraintElement constraint, String tableID) {
- StringBuilder toReturn = new StringBuilder();
- String id = formatQuotedString(constraint.getId(), "\\.");
- String type = constraint.getConstraintType().toString();
- String appliesTo = formatQuotedString(constraint.getCommaSeparatedColumnsList(), ",");
-
- if (Strings.isValid(id) && Strings.isValid(appliesTo)) {
- toReturn.append("CONSTRAINT ").append(id).append(" ").append(type).append(" (").append(appliesTo).append(")");
-
- if (constraint instanceof ForeignKey) {
- ForeignKey fk = (ForeignKey) constraint;
- List<ReferenceClause> refs = fk.getReferences();
-
- for (ReferenceClause ref : refs) {
- String refTable = formatQuotedString(ref.getFullyQualifiedTableName(), "\\.");
- String refColumns = formatQuotedString(ref.getCommaSeparatedColumnsList(), ",");
-
- String onUpdate = "";
- if (!ref.getOnUpdateAction().equals(OnUpdateEnum.UNSPECIFIED)) {
- onUpdate = "ON UPDATE " + ref.getOnUpdateAction().toString();
- }
-
- String onDelete = "";
- if (!ref.getOnDeleteAction().equals(OnDeleteEnum.UNSPECIFIED)) {
- onDelete = "ON DELETE " + ref.getOnDeleteAction().toString();
- }
-
- if (refTable != null && refColumns != null && !refTable.equals("") && !refColumns.equals("")) {
- toReturn.append(" REFERENCES ").append(refTable).append(" (").append(refColumns).append(")");
- if (!onUpdate.equals("")) {
- toReturn.append(" ").append(onUpdate);
- }
-
- if (!onDelete.equals("")) {
- toReturn.append(" ").append(onDelete);
- }
-
- }
-
- else {
- getLogger().warn("Skipping CONSTRAINT at Table: %s\n\t %s", tableID, fk);
- }
- }
- }
- } else {
- getLogger().warn("Skipping CONSTRAINT at Table: %s\n\t %s", tableID, constraint);
- }
- return toReturn.toString();
- }
-
- @Override
- public void createIndex(TableElement tableDef) throws OseeCoreException {
- List<IndexElement> tableIndices = tableDef.getIndexData();
- String indexId = null;
- StringBuilder appliesTo = new StringBuilder();
- String tableName = formatQuotedString(tableDef.getFullyQualifiedTableName(), "\\.");
- for (IndexElement iData : tableIndices) {
- if (iData.ignoreMySql()) {
- continue;
- }
- indexId = iData.getId();
- appliesTo.delete(0, appliesTo.length());
-
- List<AppliesToClause> appliesToList = iData.getAppliesToList();
- for (int index = 0; index < appliesToList.size(); index++) {
- AppliesToClause record = appliesToList.get(index);
- appliesTo.append(record.getColumnName());
-
- if (index + 1 < appliesToList.size()) {
- appliesTo.append(", ");
- }
- }
- String toExecute = String.format("%s INDEX %s ON %s (%s)", CREATE_STRING, indexId, tableName, appliesTo);
- toExecute = createIndexPostProcess(iData, toExecute);
- getLogger().debug(toExecute);
- getDatabaseService().runPreparedUpdate(toExecute);
- }
- }
-
- @Override
- public void createTable(TableElement tableDef) throws OseeCoreException {
- StringBuilder builder = new StringBuilder();
- builder.append("CREATE TABLE ").append(tableDef.getName()).append(" ( \n");
- builder.append(handleColumnCreationSection(tableDef.getColumns()));
- builder.append(handleConstraintCreationSection(tableDef.getConstraints(), tableDef.getFullyQualifiedTableName()));
- builder.append(handleConstraintCreationSection(tableDef.getForeignKeyConstraints(),
- tableDef.getFullyQualifiedTableName()));
- builder.append(" \n)\n");
- getLogger().debug("Creating Table: [%s]", tableDef.getFullyQualifiedTableName());
- getDatabaseService().runPreparedUpdate(builder.toString());
- }
-
- @Override
- public void dropIndex(TableElement tableDef) {
- // Do Nothing -- Indexes are dropped during table drop
- }
-
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/MySqlDataType.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/MySqlDataType.java
deleted file mode 100644
index acae971408..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/MySqlDataType.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.sql;
-
-/**
- * @author Roberto E. Escobar
- */
-public class MySqlDataType extends SqlDataType {
-
- public MySqlDataType() {
- super();
- }
-
- @Override
- public String getBooleanType() {
- return "boolean";
- }
-
- @Override
- public String getBitType() {
- return "smallint";
- }
-
- @Override
- public String getIntegerType() {
- return "integer";
- }
-
- @Override
- public String getDecimalType() {
- return "decimal";
- }
-
- @Override
- public String getFloatType() {
- return "float";
- }
-
- @Override
- public String getRealType() {
- return "real";
- }
-
- @Override
- public String getDoubleType() {
- return getRealType();
- }
-
- @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 "blob";
- }
-
- @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 "long varchar";
- }
-
- @Override
- protected String getNumericType() {
- return "numeric";
- }
-
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/MysqlSqlManager.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/MysqlSqlManager.java
deleted file mode 100644
index 2f8bc10348..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/MysqlSqlManager.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.sql;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.eclipse.osee.database.schema.internal.data.ColumnMetadata;
-import org.eclipse.osee.database.schema.internal.data.ConstraintElement;
-import org.eclipse.osee.database.schema.internal.data.ForeignKey;
-import org.eclipse.osee.database.schema.internal.data.IndexElement;
-import org.eclipse.osee.database.schema.internal.data.ReferenceClause;
-import org.eclipse.osee.database.schema.internal.data.ReferenceClause.OnDeleteEnum;
-import org.eclipse.osee.database.schema.internal.data.ReferenceClause.OnUpdateEnum;
-import org.eclipse.osee.database.schema.internal.data.TableElement;
-import org.eclipse.osee.database.schema.internal.data.TableElement.ColumnFields;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.database.core.OseeConnection;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.logger.Log;
-
-/**
- * @author Andrew M. Finkbeiner
- */
-public class MysqlSqlManager extends SqlManagerImpl {
-
- public MysqlSqlManager(Log logger, SqlDataType sqlDataType, IOseeDatabaseService dbService) {
- super(logger, sqlDataType, dbService);
- }
-
- private String handleColumnCreationSection(OseeConnection connection, Map<String, ColumnMetadata> columns) {
- List<String> lines = new ArrayList<String>();
- Set<String> keys = columns.keySet();
- for (String key : keys) {
- Map<ColumnFields, String> column = columns.get(key).getColumnFields();
- lines.add(columnDataToSQL(column));
- }
- String toExecute = org.eclipse.osee.framework.jdk.core.util.Collections.toString(",\n", lines);
- return toExecute;
- }
-
- public void createTable(OseeConnection connection, TableElement tableDef) throws OseeCoreException {
- String toExecute = "CREATE TABLE " + tableDef.getFullyQualifiedTableName() + " ( \n";
- toExecute += handleColumnCreationSection(connection, tableDef.getColumns());
- toExecute += handleConstraintCreationSection(tableDef.getConstraints(), tableDef.getFullyQualifiedTableName());
- toExecute +=
- handleConstraintCreationSection(tableDef.getForeignKeyConstraints(), tableDef.getFullyQualifiedTableName());
- toExecute += " \n)\n";
- getLogger().debug("Creating Table: [%s]", tableDef.getFullyQualifiedTableName());
- getDatabaseService().runPreparedUpdate(connection, toExecute);
- }
-
- @Override
- public void dropTable(TableElement tableDef) throws OseeCoreException {
- String toExecute = "DROP TABLE " + formatQuotedString(tableDef.getFullyQualifiedTableName(), "\\.");
- getLogger().debug("Dropping Table: [%s]", tableDef.getFullyQualifiedTableName());
- getDatabaseService().runPreparedUpdate(toExecute);
- }
-
- @Override
- protected String formatQuotedString(String value, String splitAt) {
- String[] array = value.split(splitAt);
- for (int index = 0; index < array.length; index++) {
- array[index] = array[index];
- }
- return join(array, splitAt.replaceAll("\\\\", ""));
- }
-
- @Override
- public void dropIndex(TableElement tableDef) throws OseeCoreException {
- List<IndexElement> tableIndices = tableDef.getIndexData();
- String tableName = tableDef.getFullyQualifiedTableName();
- for (IndexElement iData : tableIndices) {
- if (iData.ignoreMySql()) {
- continue;
- }
- getLogger().debug("Dropping Index: [%s] FROM [%s]", iData.getId(), tableName);
- if (iData.getId().equals("PRIMARY")) {
- getDatabaseService().runPreparedUpdate(
- "ALTER TABLE " + tableDef.getFullyQualifiedTableName() + " DROP PRIMARY KEY");
- } else {
- getDatabaseService().runPreparedUpdate(
- "ALTER TABLE " + tableDef.getFullyQualifiedTableName() + " DROP INDEX " + iData.getId());
- }
- }
- }
-
- @Override
- public String constraintDataToSQL(ConstraintElement constraint, String tableID) {
- StringBuilder toReturn = new StringBuilder();
- String id = formatQuotedString(constraint.getId(), "\\.");
- String type = constraint.getConstraintType().toString();
- String appliesTo = formatQuotedString(constraint.getCommaSeparatedColumnsList(), ",");
-
- if (Strings.isValid(id) && Strings.isValid(appliesTo)) {
- toReturn.append("CONSTRAINT " + id + " " + type + " (" + appliesTo + ")");
-
- if (constraint instanceof ForeignKey) {
- ForeignKey fk = (ForeignKey) constraint;
- List<ReferenceClause> refs = fk.getReferences();
-
- for (ReferenceClause ref : refs) {
- String refTable = formatQuotedString(ref.getFullyQualifiedTableName(), "\\.");
- String refColumns = formatQuotedString(ref.getCommaSeparatedColumnsList(), ",");
-
- String onUpdate = "";
- if (!ref.getOnUpdateAction().equals(OnUpdateEnum.UNSPECIFIED)) {
- onUpdate = "ON UPDATE " + ref.getOnUpdateAction().toString();
- }
-
- String onDelete = "";
- if (!ref.getOnDeleteAction().equals(OnDeleteEnum.UNSPECIFIED)) {
- onDelete = "ON DELETE " + ref.getOnDeleteAction().toString();
- }
-
- if (refTable != null && refColumns != null && !refTable.equals("") && !refColumns.equals("")) {
- toReturn.append(" REFERENCES " + refTable + " (" + refColumns + ")");
- if (!onUpdate.equals("")) {
- toReturn.append(" " + onUpdate);
- }
-
- if (!onDelete.equals("")) {
- toReturn.append(" " + onDelete);
- }
-
- // if (constraint.isDeferrable()) {
- // toReturn.append(" DEFERRABLE");
- // }
- }
-
- else {
- getLogger().warn("Skipping CONSTRAINT at Table: %s\n\t%s", tableID, fk.toString());
- }
-
- }
- }
- } else {
- getLogger().warn("Skipping CONSTRAINT at Table: %s\n\t%s", tableID, constraint.toString());
- }
- return toReturn.toString();
- }
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/OracleSqlDataType.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/OracleSqlDataType.java
deleted file mode 100644
index 1cc4024ab4..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/OracleSqlDataType.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.sql;
-
-import org.eclipse.osee.framework.database.core.SQL3DataType;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-
-/**
- * @author Roberto E. Escobar
- */
-public class OracleSqlDataType extends SqlDataType {
-
- public OracleSqlDataType() {
- super();
- }
-
- @Override
- public String getLimit(SQL3DataType dataType, String limit) {
- if (dataType == SQL3DataType.VARCHAR && Strings.isValid(limit)) {
- return limit + " CHAR";
- } else {
- return super.getLimit(dataType, limit);
- }
- }
-
- @Override
- public String getBooleanType() {
- return "number";
- }
-
- @Override
- public String getBitType() {
- return "number";
- }
-
- @Override
- public String getIntegerType() {
- return "integer";
- }
-
- @Override
- public String getDecimalType() {
- return "number";
- }
-
- @Override
- public String getFloatType() {
- return "float";
- }
-
- @Override
- public String getRealType() {
- return "real";
- }
-
- @Override
- public String getDoubleType() {
- return "number";
- }
-
- @Override
- public String getDateType() {
- return "date";
- }
-
- @Override
- public String getCharType() {
- return "char";
- }
-
- @Override
- public String getVarCharType() {
- return "varchar2";
- }
-
- @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 "number";
- }
-
- @Override
- protected String getLongVarCharType() {
- return "varchar2";
- }
-
- @Override
- protected String getNumericType() {
- return "number";
- }
-
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/OracleSqlManager.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/OracleSqlManager.java
deleted file mode 100644
index 56457a2200..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/OracleSqlManager.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.sql;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.eclipse.osee.database.schema.internal.data.ColumnMetadata;
-import org.eclipse.osee.database.schema.internal.data.IndexElement;
-import org.eclipse.osee.database.schema.internal.data.TableElement;
-import org.eclipse.osee.database.schema.internal.data.TableElement.ColumnFields;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.logger.Log;
-
-/**
- * @author Roberto E. Escobar
- */
-public class OracleSqlManager extends SqlManager {
-
- public OracleSqlManager(Log logger, SqlDataType sqlDataType, IOseeDatabaseService dbService) {
- super(logger, sqlDataType, dbService);
- }
-
- protected String handleColumnCreationSection(Map<String, ColumnMetadata> columns) {
- List<String> lines = new ArrayList<String>();
- Set<String> keys = columns.keySet();
- for (String key : keys) {
- Map<ColumnFields, String> column = columns.get(key).getColumnFields();
- lines.add(columnDataToSQL(column));
- }
- String toExecute = org.eclipse.osee.framework.jdk.core.util.Collections.toString(",\n", lines);
- return toExecute;
- }
-
- @Override
- public void createTable(TableElement tableDef) throws OseeCoreException {
- StringBuilder toExecute = new StringBuilder();
- toExecute.append(SqlManager.CREATE_STRING + " TABLE " + formatQuotedString(tableDef.getFullyQualifiedTableName(),
- "\\.") + " ( \n");
- toExecute.append(handleColumnCreationSection(tableDef.getColumns()));
- toExecute.append(handleConstraintCreationSection(tableDef.getConstraints(), tableDef.getFullyQualifiedTableName()));
- toExecute.append(handleConstraintCreationSection(tableDef.getForeignKeyConstraints(),
- tableDef.getFullyQualifiedTableName()));
- toExecute.append(" \n)");
- toExecute.append(" tablespace ");
- toExecute.append(tableDef.getTablespace());
- toExecute.append("\n");
- getLogger().debug("Creating Table: [%s]", tableDef.getFullyQualifiedTableName());
- getDatabaseService().runPreparedUpdate(toExecute.toString());
- }
-
- @Override
- protected String createIndexPostProcess(IndexElement indexElement, String original) {
- StringBuilder buffer = new StringBuilder(original);
- buffer.append(" tablespace ");
- buffer.append(indexElement.getTablespace());
- return buffer.toString();
- }
-
- @Override
- public void dropTable(TableElement tableDef) throws OseeCoreException {
- StringBuilder toExecute = new StringBuilder();
- toExecute.append(SqlManager.DROP_STRING + " TABLE " + formatQuotedString(tableDef.getFullyQualifiedTableName(),
- "\\.") + " cascade constraints purge");
- getLogger().debug("Dropping Table: [%s]", tableDef.getFullyQualifiedTableName());
- getDatabaseService().runPreparedUpdate(toExecute.toString());
- }
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/PostgreSqlManager.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/PostgreSqlManager.java
deleted file mode 100644
index da2b8f0ffc..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/PostgreSqlManager.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.sql;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.eclipse.osee.database.schema.internal.data.AppliesToClause;
-import org.eclipse.osee.database.schema.internal.data.ColumnMetadata;
-import org.eclipse.osee.database.schema.internal.data.ConstraintElement;
-import org.eclipse.osee.database.schema.internal.data.ForeignKey;
-import org.eclipse.osee.database.schema.internal.data.IndexElement;
-import org.eclipse.osee.database.schema.internal.data.ReferenceClause;
-import org.eclipse.osee.database.schema.internal.data.ReferenceClause.OnDeleteEnum;
-import org.eclipse.osee.database.schema.internal.data.ReferenceClause.OnUpdateEnum;
-import org.eclipse.osee.database.schema.internal.data.TableElement;
-import org.eclipse.osee.database.schema.internal.data.TableElement.ColumnFields;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.database.core.OseeConnection;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.logger.Log;
-
-/**
- * @author Andrew M. Finkbeiner
- */
-public class PostgreSqlManager extends SqlManagerImpl {
-
- public PostgreSqlManager(Log logger, SqlDataType sqlDataType, IOseeDatabaseService dbService) {
- super(logger, sqlDataType, dbService);
- }
-
- private String handleColumnCreationSection(OseeConnection connection, Map<String, ColumnMetadata> columns) {
- List<String> lines = new ArrayList<String>();
- Set<String> keys = columns.keySet();
- for (String key : keys) {
- Map<ColumnFields, String> column = columns.get(key).getColumnFields();
- lines.add(columnDataToSQL(column));
- }
- String toExecute = org.eclipse.osee.framework.jdk.core.util.Collections.toString(",\n", lines);
- return toExecute;
- }
-
- public void createTable(OseeConnection connection, TableElement tableDef) throws OseeCoreException {
- String toExecute = "CREATE TABLE " + tableDef.getFullyQualifiedTableName() + " ( \n";
- toExecute += handleColumnCreationSection(connection, tableDef.getColumns());
- toExecute += handleConstraintCreationSection(tableDef.getConstraints(), tableDef.getFullyQualifiedTableName());
- toExecute +=
- handleConstraintCreationSection(tableDef.getForeignKeyConstraints(), tableDef.getFullyQualifiedTableName());
- toExecute += " \n)\n";
- getLogger().debug("Creating Table: [%s]", tableDef.getFullyQualifiedTableName());
- getDatabaseService().runPreparedUpdate(connection, toExecute);
- }
-
- @Override
- public void dropTable(TableElement tableDef) throws OseeCoreException {
- String toExecute = "DROP TABLE " + formatQuotedString(tableDef.getFullyQualifiedTableName(), "\\.") + " CASCADE";
- getLogger().debug("Dropping Table: [%s]", tableDef.getFullyQualifiedTableName());
- getDatabaseService().runPreparedUpdate(toExecute);
- }
-
- @Override
- protected String formatQuotedString(String value, String splitAt) {
- String[] array = value.split(splitAt);
- for (int index = 0; index < array.length; index++) {
- array[index] = array[index];
- }
- return join(array, splitAt.replaceAll("\\\\", ""));
- }
-
- public void dropIndex(OseeConnection connection, TableElement tableDef) throws OseeCoreException {
- List<IndexElement> tableIndices = tableDef.getIndexData();
- String tableName = tableDef.getFullyQualifiedTableName();
- for (IndexElement iData : tableIndices) {
- if (iData.ignoreMySql()) {
- continue;
- }
- getLogger().debug("Dropping Index: [%s] FROM [%s]\n", iData.getId(), tableName);
- if (iData.getId().equals("PRIMARY")) {
- getDatabaseService().runPreparedUpdate(connection,
- "ALTER TABLE " + tableDef.getFullyQualifiedTableName() + " DROP PRIMARY KEY");
- } else {
- getDatabaseService().runPreparedUpdate(connection,
- "ALTER TABLE " + tableDef.getFullyQualifiedTableName() + " DROP INDEX " + iData.getId());
- }
- }
- }
-
- @Override
- public String constraintDataToSQL(ConstraintElement constraint, String tableID) {
- StringBuilder toReturn = new StringBuilder();
- String id = formatQuotedString(constraint.getId(), "\\.");
- String type = constraint.getConstraintType().toString();
- String appliesTo = formatQuotedString(constraint.getCommaSeparatedColumnsList(), ",");
-
- if (Strings.isValid(id) && Strings.isValid(appliesTo)) {
- toReturn.append("CONSTRAINT " + id + " " + type + " (" + appliesTo + ")");
-
- if (constraint instanceof ForeignKey) {
- ForeignKey fk = (ForeignKey) constraint;
- List<ReferenceClause> refs = fk.getReferences();
-
- for (ReferenceClause ref : refs) {
- String refTable = formatQuotedString(ref.getFullyQualifiedTableName(), "\\.");
- String refColumns = formatQuotedString(ref.getCommaSeparatedColumnsList(), ",");
-
- String onUpdate = "";
- if (!ref.getOnUpdateAction().equals(OnUpdateEnum.UNSPECIFIED)) {
- onUpdate = "ON UPDATE " + ref.getOnUpdateAction().toString();
- }
-
- String onDelete = "";
- if (!ref.getOnDeleteAction().equals(OnDeleteEnum.UNSPECIFIED)) {
- onDelete = "ON DELETE " + ref.getOnDeleteAction().toString();
- }
-
- if (refTable != null && refColumns != null && !refTable.equals("") && !refColumns.equals("")) {
- toReturn.append(" REFERENCES " + refTable + " (" + refColumns + ")");
- if (!onUpdate.equals("")) {
- toReturn.append(" " + onUpdate);
- }
-
- if (!onDelete.equals("")) {
- toReturn.append(" " + onDelete);
- }
-
- if (constraint.isDeferrable()) {
- toReturn.append(" DEFERRABLE");
- }
- }
-
- else {
- getLogger().warn("Skipping CONSTRAINT at Table: %s\n\t%s", tableID, fk.toString());
- }
-
- }
- }
- } else {
- getLogger().warn("Skipping CONSTRAINT at Table: %s\n\t%s", tableID, constraint.toString());
- }
- return toReturn.toString();
- }
-
- public void createIndex(OseeConnection connection, TableElement tableDef) throws OseeCoreException {
- List<IndexElement> tableIndices = tableDef.getIndexData();
- String indexId = null;
- StringBuilder appliesTo = new StringBuilder();
- String tableName = formatQuotedString(tableDef.getFullyQualifiedTableName(), "\\.");
- for (IndexElement iData : tableIndices) {
- if (iData.ignoreMySql()) {
- continue;
- }
- indexId = iData.getId();
- appliesTo.delete(0, appliesTo.length());
-
- List<AppliesToClause> appliesToList = iData.getAppliesToList();
- for (int index = 0; index < appliesToList.size(); index++) {
- AppliesToClause record = appliesToList.get(index);
- appliesTo.append(record.getColumnName());
-
- // switch (record.getOrderType()) {
- // case Ascending:
- // appliesTo.append(" ASC");
- // break;
- // case Descending:
- // appliesTo.append(" DESC");
- // break;
- // default:
- // break;
- // }
- if (index + 1 < appliesToList.size()) {
- appliesTo.append(", ");
- }
- }
- String toExecute =
- String.format("%s %s INDEX %s ON %s (%s)", CREATE_STRING, iData.getIndexType(), indexId, tableName,
- appliesTo);
- getLogger().debug(toExecute);
- getDatabaseService().runPreparedUpdate(connection, toExecute);
- }
- }
-
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/PostgresqlDataType.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/PostgresqlDataType.java
deleted file mode 100644
index 7c760e4e1f..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/PostgresqlDataType.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.sql;
-
-/**
- * @author Roberto E. Escobar
- */
-public class PostgresqlDataType extends SqlDataType {
-
- public PostgresqlDataType() {
- super();
- }
-
- @Override
- public String getBooleanType() {
- return "bool";
- }
-
- @Override
- public String getBitType() {
- return "number";
- }
-
- @Override
- public String getIntegerType() {
- return "integer";
- }
-
- @Override
- public String getDecimalType() {
- return "decimal";
- }
-
- @Override
- public String getFloatType() {
- return "float";
- }
-
- @Override
- public String getRealType() {
- return "float8";
- }
-
- @Override
- public String getDoubleType() {
- return "numeric";
- }
-
- @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 "text";
- }
-
- @Override
- protected String getTimestamp() {
- return "timestamp";
- }
-
- @Override
- protected String getTime() {
- return "time";
- }
-
- @Override
- protected String getBlobType() {
- return "bytea";
- }
-
- @Override
- protected String getBigInt() {
- return "numeric";
- }
-
- @Override
- protected String getLongVarCharType() {
- return "varchar";
- }
-
- @Override
- protected String getNumericType() {
- return "numeric";
- }
-
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/SchemaSqlUtil.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/SchemaSqlUtil.java
deleted file mode 100644
index 1bd1205498..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/SchemaSqlUtil.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.sql;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.eclipse.osee.database.schema.internal.data.SchemaData;
-import org.eclipse.osee.database.schema.internal.data.TableElement;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-
-public class SchemaSqlUtil {
- private final SqlManager sqlManager;
-
- public SchemaSqlUtil(SqlManager sqlManager) {
- this.sqlManager = sqlManager;
- }
-
- public void addIndices(Set<String> schemas, Map<String, SchemaData> userSpecifiedConfig) throws OseeCoreException {
- for (String schemaId : schemas) {
- if (userSpecifiedConfig.containsKey(schemaId)) {
- SchemaData schemaData = userSpecifiedConfig.get(schemaId);
-
- for (TableElement tableDef : schemaData.getTableMap().values()) {
- sqlManager.createIndex(tableDef);
- }
- }
- }
- }
-
- public void addTables(Set<String> schemas, Map<String, SchemaData> userSpecifiedConfig) throws OseeCoreException {
- for (String schemaId : schemas) {
- if (userSpecifiedConfig.containsKey(schemaId)) {
- SchemaData schemaData = userSpecifiedConfig.get(schemaId);
-
- List<TableElement> tableDefs = schemaData.getTablesOrderedByDependency();
- for (TableElement tableDef : tableDefs) {
- sqlManager.createTable(tableDef);
- }
- }
- }
- }
-
- public void dropTables(Set<String> schemas, Map<String, SchemaData> userSpecifiedConfig, Map<String, SchemaData> currentDatabaseConfig) throws OseeCoreException {
- for (String schemaId : schemas) {
- if (currentDatabaseConfig.containsKey(schemaId)) {
- SchemaData currentDbSchemaData = currentDatabaseConfig.get(schemaId);
- SchemaData userSchema = userSpecifiedConfig.get(schemaId);
- Map<String, TableElement> currentDBmap = currentDbSchemaData.getTableMap();
- Map<String, TableElement> userDbMap = userSchema.getTableMap();
- Set<String> currentDbKeys = currentDBmap.keySet();
- Set<String> userDbKeys = userDbMap.keySet();
-
- SchemaData toDrop = new SchemaData();
- for (String userKey : userDbKeys) {
- if (currentDbKeys.contains(userKey)) {
- toDrop.addTableDefinition(currentDBmap.get(userKey));
- }
- }
-
- List<TableElement> tableDefs = toDrop.getTablesOrderedByDependency();
- for (int index = tableDefs.size() - 1; index >= 0; index--) {
- TableElement tableDef = tableDefs.get(index);
- sqlManager.dropTable(tableDef);
- }
- }
- }
- }
-
- public void dropIndices(Set<String> schemas, Map<String, SchemaData> userSpecifiedConfig, Map<String, SchemaData> currentDatabaseConfig) throws OseeCoreException {
- for (String schemaId : schemas) {
- if (currentDatabaseConfig.containsKey(schemaId)) {
- SchemaData currentDbSchemaData = currentDatabaseConfig.get(schemaId);
- SchemaData userSchema = userSpecifiedConfig.get(schemaId);
- Map<String, TableElement> currentDBmap = currentDbSchemaData.getTableMap();
- Map<String, TableElement> userDbMap = userSchema.getTableMap();
- Set<String> currentDbKeys = currentDBmap.keySet();
- Set<String> userDbKeys = userDbMap.keySet();
-
- SchemaData toDrop = new SchemaData();
- for (String userKey : userDbKeys) {
- if (currentDbKeys.contains(userKey)) {
- toDrop.addTableDefinition(currentDBmap.get(userKey));
- }
- }
-
- for (TableElement tableDef : toDrop.getTableMap().values()) {
- sqlManager.dropIndex(tableDef);
- }
- }
- }
- }
-
- public void createSchema(Set<String> schemas) throws OseeCoreException {
- for (String schemaId : schemas) {
- sqlManager.createSchema(schemaId.toLowerCase());
- }
- }
-
- public void dropSchema(Set<String> schemas) throws OseeCoreException {
- for (String schemaId : schemas) {
- sqlManager.dropSchema(schemaId.toLowerCase());
- }
- }
-
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/SqlDataType.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/SqlDataType.java
deleted file mode 100644
index 1ebf271050..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/SqlDataType.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.sql;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.eclipse.osee.framework.database.core.SQL3DataType;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-
-/**
- * @author Roberto E. Escobar
- */
-public abstract class SqlDataType {
-
- public SqlDataType() {
- super();
- }
-
- protected abstract String getBooleanType();
-
- protected abstract String getBitType();
-
- protected abstract String getSmallIntType();
-
- protected abstract String getIntegerType();
-
- protected abstract String getDecimalType();
-
- protected abstract String getFloatType();
-
- protected abstract String getDoubleType();
-
- protected abstract String getRealType();
-
- protected abstract String getDateType();
-
- protected abstract String getCharType();
-
- protected abstract String getVarCharType();
-
- protected abstract String getClobType();
-
- protected abstract String getBlobType();
-
- protected abstract String getTimestamp();
-
- protected abstract String getTime();
-
- protected abstract String getBigInt();
-
- protected abstract String getLongVarCharType();
-
- protected abstract String getNumericType();
-
- public String getLimit(SQL3DataType dataType, String limit) {
- return limit;
- }
-
- public String getType(SQL3DataType dataType) {
- String toReturn = "";
-
- switch (dataType) {
- case BOOLEAN:
- toReturn = this.getBooleanType();
- break;
- case BIT:
- toReturn = this.getBitType();
- break;
- case SMALLINT:
- toReturn = this.getSmallIntType();
- break;
- case INTEGER:
- toReturn = this.getIntegerType();
- break;
- case REAL:
- toReturn = this.getRealType();
- break;
- case DECIMAL:
- toReturn = this.getDecimalType();
- break;
- case FLOAT:
- toReturn = this.getFloatType();
- break;
- case DOUBLE:
- toReturn = this.getDoubleType();
- break;
- case DATE:
- toReturn = this.getDateType();
- break;
- case CHAR:
- toReturn = this.getCharType();
- break;
- case VARCHAR:
- toReturn = this.getVarCharType();
- break;
- case CLOB:
- toReturn = this.getClobType();
- break;
- case TIMESTAMP:
- toReturn = this.getTimestamp();
- break;
- case TIME:
- toReturn = this.getTime();
- break;
- case BLOB:
- toReturn = this.getBlobType();
- break;
- case BIGINT:
- toReturn = this.getBigInt();
- break;
- case LONGVARCHAR:
- toReturn = this.getLongVarCharType();
- break;
- case NUMERIC:
- toReturn = this.getNumericType();
- break;
- default:
- toReturn = "ADDTHISTYPE:" + dataType.name();
- break;
- }
- return toReturn;
- }
-
- public String formatDataValueforDataType(String columnValue, SQL3DataType columnType) {
- String toReturn = "";
- switch (columnType) {
- case BIGINT:
- case BIT:
- case BOOLEAN:
- case DECIMAL:
- case DOUBLE:
- case FLOAT:
- case INTEGER:
- case REAL:
- case NUMERIC:
- case SMALLINT:
- case TINYINT:
- toReturn = Strings.isValid(columnValue) ? columnValue : "0";
- break;
- case DATE:
- toReturn = "{d '" + formatDate(columnValue) + "'}";
- break;
- case TIMESTAMP:
- toReturn = "{ts '" + formatDate(columnValue) + "'}";
- break;
- case TIME:
- toReturn = "{t '" + columnValue + "'}";
- break;
- default:
- toReturn = "'" + columnValue + "'";
- break;
- }
- return toReturn;
- }
-
- private String formatDate(String input) {
- String[] sets = input.split(" ");
- String date = sets[0];
- String time = "";
- if (sets.length > 1) {
- time += " ";
- for (int i = 1; i < sets.length; i++) {
- time += sets[i];
- }
- }
- if (!date.contains("/") && !date.contains("-") && !date.contains(":")) {
- Pattern pattern = Pattern.compile("([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])");
- Matcher matcher = pattern.matcher(date);
-
- if (matcher.find()) {
- if (matcher.groupCount() == 3) {
- String year = matcher.group(1);
- String month = matcher.group(2);
- String day = matcher.group(3);
-
- date = year + "-" + month + "-" + day;
- }
- }
- } else {
- date = date.replaceAll("/", "-");
- date = date.replaceAll(":", "-");
- }
- return date + time;
- }
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/SqlFactory.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/SqlFactory.java
deleted file mode 100644
index 831e9a92f6..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/SqlFactory.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.sql;
-
-import java.sql.DatabaseMetaData;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.database.core.SupportedDatabase;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.logger.Log;
-
-/**
- * @author Roberto E. Escobar
- */
-public class SqlFactory {
-
- private SqlFactory() {
- super();
- }
-
- public static SqlManager getSqlManager(Log logger, IOseeDatabaseService dbService, DatabaseMetaData metaData) throws OseeCoreException {
- SupportedDatabase db = SupportedDatabase.getDatabaseType(metaData);
- return getSqlManager(logger, dbService, db);
- }
-
- private static SqlManager getSqlManager(Log logger, IOseeDatabaseService dbService, SupportedDatabase db) throws OseeCoreException {
- SqlManager instance = null;
- switch (db) {
- case oracle:
- instance = new OracleSqlManager(logger, new OracleSqlDataType(), dbService);
- break;
- case foxpro:
- instance = new SqlManagerImpl(logger, new FoxProDataType(), dbService);
- break;
- case mysql:
- instance = new MysqlSqlManager(logger, new MySqlDataType(), dbService);
- break;
- case postgresql:
- instance = new PostgreSqlManager(logger, new PostgresqlDataType(), dbService);
- break;
- case h2:
- instance = new H2SqlManager(logger, new H2DataType(), dbService);
- break;
- case hsql:
- instance = new HyperSqlManager(logger, new HyperSqlDataType(), dbService);
- break;
- default:
- throw new OseeDataStoreException("Unsupported database type [%s] ", db);
- }
- return instance;
- }
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/SqlManager.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/SqlManager.java
deleted file mode 100644
index 3ef840b0eb..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/SqlManager.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.sql;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.math.BigDecimal;
-import java.sql.Date;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import org.eclipse.osee.database.schema.internal.data.AppliesToClause;
-import org.eclipse.osee.database.schema.internal.data.ColumnDbData;
-import org.eclipse.osee.database.schema.internal.data.ColumnMetadata;
-import org.eclipse.osee.database.schema.internal.data.ConstraintElement;
-import org.eclipse.osee.database.schema.internal.data.ForeignKey;
-import org.eclipse.osee.database.schema.internal.data.IndexElement;
-import org.eclipse.osee.database.schema.internal.data.ReferenceClause;
-import org.eclipse.osee.database.schema.internal.data.ReferenceClause.OnDeleteEnum;
-import org.eclipse.osee.database.schema.internal.data.ReferenceClause.OnUpdateEnum;
-import org.eclipse.osee.database.schema.internal.data.SchemaDataLookup;
-import org.eclipse.osee.database.schema.internal.data.TableElement;
-import org.eclipse.osee.database.schema.internal.data.TableElement.ColumnFields;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.database.core.SQL3DataType;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.Collections;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.framework.jdk.core.util.time.GlobalTime;
-import org.eclipse.osee.logger.Log;
-
-/**
- * @author Roberto E. Escobar
- */
-public abstract class SqlManager {
-
- private final Log logger;
- protected SqlDataType sqlDataType;
- private final IOseeDatabaseService dbService;
-
- public static final String CREATE_STRING = "CREATE";
- public static final String DROP_STRING = "DROP";
-
- protected SqlManager(Log logger, SqlDataType sqlDataType, IOseeDatabaseService dbService) {
- this.logger = logger;
- this.sqlDataType = sqlDataType;
- this.dbService = dbService;
- }
-
- protected IOseeDatabaseService getDatabaseService() {
- return dbService;
- }
-
- protected Log getLogger() {
- return logger;
- }
-
- protected String join(String[] data, String separator) {
- return Collections.toString(separator, (Object[]) data);
- }
-
- protected String join(List<String> data, String separator) {
- return Collections.toString(separator, data);
- }
-
- public abstract void createTable(TableElement tableDef) throws OseeCoreException;
-
- public abstract void dropTable(TableElement tableDef) throws OseeCoreException;
-
- public void insertData(List<ColumnDbData> rowData, TableElement tableMetadata) throws OseeCoreException {
- List<String> columnNames = new ArrayList<String>();
- List<String> placeHolders = new ArrayList<String>();
- List<String> columnValues = new ArrayList<String>();
- List<SQL3DataType> columnTypes = new ArrayList<SQL3DataType>();
-
- for (ColumnDbData dbData : rowData) {
- String columnId = dbData.getColumnName();
- String columnValue = dbData.getColumnValue();
-
- ColumnMetadata columnMetadata = SchemaDataLookup.getColumnDefinition(tableMetadata.getColumns(), columnId);
- SQL3DataType type = SQL3DataType.valueOf(columnMetadata.getColumnField(ColumnFields.type));
-
- columnNames.add("\"" + columnId + "\"");
- placeHolders.add("?");
- columnValues.add(columnValue);
- columnTypes.add(type);
- }
-
- String toExecute =
- "INSERT INTO " + formatQuotedString(tableMetadata.getFullyQualifiedTableName(), "\\.") + " (\n";
- toExecute += join(columnNames, ",");
- toExecute += "\n) VALUES (\n";
- toExecute += join(placeHolders, ",");
- toExecute += ")\n";
-
- Object[] data = new Object[columnNames.size()];
- for (int index = 0; index < columnNames.size(); index++) {
- data[index] = preparedStatementHelper(columnTypes.get(index), columnValues.get(index));
- }
- dbService.runPreparedUpdate(toExecute, data);
- }
-
- public Object preparedStatementHelper(SQL3DataType columnType, String value) throws OseeDataStoreException {
- switch (columnType) {
- case BINARY:
- case BIT:
- return Strings.isValid(value) ? Byte.parseByte(value) : 0;
- case TINYINT:
- case SMALLINT:
- return Strings.isValid(value) ? Short.valueOf(value) : 0;
- case INTEGER:
- return Strings.isValid(value) ? Integer.valueOf(value) : 0;
- case BIGINT:
- return Strings.isValid(value) ? BigDecimal.valueOf(Double.valueOf(value)) : new BigDecimal(0);
- case FLOAT:
- return Strings.isValid(value) ? Float.valueOf(value) : 0.0f;
- case NUMERIC:
- case DECIMAL:
- case REAL:
- case DOUBLE:
- return Strings.isValid(value) ? Double.valueOf(value) : 0.0;
- case CHAR:
- case VARCHAR:
- case LONGVARCHAR:
- return value;
- case DATE:
- return !Strings.isValid(value) ? SQL3DataType.DATE : Date.valueOf(value);
- case TIMESTAMP:
- return Strings.isValid(value) ? Timestamp.valueOf(value) : GlobalTime.GreenwichMeanTimestamp();
- case TIME:
- return !Strings.isValid(value) ? SQL3DataType.TIME : Time.valueOf(value);
- case VARBINARY:
- case LONGVARBINARY:
- return value.getBytes();
- case BLOB:
- return new BufferedInputStream(new ByteArrayInputStream(value.getBytes()));
- case CLOB:
- return new BufferedInputStream(new ByteArrayInputStream(value.getBytes()));
- case BOOLEAN:
- return !Strings.isValid(value) ? false : Boolean.parseBoolean(value);
- default:
- throw new OseeDataStoreException("unexpected column type [%s]", columnType);
- }
- }
-
- public String getType(SQL3DataType dataType) {
- return sqlDataType.getType(dataType);
- }
-
- public String columnDataToSQL(Map<ColumnFields, String> column) {
- StringBuilder toReturn = new StringBuilder();
-
- String columnLimits = column.get(ColumnFields.limits);
- String defaultValue = column.get(ColumnFields.defaultValue);
-
- SQL3DataType dataType = SQL3DataType.valueOf(column.get(ColumnFields.type));
- columnLimits = sqlDataType.getLimit(dataType, columnLimits);
- toReturn.append(column.get(ColumnFields.id));
- toReturn.append(" ");
- toReturn.append(sqlDataType.getType(dataType));
-
- if (Strings.isValid(columnLimits)) {
- toReturn.append(" (" + columnLimits + ")");
- }
- if (Strings.isValid(defaultValue)) {
- toReturn.append(" " + defaultValue);
- }
- return toReturn.toString();
- }
-
- protected String handleConstraintCreationSection(List<? extends ConstraintElement> constraints, String tableId) {
- List<String> constraintStatements = new ArrayList<String>();
- for (ConstraintElement constraint : constraints) {
- constraintStatements.add(constraintDataToSQL(constraint, tableId));
- }
- StringBuilder toExecute = new StringBuilder();
- toExecute.append((constraintStatements.size() != 0 ? ",\n" : ""));
- toExecute.append(join(constraintStatements, ",\n"));
- return toExecute.toString();
- }
-
- protected String formatQuotedString(String value, String splitAt) {
- String[] array = value.split(splitAt);
- for (int index = 0; index < array.length; index++) {
- array[index] = "\"" + array[index] + "\"";
- }
- String separator = splitAt.replaceAll("\\\\", "");
- return join(array, separator);
- }
-
- public String constraintDataToSQL(ConstraintElement constraint, String tableID) {
- StringBuilder toReturn = new StringBuilder();
- String id = formatQuotedString(constraint.getId(), "\\.");
- String type = constraint.getConstraintType().toString();
- String appliesTo = formatQuotedString(constraint.getCommaSeparatedColumnsList(), ",");
-
- if (Strings.isValid(id) && Strings.isValid(appliesTo)) {
- toReturn.append("CONSTRAINT " + id + " " + type + " (" + appliesTo + ")");
-
- if (constraint instanceof ForeignKey) {
- ForeignKey fk = (ForeignKey) constraint;
- List<ReferenceClause> refs = fk.getReferences();
-
- for (ReferenceClause ref : refs) {
- String refTable = formatQuotedString(ref.getFullyQualifiedTableName(), "\\.");
- String refColumns = formatQuotedString(ref.getCommaSeparatedColumnsList(), ",");
-
- String onUpdate = "";
- if (!ref.getOnUpdateAction().equals(OnUpdateEnum.UNSPECIFIED)) {
- onUpdate = "ON UPDATE " + ref.getOnUpdateAction().toString();
- }
-
- String onDelete = "";
- if (!ref.getOnDeleteAction().equals(OnDeleteEnum.UNSPECIFIED)) {
- onDelete = "ON DELETE " + ref.getOnDeleteAction().toString();
- }
-
- if (refTable != null && refColumns != null && !refTable.equals("") && !refColumns.equals("")) {
- toReturn.append(" REFERENCES " + refTable + " (" + refColumns + ")");
- if (!onUpdate.equals("")) {
- toReturn.append(" " + onUpdate);
- }
-
- if (!onDelete.equals("")) {
- toReturn.append(" " + onDelete);
- }
-
- if (constraint.isDeferrable()) {
- toReturn.append(" DEFERRABLE");
- }
- }
-
- else {
- getLogger().warn("Skipping CONSTRAINT at Table: %s\n\t %s", tableID, fk);
- }
- }
- }
- } else {
- getLogger().warn("Skipping CONSTRAINT at Table: %s\n\t %s", tableID, constraint);
- }
- return toReturn.toString();
- }
-
- public void createSchema(String schema) throws OseeCoreException {
- dbService.runPreparedUpdate(CREATE_STRING + " SCHEMA \"" + schema + "\"");
- }
-
- public void dropSchema(String schema) throws OseeCoreException {
- dbService.runPreparedUpdate(DROP_STRING + " SCHEMA \"" + schema + "\" CASCADE");
- }
-
- protected String insertDataToSQL(String fullyQualifiedTableName, List<String> columns, List<String> columnData) {
- StringBuilder toExecute = new StringBuilder();
- toExecute.append("INSERT INTO " + formatQuotedString(fullyQualifiedTableName, "\\.") + " (\n");
- toExecute.append(join(columns, ","));
- toExecute.append("\n) VALUES (\n");
- toExecute.append(join(columnData, ","));
- toExecute.append(")\n");
- return toExecute.toString();
- }
-
- public void createIndex(TableElement tableDef) throws OseeCoreException {
- List<IndexElement> tableIndices = tableDef.getIndexData();
- String indexId = null;
- StringBuilder appliesTo = new StringBuilder();
- String tableName = formatQuotedString(tableDef.getFullyQualifiedTableName(), "\\.");
- for (IndexElement iData : tableIndices) {
- if (iData.ignoreMySql()) {
- continue;
- }
- indexId = iData.getId();
- appliesTo.delete(0, appliesTo.length());
-
- List<AppliesToClause> appliesToList = iData.getAppliesToList();
- for (int index = 0; index < appliesToList.size(); index++) {
- AppliesToClause record = appliesToList.get(index);
- appliesTo.append(record.getColumnName());
-
- switch (record.getOrderType()) {
- case Ascending:
- appliesTo.append(" ASC");
- break;
- case Descending:
- appliesTo.append(" DESC");
- break;
- default:
- break;
- }
- if (index + 1 < appliesToList.size()) {
- appliesTo.append(", ");
- }
- }
- String toExecute =
- String.format("%s %s INDEX %s ON %s (%s)", CREATE_STRING, iData.getIndexType(), indexId, tableName,
- appliesTo);
- toExecute = createIndexPostProcess(iData, toExecute);
- getLogger().debug(toExecute);
- dbService.runPreparedUpdate(toExecute);
- }
- }
-
- protected String createIndexPostProcess(IndexElement indexElement, String original) {
- return original;
- }
-
- public void dropIndex(TableElement tableDef) throws OseeCoreException {
- List<IndexElement> tableIndices = tableDef.getIndexData();
- String tableName = tableDef.getFullyQualifiedTableName();
- for (IndexElement iData : tableIndices) {
- getLogger().debug("Dropping Index: [%s] FROM [%s]\n", iData.getId(), tableName);
- dbService.runPreparedUpdate(DROP_STRING + " INDEX " + iData.getId());
- }
- }
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/SqlManagerImpl.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/SqlManagerImpl.java
deleted file mode 100644
index 8f7274a277..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/sql/SqlManagerImpl.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.sql;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.eclipse.osee.database.schema.internal.data.ColumnMetadata;
-import org.eclipse.osee.database.schema.internal.data.TableElement;
-import org.eclipse.osee.database.schema.internal.data.TableElement.ColumnFields;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.logger.Log;
-
-/**
- * @author Roberto E. Escobar
- */
-public class SqlManagerImpl extends SqlManager {
-
- public SqlManagerImpl(Log logger, SqlDataType sqlDataType, IOseeDatabaseService dbService) {
- super(logger, sqlDataType, dbService);
- }
-
- private String handleColumnCreationSection(Map<String, ColumnMetadata> columns) {
- List<String> lines = new ArrayList<String>();
- Set<String> keys = columns.keySet();
- for (String key : keys) {
- Map<ColumnFields, String> column = columns.get(key).getColumnFields();
- lines.add(columnDataToSQL(column));
- }
- String toExecute = join(lines, ",\n");
- return toExecute;
- }
-
- @Override
- public void createTable(TableElement tableDef) throws OseeCoreException {
- StringBuilder toExecute = new StringBuilder();
- toExecute.append(SqlManager.CREATE_STRING + " TABLE " + formatQuotedString(tableDef.getFullyQualifiedTableName(),
- "\\.") + " ( \n");
- toExecute.append(handleColumnCreationSection(tableDef.getColumns()));
- toExecute.append(handleConstraintCreationSection(tableDef.getConstraints(), tableDef.getFullyQualifiedTableName()));
- toExecute.append(handleConstraintCreationSection(tableDef.getForeignKeyConstraints(),
- tableDef.getFullyQualifiedTableName()));
- toExecute.append(" \n)\n");
- getLogger().debug("Creating Table: [%s]", tableDef.getFullyQualifiedTableName());
- getDatabaseService().runPreparedUpdate(toExecute.toString());
- }
-
- @Override
- public void dropTable(TableElement tableDef) throws OseeCoreException {
- StringBuilder toExecute = new StringBuilder();
- toExecute.append(SqlManager.DROP_STRING + " TABLE " + formatQuotedString(tableDef.getFullyQualifiedTableName(),
- "\\."));
- getLogger().debug("Dropping Table: [%s]", tableDef.getFullyQualifiedTableName());
- getDatabaseService().runPreparedUpdate(toExecute.toString());
- }
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/util/DatabaseDataImporter.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/util/DatabaseDataImporter.java
deleted file mode 100644
index 34beff38a1..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/util/DatabaseDataImporter.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.util;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import org.eclipse.osee.database.schema.internal.data.ColumnDbData;
-import org.eclipse.osee.database.schema.internal.data.ColumnMetadata;
-import org.eclipse.osee.database.schema.internal.data.TableElement;
-import org.eclipse.osee.database.schema.internal.data.TableElement.ColumnFields;
-import org.eclipse.osee.database.schema.internal.data.TableElement.TableDescriptionFields;
-import org.eclipse.osee.database.schema.internal.data.TableElement.TableTags;
-import org.eclipse.osee.database.schema.internal.sql.SqlManager;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.logger.Log;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * @author Roberto E. Escobar
- */
-public class DatabaseDataImporter {
- private final File directory;
- private final SqlManager sqlManager;
- private List<String> tableOrder;
- private String schemaToImportTo;
- private final Set<String> tableFilter;
- private final Log logger;
-
- public DatabaseDataImporter(Log logger, File directory, SqlManager sqlManager) {
- this.logger = logger;
- this.directory = directory;
- this.sqlManager = sqlManager;
- this.tableFilter = new TreeSet<String>();
- }
-
- public void setImportOrder(List<String> tableOrder) {
- this.tableOrder = tableOrder;
- }
-
- public void setSchemaToImportTo(String schema) {
- this.schemaToImportTo = schema;
- }
-
- public void addToTableFilter(String fullyQualifiedTableName) {
- this.tableFilter.add(fullyQualifiedTableName);
- }
-
- public void clearTableFilter() {
- this.tableFilter.clear();
- }
-
- public List<File> orderFilesByImportOrder(Map<String, File> toOrder) {
- List<File> orderedSet = new ArrayList<File>();
- if (tableOrder != null && tableOrder.size() != 0) {
- for (String tableName : tableOrder) {
- String fileName = tableName + FileUtility.DB_DATA_EXTENSION;
- File file = toOrder.get(fileName);
- if (file != null) {
- orderedSet.add(file);
- }
- }
- } else {
- Set<String> keys = toOrder.keySet();
- for (String key : keys) {
- orderedSet.add(toOrder.get(key));
- }
- }
- return orderedSet;
- }
-
- public Map<String, File> filterDataToImport(Map<String, File> toProcess) {
- Map<String, File> filteredList = new HashMap<String, File>();
- if (tableFilter != null && tableFilter.size() != 0) {
- for (String tableName : tableFilter) {
- String fileName = tableName + FileUtility.DB_DATA_EXTENSION;
- File file = toProcess.get(fileName);
- if (file != null) {
- filteredList.put(fileName, file);
- }
- }
- } else {
- return toProcess;
- }
- return filteredList;
- }
-
- public void importDataIntoDatabase() {
- if (FileUtility.isValidDirectory(directory)) {
- Map<String, File> filesToProcess = getFilesToProcess();
- Map<String, File> filteredFiles = filterDataToImport(filesToProcess);
- List<File> files = orderFilesByImportOrder(filteredFiles);
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder;
- Document document;
- for (File file : files) {
- try {
- builder = factory.newDocumentBuilder();
- document = builder.parse(file);
- processData(parseXMLDbDataFile(document));
- } catch (ParserConfigurationException ex) {
- logger.error(ex, "Unable to Parse File. ");
- } catch (Exception ex) {
- logger.error(ex, "Error importing into database");
- }
- }
- }
- }
-
- private Map<String, File> getFilesToProcess() {
- Map<String, File> toReturn = new HashMap<String, File>();
- List<File> files = FileUtility.getDBDataFileList(directory);
- for (File fileName : files) {
- toReturn.put(fileName.getName(), new File(directory + File.separator + fileName.getName()));
- }
- return toReturn;
- }
-
- private void processData(List<TableData> tables) throws OseeCoreException {
- if (tables.size() != 0) {
- for (TableData tableData : tables) {
- logger.info("Populating: [%s]\n", tableData.getFullyQualifiedTableName());
- List<List<ColumnDbData>> rows = tableData.getRows();
- if (!rows.isEmpty()) {
- for (List<ColumnDbData> rowData : rows) {
- sqlManager.insertData(rowData, tableData);
- }
- }
- }
- }
- }
-
- private void parseColumnMetadata(Element tableElement, TableData tableData) {
- NodeList columnElements = tableElement.getElementsByTagName(TableTags.ColumnInfo.name());
- if (columnElements != null) {
- for (int index = 0; index < columnElements.getLength(); index++) {
- Element columnElement = (Element) columnElements.item(index);
- if (columnElement != null) {
-
- NamedNodeMap attributeMap = columnElement.getAttributes();
- if (attributeMap != null && attributeMap.getLength() != 0) {
- ColumnMetadata columnMetaData = new ColumnMetadata("");
- for (int attributeIndex = 0; attributeIndex < attributeMap.getLength(); attributeIndex++) {
- Node node = attributeMap.item(attributeIndex);
- String nodeName = node.getNodeName();
- String nodeValue = node.getTextContent();
- if (Strings.isValid(nodeName)) {
- columnMetaData.addColumnField(ColumnFields.valueOf(nodeName),
- (nodeValue != null ? nodeValue : ""));
- }
- }
- tableData.addColumn(columnMetaData);
- }
- }
- }
- }
- }
-
- private void parseRowInformation(Element tableElement, TableData tableData) {
- NodeList rowElements = tableElement.getElementsByTagName(TableTags.Row.name());
- if (rowElements != null) {
- for (int rowIndex = 0; rowIndex < rowElements.getLength(); rowIndex++) {
- Element row = (Element) rowElements.item(rowIndex);
- if (row != null) {
- NamedNodeMap attributeMap = row.getAttributes();
- if (attributeMap != null && attributeMap.getLength() != 0) {
- List<ColumnDbData> rowData = new ArrayList<ColumnDbData>();
- tableData.addRow(rowData);
- for (int attributeIndex = 0; attributeIndex < attributeMap.getLength(); attributeIndex++) {
- Node node = attributeMap.item(attributeIndex);
- String nodeName = node.getNodeName();
- String nodeValue = node.getTextContent();
- if (Strings.isValid(nodeName)) {
- rowData.add(new ColumnDbData(nodeName, (nodeValue != null ? nodeValue : "")));
- }
- }
- }
- }
- }
- }
- }
-
- private List<TableData> parseXMLDbDataFile(Document document) {
- NodeList tableElements = document.getElementsByTagName(TableTags.Table.name());
- List<TableData> tables = new ArrayList<TableData>();
- for (int index = 0; index < tableElements.getLength(); index++) {
- Element tableXmlElement = (Element) tableElements.item(index);
- if (tableXmlElement != null) {
- NamedNodeMap map = tableXmlElement.getAttributes();
- if (map != null && map.getLength() != 0) {
- Node tableName = map.getNamedItem(TableDescriptionFields.name.name());
- Node tableAddress = map.getNamedItem(TableDescriptionFields.schema.name());
- String tableNameString = "";
- String tableAddressString = "";
- if (tableName != null) {
- tableNameString = tableName.getTextContent();
- }
- if (tableAddress != null) {
- tableAddressString = tableAddress.getTextContent();
- }
-
- if (Strings.isValid(tableNameString) && Strings.isValid(tableAddressString)) {
- TableData tableData = new TableData();
- tableData.addTableDescription(TableDescriptionFields.name, tableNameString);
- if (Strings.isValid(this.schemaToImportTo)) {
- tableData.addTableDescription(TableDescriptionFields.schema, schemaToImportTo);
- } else {
- tableData.addTableDescription(TableDescriptionFields.schema, tableAddressString);
- }
- parseRowInformation(tableXmlElement, tableData);
- parseColumnMetadata(tableXmlElement, tableData);
- tables.add(tableData);
- }
- }
- }
- }
- return tables;
- }
-
- private static class TableData extends TableElement {
- private final List<List<ColumnDbData>> rowData;
-
- public TableData() {
- rowData = new ArrayList<List<ColumnDbData>>();
- }
-
- public void addRow(List<ColumnDbData> row) {
- rowData.add(row);
- }
-
- public List<List<ColumnDbData>> getRows() {
- return rowData;
- }
- }
-}
diff --git a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/util/FileUtility.java b/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/util/FileUtility.java
deleted file mode 100644
index 6920a000b8..0000000000
--- a/plugins/org.eclipse.osee.database.schema/src/org/eclipse/osee/database/schema/internal/util/FileUtility.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * 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.database.schema.internal.util;
-
-import java.io.File;
-import java.io.FilenameFilter;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-// TODO: this class has some overlap with methods provided in org.eclipse.osee.framework.jdk.core.Lib
-public final class FileUtility {
-
- public static String SCHEMA_EXTENSION = ".SCHEMA.xml";
- public static String DB_DATA_EXTENSION = ".DATA.xml";
-
- private FileUtility() {
- // Utility class
- }
-
- public static boolean isValidDirectory(File directory) {
- if (directory != null && directory.exists() && directory.canRead()) {
- File[] listOfFiles = directory.listFiles();
- if (listOfFiles.length != 0) {
- return true;
- }
- }
- return false;
- }
-
- public static void setupDirectoryForWrite(File directory) {
- if (directory.exists() && directory.canWrite()) {
- if (!directory.isDirectory()) {
- directory.mkdirs();
- }
- } else {
- directory.mkdirs();
- }
- }
-
- public static List<File> getFileList(File sourceDirectory, final String extension) {
- File[] listOfFiles = sourceDirectory.listFiles(new FilenameFilter() {
- @Override
- public boolean accept(File directoryName, String filename) {
- return filename.endsWith(extension) && new File(directoryName + File.separator + filename).canRead();
- }
- });
- return Arrays.asList(listOfFiles);
- }
-
- public static List<URL> getSchemaFileList(File sourceDirectory) {
- List<File> files = getFileList(sourceDirectory, SCHEMA_EXTENSION);
- List<URL> streams = new ArrayList<URL>();
- for (File file : files) {
- try {
- streams.add(file.toURI().toURL());
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- }
- return streams;
- }
-
- public static List<File> getDBDataFileList(File sourceDirectory) {
- return getFileList(sourceDirectory, DB_DATA_EXTENSION);
- }
-
- public static List<URL> getDBDataFileListInputStream(File sourceDirectory) {
- List<File> files = getFileList(sourceDirectory, DB_DATA_EXTENSION);
- List<URL> streams = new ArrayList<URL>();
- for (File file : files) {
- try {
- streams.add(file.toURI().toURL());
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- }
- return streams;
- }
-}
diff --git a/plugins/org.eclipse.osee.orcs.parent/pom.xml b/plugins/org.eclipse.osee.orcs.parent/pom.xml
index f6656bd4ba..c3cbe8487c 100644
--- a/plugins/org.eclipse.osee.orcs.parent/pom.xml
+++ b/plugins/org.eclipse.osee.orcs.parent/pom.xml
@@ -28,8 +28,6 @@
<module>../../plugins/org.eclipse.osee.framework.resource.management.test</module>
<module>../../plugins/org.eclipse.osee.framework.database</module>
- <module>../../plugins/org.eclipse.osee.database.schema</module>
-
<module>../../plugins/org.eclipse.osee.activity</module>
<module>../../plugins/org.eclipse.osee.activity.server</module>

Back to the top