Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2014-12-08 19:04:53 +0000
committerAngel Avila2014-12-08 19:04:53 +0000
commitec6358e83aead762af0ac8bf7d9a165c2cec09e0 (patch)
tree4fa438635e17a829ebb8e1ad35350954544d9935 /plugins/org.eclipse.osee.framework.database
parent225a60dac3e53219493fb3962ccee73deffc6620 (diff)
downloadorg.eclipse.osee-ec6358e83aead762af0ac8bf7d9a165c2cec09e0.tar.gz
org.eclipse.osee-ec6358e83aead762af0ac8bf7d9a165c2cec09e0.tar.xz
org.eclipse.osee-ec6358e83aead762af0ac8bf7d9a165c2cec09e0.zip
feature[ats_ATS144309]: Move client db JoinUtil to skynet.core
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.java119
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ArtifactJoinQuery.java119
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/CharJoinQuery.java83
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DatabaseJoinAccessor.java113
-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.java122
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/TransactionJoinQuery.java111
8 files changed, 0 insertions, 757 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
deleted file mode 100644
index d317689bd45..00000000000
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/AbstractJoinQuery.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database.core;
-
-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.database.core.DatabaseJoinAccessor.JoinItem;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-
-/**
- * @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 Long expiresIn;
- private final int queryId;
-
- protected final Set<IJoinRow> entries = new HashSet<IJoinRow>();
-
- private boolean wasStored;
- private int storedSize;
-
- protected AbstractJoinQuery(IJoinAccessor joinAccessor, JoinItem joinItem, Long expiresIn, int queryId) {
- this.joinAccessor = joinAccessor;
- this.joinItem = joinItem;
- this.expiresIn = expiresIn;
- this.queryId = queryId;
- 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 String getJoinTableName() {
- return joinItem.getJoinTableName();
- }
-
- public boolean wasStored() {
- return wasStored;
- }
-
- public void store(OseeConnection connection) throws OseeCoreException {
- if (!this.wasStored) {
- List<Object[]> data = new ArrayList<Object[]>();
- for (IJoinRow joinArray : entries) {
- data.add(joinArray.toArray());
- }
- joinAccessor.store(connection, joinItem, getQueryId(), data, getIssuedAt(), getExpiresIn());
- this.storedSize = this.entries.size();
- this.wasStored = true;
- this.entries.clear();
- } else {
- throw new OseeCoreException("Cannot store query id twice");
- }
- }
-
- private Long getIssuedAt() {
- return System.currentTimeMillis() / 1000L;
- }
-
- public Long getExpiresIn() {
- return expiresIn;
- }
-
- 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
deleted file mode 100644
index e6b2ff258ef..00000000000
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ArtifactJoinQuery.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database.core;
-
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.database.core.DatabaseJoinAccessor.JoinItem;
-
-/**
- * @author Roberto E. Escobar
- */
-public class ArtifactJoinQuery extends AbstractJoinQuery {
-
- private final int maxJoinSize;
-
- private final class Entry implements IJoinRow {
- private final Integer artId;
- private final Long branchUuid;
- private final Integer transactionId;
-
- private Entry(Integer artId, Long branchUuid, Integer transactionId) {
- this.artId = artId;
- this.branchUuid = branchUuid;
- this.transactionId = transactionId;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[] {
- getQueryId(),
- artId,
- branchUuid,
- transactionId != null ? transactionId : SQL3DataType.INTEGER};
- }
-
- @Override
- public String toString() {
- return String.format("art_id=%s, branch_id=%s, transaction_id=%s", artId, branchUuid, transactionId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- Entry other = (Entry) obj;
- if (!getOuterType().equals(other.getOuterType())) {
- return false;
- }
- if (artId == null) {
- if (other.artId != null) {
- return false;
- }
- } else if (!artId.equals(other.artId)) {
- return false;
- }
- if (branchUuid == null) {
- if (other.branchUuid != null) {
- return false;
- }
- } else if (!branchUuid.equals(other.branchUuid)) {
- return false;
- }
- if (transactionId == null) {
- if (other.transactionId != null) {
- return false;
- }
- } else if (!transactionId.equals(other.transactionId)) {
- return false;
- }
- return true;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + getOuterType().hashCode();
- result = prime * result + ((artId == null) ? 0 : artId.hashCode());
- result = prime * result + ((branchUuid == null) ? 0 : branchUuid.hashCode());
- result = prime * result + ((transactionId == null) ? 0 : transactionId.hashCode());
- return result;
- }
-
- private ArtifactJoinQuery getOuterType() {
- return ArtifactJoinQuery.this;
- }
- }
-
- public ArtifactJoinQuery(IJoinAccessor joinAccessor, Long expiresIn, int queryId, int maxJoinSize) {
- super(joinAccessor, JoinItem.ARTIFACT, expiresIn, queryId);
- this.maxJoinSize = maxJoinSize;
- }
-
- public void add(Integer art_id, Long branchUuid, Integer transactionId) {
- entries.add(new Entry(art_id, branchUuid, transactionId));
- if (entries.size() > maxJoinSize) {
- throw new OseeDataStoreException("Exceeded max artifact join size of [%d]", maxJoinSize);
- }
- }
-
- public void add(Integer art_id, Long branchUuid) {
- add(art_id, branchUuid, null);
- }
-
-} \ 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
deleted file mode 100644
index fde4635aa77..00000000000
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/CharJoinQuery.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.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 boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- CharJoinEntry other = (CharJoinEntry) obj;
- if (!getOuterType().equals(other.getOuterType())) {
- return false;
- }
- if (value == null) {
- if (other.value != null) {
- return false;
- }
- } else if (!value.equals(other.value)) {
- return false;
- }
- return true;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + getOuterType().hashCode();
- result = prime * result + ((value == null) ? 0 : value.hashCode());
- return result;
- }
-
- @Override
- public String toString() {
- return value;
- }
-
- private CharJoinQuery getOuterType() {
- return CharJoinQuery.this;
- }
- }
-
- public CharJoinQuery(IJoinAccessor joinAccessor, Long expiresIn, int queryId) {
- super(joinAccessor, JoinItem.CHAR_ID, expiresIn, 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
deleted file mode 100644
index eb35381ab80..00000000000
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DatabaseJoinAccessor.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database.core;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-
-/**
- * @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, art_id, branch_id, transaction_id) VALUES (?, ?, ?, ?)";
- private static final String INSERT_INTO_JOIN_TRANSACTION =
- "INSERT INTO osee_join_transaction (query_id, gamma_id, transaction_id, branch_id) VALUES (?, ?, ?, ?)";
-
- private static final String INSERT_INTO_JOIN_ID = "INSERT INTO osee_join_id (query_id, 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_CHAR_ID = "DELETE FROM osee_join_char_id WHERE query_id =?";
-
- private static final String INSERT_INTO_JOIN_CLEANUP =
- "INSERT INTO osee_join_cleanup (query_id, table_name, issued_at, expires_in) VALUES (?,?,?,?)";
-
- private static final String DELETE_FROM_JOIN_CLEANUP = "DELETE FROM osee_join_cleanup 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),
- ID("osee_join_id", INSERT_INTO_JOIN_ID, DELETE_FROM_JOIN_ID),
- 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;
-
- public DatabaseJoinAccessor(IOseeDatabaseService databaseService) {
- super();
- this.databaseService = databaseService;
- }
-
- @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);
- databaseService.runPreparedUpdate(connection, DELETE_FROM_JOIN_CLEANUP, queryId);
- }
- return updated;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public void store(OseeConnection connection, JoinItem joinItem, int queryId, List<Object[]> dataList, Long issuedAt, Long expiresIn) throws OseeCoreException {
- databaseService.runPreparedUpdate(connection, INSERT_INTO_JOIN_CLEANUP, queryId, joinItem.getJoinTableName(),
- issuedAt, expiresIn);
- databaseService.runBatchUpdate(connection, joinItem.getInsertSql(), dataList);
- }
-
- @Override
- public Collection<Integer> getAllQueryIds(OseeConnection connection, JoinItem joinItem) throws OseeCoreException {
- Collection<Integer> queryIds = new ArrayList<Integer>();
- IOseeStatement chStmt = databaseService.getStatement(connection);
- 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/IJoinAccessor.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IJoinAccessor.java
deleted file mode 100644
index 21a98e2931c..00000000000
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IJoinAccessor.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database.core;
-
-import java.util.Collection;
-import java.util.List;
-import org.eclipse.osee.framework.database.core.DatabaseJoinAccessor.JoinItem;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-
-/**
- * @author Roberto E. Escobar
- */
-public interface IJoinAccessor {
-
- void store(OseeConnection connection, JoinItem joinItem, int queryId, List<Object[]> dataList, Long issuedAt, Long expiresIn) 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
deleted file mode 100644
index c2a8c736bb0..00000000000
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IdJoinQuery.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database.core;
-
-import org.eclipse.osee.framework.database.core.DatabaseJoinAccessor.JoinItem;
-
-/**
- * @author Roberto E. Escobar
- */
-public class IdJoinQuery extends AbstractJoinQuery {
-
- private final class TempIdEntry implements IJoinRow {
- private final Long id;
-
- private TempIdEntry(Long id) {
- this.id = id;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[] {getQueryId(), 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.equals(this.id);
- }
-
- @Override
- public int hashCode() {
- return 37 * id.hashCode();
- }
-
- @Override
- public String toString() {
- return "id = " + id;
- }
- }
-
- public IdJoinQuery(IJoinAccessor joinAccessor, Long expiresIn, int queryId) {
- super(joinAccessor, JoinItem.ID, expiresIn, queryId);
- }
-
- public void add(Number id) {
- entries.add(new TempIdEntry(id.longValue()));
- }
-} \ 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
deleted file mode 100644
index 0bf2bd576c2..00000000000
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/JoinUtility.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.database.core;
-
-import java.util.Random;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.database.internal.ServiceUtil;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-
-/**
- * @author Roberto E. Escobar
- */
-public class JoinUtility {
-
- private static final Long DEFAULT_JOIN_EXPIRATION_SECONDS = 3L * 60L * 60L; // 3 hours
-
- private static final String EXPIRATION_SECS__ARTIFACT_JOIN_QUERY = "artifact.join.expiration.secs";
- private static final String EXPIRATION_SECS__CHAR_JOIN_QUERY = "char.join.expiration.secs";
- private static final String EXPIRATION_SECS__ID_JOIN_QUERY = "id.join.expiration.secs";
- private static final String EXPIRATION_SECS__TX_JOIN_QUERY = "tx.join.expiration.secs";
-
- private static final Random random = new Random();
-
- private JoinUtility() {
- // Utility Class
- }
-
- private static int getNewQueryId() {
- return random.nextInt();
- }
-
- private static IJoinAccessor createAccessor(IOseeDatabaseService service) {
- return new DatabaseJoinAccessor(service);
- }
-
- public static CharJoinQuery createCharJoinQuery(IOseeDatabaseService service) {
- return createCharJoinQuery(service, null);
- }
-
- public static CharJoinQuery createCharJoinQuery(IOseeDatabaseService service, Long expiresIn) {
- Long actualExpiration = getExpiresIn(service, expiresIn, EXPIRATION_SECS__CHAR_JOIN_QUERY);
- return new CharJoinQuery(createAccessor(service), actualExpiration, getNewQueryId());
- }
-
- public static IdJoinQuery createIdJoinQuery(IOseeDatabaseService service) {
- return createIdJoinQuery(service, null);
- }
-
- public static IdJoinQuery createIdJoinQuery(IOseeDatabaseService service, Long expiresIn) {
- Long actualExpiration = getExpiresIn(service, expiresIn, EXPIRATION_SECS__ID_JOIN_QUERY);
- return new IdJoinQuery(createAccessor(service), actualExpiration, getNewQueryId());
- }
-
- public static ArtifactJoinQuery createArtifactJoinQuery(IOseeDatabaseService service) {
- return createArtifactJoinQuery(service, null);
- }
-
- public static ArtifactJoinQuery createArtifactJoinQuery(IOseeDatabaseService service, Long expiresIn) {
- Long actualExpiration = getExpiresIn(service, expiresIn, EXPIRATION_SECS__ARTIFACT_JOIN_QUERY);
- return new ArtifactJoinQuery(createAccessor(service), actualExpiration, getNewQueryId(),
- getMaxArtifactJoinSize(service));
- }
-
- public static TransactionJoinQuery createTransactionJoinQuery(IOseeDatabaseService service) {
- return createTransactionJoinQuery(service, null);
- }
-
- public static TransactionJoinQuery createTransactionJoinQuery(IOseeDatabaseService service, Long expiresIn) {
- Long actualExpiration = getExpiresIn(service, expiresIn, EXPIRATION_SECS__TX_JOIN_QUERY);
- return new TransactionJoinQuery(createAccessor(service), actualExpiration, getNewQueryId());
- }
-
- ////////////////// Static Legacy Calls /////////////////////////
- private static IOseeDatabaseService getDatabase() throws OseeDataStoreException {
- return ServiceUtil.getDatabaseService();
- }
-
- public static IdJoinQuery createIdJoinQuery() throws OseeDataStoreException {
- return createIdJoinQuery(getDatabase());
- }
-
- public static ArtifactJoinQuery createArtifactJoinQuery() {
- IOseeDatabaseService service = getDatabase();
- return createArtifactJoinQuery(service);
- }
-
- public static TransactionJoinQuery createTransactionJoinQuery() {
- IOseeDatabaseService service = getDatabase();
- return createTransactionJoinQuery(service);
- }
-
- private static int getMaxArtifactJoinSize(IOseeDatabaseService service) {
- int toReturn = Integer.MAX_VALUE;
- String maxSize = OseeInfo.getValue(service, "artifact.join.max.size");
- if (Strings.isNumeric(maxSize)) {
- toReturn = Integer.parseInt(maxSize);
- }
- return toReturn;
- }
-
- private static Long getExpiresIn(IOseeDatabaseService service, Long actual, String defaultKey) {
- Long toReturn = DEFAULT_JOIN_EXPIRATION_SECONDS;
- if (actual != null) {
- toReturn = actual;
- } else {
- String expiration = OseeInfo.getValue(service, defaultKey);
- if (Strings.isNumeric(expiration)) {
- toReturn = Long.parseLong(expiration);
- }
- }
- return toReturn;
- }
-}
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
deleted file mode 100644
index d0a2d46a93b..00000000000
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/TransactionJoinQuery.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.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 Integer transactionId;
- private final Long branchUuid;
-
- private TempTransactionEntry(Long gammaId, Integer transactionId, Long branchUuid) {
- this.gammaId = gammaId;
- this.transactionId = transactionId;
- this.branchUuid = branchUuid;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[] {
- getQueryId(),
- gammaId,
- transactionId,
- branchUuid != null ? branchUuid : SQL3DataType.BIGINT};
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + getOuterType().hashCode();
- result = prime * result + ((branchUuid == null) ? 0 : branchUuid.hashCode());
- result = prime * result + ((gammaId == null) ? 0 : gammaId.hashCode());
- result = prime * result + ((transactionId == null) ? 0 : transactionId.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- TempTransactionEntry other = (TempTransactionEntry) obj;
- if (!getOuterType().equals(other.getOuterType())) {
- return false;
- }
- if (branchUuid == null) {
- if (other.branchUuid != null) {
- return false;
- }
- } else if (!branchUuid.equals(other.branchUuid)) {
- return false;
- }
- if (gammaId == null) {
- if (other.gammaId != null) {
- return false;
- }
- } else if (!gammaId.equals(other.gammaId)) {
- return false;
- }
- if (transactionId == null) {
- if (other.transactionId != null) {
- return false;
- }
- } else if (!transactionId.equals(other.transactionId)) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- return String.format("gamma_id=%s, tx_id=%s, branch_id=%s", gammaId, transactionId, branchUuid);
- }
-
- private TransactionJoinQuery getOuterType() {
- return TransactionJoinQuery.this;
- }
- }
-
- protected TransactionJoinQuery(IJoinAccessor joinAccessor, Long expiresIn, int queryId) {
- super(joinAccessor, JoinItem.TRANSACTION, expiresIn, queryId);
- }
-
- public void add(Long gammaId, Integer transactionId) {
- add(gammaId, transactionId, null);
- }
-
- public void add(Long gammaId, Integer transactionId, Long branchUuid) {
- entries.add(new TempTransactionEntry(gammaId, transactionId, branchUuid));
- }
-} \ No newline at end of file

Back to the top