Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrbrooks2010-07-24 04:02:08 -0400
committerrbrooks2010-07-24 04:02:08 -0400
commit4ed8bddc791fda93940f238c5135556a07041dc0 (patch)
tree64a118285c5006c3a38320dbb2d374e8ea72a061 /plugins/org.eclipse.osee.framework.database
parent542cc7344d3f129d64e47f547384297c8e1b1f43 (diff)
downloadorg.eclipse.osee-4ed8bddc791fda93940f238c5135556a07041dc0.tar.gz
org.eclipse.osee-4ed8bddc791fda93940f238c5135556a07041dc0.tar.xz
org.eclipse.osee-4ed8bddc791fda93940f238c5135556a07041dc0.zip
converted all line terminators to unix style
Diffstat (limited to 'plugins/org.eclipse.osee.framework.database')
-rw-r--r--plugins/org.eclipse.osee.framework.database/.classpath14
-rw-r--r--plugins/org.eclipse.osee.framework.database/.project68
-rw-r--r--plugins/org.eclipse.osee.framework.database/build.properties18
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/IOseeDatabaseService.java106
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/IOseeDatabaseServiceProvider.java42
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/AbstractDbTxOperation.java162
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DatabaseInfoManager.java102
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DatabaseTransactions.java132
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DbTransaction.java186
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IDatabaseInfoProvider.java50
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IDbConnectionInformationContributor.java44
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IDbTransactionWork.java96
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IOseeSequence.java144
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IOseeSequenceProvider.java42
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/JoinUtility.java1166
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/OseeConnection.java80
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/OseeInfo.java112
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ResultSetProcessor.java182
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/Activator.java146
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/DatabaseInfoProvider.java178
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/UriDbConnectionInfo.java86
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/ConnectionFactoryProvider.java102
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeConnectionImpl.java270
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeConnectionPoolImpl.java218
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeDatabaseServiceImpl.java444
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/StaleConnectionCloser.java80
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/StatementUtil.java242
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/parser/DbDetailData.java188
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/parser/DbInformation.java252
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/trackers/OseeDatabaseServiceRegistrationHandler.java108
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/operation/Address.java276
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/operation/InvalidTxCurrentsAndModTypes.java386
32 files changed, 2861 insertions, 2861 deletions
diff --git a/plugins/org.eclipse.osee.framework.database/.classpath b/plugins/org.eclipse.osee.framework.database/.classpath
index 8a8f1668cd..ad32c83a78 100644
--- a/plugins/org.eclipse.osee.framework.database/.classpath
+++ b/plugins/org.eclipse.osee.framework.database/.classpath
@@ -1,7 +1,7 @@
-<?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>
+<?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.framework.database/.project b/plugins/org.eclipse.osee.framework.database/.project
index afbf23100f..16ccafdb72 100644
--- a/plugins/org.eclipse.osee.framework.database/.project
+++ b/plugins/org.eclipse.osee.framework.database/.project
@@ -1,34 +1,34 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.osee.framework.database</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>
- <buildCommand>
- <name>org.eclipse.pde.ds.core.builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.apache.derby.ui.derbyEngine</nature>
- </natures>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.framework.database</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>
+ <buildCommand>
+ <name>org.eclipse.pde.ds.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.apache.derby.ui.derbyEngine</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.osee.framework.database/build.properties b/plugins/org.eclipse.osee.framework.database/build.properties
index cdbb2337a9..89cea42aab 100644
--- a/plugins/org.eclipse.osee.framework.database/build.properties
+++ b/plugins/org.eclipse.osee.framework.database/build.properties
@@ -1,9 +1,9 @@
-bin.includes = META-INF/,\
- support/,\
- src/,\
- .,\
- OSGI-INF/
-jars.compile.order = .
-source.. = src/
-output.. = bin/
-
+bin.includes = META-INF/,\
+ support/,\
+ src/,\
+ .,\
+ OSGI-INF/
+jars.compile.order = .
+source.. = src/
+output.. = bin/
+
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/IOseeDatabaseService.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/IOseeDatabaseService.java
index 70ed9514c1..500102f6b0 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/IOseeDatabaseService.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/IOseeDatabaseService.java
@@ -1,53 +1,53 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database;
-
-import java.util.List;
-import org.eclipse.osee.framework.core.data.IDatabaseInfo;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.database.core.IOseeSequence;
-import org.eclipse.osee.framework.database.core.IOseeStatement;
-import org.eclipse.osee.framework.database.core.OseeConnection;
-
-/**
- * @author Roberto E. Escobar
- */
-public interface IOseeDatabaseService {
-
- IOseeSequence getSequence() throws OseeDataStoreException;
-
- IOseeStatement getStatement() throws OseeDataStoreException;
-
- IOseeStatement getStatement(OseeConnection connection) throws OseeDataStoreException;
-
- IOseeStatement getStatement(OseeConnection connection, boolean autoClose) throws OseeDataStoreException;
-
- IOseeStatement getStatement(int resultSetType, int resultSetConcurrency) throws OseeDataStoreException;
-
- OseeConnection getConnection() throws OseeDataStoreException;
-
- OseeConnection getConnection(IDatabaseInfo info) throws OseeDataStoreException;
-
- <O extends Object> int runBatchUpdate(String query, List<O[]> dataList) throws OseeDataStoreException;
-
- <O extends Object> int runPreparedUpdate(String query, O... data) throws OseeDataStoreException;
-
- <O extends Object> int runBatchUpdate(OseeConnection connection, String query, List<O[]> dataList) throws OseeDataStoreException;
-
- <O extends Object> int runPreparedUpdate(OseeConnection connection, String query, O... data) throws OseeDataStoreException;
-
- <T, O extends Object> T runPreparedQueryFetchObject(T defaultValue, String query, O... data) throws OseeDataStoreException;
-
- <T, O extends Object> T runPreparedQueryFetchObject(OseeConnection connection, T defaultValue, String query, O... data) throws OseeDataStoreException;
-
- boolean isProduction() throws OseeCoreException;
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.database;
+
+import java.util.List;
+import org.eclipse.osee.framework.core.data.IDatabaseInfo;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.database.core.IOseeSequence;
+import org.eclipse.osee.framework.database.core.IOseeStatement;
+import org.eclipse.osee.framework.database.core.OseeConnection;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface IOseeDatabaseService {
+
+ IOseeSequence getSequence() throws OseeDataStoreException;
+
+ IOseeStatement getStatement() throws OseeDataStoreException;
+
+ IOseeStatement getStatement(OseeConnection connection) throws OseeDataStoreException;
+
+ IOseeStatement getStatement(OseeConnection connection, boolean autoClose) throws OseeDataStoreException;
+
+ IOseeStatement getStatement(int resultSetType, int resultSetConcurrency) throws OseeDataStoreException;
+
+ OseeConnection getConnection() throws OseeDataStoreException;
+
+ OseeConnection getConnection(IDatabaseInfo info) throws OseeDataStoreException;
+
+ <O extends Object> int runBatchUpdate(String query, List<O[]> dataList) throws OseeDataStoreException;
+
+ <O extends Object> int runPreparedUpdate(String query, O... data) throws OseeDataStoreException;
+
+ <O extends Object> int runBatchUpdate(OseeConnection connection, String query, List<O[]> dataList) throws OseeDataStoreException;
+
+ <O extends Object> int runPreparedUpdate(OseeConnection connection, String query, O... data) throws OseeDataStoreException;
+
+ <T, O extends Object> T runPreparedQueryFetchObject(T defaultValue, String query, O... data) throws OseeDataStoreException;
+
+ <T, O extends Object> T runPreparedQueryFetchObject(OseeConnection connection, T defaultValue, String query, O... data) throws OseeDataStoreException;
+
+ boolean isProduction() throws OseeCoreException;
+}
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/IOseeDatabaseServiceProvider.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/IOseeDatabaseServiceProvider.java
index ac3927dd3d..0aa0367889 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/IOseeDatabaseServiceProvider.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/IOseeDatabaseServiceProvider.java
@@ -1,21 +1,21 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database;
-
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-
-/**
- * @author Roberto E. Escobar
- */
-public interface IOseeDatabaseServiceProvider {
-
- IOseeDatabaseService getOseeDatabaseService() throws OseeDataStoreException;
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.database;
+
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface IOseeDatabaseServiceProvider {
+
+ IOseeDatabaseService getOseeDatabaseService() throws OseeDataStoreException;
+}
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/AbstractDbTxOperation.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/AbstractDbTxOperation.java
index 5e3325bb9d..4a62e2d365 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/AbstractDbTxOperation.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/AbstractDbTxOperation.java
@@ -1,82 +1,82 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database.core;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.core.operation.AbstractOperation;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.database.IOseeDatabaseServiceProvider;
-
-/**
- * @author Roberto E. Escobar
- */
-public abstract class AbstractDbTxOperation extends AbstractOperation {
-
- private final IOseeDatabaseServiceProvider provider;
-
- public AbstractDbTxOperation(IOseeDatabaseServiceProvider provider, String operationName, String pluginId) {
- super(operationName, pluginId);
- this.provider = provider;
- }
-
- protected IOseeDatabaseService getDatabaseService() throws OseeDataStoreException {
- return provider.getOseeDatabaseService();
- }
-
- protected IOseeDatabaseServiceProvider getDatabaseServiceProvider() throws OseeDataStoreException {
- return provider;
- }
-
- @Override
- protected final void doWork(IProgressMonitor monitor) throws Exception {
- Transaction transaction = new Transaction(monitor);
- transaction.execute();
- }
-
- protected abstract void doTxWork(IProgressMonitor monitor, OseeConnection connection) throws OseeCoreException;
-
- protected void handleTxException(IProgressMonitor monitor, Exception ex) {
- }
-
- protected void handleTxFinally(IProgressMonitor monitor) throws OseeCoreException {
- }
-
- private final class Transaction extends DbTransaction {
- private final IProgressMonitor monitor;
-
- private Transaction(IProgressMonitor monitor) throws OseeCoreException {
- super();
- this.monitor = monitor;
- }
-
- @Override
- protected String getTxName() {
- return AbstractDbTxOperation.this.getName();
- }
-
- @Override
- protected void handleTxWork(OseeConnection connection) throws OseeCoreException {
- AbstractDbTxOperation.this.doTxWork(monitor, connection);
- }
-
- @Override
- protected void handleTxException(Exception ex) {
- AbstractDbTxOperation.this.handleTxException(monitor, ex);
- }
-
- @Override
- protected void handleTxFinally() throws OseeCoreException {
- AbstractDbTxOperation.this.handleTxFinally(monitor);
- }
- }
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.database.core;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.core.operation.AbstractOperation;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
+import org.eclipse.osee.framework.database.IOseeDatabaseServiceProvider;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public abstract class AbstractDbTxOperation extends AbstractOperation {
+
+ private final IOseeDatabaseServiceProvider provider;
+
+ public AbstractDbTxOperation(IOseeDatabaseServiceProvider provider, String operationName, String pluginId) {
+ super(operationName, pluginId);
+ this.provider = provider;
+ }
+
+ protected IOseeDatabaseService getDatabaseService() throws OseeDataStoreException {
+ return provider.getOseeDatabaseService();
+ }
+
+ protected IOseeDatabaseServiceProvider getDatabaseServiceProvider() throws OseeDataStoreException {
+ return provider;
+ }
+
+ @Override
+ protected final void doWork(IProgressMonitor monitor) throws Exception {
+ Transaction transaction = new Transaction(monitor);
+ transaction.execute();
+ }
+
+ protected abstract void doTxWork(IProgressMonitor monitor, OseeConnection connection) throws OseeCoreException;
+
+ protected void handleTxException(IProgressMonitor monitor, Exception ex) {
+ }
+
+ protected void handleTxFinally(IProgressMonitor monitor) throws OseeCoreException {
+ }
+
+ private final class Transaction extends DbTransaction {
+ private final IProgressMonitor monitor;
+
+ private Transaction(IProgressMonitor monitor) throws OseeCoreException {
+ super();
+ this.monitor = monitor;
+ }
+
+ @Override
+ protected String getTxName() {
+ return AbstractDbTxOperation.this.getName();
+ }
+
+ @Override
+ protected void handleTxWork(OseeConnection connection) throws OseeCoreException {
+ AbstractDbTxOperation.this.doTxWork(monitor, connection);
+ }
+
+ @Override
+ protected void handleTxException(Exception ex) {
+ AbstractDbTxOperation.this.handleTxException(monitor, ex);
+ }
+
+ @Override
+ protected void handleTxFinally() throws OseeCoreException {
+ AbstractDbTxOperation.this.handleTxFinally(monitor);
+ }
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DatabaseInfoManager.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DatabaseInfoManager.java
index 006fdabef4..187dce207a 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DatabaseInfoManager.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DatabaseInfoManager.java
@@ -1,51 +1,51 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database.core;
-
-import java.io.IOException;
-import java.io.InputStream;
-import javax.xml.parsers.ParserConfigurationException;
-import org.eclipse.osee.framework.core.data.IDatabaseInfo;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.database.internal.Activator;
-import org.eclipse.osee.framework.database.internal.parser.DbConfigParser;
-import org.eclipse.osee.framework.jdk.core.util.xml.Jaxp;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.xml.sax.SAXException;
-
-public class DatabaseInfoManager {
-
- private DatabaseInfoManager() {
- }
-
- public static IDatabaseInfo getDefault() throws OseeDataStoreException {
- return Activator.getInstance().getDatabaseInfoProvider().getSelectedDatabaseInfo();
- }
-
- public static IDatabaseInfo getDataStoreById(String id) throws OseeCoreException {
- return Activator.getInstance().getDatabaseInfoProvider().getDatabaseInfo(id);
- }
-
- public static IDatabaseInfo[] readFromXml(InputStream inputStream) throws IOException, ParserConfigurationException, SAXException {
- try {
- Document document = Jaxp.readXmlDocument(inputStream);
- Element rootElement = document.getDocumentElement();
- return DbConfigParser.parse(rootElement);
- } finally {
- if (inputStream != null) {
- inputStream.close();
- }
- }
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.database.core;
+
+import java.io.IOException;
+import java.io.InputStream;
+import javax.xml.parsers.ParserConfigurationException;
+import org.eclipse.osee.framework.core.data.IDatabaseInfo;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.database.internal.Activator;
+import org.eclipse.osee.framework.database.internal.parser.DbConfigParser;
+import org.eclipse.osee.framework.jdk.core.util.xml.Jaxp;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+public class DatabaseInfoManager {
+
+ private DatabaseInfoManager() {
+ }
+
+ public static IDatabaseInfo getDefault() throws OseeDataStoreException {
+ return Activator.getInstance().getDatabaseInfoProvider().getSelectedDatabaseInfo();
+ }
+
+ public static IDatabaseInfo getDataStoreById(String id) throws OseeCoreException {
+ return Activator.getInstance().getDatabaseInfoProvider().getDatabaseInfo(id);
+ }
+
+ public static IDatabaseInfo[] readFromXml(InputStream inputStream) throws IOException, ParserConfigurationException, SAXException {
+ try {
+ Document document = Jaxp.readXmlDocument(inputStream);
+ Element rootElement = document.getDocumentElement();
+ return DbConfigParser.parse(rootElement);
+ } finally {
+ if (inputStream != null) {
+ inputStream.close();
+ }
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DatabaseTransactions.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DatabaseTransactions.java
index 157bf458b3..5a21456fc8 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DatabaseTransactions.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DatabaseTransactions.java
@@ -8,69 +8,69 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.framework.database.core;
-
-import java.util.logging.Level;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeWrappedException;
-import org.eclipse.osee.framework.database.internal.Activator;
-import org.eclipse.osee.framework.logging.OseeLog;
-
-public final class DatabaseTransactions {
-
- private DatabaseTransactions() {
- }
-
- public static void execute(IDbTransactionWork dbWork) throws OseeCoreException {
- execute(ConnectionHandler.getConnection(), dbWork);
- }
-
- public static void execute(OseeConnection connection, IDbTransactionWork dbWork) throws OseeCoreException {
- boolean initialAutoCommit = true;
- OseeCoreException saveException = null;
- try {
- OseeLog.log(Activator.class, Level.FINEST, String.format("Start Transaction: [%s]", dbWork.getName()));
-
- initialAutoCommit = connection.getAutoCommit();
- connection.setAutoCommit(false);
- ConnectionHandler.deferConstraintChecking(connection);
- dbWork.handleTxWork(connection);
-
- connection.commit();
- OseeLog.log(Activator.class, Level.FINEST, String.format("End Transaction: [%s]", dbWork.getName()));
- } catch (Exception ex) {
- if (ex instanceof OseeCoreException) {
- saveException = (OseeCoreException) ex;
- } else {
- saveException = new OseeWrappedException(ex);
- }
- try {
- connection.rollback();
- connection.destroy();
- } finally {
- dbWork.handleTxException(ex);
- }
- } finally {
- try {
- try {
- if (!connection.isClosed()) {
- connection.setAutoCommit(initialAutoCommit);
- connection.close();
- }
- } finally {
- dbWork.handleTxFinally();
- }
- } catch (OseeCoreException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- if (saveException == null) {
- saveException = ex;
- }
- }
-
- if (saveException != null) {
- throw saveException;
- }
- }
- }
-
-}
+package org.eclipse.osee.framework.database.core;
+
+import java.util.logging.Level;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeWrappedException;
+import org.eclipse.osee.framework.database.internal.Activator;
+import org.eclipse.osee.framework.logging.OseeLog;
+
+public final class DatabaseTransactions {
+
+ private DatabaseTransactions() {
+ }
+
+ public static void execute(IDbTransactionWork dbWork) throws OseeCoreException {
+ execute(ConnectionHandler.getConnection(), dbWork);
+ }
+
+ public static void execute(OseeConnection connection, IDbTransactionWork dbWork) throws OseeCoreException {
+ boolean initialAutoCommit = true;
+ OseeCoreException saveException = null;
+ try {
+ OseeLog.log(Activator.class, Level.FINEST, String.format("Start Transaction: [%s]", dbWork.getName()));
+
+ initialAutoCommit = connection.getAutoCommit();
+ connection.setAutoCommit(false);
+ ConnectionHandler.deferConstraintChecking(connection);
+ dbWork.handleTxWork(connection);
+
+ connection.commit();
+ OseeLog.log(Activator.class, Level.FINEST, String.format("End Transaction: [%s]", dbWork.getName()));
+ } catch (Exception ex) {
+ if (ex instanceof OseeCoreException) {
+ saveException = (OseeCoreException) ex;
+ } else {
+ saveException = new OseeWrappedException(ex);
+ }
+ try {
+ connection.rollback();
+ connection.destroy();
+ } finally {
+ dbWork.handleTxException(ex);
+ }
+ } finally {
+ try {
+ try {
+ if (!connection.isClosed()) {
+ connection.setAutoCommit(initialAutoCommit);
+ connection.close();
+ }
+ } finally {
+ dbWork.handleTxFinally();
+ }
+ } catch (OseeCoreException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ if (saveException == null) {
+ saveException = ex;
+ }
+ }
+
+ if (saveException != null) {
+ throw saveException;
+ }
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DbTransaction.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DbTransaction.java
index 4c1163d1eb..a6a11347c9 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DbTransaction.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DbTransaction.java
@@ -1,94 +1,94 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database.core;
-
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-
-/**
- * This abstract class provides a uniform way of executing database transactions. It handles exceptions ensuring that
- * transactions are processed in the correct order and roll-backs are performed whenever errors are detected.
- *
- * @author Roberto E. Escobar
- */
-public abstract class DbTransaction {
-
- /**
- * Gets the name of this transaction. This is provided mainly for logging purposes.
- *
- * @return String transaction class Name
- */
- protected String getTxName() {
- return this.getClass().getCanonicalName();
- }
-
- /**
- * This template method calls {@link #handleTxWork} which is provided by child classes. This method handles
- * roll-backs and exception handling to prevent transactions from being left in an incorrect state.
- *
- * @throws OseeCoreException
- */
- public void execute() throws OseeCoreException {
- DatabaseTransactions.execute(new InternalTransactionWork());
- }
-
- /**
- * Provides the transaction's work implementation.
- *
- * @param connection
- * @throws OseeCoreException
- */
- protected abstract void handleTxWork(OseeConnection connection) throws OseeCoreException;
-
- /**
- * When an exception is detected during transaction processing, the exception is caught and passed to this method.
- * This convenience method is provided so child classes have access to the exception. <br/>
- * <b>Override to handle transaction exception</b>
- *
- * @param ex
- * @throws Exception
- */
- protected void handleTxException(Exception ex) {
- }
-
- /**
- * This convenience method is provided in case child classes have a portion of code that needs to execute always at
- * the end of the transaction, regardless of exceptions. <br/>
- * <b>Override to add additional code to finally block</b>
- *
- * @throws OseeCoreException
- */
- protected void handleTxFinally() throws OseeCoreException {
- // override to add additional code to finally
- }
-
- private final class InternalTransactionWork implements IDbTransactionWork {
-
- @Override
- public void handleTxException(Exception ex) {
- DbTransaction.this.handleTxException(ex);
- }
-
- @Override
- public void handleTxFinally() throws OseeCoreException {
- DbTransaction.this.handleTxFinally();
- }
-
- @Override
- public void handleTxWork(OseeConnection connection) throws OseeCoreException {
- DbTransaction.this.handleTxWork(connection);
- }
-
- @Override
- public String getName() {
- return DbTransaction.this.getTxName();
- }
- };
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.database.core;
+
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+
+/**
+ * This abstract class provides a uniform way of executing database transactions. It handles exceptions ensuring that
+ * transactions are processed in the correct order and roll-backs are performed whenever errors are detected.
+ *
+ * @author Roberto E. Escobar
+ */
+public abstract class DbTransaction {
+
+ /**
+ * Gets the name of this transaction. This is provided mainly for logging purposes.
+ *
+ * @return String transaction class Name
+ */
+ protected String getTxName() {
+ return this.getClass().getCanonicalName();
+ }
+
+ /**
+ * This template method calls {@link #handleTxWork} which is provided by child classes. This method handles
+ * roll-backs and exception handling to prevent transactions from being left in an incorrect state.
+ *
+ * @throws OseeCoreException
+ */
+ public void execute() throws OseeCoreException {
+ DatabaseTransactions.execute(new InternalTransactionWork());
+ }
+
+ /**
+ * Provides the transaction's work implementation.
+ *
+ * @param connection
+ * @throws OseeCoreException
+ */
+ protected abstract void handleTxWork(OseeConnection connection) throws OseeCoreException;
+
+ /**
+ * When an exception is detected during transaction processing, the exception is caught and passed to this method.
+ * This convenience method is provided so child classes have access to the exception. <br/>
+ * <b>Override to handle transaction exception</b>
+ *
+ * @param ex
+ * @throws Exception
+ */
+ protected void handleTxException(Exception ex) {
+ }
+
+ /**
+ * This convenience method is provided in case child classes have a portion of code that needs to execute always at
+ * the end of the transaction, regardless of exceptions. <br/>
+ * <b>Override to add additional code to finally block</b>
+ *
+ * @throws OseeCoreException
+ */
+ protected void handleTxFinally() throws OseeCoreException {
+ // override to add additional code to finally
+ }
+
+ private final class InternalTransactionWork implements IDbTransactionWork {
+
+ @Override
+ public void handleTxException(Exception ex) {
+ DbTransaction.this.handleTxException(ex);
+ }
+
+ @Override
+ public void handleTxFinally() throws OseeCoreException {
+ DbTransaction.this.handleTxFinally();
+ }
+
+ @Override
+ public void handleTxWork(OseeConnection connection) throws OseeCoreException {
+ DbTransaction.this.handleTxWork(connection);
+ }
+
+ @Override
+ public String getName() {
+ return DbTransaction.this.getTxName();
+ }
+ };
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IDatabaseInfoProvider.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IDatabaseInfoProvider.java
index 36b3520065..194c264cd1 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IDatabaseInfoProvider.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IDatabaseInfoProvider.java
@@ -1,25 +1,25 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database.core;
-
-import org.eclipse.osee.framework.core.data.IDatabaseInfo;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-
-/**
- * @author Roberto E. Escobar
- */
-public interface IDatabaseInfoProvider {
-
- public IDatabaseInfo getDatabaseInfo() throws OseeDataStoreException;
-
- public int getPriority();
-
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.database.core;
+
+import org.eclipse.osee.framework.core.data.IDatabaseInfo;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface IDatabaseInfoProvider {
+
+ public IDatabaseInfo getDatabaseInfo() throws OseeDataStoreException;
+
+ public int getPriority();
+
+}
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IDbConnectionInformationContributor.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IDbConnectionInformationContributor.java
index 0be55e6ea5..78f5e7e514 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IDbConnectionInformationContributor.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IDbConnectionInformationContributor.java
@@ -1,22 +1,22 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.osee.framework.database.core;
-
-import org.eclipse.osee.framework.core.data.IDatabaseInfo;
-
-
-/**
- * @author Andrew M. Finkbeiner
- */
-public interface IDbConnectionInformationContributor {
- IDatabaseInfo[] getDbInformation() throws Exception;
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.osee.framework.database.core;
+
+import org.eclipse.osee.framework.core.data.IDatabaseInfo;
+
+
+/**
+ * @author Andrew M. Finkbeiner
+ */
+public interface IDbConnectionInformationContributor {
+ IDatabaseInfo[] getDbInformation() throws Exception;
+}
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IDbTransactionWork.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IDbTransactionWork.java
index 2c1b46f4a0..d70eeff18a 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IDbTransactionWork.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IDbTransactionWork.java
@@ -1,49 +1,49 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.osee.framework.database.core;
-
-import org.eclipse.osee.framework.core.data.Named;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-/**
- * @author Roberto E. Escobar
- * @author Jeff C. Phillips
- */
-public interface IDbTransactionWork extends Named {
-
- /**
- * Provides the transaction's work implementation.
- *
- * @param connection
- * @throws OseeCoreException
- */
- void handleTxWork(OseeConnection connection) throws OseeCoreException;
-
- /**
- * When an exception is detected during transaction processing, the exception is caught and passed to this method.
- * This convenience method is provided so child classes have access to the exception. <br/>
- * <b>Override to handle transaction exception</b>
- *
- * @param ex
- * @throws Exception
- */
- void handleTxException(Exception ex);
-
- /**
- * This convenience method is provided in case child classes have a portion of code that needs to execute always
- * at
- * the end of the transaction, regardless of exceptions. <br/>
- * <b>Override to add additional code to finally block</b>
- *
- * @throws OseeCoreException
- */
- void handleTxFinally() throws OseeCoreException;
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.osee.framework.database.core;
+
+import org.eclipse.osee.framework.core.data.Named;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+/**
+ * @author Roberto E. Escobar
+ * @author Jeff C. Phillips
+ */
+public interface IDbTransactionWork extends Named {
+
+ /**
+ * Provides the transaction's work implementation.
+ *
+ * @param connection
+ * @throws OseeCoreException
+ */
+ void handleTxWork(OseeConnection connection) throws OseeCoreException;
+
+ /**
+ * When an exception is detected during transaction processing, the exception is caught and passed to this method.
+ * This convenience method is provided so child classes have access to the exception. <br/>
+ * <b>Override to handle transaction exception</b>
+ *
+ * @param ex
+ * @throws Exception
+ */
+ void handleTxException(Exception ex);
+
+ /**
+ * This convenience method is provided in case child classes have a portion of code that needs to execute always
+ * at
+ * the end of the transaction, regardless of exceptions. <br/>
+ * <b>Override to add additional code to finally block</b>
+ *
+ * @throws OseeCoreException
+ */
+ void handleTxFinally() throws OseeCoreException;
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IOseeSequence.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IOseeSequence.java
index 00eb1b48da..235ebe1ebd 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IOseeSequence.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IOseeSequence.java
@@ -1,72 +1,72 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database.core;
-
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-
-/**
- * @author Roberto E. Escobar
- */
-public interface IOseeSequence {
-
- static final String ART_ID_SEQ = "SKYNET_ART_ID_SEQ";
- static final String ENUM_TYPE_ID_SEQ = "SKYNET_ENUM_TYPE_ID_SEQ";
- static final String ART_TYPE_ID_SEQ = "SKYNET_ART_TYPE_ID_SEQ";
- static final String ATTR_BASE_TYPE_ID_SEQ = "SKYNET_ATTR_BASE_TYPE_ID_SEQ";
- static final String ATTR_PROVIDER_TYPE_ID_SEQ = "SKYNET_ATTR_PROVIDER_TYPE_ID_SEQ";
- static final String ATTR_ID_SEQ = "SKYNET_ATTR_ID_SEQ";
- static final String ATTR_TYPE_ID_SEQ = "SKYNET_ATTR_TYPE_ID_SEQ";
- static final String FACTORY_ID_SEQ = "SKYNET_FACTORY_ID_SEQ";
- static final String BRANCH_ID_SEQ = "SKYNET_BRANCH_ID_SEQ";
- static final String REL_LINK_TYPE_ID_SEQ = "SKYNET_REL_LINK_TYPE_ID_SEQ";
- static final String REL_LINK_ID_SEQ = "SKYNET_REL_LINK_ID_SEQ";
- static final String GAMMA_ID_SEQ = "SKYNET_GAMMA_ID_SEQ";
- static final String TRANSACTION_ID_SEQ = "SKYNET_TRANSACTION_ID_SEQ";
- static final String IMPORT_ID_SEQ = "SKYNET_IMPORT_ID_SEQ";
- static final String IMPORT_MAPPED_INDEX_SEQ = "SKYNET_IMPORT_MAPPED_INDEX_SEQ";
- static final String TTE_SESSION_SEQ = "TTE_SESSION_SEQ";
-
- long getNextSequence(String sequenceName) throws OseeDataStoreException;
-
- int getNextSessionId() throws OseeDataStoreException;
-
- int getNextTransactionId() throws OseeDataStoreException;
-
- int getNextArtifactId() throws OseeDataStoreException;
-
- int getNextOseeEnumTypeId() throws OseeDataStoreException;
-
- int getNextGammaId() throws OseeDataStoreException;
-
- int getNextArtifactTypeId() throws OseeDataStoreException;
-
- int getNextAttributeBaseTypeId() throws OseeDataStoreException;
-
- int getNextAttributeProviderTypeId() throws OseeDataStoreException;
-
- int getNextAttributeId() throws OseeDataStoreException;
-
- int getNextAttributeTypeId() throws OseeDataStoreException;
-
- int getNextFactoryId() throws OseeDataStoreException;
-
- int getNextBranchId() throws OseeDataStoreException;
-
- int getNextRelationTypeId() throws OseeDataStoreException;
-
- int getNextRelationId() throws OseeDataStoreException;
-
- int getNextImportId() throws OseeDataStoreException;
-
- int getNextImportMappedIndexId() throws OseeDataStoreException;
-
- void clear() throws OseeDataStoreException;
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.database.core;
+
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface IOseeSequence {
+
+ static final String ART_ID_SEQ = "SKYNET_ART_ID_SEQ";
+ static final String ENUM_TYPE_ID_SEQ = "SKYNET_ENUM_TYPE_ID_SEQ";
+ static final String ART_TYPE_ID_SEQ = "SKYNET_ART_TYPE_ID_SEQ";
+ static final String ATTR_BASE_TYPE_ID_SEQ = "SKYNET_ATTR_BASE_TYPE_ID_SEQ";
+ static final String ATTR_PROVIDER_TYPE_ID_SEQ = "SKYNET_ATTR_PROVIDER_TYPE_ID_SEQ";
+ static final String ATTR_ID_SEQ = "SKYNET_ATTR_ID_SEQ";
+ static final String ATTR_TYPE_ID_SEQ = "SKYNET_ATTR_TYPE_ID_SEQ";
+ static final String FACTORY_ID_SEQ = "SKYNET_FACTORY_ID_SEQ";
+ static final String BRANCH_ID_SEQ = "SKYNET_BRANCH_ID_SEQ";
+ static final String REL_LINK_TYPE_ID_SEQ = "SKYNET_REL_LINK_TYPE_ID_SEQ";
+ static final String REL_LINK_ID_SEQ = "SKYNET_REL_LINK_ID_SEQ";
+ static final String GAMMA_ID_SEQ = "SKYNET_GAMMA_ID_SEQ";
+ static final String TRANSACTION_ID_SEQ = "SKYNET_TRANSACTION_ID_SEQ";
+ static final String IMPORT_ID_SEQ = "SKYNET_IMPORT_ID_SEQ";
+ static final String IMPORT_MAPPED_INDEX_SEQ = "SKYNET_IMPORT_MAPPED_INDEX_SEQ";
+ static final String TTE_SESSION_SEQ = "TTE_SESSION_SEQ";
+
+ long getNextSequence(String sequenceName) throws OseeDataStoreException;
+
+ int getNextSessionId() throws OseeDataStoreException;
+
+ int getNextTransactionId() throws OseeDataStoreException;
+
+ int getNextArtifactId() throws OseeDataStoreException;
+
+ int getNextOseeEnumTypeId() throws OseeDataStoreException;
+
+ int getNextGammaId() throws OseeDataStoreException;
+
+ int getNextArtifactTypeId() throws OseeDataStoreException;
+
+ int getNextAttributeBaseTypeId() throws OseeDataStoreException;
+
+ int getNextAttributeProviderTypeId() throws OseeDataStoreException;
+
+ int getNextAttributeId() throws OseeDataStoreException;
+
+ int getNextAttributeTypeId() throws OseeDataStoreException;
+
+ int getNextFactoryId() throws OseeDataStoreException;
+
+ int getNextBranchId() throws OseeDataStoreException;
+
+ int getNextRelationTypeId() throws OseeDataStoreException;
+
+ int getNextRelationId() throws OseeDataStoreException;
+
+ int getNextImportId() throws OseeDataStoreException;
+
+ int getNextImportMappedIndexId() throws OseeDataStoreException;
+
+ void clear() throws OseeDataStoreException;
+}
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IOseeSequenceProvider.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IOseeSequenceProvider.java
index 7ac15df95e..38ddb24b71 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IOseeSequenceProvider.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IOseeSequenceProvider.java
@@ -1,21 +1,21 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database.core;
-
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-
-/**
- * @author Roberto E. Escobar
- */
-public interface IOseeSequenceProvider {
-
- public IOseeSequence getOseeSequence() throws OseeDataStoreException;
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.database.core;
+
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface IOseeSequenceProvider {
+
+ public IOseeSequence getOseeSequence() throws OseeDataStoreException;
+}
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/JoinUtility.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/JoinUtility.java
index 0c0b1ef77e..01d18376ef 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/JoinUtility.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/JoinUtility.java
@@ -1,583 +1,583 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database.core;
-
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Random;
-import java.util.Set;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.database.internal.Activator;
-import org.eclipse.osee.framework.jdk.core.util.time.GlobalTime;
-
-/**
- * @author Roberto E. Escobar
- */
-public class JoinUtility {
-
- private static final String INSERT_INTO_JOIN_ARTIFACT =
- "INSERT INTO osee_join_artifact (query_id, insert_time, art_id, branch_id) VALUES (?, ?, ?, ?)";
-
- private static final String INSERT_INTO_JOIN_TRANSACTION =
- "INSERT INTO osee_join_transaction (query_id, insert_time, gamma_id, transaction_id) VALUES (?, ?, ?, ?)";
-
- private static final String INSERT_INTO_JOIN_SEARCH_TAGS =
- "INSERT INTO osee_join_search_tags (query_id, insert_time, coded_tag_id) VALUES (?, ?, ?)";
-
- private static final String INSERT_INTO_TAG_GAMMA_QUEUE =
- "INSERT INTO osee_tag_gamma_queue (query_id, insert_time, gamma_id) VALUES (?, ?, ?)";
-
- private static final String INSERT_INTO_JOIN_EXPORT_IMPORT =
- "INSERT INTO osee_join_export_import (query_id, insert_time, id1, id2) VALUES (?, ?, ?, ?)";
- private static final String INSERT_INTO_JOIN_ID =
- "INSERT INTO osee_join_id (query_id, insert_time, id) VALUES (?, ?, ?)";
-
- private static final String INSERT_INTO_JOIN_CLEANUP =
- "INSERT INTO osee_join_cleanup (query_id, table_name, session_id) VALUES (?, ?, ?)";
-
- private static final String INSERT_INTO_JOIN_CHAR_ID = "INSERT INTO osee_join_char_id (query_id, id) VALUES (?, ?)";
-
- private static final String DELETE_FROM_JOIN_ID = "DELETE FROM osee_join_id WHERE query_id = ?";
- private static final String DELETE_FROM_JOIN_TRANSACTION = "DELETE FROM osee_join_transaction WHERE query_id = ?";
- private static final String DELETE_FROM_JOIN_ARTIFACT = "DELETE FROM osee_join_artifact WHERE query_id = ?";
- private static final String DELETE_FROM_JOIN_SEARCH_TAGS = "DELETE FROM osee_join_search_tags WHERE query_id = ?";
- private static final String DELETE_FROM_TAG_GAMMA_QUEUE = "DELETE FROM osee_tag_gamma_queue WHERE query_id = ?";
- private static final String DELETE_FROM_JOIN_EXPORT_IMPORT = "DELETE FROM osee_join_export_import WHERE query_id =?";
- private static final String DELETE_FROM_JOIN = "DELETE FROM osee_join_cleanup WHERE query_id =?";
- private static final String DELETE_FROM_JOIN_CHAR_ID = "DELETE FROM osee_join_char_id WHERE query_id =?";
- private static final String SELECT_TAG_GAMMA_QUEUE_QUERIES = "select DISTINCT query_id from osee_tag_gamma_queue";
- private static final Random random = new Random();
-
- public enum JoinItem {
- TRANSACTION(INSERT_INTO_JOIN_TRANSACTION, DELETE_FROM_JOIN_TRANSACTION),
- ARTIFACT(INSERT_INTO_JOIN_ARTIFACT, DELETE_FROM_JOIN_ARTIFACT),
- SEARCH_TAGS(INSERT_INTO_JOIN_SEARCH_TAGS, DELETE_FROM_JOIN_SEARCH_TAGS),
- TAG_GAMMA_QUEUE(INSERT_INTO_TAG_GAMMA_QUEUE, DELETE_FROM_TAG_GAMMA_QUEUE),
- EXPORT_IMPORT(INSERT_INTO_JOIN_EXPORT_IMPORT, DELETE_FROM_JOIN_EXPORT_IMPORT),
- ID(INSERT_INTO_JOIN_ID, DELETE_FROM_JOIN_ID),
- JOIN(INSERT_INTO_JOIN_CLEANUP, DELETE_FROM_JOIN),
- CHAR_ID(INSERT_INTO_JOIN_CHAR_ID, DELETE_FROM_JOIN_CHAR_ID);
-
- private final String deleteSql;
- private final String insertSql;
-
- JoinItem(String insertSql, String deleteSql) {
- this.deleteSql = deleteSql;
- this.insertSql = insertSql;
- }
-
- String getDeleteSql() {
- return deleteSql;
- }
-
- String getInsertSql() {
- return insertSql;
- }
- }
-
- private JoinUtility() {
- }
-
- public static int getNewQueryId() {
- return random.nextInt();
- }
-
- public static TransactionJoinQuery createTransactionJoinQuery() {
- return new TransactionJoinQuery(null);
- }
-
- public static IdJoinQuery createIdJoinQuery() {
- return new IdJoinQuery(null);
- }
-
- public static ArtifactJoinQuery createArtifactJoinQuery() {
- return new ArtifactJoinQuery(null);
- }
-
- public static SearchTagJoinQuery createSearchTagJoinQuery() {
- return new SearchTagJoinQuery(null);
- }
-
- public static TagQueueJoinQuery createTagQueueJoinQuery() {
- return new TagQueueJoinQuery(null);
- }
-
- public static ExportImportJoinQuery createExportImportJoinQuery() {
- return new ExportImportJoinQuery(null);
- }
-
- public static CharJoinQuery createCharJoinQuery(String sessionId) {
- return new CharJoinQuery(sessionId);
- }
-
- public static List<Integer> getAllTagQueueQueryIds() throws OseeDataStoreException {
- List<Integer> queryIds = new ArrayList<Integer>();
- IOseeStatement chStmt = ConnectionHandler.getStatement();
- try {
- chStmt.runPreparedQuery(SELECT_TAG_GAMMA_QUEUE_QUERIES);
- while (chStmt.next()) {
- queryIds.add(chStmt.getInt("query_id"));
- }
- } finally {
- chStmt.close();
- }
- return queryIds;
- }
- public static abstract class JoinQueryEntry {
- public final JoinItem joinItem;
- private final int queryId;
- private final Timestamp insertTime;
- protected Set<IJoinRow> entries;
- private boolean wasStored;
- private int storedSize;
- private final String sessionId;
-
- protected JoinQueryEntry(JoinItem joinItem, String sessionId) {
- this.wasStored = false;
- this.joinItem = joinItem;
- this.queryId = getNewQueryId();
- this.insertTime = GlobalTime.GreenwichMeanTimestamp();
- this.entries = new HashSet<IJoinRow>();
- this.storedSize = -1;
- this.sessionId = sessionId;
- }
-
- public abstract String getJoinTableName();
-
- public boolean isEmpty() {
- return this.wasStored != true ? entries.isEmpty() : this.storedSize > 0;
- }
-
- public int size() {
- return this.wasStored != true ? entries.size() : this.storedSize;
- }
-
- public int getQueryId() {
- return queryId;
- }
-
- public Timestamp getInsertTime() {
- return insertTime;
- }
-
- @SuppressWarnings("unchecked")
- public void store(OseeConnection connection) throws OseeDataStoreException {
- if (this.wasStored != true) {
- List<Object[]> data = new ArrayList<Object[]>();
- for (IJoinRow joinArray : entries) {
- data.add(joinArray.toArray());
- }
- ConnectionHandler.runBatchUpdate(connection, joinItem.getInsertSql(), data);
- if (sessionId != null) {
- Activator.getInstance().getOseeDatabaseService().runPreparedUpdate(connection, INSERT_INTO_JOIN_CLEANUP,
- getQueryId(), getJoinTableName(), sessionId);
- }
- this.storedSize = this.entries.size();
- this.wasStored = true;
- this.entries.clear();
- } else {
- throw new OseeDataStoreException("Cannot store query id twice");
- }
- }
-
- public int delete(OseeConnection connection) throws OseeDataStoreException {
- int updated = 0;
- IOseeDatabaseService databaseService = Activator.getInstance().getOseeDatabaseService();
- if (queryId != -1) {
- updated = databaseService.runPreparedUpdate(connection, joinItem.getDeleteSql(), queryId);
- if (sessionId != null) {
- databaseService.runPreparedUpdate(connection, DELETE_FROM_JOIN, getQueryId());
- }
- }
- return updated;
- }
-
- public void store() throws OseeDataStoreException {
- store(null);
- }
-
- public int delete() throws OseeDataStoreException {
- return delete(null);
- }
-
- @Override
- public String toString() {
- return String.format("id: [%s] entrySize: [%d]", getQueryId(), size());
- }
- }
-
- public static void deleteQuery(OseeConnection connection, JoinItem item, int queryId) throws Exception {
- if (item != null) {
- ConnectionHandler.runPreparedUpdate(connection, item.getDeleteSql(), queryId);
- }
- }
-
- public static void deleteQuery(JoinItem item, int queryId) throws Exception {
- if (item != null) {
- ConnectionHandler.runPreparedUpdate(item.getDeleteSql(), queryId);
- }
- }
-
- private interface IJoinRow {
- public Object[] toArray();
-
- public String toString();
- }
-
- public static final class IdJoinQuery extends JoinQueryEntry {
-
- private final class TempIdEntry implements IJoinRow {
- private final int id;
-
- private TempIdEntry(Integer id) {
- this.id = id;
- }
-
- public Object[] toArray() {
- return new Object[] {getQueryId(), getInsertTime(), id};
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if (!(obj instanceof TempIdEntry)) {
- return false;
- }
- TempIdEntry other = (TempIdEntry) obj;
- return other.id == this.id;
- }
-
- @Override
- public int hashCode() {
- return 37 * id;
- }
-
- @Override
- public String toString() {
- return "id = " + id;
- }
- }
-
- private IdJoinQuery(String sessionId) {
- super(JoinItem.ID, sessionId);
- }
-
- public void add(Integer id) {
- entries.add(new TempIdEntry(id));
- }
-
- @Override
- public String getJoinTableName() {
- return "osee_join_id";
- }
- }
-
- public static final class TransactionJoinQuery extends JoinQueryEntry {
-
- private final class TempTransactionEntry implements IJoinRow {
- private final long gammaId;
- private final int transactionId;
-
- private TempTransactionEntry(Long gammaId, Integer transactionId) {
- this.gammaId = gammaId;
- this.transactionId = transactionId;
- }
-
- public Object[] toArray() {
- return new Object[] {getQueryId(), getInsertTime(), gammaId, transactionId};
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if (!(obj instanceof TempTransactionEntry)) {
- return false;
- }
- TempTransactionEntry other = (TempTransactionEntry) obj;
- return other.gammaId == this.gammaId && other.transactionId == this.transactionId;
- }
-
- @Override
- public int hashCode() {
- return Long.valueOf(37 * gammaId * transactionId).hashCode();
- }
-
- @Override
- public String toString() {
- return String.format("gamma_id=%s, tx_id=%s", gammaId, transactionId);
- }
- }
-
- private TransactionJoinQuery(String sessionId) {
- super(JoinItem.TRANSACTION, sessionId);
- }
-
- public void add(Long gammaId, Integer transactionId) {
- entries.add(new TempTransactionEntry(gammaId, transactionId));
- }
-
- @Override
- public String getJoinTableName() {
- return "osee_join_transaction";
- }
- }
-
- public static final class ArtifactJoinQuery extends JoinQueryEntry {
-
- private final class Entry implements IJoinRow {
- private final int artId;
- private final int branchId;
-
- private Entry(Integer artId, Integer branchId) {
- this.artId = artId;
- this.branchId = branchId;
- }
-
- public Object[] toArray() {
- return new Object[] {getQueryId(), getInsertTime(), artId, branchId};
- }
-
- @Override
- public String toString() {
- return String.format("art_id=%s, branch_id=%s", artId, branchId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if (!(obj instanceof Entry)) {
- return false;
- }
- Entry other = (Entry) obj;
- return other.artId == this.artId && other.branchId == this.branchId;
- }
-
- @Override
- public int hashCode() {
- return 37 * artId * branchId;
- }
- }
-
- private ArtifactJoinQuery(String sessionId) {
- super(JoinItem.ARTIFACT, sessionId);
- }
-
- public void add(Integer art_id, Integer branchId) {
- entries.add(new Entry(art_id, branchId));
- }
-
- @Override
- public String getJoinTableName() {
- return "osee_join_artifact";
- }
- }
-
- public static final class SearchTagJoinQuery extends JoinQueryEntry {
-
- private final class TagEntry implements IJoinRow {
- private final long value;
-
- private TagEntry(Long value) {
- this.value = value;
- }
-
- public Object[] toArray() {
- return new Object[] {getQueryId(), getInsertTime(), value};
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if (!(obj instanceof TagEntry)) {
- return false;
- }
- TagEntry other = (TagEntry) obj;
- return this.value == other.value;
- }
-
- @Override
- public int hashCode() {
- return Long.valueOf(37 * value).hashCode();
- }
-
- @Override
- public String toString() {
- return String.format("tag=%s", value);
- }
- }
-
- private SearchTagJoinQuery(String sessionId) {
- super(JoinItem.SEARCH_TAGS, sessionId);
- }
-
- public void add(Long tag) {
- entries.add(new TagEntry(tag));
- }
-
- @Override
- public String getJoinTableName() {
- return "osee_join_search_tags";
- }
- }
-
- public static final class TagQueueJoinQuery extends JoinQueryEntry {
-
- private final class GammaEntry implements IJoinRow {
- private final long gammaId;
-
- private GammaEntry(Long gammaId) {
- this.gammaId = gammaId;
- }
-
- public Object[] toArray() {
- return new Object[] {getQueryId(), getInsertTime(), gammaId};
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if (!(obj instanceof GammaEntry)) {
- return false;
- }
- GammaEntry other = (GammaEntry) obj;
- return this.gammaId == other.gammaId;
- }
-
- @Override
- public int hashCode() {
- return Long.valueOf(37 * gammaId).hashCode();
- }
-
- @Override
- public String toString() {
- return String.format("gammaId=%s", gammaId);
- }
- }
-
- private TagQueueJoinQuery(String sessionId) {
- super(JoinItem.TAG_GAMMA_QUEUE, sessionId);
- }
-
- public void add(Long gammaId) {
- entries.add(new GammaEntry(gammaId));
- }
-
- @Override
- public String getJoinTableName() {
- return "osee_tag_gamma_queue";
- }
- }
-
- public static final class ExportImportJoinQuery extends JoinQueryEntry {
-
- private final class ExportImportEntry implements IJoinRow {
- private final long id1;
- private final long id2;
-
- private ExportImportEntry(Long id1, Long id2) {
- this.id1 = id1;
- this.id2 = id2;
- }
-
- public Object[] toArray() {
- return new Object[] {getQueryId(), getInsertTime(), id1, id2};
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if (!(obj instanceof ExportImportEntry)) {
- return false;
- }
- ExportImportEntry other = (ExportImportEntry) obj;
- return this.id1 == other.id1 && this.id2 == other.id2;
- }
-
- @Override
- public int hashCode() {
- return Long.valueOf(37 * id1 * id2).hashCode();
- }
-
- @Override
- public String toString() {
- return String.format("id1=%s id2=%s", id1, id2);
- }
- }
-
- private ExportImportJoinQuery(String sessionId) {
- super(JoinItem.EXPORT_IMPORT, sessionId);
- }
-
- public void add(Long id1, Long id2) {
- entries.add(new ExportImportEntry(id1, id2));
- }
-
- @Override
- public String getJoinTableName() {
- return null;
- }
- }
-
- public static final class CharJoinQuery extends JoinQueryEntry {
-
- protected CharJoinQuery(String sessionId) {
- super(JoinItem.CHAR_ID, sessionId);
- }
-
- private final class CharJoinEntry implements IJoinRow {
- private final String value;
-
- private CharJoinEntry(String value) {
- this.value = value;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[] {getQueryId(), value};
- }
-
- @Override
- public int hashCode() {
- return 37 * value.hashCode();
- }
-
- @Override
- public String toString() {
- return value;
- }
-
- }
-
- public void add(String value) {
- entries.add(new CharJoinEntry(value));
- }
-
- @Override
- public String getJoinTableName() {
- return "osee_join_char_id";
- }
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.database.core;
+
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Random;
+import java.util.Set;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
+import org.eclipse.osee.framework.database.internal.Activator;
+import org.eclipse.osee.framework.jdk.core.util.time.GlobalTime;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class JoinUtility {
+
+ private static final String INSERT_INTO_JOIN_ARTIFACT =
+ "INSERT INTO osee_join_artifact (query_id, insert_time, art_id, branch_id) VALUES (?, ?, ?, ?)";
+
+ private static final String INSERT_INTO_JOIN_TRANSACTION =
+ "INSERT INTO osee_join_transaction (query_id, insert_time, gamma_id, transaction_id) VALUES (?, ?, ?, ?)";
+
+ private static final String INSERT_INTO_JOIN_SEARCH_TAGS =
+ "INSERT INTO osee_join_search_tags (query_id, insert_time, coded_tag_id) VALUES (?, ?, ?)";
+
+ private static final String INSERT_INTO_TAG_GAMMA_QUEUE =
+ "INSERT INTO osee_tag_gamma_queue (query_id, insert_time, gamma_id) VALUES (?, ?, ?)";
+
+ private static final String INSERT_INTO_JOIN_EXPORT_IMPORT =
+ "INSERT INTO osee_join_export_import (query_id, insert_time, id1, id2) VALUES (?, ?, ?, ?)";
+ private static final String INSERT_INTO_JOIN_ID =
+ "INSERT INTO osee_join_id (query_id, insert_time, id) VALUES (?, ?, ?)";
+
+ private static final String INSERT_INTO_JOIN_CLEANUP =
+ "INSERT INTO osee_join_cleanup (query_id, table_name, session_id) VALUES (?, ?, ?)";
+
+ private static final String INSERT_INTO_JOIN_CHAR_ID = "INSERT INTO osee_join_char_id (query_id, id) VALUES (?, ?)";
+
+ private static final String DELETE_FROM_JOIN_ID = "DELETE FROM osee_join_id WHERE query_id = ?";
+ private static final String DELETE_FROM_JOIN_TRANSACTION = "DELETE FROM osee_join_transaction WHERE query_id = ?";
+ private static final String DELETE_FROM_JOIN_ARTIFACT = "DELETE FROM osee_join_artifact WHERE query_id = ?";
+ private static final String DELETE_FROM_JOIN_SEARCH_TAGS = "DELETE FROM osee_join_search_tags WHERE query_id = ?";
+ private static final String DELETE_FROM_TAG_GAMMA_QUEUE = "DELETE FROM osee_tag_gamma_queue WHERE query_id = ?";
+ private static final String DELETE_FROM_JOIN_EXPORT_IMPORT = "DELETE FROM osee_join_export_import WHERE query_id =?";
+ private static final String DELETE_FROM_JOIN = "DELETE FROM osee_join_cleanup WHERE query_id =?";
+ private static final String DELETE_FROM_JOIN_CHAR_ID = "DELETE FROM osee_join_char_id WHERE query_id =?";
+ private static final String SELECT_TAG_GAMMA_QUEUE_QUERIES = "select DISTINCT query_id from osee_tag_gamma_queue";
+ private static final Random random = new Random();
+
+ public enum JoinItem {
+ TRANSACTION(INSERT_INTO_JOIN_TRANSACTION, DELETE_FROM_JOIN_TRANSACTION),
+ ARTIFACT(INSERT_INTO_JOIN_ARTIFACT, DELETE_FROM_JOIN_ARTIFACT),
+ SEARCH_TAGS(INSERT_INTO_JOIN_SEARCH_TAGS, DELETE_FROM_JOIN_SEARCH_TAGS),
+ TAG_GAMMA_QUEUE(INSERT_INTO_TAG_GAMMA_QUEUE, DELETE_FROM_TAG_GAMMA_QUEUE),
+ EXPORT_IMPORT(INSERT_INTO_JOIN_EXPORT_IMPORT, DELETE_FROM_JOIN_EXPORT_IMPORT),
+ ID(INSERT_INTO_JOIN_ID, DELETE_FROM_JOIN_ID),
+ JOIN(INSERT_INTO_JOIN_CLEANUP, DELETE_FROM_JOIN),
+ CHAR_ID(INSERT_INTO_JOIN_CHAR_ID, DELETE_FROM_JOIN_CHAR_ID);
+
+ private final String deleteSql;
+ private final String insertSql;
+
+ JoinItem(String insertSql, String deleteSql) {
+ this.deleteSql = deleteSql;
+ this.insertSql = insertSql;
+ }
+
+ String getDeleteSql() {
+ return deleteSql;
+ }
+
+ String getInsertSql() {
+ return insertSql;
+ }
+ }
+
+ private JoinUtility() {
+ }
+
+ public static int getNewQueryId() {
+ return random.nextInt();
+ }
+
+ public static TransactionJoinQuery createTransactionJoinQuery() {
+ return new TransactionJoinQuery(null);
+ }
+
+ public static IdJoinQuery createIdJoinQuery() {
+ return new IdJoinQuery(null);
+ }
+
+ public static ArtifactJoinQuery createArtifactJoinQuery() {
+ return new ArtifactJoinQuery(null);
+ }
+
+ public static SearchTagJoinQuery createSearchTagJoinQuery() {
+ return new SearchTagJoinQuery(null);
+ }
+
+ public static TagQueueJoinQuery createTagQueueJoinQuery() {
+ return new TagQueueJoinQuery(null);
+ }
+
+ public static ExportImportJoinQuery createExportImportJoinQuery() {
+ return new ExportImportJoinQuery(null);
+ }
+
+ public static CharJoinQuery createCharJoinQuery(String sessionId) {
+ return new CharJoinQuery(sessionId);
+ }
+
+ public static List<Integer> getAllTagQueueQueryIds() throws OseeDataStoreException {
+ List<Integer> queryIds = new ArrayList<Integer>();
+ IOseeStatement chStmt = ConnectionHandler.getStatement();
+ try {
+ chStmt.runPreparedQuery(SELECT_TAG_GAMMA_QUEUE_QUERIES);
+ while (chStmt.next()) {
+ queryIds.add(chStmt.getInt("query_id"));
+ }
+ } finally {
+ chStmt.close();
+ }
+ return queryIds;
+ }
+ public static abstract class JoinQueryEntry {
+ public final JoinItem joinItem;
+ private final int queryId;
+ private final Timestamp insertTime;
+ protected Set<IJoinRow> entries;
+ private boolean wasStored;
+ private int storedSize;
+ private final String sessionId;
+
+ protected JoinQueryEntry(JoinItem joinItem, String sessionId) {
+ this.wasStored = false;
+ this.joinItem = joinItem;
+ this.queryId = getNewQueryId();
+ this.insertTime = GlobalTime.GreenwichMeanTimestamp();
+ this.entries = new HashSet<IJoinRow>();
+ this.storedSize = -1;
+ this.sessionId = sessionId;
+ }
+
+ public abstract String getJoinTableName();
+
+ public boolean isEmpty() {
+ return this.wasStored != true ? entries.isEmpty() : this.storedSize > 0;
+ }
+
+ public int size() {
+ return this.wasStored != true ? entries.size() : this.storedSize;
+ }
+
+ public int getQueryId() {
+ return queryId;
+ }
+
+ public Timestamp getInsertTime() {
+ return insertTime;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void store(OseeConnection connection) throws OseeDataStoreException {
+ if (this.wasStored != true) {
+ List<Object[]> data = new ArrayList<Object[]>();
+ for (IJoinRow joinArray : entries) {
+ data.add(joinArray.toArray());
+ }
+ ConnectionHandler.runBatchUpdate(connection, joinItem.getInsertSql(), data);
+ if (sessionId != null) {
+ Activator.getInstance().getOseeDatabaseService().runPreparedUpdate(connection, INSERT_INTO_JOIN_CLEANUP,
+ getQueryId(), getJoinTableName(), sessionId);
+ }
+ this.storedSize = this.entries.size();
+ this.wasStored = true;
+ this.entries.clear();
+ } else {
+ throw new OseeDataStoreException("Cannot store query id twice");
+ }
+ }
+
+ public int delete(OseeConnection connection) throws OseeDataStoreException {
+ int updated = 0;
+ IOseeDatabaseService databaseService = Activator.getInstance().getOseeDatabaseService();
+ if (queryId != -1) {
+ updated = databaseService.runPreparedUpdate(connection, joinItem.getDeleteSql(), queryId);
+ if (sessionId != null) {
+ databaseService.runPreparedUpdate(connection, DELETE_FROM_JOIN, getQueryId());
+ }
+ }
+ return updated;
+ }
+
+ public void store() throws OseeDataStoreException {
+ store(null);
+ }
+
+ public int delete() throws OseeDataStoreException {
+ return delete(null);
+ }
+
+ @Override
+ public String toString() {
+ return String.format("id: [%s] entrySize: [%d]", getQueryId(), size());
+ }
+ }
+
+ public static void deleteQuery(OseeConnection connection, JoinItem item, int queryId) throws Exception {
+ if (item != null) {
+ ConnectionHandler.runPreparedUpdate(connection, item.getDeleteSql(), queryId);
+ }
+ }
+
+ public static void deleteQuery(JoinItem item, int queryId) throws Exception {
+ if (item != null) {
+ ConnectionHandler.runPreparedUpdate(item.getDeleteSql(), queryId);
+ }
+ }
+
+ private interface IJoinRow {
+ public Object[] toArray();
+
+ public String toString();
+ }
+
+ public static final class IdJoinQuery extends JoinQueryEntry {
+
+ private final class TempIdEntry implements IJoinRow {
+ private final int id;
+
+ private TempIdEntry(Integer id) {
+ this.id = id;
+ }
+
+ public Object[] toArray() {
+ return new Object[] {getQueryId(), getInsertTime(), id};
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof TempIdEntry)) {
+ return false;
+ }
+ TempIdEntry other = (TempIdEntry) obj;
+ return other.id == this.id;
+ }
+
+ @Override
+ public int hashCode() {
+ return 37 * id;
+ }
+
+ @Override
+ public String toString() {
+ return "id = " + id;
+ }
+ }
+
+ private IdJoinQuery(String sessionId) {
+ super(JoinItem.ID, sessionId);
+ }
+
+ public void add(Integer id) {
+ entries.add(new TempIdEntry(id));
+ }
+
+ @Override
+ public String getJoinTableName() {
+ return "osee_join_id";
+ }
+ }
+
+ public static final class TransactionJoinQuery extends JoinQueryEntry {
+
+ private final class TempTransactionEntry implements IJoinRow {
+ private final long gammaId;
+ private final int transactionId;
+
+ private TempTransactionEntry(Long gammaId, Integer transactionId) {
+ this.gammaId = gammaId;
+ this.transactionId = transactionId;
+ }
+
+ public Object[] toArray() {
+ return new Object[] {getQueryId(), getInsertTime(), gammaId, transactionId};
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof TempTransactionEntry)) {
+ return false;
+ }
+ TempTransactionEntry other = (TempTransactionEntry) obj;
+ return other.gammaId == this.gammaId && other.transactionId == this.transactionId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Long.valueOf(37 * gammaId * transactionId).hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return String.format("gamma_id=%s, tx_id=%s", gammaId, transactionId);
+ }
+ }
+
+ private TransactionJoinQuery(String sessionId) {
+ super(JoinItem.TRANSACTION, sessionId);
+ }
+
+ public void add(Long gammaId, Integer transactionId) {
+ entries.add(new TempTransactionEntry(gammaId, transactionId));
+ }
+
+ @Override
+ public String getJoinTableName() {
+ return "osee_join_transaction";
+ }
+ }
+
+ public static final class ArtifactJoinQuery extends JoinQueryEntry {
+
+ private final class Entry implements IJoinRow {
+ private final int artId;
+ private final int branchId;
+
+ private Entry(Integer artId, Integer branchId) {
+ this.artId = artId;
+ this.branchId = branchId;
+ }
+
+ public Object[] toArray() {
+ return new Object[] {getQueryId(), getInsertTime(), artId, branchId};
+ }
+
+ @Override
+ public String toString() {
+ return String.format("art_id=%s, branch_id=%s", artId, branchId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof Entry)) {
+ return false;
+ }
+ Entry other = (Entry) obj;
+ return other.artId == this.artId && other.branchId == this.branchId;
+ }
+
+ @Override
+ public int hashCode() {
+ return 37 * artId * branchId;
+ }
+ }
+
+ private ArtifactJoinQuery(String sessionId) {
+ super(JoinItem.ARTIFACT, sessionId);
+ }
+
+ public void add(Integer art_id, Integer branchId) {
+ entries.add(new Entry(art_id, branchId));
+ }
+
+ @Override
+ public String getJoinTableName() {
+ return "osee_join_artifact";
+ }
+ }
+
+ public static final class SearchTagJoinQuery extends JoinQueryEntry {
+
+ private final class TagEntry implements IJoinRow {
+ private final long value;
+
+ private TagEntry(Long value) {
+ this.value = value;
+ }
+
+ public Object[] toArray() {
+ return new Object[] {getQueryId(), getInsertTime(), value};
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof TagEntry)) {
+ return false;
+ }
+ TagEntry other = (TagEntry) obj;
+ return this.value == other.value;
+ }
+
+ @Override
+ public int hashCode() {
+ return Long.valueOf(37 * value).hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return String.format("tag=%s", value);
+ }
+ }
+
+ private SearchTagJoinQuery(String sessionId) {
+ super(JoinItem.SEARCH_TAGS, sessionId);
+ }
+
+ public void add(Long tag) {
+ entries.add(new TagEntry(tag));
+ }
+
+ @Override
+ public String getJoinTableName() {
+ return "osee_join_search_tags";
+ }
+ }
+
+ public static final class TagQueueJoinQuery extends JoinQueryEntry {
+
+ private final class GammaEntry implements IJoinRow {
+ private final long gammaId;
+
+ private GammaEntry(Long gammaId) {
+ this.gammaId = gammaId;
+ }
+
+ public Object[] toArray() {
+ return new Object[] {getQueryId(), getInsertTime(), gammaId};
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof GammaEntry)) {
+ return false;
+ }
+ GammaEntry other = (GammaEntry) obj;
+ return this.gammaId == other.gammaId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Long.valueOf(37 * gammaId).hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return String.format("gammaId=%s", gammaId);
+ }
+ }
+
+ private TagQueueJoinQuery(String sessionId) {
+ super(JoinItem.TAG_GAMMA_QUEUE, sessionId);
+ }
+
+ public void add(Long gammaId) {
+ entries.add(new GammaEntry(gammaId));
+ }
+
+ @Override
+ public String getJoinTableName() {
+ return "osee_tag_gamma_queue";
+ }
+ }
+
+ public static final class ExportImportJoinQuery extends JoinQueryEntry {
+
+ private final class ExportImportEntry implements IJoinRow {
+ private final long id1;
+ private final long id2;
+
+ private ExportImportEntry(Long id1, Long id2) {
+ this.id1 = id1;
+ this.id2 = id2;
+ }
+
+ public Object[] toArray() {
+ return new Object[] {getQueryId(), getInsertTime(), id1, id2};
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof ExportImportEntry)) {
+ return false;
+ }
+ ExportImportEntry other = (ExportImportEntry) obj;
+ return this.id1 == other.id1 && this.id2 == other.id2;
+ }
+
+ @Override
+ public int hashCode() {
+ return Long.valueOf(37 * id1 * id2).hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return String.format("id1=%s id2=%s", id1, id2);
+ }
+ }
+
+ private ExportImportJoinQuery(String sessionId) {
+ super(JoinItem.EXPORT_IMPORT, sessionId);
+ }
+
+ public void add(Long id1, Long id2) {
+ entries.add(new ExportImportEntry(id1, id2));
+ }
+
+ @Override
+ public String getJoinTableName() {
+ return null;
+ }
+ }
+
+ public static final class CharJoinQuery extends JoinQueryEntry {
+
+ protected CharJoinQuery(String sessionId) {
+ super(JoinItem.CHAR_ID, sessionId);
+ }
+
+ private final class CharJoinEntry implements IJoinRow {
+ private final String value;
+
+ private CharJoinEntry(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public Object[] toArray() {
+ return new Object[] {getQueryId(), value};
+ }
+
+ @Override
+ public int hashCode() {
+ return 37 * value.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return value;
+ }
+
+ }
+
+ public void add(String value) {
+ entries.add(new CharJoinEntry(value));
+ }
+
+ @Override
+ public String getJoinTableName() {
+ return "osee_join_char_id";
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/OseeConnection.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/OseeConnection.java
index e82ebcf38f..ac1e8838ca 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/OseeConnection.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/OseeConnection.java
@@ -1,41 +1,41 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database.core;
-
-import java.io.Closeable;
-import java.sql.DatabaseMetaData;
-import java.sql.SQLException;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-
-public abstract class OseeConnection implements Closeable{
-
- protected OseeConnection() {
-
- }
-
- public abstract void close();
-
- public abstract boolean isClosed() throws OseeDataStoreException;
-
- public abstract boolean isStale();
-
- public abstract DatabaseMetaData getMetaData() throws OseeDataStoreException;
-
- protected abstract void setAutoCommit(boolean autoCommit) throws OseeDataStoreException;
-
- protected abstract boolean getAutoCommit() throws SQLException;
-
- protected abstract void commit() throws SQLException;
-
- protected abstract void rollback() throws OseeDataStoreException;
-
- protected abstract void destroy() throws OseeDataStoreException;
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.database.core;
+
+import java.io.Closeable;
+import java.sql.DatabaseMetaData;
+import java.sql.SQLException;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+
+public abstract class OseeConnection implements Closeable{
+
+ protected OseeConnection() {
+
+ }
+
+ public abstract void close();
+
+ public abstract boolean isClosed() throws OseeDataStoreException;
+
+ public abstract boolean isStale();
+
+ public abstract DatabaseMetaData getMetaData() throws OseeDataStoreException;
+
+ protected abstract void setAutoCommit(boolean autoCommit) throws OseeDataStoreException;
+
+ protected abstract boolean getAutoCommit() throws SQLException;
+
+ protected abstract void commit() throws SQLException;
+
+ protected abstract void rollback() throws OseeDataStoreException;
+
+ protected abstract void destroy() throws OseeDataStoreException;
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/OseeInfo.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/OseeInfo.java
index 09cecb8e84..c0e5b0a55e 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/OseeInfo.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/OseeInfo.java
@@ -1,57 +1,57 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database.core;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-
-/**
- * @author Donald G. Dunne
- */
-public class OseeInfo {
- private static final String GET_VALUE_SQL = "Select OSEE_VALUE FROM osee_info where OSEE_KEY = ?";
- private static final String INSERT_KEY_VALUE_SQL = "INSERT INTO osee_info (OSEE_KEY, OSEE_VALUE) VALUES (?, ?)";
- private static final String DELETE_KEY_SQL = "DELETE FROM osee_info WHERE OSEE_KEY = ?";
- public static final String SAVE_OUTFILE_IN_DB = "SAVE_OUTFILE_IN_DB";
- public static final String USE_GUID_STORAGE = "osee.framework.skynet.core.guid.storage";
- // This is a unique identifier generated upon database initialization and should never be changed once it has been created.
- public static final String DB_ID_KEY = "osee.db.guid";
- public static final String DB_TYPE_KEY = "osee.db.type";
-
- private static Map<String, String> cache = new HashMap<String, String>();
-
- public static String getValue(String key) throws OseeDataStoreException {
- String toReturn = ConnectionHandler.runPreparedQueryFetchString("", GET_VALUE_SQL, key);
- cache.put(key, toReturn);
- return toReturn;
- }
-
- public static String getCachedValue(String key) throws OseeDataStoreException {
- String cacheValue = cache.get(key);
- if (cacheValue == null) {
- cacheValue = getValue(key);
- cache.put(key, cacheValue);
- }
-
- return cacheValue;
- }
-
- public static void putValue(String key, String value) throws OseeDataStoreException {
- ConnectionHandler.runPreparedUpdate(DELETE_KEY_SQL, key);
- ConnectionHandler.runPreparedUpdate(INSERT_KEY_VALUE_SQL, key, value);
- cache.put(key, value);
- }
-
- public static String getDatabaseGuid() throws OseeDataStoreException {
- return getValue(DB_ID_KEY);
- }
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.database.core;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class OseeInfo {
+ private static final String GET_VALUE_SQL = "Select OSEE_VALUE FROM osee_info where OSEE_KEY = ?";
+ private static final String INSERT_KEY_VALUE_SQL = "INSERT INTO osee_info (OSEE_KEY, OSEE_VALUE) VALUES (?, ?)";
+ private static final String DELETE_KEY_SQL = "DELETE FROM osee_info WHERE OSEE_KEY = ?";
+ public static final String SAVE_OUTFILE_IN_DB = "SAVE_OUTFILE_IN_DB";
+ public static final String USE_GUID_STORAGE = "osee.framework.skynet.core.guid.storage";
+ // This is a unique identifier generated upon database initialization and should never be changed once it has been created.
+ public static final String DB_ID_KEY = "osee.db.guid";
+ public static final String DB_TYPE_KEY = "osee.db.type";
+
+ private static Map<String, String> cache = new HashMap<String, String>();
+
+ public static String getValue(String key) throws OseeDataStoreException {
+ String toReturn = ConnectionHandler.runPreparedQueryFetchString("", GET_VALUE_SQL, key);
+ cache.put(key, toReturn);
+ return toReturn;
+ }
+
+ public static String getCachedValue(String key) throws OseeDataStoreException {
+ String cacheValue = cache.get(key);
+ if (cacheValue == null) {
+ cacheValue = getValue(key);
+ cache.put(key, cacheValue);
+ }
+
+ return cacheValue;
+ }
+
+ public static void putValue(String key, String value) throws OseeDataStoreException {
+ ConnectionHandler.runPreparedUpdate(DELETE_KEY_SQL, key);
+ ConnectionHandler.runPreparedUpdate(INSERT_KEY_VALUE_SQL, key, value);
+ cache.put(key, value);
+ }
+
+ public static String getDatabaseGuid() throws OseeDataStoreException {
+ return getValue(DB_ID_KEY);
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ResultSetProcessor.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ResultSetProcessor.java
index 56a2993a7e..0e9de71c90 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ResultSetProcessor.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ResultSetProcessor.java
@@ -1,91 +1,91 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database.core;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.sql.Date;
-import java.sql.Timestamp;
-import java.sql.Types;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.jdk.core.type.IVariantData;
-import org.eclipse.osee.framework.jdk.core.type.VariantData;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-
-/**
- * @author Roberto E. Escobar
- */
-public class ResultSetProcessor {
- public static IVariantData parse(IOseeStatement chStmt) throws OseeDataStoreException {
- IVariantData toReturn = new VariantData();
- int numberOfColumns = chStmt.getColumnCount() + 1;
- for (int index = 1; index < numberOfColumns; index++) {
- int columnIndex = index;
- int type = chStmt.getColumnType(columnIndex);
- String name = chStmt.getColumnName(columnIndex);
- // Store name - all upper case
- String upperCasedName = name.toUpperCase();
- switch (type) {
- case Types.CLOB:
- case Types.BINARY:
- InputStream inputStream = chStmt.getAsciiStream(name);
- toReturn.put(upperCasedName, streamToByteArray(inputStream));
- break;
- case Types.BLOB:
- InputStream blobStream = chStmt.getBinaryStream(name);
- toReturn.put(upperCasedName, streamToByteArray(blobStream));
- break;
- case Types.TIMESTAMP:
- Timestamp timeStamp = chStmt.getTimestamp(name);
- if (timeStamp != null) {
- toReturn.put(upperCasedName, timeStamp.getTime());
- }
- break;
- case Types.DATE:
- Date date = chStmt.getDate(name);
- if (date != null) {
- toReturn.put(upperCasedName, date.getTime());
- }
- break;
- default:
- try {
- String value = chStmt.getString(name);
- if (Strings.isValid(value) != false) {
- value = value.trim();
- }
- toReturn.put(upperCasedName, chStmt.getString(name));
- } catch (OseeDataStoreException ex) {
- String typeName = chStmt.getColumnTypeName(columnIndex);
- throw new OseeDataStoreException(getErrorMessage(name, typeName), ex);
- }
- break;
- }
- }
- return toReturn;
- }
-
- private static String getErrorMessage(String name, String typeName) {
- return String.format("Unable to convert [%s] of raw type [%s] to string.", name, typeName);
- }
-
- private static byte[] streamToByteArray(InputStream inputStream) throws OseeDataStoreException {
- byte[] toReturn = new byte[0];
- if (inputStream != null) {
- try {
- toReturn = Lib.inputStreamToBytes(inputStream);
- } catch (IOException ex) {
- throw new OseeDataStoreException(ex);
- }
- }
- return toReturn;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.database.core;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.sql.Date;
+import java.sql.Timestamp;
+import java.sql.Types;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.jdk.core.type.IVariantData;
+import org.eclipse.osee.framework.jdk.core.type.VariantData;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class ResultSetProcessor {
+ public static IVariantData parse(IOseeStatement chStmt) throws OseeDataStoreException {
+ IVariantData toReturn = new VariantData();
+ int numberOfColumns = chStmt.getColumnCount() + 1;
+ for (int index = 1; index < numberOfColumns; index++) {
+ int columnIndex = index;
+ int type = chStmt.getColumnType(columnIndex);
+ String name = chStmt.getColumnName(columnIndex);
+ // Store name - all upper case
+ String upperCasedName = name.toUpperCase();
+ switch (type) {
+ case Types.CLOB:
+ case Types.BINARY:
+ InputStream inputStream = chStmt.getAsciiStream(name);
+ toReturn.put(upperCasedName, streamToByteArray(inputStream));
+ break;
+ case Types.BLOB:
+ InputStream blobStream = chStmt.getBinaryStream(name);
+ toReturn.put(upperCasedName, streamToByteArray(blobStream));
+ break;
+ case Types.TIMESTAMP:
+ Timestamp timeStamp = chStmt.getTimestamp(name);
+ if (timeStamp != null) {
+ toReturn.put(upperCasedName, timeStamp.getTime());
+ }
+ break;
+ case Types.DATE:
+ Date date = chStmt.getDate(name);
+ if (date != null) {
+ toReturn.put(upperCasedName, date.getTime());
+ }
+ break;
+ default:
+ try {
+ String value = chStmt.getString(name);
+ if (Strings.isValid(value) != false) {
+ value = value.trim();
+ }
+ toReturn.put(upperCasedName, chStmt.getString(name));
+ } catch (OseeDataStoreException ex) {
+ String typeName = chStmt.getColumnTypeName(columnIndex);
+ throw new OseeDataStoreException(getErrorMessage(name, typeName), ex);
+ }
+ break;
+ }
+ }
+ return toReturn;
+ }
+
+ private static String getErrorMessage(String name, String typeName) {
+ return String.format("Unable to convert [%s] of raw type [%s] to string.", name, typeName);
+ }
+
+ private static byte[] streamToByteArray(InputStream inputStream) throws OseeDataStoreException {
+ byte[] toReturn = new byte[0];
+ if (inputStream != null) {
+ try {
+ toReturn = Lib.inputStreamToBytes(inputStream);
+ } catch (IOException ex) {
+ throw new OseeDataStoreException(ex);
+ }
+ }
+ return toReturn;
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/Activator.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/Activator.java
index c64d05c06e..714b4012c6 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/Activator.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/Activator.java
@@ -1,73 +1,73 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database.internal;
-
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.core.util.ServiceDependencyTracker;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.database.IOseeDatabaseServiceProvider;
-import org.eclipse.osee.framework.database.internal.trackers.OseeDatabaseServiceRegistrationHandler;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * @author Roberto E. Escobar
- */
-public class Activator implements BundleActivator, IOseeDatabaseServiceProvider {
- public static final String PLUGIN_ID = "org.eclipse.osee.framework.database";
-
- private static Activator instance = null;
-
- private ServiceDependencyTracker databaseServiceTracker;
- private ServiceTracker dbTracker;
- private DatabaseInfoProvider databaseInfoProvider;
-
- public Activator() {
- }
-
- public void start(BundleContext bundleContext) throws Exception {
- instance = this;
- databaseInfoProvider = new DatabaseInfoProvider(bundleContext);
-
- databaseServiceTracker =
- new ServiceDependencyTracker(bundleContext, new OseeDatabaseServiceRegistrationHandler());
- databaseServiceTracker.open();
-
- dbTracker = new ServiceTracker(bundleContext, IOseeDatabaseService.class.getName(), null);
- dbTracker.open(true);
- }
-
- public DatabaseInfoProvider getDatabaseInfoProvider() {
- return databaseInfoProvider;
- }
-
- @Override
- public IOseeDatabaseService getOseeDatabaseService() throws OseeDataStoreException {
- IOseeDatabaseService databaseService = (IOseeDatabaseService) dbTracker.getService();
- if (databaseService == null) {
- throw new OseeDataStoreException("OseeDatabaseService not found");
- }
- return databaseService;
- }
-
- public void stop(BundleContext context) throws Exception {
- databaseServiceTracker.close();
- dbTracker.close();
- databaseInfoProvider = null;
- instance = null;
- }
-
- public static Activator getInstance() {
- return instance;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.database.internal;
+
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.core.util.ServiceDependencyTracker;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
+import org.eclipse.osee.framework.database.IOseeDatabaseServiceProvider;
+import org.eclipse.osee.framework.database.internal.trackers.OseeDatabaseServiceRegistrationHandler;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class Activator implements BundleActivator, IOseeDatabaseServiceProvider {
+ public static final String PLUGIN_ID = "org.eclipse.osee.framework.database";
+
+ private static Activator instance = null;
+
+ private ServiceDependencyTracker databaseServiceTracker;
+ private ServiceTracker dbTracker;
+ private DatabaseInfoProvider databaseInfoProvider;
+
+ public Activator() {
+ }
+
+ public void start(BundleContext bundleContext) throws Exception {
+ instance = this;
+ databaseInfoProvider = new DatabaseInfoProvider(bundleContext);
+
+ databaseServiceTracker =
+ new ServiceDependencyTracker(bundleContext, new OseeDatabaseServiceRegistrationHandler());
+ databaseServiceTracker.open();
+
+ dbTracker = new ServiceTracker(bundleContext, IOseeDatabaseService.class.getName(), null);
+ dbTracker.open(true);
+ }
+
+ public DatabaseInfoProvider getDatabaseInfoProvider() {
+ return databaseInfoProvider;
+ }
+
+ @Override
+ public IOseeDatabaseService getOseeDatabaseService() throws OseeDataStoreException {
+ IOseeDatabaseService databaseService = (IOseeDatabaseService) dbTracker.getService();
+ if (databaseService == null) {
+ throw new OseeDataStoreException("OseeDatabaseService not found");
+ }
+ return databaseService;
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ databaseServiceTracker.close();
+ dbTracker.close();
+ databaseInfoProvider = null;
+ instance = null;
+ }
+
+ public static Activator getInstance() {
+ return instance;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/DatabaseInfoProvider.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/DatabaseInfoProvider.java
index f56d11e392..933dc824a8 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/DatabaseInfoProvider.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/DatabaseInfoProvider.java
@@ -1,89 +1,89 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.osee.framework.database.internal;
-
-import java.util.HashSet;
-import java.util.Set;
-import java.util.logging.Level;
-import org.eclipse.osee.framework.core.data.IDatabaseInfo;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.core.exception.OseeDatabaseConnectionInfoNotFoundException;
-import org.eclipse.osee.framework.core.util.Conditions;
-import org.eclipse.osee.framework.database.core.IDbConnectionInformationContributor;
-import org.eclipse.osee.framework.jdk.core.util.OseeProperties;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.framework.logging.OseeLog;
-import org.osgi.framework.BundleContext;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * @author Andrew M. Finkbeiner
- */
-public class DatabaseInfoProvider {
-
- private IDatabaseInfo selectedDbInfo;
- private final BundleContext context;
-
- public DatabaseInfoProvider(BundleContext context) {
- this.context = context;
- }
-
- public IDatabaseInfo getDatabaseInfo(String serviceId) throws OseeCoreException {
- Conditions.checkNotNull(serviceId, "Service Id to find");
- return findDatabaseInfo(serviceId);
- }
-
- public IDatabaseInfo getSelectedDatabaseInfo() throws OseeDataStoreException {
- if (selectedDbInfo == null) {
- String dbConnectionId = OseeProperties.getOseeDbConnectionId();
- if (Strings.isValid(dbConnectionId)) {
- selectedDbInfo = findDatabaseInfo(dbConnectionId);
- } else {
- throw new IllegalStateException("No DB connection information provided");
- }
- }
- return selectedDbInfo;
- }
-
- private IDatabaseInfo findDatabaseInfo(String serverIdToFind) throws OseeDataStoreException {
- Set<String> infoKeys = new HashSet<String>();
- ServiceTracker tracker = new ServiceTracker(context, IDbConnectionInformationContributor.class.getName(), null);
- tracker.open(true);
- try {
- Object[] services = tracker.getServices();
- if (services != null) {
- for (Object object : services) {
- if (object instanceof IDbConnectionInformationContributor) {
- IDbConnectionInformationContributor contributor = (IDbConnectionInformationContributor) object;
- try {
- for (IDatabaseInfo databaseInfo : contributor.getDbInformation()) {
- String key = databaseInfo.getId();
- infoKeys.add(key);
- if (serverIdToFind.equals(key)) {
- return databaseInfo;
- }
- }
- } catch (Exception ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- }
- }
- }
- }
- } finally {
- tracker.close();
- }
- throw new OseeDatabaseConnectionInfoNotFoundException(String.format(
- "DB connection information was not found for: [%s]\n Available connection ids are: [%s]\n", serverIdToFind,
- infoKeys));
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.osee.framework.database.internal;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.logging.Level;
+import org.eclipse.osee.framework.core.data.IDatabaseInfo;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.core.exception.OseeDatabaseConnectionInfoNotFoundException;
+import org.eclipse.osee.framework.core.util.Conditions;
+import org.eclipse.osee.framework.database.core.IDbConnectionInformationContributor;
+import org.eclipse.osee.framework.jdk.core.util.OseeProperties;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * @author Andrew M. Finkbeiner
+ */
+public class DatabaseInfoProvider {
+
+ private IDatabaseInfo selectedDbInfo;
+ private final BundleContext context;
+
+ public DatabaseInfoProvider(BundleContext context) {
+ this.context = context;
+ }
+
+ public IDatabaseInfo getDatabaseInfo(String serviceId) throws OseeCoreException {
+ Conditions.checkNotNull(serviceId, "Service Id to find");
+ return findDatabaseInfo(serviceId);
+ }
+
+ public IDatabaseInfo getSelectedDatabaseInfo() throws OseeDataStoreException {
+ if (selectedDbInfo == null) {
+ String dbConnectionId = OseeProperties.getOseeDbConnectionId();
+ if (Strings.isValid(dbConnectionId)) {
+ selectedDbInfo = findDatabaseInfo(dbConnectionId);
+ } else {
+ throw new IllegalStateException("No DB connection information provided");
+ }
+ }
+ return selectedDbInfo;
+ }
+
+ private IDatabaseInfo findDatabaseInfo(String serverIdToFind) throws OseeDataStoreException {
+ Set<String> infoKeys = new HashSet<String>();
+ ServiceTracker tracker = new ServiceTracker(context, IDbConnectionInformationContributor.class.getName(), null);
+ tracker.open(true);
+ try {
+ Object[] services = tracker.getServices();
+ if (services != null) {
+ for (Object object : services) {
+ if (object instanceof IDbConnectionInformationContributor) {
+ IDbConnectionInformationContributor contributor = (IDbConnectionInformationContributor) object;
+ try {
+ for (IDatabaseInfo databaseInfo : contributor.getDbInformation()) {
+ String key = databaseInfo.getId();
+ infoKeys.add(key);
+ if (serverIdToFind.equals(key)) {
+ return databaseInfo;
+ }
+ }
+ } catch (Exception ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ }
+ }
+ }
+ }
+ } finally {
+ tracker.close();
+ }
+ throw new OseeDatabaseConnectionInfoNotFoundException(String.format(
+ "DB connection information was not found for: [%s]\n Available connection ids are: [%s]\n", serverIdToFind,
+ infoKeys));
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/UriDbConnectionInfo.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/UriDbConnectionInfo.java
index 5b231d3a7f..023224646f 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/UriDbConnectionInfo.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/UriDbConnectionInfo.java
@@ -1,43 +1,43 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database.internal;
-
-import java.io.File;
-import java.net.URI;
-import java.util.logging.Level;
-import org.eclipse.osee.framework.core.data.IDatabaseInfo;
-import org.eclipse.osee.framework.database.core.DatabaseInfoManager;
-import org.eclipse.osee.framework.database.core.IDbConnectionInformationContributor;
-import org.eclipse.osee.framework.jdk.core.util.OseeProperties;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.framework.logging.OseeLog;
-
-/**
- * @author Roberto E. Escobar
- */
-public class UriDbConnectionInfo implements IDbConnectionInformationContributor {
-
- @Override
- public IDatabaseInfo[] getDbInformation() throws Exception {
- String uri = OseeProperties.getOseeConnectionInfoUri();
- if (Strings.isValid(uri)) {
- OseeLog.log(Activator.class, Level.INFO, String.format("Loading connection info from: [%s]", uri));
- URI connectionFile = null;
- if (!uri.contains("://")) {
- connectionFile = new File(uri).toURI();
- } else {
- connectionFile = new URI(uri);
- }
- return DatabaseInfoManager.readFromXml(connectionFile.toURL().openStream());
- }
- return new IDatabaseInfo[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.framework.database.internal;
+
+import java.io.File;
+import java.net.URI;
+import java.util.logging.Level;
+import org.eclipse.osee.framework.core.data.IDatabaseInfo;
+import org.eclipse.osee.framework.database.core.DatabaseInfoManager;
+import org.eclipse.osee.framework.database.core.IDbConnectionInformationContributor;
+import org.eclipse.osee.framework.jdk.core.util.OseeProperties;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.logging.OseeLog;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class UriDbConnectionInfo implements IDbConnectionInformationContributor {
+
+ @Override
+ public IDatabaseInfo[] getDbInformation() throws Exception {
+ String uri = OseeProperties.getOseeConnectionInfoUri();
+ if (Strings.isValid(uri)) {
+ OseeLog.log(Activator.class, Level.INFO, String.format("Loading connection info from: [%s]", uri));
+ URI connectionFile = null;
+ if (!uri.contains("://")) {
+ connectionFile = new File(uri).toURI();
+ } else {
+ connectionFile = new URI(uri);
+ }
+ return DatabaseInfoManager.readFromXml(connectionFile.toURL().openStream());
+ }
+ return new IDatabaseInfo[0];
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/ConnectionFactoryProvider.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/ConnectionFactoryProvider.java
index 6f17de3284..4078b6e711 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/ConnectionFactoryProvider.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/ConnectionFactoryProvider.java
@@ -1,51 +1,51 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.osee.framework.database.internal.core;
-
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeNotFoundException;
-import org.eclipse.osee.framework.core.util.Conditions;
-import org.eclipse.osee.framework.database.core.IConnectionFactory;
-import org.osgi.framework.BundleContext;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * @author Andrew M. Finkbeiner
- */
-public class ConnectionFactoryProvider {
-
- private final BundleContext bundleContext;
-
- public ConnectionFactoryProvider(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
-
- public IConnectionFactory get(String driver) throws OseeCoreException {
- Conditions.checkNotNull(driver, "database driver to find");
- ServiceTracker serviceTracker = new ServiceTracker(bundleContext, IConnectionFactory.class.getName(), null);
- serviceTracker.open(true);
- try {
- Object[] services = serviceTracker.getServices();
- for (Object object : services) {
- if (object instanceof IConnectionFactory) {
- IConnectionFactory factory = (IConnectionFactory) object;
- if (driver.equals(factory.getDriver())) {
- return factory;
- }
- }
- }
- } finally {
- serviceTracker.close();
- }
- throw new OseeNotFoundException(String.format("Unable to find connection factory with driver [%s]", driver));
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.osee.framework.database.internal.core;
+
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeNotFoundException;
+import org.eclipse.osee.framework.core.util.Conditions;
+import org.eclipse.osee.framework.database.core.IConnectionFactory;
+import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * @author Andrew M. Finkbeiner
+ */
+public class ConnectionFactoryProvider {
+
+ private final BundleContext bundleContext;
+
+ public ConnectionFactoryProvider(BundleContext bundleContext) {
+ this.bundleContext = bundleContext;
+ }
+
+ public IConnectionFactory get(String driver) throws OseeCoreException {
+ Conditions.checkNotNull(driver, "database driver to find");
+ ServiceTracker serviceTracker = new ServiceTracker(bundleContext, IConnectionFactory.class.getName(), null);
+ serviceTracker.open(true);
+ try {
+ Object[] services = serviceTracker.getServices();
+ for (Object object : services) {
+ if (object instanceof IConnectionFactory) {
+ IConnectionFactory factory = (IConnectionFactory) object;
+ if (driver.equals(factory.getDriver())) {
+ return factory;
+ }
+ }
+ }
+ } finally {
+ serviceTracker.close();
+ }
+ throw new OseeNotFoundException(String.format("Unable to find connection factory with driver [%s]", driver));
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeConnectionImpl.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeConnectionImpl.java
index 84ac2b672b..ba11b6820e 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeConnectionImpl.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeConnectionImpl.java
@@ -1,136 +1,136 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database.internal.core;
-
-import java.sql.CallableStatement;
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.database.core.OseeConnection;
-
-public class OseeConnectionImpl extends OseeConnection {
- final static private long timeout = 60000;
- private final OseeConnectionPoolImpl pool;
- private final Connection conn;
- private volatile boolean inuse;
- private long lastUsedTime;
-
- public OseeConnectionImpl(Connection conn, OseeConnectionPoolImpl pool) {
- super();
- this.conn = conn;
- this.pool = pool;
- this.inuse = true;
- this.lastUsedTime = 0;
- }
-
- @Override
- public void close() {
- pool.returnConnection(this);
- }
-
- @Override
- public boolean isClosed() throws OseeDataStoreException {
- try {
- return conn.isClosed();
- } catch (SQLException ex) {
- throw new OseeDataStoreException(ex);
- }
- }
-
- @Override
- public boolean isStale() {
- return !inUse() && getLastUse() + timeout < System.currentTimeMillis();
- }
-
- @Override
- public DatabaseMetaData getMetaData() throws OseeDataStoreException {
- try {
- return conn.getMetaData();
- } catch (SQLException ex) {
- throw new OseeDataStoreException(ex);
- }
- }
-
- PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
- return conn.prepareStatement(sql, resultSetType, resultSetConcurrency);
- }
-
- PreparedStatement prepareStatement(String sql) throws SQLException {
- return prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
- }
-
- CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
- return conn.prepareCall(sql, resultSetType, resultSetConcurrency);
- }
-
- synchronized boolean lease() {
- if (inuse) {
- return false;
- } else {
- inuse = true;
- return true;
- }
- }
-
- @Override
- protected void destroy() throws OseeDataStoreException {
- try {
- conn.close();
- } catch (SQLException ex) {
- throw new OseeDataStoreException(ex);
- }
- pool.removeConnection(this);
- }
-
- boolean inUse() {
- return inuse;
- }
-
- long getLastUse() {
- return lastUsedTime;
- }
-
- void expireLease() {
- inuse = false;
- lastUsedTime = System.currentTimeMillis();
- }
-
- @Override
- protected void setAutoCommit(boolean autoCommit) throws OseeDataStoreException {
- try {
- conn.setAutoCommit(autoCommit);
- } catch (SQLException ex) {
- throw new OseeDataStoreException(ex);
- }
- }
-
- @Override
- protected boolean getAutoCommit() throws SQLException {
- return conn.getAutoCommit();
- }
-
- @Override
- protected void commit() throws SQLException {
- conn.commit();
- }
-
- @Override
- protected void rollback() throws OseeDataStoreException {
- try {
- conn.rollback();
- } catch (SQLException ex) {
- throw new OseeDataStoreException(ex);
- }
- }
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.database.internal.core;
+
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.database.core.OseeConnection;
+
+public class OseeConnectionImpl extends OseeConnection {
+ final static private long timeout = 60000;
+ private final OseeConnectionPoolImpl pool;
+ private final Connection conn;
+ private volatile boolean inuse;
+ private long lastUsedTime;
+
+ public OseeConnectionImpl(Connection conn, OseeConnectionPoolImpl pool) {
+ super();
+ this.conn = conn;
+ this.pool = pool;
+ this.inuse = true;
+ this.lastUsedTime = 0;
+ }
+
+ @Override
+ public void close() {
+ pool.returnConnection(this);
+ }
+
+ @Override
+ public boolean isClosed() throws OseeDataStoreException {
+ try {
+ return conn.isClosed();
+ } catch (SQLException ex) {
+ throw new OseeDataStoreException(ex);
+ }
+ }
+
+ @Override
+ public boolean isStale() {
+ return !inUse() && getLastUse() + timeout < System.currentTimeMillis();
+ }
+
+ @Override
+ public DatabaseMetaData getMetaData() throws OseeDataStoreException {
+ try {
+ return conn.getMetaData();
+ } catch (SQLException ex) {
+ throw new OseeDataStoreException(ex);
+ }
+ }
+
+ PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
+ return conn.prepareStatement(sql, resultSetType, resultSetConcurrency);
+ }
+
+ PreparedStatement prepareStatement(String sql) throws SQLException {
+ return prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
+ }
+
+ CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
+ return conn.prepareCall(sql, resultSetType, resultSetConcurrency);
+ }
+
+ synchronized boolean lease() {
+ if (inuse) {
+ return false;
+ } else {
+ inuse = true;
+ return true;
+ }
+ }
+
+ @Override
+ protected void destroy() throws OseeDataStoreException {
+ try {
+ conn.close();
+ } catch (SQLException ex) {
+ throw new OseeDataStoreException(ex);
+ }
+ pool.removeConnection(this);
+ }
+
+ boolean inUse() {
+ return inuse;
+ }
+
+ long getLastUse() {
+ return lastUsedTime;
+ }
+
+ void expireLease() {
+ inuse = false;
+ lastUsedTime = System.currentTimeMillis();
+ }
+
+ @Override
+ protected void setAutoCommit(boolean autoCommit) throws OseeDataStoreException {
+ try {
+ conn.setAutoCommit(autoCommit);
+ } catch (SQLException ex) {
+ throw new OseeDataStoreException(ex);
+ }
+ }
+
+ @Override
+ protected boolean getAutoCommit() throws SQLException {
+ return conn.getAutoCommit();
+ }
+
+ @Override
+ protected void commit() throws SQLException {
+ conn.commit();
+ }
+
+ @Override
+ protected void rollback() throws OseeDataStoreException {
+ try {
+ conn.rollback();
+ } catch (SQLException ex) {
+ throw new OseeDataStoreException(ex);
+ }
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeConnectionPoolImpl.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeConnectionPoolImpl.java
index d72026a839..9ed1f4f9ef 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeConnectionPoolImpl.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeConnectionPoolImpl.java
@@ -1,110 +1,110 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database.internal.core;
-
-import java.sql.Connection;
-import java.util.List;
-import java.util.Properties;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.logging.Level;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.database.core.IConnectionFactory;
-import org.eclipse.osee.framework.database.core.OseeConnection;
-import org.eclipse.osee.framework.database.internal.Activator;
-import org.eclipse.osee.framework.logging.OseeLog;
-
-public class OseeConnectionPoolImpl {
- private static final int MAX_CONNECTIONS_PER_CLIENT = Math.max(8, 2 * Runtime.getRuntime().availableProcessors());
- private final List<OseeConnectionImpl> connections = new CopyOnWriteArrayList<OseeConnectionImpl>();
- private final String dbUrl;
- private final Properties properties;
- private final ConnectionFactoryProvider connectionFactory;
- private final String driver;
-
- public OseeConnectionPoolImpl(ConnectionFactoryProvider connectionFactory, String driver, String dbUrl, Properties properties) {
- this.connectionFactory = connectionFactory;
- this.driver = driver;
- this.dbUrl = dbUrl;
- this.properties = properties;
- }
-
- private IConnectionFactory createConnection(String driver) throws OseeCoreException {
- return connectionFactory.get(driver);
- }
-
- public synchronized boolean hasOpenConnection() {
- return connections.size() > 0;
- }
-
- /**
- * at a minimum this should be called on jvm shutdown
- */
- public synchronized void closeConnections() {
- for (OseeConnection connection : connections) {
- connection.close();
- }
- connections.clear();
- }
-
- synchronized void removeConnection(OseeConnection conn) {
- connections.remove(conn);
- }
-
- public synchronized OseeConnectionImpl getConnection() throws OseeDataStoreException {
- for (OseeConnectionImpl connection : connections) {
- if (connection.lease()) {
- return connection;
- }
- }
-
- if (connections.size() >= MAX_CONNECTIONS_PER_CLIENT) {
- throw new OseeDataStoreException(
- "This client has reached the maximum number of allowed simultaneous database connections of : " + MAX_CONNECTIONS_PER_CLIENT);
- }
- try {
- OseeConnectionImpl connection = getOseeConnection();
- connections.add(connection);
- OseeLog.log(Activator.class, Level.INFO, String.format("DbConnection: [%s] - [%d]", dbUrl, connections.size()));
- return connection;
- } catch (Throwable th) {
- throw new OseeDataStoreException("Unable to get a database connection: ", th);
- }
- }
-
- private OseeConnectionImpl getOseeConnection() throws Exception {
- IConnectionFactory connectionDriver = createConnection(driver);
- Connection connection = connectionDriver.getConnection(properties, dbUrl);
- connection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
- return new OseeConnectionImpl(connection, this);
- }
-
- synchronized void returnConnection(OseeConnectionImpl connection) {
- try {
- if (connection.isClosed()) {
- removeConnection(connection);
- } else {
- connection.expireLease();
- }
- } catch (OseeDataStoreException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- removeConnection(connection);
- }
- }
-
- synchronized void releaseUneededConnections() throws OseeDataStoreException {
- for (OseeConnectionImpl connection : connections) {
- if (connection.isStale()) {
- connection.destroy();
- }
- }
- }
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.database.internal.core;
+
+import java.sql.Connection;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.logging.Level;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.database.core.IConnectionFactory;
+import org.eclipse.osee.framework.database.core.OseeConnection;
+import org.eclipse.osee.framework.database.internal.Activator;
+import org.eclipse.osee.framework.logging.OseeLog;
+
+public class OseeConnectionPoolImpl {
+ private static final int MAX_CONNECTIONS_PER_CLIENT = Math.max(8, 2 * Runtime.getRuntime().availableProcessors());
+ private final List<OseeConnectionImpl> connections = new CopyOnWriteArrayList<OseeConnectionImpl>();
+ private final String dbUrl;
+ private final Properties properties;
+ private final ConnectionFactoryProvider connectionFactory;
+ private final String driver;
+
+ public OseeConnectionPoolImpl(ConnectionFactoryProvider connectionFactory, String driver, String dbUrl, Properties properties) {
+ this.connectionFactory = connectionFactory;
+ this.driver = driver;
+ this.dbUrl = dbUrl;
+ this.properties = properties;
+ }
+
+ private IConnectionFactory createConnection(String driver) throws OseeCoreException {
+ return connectionFactory.get(driver);
+ }
+
+ public synchronized boolean hasOpenConnection() {
+ return connections.size() > 0;
+ }
+
+ /**
+ * at a minimum this should be called on jvm shutdown
+ */
+ public synchronized void closeConnections() {
+ for (OseeConnection connection : connections) {
+ connection.close();
+ }
+ connections.clear();
+ }
+
+ synchronized void removeConnection(OseeConnection conn) {
+ connections.remove(conn);
+ }
+
+ public synchronized OseeConnectionImpl getConnection() throws OseeDataStoreException {
+ for (OseeConnectionImpl connection : connections) {
+ if (connection.lease()) {
+ return connection;
+ }
+ }
+
+ if (connections.size() >= MAX_CONNECTIONS_PER_CLIENT) {
+ throw new OseeDataStoreException(
+ "This client has reached the maximum number of allowed simultaneous database connections of : " + MAX_CONNECTIONS_PER_CLIENT);
+ }
+ try {
+ OseeConnectionImpl connection = getOseeConnection();
+ connections.add(connection);
+ OseeLog.log(Activator.class, Level.INFO, String.format("DbConnection: [%s] - [%d]", dbUrl, connections.size()));
+ return connection;
+ } catch (Throwable th) {
+ throw new OseeDataStoreException("Unable to get a database connection: ", th);
+ }
+ }
+
+ private OseeConnectionImpl getOseeConnection() throws Exception {
+ IConnectionFactory connectionDriver = createConnection(driver);
+ Connection connection = connectionDriver.getConnection(properties, dbUrl);
+ connection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
+ return new OseeConnectionImpl(connection, this);
+ }
+
+ synchronized void returnConnection(OseeConnectionImpl connection) {
+ try {
+ if (connection.isClosed()) {
+ removeConnection(connection);
+ } else {
+ connection.expireLease();
+ }
+ } catch (OseeDataStoreException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ removeConnection(connection);
+ }
+ }
+
+ synchronized void releaseUneededConnections() throws OseeDataStoreException {
+ for (OseeConnectionImpl connection : connections) {
+ if (connection.isStale()) {
+ connection.destroy();
+ }
+ }
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeDatabaseServiceImpl.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeDatabaseServiceImpl.java
index faa51c6aa7..b436821022 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeDatabaseServiceImpl.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/OseeDatabaseServiceImpl.java
@@ -8,225 +8,225 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.framework.database.internal.core;
-
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Timer;
-import java.util.logging.Level;
-import org.eclipse.osee.framework.core.data.IDatabaseInfo;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.core.util.Conditions;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.database.core.IDatabaseInfoProvider;
-import org.eclipse.osee.framework.database.core.IOseeSequence;
-import org.eclipse.osee.framework.database.core.IOseeStatement;
-import org.eclipse.osee.framework.database.core.OseeConnection;
-import org.eclipse.osee.framework.database.internal.Activator;
-import org.eclipse.osee.framework.logging.OseeLog;
-
-/**
- * @author Roberto E. Escobar
- */
-public class OseeDatabaseServiceImpl implements IOseeDatabaseService {
- private static final Timer timer = new Timer();
- private static final Map<String, OseeConnectionPoolImpl> dbInfoToPools =
- new HashMap<String, OseeConnectionPoolImpl>();
-
- private final IOseeSequence oseeSequence;
- private final ConnectionFactoryProvider dbConnectionFactory;
- private final IDatabaseInfoProvider dbInfoProvider;
-
- public OseeDatabaseServiceImpl(IDatabaseInfoProvider dbInfoProvider, ConnectionFactoryProvider dbConnectionFactory) {
- this.oseeSequence = new OseeSequenceImpl(this);
- this.dbInfoProvider = dbInfoProvider;
- this.dbConnectionFactory = dbConnectionFactory;
- }
-
- private IDatabaseInfo getDatabaseInfoProvider() throws OseeDataStoreException {
- return dbInfoProvider.getDatabaseInfo();
- }
-
- private OseeConnectionPoolImpl getDefaultConnectionPool() throws OseeDataStoreException {
- return getConnectionPool(getDatabaseInfoProvider());
- }
-
- @Override
- public IOseeSequence getSequence() throws OseeDataStoreException {
- return oseeSequence;
- }
-
- @Override
- public OseeConnection getConnection() throws OseeDataStoreException {
- return getConnection(getDatabaseInfoProvider());
- }
-
- private OseeConnectionPoolImpl getConnectionPool(IDatabaseInfo databaseInfo) throws OseeDataStoreException {
- if (databaseInfo == null) {
- throw new OseeDataStoreException("Unable to get connection - database info was null.");
- }
- OseeConnectionPoolImpl pool = dbInfoToPools.get(databaseInfo.getId());
- if (pool == null) {
- pool =
- new OseeConnectionPoolImpl(dbConnectionFactory, databaseInfo.getDriver(),
- databaseInfo.getConnectionUrl(), databaseInfo.getConnectionProperties());
- dbInfoToPools.put(databaseInfo.getId(), pool);
- timer.schedule(new StaleConnectionCloser(pool), 900000, 900000);
- }
- return pool;
- }
-
- @Override
- public OseeConnection getConnection(IDatabaseInfo databaseInfo) throws OseeDataStoreException {
- return getConnectionPool(databaseInfo).getConnection();
- }
-
- @Override
- public IOseeStatement getStatement() throws OseeDataStoreException {
- return new OseeStatementImpl(getDefaultConnectionPool());
- }
-
- @Override
- public IOseeStatement getStatement(OseeConnection connection) throws OseeDataStoreException {
- return new OseeStatementImpl(getDefaultConnectionPool(), (OseeConnectionImpl) connection);
- }
-
- @Override
- public IOseeStatement getStatement(OseeConnection connection, boolean autoClose) throws OseeDataStoreException {
- return new OseeStatementImpl(getDefaultConnectionPool(), (OseeConnectionImpl) connection, autoClose);
- }
-
- @Override
- public IOseeStatement getStatement(int resultSetType, int resultSetConcurrency) throws OseeDataStoreException {
- throw new UnsupportedOperationException("This needs to be implemented");
- }
-
- @Override
- public <O extends Object> int runPreparedUpdate(OseeConnection connection, String query, O... data) throws OseeDataStoreException {
- if (connection == null) {
- return runPreparedUpdate(query, data);
- }
- PreparedStatement preparedStatement = null;
- int updateCount = 0;
- try {
- preparedStatement = ((OseeConnectionImpl) connection).prepareStatement(query);
- StatementUtil.populateValuesForPreparedStatement(preparedStatement, data);
- updateCount = preparedStatement.executeUpdate();
- } catch (SQLException ex) {
- throw new OseeDataStoreException(ex);
- } finally {
- StatementUtil.close(preparedStatement);
- }
- return updateCount;
- }
-
- @Override
- public <O extends Object> int runBatchUpdate(OseeConnection connection, String query, List<O[]> dataList) throws OseeDataStoreException {
- if (connection == null) {
- return runBatchUpdate(query, dataList);
- }
- int returnCount = 0;
- PreparedStatement preparedStatement = null;
- try {
- preparedStatement = ((OseeConnectionImpl) connection).prepareStatement(query);
- boolean needExecute = false;
- int count = 0;
- for (Object[] data : dataList) {
- count++;
- StatementUtil.populateValuesForPreparedStatement(preparedStatement, data);
- preparedStatement.addBatch();
- preparedStatement.clearParameters();
- needExecute = true;
- if (count > 2000) {
- int[] updates = preparedStatement.executeBatch();
- returnCount += StatementUtil.calculateBatchUpdateResults(updates);
- count = 0;
- needExecute = false;
- }
- }
- if (needExecute) {
- int[] updates = preparedStatement.executeBatch();
- returnCount += StatementUtil.calculateBatchUpdateResults(updates);
- }
-
- } catch (SQLException ex) {
- SQLException exlist;
- if ((exlist = ex.getNextException()) != null) {
- OseeLog.log(Activator.class, Level.SEVERE, "This is the nested exception", exlist);
- }
- throw new OseeDataStoreException(
- "sql update failed: \n" + query + "\n" + StatementUtil.getBatchErrorMessage(dataList), ex);
- } finally {
- StatementUtil.close(preparedStatement);
- }
- return returnCount;
- }
-
- @Override
- public <O> int runBatchUpdate(String query, List<O[]> dataList) throws OseeDataStoreException {
- OseeConnection connection = getConnection();
- try {
- return runBatchUpdate(connection, query, dataList);
- } finally {
- connection.close();
- }
- }
-
- @Override
- public <O> int runPreparedUpdate(String query, O... data) throws OseeDataStoreException {
- OseeConnection connection = getConnection();
- try {
- return runPreparedUpdate(connection, query, data);
- } finally {
- connection.close();
- }
- }
-
- @Override
- public <T, O extends Object> T runPreparedQueryFetchObject(T defaultValue, String query, O... data) throws OseeDataStoreException {
- return runPreparedQueryFetchObject(getStatement(), defaultValue, query, data);
- }
-
- @Override
- public <T, O extends Object> T runPreparedQueryFetchObject(OseeConnection connection, T defaultValue, String query, O... data) throws OseeDataStoreException {
- return runPreparedQueryFetchObject(getStatement(connection), defaultValue, query, data);
- }
-
- @SuppressWarnings("unchecked")
- private <T, O extends Object> T runPreparedQueryFetchObject(IOseeStatement chStmt, T defaultValue, String query, O... data) throws OseeDataStoreException {
- try {
- Conditions.checkNotNull(defaultValue, "default value");
- } catch (OseeCoreException ex) {
- throw new OseeDataStoreException(ex);
- }
- try {
- chStmt.runPreparedQuery(1, query, data);
- if (chStmt.next()) {
- Object toReturn = null;
- Class<?> classValue = defaultValue.getClass();
- if (classValue.isAssignableFrom(Integer.class)) {
- toReturn = chStmt.getInt(1);
- } else if (classValue.isAssignableFrom(String.class)) {
- toReturn = chStmt.getString(1);
- } else if (classValue.isAssignableFrom(Long.class)) {
- toReturn = chStmt.getLong(1);
- } else {
- toReturn = chStmt.getObject(1);
- }
- return (T) toReturn;
- }
- return defaultValue;
- } finally {
- chStmt.close();
- }
- }
-
- @Override
- public boolean isProduction() throws OseeCoreException {
- return getDatabaseInfoProvider().isProduction();
- }
-}
+package org.eclipse.osee.framework.database.internal.core;
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Timer;
+import java.util.logging.Level;
+import org.eclipse.osee.framework.core.data.IDatabaseInfo;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.core.util.Conditions;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
+import org.eclipse.osee.framework.database.core.IDatabaseInfoProvider;
+import org.eclipse.osee.framework.database.core.IOseeSequence;
+import org.eclipse.osee.framework.database.core.IOseeStatement;
+import org.eclipse.osee.framework.database.core.OseeConnection;
+import org.eclipse.osee.framework.database.internal.Activator;
+import org.eclipse.osee.framework.logging.OseeLog;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class OseeDatabaseServiceImpl implements IOseeDatabaseService {
+ private static final Timer timer = new Timer();
+ private static final Map<String, OseeConnectionPoolImpl> dbInfoToPools =
+ new HashMap<String, OseeConnectionPoolImpl>();
+
+ private final IOseeSequence oseeSequence;
+ private final ConnectionFactoryProvider dbConnectionFactory;
+ private final IDatabaseInfoProvider dbInfoProvider;
+
+ public OseeDatabaseServiceImpl(IDatabaseInfoProvider dbInfoProvider, ConnectionFactoryProvider dbConnectionFactory) {
+ this.oseeSequence = new OseeSequenceImpl(this);
+ this.dbInfoProvider = dbInfoProvider;
+ this.dbConnectionFactory = dbConnectionFactory;
+ }
+
+ private IDatabaseInfo getDatabaseInfoProvider() throws OseeDataStoreException {
+ return dbInfoProvider.getDatabaseInfo();
+ }
+
+ private OseeConnectionPoolImpl getDefaultConnectionPool() throws OseeDataStoreException {
+ return getConnectionPool(getDatabaseInfoProvider());
+ }
+
+ @Override
+ public IOseeSequence getSequence() throws OseeDataStoreException {
+ return oseeSequence;
+ }
+
+ @Override
+ public OseeConnection getConnection() throws OseeDataStoreException {
+ return getConnection(getDatabaseInfoProvider());
+ }
+
+ private OseeConnectionPoolImpl getConnectionPool(IDatabaseInfo databaseInfo) throws OseeDataStoreException {
+ if (databaseInfo == null) {
+ throw new OseeDataStoreException("Unable to get connection - database info was null.");
+ }
+ OseeConnectionPoolImpl pool = dbInfoToPools.get(databaseInfo.getId());
+ if (pool == null) {
+ pool =
+ new OseeConnectionPoolImpl(dbConnectionFactory, databaseInfo.getDriver(),
+ databaseInfo.getConnectionUrl(), databaseInfo.getConnectionProperties());
+ dbInfoToPools.put(databaseInfo.getId(), pool);
+ timer.schedule(new StaleConnectionCloser(pool), 900000, 900000);
+ }
+ return pool;
+ }
+
+ @Override
+ public OseeConnection getConnection(IDatabaseInfo databaseInfo) throws OseeDataStoreException {
+ return getConnectionPool(databaseInfo).getConnection();
+ }
+
+ @Override
+ public IOseeStatement getStatement() throws OseeDataStoreException {
+ return new OseeStatementImpl(getDefaultConnectionPool());
+ }
+
+ @Override
+ public IOseeStatement getStatement(OseeConnection connection) throws OseeDataStoreException {
+ return new OseeStatementImpl(getDefaultConnectionPool(), (OseeConnectionImpl) connection);
+ }
+
+ @Override
+ public IOseeStatement getStatement(OseeConnection connection, boolean autoClose) throws OseeDataStoreException {
+ return new OseeStatementImpl(getDefaultConnectionPool(), (OseeConnectionImpl) connection, autoClose);
+ }
+
+ @Override
+ public IOseeStatement getStatement(int resultSetType, int resultSetConcurrency) throws OseeDataStoreException {
+ throw new UnsupportedOperationException("This needs to be implemented");
+ }
+
+ @Override
+ public <O extends Object> int runPreparedUpdate(OseeConnection connection, String query, O... data) throws OseeDataStoreException {
+ if (connection == null) {
+ return runPreparedUpdate(query, data);
+ }
+ PreparedStatement preparedStatement = null;
+ int updateCount = 0;
+ try {
+ preparedStatement = ((OseeConnectionImpl) connection).prepareStatement(query);
+ StatementUtil.populateValuesForPreparedStatement(preparedStatement, data);
+ updateCount = preparedStatement.executeUpdate();
+ } catch (SQLException ex) {
+ throw new OseeDataStoreException(ex);
+ } finally {
+ StatementUtil.close(preparedStatement);
+ }
+ return updateCount;
+ }
+
+ @Override
+ public <O extends Object> int runBatchUpdate(OseeConnection connection, String query, List<O[]> dataList) throws OseeDataStoreException {
+ if (connection == null) {
+ return runBatchUpdate(query, dataList);
+ }
+ int returnCount = 0;
+ PreparedStatement preparedStatement = null;
+ try {
+ preparedStatement = ((OseeConnectionImpl) connection).prepareStatement(query);
+ boolean needExecute = false;
+ int count = 0;
+ for (Object[] data : dataList) {
+ count++;
+ StatementUtil.populateValuesForPreparedStatement(preparedStatement, data);
+ preparedStatement.addBatch();
+ preparedStatement.clearParameters();
+ needExecute = true;
+ if (count > 2000) {
+ int[] updates = preparedStatement.executeBatch();
+ returnCount += StatementUtil.calculateBatchUpdateResults(updates);
+ count = 0;
+ needExecute = false;
+ }
+ }
+ if (needExecute) {
+ int[] updates = preparedStatement.executeBatch();
+ returnCount += StatementUtil.calculateBatchUpdateResults(updates);
+ }
+
+ } catch (SQLException ex) {
+ SQLException exlist;
+ if ((exlist = ex.getNextException()) != null) {
+ OseeLog.log(Activator.class, Level.SEVERE, "This is the nested exception", exlist);
+ }
+ throw new OseeDataStoreException(
+ "sql update failed: \n" + query + "\n" + StatementUtil.getBatchErrorMessage(dataList), ex);
+ } finally {
+ StatementUtil.close(preparedStatement);
+ }
+ return returnCount;
+ }
+
+ @Override
+ public <O> int runBatchUpdate(String query, List<O[]> dataList) throws OseeDataStoreException {
+ OseeConnection connection = getConnection();
+ try {
+ return runBatchUpdate(connection, query, dataList);
+ } finally {
+ connection.close();
+ }
+ }
+
+ @Override
+ public <O> int runPreparedUpdate(String query, O... data) throws OseeDataStoreException {
+ OseeConnection connection = getConnection();
+ try {
+ return runPreparedUpdate(connection, query, data);
+ } finally {
+ connection.close();
+ }
+ }
+
+ @Override
+ public <T, O extends Object> T runPreparedQueryFetchObject(T defaultValue, String query, O... data) throws OseeDataStoreException {
+ return runPreparedQueryFetchObject(getStatement(), defaultValue, query, data);
+ }
+
+ @Override
+ public <T, O extends Object> T runPreparedQueryFetchObject(OseeConnection connection, T defaultValue, String query, O... data) throws OseeDataStoreException {
+ return runPreparedQueryFetchObject(getStatement(connection), defaultValue, query, data);
+ }
+
+ @SuppressWarnings("unchecked")
+ private <T, O extends Object> T runPreparedQueryFetchObject(IOseeStatement chStmt, T defaultValue, String query, O... data) throws OseeDataStoreException {
+ try {
+ Conditions.checkNotNull(defaultValue, "default value");
+ } catch (OseeCoreException ex) {
+ throw new OseeDataStoreException(ex);
+ }
+ try {
+ chStmt.runPreparedQuery(1, query, data);
+ if (chStmt.next()) {
+ Object toReturn = null;
+ Class<?> classValue = defaultValue.getClass();
+ if (classValue.isAssignableFrom(Integer.class)) {
+ toReturn = chStmt.getInt(1);
+ } else if (classValue.isAssignableFrom(String.class)) {
+ toReturn = chStmt.getString(1);
+ } else if (classValue.isAssignableFrom(Long.class)) {
+ toReturn = chStmt.getLong(1);
+ } else {
+ toReturn = chStmt.getObject(1);
+ }
+ return (T) toReturn;
+ }
+ return defaultValue;
+ } finally {
+ chStmt.close();
+ }
+ }
+
+ @Override
+ public boolean isProduction() throws OseeCoreException {
+ return getDatabaseInfoProvider().isProduction();
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/StaleConnectionCloser.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/StaleConnectionCloser.java
index 314b22b59b..8cc7220819 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/StaleConnectionCloser.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/StaleConnectionCloser.java
@@ -1,41 +1,41 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database.internal.core;
-
-import java.util.TimerTask;
-import java.util.logging.Level;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.database.internal.Activator;
-import org.eclipse.osee.framework.logging.OseeLog;
-
-/**
- * @author Ryan D. Brooks
- */
-public class StaleConnectionCloser extends TimerTask {
- private final OseeConnectionPoolImpl connectionPool;
-
- /**
- * @param connectionPool
- */
- public StaleConnectionCloser(OseeConnectionPoolImpl connectionPool) {
- super();
- this.connectionPool = connectionPool;
- }
-
- @Override
- public void run() {
- try {
- connectionPool.releaseUneededConnections();
- } catch (OseeDataStoreException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- }
- }
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.database.internal.core;
+
+import java.util.TimerTask;
+import java.util.logging.Level;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.database.internal.Activator;
+import org.eclipse.osee.framework.logging.OseeLog;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class StaleConnectionCloser extends TimerTask {
+ private final OseeConnectionPoolImpl connectionPool;
+
+ /**
+ * @param connectionPool
+ */
+ public StaleConnectionCloser(OseeConnectionPoolImpl connectionPool) {
+ super();
+ this.connectionPool = connectionPool;
+ }
+
+ @Override
+ public void run() {
+ try {
+ connectionPool.releaseUneededConnections();
+ } catch (OseeDataStoreException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ }
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/StatementUtil.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/StatementUtil.java
index b140d077e3..faaf68f5fe 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/StatementUtil.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/core/StatementUtil.java
@@ -1,121 +1,121 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database.internal.core;
-
-import java.io.ByteArrayInputStream;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.List;
-import java.util.logging.Level;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.database.core.SQL3DataType;
-import org.eclipse.osee.framework.database.internal.Activator;
-import org.eclipse.osee.framework.logging.OseeLog;
-
-/**
- * @author Roberto E. Escobar
- */
-public class StatementUtil {
-
- private StatementUtil() {
-
- }
-
- public static <O extends Object> String getBatchErrorMessage(List<O[]> dataList) {
- StringBuilder details = new StringBuilder(dataList.size() * dataList.get(0).length * 20);
- details.append("[ DATA OBJECT: \n");
- for (Object[] data : dataList) {
- for (int i = 0; i < data.length; i++) {
- details.append(i);
- details.append(": ");
- Object dataValue = data[i];
- if (dataValue != null) {
- details.append(dataValue.getClass().getName());
- details.append(":");
-
- String value = dataValue.toString();
- if (value.length() > 35) {
- details.append(value.substring(0, 35));
- } else {
- details.append(value);
- }
- details.append("\n");
- } else {
- details.append("NULL\n");
- }
- }
- }
- details.append("]\n");
- return details.toString();
- }
-
- public static int calculateBatchUpdateResults(int[] updates) {
- int returnCount = 0;
- for (int update : updates) {
- if (update >= 0) {
- returnCount += update;
- } else if (Statement.EXECUTE_FAILED == update) {
- OseeLog.log(Activator.class, Level.SEVERE, "sql execute failed.");
- } else if (Statement.SUCCESS_NO_INFO == update) {
- returnCount++;
- }
- }
- return returnCount;
- }
-
- public static void close(PreparedStatement stmt) {
- if (stmt != null) {
- try {
- stmt.close();
- } catch (SQLException ex) {
- OseeLog.log(Activator.class, Level.WARNING, "Unable to close database statement: ", ex);
- }
- }
- }
-
- public static <O extends Object> void populateValuesForPreparedStatement(PreparedStatement preparedStatement, O... data) throws OseeDataStoreException {
- try {
- int preparedIndex = 0;
- for (Object dataValue : data) {
- preparedIndex++;
- if (dataValue instanceof String) {
- int length = ((String) dataValue).length();
- if (length > 4000) {
- throw new OseeDataStoreException(
- "SQL data value length must be <= 4000 not " + length + "\nValue: " + dataValue);
- }
- }
-
- if (dataValue == null) {
- throw new OseeDataStoreException(
- "instead of passing null for an query parameter, pass the corresponding SQL3DataType");
- } else if (dataValue instanceof SQL3DataType) {
- int dataTypeNumber = ((SQL3DataType) dataValue).getSQLTypeNumber();
- if (dataTypeNumber == java.sql.Types.BLOB) {
- // TODO Need to check this - for PostgreSql, setNull for BLOB with the new JDBC driver gives the error "column
- // "content" is of type bytea but expression is of type oid"
- preparedStatement.setBytes(preparedIndex, null);
- } else {
- preparedStatement.setNull(preparedIndex, dataTypeNumber);
- }
- } else if (dataValue instanceof ByteArrayInputStream) {
- preparedStatement.setBinaryStream(preparedIndex, (ByteArrayInputStream) dataValue,
- ((ByteArrayInputStream) dataValue).available());
- } else {
- preparedStatement.setObject(preparedIndex, dataValue);
- }
- }
- } catch (SQLException ex) {
- throw new OseeDataStoreException(ex);
- }
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.database.internal.core;
+
+import java.io.ByteArrayInputStream;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.List;
+import java.util.logging.Level;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.database.core.SQL3DataType;
+import org.eclipse.osee.framework.database.internal.Activator;
+import org.eclipse.osee.framework.logging.OseeLog;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class StatementUtil {
+
+ private StatementUtil() {
+
+ }
+
+ public static <O extends Object> String getBatchErrorMessage(List<O[]> dataList) {
+ StringBuilder details = new StringBuilder(dataList.size() * dataList.get(0).length * 20);
+ details.append("[ DATA OBJECT: \n");
+ for (Object[] data : dataList) {
+ for (int i = 0; i < data.length; i++) {
+ details.append(i);
+ details.append(": ");
+ Object dataValue = data[i];
+ if (dataValue != null) {
+ details.append(dataValue.getClass().getName());
+ details.append(":");
+
+ String value = dataValue.toString();
+ if (value.length() > 35) {
+ details.append(value.substring(0, 35));
+ } else {
+ details.append(value);
+ }
+ details.append("\n");
+ } else {
+ details.append("NULL\n");
+ }
+ }
+ }
+ details.append("]\n");
+ return details.toString();
+ }
+
+ public static int calculateBatchUpdateResults(int[] updates) {
+ int returnCount = 0;
+ for (int update : updates) {
+ if (update >= 0) {
+ returnCount += update;
+ } else if (Statement.EXECUTE_FAILED == update) {
+ OseeLog.log(Activator.class, Level.SEVERE, "sql execute failed.");
+ } else if (Statement.SUCCESS_NO_INFO == update) {
+ returnCount++;
+ }
+ }
+ return returnCount;
+ }
+
+ public static void close(PreparedStatement stmt) {
+ if (stmt != null) {
+ try {
+ stmt.close();
+ } catch (SQLException ex) {
+ OseeLog.log(Activator.class, Level.WARNING, "Unable to close database statement: ", ex);
+ }
+ }
+ }
+
+ public static <O extends Object> void populateValuesForPreparedStatement(PreparedStatement preparedStatement, O... data) throws OseeDataStoreException {
+ try {
+ int preparedIndex = 0;
+ for (Object dataValue : data) {
+ preparedIndex++;
+ if (dataValue instanceof String) {
+ int length = ((String) dataValue).length();
+ if (length > 4000) {
+ throw new OseeDataStoreException(
+ "SQL data value length must be <= 4000 not " + length + "\nValue: " + dataValue);
+ }
+ }
+
+ if (dataValue == null) {
+ throw new OseeDataStoreException(
+ "instead of passing null for an query parameter, pass the corresponding SQL3DataType");
+ } else if (dataValue instanceof SQL3DataType) {
+ int dataTypeNumber = ((SQL3DataType) dataValue).getSQLTypeNumber();
+ if (dataTypeNumber == java.sql.Types.BLOB) {
+ // TODO Need to check this - for PostgreSql, setNull for BLOB with the new JDBC driver gives the error "column
+ // "content" is of type bytea but expression is of type oid"
+ preparedStatement.setBytes(preparedIndex, null);
+ } else {
+ preparedStatement.setNull(preparedIndex, dataTypeNumber);
+ }
+ } else if (dataValue instanceof ByteArrayInputStream) {
+ preparedStatement.setBinaryStream(preparedIndex, (ByteArrayInputStream) dataValue,
+ ((ByteArrayInputStream) dataValue).available());
+ } else {
+ preparedStatement.setObject(preparedIndex, dataValue);
+ }
+ }
+ } catch (SQLException ex) {
+ throw new OseeDataStoreException(ex);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/parser/DbDetailData.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/parser/DbDetailData.java
index 50387add32..37635863d7 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/parser/DbDetailData.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/parser/DbDetailData.java
@@ -1,95 +1,95 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database.internal.parser;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import org.eclipse.osee.framework.database.core.SupportedDatabase;
-import org.eclipse.osee.framework.jdk.core.type.Pair;
-
-/**
- * @author Roberto E. Escobar
- */
-public class DbDetailData implements Serializable {
-
- private static final long serialVersionUID = 4610179141542353247L;
-
- public enum ConfigPairField {
- key, value;
- }
-
- public enum ConfigField {
- DatabaseType, DatabaseName, DatabaseHome, Prefix, UserName, Password, Host, Port
- }
-
- public enum DescriptionField {
- id;
- }
-
- private final Map<ConfigField, Pair<String, String>> configFieldMap;
- private final Map<DescriptionField, String> descriptionMap;
-
- public DbDetailData() {
- super();
- configFieldMap = new HashMap<ConfigField, Pair<String, String>>();
- descriptionMap = new HashMap<DescriptionField, String>();
- }
-
- public String getId() {
- return descriptionMap.get(DescriptionField.id);
- }
-
- public void addDescription(DescriptionField field, String value) {
- descriptionMap.put(field, value);
- }
-
- public void addConfigField(ConfigField field, Pair<String, String> pair) {
- configFieldMap.put(field, pair);
- }
-
- public SupportedDatabase getDbType() {
- return SupportedDatabase.valueOf(getFieldValue(ConfigField.DatabaseType).toLowerCase());
- }
-
- public String getFieldValue(ConfigField field) {
- String toReturn = "";
- if (configFieldMap.containsKey(field)) {
- Pair<String, String> pair = configFieldMap.get(field);
- toReturn = pair.getSecond();
- }
- return toReturn;
- }
-
- @Override
- public String toString() {
- StringBuilder toReturn = new StringBuilder("DatabaseInfo: \n");
- Set<DescriptionField> descriptionMapkeys = descriptionMap.keySet();
- for (DescriptionField field : descriptionMapkeys) {
- String value = descriptionMap.get(field);
- toReturn.append(String.format("%s: [%s]\n", field, value));
- }
-
- toReturn.append("Fields: \n");
- Set<ConfigField> keys = configFieldMap.keySet();
- for (ConfigField field : keys) {
- Pair<String, String> pair = configFieldMap.get(field);
- toReturn.append(field + ": " + "[" + pair.getFirst() + "],[" + pair.getSecond() + "]\n");
- }
- toReturn.append("\n");
- return toReturn.toString();
- }
-
- public Map<ConfigField, Pair<String, String>> getConfigMap() {
- return configFieldMap;
- }
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.database.internal.parser;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import org.eclipse.osee.framework.database.core.SupportedDatabase;
+import org.eclipse.osee.framework.jdk.core.type.Pair;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class DbDetailData implements Serializable {
+
+ private static final long serialVersionUID = 4610179141542353247L;
+
+ public enum ConfigPairField {
+ key, value;
+ }
+
+ public enum ConfigField {
+ DatabaseType, DatabaseName, DatabaseHome, Prefix, UserName, Password, Host, Port
+ }
+
+ public enum DescriptionField {
+ id;
+ }
+
+ private final Map<ConfigField, Pair<String, String>> configFieldMap;
+ private final Map<DescriptionField, String> descriptionMap;
+
+ public DbDetailData() {
+ super();
+ configFieldMap = new HashMap<ConfigField, Pair<String, String>>();
+ descriptionMap = new HashMap<DescriptionField, String>();
+ }
+
+ public String getId() {
+ return descriptionMap.get(DescriptionField.id);
+ }
+
+ public void addDescription(DescriptionField field, String value) {
+ descriptionMap.put(field, value);
+ }
+
+ public void addConfigField(ConfigField field, Pair<String, String> pair) {
+ configFieldMap.put(field, pair);
+ }
+
+ public SupportedDatabase getDbType() {
+ return SupportedDatabase.valueOf(getFieldValue(ConfigField.DatabaseType).toLowerCase());
+ }
+
+ public String getFieldValue(ConfigField field) {
+ String toReturn = "";
+ if (configFieldMap.containsKey(field)) {
+ Pair<String, String> pair = configFieldMap.get(field);
+ toReturn = pair.getSecond();
+ }
+ return toReturn;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder toReturn = new StringBuilder("DatabaseInfo: \n");
+ Set<DescriptionField> descriptionMapkeys = descriptionMap.keySet();
+ for (DescriptionField field : descriptionMapkeys) {
+ String value = descriptionMap.get(field);
+ toReturn.append(String.format("%s: [%s]\n", field, value));
+ }
+
+ toReturn.append("Fields: \n");
+ Set<ConfigField> keys = configFieldMap.keySet();
+ for (ConfigField field : keys) {
+ Pair<String, String> pair = configFieldMap.get(field);
+ toReturn.append(field + ": " + "[" + pair.getFirst() + "],[" + pair.getSecond() + "]\n");
+ }
+ toReturn.append("\n");
+ return toReturn.toString();
+ }
+
+ public Map<ConfigField, Pair<String, String>> getConfigMap() {
+ return configFieldMap;
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/parser/DbInformation.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/parser/DbInformation.java
index 6d2e8434c6..6fd21841ed 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/parser/DbInformation.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/parser/DbInformation.java
@@ -1,126 +1,126 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database.internal.parser;
-
-import java.util.Properties;
-import java.util.Set;
-import org.eclipse.osee.framework.core.data.IDatabaseInfo;
-import org.eclipse.osee.framework.database.internal.parser.DbDetailData.ConfigField;
-import org.eclipse.osee.framework.database.internal.parser.DbSetupData.ServerInfoFields;
-import org.eclipse.osee.framework.jdk.core.type.Pair;
-
-/**
- * @author Roberto E. Escobar
- */
-public class DbInformation implements IDatabaseInfo {
-
- private static final long serialVersionUID = -4704655033702137367L;
- private final DbDetailData dbDetailData;
- private final DbSetupData dbSetupData;
- private final DbConnectionData dbConnectionData;
-
- public enum DbObjectType {
- ConnectionDescription,
- AvailableDbServices,
- DatabaseInfo
- }
-
- public DbInformation(DbDetailData dbDetailData, DbSetupData dbSetupData, DbConnectionData dbConnectionData) {
- this.dbDetailData = dbDetailData;
- this.dbSetupData = dbSetupData;
- this.dbConnectionData = dbConnectionData;
- }
-
- public DbConnectionData getConnectionData() {
- return dbConnectionData;
- }
-
- public DbDetailData getDatabaseDetails() {
- return dbDetailData;
- }
-
- public DbSetupData getDatabaseSetupDetails() {
- return dbSetupData;
- }
-
- public String getFormattedURL() {
- String toReturn = dbConnectionData.getRawUrl();
- Set<DbDetailData.ConfigField> keys = dbDetailData.getConfigMap().keySet();
- for (DbDetailData.ConfigField field : keys) {
- Pair<String, String> pair = dbDetailData.getConfigMap().get(field);
- if (pair.getSecond().startsWith("@")) {
- DbObjectType type = DbObjectType.valueOf(pair.getSecond().substring(1, pair.getSecond().indexOf('.')));
- String value = pair.getSecond().substring(pair.getSecond().indexOf('.') + 1);
- String realValue = getValue(type, value);
-
- toReturn = toReturn.replace(pair.getFirst(), realValue);
- } else {
- toReturn = toReturn.replace(pair.getFirst(), pair.getSecond());
- }
- }
- return toReturn;
- }
-
- private String getValue(DbObjectType type, String key) {
- switch (type) {
- case AvailableDbServices:
- return dbSetupData.getServerInfoValue(DbSetupData.ServerInfoFields.valueOf(key));
- case ConnectionDescription:
- break;
- case DatabaseInfo:
- break;
- }
- return "none";
- }
-
- @Override
- public String toString() {
- return getFormattedURL() + " : user=" + getDatabaseLoginName();
- }
-
- @Override
- public String getConnectionUrl() {
- return getFormattedURL() + getConnectionData().getAttributes();
- }
-
- @Override
- public Properties getConnectionProperties() {
- Properties properties = getConnectionData().getProperties();
- properties.setProperty("user", getDatabaseLoginName());
- properties.setProperty("password", getDatabaseDetails().getFieldValue(ConfigField.Password));
- return properties;
- }
-
- @Override
- public String getDatabaseLoginName() {
- return getDatabaseDetails().getFieldValue(ConfigField.UserName);
- }
-
- @Override
- public String getDatabaseName() {
- return getDatabaseDetails().getFieldValue(ConfigField.DatabaseName);
- }
-
- @Override
- public String getDriver() {
- return getConnectionData().getDBDriver();
- }
-
- @Override
- public String getId() {
- return getDatabaseSetupDetails().getId();
- }
-
- @Override
- public boolean isProduction() {
- return Boolean.valueOf(getDatabaseSetupDetails().getServerInfoValue(ServerInfoFields.isProduction));
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.database.internal.parser;
+
+import java.util.Properties;
+import java.util.Set;
+import org.eclipse.osee.framework.core.data.IDatabaseInfo;
+import org.eclipse.osee.framework.database.internal.parser.DbDetailData.ConfigField;
+import org.eclipse.osee.framework.database.internal.parser.DbSetupData.ServerInfoFields;
+import org.eclipse.osee.framework.jdk.core.type.Pair;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class DbInformation implements IDatabaseInfo {
+
+ private static final long serialVersionUID = -4704655033702137367L;
+ private final DbDetailData dbDetailData;
+ private final DbSetupData dbSetupData;
+ private final DbConnectionData dbConnectionData;
+
+ public enum DbObjectType {
+ ConnectionDescription,
+ AvailableDbServices,
+ DatabaseInfo
+ }
+
+ public DbInformation(DbDetailData dbDetailData, DbSetupData dbSetupData, DbConnectionData dbConnectionData) {
+ this.dbDetailData = dbDetailData;
+ this.dbSetupData = dbSetupData;
+ this.dbConnectionData = dbConnectionData;
+ }
+
+ public DbConnectionData getConnectionData() {
+ return dbConnectionData;
+ }
+
+ public DbDetailData getDatabaseDetails() {
+ return dbDetailData;
+ }
+
+ public DbSetupData getDatabaseSetupDetails() {
+ return dbSetupData;
+ }
+
+ public String getFormattedURL() {
+ String toReturn = dbConnectionData.getRawUrl();
+ Set<DbDetailData.ConfigField> keys = dbDetailData.getConfigMap().keySet();
+ for (DbDetailData.ConfigField field : keys) {
+ Pair<String, String> pair = dbDetailData.getConfigMap().get(field);
+ if (pair.getSecond().startsWith("@")) {
+ DbObjectType type = DbObjectType.valueOf(pair.getSecond().substring(1, pair.getSecond().indexOf('.')));
+ String value = pair.getSecond().substring(pair.getSecond().indexOf('.') + 1);
+ String realValue = getValue(type, value);
+
+ toReturn = toReturn.replace(pair.getFirst(), realValue);
+ } else {
+ toReturn = toReturn.replace(pair.getFirst(), pair.getSecond());
+ }
+ }
+ return toReturn;
+ }
+
+ private String getValue(DbObjectType type, String key) {
+ switch (type) {
+ case AvailableDbServices:
+ return dbSetupData.getServerInfoValue(DbSetupData.ServerInfoFields.valueOf(key));
+ case ConnectionDescription:
+ break;
+ case DatabaseInfo:
+ break;
+ }
+ return "none";
+ }
+
+ @Override
+ public String toString() {
+ return getFormattedURL() + " : user=" + getDatabaseLoginName();
+ }
+
+ @Override
+ public String getConnectionUrl() {
+ return getFormattedURL() + getConnectionData().getAttributes();
+ }
+
+ @Override
+ public Properties getConnectionProperties() {
+ Properties properties = getConnectionData().getProperties();
+ properties.setProperty("user", getDatabaseLoginName());
+ properties.setProperty("password", getDatabaseDetails().getFieldValue(ConfigField.Password));
+ return properties;
+ }
+
+ @Override
+ public String getDatabaseLoginName() {
+ return getDatabaseDetails().getFieldValue(ConfigField.UserName);
+ }
+
+ @Override
+ public String getDatabaseName() {
+ return getDatabaseDetails().getFieldValue(ConfigField.DatabaseName);
+ }
+
+ @Override
+ public String getDriver() {
+ return getConnectionData().getDBDriver();
+ }
+
+ @Override
+ public String getId() {
+ return getDatabaseSetupDetails().getId();
+ }
+
+ @Override
+ public boolean isProduction() {
+ return Boolean.valueOf(getDatabaseSetupDetails().getServerInfoValue(ServerInfoFields.isProduction));
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/trackers/OseeDatabaseServiceRegistrationHandler.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/trackers/OseeDatabaseServiceRegistrationHandler.java
index 174fd6f123..4642f7d77d 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/trackers/OseeDatabaseServiceRegistrationHandler.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/internal/trackers/OseeDatabaseServiceRegistrationHandler.java
@@ -1,55 +1,55 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database.internal.trackers;
-
-import java.util.Map;
-import org.eclipse.osee.framework.core.util.AbstractTrackingHandler;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.database.core.IDatabaseInfoProvider;
-import org.eclipse.osee.framework.database.internal.core.ConnectionFactoryProvider;
-import org.eclipse.osee.framework.database.internal.core.OseeDatabaseServiceImpl;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-
-/**
- * @author Roberto E. Escobar
- */
-public final class OseeDatabaseServiceRegistrationHandler extends AbstractTrackingHandler {
-
- private final static Class<?>[] SERVICE_DEPENDENCIES = new Class<?>[] {IDatabaseInfoProvider.class};
-
- private ServiceRegistration serviceRegistration;
-
- public OseeDatabaseServiceRegistrationHandler() {
- super();
- }
-
- @Override
- public Class<?>[] getDependencies() {
- return SERVICE_DEPENDENCIES;
- }
-
- @Override
- public void onActivate(BundleContext context, Map<Class<?>, Object> services) {
- IDatabaseInfoProvider dbInfoProvider = getService(IDatabaseInfoProvider.class, services);
-
- ConnectionFactoryProvider dbConnectionFactory = new ConnectionFactoryProvider(context);
- IOseeDatabaseService databaseService = new OseeDatabaseServiceImpl(dbInfoProvider, dbConnectionFactory);
- serviceRegistration = context.registerService(IOseeDatabaseService.class.getName(), databaseService, null);
- }
-
- @Override
- public void onDeActivate() {
- if (serviceRegistration != null) {
- serviceRegistration.unregister();
- }
- }
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.database.internal.trackers;
+
+import java.util.Map;
+import org.eclipse.osee.framework.core.util.AbstractTrackingHandler;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
+import org.eclipse.osee.framework.database.core.IDatabaseInfoProvider;
+import org.eclipse.osee.framework.database.internal.core.ConnectionFactoryProvider;
+import org.eclipse.osee.framework.database.internal.core.OseeDatabaseServiceImpl;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class OseeDatabaseServiceRegistrationHandler extends AbstractTrackingHandler {
+
+ private final static Class<?>[] SERVICE_DEPENDENCIES = new Class<?>[] {IDatabaseInfoProvider.class};
+
+ private ServiceRegistration serviceRegistration;
+
+ public OseeDatabaseServiceRegistrationHandler() {
+ super();
+ }
+
+ @Override
+ public Class<?>[] getDependencies() {
+ return SERVICE_DEPENDENCIES;
+ }
+
+ @Override
+ public void onActivate(BundleContext context, Map<Class<?>, Object> services) {
+ IDatabaseInfoProvider dbInfoProvider = getService(IDatabaseInfoProvider.class, services);
+
+ ConnectionFactoryProvider dbConnectionFactory = new ConnectionFactoryProvider(context);
+ IOseeDatabaseService databaseService = new OseeDatabaseServiceImpl(dbInfoProvider, dbConnectionFactory);
+ serviceRegistration = context.registerService(IOseeDatabaseService.class.getName(), databaseService, null);
+ }
+
+ @Override
+ public void onDeActivate() {
+ if (serviceRegistration != null) {
+ serviceRegistration.unregister();
+ }
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/operation/Address.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/operation/Address.java
index fa0d8bb47b..62eba303ee 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/operation/Address.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/operation/Address.java
@@ -1,139 +1,139 @@
-/*******************************************************************************
- * Copyright (c) 2010 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database.operation;
-
-import org.eclipse.osee.framework.core.enums.ModificationType;
-import org.eclipse.osee.framework.core.enums.TxChange;
-
-/**
- * @author Ryan D. Brooks
- */
-public final class Address implements Comparable<Address> {
- private final int branchId;
- private final int itemId;
- private final int transactionId;
- private final long gammaId;
- private ModificationType modType;
- private final TxChange txCurrent;
- private final boolean isBaseline;
- private TxChange correctedTxCurrent;
- private boolean purge;
-
- public Address(boolean isBaseline, int branchId, int itemId, int transactionId, long gammaId, ModificationType modType, TxChange txCurrent) {
- super();
- this.branchId = branchId;
- this.itemId = itemId;
- this.transactionId = transactionId;
- this.gammaId = gammaId;
- this.modType = modType;
- this.txCurrent = txCurrent;
- this.isBaseline = isBaseline;
- }
-
- public boolean isBaselineTx() {
- return isBaseline;
- }
-
- public boolean isSimilar(Address other) {
- return other != null && other.itemId == itemId && other.branchId == branchId;
- }
-
- public boolean isSameTransaction(Address other) {
- return other != null && transactionId == other.transactionId;
- }
-
- public boolean hasSameGamma(Address other) {
- return other != null && gammaId == other.gammaId;
- }
-
- public boolean hasSameModType(Address other) {
- return modType == other.modType;
- }
-
- public void ensureCorrectCurrent() {
- TxChange correctCurrent = TxChange.getCurrent(modType);
- if (txCurrent != correctCurrent) {
- correctedTxCurrent = correctCurrent;
- }
- }
-
- public void ensureNotCurrent() {
- if (txCurrent != TxChange.NOT_CURRENT) {
- correctedTxCurrent = TxChange.NOT_CURRENT;
- }
- }
-
- public boolean hasIssue() {
- return purge || correctedTxCurrent != null;
- }
-
- public TxChange getCorrectedTxCurrent() {
- return correctedTxCurrent;
- }
-
- public void setCorrectedTxCurrent(TxChange correctedTxCurrent) {
- this.correctedTxCurrent = correctedTxCurrent;
- }
-
- public boolean isPurge() {
- return purge;
- }
-
- public void setPurge(boolean purge) {
- this.purge = purge;
- }
-
- public int getBranchId() {
- return branchId;
- }
-
- public int getItemId() {
- return itemId;
- }
-
- public int getTransactionId() {
- return transactionId;
- }
-
- public long getGammaId() {
- return gammaId;
- }
-
- public ModificationType getModType() {
- return modType;
- }
-
- public void setModType(ModificationType modType) {
- this.modType = modType;
- }
-
- public TxChange getTxCurrent() {
- return txCurrent;
- }
-
- public boolean isBaseline() {
- return isBaseline;
- }
-
- @Override
- public String toString() {
- return "Address [branchId=" + branchId + ", gammaId=" + gammaId + ", itemId=" + itemId + ", modType=" + modType + ", transactionId=" + transactionId + ", txCurrent=" + txCurrent + "]";
- }
-
- @Override
- public int compareTo(Address otherAddress) {
- if (transactionId != otherAddress.transactionId) {
- return transactionId - otherAddress.transactionId;
- } else {
- return (int) (gammaId - otherAddress.gammaId);
- }
- }
+/*******************************************************************************
+ * Copyright (c) 2010 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.database.operation;
+
+import org.eclipse.osee.framework.core.enums.ModificationType;
+import org.eclipse.osee.framework.core.enums.TxChange;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public final class Address implements Comparable<Address> {
+ private final int branchId;
+ private final int itemId;
+ private final int transactionId;
+ private final long gammaId;
+ private ModificationType modType;
+ private final TxChange txCurrent;
+ private final boolean isBaseline;
+ private TxChange correctedTxCurrent;
+ private boolean purge;
+
+ public Address(boolean isBaseline, int branchId, int itemId, int transactionId, long gammaId, ModificationType modType, TxChange txCurrent) {
+ super();
+ this.branchId = branchId;
+ this.itemId = itemId;
+ this.transactionId = transactionId;
+ this.gammaId = gammaId;
+ this.modType = modType;
+ this.txCurrent = txCurrent;
+ this.isBaseline = isBaseline;
+ }
+
+ public boolean isBaselineTx() {
+ return isBaseline;
+ }
+
+ public boolean isSimilar(Address other) {
+ return other != null && other.itemId == itemId && other.branchId == branchId;
+ }
+
+ public boolean isSameTransaction(Address other) {
+ return other != null && transactionId == other.transactionId;
+ }
+
+ public boolean hasSameGamma(Address other) {
+ return other != null && gammaId == other.gammaId;
+ }
+
+ public boolean hasSameModType(Address other) {
+ return modType == other.modType;
+ }
+
+ public void ensureCorrectCurrent() {
+ TxChange correctCurrent = TxChange.getCurrent(modType);
+ if (txCurrent != correctCurrent) {
+ correctedTxCurrent = correctCurrent;
+ }
+ }
+
+ public void ensureNotCurrent() {
+ if (txCurrent != TxChange.NOT_CURRENT) {
+ correctedTxCurrent = TxChange.NOT_CURRENT;
+ }
+ }
+
+ public boolean hasIssue() {
+ return purge || correctedTxCurrent != null;
+ }
+
+ public TxChange getCorrectedTxCurrent() {
+ return correctedTxCurrent;
+ }
+
+ public void setCorrectedTxCurrent(TxChange correctedTxCurrent) {
+ this.correctedTxCurrent = correctedTxCurrent;
+ }
+
+ public boolean isPurge() {
+ return purge;
+ }
+
+ public void setPurge(boolean purge) {
+ this.purge = purge;
+ }
+
+ public int getBranchId() {
+ return branchId;
+ }
+
+ public int getItemId() {
+ return itemId;
+ }
+
+ public int getTransactionId() {
+ return transactionId;
+ }
+
+ public long getGammaId() {
+ return gammaId;
+ }
+
+ public ModificationType getModType() {
+ return modType;
+ }
+
+ public void setModType(ModificationType modType) {
+ this.modType = modType;
+ }
+
+ public TxChange getTxCurrent() {
+ return txCurrent;
+ }
+
+ public boolean isBaseline() {
+ return isBaseline;
+ }
+
+ @Override
+ public String toString() {
+ return "Address [branchId=" + branchId + ", gammaId=" + gammaId + ", itemId=" + itemId + ", modType=" + modType + ", transactionId=" + transactionId + ", txCurrent=" + txCurrent + "]";
+ }
+
+ @Override
+ public int compareTo(Address otherAddress) {
+ if (transactionId != otherAddress.transactionId) {
+ return transactionId - otherAddress.transactionId;
+ } else {
+ return (int) (gammaId - otherAddress.gammaId);
+ }
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/operation/InvalidTxCurrentsAndModTypes.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/operation/InvalidTxCurrentsAndModTypes.java
index 773157b50d..1a0da3e36a 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/operation/InvalidTxCurrentsAndModTypes.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/operation/InvalidTxCurrentsAndModTypes.java
@@ -1,194 +1,194 @@
-/*******************************************************************************
- * Copyright (c) 2010 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database.operation;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.core.enums.ModificationType;
-import org.eclipse.osee.framework.core.enums.TransactionDetailsType;
-import org.eclipse.osee.framework.core.enums.TxChange;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.core.operation.AbstractOperation;
-import org.eclipse.osee.framework.core.operation.OperationReporter;
-import org.eclipse.osee.framework.database.core.ConnectionHandler;
-import org.eclipse.osee.framework.database.core.IOseeStatement;
-import org.eclipse.osee.framework.database.internal.Activator;
-
-/**
- * @author Ryan D. Brooks
- */
-public class InvalidTxCurrentsAndModTypes extends AbstractOperation {
- private static final String SELECT_ADDRESSES =
- "select %s, txs.branch_id, txs.transaction_id, txs.gamma_id, txs.mod_type, txs.tx_current, txd.tx_type from %s t1, osee_txs%s txs, osee_tx_details txd where t1.gamma_id = txs.gamma_id and txd.transaction_id = txs.transaction_id and txs.branch_id = txd.branch_id order by txs.branch_id, %s, txs.transaction_id desc, txs.gamma_id desc";
-
- private static final String DELETE_ADDRESS = "delete from osee_txs%s where transaction_id = ? and gamma_id = ?";
- private static final String UPDATE_ADDRESS =
- "update osee_txs%s set tx_current = ? where transaction_id = ? and gamma_id = ?";
-
- private final List<Address> addresses = new ArrayList<Address>();
- private final OperationReporter reporter;
-
- private final List<Object[]> purgeData = new ArrayList<Object[]>();
- private final List<Object[]> currentData = new ArrayList<Object[]>();
- private final String tableName;
- private final String columnName;
- private final boolean isFixOperationEnabled;
- private final String txsTableName;
-
- public InvalidTxCurrentsAndModTypes(String tableName, String columnName, OperationReporter reporter, boolean isFixOperationEnabled, boolean archived) {
- super("InvalidTxCurrentsAndModTypes " + tableName + " " + archived, Activator.PLUGIN_ID);
- this.tableName = tableName;
- this.columnName = columnName;
- this.isFixOperationEnabled = isFixOperationEnabled;
- this.reporter = reporter;
- txsTableName = archived ? "_archived" : "";
- }
-
- private void fixIssues(IProgressMonitor monitor) throws OseeDataStoreException {
- if (isFixOperationEnabled) {
- checkForCancelledStatus(monitor);
- ConnectionHandler.runBatchUpdate(String.format(DELETE_ADDRESS, txsTableName), purgeData);
- ConnectionHandler.runBatchUpdate(String.format(UPDATE_ADDRESS, txsTableName), currentData);
- }
- monitor.worked(calculateWork(0.1));
- }
-
- private void logIssue(String issue, Address address) {
- reporter.report(issue, String.valueOf(address.getBranchId()), String.valueOf(address.getItemId()),
- String.valueOf(address.getTransactionId()), String.valueOf(address.getGammaId()),
- address.getModType().toString(), address.getTxCurrent().toString());
- }
-
- private void consolidateAddressing() {
- checkForMultipleVersionsInOneTransaction();
- checkForIdenticalAddressingInDifferentTransactions();
- checkForMultipleCurrents();
- checkForInvalidMergedModType();
-
- if (issueDetected()) {
- for (Address address : addresses) {
- if (address.isPurge()) {
- logIssue("purge", address);
- purgeData.add(new Object[] {address.getTransactionId(), address.getGammaId()});
- } else if (address.getCorrectedTxCurrent() != null) {
- logIssue("corrected txCurrent: " + address.getCorrectedTxCurrent(), address);
- currentData.add(new Object[] {address.getCorrectedTxCurrent().getValue(), address.getTransactionId(),
- address.getGammaId()});
- } else {
- System.out.println("would have fixed merge here");
- }
- }
- }
- }
-
- private void checkForInvalidMergedModType() {
- int index = addresses.size() - 1;
- Address lastAddress = addresses.get(index);
- if (!lastAddress.isBaselineTx()) {
- for (; index > -1; index--) {
- if (!addresses.get(index).isPurge()) {
- if (addresses.get(index).getModType() == ModificationType.MERGED) {
- logIssue("found merged mod type for item not in baseline: ", addresses.get(index));
- }
- return;
- }
- }
- }
- }
-
- private void checkForIdenticalAddressingInDifferentTransactions() {
- Address previousAddress = null;
-
- for (Address address : addresses) {
- if (address.hasSameGamma(previousAddress) && address.hasSameModType(previousAddress)) {
- previousAddress.setPurge(true);
- }
- previousAddress = address;
- }
- }
-
- private boolean issueDetected() {
- for (Address address : addresses) {
- if (address.hasIssue()) {
- return true;
- }
- }
- return false;
- }
-
- private void checkForMultipleVersionsInOneTransaction() {
- Address previousAddress = null;
-
- for (Address address : addresses) {
- if (address.isSameTransaction(previousAddress)) {
- if (address.hasSameModType(previousAddress) || !address.getModType().isDeleted() && previousAddress.getModType().isEdited()) {
- address.setPurge(true);
- } else {
- logIssue("multiple versions in one transaction - unknown case", address);
- }
- }
- previousAddress = address;
- }
- }
-
- private void checkForMultipleCurrents() {
- boolean mostRecentTx = true;
- for (Address address : addresses) {
- if (!address.isPurge()) {
- if (mostRecentTx) {
- address.ensureCorrectCurrent();
- mostRecentTx = false;
- } else {
- address.ensureNotCurrent();
- }
- }
- }
- }
-
- @Override
- protected void doWork(IProgressMonitor monitor) throws Exception {
- checkForCancelledStatus(monitor);
-
- IOseeStatement chStmt = ConnectionHandler.getStatement();
- String sql = String.format(SELECT_ADDRESSES, columnName, tableName, txsTableName, columnName);
- try {
- chStmt.runPreparedQuery(10000, sql);
- monitor.worked(calculateWork(0.40));
-
- Address previousAddress = null;
- while (chStmt.next()) {
- checkForCancelledStatus(monitor);
- ModificationType modType = ModificationType.getMod(chStmt.getInt("mod_type"));
- TxChange txCurrent = TxChange.getChangeType(chStmt.getInt("tx_current"));
- TransactionDetailsType type = TransactionDetailsType.toEnum(chStmt.getInt("tx_type"));
- Address address =
- new Address(type.isBaseline(), chStmt.getInt("branch_id"), chStmt.getInt(columnName),
- chStmt.getInt("transaction_id"), chStmt.getLong("gamma_id"), modType, txCurrent);
-
- if (!address.isSimilar(previousAddress)) {
- if (!addresses.isEmpty()) {
- consolidateAddressing();
- }
- addresses.clear();
- }
-
- addresses.add(address);
- previousAddress = address;
- }
- monitor.worked(calculateWork(0.5));
- } finally {
- chStmt.close();
- }
-
- fixIssues(monitor);
- }
+/*******************************************************************************
+ * Copyright (c) 2010 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.database.operation;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.enums.ModificationType;
+import org.eclipse.osee.framework.core.enums.TransactionDetailsType;
+import org.eclipse.osee.framework.core.enums.TxChange;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.core.operation.AbstractOperation;
+import org.eclipse.osee.framework.core.operation.OperationReporter;
+import org.eclipse.osee.framework.database.core.ConnectionHandler;
+import org.eclipse.osee.framework.database.core.IOseeStatement;
+import org.eclipse.osee.framework.database.internal.Activator;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class InvalidTxCurrentsAndModTypes extends AbstractOperation {
+ private static final String SELECT_ADDRESSES =
+ "select %s, txs.branch_id, txs.transaction_id, txs.gamma_id, txs.mod_type, txs.tx_current, txd.tx_type from %s t1, osee_txs%s txs, osee_tx_details txd where t1.gamma_id = txs.gamma_id and txd.transaction_id = txs.transaction_id and txs.branch_id = txd.branch_id order by txs.branch_id, %s, txs.transaction_id desc, txs.gamma_id desc";
+
+ private static final String DELETE_ADDRESS = "delete from osee_txs%s where transaction_id = ? and gamma_id = ?";
+ private static final String UPDATE_ADDRESS =
+ "update osee_txs%s set tx_current = ? where transaction_id = ? and gamma_id = ?";
+
+ private final List<Address> addresses = new ArrayList<Address>();
+ private final OperationReporter reporter;
+
+ private final List<Object[]> purgeData = new ArrayList<Object[]>();
+ private final List<Object[]> currentData = new ArrayList<Object[]>();
+ private final String tableName;
+ private final String columnName;
+ private final boolean isFixOperationEnabled;
+ private final String txsTableName;
+
+ public InvalidTxCurrentsAndModTypes(String tableName, String columnName, OperationReporter reporter, boolean isFixOperationEnabled, boolean archived) {
+ super("InvalidTxCurrentsAndModTypes " + tableName + " " + archived, Activator.PLUGIN_ID);
+ this.tableName = tableName;
+ this.columnName = columnName;
+ this.isFixOperationEnabled = isFixOperationEnabled;
+ this.reporter = reporter;
+ txsTableName = archived ? "_archived" : "";
+ }
+
+ private void fixIssues(IProgressMonitor monitor) throws OseeDataStoreException {
+ if (isFixOperationEnabled) {
+ checkForCancelledStatus(monitor);
+ ConnectionHandler.runBatchUpdate(String.format(DELETE_ADDRESS, txsTableName), purgeData);
+ ConnectionHandler.runBatchUpdate(String.format(UPDATE_ADDRESS, txsTableName), currentData);
+ }
+ monitor.worked(calculateWork(0.1));
+ }
+
+ private void logIssue(String issue, Address address) {
+ reporter.report(issue, String.valueOf(address.getBranchId()), String.valueOf(address.getItemId()),
+ String.valueOf(address.getTransactionId()), String.valueOf(address.getGammaId()),
+ address.getModType().toString(), address.getTxCurrent().toString());
+ }
+
+ private void consolidateAddressing() {
+ checkForMultipleVersionsInOneTransaction();
+ checkForIdenticalAddressingInDifferentTransactions();
+ checkForMultipleCurrents();
+ checkForInvalidMergedModType();
+
+ if (issueDetected()) {
+ for (Address address : addresses) {
+ if (address.isPurge()) {
+ logIssue("purge", address);
+ purgeData.add(new Object[] {address.getTransactionId(), address.getGammaId()});
+ } else if (address.getCorrectedTxCurrent() != null) {
+ logIssue("corrected txCurrent: " + address.getCorrectedTxCurrent(), address);
+ currentData.add(new Object[] {address.getCorrectedTxCurrent().getValue(), address.getTransactionId(),
+ address.getGammaId()});
+ } else {
+ System.out.println("would have fixed merge here");
+ }
+ }
+ }
+ }
+
+ private void checkForInvalidMergedModType() {
+ int index = addresses.size() - 1;
+ Address lastAddress = addresses.get(index);
+ if (!lastAddress.isBaselineTx()) {
+ for (; index > -1; index--) {
+ if (!addresses.get(index).isPurge()) {
+ if (addresses.get(index).getModType() == ModificationType.MERGED) {
+ logIssue("found merged mod type for item not in baseline: ", addresses.get(index));
+ }
+ return;
+ }
+ }
+ }
+ }
+
+ private void checkForIdenticalAddressingInDifferentTransactions() {
+ Address previousAddress = null;
+
+ for (Address address : addresses) {
+ if (address.hasSameGamma(previousAddress) && address.hasSameModType(previousAddress)) {
+ previousAddress.setPurge(true);
+ }
+ previousAddress = address;
+ }
+ }
+
+ private boolean issueDetected() {
+ for (Address address : addresses) {
+ if (address.hasIssue()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void checkForMultipleVersionsInOneTransaction() {
+ Address previousAddress = null;
+
+ for (Address address : addresses) {
+ if (address.isSameTransaction(previousAddress)) {
+ if (address.hasSameModType(previousAddress) || !address.getModType().isDeleted() && previousAddress.getModType().isEdited()) {
+ address.setPurge(true);
+ } else {
+ logIssue("multiple versions in one transaction - unknown case", address);
+ }
+ }
+ previousAddress = address;
+ }
+ }
+
+ private void checkForMultipleCurrents() {
+ boolean mostRecentTx = true;
+ for (Address address : addresses) {
+ if (!address.isPurge()) {
+ if (mostRecentTx) {
+ address.ensureCorrectCurrent();
+ mostRecentTx = false;
+ } else {
+ address.ensureNotCurrent();
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void doWork(IProgressMonitor monitor) throws Exception {
+ checkForCancelledStatus(monitor);
+
+ IOseeStatement chStmt = ConnectionHandler.getStatement();
+ String sql = String.format(SELECT_ADDRESSES, columnName, tableName, txsTableName, columnName);
+ try {
+ chStmt.runPreparedQuery(10000, sql);
+ monitor.worked(calculateWork(0.40));
+
+ Address previousAddress = null;
+ while (chStmt.next()) {
+ checkForCancelledStatus(monitor);
+ ModificationType modType = ModificationType.getMod(chStmt.getInt("mod_type"));
+ TxChange txCurrent = TxChange.getChangeType(chStmt.getInt("tx_current"));
+ TransactionDetailsType type = TransactionDetailsType.toEnum(chStmt.getInt("tx_type"));
+ Address address =
+ new Address(type.isBaseline(), chStmt.getInt("branch_id"), chStmt.getInt(columnName),
+ chStmt.getInt("transaction_id"), chStmt.getLong("gamma_id"), modType, txCurrent);
+
+ if (!address.isSimilar(previousAddress)) {
+ if (!addresses.isEmpty()) {
+ consolidateAddressing();
+ }
+ addresses.clear();
+ }
+
+ addresses.add(address);
+ previousAddress = address;
+ }
+ monitor.worked(calculateWork(0.5));
+ } finally {
+ chStmt.close();
+ }
+
+ fixIssues(monitor);
+ }
} \ No newline at end of file

Back to the top