Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2010-11-03 13:39:53 -0400
committerRyan D. Brooks2010-11-03 13:39:53 -0400
commit489952c3cc822596638d3ecb7d3c793af77e646c (patch)
tree961a6c22bb180d63da3aac0145d8cd6136a75999 /plugins/org.eclipse.osee.framework.database
parentcbf64db559f231e2432182f2a9ebf53b15dc652a (diff)
downloadorg.eclipse.osee-489952c3cc822596638d3ecb7d3c793af77e646c.tar.gz
org.eclipse.osee-489952c3cc822596638d3ecb7d3c793af77e646c.tar.xz
org.eclipse.osee-489952c3cc822596638d3ecb7d3c793af77e646c.zip
refactor: Split JoinUtility into top-level classes
Separate database access for testability Add getAllQueryIds to base join query class Remove getAllTagQueuQueryIds from JoinUtility Remove JoinUtility.deleteQuery methods
Diffstat (limited to 'plugins/org.eclipse.osee.framework.database')
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/AbstractJoinQuery.java118
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ArtifactJoinQuery.java65
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/CharJoinQuery.java50
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DatabaseJoinAccessor.java142
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ExportImportJoinQuery.java64
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IJoinAccessor.java28
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IdJoinQuery.java62
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/JoinUtility.java565
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/SearchTagJoinQuery.java62
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/TagQueueJoinQuery.java62
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/TransactionJoinQuery.java85
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/operation/ConsolidateArtifactVersionTxOperation.java2
12 files changed, 763 insertions, 542 deletions
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/AbstractJoinQuery.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/AbstractJoinQuery.java
new file mode 100644
index 0000000000..e1d7b22158
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/AbstractJoinQuery.java
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * 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.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.database.core.DatabaseJoinAccessor.JoinItem;
+import org.eclipse.osee.framework.jdk.core.util.time.GlobalTime;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public abstract class AbstractJoinQuery {
+
+ protected static interface IJoinRow {
+ Object[] toArray();
+
+ @Override
+ String toString();
+ }
+
+ private final IJoinAccessor joinAccessor;
+ private final JoinItem joinItem;
+ private final int queryId;
+
+ private final Timestamp insertTime;
+ protected final Set<IJoinRow> entries = new HashSet<IJoinRow>();
+
+ private boolean wasStored;
+ private int storedSize;
+
+ protected AbstractJoinQuery(IJoinAccessor joinAccessor, JoinItem joinItem, int queryId) {
+ this.joinAccessor = joinAccessor;
+ this.joinItem = joinItem;
+ this.queryId = queryId;
+ this.insertTime = GlobalTime.GreenwichMeanTimestamp();
+ this.storedSize = -1;
+ this.wasStored = false;
+ }
+
+ 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;
+ }
+
+ public String getJoinTableName() {
+ return joinItem.getJoinTableName();
+ }
+
+ public boolean wasStored() {
+ return wasStored;
+ }
+
+ public void store(OseeConnection connection) throws OseeCoreException {
+ if (this.wasStored != true) {
+ List<Object[]> data = new ArrayList<Object[]>();
+ for (IJoinRow joinArray : entries) {
+ data.add(joinArray.toArray());
+ }
+ joinAccessor.store(connection, joinItem, getQueryId(), data);
+ 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 OseeCoreException {
+ return joinAccessor.delete(connection, joinItem, getQueryId());
+ }
+
+ public void store() throws OseeCoreException {
+ store(null);
+ }
+
+ public int delete() throws OseeCoreException {
+ return delete(null);
+ }
+
+ public Collection<Integer> getAllQueryIds(OseeConnection connection) throws OseeCoreException {
+ return joinAccessor.getAllQueryIds(connection, joinItem);
+ }
+
+ public Collection<Integer> getAllQueryIds() throws OseeCoreException {
+ return joinAccessor.getAllQueryIds(null, joinItem);
+ }
+
+ @Override
+ public String toString() {
+ return String.format("id: [%s] entrySize: [%d]", getQueryId(), size());
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ArtifactJoinQuery.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ArtifactJoinQuery.java
new file mode 100644
index 0000000000..2ba4510fd7
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ArtifactJoinQuery.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * 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.database.core.DatabaseJoinAccessor.JoinItem;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class ArtifactJoinQuery extends AbstractJoinQuery {
+
+ 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;
+ }
+
+ @Override
+ 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;
+ }
+ }
+
+ protected ArtifactJoinQuery(IJoinAccessor joinAccessor, int queryId) {
+ super(joinAccessor, JoinItem.ARTIFACT, queryId);
+ }
+
+ public void add(Integer art_id, Integer branchId) {
+ entries.add(new Entry(art_id, branchId));
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/CharJoinQuery.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/CharJoinQuery.java
new file mode 100644
index 0000000000..7a092f6457
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/CharJoinQuery.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * 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.database.core.DatabaseJoinAccessor.JoinItem;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class CharJoinQuery extends AbstractJoinQuery {
+
+ 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;
+ }
+ }
+
+ protected CharJoinQuery(IJoinAccessor joinAccessor, int queryId) {
+ super(joinAccessor, JoinItem.CHAR_ID, queryId);
+ }
+
+ public void add(String value) {
+ entries.add(new CharJoinEntry(value));
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DatabaseJoinAccessor.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DatabaseJoinAccessor.java
new file mode 100644
index 0000000000..e3ea1d05f1
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DatabaseJoinAccessor.java
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * 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.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class DatabaseJoinAccessor implements IJoinAccessor {
+
+ private static final String SELECT_QUERY_IDS = "select DISTINCT query_id from %s";
+
+ 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 =?";
+
+ public enum JoinItem {
+ TRANSACTION("osee_join_transaction", INSERT_INTO_JOIN_TRANSACTION, DELETE_FROM_JOIN_TRANSACTION),
+ ARTIFACT("osee_join_artifact", INSERT_INTO_JOIN_ARTIFACT, DELETE_FROM_JOIN_ARTIFACT),
+ SEARCH_TAGS("osee_join_search_tags", INSERT_INTO_JOIN_SEARCH_TAGS, DELETE_FROM_JOIN_SEARCH_TAGS),
+ TAG_GAMMA_QUEUE("osee_tag_gamma_queue", INSERT_INTO_TAG_GAMMA_QUEUE, DELETE_FROM_TAG_GAMMA_QUEUE),
+ EXPORT_IMPORT("osee_join_export_import", INSERT_INTO_JOIN_EXPORT_IMPORT, DELETE_FROM_JOIN_EXPORT_IMPORT),
+ ID("osee_join_id", INSERT_INTO_JOIN_ID, DELETE_FROM_JOIN_ID),
+ JOIN("osee_join_cleanup", INSERT_INTO_JOIN_CLEANUP, DELETE_FROM_JOIN),
+ CHAR_ID("osee_join_char_id", INSERT_INTO_JOIN_CHAR_ID, DELETE_FROM_JOIN_CHAR_ID);
+
+ private final String tableName;
+ private final String deleteSql;
+ private final String insertSql;
+
+ JoinItem(String tableName, String insertSql, String deleteSql) {
+ this.tableName = tableName;
+ this.deleteSql = deleteSql;
+ this.insertSql = insertSql;
+ }
+
+ public String getDeleteSql() {
+ return deleteSql;
+ }
+
+ public String getInsertSql() {
+ return insertSql;
+ }
+
+ public String getJoinTableName() {
+ return tableName;
+ }
+ }
+
+ private final IOseeDatabaseService databaseService;
+ private final String sessionId;
+
+ public DatabaseJoinAccessor(IOseeDatabaseService databaseService, String sessionId) {
+ super();
+ this.databaseService = databaseService;
+ this.sessionId = sessionId;
+ }
+
+ public DatabaseJoinAccessor(IOseeDatabaseService databaseService) {
+ this(databaseService, null);
+ }
+
+ @Override
+ public int delete(OseeConnection connection, JoinItem joinItem, int queryId) throws OseeCoreException {
+ int updated = 0;
+ if (queryId != -1) {
+ updated = databaseService.runPreparedUpdate(connection, joinItem.getDeleteSql(), queryId);
+ if (sessionId != null) {
+ databaseService.runPreparedUpdate(connection, DELETE_FROM_JOIN, queryId);
+ }
+ }
+ return updated;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void store(OseeConnection connection, JoinItem joinItem, int queryId, List<Object[]> dataList) throws OseeCoreException {
+ databaseService.runBatchUpdate(connection, joinItem.getInsertSql(), dataList);
+ if (sessionId != null) {
+ databaseService.runPreparedUpdate(connection, INSERT_INTO_JOIN_CLEANUP, queryId, joinItem.getJoinTableName(),
+ sessionId);
+ }
+ }
+
+ @Override
+ public Collection<Integer> getAllQueryIds(OseeConnection connection, JoinItem joinItem) throws OseeCoreException {
+ Collection<Integer> queryIds = new ArrayList<Integer>();
+ IOseeStatement chStmt = databaseService.getStatement();
+ try {
+ String query = String.format(SELECT_QUERY_IDS, joinItem.getJoinTableName());
+ chStmt.runPreparedQuery(query);
+ while (chStmt.next()) {
+ queryIds.add(chStmt.getInt("query_id"));
+ }
+ } finally {
+ chStmt.close();
+ }
+ return queryIds;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ExportImportJoinQuery.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ExportImportJoinQuery.java
new file mode 100644
index 0000000000..9109688c0c
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ExportImportJoinQuery.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * 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.database.core.DatabaseJoinAccessor.JoinItem;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class ExportImportJoinQuery extends AbstractJoinQuery {
+
+ 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;
+ }
+
+ @Override
+ 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);
+ }
+ }
+
+ protected ExportImportJoinQuery(IJoinAccessor joinAccessor, int queryId) {
+ super(joinAccessor, JoinItem.EXPORT_IMPORT, queryId);
+ }
+
+ public void add(Long id1, Long id2) {
+ entries.add(new ExportImportEntry(id1, id2));
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IJoinAccessor.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IJoinAccessor.java
new file mode 100644
index 0000000000..6b84a9e0cc
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IJoinAccessor.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * 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.Collection;
+import java.util.List;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.database.core.DatabaseJoinAccessor.JoinItem;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface IJoinAccessor {
+
+ void store(OseeConnection connection, JoinItem joinItem, int queryId, List<Object[]> dataList) throws OseeCoreException;
+
+ int delete(OseeConnection connection, JoinItem joinItem, int queryId) throws OseeCoreException;
+
+ Collection<Integer> getAllQueryIds(OseeConnection connection, JoinItem joinItem) throws OseeCoreException;
+}
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IdJoinQuery.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IdJoinQuery.java
new file mode 100644
index 0000000000..5bd47720bd
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IdJoinQuery.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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.database.core.DatabaseJoinAccessor.JoinItem;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class IdJoinQuery extends AbstractJoinQuery {
+
+ private final class TempIdEntry implements IJoinRow {
+ private final int id;
+
+ private TempIdEntry(Integer id) {
+ this.id = id;
+ }
+
+ @Override
+ 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;
+ }
+ }
+
+ protected IdJoinQuery(IJoinAccessor joinAccessor, int queryId) {
+ super(joinAccessor, JoinItem.ID, queryId);
+ }
+
+ public void add(Integer id) {
+ entries.add(new TempIdEntry(id));
+ }
+} \ No newline at end of file
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 fcd76f707c..127eb256bc 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
@@ -10,582 +10,65 @@
*******************************************************************************/
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.OseeCoreException;
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() {
+ // Utility Class
}
- public static int getNewQueryId() {
+ private static int getNewQueryId() {
return random.nextInt();
}
- public static TransactionJoinQuery createTransactionJoinQuery() {
- return new TransactionJoinQuery(null);
+ private static IOseeDatabaseService getDatabase() throws OseeDataStoreException {
+ return Activator.getInstance().getOseeDatabaseService();
}
- public static IdJoinQuery createIdJoinQuery() {
- return new IdJoinQuery(null);
+ private static IJoinAccessor createAccessor() throws OseeDataStoreException {
+ IOseeDatabaseService service = getDatabase();
+ return new DatabaseJoinAccessor(service);
}
- public static ArtifactJoinQuery createArtifactJoinQuery() {
- return new ArtifactJoinQuery(null);
+ private static IJoinAccessor createAccessor(String sessionId) throws OseeDataStoreException {
+ IOseeDatabaseService service = getDatabase();
+ return new DatabaseJoinAccessor(service, sessionId);
}
- public static SearchTagJoinQuery createSearchTagJoinQuery() {
- return new SearchTagJoinQuery(null);
+ public static TransactionJoinQuery createTransactionJoinQuery() throws OseeDataStoreException {
+ return new TransactionJoinQuery(createAccessor(), getNewQueryId());
}
- public static TagQueueJoinQuery createTagQueueJoinQuery() {
- return new TagQueueJoinQuery(null);
+ public static IdJoinQuery createIdJoinQuery() throws OseeDataStoreException {
+ return new IdJoinQuery(createAccessor(), getNewQueryId());
}
- public static ExportImportJoinQuery createExportImportJoinQuery() {
- return new ExportImportJoinQuery(null);
+ public static ArtifactJoinQuery createArtifactJoinQuery() throws OseeDataStoreException {
+ return new ArtifactJoinQuery(createAccessor(), getNewQueryId());
}
- public static CharJoinQuery createCharJoinQuery(String sessionId) {
- return new CharJoinQuery(sessionId);
- }
-
- public static List<Integer> getAllTagQueueQueryIds() throws OseeCoreException {
- 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 OseeCoreException {
- 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 OseeCoreException {
- 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 OseeCoreException {
- store(null);
- }
-
- public int delete() throws OseeCoreException {
- return delete(null);
- }
-
- @Override
- public String toString() {
- return String.format("id: [%s] entrySize: [%d]", getQueryId(), size());
- }
+ public static SearchTagJoinQuery createSearchTagJoinQuery() throws OseeDataStoreException {
+ return new SearchTagJoinQuery(createAccessor(), getNewQueryId());
}
- public static void deleteQuery(OseeConnection connection, JoinItem item, int queryId) throws Exception {
- if (item != null) {
- ConnectionHandler.runPreparedUpdate(connection, item.getDeleteSql(), queryId);
- }
+ public static TagQueueJoinQuery createTagQueueJoinQuery() throws OseeDataStoreException {
+ return new TagQueueJoinQuery(createAccessor(), getNewQueryId());
}
- public static void deleteQuery(JoinItem item, int queryId) throws Exception {
- if (item != null) {
- ConnectionHandler.runPreparedUpdate(item.getDeleteSql(), queryId);
- }
+ public static ExportImportJoinQuery createExportImportJoinQuery() throws OseeDataStoreException {
+ return new ExportImportJoinQuery(createAccessor(), getNewQueryId());
}
- private interface IJoinRow {
- public Object[] toArray();
-
- @Override
- 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;
- }
-
- @Override
- 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;
- }
-
- @Override
- 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;
- }
-
- @Override
- 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;
- }
-
- @Override
- 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;
- }
-
- @Override
- 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;
- }
-
- @Override
- 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";
- }
+ public static CharJoinQuery createCharJoinQuery(String sessionId) throws OseeDataStoreException {
+ return new CharJoinQuery(createAccessor(sessionId), getNewQueryId());
}
}
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/SearchTagJoinQuery.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/SearchTagJoinQuery.java
new file mode 100644
index 0000000000..c367bd8020
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/SearchTagJoinQuery.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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.database.core.DatabaseJoinAccessor.JoinItem;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class SearchTagJoinQuery extends AbstractJoinQuery {
+
+ private final class TagEntry implements IJoinRow {
+ private final long value;
+
+ private TagEntry(Long value) {
+ this.value = value;
+ }
+
+ @Override
+ 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);
+ }
+ }
+
+ protected SearchTagJoinQuery(IJoinAccessor joinAccessor, int queryId) {
+ super(joinAccessor, JoinItem.SEARCH_TAGS, queryId);
+ }
+
+ public void add(Long tag) {
+ entries.add(new TagEntry(tag));
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/TagQueueJoinQuery.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/TagQueueJoinQuery.java
new file mode 100644
index 0000000000..b1c996a579
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/TagQueueJoinQuery.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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.database.core.DatabaseJoinAccessor.JoinItem;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class TagQueueJoinQuery extends AbstractJoinQuery {
+
+ private final class GammaEntry implements IJoinRow {
+ private final long gammaId;
+
+ private GammaEntry(Long gammaId) {
+ this.gammaId = gammaId;
+ }
+
+ @Override
+ 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);
+ }
+ }
+
+ protected TagQueueJoinQuery(IJoinAccessor joinAccessor, int queryId) {
+ super(joinAccessor, JoinItem.TAG_GAMMA_QUEUE, queryId);
+ }
+
+ public void add(Long gammaId) {
+ entries.add(new GammaEntry(gammaId));
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/TransactionJoinQuery.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/TransactionJoinQuery.java
new file mode 100644
index 0000000000..77c6520897
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/TransactionJoinQuery.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * 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.database.core.DatabaseJoinAccessor.JoinItem;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class TransactionJoinQuery extends AbstractJoinQuery {
+
+ 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;
+ }
+
+ @Override
+ public Object[] toArray() {
+ return new Object[] {getQueryId(), getInsertTime(), gammaId, transactionId};
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + getOuterType().hashCode();
+ result = prime * result + (int) (gammaId ^ (gammaId >>> 32));
+ result = prime * result + transactionId;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ TempTransactionEntry other = (TempTransactionEntry) obj;
+ if (!getOuterType().equals(other.getOuterType())) {
+ return false;
+ }
+ if (gammaId != other.gammaId) {
+ return false;
+ }
+ if (transactionId != other.transactionId) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("gamma_id=%s, tx_id=%s", gammaId, transactionId);
+ }
+
+ private TransactionJoinQuery getOuterType() {
+ return TransactionJoinQuery.this;
+ }
+ }
+
+ protected TransactionJoinQuery(IJoinAccessor joinAccessor, int queryId) {
+ super(joinAccessor, JoinItem.TRANSACTION, queryId);
+ }
+
+ public void add(Long gammaId, Integer transactionId) {
+ entries.add(new TempTransactionEntry(gammaId, transactionId));
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/operation/ConsolidateArtifactVersionTxOperation.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/operation/ConsolidateArtifactVersionTxOperation.java
index fb5752a973..d75f431004 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/operation/ConsolidateArtifactVersionTxOperation.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/operation/ConsolidateArtifactVersionTxOperation.java
@@ -20,9 +20,9 @@ import org.eclipse.osee.framework.core.exception.OseeStateException;
import org.eclipse.osee.framework.core.operation.OperationReporter;
import org.eclipse.osee.framework.database.IOseeDatabaseService;
import org.eclipse.osee.framework.database.core.AbstractDbTxOperation;
+import org.eclipse.osee.framework.database.core.ExportImportJoinQuery;
import org.eclipse.osee.framework.database.core.IOseeStatement;
import org.eclipse.osee.framework.database.core.JoinUtility;
-import org.eclipse.osee.framework.database.core.JoinUtility.ExportImportJoinQuery;
import org.eclipse.osee.framework.database.core.OseeConnection;
import org.eclipse.osee.framework.database.internal.Activator;

Back to the top