Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ArtifactJoinQuery.java120
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DatabaseJoinAccessor.java2
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/JoinUtility.java27
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/TransactionJoinQuery.java112
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactLoader.java183
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/BranchManager.java23
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/PurgeArtifacts.java180
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/UpdateMergeBranch.java30
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeManager.java50
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ConflictManagerInternal.java29
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/acquirer/AttributeChangeAcquirer.java61
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/TransactionJoinQueryTest.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/ArtifactJoinQuery.java11
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/DatabaseJoinAccessor.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/ExportImportJoinQuery.java41
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/IdJoinQuery.java29
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/TagQueueJoinQuery.java31
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/TransactionJoinQuery.java48
18 files changed, 618 insertions, 365 deletions
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 00000000000..ee58f2dba0f
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ArtifactJoinQuery.java
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * 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(),
+ getInsertTime(),
+ 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, int queryId, int maxJoinSize) {
+ super(joinAccessor, JoinItem.ARTIFACT, 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/DatabaseJoinAccessor.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DatabaseJoinAccessor.java
index 5f233056be8..cd72c9d88f3 100644
--- 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
@@ -27,7 +27,7 @@ public class DatabaseJoinAccessor implements IJoinAccessor {
"INSERT INTO osee_join_artifact (query_id, insert_time, art_id, branch_id, transaction_id) VALUES (?, ?, ?, ?, ?)";
private static final String INSERT_INTO_JOIN_TRANSACTION =
- "INSERT INTO osee_join_transaction (query_id, insert_time, gamma_id, transaction_id) VALUES (?, ?, ?, ?)";
+ "INSERT INTO osee_join_transaction (query_id, insert_time, gamma_id, transaction_id, branch_id) VALUES (?, ?, ?, ?, ?)";
private static final String INSERT_INTO_TAG_GAMMA_QUEUE =
"INSERT INTO osee_tag_gamma_queue (query_id, insert_time, gamma_id) VALUES (?, ?, ?)";
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 cfe792d6b0e..13bd80a78af 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
@@ -14,6 +14,7 @@ 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
@@ -42,6 +43,14 @@ public class JoinUtility {
return new IdJoinQuery(createAccessor(service), getNewQueryId());
}
+ public static ArtifactJoinQuery createArtifactJoinQuery(IOseeDatabaseService service) {
+ return new ArtifactJoinQuery(createAccessor(service), getNewQueryId(), getMaxArtifactJoinSize(service));
+ }
+
+ public static TransactionJoinQuery createTransactionJoinQuery(IOseeDatabaseService service) {
+ return new TransactionJoinQuery(createAccessor(service), getNewQueryId());
+ }
+
////////////////// Static Legacy Calls /////////////////////////
private static IOseeDatabaseService getDatabase() throws OseeDataStoreException {
return ServiceUtil.getDatabaseService();
@@ -51,4 +60,22 @@ public class JoinUtility {
return new IdJoinQuery(createAccessor(getDatabase()), getNewQueryId());
}
+ 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.getCachedValue(service, "artifact.join.max.size");
+ if (Strings.isNumeric(maxSize)) {
+ toReturn = Integer.parseInt(maxSize);
+ }
+ 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
new file mode 100644
index 00000000000..05ffe376026
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/TransactionJoinQuery.java
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.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(),
+ getInsertTime(),
+ 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, int queryId) {
+ super(joinAccessor, JoinItem.TRANSACTION, 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
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactLoader.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactLoader.java
index 4d2e0895a23..02a0266c44b 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactLoader.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactLoader.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.osee.framework.skynet.core.artifact;
-import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
@@ -19,7 +18,6 @@ import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
-import java.util.Random;
import java.util.Set;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level;
@@ -32,16 +30,15 @@ import org.eclipse.osee.framework.core.enums.ModificationType;
import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.TransactionRecord;
+import org.eclipse.osee.framework.database.core.ArtifactJoinQuery;
import org.eclipse.osee.framework.database.core.ConnectionHandler;
import org.eclipse.osee.framework.database.core.IOseeStatement;
-import org.eclipse.osee.framework.database.core.OseeConnection;
+import org.eclipse.osee.framework.database.core.JoinUtility;
import org.eclipse.osee.framework.database.core.OseeSql;
-import org.eclipse.osee.framework.database.core.SQL3DataType;
import org.eclipse.osee.framework.jdk.core.type.CompositeKeyHashMap;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.Pair;
import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.framework.jdk.core.util.time.GlobalTime;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.internal.Activator;
@@ -50,13 +47,8 @@ import org.eclipse.osee.framework.skynet.core.internal.Activator;
*/
public final class ArtifactLoader {
- private static final String INSERT_JOIN_ARTIFACT =
- "INSERT INTO osee_join_artifact (query_id, insert_time, art_id, branch_id, transaction_id) VALUES (?, ?, ?, ?, ?)";
- private static final String DELETE_FROM_JOIN_ARTIFACT = "DELETE FROM osee_join_artifact WHERE query_id = ?";
-
private static final CompositeKeyHashMap<Integer, Long, ReentrantLock> loadingActiveMap =
new CompositeKeyHashMap<Integer, Long, ReentrantLock>(1000, true);
- private static final Random queryRandom = new Random();
/**
* (re)loads the artifacts selected by sql and then returns them in a list
@@ -193,52 +185,48 @@ public final class ArtifactLoader {
}
private static void loadArtifactsFromQueryId(Collection<Artifact> loadedItems, int queryId, LoadLevel loadLevel, ISearchConfirmer confirmer, int fetchSize, LoadType reload, TransactionRecord transactionId, DeletionFlag allowDeleted) throws OseeCoreException {
- try {
- OseeSql sqlKey;
- boolean historical = transactionId != null;
- if (historical) {
- sqlKey = OseeSql.LOAD_HISTORICAL_ARTIFACTS;
- } else if (allowDeleted == DeletionFlag.INCLUDE_DELETED) {
- sqlKey = OseeSql.LOAD_CURRENT_ARTIFACTS_WITH_DELETED;
- } else {
- sqlKey = OseeSql.LOAD_CURRENT_ARTIFACTS;
- }
+ OseeSql sqlKey;
+ boolean historical = transactionId != null;
+ if (historical) {
+ sqlKey = OseeSql.LOAD_HISTORICAL_ARTIFACTS;
+ } else if (allowDeleted == DeletionFlag.INCLUDE_DELETED) {
+ sqlKey = OseeSql.LOAD_CURRENT_ARTIFACTS_WITH_DELETED;
+ } else {
+ sqlKey = OseeSql.LOAD_CURRENT_ARTIFACTS;
+ }
+
+ IOseeStatement chStmt = ConnectionHandler.getStatement();
- IOseeStatement chStmt = ConnectionHandler.getStatement();
+ String sql = null;
+ try {
+ sql = ClientSessionManager.getSql(sqlKey);
+ chStmt.runPreparedQuery(fetchSize, sql, queryId);
- String sql = null;
- try {
- sql = ClientSessionManager.getSql(sqlKey);
- chStmt.runPreparedQuery(fetchSize, sql, queryId);
-
- int previousArtId = -1;
- long previousBranchId = -1;
- while (chStmt.next()) {
- int artId = chStmt.getInt("art_id");
- long branchUuid = chStmt.getLong("branch_id");
- // assumption: sql is returning rows ordered by branch_id, art_id, transaction_id in descending order
- if (previousArtId != artId || previousBranchId != branchUuid) {
- // assumption: sql is returning unwanted deleted artifacts only in the historical case
- if (!historical || allowDeleted == DeletionFlag.INCLUDE_DELETED || ModificationType.getMod(chStmt.getInt("mod_type")) != ModificationType.DELETED) {
- Artifact shallowArtifact = retrieveShallowArtifact(chStmt, reload, historical);
- loadedItems.add(shallowArtifact);
- }
+ int previousArtId = -1;
+ long previousBranchId = -1;
+ while (chStmt.next()) {
+ int artId = chStmt.getInt("art_id");
+ long branchUuid = chStmt.getLong("branch_id");
+ // assumption: sql is returning rows ordered by branch_id, art_id, transaction_id in descending order
+ if (previousArtId != artId || previousBranchId != branchUuid) {
+ // assumption: sql is returning unwanted deleted artifacts only in the historical case
+ if (!historical || allowDeleted == DeletionFlag.INCLUDE_DELETED || ModificationType.getMod(chStmt.getInt("mod_type")) != ModificationType.DELETED) {
+ Artifact shallowArtifact = retrieveShallowArtifact(chStmt, reload, historical);
+ loadedItems.add(shallowArtifact);
}
- previousArtId = artId;
- previousBranchId = branchUuid;
}
- } catch (OseeDataStoreException ex) {
- OseeLog.logf(Activator.class, Level.SEVERE, ex, "%s - %s", sqlKey, sql == null ? "SQL unknown" : sql);
- throw ex;
- } finally {
- chStmt.close();
- }
-
- if (confirmer == null || confirmer.canProceed(loadedItems.size())) {
- loadArtifactsData(queryId, loadedItems, loadLevel, reload, transactionId, allowDeleted);
+ previousArtId = artId;
+ previousBranchId = branchUuid;
}
+ } catch (OseeDataStoreException ex) {
+ OseeLog.logf(Activator.class, Level.SEVERE, ex, "%s - %s", sqlKey, sql == null ? "SQL unknown" : sql);
+ throw ex;
} finally {
- clearQuery(queryId);
+ chStmt.close();
+ }
+
+ if (confirmer == null || confirmer.canProceed(loadedItems.size())) {
+ loadArtifactsData(queryId, loadedItems, loadLevel, reload, transactionId, allowDeleted);
}
}
@@ -250,89 +238,45 @@ public final class ArtifactLoader {
*/
private static void loadArtifacts(List<Pair<Integer, Long>> toLoad, LoadLevel loadLevel, TransactionRecord transactionId, LoadType reload, DeletionFlag allowDeleted, Set<Artifact> artifacts) throws OseeCoreException {
if (toLoad != null && !toLoad.isEmpty()) {
- int queryId = ArtifactLoader.getNewQueryId();
- Timestamp insertTime = GlobalTime.GreenwichMeanTimestamp();
- boolean historical = transactionId != null;
-
- List<Object[]> insertParameters = new LinkedList<Object[]>();
+ ArtifactJoinQuery joinQuery = JoinUtility.createArtifactJoinQuery();
+ Integer txId = transactionId != null ? transactionId.getId() : null;
for (Pair<Integer, Long> pair : toLoad) {
- insertParameters.add(new Object[] {
- queryId,
- insertTime,
- pair.getFirst(),
- pair.getSecond(),
- historical ? transactionId.getId() : SQL3DataType.INTEGER});
+ joinQuery.add(pair.getFirst(), pair.getSecond(), txId);
}
-
- loadArtifacts(artifacts, queryId, loadLevel, null, insertParameters, reload, transactionId, allowDeleted);
+ loadArtifacts(artifacts, joinQuery, loadLevel, null, reload, transactionId, allowDeleted);
}
}
- private static void loadArtifacts(Collection<Artifact> loadedItems, int queryId, LoadLevel loadLevel, ISearchConfirmer confirmer, List<Object[]> insertParameters, LoadType reload, TransactionRecord transactionId, DeletionFlag allowDeleted) throws OseeCoreException {
- if (!insertParameters.isEmpty()) {
+ private static void loadArtifacts(Collection<Artifact> loadedItems, ArtifactJoinQuery joinQuery, LoadLevel loadLevel, ISearchConfirmer confirmer, LoadType reload, TransactionRecord transactionId, DeletionFlag allowDeleted) throws OseeCoreException {
+ if (!joinQuery.isEmpty()) {
Collection<Artifact> data;
if (loadedItems.isEmpty()) {
data = loadedItems;
} else {
// Use a new list if loaded items already contains data to prevent artifact overwrites during loading
- data = new ArrayList<Artifact>(insertParameters.size());
+ data = new ArrayList<Artifact>(joinQuery.size());
}
long time = System.currentTimeMillis();
try {
- insertIntoArtifactJoin(insertParameters);
- loadArtifactsFromQueryId(data, queryId, loadLevel, confirmer, insertParameters.size(), reload,
+ joinQuery.store();
+ loadArtifactsFromQueryId(data, joinQuery.getQueryId(), loadLevel, confirmer, joinQuery.size(), reload,
transactionId, allowDeleted);
} finally {
- if (data != loadedItems) {
- loadedItems.addAll(data);
+ try {
+ if (data != loadedItems) {
+ loadedItems.addAll(data);
+ }
+ OseeLog.logf(Activator.class, Level.FINE, new Exception("Artifact Load Time"),
+ "Artifact Load Time [%s] for [%d] artifacts. ", Lib.getElapseString(time), loadedItems.size());
+ } finally {
+ joinQuery.delete();
}
- OseeLog.logf(Activator.class, Level.FINE, new Exception("Artifact Load Time"),
- "Artifact Load Time [%s] for [%d] artifacts. ", Lib.getElapseString(time), loadedItems.size());
- clearQuery(queryId);
}
}
}
/**
- * must be call in a try block with a finally clause which calls clearQuery()
- */
- public static int insertIntoArtifactJoin(OseeConnection connection, List<Object[]> insertParameters) throws OseeCoreException {
- return ConnectionHandler.runBatchUpdate(connection, INSERT_JOIN_ARTIFACT, insertParameters);
- }
-
- /**
- * must be call in a try block with a finally clause which calls clearQuery()
- */
- public static int insertIntoArtifactJoin(List<Object[]> insertParameters) throws OseeCoreException {
- return insertIntoArtifactJoin(null, insertParameters);
- }
-
- /**
- * should only be used in tandem with with selectArtifacts()
- *
- * @param queryId value gotten from call to getNewQueryId and used in populating the insert parameters for
- * selectArtifacts
- */
- public static void clearQuery(int queryId) throws OseeCoreException {
- ConnectionHandler.runPreparedUpdate(DELETE_FROM_JOIN_ARTIFACT, queryId);
- }
-
- /**
- * should only be used in tandem with with selectArtifacts()
- *
- * @param queryId value gotten from call to getNewQueryId and used in populating the insert parameters for
- * selectArtifacts
- */
- public static void clearQuery(OseeConnection connection, int queryId) throws OseeCoreException {
- if (connection != null) {
- ConnectionHandler.runPreparedUpdate(connection, DELETE_FROM_JOIN_ARTIFACT, queryId);
- } else {
- ConnectionHandler.runPreparedUpdate(DELETE_FROM_JOIN_ARTIFACT, queryId);
- }
- }
-
- /**
* Determines the artIds and branchUuids of artifacts to load based on sql and queryParameters
*/
private static List<Pair<Integer, Long>> selectArtifacts(String sql, Object[] queryParameters, int artifactCountEstimate) throws OseeCoreException {
@@ -387,26 +331,22 @@ public final class ArtifactLoader {
return artifact;
}
- @SuppressWarnings("unchecked")
static void loadArtifactData(Artifact artifact, LoadLevel loadLevel) throws OseeCoreException {
- int queryId = getNewQueryId();
- Timestamp insertTime = GlobalTime.GreenwichMeanTimestamp();
-
+ ArtifactJoinQuery joinQuery = JoinUtility.createArtifactJoinQuery();
try {
- ConnectionHandler.runPreparedUpdate(INSERT_JOIN_ARTIFACT, queryId, insertTime, artifact.getArtId(),
- artifact.getFullBranch().getUuid(), SQL3DataType.INTEGER);
+ joinQuery.add(artifact.getArtId(), artifact.getFullBranch().getUuid());
+ joinQuery.store();
List<Artifact> artifacts = new ArrayList<Artifact>(1);
artifacts.add(artifact);
- loadArtifactsData(queryId, artifacts, loadLevel, LoadType.INCLUDE_CACHE, null,
+ loadArtifactsData(joinQuery.getQueryId(), artifacts, loadLevel, LoadType.INCLUDE_CACHE, null,
artifact.isDeleted() ? DeletionFlag.INCLUDE_DELETED : DeletionFlag.EXCLUDE_DELETED);
} finally {
- clearQuery(queryId);
+ joinQuery.delete();
}
}
private static void loadArtifactsData(int queryId, Collection<Artifact> artifacts, LoadLevel loadLevel, LoadType reload, TransactionRecord transactionId, DeletionFlag allowDeleted) throws OseeCoreException {
-
if (reload == LoadType.RELOAD_CACHE) {
for (Artifact artifact : artifacts) {
artifact.prepareForReload();
@@ -434,7 +374,4 @@ public final class ArtifactLoader {
}
}
- public static int getNewQueryId() {
- return queryRandom.nextInt(Integer.MAX_VALUE);
- }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/BranchManager.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/BranchManager.java
index b19e139fe86..614820f308a 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/BranchManager.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/BranchManager.java
@@ -11,11 +11,9 @@
package org.eclipse.osee.framework.skynet.core.artifact;
-import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -45,14 +43,14 @@ import org.eclipse.osee.framework.core.operation.IOperation;
import org.eclipse.osee.framework.core.operation.OperationBuilder;
import org.eclipse.osee.framework.core.operation.Operations;
import org.eclipse.osee.framework.database.IOseeDatabaseService;
+import org.eclipse.osee.framework.database.core.ArtifactJoinQuery;
import org.eclipse.osee.framework.database.core.IOseeStatement;
+import org.eclipse.osee.framework.database.core.JoinUtility;
import org.eclipse.osee.framework.database.core.OseeInfo;
-import org.eclipse.osee.framework.database.core.SQL3DataType;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Conditions;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.framework.jdk.core.util.time.GlobalTime;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.plugin.core.util.ExtensionDefinedObjects;
import org.eclipse.osee.framework.skynet.core.UserManager;
@@ -403,20 +401,13 @@ public class BranchManager {
}
private static MergeBranch createMergeBranch(final Branch sourceBranch, final Branch destBranch, final ArrayList<Integer> expectedArtIds) throws OseeCoreException {
- Timestamp insertTime = GlobalTime.GreenwichMeanTimestamp();
- int mergeAddressingQueryId = ArtifactLoader.getNewQueryId();
- List<Object[]> datas = new LinkedList<Object[]>();
+ ArtifactJoinQuery joinQuery = JoinUtility.createArtifactJoinQuery();
for (int artId : expectedArtIds) {
- datas.add(new Object[] {
- mergeAddressingQueryId,
- insertTime,
- artId,
- sourceBranch.getUuid(),
- SQL3DataType.INTEGER});
+ joinQuery.add(artId, sourceBranch.getUuid());
}
MergeBranch mergeBranch = null;
try {
- ArtifactLoader.insertIntoArtifactJoin(datas);
+ joinQuery.store();
int parentTxId = sourceBranch.getBaseTransaction().getId();
String creationComment =
@@ -425,11 +416,11 @@ public class BranchManager {
String branchName = "Merge " + sourceBranch.getShortName() + " <=> " + destBranch.getShortName();
mergeBranch =
(MergeBranch) createBranch(BranchType.MERGE, sourceBranch.getBaseTransaction(), branchName,
- Lib.generateUuid(), UserManager.getUser(), creationComment, mergeAddressingQueryId, destBranch.getUuid());
+ Lib.generateUuid(), UserManager.getUser(), creationComment, joinQuery.getQueryId(), destBranch.getUuid());
mergeBranch.setSourceBranch(sourceBranch);
mergeBranch.setDestinationBranch(destBranch);
} finally {
- ArtifactLoader.clearQuery(mergeAddressingQueryId);
+ joinQuery.delete();
}
return mergeBranch;
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/PurgeArtifacts.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/PurgeArtifacts.java
index fa86e266566..ac872b294a7 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/PurgeArtifacts.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/PurgeArtifacts.java
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.osee.framework.skynet.core.artifact;
-import java.sql.Timestamp;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
@@ -21,12 +19,12 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.osee.framework.core.enums.DeletionFlag;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.database.core.AbstractDbTxOperation;
-import org.eclipse.osee.framework.database.core.ConnectionHandler;
+import org.eclipse.osee.framework.database.core.ArtifactJoinQuery;
import org.eclipse.osee.framework.database.core.IOseeStatement;
+import org.eclipse.osee.framework.database.core.JoinUtility;
import org.eclipse.osee.framework.database.core.OseeConnection;
-import org.eclipse.osee.framework.database.core.SQL3DataType;
+import org.eclipse.osee.framework.database.core.TransactionJoinQuery;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.time.GlobalTime;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.skynet.core.event.OseeEventManager;
import org.eclipse.osee.framework.skynet.core.event.model.ArtifactEvent;
@@ -41,8 +39,8 @@ import org.eclipse.osee.framework.skynet.core.relation.RelationLink;
*/
public class PurgeArtifacts extends AbstractDbTxOperation {
- private static final String INSERT_SELECT_ITEM =
- "INSERT INTO osee_join_transaction (query_id, insert_time, gamma_id, transaction_id, branch_id) SELECT /*+ ordered */ ?, ?, txs.gamma_id, txs.transaction_id, aj.branch_id FROM osee_join_artifact aj, %s item, osee_txs txs WHERE aj.query_id = ? AND %s AND item.gamma_id = txs.gamma_id AND aj.branch_id = txs.branch_id";
+ private static final String SELECT_ITEM_GAMMAS =
+ "SELECT /*+ ordered */ txs.gamma_id, txs.transaction_id, aj.branch_id FROM osee_join_artifact aj, %s item, osee_txs txs WHERE aj.query_id = ? AND %s AND item.gamma_id = txs.gamma_id AND aj.branch_id = txs.branch_id";
private static final String COUNT_ARTIFACT_VIOLATIONS =
"SELECT art.art_id, txs.branch_id FROM osee_join_artifact aj, osee_artifact art, osee_txs txs WHERE aj.query_id = ? AND aj.art_id = art.art_id AND art.gamma_id = txs.gamma_id AND txs.branch_id = aj.branch_id";
@@ -73,96 +71,41 @@ public class PurgeArtifacts extends AbstractDbTxOperation {
if (artifactsToPurge == null || artifactsToPurge.isEmpty()) {
return;
}
- //first determine if the purge is legal.
- List<Object[]> batchParameters = new ArrayList<Object[]>();
- int queryId = ArtifactLoader.getNewQueryId();
- Timestamp insertTime = GlobalTime.GreenwichMeanTimestamp();
- try {
- for (Artifact art : artifactsToPurge) {
- for (Branch branch : art.getFullBranch().getChildBranches(true)) {
- batchParameters.add(new Object[] {
- queryId,
- insertTime,
- art.getArtId(),
- branch.getUuid(),
- SQL3DataType.INTEGER});
- }
- }
- if (batchParameters.size() > 0) {
- ArtifactLoader.insertIntoArtifactJoin(connection, batchParameters);
- IOseeStatement chStmt = ConnectionHandler.getStatement(connection);
- try {
- chStmt.runPreparedQuery(COUNT_ARTIFACT_VIOLATIONS, queryId);
- boolean failed = false;
- StringBuilder sb = new StringBuilder();
- while (chStmt.next()) {
- int artId = chStmt.getInt("art_id");
- long branchUuid = chStmt.getLong("branch_id");
- if (recurseChildrenBranches) {
- Branch branch = BranchManager.getBranch(branchUuid);
- Artifact artifactFromId = ArtifactQuery.getArtifactFromId(artId, branch);
- artifactsToPurge.add(artifactFromId);
- } else {
- failed = true;
- sb.append("ArtifactId[");
- sb.append(artId);
- sb.append("] BranchId[");
- sb.append(branchUuid);
- sb.append("]\n");
- }
- }
- if (failed) {
- throw new OseeCoreException(
- "Unable to purge because the following artifacts exist on child branches.\n%s", sb.toString());
- }
- } finally {
- ArtifactLoader.clearQuery(connection, queryId);
- chStmt.close();
- }
- }
-
- // now load the artifacts to be purged
- batchParameters.clear();
- queryId = ArtifactLoader.getNewQueryId();
- insertTime = GlobalTime.GreenwichMeanTimestamp();
+ checkPurgeValid(connection);
- Set<Artifact> childreArtifactsToPurge = new HashSet<Artifact>();
- for (Artifact art : artifactsToPurge) {
- childreArtifactsToPurge.addAll(art.getDescendants(DeletionFlag.INCLUDE_DELETED));
- }
-
- artifactsToPurge.addAll(childreArtifactsToPurge);
+ // now load the artifacts to be purged
+ Set<Artifact> childreArtifactsToPurge = new HashSet<Artifact>();
+ for (Artifact art : artifactsToPurge) {
+ childreArtifactsToPurge.addAll(art.getDescendants(DeletionFlag.INCLUDE_DELETED));
+ }
+ artifactsToPurge.addAll(childreArtifactsToPurge);
- // insert into the artifact_join_table
+ ArtifactJoinQuery artJoin2 = JoinUtility.createArtifactJoinQuery(getDatabaseService());
+ try {
for (Artifact art : artifactsToPurge) {
- batchParameters.add(new Object[] {
- queryId,
- insertTime,
- art.getArtId(),
- art.getFullBranch().getUuid(),
- SQL3DataType.INTEGER});
+ artJoin2.add(art.getArtId(), art.getFullBranch().getUuid());
}
- ArtifactLoader.insertIntoArtifactJoin(connection, batchParameters);
-
- //run the insert select queries to populate the osee_join_transaction table (this will take care of the txs table)
- int transactionJoinId = ArtifactLoader.getNewQueryId();
- //run the insert select queries to populate the osee_join_transaction table (this will take care of the txs table)
+ artJoin2.store(connection);
- insertSelectItems(connection, "osee_relation_link",
- "(aj.art_id = item.a_art_id OR aj.art_id = item.b_art_id)", transactionJoinId, insertTime, queryId);
- insertSelectItems(connection, "osee_attribute", "aj.art_id = item.art_id", transactionJoinId, insertTime,
- queryId);
- insertSelectItems(connection, "osee_artifact", "aj.art_id = item.art_id", transactionJoinId, insertTime,
- queryId);
+ int queryId = artJoin2.getQueryId();
- ConnectionHandler.runPreparedUpdate(connection, DELETE_FROM_TXS_USING_JOIN_TRANSACTION, transactionJoinId);
+ TransactionJoinQuery txJoin = JoinUtility.createTransactionJoinQuery(getDatabaseService());
- ConnectionHandler.runPreparedUpdate(connection, DELETE_FROM_TX_DETAILS_USING_JOIN_TRANSACTION,
- transactionJoinId);
+ insertSelectItems(txJoin, connection, "osee_relation_link",
+ "(aj.art_id = item.a_art_id OR aj.art_id = item.b_art_id)", queryId);
+ insertSelectItems(txJoin, connection, "osee_attribute", "aj.art_id = item.art_id", queryId);
+ insertSelectItems(txJoin, connection, "osee_artifact", "aj.art_id = item.art_id", queryId);
- ConnectionHandler.runPreparedUpdate(connection, "DELETE FROM osee_join_transaction where query_id = ?",
- transactionJoinId);
+ try {
+ txJoin.store(connection);
+ getDatabaseService().runPreparedUpdate(connection, DELETE_FROM_TXS_USING_JOIN_TRANSACTION,
+ txJoin.getQueryId());
+ getDatabaseService().runPreparedUpdate(connection, DELETE_FROM_TX_DETAILS_USING_JOIN_TRANSACTION,
+ txJoin.getQueryId());
+ } finally {
+ txJoin.delete(connection);
+ }
for (Artifact artifact : artifactsToPurge) {
ArtifactCache.deCache(artifact);
@@ -176,7 +119,7 @@ public class PurgeArtifacts extends AbstractDbTxOperation {
}
success = true;
} finally {
- ArtifactLoader.clearQuery(connection, queryId);
+ artJoin2.delete(connection);
}
}
@@ -196,10 +139,61 @@ public class PurgeArtifacts extends AbstractDbTxOperation {
}
}
- @SuppressWarnings("unchecked")
- public void insertSelectItems(OseeConnection connection, String tableName, String artifactJoinSql, int transactionJoinId, Timestamp insertTime, int queryId) throws OseeCoreException {
- String sql = String.format(INSERT_SELECT_ITEM, tableName, artifactJoinSql);
- getDatabaseService().runPreparedUpdate(connection, sql, transactionJoinId, insertTime, queryId);
+ public void insertSelectItems(TransactionJoinQuery txJoin, OseeConnection connection, String tableName, String artifactJoinSql, int queryId) throws OseeCoreException {
+ String query = String.format(SELECT_ITEM_GAMMAS, tableName, artifactJoinSql);
+ IOseeStatement chStmt = getDatabaseService().getStatement(connection);
+ try {
+ chStmt.runPreparedQuery(query, queryId);
+ while (chStmt.next()) {
+ txJoin.add(chStmt.getLong("gamma_id"), chStmt.getInt("transaction_id"), chStmt.getLong("branch_id"));
+ }
+ } finally {
+ chStmt.close();
+ }
+ }
+
+ private void checkPurgeValid(OseeConnection connection) {
+ ArtifactJoinQuery artJoin = JoinUtility.createArtifactJoinQuery(getDatabaseService());
+ for (Artifact art : artifactsToPurge) {
+ for (Branch branch : art.getFullBranch().getChildBranches(true)) {
+ artJoin.add(art.getArtId(), branch.getUuid());
+ }
+ }
+ if (!artJoin.isEmpty()) {
+ try {
+ artJoin.store(connection);
+ IOseeStatement chStmt = getDatabaseService().getStatement(connection);
+ try {
+ chStmt.runPreparedQuery(COUNT_ARTIFACT_VIOLATIONS, artJoin.getQueryId());
+ boolean failed = false;
+ StringBuilder sb = new StringBuilder();
+ while (chStmt.next()) {
+ int artId = chStmt.getInt("art_id");
+ long branchUuid = chStmt.getLong("branch_id");
+ if (recurseChildrenBranches) {
+ Branch branch = BranchManager.getBranch(branchUuid);
+ Artifact artifactFromId = ArtifactQuery.getArtifactFromId(artId, branch);
+ artifactsToPurge.add(artifactFromId);
+ } else {
+ failed = true;
+ sb.append("ArtifactId[");
+ sb.append(artId);
+ sb.append("] BranchId[");
+ sb.append(branchUuid);
+ sb.append("]\n");
+ }
+ }
+ if (failed) {
+ throw new OseeCoreException(
+ "Unable to purge because the following artifacts exist on child branches.\n%s", sb.toString());
+ }
+ } finally {
+ chStmt.close();
+ }
+ } finally {
+ artJoin.delete(connection);
+ }
+ }
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/UpdateMergeBranch.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/UpdateMergeBranch.java
index 238ed324406..dce6b8284a1 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/UpdateMergeBranch.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/UpdateMergeBranch.java
@@ -11,27 +11,24 @@
package org.eclipse.osee.framework.skynet.core.artifact;
import static org.eclipse.osee.framework.core.enums.DeletionFlag.INCLUDE_DELETED;
-import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
import org.eclipse.core.runtime.Platform;
import org.eclipse.osee.framework.core.client.ClientSessionManager;
import org.eclipse.osee.framework.core.enums.ModificationType;
import org.eclipse.osee.framework.core.enums.TxChange;
import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.database.core.ArtifactJoinQuery;
import org.eclipse.osee.framework.database.core.ConnectionHandler;
import org.eclipse.osee.framework.database.core.DbTransaction;
import org.eclipse.osee.framework.database.core.IOseeStatement;
+import org.eclipse.osee.framework.database.core.JoinUtility;
import org.eclipse.osee.framework.database.core.OseeConnection;
import org.eclipse.osee.framework.database.core.OseeSql;
-import org.eclipse.osee.framework.database.core.SQL3DataType;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.framework.jdk.core.util.time.GlobalTime;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
/**
@@ -128,9 +125,9 @@ public class UpdateMergeBranch extends DbTransaction {
int baselineTransaction = mergeBranch.getBaseTransaction().getId();
for (Artifact artifact : goodMergeBranchArtifacts) {
numberAttrUpdated +=
- ConnectionHandler.runPreparedUpdate(connection, UPDATE_ARTIFACTS, baselineTransaction, mergeBranch.getUuid(),
- artifact.getArtId(), sourceBranch.getUuid(), TxChange.NOT_CURRENT.getValue(), mergeBranch.getUuid(),
- baselineTransaction);
+ ConnectionHandler.runPreparedUpdate(connection, UPDATE_ARTIFACTS, baselineTransaction,
+ mergeBranch.getUuid(), artifact.getArtId(), sourceBranch.getUuid(), TxChange.NOT_CURRENT.getValue(),
+ mergeBranch.getUuid(), baselineTransaction);
}
if (DEBUG) {
System.out.println(String.format(" Adding %d Attributes to Existing Artifacts took %s",
@@ -163,23 +160,22 @@ public class UpdateMergeBranch extends DbTransaction {
throw new IllegalArgumentException("Artifact IDs can not be null or empty");
}
- List<Object[]> datas = new LinkedList<Object[]>();
- int queryId = ArtifactLoader.getNewQueryId();
- Timestamp insertTime = GlobalTime.GreenwichMeanTimestamp();
-
+ ArtifactJoinQuery joinQuery = JoinUtility.createArtifactJoinQuery();
for (int artId : artIds) {
- datas.add(new Object[] {queryId, insertTime, artId, sourceBranch.getUuid(), SQL3DataType.INTEGER});
+ joinQuery.add(artId, sourceBranch.getUuid());
}
try {
- ArtifactLoader.insertIntoArtifactJoin(datas);
+ joinQuery.store(connection);
Integer startTransactionNumber = mergeBranch.getBaseTransaction().getId();
- insertGammas(connection, INSERT_ATTRIBUTE_GAMMAS, startTransactionNumber, queryId, sourceBranch, mergeBranch);
- insertGammas(connection, INSERT_ARTIFACT_GAMMAS, startTransactionNumber, queryId, sourceBranch, mergeBranch);
+ insertGammas(connection, INSERT_ATTRIBUTE_GAMMAS, startTransactionNumber, joinQuery.getQueryId(),
+ sourceBranch, mergeBranch);
+ insertGammas(connection, INSERT_ARTIFACT_GAMMAS, startTransactionNumber, joinQuery.getQueryId(), sourceBranch,
+ mergeBranch);
} catch (OseeCoreException ex) {
throw new OseeCoreException("Source Branch %s Artifact Ids: %s", sourceBranch.getUuid(), Collections.toString(
",", artIds));
} finally {
- ArtifactLoader.clearQuery(connection, queryId);
+ joinQuery.delete(connection);
}
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeManager.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeManager.java
index 7423c42785e..9fd6358510c 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeManager.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeManager.java
@@ -10,10 +10,8 @@
*******************************************************************************/
package org.eclipse.osee.framework.skynet.core.revision;
-import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.osee.framework.core.client.ClientSessionManager;
import org.eclipse.osee.framework.core.data.IOseeBranch;
@@ -23,16 +21,15 @@ import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.TransactionDelta;
import org.eclipse.osee.framework.core.model.TransactionRecord;
import org.eclipse.osee.framework.core.operation.IOperation;
+import org.eclipse.osee.framework.database.core.ArtifactJoinQuery;
import org.eclipse.osee.framework.database.core.ConnectionHandler;
import org.eclipse.osee.framework.database.core.IOseeStatement;
+import org.eclipse.osee.framework.database.core.JoinUtility;
import org.eclipse.osee.framework.database.core.OseeSql;
-import org.eclipse.osee.framework.database.core.SQL3DataType;
import org.eclipse.osee.framework.jdk.core.type.CompositeKeyHashMap;
import org.eclipse.osee.framework.jdk.core.type.HashCollection;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.time.GlobalTime;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.ArtifactLoader;
import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
import org.eclipse.osee.framework.skynet.core.change.ArtifactDelta;
import org.eclipse.osee.framework.skynet.core.change.Change;
@@ -104,38 +101,29 @@ public final class ChangeManager {
* @return a map of artifact to collection of TransactionIds which affected the given artifact
*/
public static HashCollection<Artifact, TransactionRecord> getModifingTransactions(Collection<Artifact> artifacts) throws OseeCoreException {
- List<Object[]> insertParameters = new ArrayList<Object[]>(artifacts.size() * 5);
-
- int queryId = ArtifactLoader.getNewQueryId();
- Timestamp insertTime = GlobalTime.GreenwichMeanTimestamp();
-
+ ArtifactJoinQuery joinQuery = JoinUtility.createArtifactJoinQuery();
CompositeKeyHashMap<Integer, Branch, Artifact> artifactMap = new CompositeKeyHashMap<Integer, Branch, Artifact>();
for (Artifact artifact : artifacts) {
Branch branch = artifact.getFullBranch();
artifactMap.put(artifact.getArtId(), branch, artifact);
int transactionNumber = TransactionManager.getHeadTransaction(branch).getId();
- insertParameters.add(new Object[] {queryId, insertTime, artifact.getArtId(), branch.getUuid(), transactionNumber});
+ joinQuery.add(artifact.getArtId(), branch.getUuid(), transactionNumber);
// for each combination of artifact and its branch hierarchy
while (branch.hasParentBranch()) {
transactionNumber = branch.getSourceTransaction().getId();
branch = branch.getParentBranch();
- insertParameters.add(new Object[] {
- queryId,
- insertTime,
- artifact.getArtId(),
- branch.getUuid(),
- transactionNumber});
+ joinQuery.add(artifact.getArtId(), branch.getUuid(), transactionNumber);
}
}
HashCollection<Artifact, TransactionRecord> transactionMap = new HashCollection<Artifact, TransactionRecord>();
try {
- ArtifactLoader.insertIntoArtifactJoin(insertParameters);
+ joinQuery.store();
IOseeStatement chStmt = ConnectionHandler.getStatement();
try {
- chStmt.runPreparedQuery(insertParameters.size() * 2,
- ClientSessionManager.getSql(OseeSql.CHANGE_TX_MODIFYING), queryId);
+ chStmt.runPreparedQuery(joinQuery.size() * 2, ClientSessionManager.getSql(OseeSql.CHANGE_TX_MODIFYING),
+ joinQuery.getQueryId());
while (chStmt.next()) {
Branch branch = BranchManager.getBranch(chStmt.getLong("branch_id"));
Artifact artifact = artifactMap.get(chStmt.getInt("art_id"), branch);
@@ -145,9 +133,8 @@ public final class ChangeManager {
chStmt.close();
}
} finally {
- ArtifactLoader.clearQuery(queryId);
+ joinQuery.delete();
}
-
return transactionMap;
}
@@ -158,9 +145,7 @@ public final class ChangeManager {
* @return a map of artifact to collection of branches which affected the given artifact
*/
public static HashCollection<Artifact, Branch> getModifingBranches(Collection<Artifact> artifacts) throws OseeCoreException {
- List<Object[]> insertParameters = new ArrayList<Object[]>(artifacts.size() * 5);
- int queryId = ArtifactLoader.getNewQueryId();
- Timestamp insertTime = GlobalTime.GreenwichMeanTimestamp();
+ ArtifactJoinQuery joinQuery = JoinUtility.createArtifactJoinQuery();
CompositeKeyHashMap<Integer, IOseeBranch, Artifact> artifactMap =
new CompositeKeyHashMap<Integer, IOseeBranch, Artifact>();
@@ -170,23 +155,18 @@ public final class ChangeManager {
// hierarchy
for (Branch workingBranch : BranchManager.getBranches(BranchArchivedState.UNARCHIVED, BranchType.WORKING)) {
if (artifact.getBranch().equals(workingBranch.getParentBranch())) {
- insertParameters.add(new Object[] {
- queryId,
- insertTime,
- artifact.getArtId(),
- workingBranch.getUuid(),
- SQL3DataType.INTEGER});
+ joinQuery.add(artifact.getArtId(), workingBranch.getUuid());
}
}
}
HashCollection<Artifact, Branch> branchMap = new HashCollection<Artifact, Branch>();
try {
- ArtifactLoader.insertIntoArtifactJoin(insertParameters);
+ joinQuery.store();
IOseeStatement chStmt = ConnectionHandler.getStatement();
try {
- chStmt.runPreparedQuery(insertParameters.size() * 2,
- ClientSessionManager.getSql(OseeSql.CHANGE_BRANCH_MODIFYING), queryId);
+ chStmt.runPreparedQuery(joinQuery.size() * 2, ClientSessionManager.getSql(OseeSql.CHANGE_BRANCH_MODIFYING),
+ joinQuery.getQueryId());
while (chStmt.next()) {
if (chStmt.getInt("tx_count") > 0) {
Branch branch = BranchManager.getBranch(chStmt.getLong("branch_id"));
@@ -198,7 +178,7 @@ public final class ChangeManager {
chStmt.close();
}
} finally {
- ArtifactLoader.clearQuery(queryId);
+ joinQuery.delete();
}
return branchMap;
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ConflictManagerInternal.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ConflictManagerInternal.java
index 843345fdd5e..cbbaf656f57 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ConflictManagerInternal.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ConflictManagerInternal.java
@@ -11,7 +11,6 @@
package org.eclipse.osee.framework.skynet.core.revision;
import static org.eclipse.osee.framework.core.enums.DeletionFlag.INCLUDE_DELETED;
-import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -26,14 +25,14 @@ import org.eclipse.osee.framework.core.enums.ModificationType;
import org.eclipse.osee.framework.core.exception.BranchMergeException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.TransactionRecord;
+import org.eclipse.osee.framework.database.core.ArtifactJoinQuery;
import org.eclipse.osee.framework.database.core.ConnectionHandler;
import org.eclipse.osee.framework.database.core.IOseeStatement;
+import org.eclipse.osee.framework.database.core.JoinUtility;
import org.eclipse.osee.framework.database.core.OseeSql;
import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.time.GlobalTime;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.ArtifactLoader;
import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.skynet.core.conflict.ArtifactConflictBuilder;
@@ -304,25 +303,17 @@ public class ConflictManagerInternal {
private static void cleanUpConflictDB(Collection<Conflict> conflicts, long branchUuid, IProgressMonitor monitor) throws OseeCoreException {
monitor.subTask("Cleaning up old conflict data");
- int queryId = ArtifactLoader.getNewQueryId();
- try {
- if (conflicts != null && conflicts.size() != 0 && branchUuid != 0) {
- Timestamp insertTime = GlobalTime.GreenwichMeanTimestamp();
-
- List<Object[]> insertParameters = new LinkedList<Object[]>();
+ if (conflicts != null && conflicts.size() != 0 && branchUuid != 0) {
+ ArtifactJoinQuery joinQuery = JoinUtility.createArtifactJoinQuery();
+ try {
for (Conflict conflict : conflicts) {
- insertParameters.add(new Object[] {
- queryId,
- insertTime,
- conflict.getObjectId(),
- branchUuid,
- conflict.getConflictType().getValue()});
+ joinQuery.add(conflict.getObjectId(), branchUuid, conflict.getConflictType().getValue());
}
- ArtifactLoader.insertIntoArtifactJoin(insertParameters);
- ConnectionHandler.runPreparedUpdate(CONFLICT_CLEANUP, branchUuid, queryId);
+ joinQuery.store();
+ ConnectionHandler.runPreparedUpdate(CONFLICT_CLEANUP, branchUuid, joinQuery.getQueryId());
+ } finally {
+ joinQuery.delete();
}
- } finally {
- ArtifactLoader.clearQuery(queryId);
}
monitor.worked(10);
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/acquirer/AttributeChangeAcquirer.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/acquirer/AttributeChangeAcquirer.java
index 0008bce74ef..23316dba449 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/acquirer/AttributeChangeAcquirer.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/acquirer/AttributeChangeAcquirer.java
@@ -10,12 +10,9 @@
*******************************************************************************/
package org.eclipse.osee.framework.skynet.core.revision.acquirer;
-import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -28,14 +25,13 @@ import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.TransactionDelta;
import org.eclipse.osee.framework.core.model.TransactionRecord;
import org.eclipse.osee.framework.core.model.type.AttributeType;
+import org.eclipse.osee.framework.database.core.ArtifactJoinQuery;
import org.eclipse.osee.framework.database.core.ConnectionHandler;
import org.eclipse.osee.framework.database.core.IOseeStatement;
+import org.eclipse.osee.framework.database.core.JoinUtility;
import org.eclipse.osee.framework.database.core.OseeSql;
-import org.eclipse.osee.framework.database.core.SQL3DataType;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.time.GlobalTime;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.ArtifactLoader;
import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager;
import org.eclipse.osee.framework.skynet.core.attribute.AttributeTypeManager;
import org.eclipse.osee.framework.skynet.core.change.ArtifactChangeBuilder;
@@ -180,42 +176,41 @@ public class AttributeChangeAcquirer extends ChangeAcquirer {
sqlParamter = transactionId.getId();
}
- int queryId = ArtifactLoader.getNewQueryId();
- Timestamp insertTime = GlobalTime.GreenwichMeanTimestamp();
- List<Object[]> datas = new LinkedList<Object[]>();
- IOseeStatement chStmt = ConnectionHandler.getStatement();
-
+ ArtifactJoinQuery joinQuery = JoinUtility.createArtifactJoinQuery();
try {
- // insert into the artifact_join_table
for (int artId : artIds) {
- datas.add(new Object[] {queryId, insertTime, artId, wasValueBranch.getUuid(), SQL3DataType.INTEGER});
+ joinQuery.add(artId, wasValueBranch.getUuid());
}
- ArtifactLoader.insertIntoArtifactJoin(datas);
- chStmt.runPreparedQuery(sql, sqlParamter, queryId);
- int previousAttrId = -1;
-
- while (chStmt.next()) {
- int attrId = chStmt.getInt("attr_id");
-
- if (previousAttrId != attrId) {
- String wasValue = chStmt.getString("was_value");
- if (attributesWasValueCache.containsKey(attrId) && attributesWasValueCache.get(attrId) instanceof AttributeChangeBuilder) {
- AttributeChangeBuilder changeBuilder =
- (AttributeChangeBuilder) attributesWasValueCache.get(attrId);
-
- if (changeBuilder.getArtModType() != ModificationType.NEW) {
- if (changeBuilder.getModType() != ModificationType.DELETED && changeBuilder.getModType() != ModificationType.ARTIFACT_DELETED) {
- changeBuilder.setModType(ModificationType.MODIFIED);
+ joinQuery.store();
+
+ IOseeStatement chStmt = ConnectionHandler.getStatement();
+ try {
+ chStmt.runPreparedQuery(sql, sqlParamter, joinQuery.getQueryId());
+ int previousAttrId = -1;
+ while (chStmt.next()) {
+ int attrId = chStmt.getInt("attr_id");
+
+ if (previousAttrId != attrId) {
+ String wasValue = chStmt.getString("was_value");
+ if (attributesWasValueCache.containsKey(attrId) && attributesWasValueCache.get(attrId) instanceof AttributeChangeBuilder) {
+ AttributeChangeBuilder changeBuilder =
+ (AttributeChangeBuilder) attributesWasValueCache.get(attrId);
+
+ if (changeBuilder.getArtModType() != ModificationType.NEW) {
+ if (changeBuilder.getModType() != ModificationType.DELETED && changeBuilder.getModType() != ModificationType.ARTIFACT_DELETED) {
+ changeBuilder.setModType(ModificationType.MODIFIED);
+ }
+ changeBuilder.setWasValue(wasValue);
}
- changeBuilder.setWasValue(wasValue);
}
+ previousAttrId = attrId;
}
- previousAttrId = attrId;
}
+ } finally {
+ chStmt.close();
}
} finally {
- chStmt.close();
- ArtifactLoader.clearQuery(queryId);
+ joinQuery.delete();
}
if (getMonitor() != null) {
monitor.worked(12);
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/TransactionJoinQueryTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/TransactionJoinQueryTest.java
index d0097d0d46b..542e37564cc 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/TransactionJoinQueryTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/TransactionJoinQueryTest.java
@@ -13,6 +13,7 @@ package org.eclipse.osee.orcs.db.internal.sql.join;
import java.sql.Timestamp;
import java.util.List;
import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.database.core.SQL3DataType;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.junit.Assert;
import org.junit.Test;
@@ -49,11 +50,12 @@ public class TransactionJoinQueryTest {
Assert.assertEquals(1, data.size());
Object[] entry = data.get(0);
- Assert.assertEquals(4, entry.length);
+ Assert.assertEquals(5, entry.length);
Assert.assertEquals(999, entry[0]);
Assert.assertTrue(entry[1] instanceof Timestamp);
Assert.assertEquals(1234L, entry[2]);
Assert.assertEquals(5678, entry[3]);
+ Assert.assertEquals(SQL3DataType.BIGINT, entry[4]);
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/ArtifactJoinQuery.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/ArtifactJoinQuery.java
index 71572431b84..0e7d1f34434 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/ArtifactJoinQuery.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/ArtifactJoinQuery.java
@@ -11,6 +11,7 @@
package org.eclipse.osee.orcs.db.internal.sql.join;
import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
+import org.eclipse.osee.framework.database.core.SQL3DataType;
import org.eclipse.osee.orcs.db.internal.sql.join.DatabaseJoinAccessor.JoinItem;
/**
@@ -33,7 +34,12 @@ public class ArtifactJoinQuery extends AbstractJoinQuery {
@Override
public Object[] toArray() {
- return new Object[] {getQueryId(), getInsertTime(), artId, branchUuid, transactionId};
+ return new Object[] {
+ getQueryId(),
+ getInsertTime(),
+ artId,
+ branchUuid,
+ transactionId != null ? transactionId : SQL3DataType.INTEGER};
}
@Override
@@ -108,4 +114,7 @@ public class ArtifactJoinQuery extends AbstractJoinQuery {
}
}
+ 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.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/DatabaseJoinAccessor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/DatabaseJoinAccessor.java
index 399c0516e23..fde6d3b60ca 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/DatabaseJoinAccessor.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/DatabaseJoinAccessor.java
@@ -29,7 +29,7 @@ public class DatabaseJoinAccessor implements IJoinAccessor {
"INSERT INTO osee_join_artifact (query_id, insert_time, art_id, branch_id, transaction_id) VALUES (?, ?, ?, ?, ?)";
private static final String INSERT_INTO_JOIN_TRANSACTION =
- "INSERT INTO osee_join_transaction (query_id, insert_time, gamma_id, transaction_id) VALUES (?, ?, ?, ?)";
+ "INSERT INTO osee_join_transaction (query_id, insert_time, gamma_id, transaction_id, branch_id) VALUES (?, ?, ?, ?, ?)";
private static final String INSERT_INTO_TAG_GAMMA_QUEUE =
"INSERT INTO osee_tag_gamma_queue (query_id, insert_time, gamma_id) VALUES (?, ?, ?)";
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/ExportImportJoinQuery.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/ExportImportJoinQuery.java
index 21e0329f36a..9b5fd24914d 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/ExportImportJoinQuery.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/ExportImportJoinQuery.java
@@ -18,8 +18,8 @@ import org.eclipse.osee.orcs.db.internal.sql.join.DatabaseJoinAccessor.JoinItem;
public final class ExportImportJoinQuery extends AbstractJoinQuery {
private final class ExportImportEntry implements IJoinRow {
- private final long id1;
- private final long id2;
+ private final Long id1;
+ private final Long id2;
private ExportImportEntry(Long id1, Long id2) {
this.id1 = id1;
@@ -33,25 +33,54 @@ public final class ExportImportJoinQuery extends AbstractJoinQuery {
@Override
public boolean equals(Object obj) {
- if (obj == this) {
+ if (this == obj) {
return true;
}
- if (!(obj instanceof ExportImportEntry)) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
return false;
}
ExportImportEntry other = (ExportImportEntry) obj;
- return this.id1 == other.id1 && this.id2 == other.id2;
+ if (!getOuterType().equals(other.getOuterType())) {
+ return false;
+ }
+ if (id1 == null) {
+ if (other.id1 != null) {
+ return false;
+ }
+ } else if (!id1.equals(other.id1)) {
+ return false;
+ }
+ if (id2 == null) {
+ if (other.id2 != null) {
+ return false;
+ }
+ } else if (!id2.equals(other.id2)) {
+ return false;
+ }
+ return true;
}
@Override
public int hashCode() {
- return Long.valueOf(37 * id1 * id2).hashCode();
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + getOuterType().hashCode();
+ result = prime * result + ((id1 == null) ? 0 : id1.hashCode());
+ result = prime * result + ((id2 == null) ? 0 : id2.hashCode());
+ return result;
}
@Override
public String toString() {
return String.format("id1=%s id2=%s", id1, id2);
}
+
+ private ExportImportJoinQuery getOuterType() {
+ return ExportImportJoinQuery.this;
+ }
}
protected ExportImportJoinQuery(IJoinAccessor joinAccessor, int queryId) {
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/IdJoinQuery.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/IdJoinQuery.java
index 7b69305bc74..f755294b67d 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/IdJoinQuery.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/IdJoinQuery.java
@@ -31,25 +31,46 @@ public class IdJoinQuery extends AbstractJoinQuery {
@Override
public boolean equals(Object obj) {
- if (obj == this) {
+ if (this == obj) {
return true;
}
- if (!(obj instanceof TempIdEntry)) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
return false;
}
TempIdEntry other = (TempIdEntry) obj;
- return other.id.equals(this.id);
+ if (!getOuterType().equals(other.getOuterType())) {
+ return false;
+ }
+ if (id == null) {
+ if (other.id != null) {
+ return false;
+ }
+ } else if (!id.equals(other.id)) {
+ return false;
+ }
+ return true;
}
@Override
public int hashCode() {
- return 37 * id.hashCode();
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + getOuterType().hashCode();
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ return result;
}
@Override
public String toString() {
return "id = " + id;
}
+
+ private IdJoinQuery getOuterType() {
+ return IdJoinQuery.this;
+ }
}
public IdJoinQuery(IJoinAccessor joinAccessor, int queryId) {
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/TagQueueJoinQuery.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/TagQueueJoinQuery.java
index 93a8f74eb61..425fd55a53f 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/TagQueueJoinQuery.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/TagQueueJoinQuery.java
@@ -18,7 +18,7 @@ import org.eclipse.osee.orcs.db.internal.sql.join.DatabaseJoinAccessor.JoinItem;
public final class TagQueueJoinQuery extends AbstractJoinQuery {
private final class GammaEntry implements IJoinRow {
- private final long gammaId;
+ private final Long gammaId;
private GammaEntry(Long gammaId) {
this.gammaId = gammaId;
@@ -31,25 +31,46 @@ public final class TagQueueJoinQuery extends AbstractJoinQuery {
@Override
public boolean equals(Object obj) {
- if (obj == this) {
+ if (this == obj) {
return true;
}
- if (!(obj instanceof GammaEntry)) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
return false;
}
GammaEntry other = (GammaEntry) obj;
- return this.gammaId == other.gammaId;
+ if (!getOuterType().equals(other.getOuterType())) {
+ return false;
+ }
+ if (gammaId == null) {
+ if (other.gammaId != null) {
+ return false;
+ }
+ } else if (!gammaId.equals(other.gammaId)) {
+ return false;
+ }
+ return true;
}
@Override
public int hashCode() {
- return Long.valueOf(37 * gammaId).hashCode();
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + getOuterType().hashCode();
+ result = prime * result + ((gammaId == null) ? 0 : gammaId.hashCode());
+ return result;
}
@Override
public String toString() {
return String.format("gammaId=%s", gammaId);
}
+
+ private TagQueueJoinQuery getOuterType() {
+ return TagQueueJoinQuery.this;
+ }
}
protected TagQueueJoinQuery(IJoinAccessor joinAccessor, int queryId) {
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/TransactionJoinQuery.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/TransactionJoinQuery.java
index aaec7700a20..07849460f4c 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/TransactionJoinQuery.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/TransactionJoinQuery.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.sql.join;
+import org.eclipse.osee.framework.database.core.SQL3DataType;
import org.eclipse.osee.orcs.db.internal.sql.join.DatabaseJoinAccessor.JoinItem;
/**
@@ -18,17 +19,24 @@ import org.eclipse.osee.orcs.db.internal.sql.join.DatabaseJoinAccessor.JoinItem;
public final class TransactionJoinQuery extends AbstractJoinQuery {
private final class TempTransactionEntry implements IJoinRow {
- private final long gammaId;
- private final int transactionId;
+ private final Long gammaId;
+ private final Integer transactionId;
+ private final Long branchUuid;
- private TempTransactionEntry(Long gammaId, Integer transactionId) {
+ 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(), getInsertTime(), gammaId, transactionId};
+ return new Object[] {
+ getQueryId(),
+ getInsertTime(),
+ gammaId,
+ transactionId,
+ branchUuid != null ? branchUuid : SQL3DataType.BIGINT};
}
@Override
@@ -36,8 +44,9 @@ public final class TransactionJoinQuery extends AbstractJoinQuery {
final int prime = 31;
int result = 1;
result = prime * result + getOuterType().hashCode();
- result = prime * result + (int) (gammaId ^ (gammaId >>> 32));
- result = prime * result + transactionId;
+ 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;
}
@@ -56,10 +65,25 @@ public final class TransactionJoinQuery extends AbstractJoinQuery {
if (!getOuterType().equals(other.getOuterType())) {
return false;
}
- if (gammaId != other.gammaId) {
+ if (branchUuid == null) {
+ if (other.branchUuid != null) {
+ return false;
+ }
+ } else if (!branchUuid.equals(other.branchUuid)) {
return false;
}
- if (transactionId != other.transactionId) {
+ 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;
@@ -67,7 +91,7 @@ public final class TransactionJoinQuery extends AbstractJoinQuery {
@Override
public String toString() {
- return String.format("gamma_id=%s, tx_id=%s", gammaId, transactionId);
+ return String.format("gamma_id=%s, tx_id=%s, branch_id=%s", gammaId, transactionId, branchUuid);
}
private TransactionJoinQuery getOuterType() {
@@ -80,6 +104,10 @@ public final class TransactionJoinQuery extends AbstractJoinQuery {
}
public void add(Long gammaId, Integer transactionId) {
- entries.add(new TempTransactionEntry(gammaId, 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