Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ArtifactJoinQuery.java')
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ArtifactJoinQuery.java120
1 files changed, 120 insertions, 0 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

Back to the top