From 492e2f30d13730850cb3966d00ab9f0debe3f409 Mon Sep 17 00:00:00 2001 From: Morgan E. Cook Date: Tue, 24 Jan 2017 17:38:40 -0700 Subject: refactor: Add OSEE_JOIN_ID4 table for artifact loading Change-Id: Ifad6566556415e092b08550ba1352dfccd576615 Signed-off-by: Morgan E. Cook --- .../data/binary_data.zip | Bin 317812 -> 313751 bytes plugins/org.eclipse.osee.ats.mocks/data/hsql.zip | Bin 160660 -> 171493 bytes .../eclipse/osee/framework/core/sql/OseeSql.java | 36 +-- .../skynet/core/artifact/ArtifactLoader.java | 18 +- .../skynet/core/artifact/AttributeLoader.java | 2 +- .../skynet/core/artifact/BranchManager.java | 6 +- .../skynet/core/artifact/PurgeArtifacts.java | 22 +- .../skynet/core/artifact/UpdateMergeBranch.java | 11 +- .../skynet/core/revision/ChangeManager.java | 12 +- .../core/revision/ConflictManagerInternal.java | 8 +- .../revision/acquirer/AttributeChangeAcquirer.java | 7 +- .../skynet/core/utility/ArtifactJoinQuery.java | 117 ---------- .../skynet/core/utility/DatabaseJoinAccessor.java | 10 +- .../skynet/core/utility/Id4JoinQuery.java | 128 ++++++++++ .../framework/skynet/core/utility/JoinUtility.java | 12 +- .../data/binary_data.zip | Bin 317812 -> 313751 bytes .../org.eclipse.osee.orcs.db.mock/data/hsql.zip | Bin 160660 -> 171493 bytes .../osee/orcs/db/intergration/LoaderTest.java | 4 +- .../internal/loader/DataLoaderFactoryImplTest.java | 260 ++++++++++----------- .../internal/sql/join/ArtifactJoinQueryTest.java | 20 +- .../callable/CreateBranchDatabaseTxCallable.java | 4 +- .../orcs/db/internal/loader/LoadSqlWriter.java | 14 +- .../orcs/db/internal/loader/SqlObjectLoader.java | 4 +- .../ArtifactQueryContextLoadExecutor.java | 11 +- .../db/internal/loader/executors/LoadExecutor.java | 7 +- .../loader/executors/UuidsLoadExecutor.java | 11 +- .../loader/handlers/ArtifactSqlHandler.java | 4 +- .../loader/handlers/AttributeSqlHandler.java | 4 +- .../loader/handlers/RelationSqlHandler.java | 4 +- .../loader/processor/ArtifactLoadProcessor.java | 2 +- .../loader/processor/AttributeLoadProcessor.java | 2 +- ...0.25.0_2016_12_20_1436__Osee_ID4Join_Schema.sql | 11 + .../osee/orcs/db/internal/sql/TableEnum.java | 2 +- .../db/internal/sql/join/ArtifactJoinQuery.java | 117 ---------- .../db/internal/sql/join/DatabaseJoinAccessor.java | 8 +- .../orcs/db/internal/sql/join/Id4JoinQuery.java | 128 ++++++++++ .../orcs/db/internal/sql/join/SqlJoinFactory.java | 10 +- .../org/eclipse/osee/orcs/api/OrcsScriptTest.java | 8 +- .../org/eclipse/osee/orcs/api/OrcsTxQueryTest.java | 79 ++++--- .../demo/binary_data.zip | Bin 317812 -> 313751 bytes plugins/org.eclipse.osee.x.server.p2/demo/hsql.zip | Bin 160660 -> 171493 bytes 41 files changed, 572 insertions(+), 531 deletions(-) delete mode 100644 plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/ArtifactJoinQuery.java create mode 100644 plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/Id4JoinQuery.java create mode 100644 plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/resource/migration/V0.25.0_2016_12_20_1436__Osee_ID4Join_Schema.sql delete mode 100644 plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/ArtifactJoinQuery.java create mode 100644 plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/Id4JoinQuery.java diff --git a/plugins/org.eclipse.osee.ats.mocks/data/binary_data.zip b/plugins/org.eclipse.osee.ats.mocks/data/binary_data.zip index 168a4182410..75319e97477 100644 Binary files a/plugins/org.eclipse.osee.ats.mocks/data/binary_data.zip and b/plugins/org.eclipse.osee.ats.mocks/data/binary_data.zip differ diff --git a/plugins/org.eclipse.osee.ats.mocks/data/hsql.zip b/plugins/org.eclipse.osee.ats.mocks/data/hsql.zip index 5c7cb6d818a..1707c87e1ba 100644 Binary files a/plugins/org.eclipse.osee.ats.mocks/data/hsql.zip and b/plugins/org.eclipse.osee.ats.mocks/data/hsql.zip differ diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/sql/OseeSql.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/sql/OseeSql.java index 8d4aaef8215..14026d8700b 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/sql/OseeSql.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/sql/OseeSql.java @@ -34,20 +34,20 @@ public enum OseeSql { CONFLICT_GET_ATTRIBUTES("SELECT%s atr1.art_id, txs1.mod_type, atr1.attr_type_id, atr1.attr_id, atr1.gamma_id AS source_gamma, atr1.value AS source_value, atr2.gamma_id AS dest_gamma, atr2.value as dest_value, txs2.mod_type AS dest_mod_type FROM osee_txs txs1, osee_attribute atr1, osee_attribute atr2, osee_txs txs2 WHERE txs1.branch_id = ? AND txs1.transaction_id <> ? AND txs1.tx_current in (1,2) AND txs1.gamma_id = atr1.gamma_id AND atr1.attr_id = atr2.attr_id AND atr2.gamma_id = txs2.gamma_id AND txs2.branch_id = ? AND txs2.tx_current in (1,2) AND NOT EXISTS (SELECT 1 FROM osee_txs txs WHERE txs.branch_id = ? AND txs.transaction_id = ? AND ((txs1.gamma_id = txs.gamma_id and txs1.mod_type = txs.mod_type) OR (txs2.gamma_id = txs.gamma_id and txs2.mod_type = txs.mod_type))) ORDER BY attr_id", Strings.HINTS__ORDERED__INDEX__ATTRIBUTE_CONFLICT), CONFLICT_GET_HISTORICAL_ATTRIBUTES("SELECT%s atr.attr_id, atr.art_id, source_gamma_id, dest_gamma_id, attr_type_id, mer.merge_branch_id, mer.dest_branch_id, value as source_value, status, mer.source_branch_id FROM osee_merge mer, osee_conflict con, osee_attribute atr Where mer.commit_transaction_id = ? AND mer.merge_branch_id = con.merge_branch_id And con.source_gamma_id = atr.gamma_id AND con.status in (" + ConflictStatus.COMMITTED.getValue() + ", " + ConflictStatus.INFORMATIONAL.getValue() + " ) order by attr_id", Strings.HintsOrdered), - LOAD_HISTORICAL_ARTIFACTS("SELECT%s aj.art_id, txs.branch_id, txs.gamma_id, txs.mod_type, art_type_id, guid, aj.transaction_id as stripe_transaction_id, txs.app_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.transaction_id <= aj.transaction_id AND txs.branch_id = aj.branch_id order by aj.branch_id, art.art_id, txs.transaction_id desc", Strings.HintsOrdered), - LOAD_HISTORICAL_ARCHIVED_ARTIFACTS("SELECT%s aj.art_id, txs.branch_id, txs.gamma_id, txs.mod_type, art_type_id, guid, aj.transaction_id as stripe_transaction_id, txs.app_id FROM osee_join_artifact aj, osee_artifact art, osee_txs_archived txs WHERE aj.query_id = ? AND aj.art_id = art.art_id AND art.gamma_id = txs.gamma_id AND txs.transaction_id <= aj.transaction_id AND txs.branch_id = aj.branch_id order by aj.branch_id, art.art_id, txs.transaction_id desc", Strings.HintsOrdered), + LOAD_HISTORICAL_ARTIFACTS("SELECT%s aj.id2, txs.branch_id, txs.gamma_id, txs.mod_type, art_type_id, guid, aj.id4, aj.id3 AS stripe_transaction_id, txs.app_id FROM osee_join_id4 aj, osee_artifact art, osee_txs txs WHERE aj.query_id = ? AND aj.id2 = art.art_id AND art.gamma_id = txs.gamma_id AND txs.transaction_id <= aj.id3 AND txs.branch_id = aj.id1 order by aj.id1, art.art_id, txs.transaction_id desc", Strings.HintsOrdered), + LOAD_HISTORICAL_ARCHIVED_ARTIFACTS("SELECT%s aj.id2, txs.branch_id, txs.gamma_id, txs.mod_type, art_type_id, guid, aj.id4, aj.id3 AS stripe_transaction_id, txs.app_id FROM osee_join_id4 aj, osee_artifact art, osee_txs_archived txs WHERE aj.query_id = ? AND aj.id2 = art.art_id AND art.gamma_id = txs.gamma_id AND txs.transaction_id <= aj.id3 AND txs.branch_id = aj.id1 order by aj.id1, art.art_id, txs.transaction_id desc", Strings.HintsOrdered), - LOAD_HISTORICAL_ATTRIBUTES("SELECT att.art_id, att.attr_id, att.value, att.gamma_id, att.attr_type_id, att.uri, aj.branch_id, txs.mod_type, txs.transaction_id, aj.transaction_id as stripe_transaction_id, txs.app_id FROM osee_join_artifact aj, osee_attribute att, osee_txs txs WHERE aj.query_id = ? AND aj.art_id = att.art_id AND att.gamma_id = txs.gamma_id AND txs.branch_id = aj.branch_id AND txs.transaction_id <= aj.transaction_id order by txs.branch_id, att.art_id, att.attr_id, txs.transaction_id desc"), - LOAD_HISTORICAL_ARCHIVED_ATTRIBUTES("SELECT att.art_id, att.attr_id, att.value, att.gamma_id, att.attr_type_id, att.uri, aj.branch_id, txs.mod_type, txs.transaction_id, aj.transaction_id as stripe_transaction_id, txs.app_id FROM osee_join_artifact aj, osee_attribute att, osee_txs_archived txs WHERE aj.query_id = ? AND aj.art_id = att.art_id AND att.gamma_id = txs.gamma_id AND txs.branch_id = aj.branch_id AND txs.transaction_id <= aj.transaction_id order by txs.branch_id, att.art_id, att.attr_id, txs.transaction_id desc"), + LOAD_HISTORICAL_ATTRIBUTES("SELECT att.art_id, att.attr_id, att.value, att.gamma_id, att.attr_type_id, att.uri, aj.id1, txs.mod_type, txs.transaction_id, aj.id4, aj.id3 as stripe_transaction_id, txs.app_id FROM osee_join_id4 aj, osee_attribute att, osee_txs txs WHERE aj.query_id = ? AND aj.id2 = att.art_id AND att.gamma_id = txs.gamma_id AND txs.branch_id = aj.id1 AND txs.transaction_id <= aj.id3 order by txs.branch_id, att.art_id, att.attr_id, txs.transaction_id desc"), + LOAD_HISTORICAL_ARCHIVED_ATTRIBUTES("SELECT att.art_id, att.attr_id, att.value, att.gamma_id, att.attr_type_id, att.uri, aj.id1, txs.mod_type, txs.transaction_id, aj.id4, aj.id3 as stripe_transaction_id, txs.app_id FROM osee_join_id4 aj, osee_attribute att, osee_txs_archived txs WHERE aj.query_id = ? AND aj.id2 = att.art_id AND att.gamma_id = txs.gamma_id AND txs.branch_id = aj.id1 AND txs.transaction_id <= aj.id3 order by txs.branch_id, att.art_id, att.attr_id, txs.transaction_id desc"), - LOAD_CURRENT_ATTRIBUTES(Strings.SELECT_CURRENT_ATTRIBUTES_PREFIX + "= 1 order by al1.branch_id, al1.art_id, att1.attr_id, txs.transaction_id desc", Strings.HintsOrdered), - LOAD_CURRENT_ATTRIBUTES_WITH_DELETED(Strings.SELECT_CURRENT_ATTRIBUTES_PREFIX + "IN (1, 3) order by al1.branch_id, al1.art_id, att1.attr_id, txs.transaction_id desc", Strings.HintsOrdered), + LOAD_CURRENT_ATTRIBUTES(Strings.SELECT_CURRENT_ATTRIBUTES_PREFIX + "= 1 order by al1.id2, al1.id1, att1.attr_id, txs.transaction_id desc", Strings.HintsOrdered), + LOAD_CURRENT_ATTRIBUTES_WITH_DELETED(Strings.SELECT_CURRENT_ATTRIBUTES_PREFIX + "IN (1, 3) order by al1.id2, al1.id1, att1.attr_id, txs.transaction_id desc", Strings.HintsOrdered), LOAD_ALL_CURRENT_ATTRIBUTES(Strings.SELECT_CURRENT_ATTRIBUTES_PREFIX + "IN (1, 2, 3) order by al1.branch_id, al1.art_id, att1.attr_id, txs.transaction_id desc", Strings.HintsOrdered), - LOAD_CURRENT_ARCHIVED_ATTRIBUTES(Strings.SELECT_CURRENT_ARCHIVED_ATTRIBUTES_PREFIX + "= 1 order by al1.branch_id, al1.art_id, att1.attr_id, txs.transaction_id desc", Strings.HintsOrdered), - LOAD_CURRENT_ARCHIVED_ATTRIBUTES_WITH_DELETED(Strings.SELECT_CURRENT_ARCHIVED_ATTRIBUTES_PREFIX + "IN (1, 3) order by al1.branch_id, al1.art_id, att1.attr_id, txs.transaction_id desc", Strings.HintsOrdered), - LOAD_ALL_CURRENT_ARCHIVED_ATTRIBUTES(Strings.SELECT_CURRENT_ARCHIVED_ATTRIBUTES_PREFIX + "IN (1, 2, 3) order by al1.branch_id, al1.art_id, att1.attr_id, txs.transaction_id desc", Strings.HintsOrdered), + LOAD_CURRENT_ARCHIVED_ATTRIBUTES(Strings.SELECT_CURRENT_ARCHIVED_ATTRIBUTES_PREFIX + "= 1 order by al1.id2, al1.id1, att1.attr_id, txs.transaction_id desc", Strings.HintsOrdered), + LOAD_CURRENT_ARCHIVED_ATTRIBUTES_WITH_DELETED(Strings.SELECT_CURRENT_ARCHIVED_ATTRIBUTES_PREFIX + "IN (1, 3) order by al1.id2, al1.id1, att1.attr_id, txs.transaction_id desc", Strings.HintsOrdered), + LOAD_ALL_CURRENT_ARCHIVED_ATTRIBUTES(Strings.SELECT_CURRENT_ARCHIVED_ATTRIBUTES_PREFIX + "IN (1, 2, 3) order by al1.id2, al1.id1, att1.attr_id, txs.transaction_id desc", Strings.HintsOrdered), - LOAD_RELATIONS("SELECT%s txs.mod_type, rel_link_id, a_art_id, b_art_id, rel_link_type_id, rel.gamma_id, rationale, txs.branch_id, txs.app_id FROM osee_join_artifact aj, osee_relation_link rel, osee_txs txs WHERE aj.query_id = ? AND (aj.art_id = rel.a_art_id OR aj.art_id = rel.b_art_id) AND rel.gamma_id = txs.gamma_id AND txs.tx_current = " + TxChange.CURRENT.getValue() + " AND aj.branch_id = txs.branch_id", Strings.HintsOrdered), + LOAD_RELATIONS("SELECT%s txs.mod_type, rel_link_id, a_art_id, b_art_id, rel_link_type_id, rel.gamma_id, rationale, txs.branch_id, aj.id4, txs.app_id FROM osee_join_id4 aj, osee_relation_link rel, osee_txs txs WHERE aj.query_id = ? AND (aj.id2 = rel.a_art_id OR aj.id2 = rel.b_art_id) AND rel.gamma_id = txs.gamma_id AND txs.tx_current = " + TxChange.CURRENT.getValue() + " AND aj.id1 = txs.branch_id", Strings.HintsOrdered), LOAD_CURRENT_ARTIFACTS(Strings.SELECT_CURRENT_ARTIFACTS_PREFIX + "= 1", Strings.HintsOrdered), LOAD_CURRENT_ARTIFACTS_WITH_DELETED(Strings.SELECT_CURRENT_ARTIFACTS_PREFIX + "in (1, 2)", Strings.HintsOrdered), LOAD_CURRENT_ARCHIVED_ARTIFACTS(Strings.SELECT_CURRENT_ARCHIVED_ARTIFACTS_PREFIX + "= 1", Strings.HintsOrdered), @@ -56,8 +56,8 @@ public enum OseeSql { LOAD_REVISION_HISTORY_TRANSACTION_ATTR("SELECT %s txs.transaction_id from osee_attribute arv, osee_txs txs where arv.art_id = ? and arv.gamma_id = txs.gamma_id and txs.branch_id = ? and txs.transaction_id <=?", Strings.HintsOrdered), LOAD_REVISION_HISTORY_TRANSACTION_REL("SELECT %s txs.transaction_id from osee_relation_link rel, osee_txs txs where (rel.a_art_id = ? or rel.b_art_id = ?) and rel.gamma_id = txs.gamma_id and txs.branch_id = ? and txs.transaction_id <=?", Strings.HintsOrdered), - CHANGE_BRANCH_ATTRIBUTE_WAS("SELECT%s attxs1.attr_id, attxs1.value as was_value, txs1.mod_type FROM osee_join_artifact ja1, osee_attribute attxs1, osee_txs txs1, WHERE txs1.branch_id = ? AND txs1.tx_type = 1 AND attxs1.gamma_id = txs1.gamma_id AND attxs1.art_id = ja1.art_id AND txs1.branch_id = ja1.branch_id AND ja1.query_id = ?", Strings.HintsOrdered), - CHANGE_TX_ATTRIBUTE_WAS("SELECT%s att1.attr_id, att1.value as was_value, txs1.mod_type FROM osee_join_artifact al1, osee_attribute att1, osee_txs txs1 WHERE al1.art_id = att1.art_id AND att1.gamma_id = txs1.gamma_id AND txs1.transaction_id < ? AND al1.query_id = ? AND txs1.branch_id = al1.branch_id order by txs1.branch_id, att1.art_id, att1.attr_id, txs1.transaction_id desc", Strings.HintsOrdered), + CHANGE_BRANCH_ATTRIBUTE_WAS("SELECT%s attxs1.attr_id, attxs1.value as was_value, txs1.mod_type FROM osee_join_id4 ja1, osee_attribute attxs1, osee_txs txs1, WHERE txs1.branch_id = ? AND txs1.tx_type = 1 AND attxs1.gamma_id = txs1.gamma_id AND attxs1.art_id = ja1.id2 AND txs1.branch_id = ja1.id1 AND ja1.query_id = ?", Strings.HintsOrdered), + CHANGE_TX_ATTRIBUTE_WAS("SELECT%s att1.attr_id, att1.value as was_value, txs1.mod_type FROM osee_join_id4 al1, osee_attribute att1, osee_txs txs1 WHERE al1.id2 = att1.art_id AND att1.gamma_id = txs1.gamma_id AND txs1.transaction_id < ? AND al1.query_id = ? AND txs1.branch_id = al1.id1 order by txs1.branch_id, att1.art_id, att1.attr_id, txs1.transaction_id desc", Strings.HintsOrdered), CHANGE_BRANCH_ATTRIBUTE_IS("SELECT%s art1.art_type_id, attr1.art_id, attr1.attr_id, attr1.gamma_id, attr1.attr_type_id, attr1.value as is_value, txs1.mod_type FROM osee_txs txs1, osee_attribute attr1, osee_artifact art1 WHERE txs1.branch_id = ? AND txs1.transaction_id <> = ? AND txs1.tx_current in (" + TxChange.DELETED.getValue() + ", " + TxChange.CURRENT.getValue() + ", " + TxChange.ARTIFACT_DELETED.getValue() + ") AND art1.art_id = attr1.art_id AND attr1.gamma_id = txs1.gamma_id", Strings.HintsOrdered), CHANGE_TX_ATTRIBUTE_IS("SELECT art.art_type_id, att.art_id, att.attr_id, att.gamma_id, att.attr_type_id, att.value as is_value, txs.mod_type FROM osee_txs txs, osee_attribute att, osee_artifact art WHERE txs.branch_id = ? and txs.transaction_id = ? AND txs.gamma_id = att.gamma_id AND att.art_id = art.art_id"), CHANGE_TX_ATTRIBUTE_IS_FOR_SPECIFIC_ARTIFACT(CHANGE_TX_ATTRIBUTE_IS.sql + " and att.art_id =?"), @@ -67,8 +67,8 @@ public enum OseeSql { CHANGE_BRANCH_ARTIFACT("select%s art1.art_id, art1.art_type_id, art1.gamma_id, txs1.mod_type FROM osee_txs txs1, osee_artifact art1 WHERE txs1.branch_id = ? AND txs1.transaction_id <> ? AND txs1.gamma_id = art1.gamma_id AND txs1.mod_type in (" + ModificationType.DELETED.getValue() + ", " + ModificationType.NEW.getValue() + ", " + ModificationType.INTRODUCED.getValue() + ") ", Strings.HintsOrdered), CHANGE_TX_ARTIFACT("select art.art_id, art.art_type_id, art.gamma_id, txs.mod_type FROM osee_txs txs, osee_artifact art WHERE txs.branch_id = ? and txs.transaction_id = ? AND txs.gamma_id = art.gamma_id AND txs.mod_type in (" + ModificationType.DELETED.getValue() + ", " + ModificationType.NEW.getValue() + ", " + ModificationType.INTRODUCED.getValue() + ") "), CHANGE_TX_ARTIFACT_FOR_SPECIFIC_ARTIFACT(CHANGE_TX_ARTIFACT.sql + " and art.art_id =?"), - CHANGE_TX_MODIFYING("SELECT arj.art_id, arj.branch_id, txs.transaction_id from osee_join_artifact arj, osee_artifact art, osee_txs txs, osee_branch br where arj.query_id = ? AND arj.art_id = art.art_id AND art.gamma_id = txs.gamma_id AND txs.branch_id = arj.branch_id AND txs.transaction_id <= arj.transaction_id AND txs.branch_id = br.branch_id AND txs.transaction_id <> br.baseline_transaction_id", Strings.HintsOrdered), - CHANGE_BRANCH_MODIFYING("SELECT count(txs.transaction_id) as tx_count, arj.branch_id, arj.art_id FROM osee_join_artifact arj, osee_artifact art, osee_txs txs, osee_branch br where arj.query_id = ? AND arj.art_id = art.art_id AND art.gamma_id = txs.gamma_id AND txs.branch_id = arj.branch_id and txs.branch_id = br.branch_id AND txs.transaction_id <> br.baseline_transaction_id group by arj.art_id, arj.branch_id", Strings.HintsOrdered), + CHANGE_TX_MODIFYING("SELECT arj.id2, arj.id1, txs.transaction_id, arj.id4 from osee_join_id4 arj, osee_artifact art, osee_txs txs, osee_branch br where arj.query_id = ? AND arj.id2 = art.art_id AND art.gamma_id = txs.gamma_id AND txs.branch_id = arj.id1 AND txs.transaction_id <= arj.id3 AND txs.branch_id = br.branch_id AND txs.transaction_id <> br.baseline_transaction_id", Strings.HintsOrdered), + CHANGE_BRANCH_MODIFYING("SELECT count(txs.transaction_id) as tx_count, arj.id1, arj.id2, arj.id4 FROM osee_join_id4 arj, osee_artifact art, osee_txs txs, osee_branch br where arj.query_id = ? AND arj.id2 = art.art_id AND art.gamma_id = txs.gamma_id AND txs.branch_id = arj.id1 and txs.branch_id = br.branch_id AND txs.transaction_id <> br.baseline_transaction_id group by arj.id2, arj.id1", Strings.HintsOrdered), IS_ARTIFACT_ON_BRANCH("SELECT%s count(1) from osee_artifact av1, osee_txs txs1 where av1.art_id = ? and av1.gamma_id = txs1.gamma_id and txs1.branch_id = ?", Strings.HintsOrdered); @@ -118,15 +118,15 @@ public enum OseeSql { " /*+ ordered index(atr1) index(atr2) index(txs2) */"; private static final String SELECT_CURRENT_ATTRIBUTES_PREFIX = - "SELECT%s att1.art_id, att1.attr_id, att1.value, att1.gamma_id, att1.attr_type_id, att1.uri, al1.branch_id, txs.mod_type, txs.transaction_id, txs.app_id FROM osee_join_artifact al1, osee_attribute att1, osee_txs txs WHERE al1.query_id = ? AND al1.art_id = att1.art_id AND att1.gamma_id = txs.gamma_id AND txs.branch_id = al1.branch_id AND txs.tx_current "; + "SELECT%s att1.art_id, att1.attr_id, att1.value, att1.gamma_id, att1.attr_type_id, att1.uri, al1.id1, al1.id4, txs.mod_type, txs.transaction_id, txs.app_id FROM osee_join_id4 al1, osee_attribute att1, osee_txs txs WHERE al1.query_id = ? AND al1.id2 = att1.art_id AND att1.gamma_id = txs.gamma_id AND txs.branch_id = al1.id1 AND txs.tx_current "; private static final String SELECT_CURRENT_ARTIFACTS_PREFIX = - "SELECT%s aj.art_id, txs.gamma_id, mod_type, art_type_id, guid, txs.branch_id, txs.app_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 AND txs.tx_current "; + "SELECT%s aj.id2, txs.gamma_id, mod_type, art_type_id, guid, txs.branch_id, txs.app_id, aj.id4 FROM osee_join_id4 aj, osee_artifact art, osee_txs txs WHERE aj.query_id = ? AND aj.id2 = art.art_id AND art.gamma_id = txs.gamma_id AND txs.branch_id = aj.id1 AND txs.tx_current "; private static final String SELECT_CURRENT_ARCHIVED_ATTRIBUTES_PREFIX = - "SELECT%s att1.art_id, att1.attr_id, att1.value, att1.gamma_id, att1.attr_type_id, att1.uri, al1.branch_id, txs.mod_type, txs.transaction_id, txs.app_id FROM osee_join_artifact al1, osee_attribute att1, osee_txs_archived txs WHERE al1.query_id = ? AND al1.art_id = att1.art_id AND att1.gamma_id = txs.gamma_id AND txs.branch_id = al1.branch_id AND txs.tx_current "; + "SELECT%s att1.art_id, att1.attr_id, att1.value, att1.gamma_id, att1.attr_type_id, att1.uri, al1.id1, txs.mod_type, txs.transaction_id, txs.app_id, aj.id4 FROM osee_join_id4 al1, osee_attribute att1, osee_txs_archived txs WHERE al1.query_id = ? AND al1.id2 = att1.art_id AND att1.gamma_id = txs.gamma_id AND txs.branch_id = al1.id1 AND txs.tx_current "; private static final String SELECT_CURRENT_ARCHIVED_ARTIFACTS_PREFIX = - "SELECT%s aj.art_id, txs.gamma_id, mod_type, art_type_id, guid, txs.branch_id, txs.app_id FROM osee_join_artifact aj, osee_artifact art, osee_txs_archived 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 AND txs.tx_current "; + "SELECT%s aj.id2, txs.gamma_id, mod_type, art_type_id, guid, txs.branch_id, txs.app_id, aj.id4 FROM osee_join_id4 aj, osee_artifact art, osee_txs_archived txs WHERE aj.query_id = ? AND aj.id2 = art.art_id AND art.gamma_id = txs.gamma_id AND txs.branch_id = aj.id1 AND txs.tx_current "; } } \ 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 fd3ce8357cc..207ae0ab01f 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 @@ -41,8 +41,8 @@ import org.eclipse.osee.framework.jdk.core.util.Lib; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.internal.Activator; import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil; -import org.eclipse.osee.framework.skynet.core.utility.ArtifactJoinQuery; import org.eclipse.osee.framework.skynet.core.utility.ConnectionHandler; +import org.eclipse.osee.framework.skynet.core.utility.Id4JoinQuery; import org.eclipse.osee.framework.skynet.core.utility.JoinUtility; import org.eclipse.osee.jdbc.JdbcStatement; @@ -226,7 +226,7 @@ public final class ArtifactLoader { int previousArtId = -1; long previousBranchId = -1; while (chStmt.next()) { - int artId = chStmt.getInt("art_id"); + int artId = chStmt.getInt("id2"); 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) { @@ -261,15 +261,16 @@ public final class ArtifactLoader { private static void loadArtifacts(List> toLoad, LoadLevel loadLevel, TransactionId transactionId, LoadType reload, DeletionFlag allowDeleted, Set artifacts, boolean isArchived) throws OseeCoreException { if (toLoad != null && !toLoad.isEmpty()) { - ArtifactJoinQuery joinQuery = JoinUtility.createArtifactJoinQuery(); + Id4JoinQuery joinQuery = JoinUtility.createId4JoinQuery(); for (Pair pair : toLoad) { - joinQuery.add(pair.getFirst().getId().intValue(), pair.getSecond().getId(), transactionId); + joinQuery.add(BranchId.valueOf(pair.getSecond().getId()), ArtifactId.valueOf(pair.getFirst().getId()), + TransactionId.valueOf(transactionId.getId()), ArtifactId.SENTINEL); } loadArtifacts(artifacts, joinQuery, loadLevel, null, reload, transactionId, allowDeleted, isArchived); } } - private static void loadArtifacts(Collection loadedItems, ArtifactJoinQuery joinQuery, LoadLevel loadLevel, ISearchConfirmer confirmer, LoadType reload, TransactionId transactionId, DeletionFlag allowDeleted, boolean isArchived) throws OseeCoreException { + private static void loadArtifacts(Collection loadedItems, Id4JoinQuery joinQuery, LoadLevel loadLevel, ISearchConfirmer confirmer, LoadType reload, TransactionId transactionId, DeletionFlag allowDeleted, boolean isArchived) throws OseeCoreException { if (!joinQuery.isEmpty()) { Collection data; if (loadedItems.isEmpty()) { @@ -326,7 +327,7 @@ public final class ArtifactLoader { * This method is called only after the cache has been checked */ private static Artifact retrieveShallowArtifact(JdbcStatement chStmt, LoadType reload, boolean historical, boolean isArchived) throws OseeCoreException { - ArtifactId artifactId = ArtifactId.valueOf(chStmt.getLong("art_id")); + ArtifactId artifactId = ArtifactId.valueOf(chStmt.getLong("id2")); BranchId branch = BranchId.valueOf(chStmt.getLong("branch_id")); TransactionToken transactionId = TransactionToken.SENTINEL; ApplicabilityId appId = ApplicabilityId.valueOf(chStmt.getLong("app_id")); @@ -351,9 +352,10 @@ public final class ArtifactLoader { } static void loadArtifactData(Artifact artifact, LoadLevel loadLevel, boolean isArchived) throws OseeCoreException { - ArtifactJoinQuery joinQuery = JoinUtility.createArtifactJoinQuery(); + Id4JoinQuery joinQuery = JoinUtility.createId4JoinQuery(); + try { - joinQuery.add(artifact.getArtId(), artifact.getBranchId()); + joinQuery.add(BranchId.valueOf(artifact.getBranchId()), ArtifactId.valueOf(artifact.getId())); joinQuery.store(); List artifacts = new ArrayList<>(1); diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/AttributeLoader.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/AttributeLoader.java index e9bc9d1913c..19eb25dbc5c 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/AttributeLoader.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/AttributeLoader.java @@ -95,7 +95,7 @@ public class AttributeLoader { public AttrData(JdbcStatement chStmt, boolean historical) throws OseeCoreException { artifactId = chStmt.getInt("art_id"); - branchUuid = chStmt.getLong("branch_id"); + branchUuid = chStmt.getLong("id1"); attrId = chStmt.getInt("attr_id"); gammaId = chStmt.getInt("gamma_id"); modType = chStmt.getInt("mod_type"); 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 7a8e86b8c3b..d79b27edc6e 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 @@ -68,8 +68,8 @@ import org.eclipse.osee.framework.skynet.core.internal.Activator; import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil; import org.eclipse.osee.framework.skynet.core.internal.accessors.DatabaseBranchAccessor; import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager; -import org.eclipse.osee.framework.skynet.core.utility.ArtifactJoinQuery; import org.eclipse.osee.framework.skynet.core.utility.ConnectionHandler; +import org.eclipse.osee.framework.skynet.core.utility.Id4JoinQuery; import org.eclipse.osee.framework.skynet.core.utility.JoinUtility; import org.eclipse.osee.framework.skynet.core.utility.OseeInfo; import org.eclipse.osee.orcs.rest.client.OseeClient; @@ -406,9 +406,9 @@ public final class BranchManager { } private static IOseeBranch createMergeBranch(final IOseeBranch sourceBranch, final IOseeBranch destBranch, final ArrayList expectedArtIds) throws OseeCoreException { - ArtifactJoinQuery joinQuery = JoinUtility.createArtifactJoinQuery(); + Id4JoinQuery joinQuery = JoinUtility.createId4JoinQuery(); for (int artId : expectedArtIds) { - joinQuery.add(artId, sourceBranch.getUuid()); + joinQuery.add(sourceBranch, ArtifactId.valueOf(artId)); } BranchId branch; try { 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 71e2c99f4ed..f2384e28b6e 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 @@ -29,8 +29,8 @@ import org.eclipse.osee.framework.skynet.core.internal.Activator; import org.eclipse.osee.framework.skynet.core.relation.RelationLink; import org.eclipse.osee.framework.skynet.core.relation.RelationManager; import org.eclipse.osee.framework.skynet.core.utility.AbstractDbTxOperation; -import org.eclipse.osee.framework.skynet.core.utility.ArtifactJoinQuery; import org.eclipse.osee.framework.skynet.core.utility.ConnectionHandler; +import org.eclipse.osee.framework.skynet.core.utility.Id4JoinQuery; import org.eclipse.osee.framework.skynet.core.utility.JoinUtility; import org.eclipse.osee.framework.skynet.core.utility.TransactionJoinQuery; import org.eclipse.osee.jdbc.JdbcConnection; @@ -42,10 +42,10 @@ import org.eclipse.osee.jdbc.JdbcStatement; public class PurgeArtifacts extends AbstractDbTxOperation { 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"; + "SELECT /*+ ordered */ txs.gamma_id, txs.transaction_id, aj.id1 FROM osee_join_id4 aj, %s item, osee_txs txs WHERE aj.query_id = ? AND %s AND item.gamma_id = txs.gamma_id AND aj.id1 = 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"; + "SELECT art.art_id, txs.branch_id FROM osee_join_id4 aj, osee_artifact art, osee_txs txs WHERE aj.query_id = ? AND aj.id2 = art.art_id AND art.gamma_id = txs.gamma_id AND txs.branch_id = aj.id1"; private static final String DELETE_FROM_TXS_USING_JOIN_TRANSACTION = "DELETE FROM osee_txs txs WHERE EXISTS (select 1 from osee_join_transaction jt WHERE jt.query_id = ? AND jt.branch_id = txs.branch_id AND jt.gamma_id = txs.gamma_id AND jt.transaction_id = txs.transaction_id)"; @@ -83,10 +83,10 @@ public class PurgeArtifacts extends AbstractDbTxOperation { } artifactsToPurge.addAll(childreArtifactsToPurge); - ArtifactJoinQuery artJoin2 = JoinUtility.createArtifactJoinQuery(getJdbcClient()); + Id4JoinQuery artJoin2 = JoinUtility.createId4JoinQuery(getJdbcClient()); try { for (Artifact art : artifactsToPurge) { - artJoin2.add(art.getArtId(), art.getBranchId()); + artJoin2.add(art.getBranch(), art); } artJoin2.store(connection); @@ -95,9 +95,9 @@ public class PurgeArtifacts extends AbstractDbTxOperation { TransactionJoinQuery txJoin = JoinUtility.createTransactionJoinQuery(getJdbcClient()); 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); + "(aj.id2 = item.a_art_id OR aj.id1 = item.b_art_id)", queryId); + insertSelectItems(txJoin, connection, "osee_attribute", "aj.id2 = item.art_id", queryId); + insertSelectItems(txJoin, connection, "osee_artifact", "aj.id2 = item.art_id", queryId); try { txJoin.store(connection); @@ -147,7 +147,7 @@ public class PurgeArtifacts extends AbstractDbTxOperation { try { chStmt.runPreparedQuery(query, queryId); while (chStmt.next()) { - txJoin.add(chStmt.getLong("gamma_id"), chStmt.getLong("transaction_id"), chStmt.getLong("branch_id")); + txJoin.add(chStmt.getLong("gamma_id"), chStmt.getLong("transaction_id"), chStmt.getLong("id1")); } } finally { chStmt.close(); @@ -155,10 +155,10 @@ public class PurgeArtifacts extends AbstractDbTxOperation { } private void checkPurgeValid(JdbcConnection connection) { - ArtifactJoinQuery artJoin = JoinUtility.createArtifactJoinQuery(getJdbcClient()); + Id4JoinQuery artJoin = JoinUtility.createId4JoinQuery(getJdbcClient()); for (Artifact art : artifactsToPurge) { for (IOseeBranch branch : BranchManager.getChildBranches(art.getBranch(), true)) { - artJoin.add(art.getArtId(), branch.getUuid()); + artJoin.add(branch, art); } } if (!artJoin.isEmpty()) { 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 d4ad1c72ab1..903b6576777 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 @@ -16,6 +16,7 @@ import java.util.Collection; import java.util.HashSet; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Platform; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.TransactionId; import org.eclipse.osee.framework.core.enums.ModificationType; @@ -28,7 +29,7 @@ import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery; import org.eclipse.osee.framework.skynet.core.internal.Activator; import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil; import org.eclipse.osee.framework.skynet.core.utility.AbstractDbTxOperation; -import org.eclipse.osee.framework.skynet.core.utility.ArtifactJoinQuery; +import org.eclipse.osee.framework.skynet.core.utility.Id4JoinQuery; import org.eclipse.osee.framework.skynet.core.utility.JoinUtility; import org.eclipse.osee.jdbc.JdbcClient; import org.eclipse.osee.jdbc.JdbcConnection; @@ -152,18 +153,18 @@ public class UpdateMergeBranch extends AbstractDbTxOperation { } private final static String INSERT_ATTRIBUTE_GAMMAS = - "INSERT INTO OSEE_TXS (transaction_id, gamma_id, mod_type, tx_current, branch_id, app_id) SELECT ?, atr1.gamma_id, txs1.mod_type, ?, ?, txs1.app_id FROM osee_attribute atr1, osee_txs txs1, osee_join_artifact ald1 WHERE txs1.branch_id = ? AND txs1.tx_current in (1,2) AND txs1.gamma_id = atr1.gamma_id AND atr1.art_id = ald1.art_id and ald1.query_id = ?"; + "INSERT INTO OSEE_TXS (transaction_id, gamma_id, mod_type, tx_current, branch_id, app_id) SELECT ?, atr1.gamma_id, txs1.mod_type, ?, ?, txs1.app_id FROM osee_attribute atr1, osee_txs txs1, osee_join_id4 ald1 WHERE txs1.branch_id = ? AND txs1.tx_current in (1,2) AND txs1.gamma_id = atr1.gamma_id AND atr1.art_id = ald1.id2 and ald1.query_id = ?"; private final static String INSERT_ARTIFACT_GAMMAS = - "INSERT INTO OSEE_TXS (transaction_id, gamma_id, mod_type, tx_current, branch_id, app_id) SELECT ?, arv1.gamma_id, txs1.mod_type, ?, ?, txs1.app_id FROM osee_artifact arv1, osee_txs txs1, osee_join_artifact ald1 WHERE txs1.branch_id = ? AND txs1.tx_current in (1,2) AND txs1.gamma_id = arv1.gamma_id AND arv1.art_id = ald1.art_id and ald1.query_id = ?"; + "INSERT INTO OSEE_TXS (transaction_id, gamma_id, mod_type, tx_current, branch_id, app_id) SELECT ?, arv1.gamma_id, txs1.mod_type, ?, ?, txs1.app_id FROM osee_artifact arv1, osee_txs txs1, osee_join_id4 ald1 WHERE txs1.branch_id = ? AND txs1.tx_current in (1,2) AND txs1.gamma_id = arv1.gamma_id AND arv1.art_id = ald1.id2 and ald1.query_id = ?"; private void addArtifactsToBranch(JdbcConnection connection, BranchId sourceBranch, BranchId destBranch, BranchId mergeBranch, Collection artIds) throws OseeCoreException { if (artIds == null || artIds.isEmpty()) { throw new IllegalArgumentException("Artifact IDs can not be null or empty"); } - ArtifactJoinQuery joinQuery = JoinUtility.createArtifactJoinQuery(getJdbcClient()); + Id4JoinQuery joinQuery = JoinUtility.createId4JoinQuery(getJdbcClient()); for (int artId : artIds) { - joinQuery.add(artId, sourceBranch.getUuid()); + joinQuery.add(BranchId.valueOf(sourceBranch.getUuid()), ArtifactId.valueOf(artId)); } try { joinQuery.store(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 dd108ba3ea1..2fe2686216a 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 @@ -31,8 +31,8 @@ import org.eclipse.osee.framework.skynet.core.change.ArtifactDelta; import org.eclipse.osee.framework.skynet.core.change.Change; import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil; import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager; -import org.eclipse.osee.framework.skynet.core.utility.ArtifactJoinQuery; import org.eclipse.osee.framework.skynet.core.utility.ConnectionHandler; +import org.eclipse.osee.framework.skynet.core.utility.Id4JoinQuery; import org.eclipse.osee.framework.skynet.core.utility.JoinUtility; import org.eclipse.osee.jdbc.JdbcStatement; @@ -108,19 +108,19 @@ public final class ChangeManager { * @return a map of artifact to collection of TransactionIds which affected the given artifact */ public static HashCollection getModifingTransactions(Collection artifacts) throws OseeCoreException { - ArtifactJoinQuery joinQuery = JoinUtility.createArtifactJoinQuery(); + Id4JoinQuery joinQuery = JoinUtility.createId4JoinQuery(); CompositeKeyHashMap artifactMap = new CompositeKeyHashMap<>(); for (Artifact artifact : artifacts) { BranchId branch = artifact.getBranch(); artifactMap.put(artifact.getArtId(), branch, artifact); TransactionId transaction = TransactionManager.getHeadTransaction(branch); - joinQuery.add(artifact.getArtId(), branch.getUuid(), transaction); + joinQuery.add(branch, artifact, transaction); // for each combination of artifact and its branch hierarchy while (!branch.equals(CoreBranches.SYSTEM_ROOT)) { transaction = BranchManager.getSourceTransaction(branch); branch = BranchManager.getParentBranch(branch); - joinQuery.add(artifact.getArtId(), branch.getUuid(), transaction); + joinQuery.add(branch, artifact, transaction); } } @@ -152,7 +152,7 @@ public final class ChangeManager { * @return a map of artifact to collection of branches which affected the given artifact */ public static HashCollection getModifingBranches(Collection artifacts) throws OseeCoreException { - ArtifactJoinQuery joinQuery = JoinUtility.createArtifactJoinQuery(); + Id4JoinQuery joinQuery = JoinUtility.createId4JoinQuery(); CompositeKeyHashMap artifactMap = new CompositeKeyHashMap(); @@ -161,7 +161,7 @@ public final class ChangeManager { // for each combination of artifact and all working branches in its hierarchy for (BranchId workingBranch : BranchManager.getBranches(BranchArchivedState.UNARCHIVED, BranchType.WORKING)) { if (artifact.isOnBranch(BranchManager.getParentBranch(workingBranch))) { - joinQuery.add(artifact.getArtId(), workingBranch.getUuid()); + joinQuery.add(workingBranch, artifact); } } } 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 7bcfeac03f3..6273f7670ec 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 @@ -42,8 +42,8 @@ import org.eclipse.osee.framework.skynet.core.conflict.Conflict; import org.eclipse.osee.framework.skynet.core.conflict.ConflictBuilder; import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil; import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager; -import org.eclipse.osee.framework.skynet.core.utility.ArtifactJoinQuery; import org.eclipse.osee.framework.skynet.core.utility.ConnectionHandler; +import org.eclipse.osee.framework.skynet.core.utility.Id4JoinQuery; import org.eclipse.osee.framework.skynet.core.utility.IdJoinQuery; import org.eclipse.osee.framework.skynet.core.utility.JoinUtility; import org.eclipse.osee.jdbc.JdbcStatement; @@ -82,7 +82,7 @@ public class ConflictManagerInternal { "attr_d.attr_id <> sj_c.sj_attr_id"; private static final String CONFLICT_CLEANUP = - "DELETE FROM osee_conflict t1 WHERE merge_branch_id = ? and NOT EXISTS (SELECT 'X' FROM osee_join_artifact WHERE query_id = ? and t1.conflict_id = art_id and (t1.conflict_type = transaction_id or transaction_id is NULL))"; + "DELETE FROM osee_conflict t1 WHERE merge_branch_id = ? AND NOT EXISTS (SELECT 'X' FROM osee_join_id4 WHERE query_id = ? AND t1.conflict_id = id2 AND (t1.conflict_type = id3 or id3 is NULL))"; private static final String GET_DESTINATION_BRANCHES = "SELECT dest_branch_id FROM osee_merge WHERE source_branch_id = ?"; @@ -367,10 +367,10 @@ public class ConflictManagerInternal { private static void cleanUpConflictDB(Collection conflicts, long branchUuid, IProgressMonitor monitor) throws OseeCoreException { monitor.subTask("Cleaning up old conflict data"); if (conflicts != null && conflicts.size() != 0 && branchUuid != 0) { - ArtifactJoinQuery joinQuery = JoinUtility.createArtifactJoinQuery(); + Id4JoinQuery joinQuery = JoinUtility.createId4JoinQuery(); try { for (Conflict conflict : conflicts) { - joinQuery.add(conflict.getObjectId(), branchUuid, + joinQuery.add(BranchId.valueOf(branchUuid), ArtifactId.valueOf(conflict.getObjectId()), TransactionId.valueOf(conflict.getConflictType().getValue())); } joinQuery.store(); 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 13c671565fd..dcb6ed4202d 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 @@ -16,6 +16,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.IArtifactType; import org.eclipse.osee.framework.core.data.TransactionToken; @@ -33,8 +34,8 @@ import org.eclipse.osee.framework.skynet.core.change.AttributeChangeBuilder; import org.eclipse.osee.framework.skynet.core.change.ChangeBuilder; import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil; import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager; -import org.eclipse.osee.framework.skynet.core.utility.ArtifactJoinQuery; import org.eclipse.osee.framework.skynet.core.utility.ConnectionHandler; +import org.eclipse.osee.framework.skynet.core.utility.Id4JoinQuery; import org.eclipse.osee.framework.skynet.core.utility.JoinUtility; import org.eclipse.osee.jdbc.JdbcStatement; @@ -173,10 +174,10 @@ public class AttributeChangeAcquirer extends ChangeAcquirer { sqlParamter = transactionId.getId(); } - ArtifactJoinQuery joinQuery = JoinUtility.createArtifactJoinQuery(); + Id4JoinQuery joinQuery = JoinUtility.createId4JoinQuery(); try { for (int artId : artIds) { - joinQuery.add(artId, wasValueBranch.getUuid()); + joinQuery.add(wasValueBranch, ArtifactId.valueOf(artId)); } joinQuery.store(); diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/ArtifactJoinQuery.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/ArtifactJoinQuery.java deleted file mode 100644 index a4bb1660d49..00000000000 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/ArtifactJoinQuery.java +++ /dev/null @@ -1,117 +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.skynet.core.utility; - -import org.eclipse.osee.framework.core.data.TransactionId; -import org.eclipse.osee.framework.core.exception.OseeDataStoreException; -import org.eclipse.osee.framework.skynet.core.utility.DatabaseJoinAccessor.JoinItem; -import org.eclipse.osee.jdbc.SQL3DataType; - -/** - * @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 TransactionId transactionId; - - private Entry(Integer artId, Long branchUuid, TransactionId transactionId) { - this.artId = artId; - this.branchUuid = branchUuid; - this.transactionId = transactionId; - } - - @Override - public Object[] toArray() { - return new Object[] { - getQueryId(), - artId, - branchUuid, - transactionId.isValid() ? transactionId : SQL3DataType.BIGINT}; - } - - @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.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.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, TransactionId 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, TransactionId.SENTINEL); - } - -} \ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/DatabaseJoinAccessor.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/DatabaseJoinAccessor.java index 29894bc49ce..a2b0e833075 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/DatabaseJoinAccessor.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/DatabaseJoinAccessor.java @@ -25,18 +25,18 @@ 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 INSERT_INTO_JOIN_ID4 = + "INSERT INTO osee_join_id4 (query_id, id1, id2, id3, id4) 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 DELETE_FROM_JOIN_ID4 = "DELETE FROM osee_join_id4 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 (?,?,?,?)"; @@ -45,9 +45,9 @@ public class DatabaseJoinAccessor implements IJoinAccessor { 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); + CHAR_ID("osee_join_char_id", INSERT_INTO_JOIN_CHAR_ID, DELETE_FROM_JOIN_CHAR_ID), + ID4("osee_join_id4", INSERT_INTO_JOIN_ID4, DELETE_FROM_JOIN_ID4); private final String tableName; private final String deleteSql; diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/Id4JoinQuery.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/Id4JoinQuery.java new file mode 100644 index 00000000000..3d6cd552a66 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/Id4JoinQuery.java @@ -0,0 +1,128 @@ +/******************************************************************************* + * Copyright (c) 2017 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.skynet.core.utility; + +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.TransactionId; +import org.eclipse.osee.framework.core.exception.OseeDataStoreException; +import org.eclipse.osee.framework.jdk.core.type.Id; +import org.eclipse.osee.framework.skynet.core.utility.DatabaseJoinAccessor.JoinItem; + +/** + * @author Morgan E. Cook + */ +public class Id4JoinQuery extends AbstractJoinQuery { + + private final int maxJoinSize; + + private final class Entry implements IJoinRow { + private final Id id_1; + private final Id id_2; + private final Id id_3; + private final Id id_4; + + private Entry(Id id_1, Id id_2, Id id_3, Id id_4) { + this.id_1 = id_1; + this.id_2 = id_2; + this.id_3 = id_3; + this.id_4 = id_4; + } + + @Override + public Object[] toArray() { + return new Object[] {getQueryId(), id_1, id_2, id_3, id_4}; + } + + @Override + public String toString() { + return String.format("id_1=%s, id_2=%s, id_3=%s, id_4=%s", id_1, id_2, id_3, id_4); + } + + @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 (id_1 == null) { + if (other.id_1 != null) { + return false; + } + } else if (!id_1.equals(other.id_1)) { + return false; + } + if (id_2 == null) { + if (other.id_2 != null) { + return false; + } + } else if (!id_2.equals(other.id_2)) { + return false; + } + if (id_3 == null) { + if (other.id_3 != null) { + return false; + } + } else if (!id_3.equals(other.id_3)) { + return false; + } + if (!id_4.equals(other.id_4)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + getOuterType().hashCode(); + result = prime * result + (id_1 == null ? 0 : id_1.hashCode()); + result = prime * result + (id_2 == null ? 0 : id_2.hashCode()); + result = prime * result + (id_3 == null ? 0 : id_3.hashCode()); + result = prime * result + (id_4 == null ? 0 : id_4.hashCode()); + return result; + } + + private Id4JoinQuery getOuterType() { + return Id4JoinQuery.this; + } + } + + protected Id4JoinQuery(IJoinAccessor joinAccessor, Long expiresIn, int queryId, int maxJoinSize) { + super(joinAccessor, JoinItem.ID4, expiresIn, queryId); + this.maxJoinSize = maxJoinSize; + } + + public void add(Id id_1, Id id_2, Id id_3, Id id_4) { + entries.add(new Entry(id_1, id_2, id_3, id_4)); + if (entries.size() > maxJoinSize) { + throw new OseeDataStoreException("Exceeded max artifact join size of [%d]", maxJoinSize); + } + } + + public void add(Id id_1, Id id_2, Id id_3) { + add(id_1, id_2, id_3, ArtifactId.SENTINEL); + + } + + public void add(Id id_1, Id id_2) { + add(id_1, id_2, TransactionId.SENTINEL, ArtifactId.SENTINEL); + } +} diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/JoinUtility.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/JoinUtility.java index 2c4572d6f95..9a75ca04e57 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/JoinUtility.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/JoinUtility.java @@ -59,13 +59,13 @@ public class JoinUtility { return new IdJoinQuery(createAccessor(jdbcClient), actualExpiration, getNewQueryId()); } - public static ArtifactJoinQuery createArtifactJoinQuery(JdbcClient jdbcClient) { - return createArtifactJoinQuery(jdbcClient, null); + public static Id4JoinQuery createId4JoinQuery(JdbcClient jdbcClient) { + return createId4JoinQuery(jdbcClient, null); } - public static ArtifactJoinQuery createArtifactJoinQuery(JdbcClient jdbcClient, Long expiresIn) { + public static Id4JoinQuery createId4JoinQuery(JdbcClient jdbcClient, Long expiresIn) { Long actualExpiration = getExpiresIn(jdbcClient, expiresIn, EXPIRATION_SECS__ARTIFACT_JOIN_QUERY); - return new ArtifactJoinQuery(createAccessor(jdbcClient), actualExpiration, getNewQueryId(), + return new Id4JoinQuery(createAccessor(jdbcClient), actualExpiration, getNewQueryId(), getMaxArtifactJoinSize(jdbcClient)); } @@ -87,9 +87,9 @@ public class JoinUtility { return createIdJoinQuery(getJdbcClient()); } - public static ArtifactJoinQuery createArtifactJoinQuery() { + public static Id4JoinQuery createId4JoinQuery() { JdbcClient jdbcClient = getJdbcClient(); - return createArtifactJoinQuery(jdbcClient); + return createId4JoinQuery(jdbcClient); } public static TransactionJoinQuery createTransactionJoinQuery() { diff --git a/plugins/org.eclipse.osee.orcs.db.mock/data/binary_data.zip b/plugins/org.eclipse.osee.orcs.db.mock/data/binary_data.zip index 168a4182410..75319e97477 100644 Binary files a/plugins/org.eclipse.osee.orcs.db.mock/data/binary_data.zip and b/plugins/org.eclipse.osee.orcs.db.mock/data/binary_data.zip differ diff --git a/plugins/org.eclipse.osee.orcs.db.mock/data/hsql.zip b/plugins/org.eclipse.osee.orcs.db.mock/data/hsql.zip index 5c7cb6d818a..1707c87e1ba 100644 Binary files a/plugins/org.eclipse.osee.orcs.db.mock/data/hsql.zip and b/plugins/org.eclipse.osee.orcs.db.mock/data/hsql.zip differ diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/LoaderTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/LoaderTest.java index 6eaca7f7119..1b2a8a13b5d 100644 --- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/LoaderTest.java +++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/LoaderTest.java @@ -105,8 +105,8 @@ public class LoaderTest { private static int OseeTypesClientDemoId, OseeTypesClientDemoActiveAttrId, OseeTypesClientDemoNameAttrId; private static long OseeTypesClientDemoActiveGammaId, OseeTypesClientDemoNameGammaId; private static String OseeTypesClientDemoGuid; - private static final long UserGroupsArtifactGammaId = 55L, OseeTypesClientDemoGammaId = 11L, - OseeTypesFrameworkGammaId = 9L; + private static final long UserGroupsArtifactGammaId = 43L, OseeTypesClientDemoGammaId = 11L, + OseeTypesFrameworkGammaId = 8L; private static final int UserGroupsId = CoreArtifactTokens.UserGroups.getUuid().intValue(); private static int UserGroupsNameAttrId; private static long UserGroupsNameGammaId; diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderFactoryImplTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderFactoryImplTest.java index bb6c1153ce9..fee38fddd1a 100644 --- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderFactoryImplTest.java +++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderFactoryImplTest.java @@ -50,8 +50,8 @@ import org.eclipse.osee.orcs.db.internal.IdentityManager; import org.eclipse.osee.orcs.db.internal.OrcsObjectFactory; import org.eclipse.osee.orcs.db.internal.loader.criteria.CriteriaOrcsLoad; import org.eclipse.osee.orcs.db.internal.sql.join.AbstractJoinQuery; -import org.eclipse.osee.orcs.db.internal.sql.join.ArtifactJoinQuery; import org.eclipse.osee.orcs.db.internal.sql.join.IJoinAccessor; +import org.eclipse.osee.orcs.db.internal.sql.join.Id4JoinQuery; import org.eclipse.osee.orcs.db.internal.sql.join.IdJoinQuery; import org.eclipse.osee.orcs.db.internal.sql.join.SqlJoinFactory; import org.eclipse.osee.orcs.db.mock.OsgiService; @@ -93,7 +93,7 @@ public class DataLoaderFactoryImplTest { @Mock private IJoinAccessor joinAccessor; @Captor private ArgumentCaptor contextCaptor; - @Captor private ArgumentCaptor joinCaptor; + @Captor private ArgumentCaptor joinCaptor; @Captor private ArgumentCaptor criteriaCaptor; @Captor private ArgumentCaptor descriptionCaptor; @@ -123,11 +123,11 @@ public class DataLoaderFactoryImplTest { when(jdbcClient.getStatement()).thenReturn(chStmt); when(jdbcClient.fetch(eq(TransactionId.SENTINEL), Matchers.anyString(), eq(COMMON))).thenReturn(EXPECTED_HEAD_TX); - when(joinFactory.createArtifactJoinQuery()).thenAnswer(new Answer() { + when(joinFactory.createId4JoinQuery()).thenAnswer(new Answer() { @Override - public ArtifactJoinQuery answer(InvocationOnMock invocation) throws Throwable { - return new ArtifactJoinQuery(joinAccessor, -1L, 23, Integer.MAX_VALUE); + public Id4JoinQuery answer(InvocationOnMock invocation) throws Throwable { + return new Id4JoinQuery(joinAccessor, -1L, 23, Integer.MAX_VALUE); } }); @@ -167,13 +167,13 @@ public class DataLoaderFactoryImplTest { LoadLevel expectedLoadLevel = LoadLevel.ARTIFACT_DATA; String expected = "SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id,\n" + // - " jart1.art_id, art1.art_type_id, art1.guid\n" + // + " jart1.id2, art1.art_type_id, art1.guid\n" + // " FROM \n" + // - "osee_join_artifact jart1, osee_artifact art1, osee_txs txs1\n" + // + "osee_join_id4 jart1, osee_artifact art1, osee_txs txs1\n" + // " WHERE \n" + // - "art1.art_id = jart1.art_id AND jart1.query_id = ? AND art1.gamma_id = txs1.gamma_id\n" + // - " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // - " ORDER BY txs1.branch_id, jart1.art_id, txs1.transaction_id desc"; + "art1.art_id = jart1.id2 AND jart1.query_id = ? AND art1.gamma_id = txs1.gamma_id\n" + // + " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.id1\n" + // + " ORDER BY txs1.branch_id, jart1.id2, txs1.transaction_id desc"; DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON, Arrays.asList(1, 2, 3)); @@ -191,13 +191,13 @@ public class DataLoaderFactoryImplTest { LoadLevel expectedLoadLevel = LoadLevel.ARTIFACT_DATA; String expected = "SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id,\n" + // - " jart1.art_id, art1.art_type_id, art1.guid\n" + // + " jart1.id2, art1.art_type_id, art1.guid\n" + // " FROM \n" + // - "osee_join_artifact jart1, osee_artifact art1, osee_txs txs1\n" + // + "osee_join_id4 jart1, osee_artifact art1, osee_txs txs1\n" + // " WHERE \n" + // - "art1.art_id = jart1.art_id AND jart1.query_id = ? AND art1.gamma_id = txs1.gamma_id\n" + // - " AND txs1.tx_current IN (1, 2, 3) AND txs1.branch_id = jart1.branch_id\n" + // - " ORDER BY txs1.branch_id, jart1.art_id, txs1.transaction_id desc"; + "art1.art_id = jart1.id2 AND jart1.query_id = ? AND art1.gamma_id = txs1.gamma_id\n" + // + " AND txs1.tx_current IN (1, 2, 3) AND txs1.branch_id = jart1.id1\n" + // + " ORDER BY txs1.branch_id, jart1.id2, txs1.transaction_id desc"; DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON, Arrays.asList(1, 2, 3)); @@ -216,13 +216,13 @@ public class DataLoaderFactoryImplTest { LoadLevel expectedLoadLevel = LoadLevel.ARTIFACT_DATA; String expected = "SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id, txs1.transaction_id as stripe_transaction_id,\n" + // - " jart1.art_id, art1.art_type_id, art1.guid\n" + // + " jart1.id2, art1.art_type_id, art1.guid\n" + // " FROM \n" + // - "osee_join_artifact jart1, osee_artifact art1, osee_txs txs1\n" + // + "osee_join_id4 jart1, osee_artifact art1, osee_txs txs1\n" + // " WHERE \n" + // - "art1.art_id = jart1.art_id AND jart1.query_id = ? AND art1.gamma_id = txs1.gamma_id\n" + // - " AND txs1.transaction_id <= jart1.transaction_id AND txs1.mod_type != 3 AND txs1.branch_id = jart1.branch_id\n" + // - " ORDER BY txs1.branch_id, jart1.art_id, txs1.transaction_id desc"; + "art1.art_id = jart1.id2 AND jart1.query_id = ? AND art1.gamma_id = txs1.gamma_id\n" + // + " AND txs1.transaction_id <= jart1.id3 AND txs1.mod_type != 3 AND txs1.branch_id = jart1.id1\n" + // + " ORDER BY txs1.branch_id, jart1.id2, txs1.transaction_id desc"; DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); @@ -240,13 +240,13 @@ public class DataLoaderFactoryImplTest { LoadLevel expectedLoadLevel = LoadLevel.ARTIFACT_DATA; String expected = "SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id, txs1.transaction_id as stripe_transaction_id,\n" + // - " jart1.art_id, art1.art_type_id, art1.guid\n" + // + " jart1.id2, art1.art_type_id, art1.guid\n" + // " FROM \n" + // - "osee_join_artifact jart1, osee_artifact art1, osee_txs txs1\n" + // + "osee_join_id4 jart1, osee_artifact art1, osee_txs txs1\n" + // " WHERE \n" + // - "art1.art_id = jart1.art_id AND jart1.query_id = ? AND art1.gamma_id = txs1.gamma_id\n" + // - " AND txs1.transaction_id <= jart1.transaction_id AND txs1.branch_id = jart1.branch_id\n" + // - " ORDER BY txs1.branch_id, jart1.art_id, txs1.transaction_id desc"; + "art1.art_id = jart1.id2 AND jart1.query_id = ? AND art1.gamma_id = txs1.gamma_id\n" + // + " AND txs1.transaction_id <= jart1.id3 AND txs1.branch_id = jart1.id1\n" + // + " ORDER BY txs1.branch_id, jart1.id2, txs1.transaction_id desc"; DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); @@ -267,13 +267,13 @@ public class DataLoaderFactoryImplTest { String expected = "SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id,\n" + // - " jart1.art_id, att1.attr_id, att1.attr_type_id, att1.value, att1.uri\n" + // + " jart1.id2, att1.attr_id, att1.attr_type_id, att1.value, att1.uri\n" + // " FROM \n" + // - "osee_join_artifact jart1, osee_attribute att1, osee_txs txs1\n" + // + "osee_join_id4 jart1, osee_attribute att1, osee_txs txs1\n" + // " WHERE \n" + // - "att1.art_id = jart1.art_id AND jart1.query_id = ? AND att1.gamma_id = txs1.gamma_id\n" + // - " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // - " ORDER BY txs1.branch_id, jart1.art_id, att1.attr_id, txs1.transaction_id desc"; + "att1.art_id = jart1.id2 AND jart1.query_id = ? AND att1.gamma_id = txs1.gamma_id\n" + // + " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.id1\n" + // + " ORDER BY txs1.branch_id, jart1.id2, att1.attr_id, txs1.transaction_id desc"; DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON, Arrays.asList(1, 2, 3)); @@ -292,13 +292,13 @@ public class DataLoaderFactoryImplTest { String expected = "SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id,\n" + // - " jart1.art_id, att1.attr_id, att1.attr_type_id, att1.value, att1.uri\n" + // + " jart1.id2, att1.attr_id, att1.attr_type_id, att1.value, att1.uri\n" + // " FROM \n" + // - "osee_join_artifact jart1, osee_attribute att1, osee_txs txs1\n" + // + "osee_join_id4 jart1, osee_attribute att1, osee_txs txs1\n" + // " WHERE \n" + // - "att1.art_id = jart1.art_id AND jart1.query_id = ? AND att1.attr_type_id = ? AND att1.gamma_id = txs1.gamma_id\n" + // - " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // - " ORDER BY txs1.branch_id, jart1.art_id, att1.attr_id, txs1.transaction_id desc"; + "att1.art_id = jart1.id2 AND jart1.query_id = ? AND att1.attr_type_id = ? AND att1.gamma_id = txs1.gamma_id\n" + // + " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.id1\n" + // + " ORDER BY txs1.branch_id, jart1.id2, att1.attr_id, txs1.transaction_id desc"; DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON, Arrays.asList(1, 2, 3)); @@ -318,13 +318,13 @@ public class DataLoaderFactoryImplTest { String expected = "SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id,\n" + // - " jart1.art_id, att1.attr_id, att1.attr_type_id, att1.value, att1.uri\n" + // + " jart1.id2, att1.attr_id, att1.attr_type_id, att1.value, att1.uri\n" + // " FROM \n" + // - "osee_join_artifact jart1, osee_join_id jid1, osee_attribute att1, osee_txs txs1\n" + // + "osee_join_id4 jart1, osee_join_id jid1, osee_attribute att1, osee_txs txs1\n" + // " WHERE \n" + // - "att1.art_id = jart1.art_id AND jart1.query_id = ? AND att1.attr_type_id = jid1.id AND jid1.query_id = ? AND att1.gamma_id = txs1.gamma_id\n" + // - " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // - " ORDER BY txs1.branch_id, jart1.art_id, att1.attr_id, txs1.transaction_id desc"; + "att1.art_id = jart1.id2 AND jart1.query_id = ? AND att1.attr_type_id = jid1.id AND jid1.query_id = ? AND att1.gamma_id = txs1.gamma_id\n" + // + " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.id1\n" + // + " ORDER BY txs1.branch_id, jart1.id2, att1.attr_id, txs1.transaction_id desc"; DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON, Arrays.asList(1, 2, 3)); @@ -345,13 +345,13 @@ public class DataLoaderFactoryImplTest { String expected = "SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id,\n" + // - " jart1.art_id, att1.attr_id, att1.attr_type_id, att1.value, att1.uri\n" + // + " jart1.id2, att1.attr_id, att1.attr_type_id, att1.value, att1.uri\n" + // " FROM \n" + // - "osee_join_artifact jart1, osee_attribute att1, osee_txs txs1\n" + // + "osee_join_id4 jart1, osee_attribute att1, osee_txs txs1\n" + // " WHERE \n" + // - "att1.art_id = jart1.art_id AND jart1.query_id = ? AND att1.attr_id = ? AND att1.gamma_id = txs1.gamma_id\n" + // - " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // - " ORDER BY txs1.branch_id, jart1.art_id, att1.attr_id, txs1.transaction_id desc"; + "att1.art_id = jart1.id2 AND jart1.query_id = ? AND att1.attr_id = ? AND att1.gamma_id = txs1.gamma_id\n" + // + " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.id1\n" + // + " ORDER BY txs1.branch_id, jart1.id2, att1.attr_id, txs1.transaction_id desc"; DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON, Arrays.asList(1, 2, 3)); @@ -371,13 +371,13 @@ public class DataLoaderFactoryImplTest { String expected = "SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id,\n" + // - " jart1.art_id, att1.attr_id, att1.attr_type_id, att1.value, att1.uri\n" + // + " jart1.id2, att1.attr_id, att1.attr_type_id, att1.value, att1.uri\n" + // " FROM \n" + // - "osee_join_artifact jart1, osee_join_id jid1, osee_attribute att1, osee_txs txs1\n" + // + "osee_join_id4 jart1, osee_join_id jid1, osee_attribute att1, osee_txs txs1\n" + // " WHERE \n" + // - "att1.art_id = jart1.art_id AND jart1.query_id = ? AND att1.attr_id = jid1.id AND jid1.query_id = ? AND att1.gamma_id = txs1.gamma_id\n" + // - " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // - " ORDER BY txs1.branch_id, jart1.art_id, att1.attr_id, txs1.transaction_id desc"; + "att1.art_id = jart1.id2 AND jart1.query_id = ? AND att1.attr_id = jid1.id AND jid1.query_id = ? AND att1.gamma_id = txs1.gamma_id\n" + // + " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.id1\n" + // + " ORDER BY txs1.branch_id, jart1.id2, att1.attr_id, txs1.transaction_id desc"; DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON, Arrays.asList(1, 2, 3)); @@ -397,13 +397,13 @@ public class DataLoaderFactoryImplTest { String expected = "SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id,\n" + // - " jart1.art_id, att1.attr_id, att1.attr_type_id, att1.value, att1.uri\n" + // + " jart1.id2, att1.attr_id, att1.attr_type_id, att1.value, att1.uri\n" + // " FROM \n" + // - "osee_join_artifact jart1, osee_join_id jid1, osee_join_id jid2, osee_attribute att1, osee_txs txs1\n" + // + "osee_join_id4 jart1, osee_join_id jid1, osee_join_id jid2, osee_attribute att1, osee_txs txs1\n" + // " WHERE \n" + // - "att1.art_id = jart1.art_id AND jart1.query_id = ? AND att1.attr_id = jid1.id AND jid1.query_id = ? AND att1.attr_type_id = jid2.id AND jid2.query_id = ? AND att1.gamma_id = txs1.gamma_id\n" + // - " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // - " ORDER BY txs1.branch_id, jart1.art_id, att1.attr_id, txs1.transaction_id desc"; + "att1.art_id = jart1.id2 AND jart1.query_id = ? AND att1.attr_id = jid1.id AND jid1.query_id = ? AND att1.attr_type_id = jid2.id AND jid2.query_id = ? AND att1.gamma_id = txs1.gamma_id\n" + // + " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.id1\n" + // + " ORDER BY txs1.branch_id, jart1.id2, att1.attr_id, txs1.transaction_id desc"; DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON, Arrays.asList(1, 2, 3)); @@ -425,13 +425,13 @@ public class DataLoaderFactoryImplTest { String expected = "SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id,\n" + // - " jart1.art_id, att1.attr_id, att1.attr_type_id, att1.value, att1.uri\n" + // + " jart1.id2, att1.attr_id, att1.attr_type_id, att1.value, att1.uri\n" + // " FROM \n" + // - "osee_join_artifact jart1, osee_attribute att1, osee_txs txs1\n" + // + "osee_join_id4 jart1, osee_attribute att1, osee_txs txs1\n" + // " WHERE \n" + // - "att1.art_id = jart1.art_id AND jart1.query_id = ? AND att1.attr_id = ? AND att1.attr_type_id = ? AND att1.gamma_id = txs1.gamma_id\n" + // - " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // - " ORDER BY txs1.branch_id, jart1.art_id, att1.attr_id, txs1.transaction_id desc"; + "att1.art_id = jart1.id2 AND jart1.query_id = ? AND att1.attr_id = ? AND att1.attr_type_id = ? AND att1.gamma_id = txs1.gamma_id\n" + // + " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.id1\n" + // + " ORDER BY txs1.branch_id, jart1.id2, att1.attr_id, txs1.transaction_id desc"; DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON, Arrays.asList(1, 2, 3)); @@ -452,13 +452,13 @@ public class DataLoaderFactoryImplTest { String expected = "SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id,\n" + // - " jart1.art_id, att1.attr_id, att1.attr_type_id, att1.value, att1.uri\n" + // + " jart1.id2, att1.attr_id, att1.attr_type_id, att1.value, att1.uri\n" + // " FROM \n" + // - "osee_join_artifact jart1, osee_attribute att1, osee_txs txs1\n" + // + "osee_join_id4 jart1, osee_attribute att1, osee_txs txs1\n" + // " WHERE \n" + // - "att1.art_id = jart1.art_id AND jart1.query_id = ? AND att1.gamma_id = txs1.gamma_id\n" + // - " AND txs1.tx_current IN (1, 2, 3) AND txs1.branch_id = jart1.branch_id\n" + // - " ORDER BY txs1.branch_id, jart1.art_id, att1.attr_id, txs1.transaction_id desc"; + "att1.art_id = jart1.id2 AND jart1.query_id = ? AND att1.gamma_id = txs1.gamma_id\n" + // + " AND txs1.tx_current IN (1, 2, 3) AND txs1.branch_id = jart1.id1\n" + // + " ORDER BY txs1.branch_id, jart1.id2, att1.attr_id, txs1.transaction_id desc"; DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON, Arrays.asList(1, 2, 3)); @@ -478,13 +478,13 @@ public class DataLoaderFactoryImplTest { String expected = "SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id, txs1.transaction_id as stripe_transaction_id,\n" + // - " jart1.art_id, att1.attr_id, att1.attr_type_id, att1.value, att1.uri\n" + // + " jart1.id2, att1.attr_id, att1.attr_type_id, att1.value, att1.uri\n" + // " FROM \n" + // - "osee_join_artifact jart1, osee_attribute att1, osee_txs txs1\n" + // + "osee_join_id4 jart1, osee_attribute att1, osee_txs txs1\n" + // " WHERE \n" + // - "att1.art_id = jart1.art_id AND jart1.query_id = ? AND att1.gamma_id = txs1.gamma_id\n" + // - " AND txs1.transaction_id <= jart1.transaction_id AND txs1.mod_type != 3 AND txs1.branch_id = jart1.branch_id\n" + // - " ORDER BY txs1.branch_id, jart1.art_id, att1.attr_id, txs1.transaction_id desc"; + "att1.art_id = jart1.id2 AND jart1.query_id = ? AND att1.gamma_id = txs1.gamma_id\n" + // + " AND txs1.transaction_id <= jart1.id3 AND txs1.mod_type != 3 AND txs1.branch_id = jart1.id1\n" + // + " ORDER BY txs1.branch_id, jart1.id2, att1.attr_id, txs1.transaction_id desc"; DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); @@ -503,13 +503,13 @@ public class DataLoaderFactoryImplTest { String expected = "SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id, txs1.transaction_id as stripe_transaction_id,\n" + // - " jart1.art_id, att1.attr_id, att1.attr_type_id, att1.value, att1.uri\n" + // + " jart1.id2, att1.attr_id, att1.attr_type_id, att1.value, att1.uri\n" + // " FROM \n" + // - "osee_join_artifact jart1, osee_attribute att1, osee_txs txs1\n" + // + "osee_join_id4 jart1, osee_attribute att1, osee_txs txs1\n" + // " WHERE \n" + // - "att1.art_id = jart1.art_id AND jart1.query_id = ? AND att1.gamma_id = txs1.gamma_id\n" + // - " AND txs1.transaction_id <= jart1.transaction_id AND txs1.branch_id = jart1.branch_id\n" + // - " ORDER BY txs1.branch_id, jart1.art_id, att1.attr_id, txs1.transaction_id desc"; + "att1.art_id = jart1.id2 AND jart1.query_id = ? AND att1.gamma_id = txs1.gamma_id\n" + // + " AND txs1.transaction_id <= jart1.id3 AND txs1.branch_id = jart1.id1\n" + // + " ORDER BY txs1.branch_id, jart1.id2, att1.attr_id, txs1.transaction_id desc"; DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); @@ -531,13 +531,13 @@ public class DataLoaderFactoryImplTest { String expected = "SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id,\n" + // - " jart1.art_id, rel1.rel_link_id, rel1.rel_link_type_id, rel1.a_art_id, rel1.b_art_id, rel1.rationale\n" + // + " jart1.id2, rel1.rel_link_id, rel1.rel_link_type_id, rel1.a_art_id, rel1.b_art_id, rel1.rationale\n" + // " FROM \n" + // - "osee_join_artifact jart1, osee_relation_link rel1, osee_txs txs1\n" + // + "osee_join_id4 jart1, osee_relation_link rel1, osee_txs txs1\n" + // " WHERE \n" + // - "(rel1.a_art_id = jart1.art_id OR rel1.b_art_id = jart1.art_id) AND jart1.query_id = ? AND rel1.gamma_id = txs1.gamma_id\n" + // - " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // - " ORDER BY txs1.branch_id, jart1.art_id, rel1.rel_link_id, txs1.transaction_id desc"; + "(rel1.a_art_id = jart1.id2 OR rel1.b_art_id = jart1.id2) AND jart1.query_id = ? AND rel1.gamma_id = txs1.gamma_id\n" + // + " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.id1\n" + // + " ORDER BY txs1.branch_id, jart1.id2, rel1.rel_link_id, txs1.transaction_id desc"; DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON, Arrays.asList(1, 2, 3)); @@ -556,13 +556,13 @@ public class DataLoaderFactoryImplTest { String expected = "SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id,\n" + // - " jart1.art_id, rel1.rel_link_id, rel1.rel_link_type_id, rel1.a_art_id, rel1.b_art_id, rel1.rationale\n" + // + " jart1.id2, rel1.rel_link_id, rel1.rel_link_type_id, rel1.a_art_id, rel1.b_art_id, rel1.rationale\n" + // " FROM \n" + // - "osee_join_artifact jart1, osee_relation_link rel1, osee_txs txs1\n" + // + "osee_join_id4 jart1, osee_relation_link rel1, osee_txs txs1\n" + // " WHERE \n" + // - "(rel1.a_art_id = jart1.art_id OR rel1.b_art_id = jart1.art_id) AND jart1.query_id = ? AND rel1.gamma_id = txs1.gamma_id\n" + // - " AND txs1.tx_current IN (1, 2, 3) AND txs1.branch_id = jart1.branch_id\n" + // - " ORDER BY txs1.branch_id, jart1.art_id, rel1.rel_link_id, txs1.transaction_id desc"; + "(rel1.a_art_id = jart1.id2 OR rel1.b_art_id = jart1.id2) AND jart1.query_id = ? AND rel1.gamma_id = txs1.gamma_id\n" + // + " AND txs1.tx_current IN (1, 2, 3) AND txs1.branch_id = jart1.id1\n" + // + " ORDER BY txs1.branch_id, jart1.id2, rel1.rel_link_id, txs1.transaction_id desc"; DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON, Arrays.asList(1, 2, 3)); @@ -582,13 +582,13 @@ public class DataLoaderFactoryImplTest { String expected = "SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id,\n" + // - " jart1.art_id, rel1.rel_link_id, rel1.rel_link_type_id, rel1.a_art_id, rel1.b_art_id, rel1.rationale\n" + // + " jart1.id2, rel1.rel_link_id, rel1.rel_link_type_id, rel1.a_art_id, rel1.b_art_id, rel1.rationale\n" + // " FROM \n" + // - "osee_join_artifact jart1, osee_relation_link rel1, osee_txs txs1\n" + // + "osee_join_id4 jart1, osee_relation_link rel1, osee_txs txs1\n" + // " WHERE \n" + // - "(rel1.a_art_id = jart1.art_id OR rel1.b_art_id = jart1.art_id) AND jart1.query_id = ? AND rel1.rel_link_type_id = ? AND rel1.gamma_id = txs1.gamma_id\n" + // - " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // - " ORDER BY txs1.branch_id, jart1.art_id, rel1.rel_link_id, txs1.transaction_id desc"; + "(rel1.a_art_id = jart1.id2 OR rel1.b_art_id = jart1.id2) AND jart1.query_id = ? AND rel1.rel_link_type_id = ? AND rel1.gamma_id = txs1.gamma_id\n" + // + " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.id1\n" + // + " ORDER BY txs1.branch_id, jart1.id2, rel1.rel_link_id, txs1.transaction_id desc"; DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON, Arrays.asList(1, 2, 3)); @@ -609,13 +609,13 @@ public class DataLoaderFactoryImplTest { String expected = "SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id,\n" + // - " jart1.art_id, rel1.rel_link_id, rel1.rel_link_type_id, rel1.a_art_id, rel1.b_art_id, rel1.rationale\n" + // + " jart1.id2, rel1.rel_link_id, rel1.rel_link_type_id, rel1.a_art_id, rel1.b_art_id, rel1.rationale\n" + // " FROM \n" + // - "osee_join_artifact jart1, osee_join_id jid1, osee_relation_link rel1, osee_txs txs1\n" + // + "osee_join_id4 jart1, osee_join_id jid1, osee_relation_link rel1, osee_txs txs1\n" + // " WHERE \n" + // - "(rel1.a_art_id = jart1.art_id OR rel1.b_art_id = jart1.art_id) AND jart1.query_id = ? AND rel1.rel_link_type_id = jid1.id AND jid1.query_id = ? AND rel1.gamma_id = txs1.gamma_id\n" + // - " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // - " ORDER BY txs1.branch_id, jart1.art_id, rel1.rel_link_id, txs1.transaction_id desc"; + "(rel1.a_art_id = jart1.id2 OR rel1.b_art_id = jart1.id2) AND jart1.query_id = ? AND rel1.rel_link_type_id = jid1.id AND jid1.query_id = ? AND rel1.gamma_id = txs1.gamma_id\n" + // + " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.id1\n" + // + " ORDER BY txs1.branch_id, jart1.id2, rel1.rel_link_id, txs1.transaction_id desc"; DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON, Arrays.asList(1, 2, 3)); @@ -638,13 +638,13 @@ public class DataLoaderFactoryImplTest { String expected = "SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id,\n" + // - " jart1.art_id, rel1.rel_link_id, rel1.rel_link_type_id, rel1.a_art_id, rel1.b_art_id, rel1.rationale\n" + // + " jart1.id2, rel1.rel_link_id, rel1.rel_link_type_id, rel1.a_art_id, rel1.b_art_id, rel1.rationale\n" + // " FROM \n" + // - "osee_join_artifact jart1, osee_relation_link rel1, osee_txs txs1\n" + // + "osee_join_id4 jart1, osee_relation_link rel1, osee_txs txs1\n" + // " WHERE \n" + // - "(rel1.a_art_id = jart1.art_id OR rel1.b_art_id = jart1.art_id) AND jart1.query_id = ? AND rel1.rel_link_id = ? AND rel1.gamma_id = txs1.gamma_id\n" + // - " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // - " ORDER BY txs1.branch_id, jart1.art_id, rel1.rel_link_id, txs1.transaction_id desc"; + "(rel1.a_art_id = jart1.id2 OR rel1.b_art_id = jart1.id2) AND jart1.query_id = ? AND rel1.rel_link_id = ? AND rel1.gamma_id = txs1.gamma_id\n" + // + " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.id1\n" + // + " ORDER BY txs1.branch_id, jart1.id2, rel1.rel_link_id, txs1.transaction_id desc"; DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON, Arrays.asList(1, 2, 3)); @@ -664,13 +664,13 @@ public class DataLoaderFactoryImplTest { String expected = "SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id,\n" + // - " jart1.art_id, rel1.rel_link_id, rel1.rel_link_type_id, rel1.a_art_id, rel1.b_art_id, rel1.rationale\n" + // + " jart1.id2, rel1.rel_link_id, rel1.rel_link_type_id, rel1.a_art_id, rel1.b_art_id, rel1.rationale\n" + // " FROM \n" + // - "osee_join_artifact jart1, osee_join_id jid1, osee_relation_link rel1, osee_txs txs1\n" + // + "osee_join_id4 jart1, osee_join_id jid1, osee_relation_link rel1, osee_txs txs1\n" + // " WHERE \n" + // - "(rel1.a_art_id = jart1.art_id OR rel1.b_art_id = jart1.art_id) AND jart1.query_id = ? AND rel1.rel_link_id = jid1.id AND jid1.query_id = ? AND rel1.gamma_id = txs1.gamma_id\n" + // - " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // - " ORDER BY txs1.branch_id, jart1.art_id, rel1.rel_link_id, txs1.transaction_id desc"; + "(rel1.a_art_id = jart1.id2 OR rel1.b_art_id = jart1.id2) AND jart1.query_id = ? AND rel1.rel_link_id = jid1.id AND jid1.query_id = ? AND rel1.gamma_id = txs1.gamma_id\n" + // + " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.id1\n" + // + " ORDER BY txs1.branch_id, jart1.id2, rel1.rel_link_id, txs1.transaction_id desc"; DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON, Arrays.asList(1, 2, 3)); @@ -690,13 +690,13 @@ public class DataLoaderFactoryImplTest { String expected = "SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id,\n" + // - " jart1.art_id, rel1.rel_link_id, rel1.rel_link_type_id, rel1.a_art_id, rel1.b_art_id, rel1.rationale\n" + // + " jart1.id2, rel1.rel_link_id, rel1.rel_link_type_id, rel1.a_art_id, rel1.b_art_id, rel1.rationale\n" + // " FROM \n" + // - "osee_join_artifact jart1, osee_join_id jid1, osee_join_id jid2, osee_relation_link rel1, osee_txs txs1\n" + // + "osee_join_id4 jart1, osee_join_id jid1, osee_join_id jid2, osee_relation_link rel1, osee_txs txs1\n" + // " WHERE \n" + // - "(rel1.a_art_id = jart1.art_id OR rel1.b_art_id = jart1.art_id) AND jart1.query_id = ? AND rel1.rel_link_id = jid1.id AND jid1.query_id = ? AND rel1.rel_link_type_id = jid2.id AND jid2.query_id = ? AND rel1.gamma_id = txs1.gamma_id\n" + // - " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // - " ORDER BY txs1.branch_id, jart1.art_id, rel1.rel_link_id, txs1.transaction_id desc"; + "(rel1.a_art_id = jart1.id2 OR rel1.b_art_id = jart1.id2) AND jart1.query_id = ? AND rel1.rel_link_id = jid1.id AND jid1.query_id = ? AND rel1.rel_link_type_id = jid2.id AND jid2.query_id = ? AND rel1.gamma_id = txs1.gamma_id\n" + // + " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.id1\n" + // + " ORDER BY txs1.branch_id, jart1.id2, rel1.rel_link_id, txs1.transaction_id desc"; DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON, Arrays.asList(1, 2, 3)); @@ -719,13 +719,13 @@ public class DataLoaderFactoryImplTest { String expected = "SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id,\n" + // - " jart1.art_id, rel1.rel_link_id, rel1.rel_link_type_id, rel1.a_art_id, rel1.b_art_id, rel1.rationale\n" + // + " jart1.id2, rel1.rel_link_id, rel1.rel_link_type_id, rel1.a_art_id, rel1.b_art_id, rel1.rationale\n" + // " FROM \n" + // - "osee_join_artifact jart1, osee_relation_link rel1, osee_txs txs1\n" + // + "osee_join_id4 jart1, osee_relation_link rel1, osee_txs txs1\n" + // " WHERE \n" + // - "(rel1.a_art_id = jart1.art_id OR rel1.b_art_id = jart1.art_id) AND jart1.query_id = ? AND rel1.rel_link_id = ? AND rel1.rel_link_type_id = ? AND rel1.gamma_id = txs1.gamma_id\n" + // - " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // - " ORDER BY txs1.branch_id, jart1.art_id, rel1.rel_link_id, txs1.transaction_id desc"; + "(rel1.a_art_id = jart1.id2 OR rel1.b_art_id = jart1.id2) AND jart1.query_id = ? AND rel1.rel_link_id = ? AND rel1.rel_link_type_id = ? AND rel1.gamma_id = txs1.gamma_id\n" + // + " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.id1\n" + // + " ORDER BY txs1.branch_id, jart1.id2, rel1.rel_link_id, txs1.transaction_id desc"; DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON, Arrays.asList(1, 2, 3)); @@ -747,13 +747,13 @@ public class DataLoaderFactoryImplTest { String expected = "SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id, txs1.transaction_id as stripe_transaction_id,\n" + // - " jart1.art_id, rel1.rel_link_id, rel1.rel_link_type_id, rel1.a_art_id, rel1.b_art_id, rel1.rationale\n" + // + " jart1.id2, rel1.rel_link_id, rel1.rel_link_type_id, rel1.a_art_id, rel1.b_art_id, rel1.rationale\n" + // " FROM \n" + // - "osee_join_artifact jart1, osee_relation_link rel1, osee_txs txs1\n" + // + "osee_join_id4 jart1, osee_relation_link rel1, osee_txs txs1\n" + // " WHERE \n" + // - "(rel1.a_art_id = jart1.art_id OR rel1.b_art_id = jart1.art_id) AND jart1.query_id = ? AND rel1.gamma_id = txs1.gamma_id\n" + // - " AND txs1.transaction_id <= jart1.transaction_id AND txs1.mod_type != 3 AND txs1.branch_id = jart1.branch_id\n" + // - " ORDER BY txs1.branch_id, jart1.art_id, rel1.rel_link_id, txs1.transaction_id desc"; + "(rel1.a_art_id = jart1.id2 OR rel1.b_art_id = jart1.id2) AND jart1.query_id = ? AND rel1.gamma_id = txs1.gamma_id\n" + // + " AND txs1.transaction_id <= jart1.id3 AND txs1.mod_type != 3 AND txs1.branch_id = jart1.id1\n" + // + " ORDER BY txs1.branch_id, jart1.id2, rel1.rel_link_id, txs1.transaction_id desc"; DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); @@ -771,13 +771,13 @@ public class DataLoaderFactoryImplTest { LoadLevel expectedLoadLevel = LoadLevel.ALL; String expected = "SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id,\n" + // - " jart1.art_id, rel1.rel_link_id, rel1.rel_link_type_id, rel1.a_art_id, rel1.b_art_id, rel1.rationale\n" + // + " jart1.id2, rel1.rel_link_id, rel1.rel_link_type_id, rel1.a_art_id, rel1.b_art_id, rel1.rationale\n" + // " FROM \n" + // - "osee_join_artifact jart1, osee_relation_link rel1, osee_txs txs1\n" + // + "osee_join_id4 jart1, osee_relation_link rel1, osee_txs txs1\n" + // " WHERE \n" + // - "(rel1.a_art_id = jart1.art_id OR rel1.b_art_id = jart1.art_id) AND jart1.query_id = ? AND rel1.gamma_id = txs1.gamma_id\n" + // - " AND txs1.tx_current IN (1, 2, 3) AND txs1.branch_id = jart1.branch_id\n" + // - " ORDER BY txs1.branch_id, jart1.art_id, rel1.rel_link_id, txs1.transaction_id desc"; + "(rel1.a_art_id = jart1.id2 OR rel1.b_art_id = jart1.id2) AND jart1.query_id = ? AND rel1.gamma_id = txs1.gamma_id\n" + // + " AND txs1.tx_current IN (1, 2, 3) AND txs1.branch_id = jart1.id1\n" + // + " ORDER BY txs1.branch_id, jart1.id2, rel1.rel_link_id, txs1.transaction_id desc"; DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON, Arrays.asList(1, 2, 3)); @@ -798,13 +798,13 @@ public class DataLoaderFactoryImplTest { LoadLevel expectedLoadLevel = LoadLevel.ALL; String expected = "SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id,\n" + // - " jart1.art_id, rel1.rel_link_id, rel1.rel_link_type_id, rel1.a_art_id, rel1.b_art_id, rel1.rationale\n" + // + " jart1.id2, rel1.rel_link_id, rel1.rel_link_type_id, rel1.a_art_id, rel1.b_art_id, rel1.rationale\n" + // " FROM \n" + // - "osee_join_artifact jart1, osee_relation_link rel1, osee_txs txs1\n" + // + "osee_join_id4 jart1, osee_relation_link rel1, osee_txs txs1\n" + // " WHERE \n" + // - "(rel1.a_art_id = jart1.art_id OR rel1.b_art_id = jart1.art_id) AND jart1.query_id = ? AND rel1.rel_link_type_id = ? AND rel1.gamma_id = txs1.gamma_id\n" + // - " AND txs1.tx_current IN (1, 2, 3) AND txs1.branch_id = jart1.branch_id\n" + // - " ORDER BY txs1.branch_id, jart1.art_id, rel1.rel_link_id, txs1.transaction_id desc"; + "(rel1.a_art_id = jart1.id2 OR rel1.b_art_id = jart1.id2) AND jart1.query_id = ? AND rel1.rel_link_type_id = ? AND rel1.gamma_id = txs1.gamma_id\n" + // + " AND txs1.tx_current IN (1, 2, 3) AND txs1.branch_id = jart1.id1\n" + // + " ORDER BY txs1.branch_id, jart1.id2, rel1.rel_link_id, txs1.transaction_id desc"; DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON, Arrays.asList(1, 2, 3)); diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/ArtifactJoinQueryTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/ArtifactJoinQueryTest.java index 5871f159649..1c522b4df62 100644 --- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/ArtifactJoinQueryTest.java +++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/ArtifactJoinQueryTest.java @@ -11,6 +11,7 @@ package org.eclipse.osee.orcs.db.internal.sql.join; import java.util.List; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.junit.Assert; @@ -26,15 +27,16 @@ public class ArtifactJoinQueryTest { @Test public void testAdd() throws OseeCoreException { MockJoinAccessor joinAccessor = new MockJoinAccessor(); - ArtifactJoinQuery join = new ArtifactJoinQuery(joinAccessor, -1L, 999, 10); + Id4JoinQuery join = new Id4JoinQuery(joinAccessor, -1L, 999, 10); Assert.assertEquals(0, join.size()); Assert.assertEquals(true, join.isEmpty()); - join.add(1234, BranchId.valueOf(5678L), null); + join.add(BranchId.valueOf(5678L), ArtifactId.valueOf(1234)); Assert.assertEquals(1, join.size()); Assert.assertEquals(false, join.isEmpty()); - join.add(1234, BranchId.valueOf(5678L), null); + join.add(BranchId.valueOf(5678L), ArtifactId.valueOf(1234)); + Assert.assertEquals(1, join.size()); Assert.assertEquals(false, join.wasStored()); @@ -48,17 +50,17 @@ public class ArtifactJoinQueryTest { 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.assertEquals(1234, entry[1]); - Assert.assertEquals(5678L, entry[2]); + Assert.assertEquals(ArtifactId.valueOf(1234), entry[2]); + Assert.assertEquals(BranchId.valueOf(5678L), entry[1]); } @Test(expected = OseeCoreException.class) public void testStoreTwice() throws OseeCoreException { MockJoinAccessor joinAccessor = new MockJoinAccessor(); - ArtifactJoinQuery join = new ArtifactJoinQuery(joinAccessor, -1L, 1000, 10); + Id4JoinQuery join = new Id4JoinQuery(joinAccessor, -1L, 1000, 10); Assert.assertEquals(false, join.wasStored()); join.store(); @@ -74,10 +76,10 @@ public class ArtifactJoinQueryTest { public void testMoreThanAllowed() throws OseeCoreException { MockJoinAccessor joinAccessor = new MockJoinAccessor(); int maxSize = 5; - ArtifactJoinQuery join = new ArtifactJoinQuery(joinAccessor, -1L, 1000, maxSize); + Id4JoinQuery join = new Id4JoinQuery(joinAccessor, -1L, 1000, maxSize); for (int i = 0; i < maxSize + 1; i++) { - join.add(i + 1, BranchId.valueOf(1123L), null); + join.add(ArtifactId.valueOf(i + 1), BranchId.valueOf(1123L)); } } diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CreateBranchDatabaseTxCallable.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CreateBranchDatabaseTxCallable.java index d32ed2e9802..34556238fd1 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CreateBranchDatabaseTxCallable.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CreateBranchDatabaseTxCallable.java @@ -80,9 +80,9 @@ public class CreateBranchDatabaseTxCallable extends JdbcTransaction { "INSERT INTO osee_merge (source_branch_id, dest_branch_id, merge_branch_id, commit_transaction_id) VALUES (?,?,?,?)"; private final static String SELECT_ATTRIBUTE_ADDRESSING_FROM_JOIN = - "SELECT item.gamma_id, txs.mod_type, txs.app_id FROM osee_attribute item, osee_txs txs, osee_join_artifact artjoin WHERE txs.branch_id = ? AND txs.tx_current <> ? AND txs.gamma_id = item.gamma_id AND item.art_id = artjoin.art_id and artjoin.query_id = ? ORDER BY txs.transaction_id DESC"; + "SELECT item.gamma_id, txs.mod_type, txs.app_id FROM osee_attribute item, osee_txs txs, osee_join_id4 artjoin WHERE txs.branch_id = ? AND txs.tx_current <> ? AND txs.gamma_id = item.gamma_id AND item.art_id = artjoin.id2 and artjoin.query_id = ? ORDER BY txs.transaction_id DESC"; private final static String SELECT_ARTIFACT_ADDRESSING_FROM_JOIN = - "SELECT item.gamma_id, txs.mod_type, txs.app_id FROM osee_artifact item, osee_txs txs, osee_join_artifact artjoin WHERE txs.branch_id = ? AND txs.tx_current <> ? AND txs.gamma_id = item.gamma_id AND item.art_id = artjoin.art_id and artjoin.query_id = ? ORDER BY txs.transaction_id DESC"; + "SELECT item.gamma_id, txs.mod_type, txs.app_id FROM osee_artifact item, osee_txs txs, osee_join_id4 artjoin WHERE txs.branch_id = ? AND txs.tx_current <> ? AND txs.gamma_id = item.gamma_id AND item.art_id = artjoin.id2 and artjoin.query_id = ? ORDER BY txs.transaction_id DESC"; private static final String TEST_MERGE_BRANCH_EXISTENCE = "SELECT COUNT(1) FROM osee_merge WHERE source_branch_id = ? AND dest_branch_id = ?"; diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/LoadSqlWriter.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/LoadSqlWriter.java index 6a156b08303..37859ebb5d3 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/LoadSqlWriter.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/LoadSqlWriter.java @@ -39,7 +39,7 @@ public class LoadSqlWriter extends AbstractSqlWriter { @Override public void writeSelect(Iterable> handlers) throws OseeCoreException { String txAlias = getLastAlias(TableEnum.TXS_TABLE); - String artJoinAlias = getLastAlias(TableEnum.ARTIFACT_JOIN_TABLE); + String artJoinAlias = getLastAlias(TableEnum.JOIN_ID4_TABLE); write("SELECT%s ", getSqlHint()); write("%s.gamma_id, %s.mod_type, %s.branch_id, %s.transaction_id, %s.app_id", txAlias, txAlias, txAlias, txAlias, @@ -47,7 +47,7 @@ public class LoadSqlWriter extends AbstractSqlWriter { if (OptionsUtil.isHistorical(getOptions())) { write(", %s.transaction_id as stripe_transaction_id", txAlias); } - write(",\n %s.art_id", artJoinAlias); + write(",\n %s.id2", artJoinAlias); for (SqlHandler handler : handlers) { setHandlerLevel(handler); write(", "); @@ -57,10 +57,10 @@ public class LoadSqlWriter extends AbstractSqlWriter { @Override public void writeGroupAndOrder() throws OseeCoreException { - String artAlias = getLastAlias(TableEnum.ARTIFACT_JOIN_TABLE); + String artAlias = getLastAlias(TableEnum.JOIN_ID4_TABLE); String txAlias = getLastAlias(TableEnum.TXS_TABLE); - write("\n ORDER BY %s.branch_id, %s.art_id", txAlias, artAlias); + write("\n ORDER BY %s.branch_id, %s.id2", txAlias, artAlias); if (hasAlias(TableEnum.ATTRIBUTE_TABLE)) { write(", %s.attr_id", getLastAlias(TableEnum.ATTRIBUTE_TABLE)); } @@ -82,13 +82,13 @@ public class LoadSqlWriter extends AbstractSqlWriter { @Override public String getTxBranchFilter(String txsAlias, boolean allowDeleted) { StringBuilder sb = new StringBuilder(); - String artJoinAlias = getLastAlias(TableEnum.ARTIFACT_JOIN_TABLE); + String artJoinAlias = getLastAlias(TableEnum.JOIN_ID4_TABLE); writeTxFilter(txsAlias, artJoinAlias, sb, allowDeleted); sb.append(" AND "); sb.append(txsAlias); sb.append(".branch_id = "); sb.append(artJoinAlias); - sb.append(".branch_id"); + sb.append(".id1"); return sb.toString(); } @@ -134,7 +134,7 @@ public class LoadSqlWriter extends AbstractSqlWriter { sb.append(txsAlias); sb.append(".transaction_id <= "); sb.append(artJoinAlias); - sb.append(".transaction_id"); + sb.append(".id3"); if (!areDeletedIncluded) { sb.append(" AND "); sb.append(txsAlias); diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/SqlObjectLoader.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/SqlObjectLoader.java index 2c6fbfedbed..610c5d8b11b 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/SqlObjectLoader.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/SqlObjectLoader.java @@ -49,7 +49,7 @@ import org.eclipse.osee.orcs.db.internal.sql.SqlContext; import org.eclipse.osee.orcs.db.internal.sql.SqlHandler; import org.eclipse.osee.orcs.db.internal.sql.SqlHandlerFactory; import org.eclipse.osee.orcs.db.internal.sql.join.AbstractJoinQuery; -import org.eclipse.osee.orcs.db.internal.sql.join.ArtifactJoinQuery; +import org.eclipse.osee.orcs.db.internal.sql.join.Id4JoinQuery; import org.eclipse.osee.orcs.db.internal.sql.join.SqlJoinFactory; /** @@ -113,7 +113,7 @@ public class SqlObjectLoader { writer.build(handler); } - public void loadArtifacts(HasCancellation cancellation, LoadDataHandler handler, ArtifactJoinQuery join, CriteriaOrcsLoad criteria, LoadSqlContext loadContext, int fetchSize) throws OseeCoreException { + public void loadArtifacts(HasCancellation cancellation, LoadDataHandler handler, Id4JoinQuery join, CriteriaOrcsLoad criteria, LoadSqlContext loadContext, int fetchSize) throws OseeCoreException { logger.trace("Sql Artifact Load - artifactJoinQuery[%s] loadSqlContext[%s]", join, loadContext); if (!join.isEmpty()) { try { diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/ArtifactQueryContextLoadExecutor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/ArtifactQueryContextLoadExecutor.java index caba8a6259d..d19ad712928 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/ArtifactQueryContextLoadExecutor.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/ArtifactQueryContextLoadExecutor.java @@ -13,6 +13,7 @@ package org.eclipse.osee.orcs.db.internal.loader.executors; import java.util.List; import java.util.function.Consumer; import org.eclipse.osee.executor.admin.HasCancellation; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.RelationalConstants; import org.eclipse.osee.framework.core.data.TransactionId; @@ -29,7 +30,7 @@ import org.eclipse.osee.orcs.db.internal.loader.criteria.CriteriaOrcsLoad; import org.eclipse.osee.orcs.db.internal.search.engines.ArtifactQuerySqlContext; import org.eclipse.osee.orcs.db.internal.sql.SqlContext; import org.eclipse.osee.orcs.db.internal.sql.join.AbstractJoinQuery; -import org.eclipse.osee.orcs.db.internal.sql.join.ArtifactJoinQuery; +import org.eclipse.osee.orcs.db.internal.sql.join.Id4JoinQuery; import org.eclipse.osee.orcs.db.internal.sql.join.SqlJoinFactory; /** @@ -50,7 +51,7 @@ public class ArtifactQueryContextLoadExecutor extends AbstractLoadExecutor { public void load(HasCancellation cancellation, LoadDataHandler handler, CriteriaOrcsLoad criteria, Options options) throws OseeCoreException { int fetchSize = computeFetchSize(queryContext); - ArtifactJoinQuery join = createArtifactIdJoin(getJdbcClient(), cancellation, fetchSize); + Id4JoinQuery join = createId4Join(getJdbcClient(), cancellation, fetchSize); LoadSqlContext loadContext = new LoadSqlContext(queryContext.getSession(), options, queryContext.getBranch()); getLoader().loadArtifacts(cancellation, handler, join, criteria, loadContext, fetchSize); @@ -64,8 +65,8 @@ public class ArtifactQueryContextLoadExecutor extends AbstractLoadExecutor { return LoadUtil.computeFetchSize(fetchSize); } - private ArtifactJoinQuery createArtifactIdJoin(JdbcClient jdbcClient, HasCancellation cancellation, int fetchSize) throws OseeCoreException { - ArtifactJoinQuery artifactJoin = joinFactory.createArtifactJoinQuery(); + private Id4JoinQuery createId4Join(JdbcClient jdbcClient, HasCancellation cancellation, int fetchSize) throws OseeCoreException { + Id4JoinQuery artifactJoin = joinFactory.createId4JoinQuery(); try { for (AbstractJoinQuery join : queryContext.getJoins()) { join.store(); @@ -76,7 +77,7 @@ public class ArtifactQueryContextLoadExecutor extends AbstractLoadExecutor { checkCancelled(cancellation); Integer artId = stmt.getInt("art_id"); BranchId branchUuid = BranchId.valueOf(stmt.getLong("branch_id")); - artifactJoin.add(artId, branchUuid, transactionId); + artifactJoin.add(branchUuid, ArtifactId.valueOf(artId), transactionId); checkCancelled(cancellation); }; checkCancelled(cancellation); diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/LoadExecutor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/LoadExecutor.java index 389204c6b37..f069f554b65 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/LoadExecutor.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/LoadExecutor.java @@ -12,6 +12,7 @@ package org.eclipse.osee.orcs.db.internal.loader.executors; import java.util.Collection; import org.eclipse.osee.executor.admin.HasCancellation; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.TransactionId; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; @@ -24,7 +25,7 @@ import org.eclipse.osee.orcs.db.internal.loader.LoadSqlContext; import org.eclipse.osee.orcs.db.internal.loader.LoadUtil; import org.eclipse.osee.orcs.db.internal.loader.SqlObjectLoader; import org.eclipse.osee.orcs.db.internal.loader.criteria.CriteriaOrcsLoad; -import org.eclipse.osee.orcs.db.internal.sql.join.ArtifactJoinQuery; +import org.eclipse.osee.orcs.db.internal.sql.join.Id4JoinQuery; import org.eclipse.osee.orcs.db.internal.sql.join.SqlJoinFactory; /** @@ -49,10 +50,10 @@ public class LoadExecutor extends AbstractLoadExecutor { public void load(HasCancellation cancellation, LoadDataHandler handler, CriteriaOrcsLoad criteria, Options options) throws OseeCoreException { checkCancelled(cancellation); - ArtifactJoinQuery join = joinFactory.createArtifactJoinQuery(); + Id4JoinQuery join = joinFactory.createId4JoinQuery(); TransactionId transactionId = OptionsUtil.getFromTransaction(options); for (Integer artId : artifactIds) { - join.add(artId, BranchId.valueOf(branch.getId()), transactionId); + join.add(branch, ArtifactId.valueOf(artId), transactionId); } LoadSqlContext loadContext = new LoadSqlContext(session, options, branch); diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/UuidsLoadExecutor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/UuidsLoadExecutor.java index e9a1fec4fff..830626f4f9e 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/UuidsLoadExecutor.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/UuidsLoadExecutor.java @@ -12,6 +12,7 @@ package org.eclipse.osee.orcs.db.internal.loader.executors; import java.util.Collection; import org.eclipse.osee.executor.admin.HasCancellation; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.TransactionId; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; @@ -24,8 +25,8 @@ import org.eclipse.osee.orcs.db.internal.loader.LoadSqlContext; import org.eclipse.osee.orcs.db.internal.loader.LoadUtil; import org.eclipse.osee.orcs.db.internal.loader.SqlObjectLoader; import org.eclipse.osee.orcs.db.internal.loader.criteria.CriteriaOrcsLoad; -import org.eclipse.osee.orcs.db.internal.sql.join.ArtifactJoinQuery; import org.eclipse.osee.orcs.db.internal.sql.join.CharJoinQuery; +import org.eclipse.osee.orcs.db.internal.sql.join.Id4JoinQuery; import org.eclipse.osee.orcs.db.internal.sql.join.SqlJoinFactory; /** @@ -53,16 +54,16 @@ public class UuidsLoadExecutor extends AbstractLoadExecutor { public void load(HasCancellation cancellation, LoadDataHandler handler, CriteriaOrcsLoad criteria, Options options) throws OseeCoreException { checkCancelled(cancellation); if (!artifactIds.isEmpty()) { - ArtifactJoinQuery join = createIdJoin(getJdbcClient(), options); + Id4JoinQuery join = createIdJoin(getJdbcClient(), options); LoadSqlContext loadContext = new LoadSqlContext(session, options, branch); int fetchSize = LoadUtil.computeFetchSize(artifactIds.size()); getLoader().loadArtifacts(cancellation, handler, join, criteria, loadContext, fetchSize); } } - private ArtifactJoinQuery createIdJoin(JdbcClient jdbcClient, Options options) throws OseeCoreException { + private Id4JoinQuery createIdJoin(JdbcClient jdbcClient, Options options) throws OseeCoreException { - ArtifactJoinQuery toReturn = joinFactory.createArtifactJoinQuery(); + Id4JoinQuery toReturn = joinFactory.createId4JoinQuery(); CharJoinQuery guidJoin = joinFactory.createCharJoinQuery(); try { @@ -75,7 +76,7 @@ public class UuidsLoadExecutor extends AbstractLoadExecutor { getJdbcClient().runQuery(stmt -> { Integer artId = stmt.getInt("art_id"); - toReturn.add(artId, BranchId.valueOf(branch.getId()), transactionId); + toReturn.add(branch, ArtifactId.valueOf(artId), transactionId); }, artifactIds.size(), GUIDS_TO_IDS, guidJoin.getQueryId()); } finally { diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/handlers/ArtifactSqlHandler.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/handlers/ArtifactSqlHandler.java index 93222f8a856..1a7ba7e70be 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/handlers/ArtifactSqlHandler.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/handlers/ArtifactSqlHandler.java @@ -43,7 +43,7 @@ public class ArtifactSqlHandler extends SqlHandler { @Override public void addTables(AbstractSqlWriter writer) { - jArtAlias = writer.addTable(TableEnum.ARTIFACT_JOIN_TABLE); + jArtAlias = writer.addTable(TableEnum.JOIN_ID4_TABLE); artAlias = writer.addTable(TableEnum.ARTIFACT_TABLE); txsAlias = writer.addTable(TableEnum.TXS_TABLE); } @@ -53,7 +53,7 @@ public class ArtifactSqlHandler extends SqlHandler { writer.write(artAlias); writer.write(".art_id = "); writer.write(jArtAlias); - writer.write(".art_id AND "); + writer.write(".id2 AND "); writer.write(jArtAlias); writer.write(".query_id = ?"); writer.addParameter(criteria.getQueryId()); diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/handlers/AttributeSqlHandler.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/handlers/AttributeSqlHandler.java index 13c23e92677..2b67ed472c8 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/handlers/AttributeSqlHandler.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/handlers/AttributeSqlHandler.java @@ -51,7 +51,7 @@ public class AttributeSqlHandler extends SqlHandler { @Override public void addTables(AbstractSqlWriter writer) throws OseeCoreException { - jArtAlias = writer.addTable(TableEnum.ARTIFACT_JOIN_TABLE); + jArtAlias = writer.addTable(TableEnum.JOIN_ID4_TABLE); if (criteria.getIds().size() > 1) { jIdAlias = writer.addTable(TableEnum.ID_JOIN_TABLE); @@ -70,7 +70,7 @@ public class AttributeSqlHandler extends SqlHandler { writer.write(attrAlias); writer.write(".art_id = "); writer.write(jArtAlias); - writer.write(".art_id AND "); + writer.write(".id2 AND "); writer.write(jArtAlias); writer.write(".query_id = ?"); writer.addParameter(criteria.getQueryId()); diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/handlers/RelationSqlHandler.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/handlers/RelationSqlHandler.java index 32f461bd081..6cbd74a4c15 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/handlers/RelationSqlHandler.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/handlers/RelationSqlHandler.java @@ -53,7 +53,7 @@ public class RelationSqlHandler extends SqlHandler { @Override public void addTables(AbstractSqlWriter writer) throws OseeCoreException { - jArtAlias = writer.addTable(TableEnum.ARTIFACT_JOIN_TABLE); + jArtAlias = writer.addTable(TableEnum.JOIN_ID4_TABLE); if (criteria.getIds().size() > 1) { jIdAlias = writer.addTable(TableEnum.ID_JOIN_TABLE); @@ -78,7 +78,7 @@ public class RelationSqlHandler extends SqlHandler { @Override public boolean addPredicates(AbstractSqlWriter writer) throws OseeCoreException { - writer.write("(%s.a_art_id = %s.art_id OR %s.b_art_id = %s.art_id)", relationAlias, jArtAlias, relationAlias, + writer.write("(%s.a_art_id = %s.id2 OR %s.b_art_id = %s.id2)", relationAlias, jArtAlias, relationAlias, jArtAlias); writer.write(" AND "); writer.write(jArtAlias); diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/ArtifactLoadProcessor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/ArtifactLoadProcessor.java index b532832cffc..506692ea94c 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/ArtifactLoadProcessor.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/ArtifactLoadProcessor.java @@ -35,7 +35,7 @@ public class ArtifactLoadProcessor extends LoadProcessor maxJoinSize) { - throw new OseeDataStoreException("Exceeded max artifact join size of [%d]", maxJoinSize); - } - } -} \ 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 664c670593d..539ad4d6c04 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 @@ -25,8 +25,8 @@ 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_ID4 = + "INSERT INTO osee_join_id4 (query_id, id1, id2, id3, id4) VALUES (?, ?, ?, ?, ?)"; private static final String INSERT_INTO_JOIN_TRANSACTION = "INSERT INTO osee_join_transaction (query_id, gamma_id, transaction_id, branch_id) VALUES (?, ?, ?, ?)"; @@ -43,10 +43,10 @@ public class DatabaseJoinAccessor implements IJoinAccessor { 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_TAG_GAMMA_QUEUE = "DELETE FROM osee_tag_gamma_queue WHERE query_id = ?"; private static final String DELETE_FROM_JOIN_EXPORT_IMPORT = "DELETE FROM osee_join_export_import WHERE query_id =?"; private static final String DELETE_FROM_JOIN_CHAR_ID = "DELETE FROM osee_join_char_id WHERE query_id =?"; + private static final String DELETE_FROM_JOIN_ID4 = "DELETE FROM osee_join_id4 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 (?,?,?,?)"; @@ -55,7 +55,7 @@ public class DatabaseJoinAccessor implements IJoinAccessor { 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), + ID4("osee_join_id4", INSERT_INTO_JOIN_ID4, DELETE_FROM_JOIN_ID4), TAG_GAMMA_QUEUE("osee_tag_gamma_queue", INSERT_INTO_TAG_GAMMA_QUEUE, DELETE_FROM_TAG_GAMMA_QUEUE), EXPORT_IMPORT("osee_join_export_import", INSERT_INTO_JOIN_EXPORT_IMPORT, DELETE_FROM_JOIN_EXPORT_IMPORT), ID("osee_join_id", INSERT_INTO_JOIN_ID, DELETE_FROM_JOIN_ID), diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/Id4JoinQuery.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/Id4JoinQuery.java new file mode 100644 index 00000000000..665b73f6fc0 --- /dev/null +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/Id4JoinQuery.java @@ -0,0 +1,128 @@ +/******************************************************************************* + * Copyright (c) 2017 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.orcs.db.internal.sql.join; + +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.TransactionId; +import org.eclipse.osee.framework.core.exception.OseeDataStoreException; +import org.eclipse.osee.framework.jdk.core.type.Id; +import org.eclipse.osee.orcs.db.internal.sql.join.DatabaseJoinAccessor.JoinItem; + +/** + * @author Morgan E. Cook + */ +public class Id4JoinQuery extends AbstractJoinQuery { + + private final int maxJoinSize; + + private final class Entry implements IJoinRow { + private final Id id_1; + private final Id id_2; + private final Id id_3; + private final Id id_4; + + private Entry(Id id_1, Id id_2, Id id_3, Id id_4) { + this.id_1 = id_1; + this.id_2 = id_2; + this.id_3 = id_3; + this.id_4 = id_4; + } + + @Override + public Object[] toArray() { + return new Object[] {getQueryId(), id_1, id_2, id_3, id_4}; + } + + @Override + public String toString() { + return String.format("id_1=%s, id_2=%s, id_3=%s, id_4=%s", id_1, id_2, id_3, id_4); + } + + @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 (id_1 == null) { + if (other.id_1 != null) { + return false; + } + } else if (!id_1.equals(other.id_1)) { + return false; + } + if (id_2 == null) { + if (other.id_2 != null) { + return false; + } + } else if (!id_2.equals(other.id_2)) { + return false; + } + if (id_3 == null) { + if (other.id_3 != null) { + return false; + } + } else if (!id_3.equals(other.id_3)) { + return false; + } + if (!id_4.equals(other.id_4)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + getOuterType().hashCode(); + result = prime * result + (id_1 == null ? 0 : id_1.hashCode()); + result = prime * result + (id_2 == null ? 0 : id_2.hashCode()); + result = prime * result + (id_3 == null ? 0 : id_3.hashCode()); + result = prime * result + (id_4 == null ? 0 : id_4.hashCode()); + return result; + } + + private Id4JoinQuery getOuterType() { + return Id4JoinQuery.this; + } + } + + public Id4JoinQuery(IJoinAccessor joinAccessor, Long expiresIn, int queryId, int maxJoinSize) { + super(joinAccessor, JoinItem.ID4, expiresIn, queryId); + this.maxJoinSize = maxJoinSize; + } + + public void add(Id id_1, Id id_2, Id id_3, Id id_4) { + entries.add(new Entry(id_1, id_2, id_3, id_4)); + if (entries.size() > maxJoinSize) { + throw new OseeDataStoreException("Exceeded max artifact join size of [%d]", maxJoinSize); + } + } + + public void add(Id id_1, Id id_2, Id id_3) { + add(id_1, id_2, id_3, ArtifactId.SENTINEL); + + } + + public void add(Id id_1, Id id_2) { + add(id_1, id_2, TransactionId.SENTINEL, ArtifactId.SENTINEL); + } +} diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/SqlJoinFactory.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/SqlJoinFactory.java index 90949f5e961..6d0e5cd3280 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/SqlJoinFactory.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/SqlJoinFactory.java @@ -105,13 +105,13 @@ public class SqlJoinFactory { return new IdJoinQuery(getAccessor(), actualExpiration, getNewQueryId()); } - public ArtifactJoinQuery createArtifactJoinQuery() { - return createArtifactJoinQuery(null); + public Id4JoinQuery createId4JoinQuery() { + return createId4JoinQuery(null); } - public ArtifactJoinQuery createArtifactJoinQuery(Long expiresIn) { - Long actualExpiration = getExpiresIn(expiresIn, EXPIRATION_SECS__ARTIFACT_JOIN_QUERY); - return new ArtifactJoinQuery(getAccessor(), actualExpiration, getNewQueryId(), getMaxArtifactJoinSize()); + public Id4JoinQuery createId4JoinQuery(Long expiresIn) { + Long actualExpiration = getExpiresIn(expiresIn, EXPIRATION_SECS__ID_JOIN_QUERY); + return new Id4JoinQuery(getAccessor(), actualExpiration, getNewQueryId(), getMaxArtifactJoinSize()); } public TagQueueJoinQuery createTagQueueJoinQuery() { diff --git a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsScriptTest.java b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsScriptTest.java index 2b080fa0b05..03596ae1138 100644 --- a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsScriptTest.java +++ b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsScriptTest.java @@ -109,9 +109,9 @@ public class OrcsScriptTest { " }, {\n" + // " 'name' : 'Common'\n" + // " }, {\n" + // - " 'name' : 'ATS6 - SAW (uncommitted) More Reqt Changes for...'\n" + // - " }, {\n" + // " 'name' : 'ATS20 - SAW (uncommitted-conflicted) More Requi...'\n" + // + " }, {\n" + // + " 'name' : 'ATS6 - SAW (uncommitted) More Reqt Changes for...'\n" + // " } ]\n" + // " } ]\n" + // "}"); @@ -171,14 +171,14 @@ public class OrcsScriptTest { " }\n" + // " }\n" + // " }, {\n" + // - " 'id' : 407107128,\n" + // + " 'id' : 940417612,\n" + // " 'attributes' : {\n" + // " 'Name' : {\n" + // " 'value' : 'Feature Groups'\n" + // " }\n" + // " }\n " + // " }, {\n" + // - " 'id' : 1691279068,\n" + // + " 'id' : 1930169170,\n" + // " 'attributes' : {\n" + // " 'Name' : {\n" + // " 'value' : 'Sprints'\n" + // diff --git a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsTxQueryTest.java b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsTxQueryTest.java index c129ca94f7a..08ad8be62fd 100644 --- a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsTxQueryTest.java +++ b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsTxQueryTest.java @@ -26,7 +26,6 @@ import java.sql.Timestamp; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Arrays; import java.util.Iterator; import java.util.List; import org.eclipse.osee.framework.core.data.ArtifactId; @@ -69,9 +68,9 @@ public class OrcsTxQueryTest { private final static DateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); private QueryFactory factory; private final ArtifactId JoeSmith = ArtifactId.valueOf(61106791); - private final Long CommonBranchHeadTransaction = 123L; + private final Long CommonBranchHeadTransaction = 178L; private final String CommonBranchTransComment = "Cleanup PopulateDemoActionsTest"; - private final int NumberCommonTransactions = 77; + private final int NumberCommonTransactions = 132; @Before public void setup() { @@ -86,7 +85,7 @@ public class OrcsTxQueryTest { assertEquals(CommonBranchHeadTransaction, Long.valueOf(results.size())); List transactions = results.getList(); - assertTx(transactions, Long.valueOf(4), Baselined, "Branch Creation for Common", COMMON, OseeSystem); + assertTx(transactions, Long.valueOf(4), Baselined, "New Branch from System Root Branch (3)", COMMON, OseeSystem); assertTx(transactions, Long.valueOf(5), NonBaselined, "Add Types to Common Branch", COMMON, OseeSystem); } @@ -110,24 +109,22 @@ public class OrcsTxQueryTest { @Test public void testGetByCommentEquals() throws OseeCoreException { TransactionQuery query = factory.transactionQuery(); - query.andCommentEquals("Branch Creation for SAW_Bld_1"); + query.andCommentEquals("New Branch from System Root Branch (3)"); - TransactionReadable actual = query.getResults().getExactlyOne(); + List actual = query.getResults().getList(); - assertEquals(1, query.getCount()); - assertTx(Arrays.asList(actual), Long.valueOf(30), Baselined, "Branch Creation for SAW_Bld_1", SAW_Bld_1, - OseeSystem); - assertEquals(Long.valueOf(30), query.getResultsAsIds().getExactlyOne()); + assertEquals(3, query.getCount()); + assertTx(actual, Long.valueOf(30), Baselined, "New Branch from System Root Branch (3)", SAW_Bld_1, OseeSystem); } @Test public void testGetByCommentPatternEquals() throws OseeCoreException { TransactionQuery query = factory.transactionQuery(); - query.andCommentPattern("Branch Creation for.*"); + query.andCommentPattern("New Branch from.*"); ResultSet results = query.getResults(); - assertEquals(4, results.size()); - assertEquals(4, query.getCount()); + assertEquals(7, results.size()); + assertEquals(7, query.getCount()); } @@ -144,13 +141,13 @@ public class OrcsTxQueryTest { List transactions = results.getList(); assertTx(transactions, Long.valueOf(1), Baselined, "System Root Branch Creation", SYSTEM_ROOT, ArtifactId.valueOf(OseeSystem.getId())); - assertTx(transactions, Long.valueOf(4), Baselined, "Branch Creation for Common", COMMON, + assertTx(transactions, Long.valueOf(4), Baselined, "New Branch from System Root Branch (3)", COMMON, ArtifactId.valueOf(OseeSystem.getId())); - assertTx(transactions, Long.valueOf(30), Baselined, "Branch Creation for SAW_Bld_1", SAW_Bld_1, + assertTx(transactions, Long.valueOf(30), Baselined, "New Branch from System Root Branch (3)", SAW_Bld_1, ArtifactId.valueOf(OseeSystem.getId())); - assertTx(transactions, Long.valueOf(33), Baselined, "Branch Creation for CIS_Bld_1", CIS_Bld_1, + assertTx(transactions, Long.valueOf(33), Baselined, "New Branch from System Root Branch (3)", CIS_Bld_1, ArtifactId.valueOf(OseeSystem.getId())); - assertTx(transactions, Long.valueOf(71), Baselined, "Branch Creation for SAW_Bld_2", SAW_Bld_2, JoeSmith); + assertTx(transactions, Long.valueOf(73), Baselined, "New Branch from SAW_Bld_1 (72)", SAW_Bld_2, JoeSmith); } @Test @@ -163,9 +160,9 @@ public class OrcsTxQueryTest { assertEquals(4, query.getCount()); List transactions = results.getList(); - assertTx(transactions, Long.valueOf(33), Baselined, "Branch Creation for CIS_Bld_1", CIS_Bld_1, + assertTx(transactions, Long.valueOf(33), Baselined, "New Branch from System Root Branch (3)", CIS_Bld_1, ArtifactId.valueOf(OseeSystem.getId())); - assertTx(transactions, Long.valueOf(71), Baselined, "Branch Creation for SAW_Bld_2", SAW_Bld_2, JoeSmith); + assertTx(transactions, Long.valueOf(73), Baselined, "New Branch from SAW_Bld_1 (72)", SAW_Bld_2, JoeSmith); } @Test @@ -179,15 +176,16 @@ public class OrcsTxQueryTest { List transactions = results.getList(); //@formatter:off - assertTx(transactions, Long.valueOf(30), Baselined, "Branch Creation for SAW_Bld_1", SAW_Bld_1, ArtifactId.valueOf(OseeSystem.getId())); + assertTx(transactions, Long.valueOf(30), Baselined, "New Branch from System Root Branch (3)", SAW_Bld_1, ArtifactId.valueOf(OseeSystem.getId())); assertTx(transactions, Long.valueOf(31), NonBaselined, "DemoDatabaseConfig", SAW_Bld_1, ArtifactId.valueOf(OseeSystem.getId())); assertTx(transactions, Long.valueOf(32), NonBaselined, "Create Demo Applicability", SAW_Bld_1, ArtifactId.valueOf(OseeSystem.getId())); - assertTx(transactions, Long.valueOf(33), Baselined, "Branch Creation for CIS_Bld_1", CIS_Bld_1, ArtifactId.valueOf(OseeSystem.getId())); + assertTx(transactions, Long.valueOf(33), Baselined, "New Branch from System Root Branch (3)", CIS_Bld_1, ArtifactId.valueOf(OseeSystem.getId())); assertTx(transactions, Long.valueOf(34), NonBaselined, "DemoDatabaseConfig", CIS_Bld_1,ArtifactId.valueOf(OseeSystem.getId())); - assertTx(transactions, Long.valueOf(67), NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", SAW_Bld_1, JoeSmith); - assertTx(transactions, Long.valueOf(68), NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", SAW_Bld_1, JoeSmith); + assertTx(transactions, Long.valueOf(69), NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", SAW_Bld_1, JoeSmith); - assertTx(transactions, Long.valueOf(70), NonBaselined, "Populate Demo DB - Create Traceability", SAW_Bld_1, JoeSmith); + assertTx(transactions, Long.valueOf(70), NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", SAW_Bld_1, JoeSmith); + assertTx(transactions, Long.valueOf(71), NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", SAW_Bld_1, JoeSmith); + assertTx(transactions, Long.valueOf(72), NonBaselined, "Populate Demo DB - Create Traceability", SAW_Bld_1, JoeSmith); //@formatter:on } @@ -322,22 +320,23 @@ public class OrcsTxQueryTest { TransactionQuery query = factory.transactionQuery(); query.andAuthorLocalIds(OseeSystem); ResultSet results = query.getResults(); - assertEquals(77, results.size()); - assertEquals(77, query.getCount()); + assertEquals(128, results.size()); + assertEquals(128, query.getCount()); List transactions = results.getList(); - assertTx(transactions, Long.valueOf(33), Baselined, "Branch Creation for CIS_Bld_1", CIS_Bld_1, OseeSystem); + assertTx(transactions, Long.valueOf(33), Baselined, "New Branch from System Root Branch (3)", CIS_Bld_1, + OseeSystem); query = factory.transactionQuery(); query.andAuthorLocalIds(OseeSystem, JoeSmith); results = query.getResults(); - assertEquals(123, results.size()); - assertEquals(123, query.getCount()); + assertEquals(178, results.size()); + assertEquals(178, query.getCount()); transactions = results.getList(); //@formatter:off - assertTx(transactions, Long.valueOf(33), Baselined, "Branch Creation for CIS_Bld_1", CIS_Bld_1, ArtifactId.valueOf(OseeSystem.getId())); - assertTx(transactions, Long.valueOf(67), NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", SAW_Bld_1, JoeSmith); + assertTx(transactions, Long.valueOf(33), Baselined, "New Branch from System Root Branch (3)", CIS_Bld_1, ArtifactId.valueOf(OseeSystem.getId())); + assertTx(transactions, Long.valueOf(69), NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", SAW_Bld_1, JoeSmith); assertTx(transactions, CommonBranchHeadTransaction, NonBaselined, CommonBranchTransComment, COMMON, JoeSmith); //@formatter:on @@ -347,13 +346,13 @@ public class OrcsTxQueryTest { list.add(JoeSmith); query.andAuthorLocalIds(list); results = query.getResults(); - assertEquals(123, results.size()); - assertEquals(123, query.getCount()); + assertEquals(178, results.size()); + assertEquals(178, query.getCount()); transactions = results.getList(); //@formatter:off - assertTx(transactions, Long.valueOf(33), Baselined, "Branch Creation for CIS_Bld_1", CIS_Bld_1, ArtifactId.valueOf(OseeSystem.getId())); - assertTx(transactions, Long.valueOf(67), NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", SAW_Bld_1, JoeSmith); + assertTx(transactions, Long.valueOf(33), Baselined, "New Branch from System Root Branch (3)", CIS_Bld_1, ArtifactId.valueOf(OseeSystem.getId())); + assertTx(transactions, Long.valueOf(69), NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", SAW_Bld_1, JoeSmith); assertTx(transactions, CommonBranchHeadTransaction, NonBaselined, CommonBranchTransComment, COMMON, JoeSmith); //@formatter:on @@ -364,7 +363,7 @@ public class OrcsTxQueryTest { TransactionQuery query = factory.transactionQuery(); query.andNullCommitId(); ResultSet results = query.getResults(); - assertEquals(122, query.getCount()); + assertEquals(177, query.getCount()); List transactions = results.getList(); assertTxExists(transactions, Long.valueOf(1)); @@ -435,14 +434,14 @@ public class OrcsTxQueryTest { TransactionQuery query = factory.transactionQuery(); query.andAuthorLocalIds(joeArt); - assertEquals(46, query.getCount()); + assertEquals(50, query.getCount()); /********************************************************** * Only valid user is 17. Verify the multiple entry by entering the same user twice */ query = factory.transactionQuery(); query.andAuthorLocalIds(joeArt, joeArt); - assertEquals(46, query.getCount()); + assertEquals(50, query.getCount()); } @@ -451,13 +450,13 @@ public class OrcsTxQueryTest { TransactionQuery query = factory.transactionQuery(); query.andAuthorLocalIds(OseeSystem); query.andIs(Baselined); - query.andCommentPattern("Branch Creation for.*"); + query.andCommentPattern("New Branch from.*"); ResultSet results = query.getResults(); assertEquals(3, results.size()); assertEquals(3, query.getCount()); for (TransactionReadable trans : query.getResults()) { - assertTrue(trans.getComment().startsWith("Branch Creation for")); + assertTrue(trans.getComment().startsWith("New Branch from")); } } diff --git a/plugins/org.eclipse.osee.x.server.p2/demo/binary_data.zip b/plugins/org.eclipse.osee.x.server.p2/demo/binary_data.zip index 168a4182410..75319e97477 100644 Binary files a/plugins/org.eclipse.osee.x.server.p2/demo/binary_data.zip and b/plugins/org.eclipse.osee.x.server.p2/demo/binary_data.zip differ diff --git a/plugins/org.eclipse.osee.x.server.p2/demo/hsql.zip b/plugins/org.eclipse.osee.x.server.p2/demo/hsql.zip index 5c7cb6d818a..1707c87e1ba 100644 Binary files a/plugins/org.eclipse.osee.x.server.p2/demo/hsql.zip and b/plugins/org.eclipse.osee.x.server.p2/demo/hsql.zip differ -- cgit v1.2.3