diff options
Diffstat (limited to 'plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee')
19 files changed, 193 insertions, 66 deletions
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 7fbcb4bf127..f0cc702ff36 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 @@ -21,7 +21,6 @@ import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.locks.ReentrantLock; import java.util.logging.Level; -import org.eclipse.osee.framework.core.client.ClientSessionManager; import org.eclipse.osee.framework.core.data.IArtifactType; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.enums.DeletionFlag; @@ -32,13 +31,14 @@ import org.eclipse.osee.framework.core.model.Branch; import org.eclipse.osee.framework.core.model.TransactionRecord; import org.eclipse.osee.framework.database.core.ConnectionHandler; import org.eclipse.osee.framework.database.core.IOseeStatement; -import org.eclipse.osee.framework.database.core.OseeSql; import org.eclipse.osee.framework.jdk.core.type.CompositeKeyHashMap; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.type.Pair; import org.eclipse.osee.framework.jdk.core.util.Lib; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.internal.Activator; +import org.eclipse.osee.framework.skynet.core.internal.OseeSql; +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.JoinUtility; @@ -199,7 +199,7 @@ public final class ArtifactLoader { String sql = null; try { - sql = ClientSessionManager.getSql(sqlKey); + sql = ServiceUtil.getSql(sqlKey); chStmt.runPreparedQuery(fetchSize, sql, queryId); int previousArtId = -1; diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactTransactionData.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactTransactionData.java index d81c4c5a999..b29340ccf90 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactTransactionData.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactTransactionData.java @@ -12,11 +12,11 @@ package org.eclipse.osee.framework.skynet.core.artifact; import org.eclipse.osee.framework.core.model.TransactionRecord; import org.eclipse.osee.framework.database.core.ConnectionHandler; -import org.eclipse.osee.framework.database.core.OseeSql; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.skynet.core.event.model.ArtifactEvent; import org.eclipse.osee.framework.skynet.core.event.model.EventBasicGuidArtifact; import org.eclipse.osee.framework.skynet.core.event.model.EventModType; +import org.eclipse.osee.framework.skynet.core.internal.OseeSql; import org.eclipse.osee.framework.skynet.core.transaction.BaseTransactionData; /** 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 56f418ed080..64c04ff1835 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 @@ -16,14 +16,12 @@ import static org.eclipse.osee.framework.core.enums.LoadLevel.RELATION_DATA; import java.util.ArrayList; import java.util.List; import java.util.logging.Level; -import org.eclipse.osee.framework.core.client.ClientSessionManager; import org.eclipse.osee.framework.core.data.IAttributeType; import org.eclipse.osee.framework.core.enums.DeletionFlag; import org.eclipse.osee.framework.core.enums.LoadLevel; import org.eclipse.osee.framework.core.enums.ModificationType; import org.eclipse.osee.framework.database.core.ConnectionHandler; import org.eclipse.osee.framework.database.core.IOseeStatement; -import org.eclipse.osee.framework.database.core.OseeSql; import org.eclipse.osee.framework.jdk.core.type.CompositeKeyHashMap; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.Strings; @@ -31,6 +29,8 @@ import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.attribute.AttributeTypeManager; import org.eclipse.osee.framework.skynet.core.attribute.BooleanAttribute; import org.eclipse.osee.framework.skynet.core.attribute.EnumeratedAttribute; +import org.eclipse.osee.framework.skynet.core.internal.OseeSql; +import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil; /** * @author Ryan Schmitt @@ -158,8 +158,8 @@ public class AttributeLoader { Level.WARNING, "multiple attribute version for attribute id [%d] artifact id[%d] branch[%d] previousGammaId[%s] currentGammaId[%s] previousModType[%s] currentModType[%s]", - current.attrId, current.artifactId, current.branchUuid, previous.gammaId, current.gammaId, previous.modType, - current.modType); + current.attrId, current.artifactId, current.branchUuid, previous.gammaId, current.gammaId, + previous.modType, current.modType); } } @@ -198,6 +198,6 @@ public class AttributeLoader { sqlKey = OseeSql.LOAD_CURRENT_ATTRIBUTES; } - return ClientSessionManager.getSql(sqlKey); + return ServiceUtil.getSql(sqlKey); } }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/RelationLoader.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/RelationLoader.java index f1ad02e2359..2e2cbb88985 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/RelationLoader.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/RelationLoader.java @@ -13,15 +13,15 @@ package org.eclipse.osee.framework.skynet.core.artifact; import static org.eclipse.osee.framework.core.enums.LoadLevel.ARTIFACT_AND_ATTRIBUTE_DATA; import static org.eclipse.osee.framework.core.enums.LoadLevel.ARTIFACT_DATA; import java.util.Collection; -import org.eclipse.osee.framework.core.client.ClientSessionManager; import org.eclipse.osee.framework.core.enums.LoadLevel; import org.eclipse.osee.framework.core.enums.ModificationType; import org.eclipse.osee.framework.core.model.Branch; import org.eclipse.osee.framework.core.model.type.RelationType; import org.eclipse.osee.framework.database.core.ConnectionHandler; import org.eclipse.osee.framework.database.core.IOseeStatement; -import org.eclipse.osee.framework.database.core.OseeSql; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; +import org.eclipse.osee.framework.skynet.core.internal.OseeSql; +import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil; import org.eclipse.osee.framework.skynet.core.relation.RelationManager; import org.eclipse.osee.framework.skynet.core.relation.RelationTypeManager; @@ -41,7 +41,7 @@ class RelationLoader { IOseeStatement chStmt = ConnectionHandler.getStatement(); try { - String sqlQuery = ClientSessionManager.getSql(OseeSql.LOAD_RELATIONS); + String sqlQuery = ServiceUtil.getSql(OseeSql.LOAD_RELATIONS); chStmt.runPreparedQuery(artifacts.size() * 8, sqlQuery, joinQueryId); while (chStmt.next()) { int relationId = chStmt.getInt("rel_link_id"); 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 069768243ef..6acf4e001c1 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 @@ -15,7 +15,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import org.eclipse.core.runtime.Platform; -import org.eclipse.osee.framework.core.client.ClientSessionManager; import org.eclipse.osee.framework.core.enums.ModificationType; import org.eclipse.osee.framework.core.enums.TxChange; import org.eclipse.osee.framework.core.model.Branch; @@ -23,11 +22,12 @@ import org.eclipse.osee.framework.database.core.ConnectionHandler; import org.eclipse.osee.framework.database.core.DbTransaction; import org.eclipse.osee.framework.database.core.IOseeStatement; import org.eclipse.osee.framework.database.core.OseeConnection; -import org.eclipse.osee.framework.database.core.OseeSql; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.Collections; import org.eclipse.osee.framework.jdk.core.util.Lib; import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery; +import org.eclipse.osee.framework.skynet.core.internal.OseeSql; +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.JoinUtility; @@ -190,7 +190,7 @@ public class UpdateMergeBranch extends DbTransaction { IOseeStatement chStmt = ConnectionHandler.getStatement(); try { - chStmt.runPreparedQuery(ClientSessionManager.getSql(OseeSql.MERGE_GET_ARTIFACTS_FOR_BRANCH), branch.getUuid()); + chStmt.runPreparedQuery(ServiceUtil.getSql(OseeSql.MERGE_GET_ARTIFACTS_FOR_BRANCH), branch.getUuid()); while (chStmt.next()) { artSet.add(chStmt.getInt("art_id")); } @@ -200,7 +200,7 @@ public class UpdateMergeBranch extends DbTransaction { time = System.currentTimeMillis(); } - chStmt.runPreparedQuery(ClientSessionManager.getSql(OseeSql.MERGE_GET_ATTRIBUTES_FOR_BRANCH), branch.getUuid()); + chStmt.runPreparedQuery(ServiceUtil.getSql(OseeSql.MERGE_GET_ATTRIBUTES_FOR_BRANCH), branch.getUuid()); while (chStmt.next()) { artSet.add(chStmt.getInt("art_id")); } @@ -210,7 +210,7 @@ public class UpdateMergeBranch extends DbTransaction { time = System.currentTimeMillis(); } - chStmt.runPreparedQuery(ClientSessionManager.getSql(OseeSql.MERGE_GET_RELATIONS_FOR_BRANCH), branch.getUuid()); + chStmt.runPreparedQuery(ServiceUtil.getSql(OseeSql.MERGE_GET_RELATIONS_FOR_BRANCH), branch.getUuid()); while (chStmt.next()) { artSet.add(chStmt.getInt("a_art_id")); artSet.add(chStmt.getInt("b_art_id")); diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/AttributeTransactionData.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/AttributeTransactionData.java index d2e38c89b62..1a9bff00a0d 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/AttributeTransactionData.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/AttributeTransactionData.java @@ -14,12 +14,12 @@ import org.eclipse.osee.framework.core.exception.OseeExceptions; import org.eclipse.osee.framework.core.model.TransactionRecord; import org.eclipse.osee.framework.core.util.HttpProcessor; import org.eclipse.osee.framework.database.core.ConnectionHandler; -import org.eclipse.osee.framework.database.core.OseeSql; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.Strings; import org.eclipse.osee.framework.skynet.core.artifact.Attribute; import org.eclipse.osee.framework.skynet.core.attribute.utils.AttributeURL; import org.eclipse.osee.framework.skynet.core.event.model.ArtifactEvent; +import org.eclipse.osee.framework.skynet.core.internal.OseeSql; import org.eclipse.osee.framework.skynet.core.transaction.BaseTransactionData; /** diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/OseeSql.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/OseeSql.java new file mode 100644 index 00000000000..ff8612a37d1 --- /dev/null +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/OseeSql.java @@ -0,0 +1,117 @@ +/******************************************************************************* + * Copyright (c) 2009 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.internal; + +import java.sql.DatabaseMetaData; +import java.util.Properties; +import org.eclipse.osee.framework.core.enums.ConflictStatus; +import org.eclipse.osee.framework.core.enums.ModificationType; +import org.eclipse.osee.framework.core.enums.TxChange; +import org.eclipse.osee.framework.database.core.SupportedDatabase; +import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; + +/** + * @author Ryan D. Brooks + */ +public enum OseeSql { + + TX_GET_ALL_TRANSACTIONS("SELECT * FROM osee_tx_details WHERE transaction_id = ?"), + TX_GET_MAX_AS_LARGEST_TX("SELECT max(transaction_id) as largest_transaction_id FROM osee_tx_details WHERE branch_id = ?"), + TX_GET_PREVIOUS_TX_NOT_CURRENT_ARTIFACTS("SELECT txs.transaction_id, txs.gamma_id FROM osee_artifact art, osee_txs txs WHERE art.art_id = ? AND art.gamma_id = txs.gamma_id AND txs.branch_id = ? AND txs.tx_current <> " + TxChange.NOT_CURRENT.getValue()), + TX_GET_PREVIOUS_TX_NOT_CURRENT_ATTRIBUTES("SELECT txs.transaction_id, txs.gamma_id FROM osee_attribute atr, osee_txs txs WHERE atr.attr_id = ? AND atr.gamma_id = txs.gamma_id AND txs.branch_id = ? AND txs.tx_current <> " + TxChange.NOT_CURRENT.getValue()), + TX_GET_PREVIOUS_TX_NOT_CURRENT_RELATIONS("SELECT txs.transaction_id, txs.gamma_id FROM osee_relation_link rel, osee_txs txs WHERE rel.rel_link_id = ? AND rel.gamma_id = txs.gamma_id AND txs.branch_id = ? AND txs.tx_current <> " + TxChange.NOT_CURRENT.getValue()), + + MERGE_GET_ARTIFACTS_FOR_BRANCH("SELECT art.art_id FROM osee_txs txs, osee_artifact art WHERE txs.branch_id = ? and txs.gamma_id = art.gamma_id"), + MERGE_GET_ATTRIBUTES_FOR_BRANCH("SELECT atr.art_id, atr.attr_id FROM osee_txs txs, osee_attribute atr WHERE txs.branch_id = ? and txs.gamma_id = atr.gamma_id"), + MERGE_GET_RELATIONS_FOR_BRANCH("SELECT rel.a_art_id, rel.b_art_id FROM osee_txs txs, osee_relation_link rel WHERE txs.branch_id = ? and txs.gamma_id = rel.gamma_id"), + + CONFLICT_GET_ARTIFACTS_DEST("SELECT%s art2.art_type_id, art1.art_id, txs1.mod_type AS source_mod_type, txs1.gamma_id AS source_gamma, txs2.mod_type AS dest_mod_type, txs2.gamma_id AS dest_gamma FROM osee_txs txs1, osee_attribute art1, osee_artifact art2, osee_txs txs2 WHERE txs1.branch_id = ? AND txs1.transaction_id <> ? AND txs1.tx_current in (1,2) AND txs1.gamma_id = art1.gamma_id AND art1.art_id = art2.art_id AND art2.gamma_id = txs2.gamma_id AND txs2.branch_id = ? AND ((txs2.tx_current = 1 AND txs2.gamma_id not in (SELECT txs.gamma_id FROM osee_txs txs WHERE branch_id = ? AND txs.transaction_id = ?)) OR (txs2.tx_current = 2 and txs2.transaction_id > ?)) ORDER BY art2.art_id", Strings.HINTS__ORDERED__INDEX__ARTIFACT_CONFLICT), + CONFLICT_GET_ARTIFACTS_SRC("SELECT%s art1.art_type_id, art1.art_id, txs1.mod_type AS source_mod_type, txs1.gamma_id AS source_gamma, txs2.mod_type AS dest_mod_type, txs2.gamma_id AS dest_gamma FROM osee_txs txs1, osee_artifact art1, osee_attribute art2, osee_txs txs2 WHERE txs1.branch_id = ? AND txs1.transaction_id <> ? AND txs1.tx_current in (1,2) AND txs1.gamma_id = art1.gamma_id AND art1.art_id = art2.art_id AND art2.gamma_id = txs2.gamma_id AND txs2.branch_id = ? AND ((txs2.tx_current = 1 AND txs2.gamma_id not in (SELECT txs.gamma_id FROM osee_txs txs WHERE txs.branch_id = ? AND txs.transaction_id = ?)) OR (txs2.tx_current = 2 and txs2.transaction_id > ?)) ORDER BY art1.art_id", Strings.HINTS__ORDERED__INDEX__ARTIFACT_CONFLICT), + 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 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", getHintsOrderedFirstRows()), + + 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 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", getHintsOrderedFirstRows()), + 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 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_CURRENT_ATTRIBUTES(Strings.SELECT_CURRENT_ATTRIBUTES_PREFIX + "= 1 order by al1.branch_id, al1.art_id, att1.attr_id, txs.transaction_id desc", getHintsOrderedFirstRows()), + 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", getHintsOrderedFirstRows()), + 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", getHintsOrderedFirstRows()), + + 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 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", getHintsOrderedFirstRows()), + LOAD_CURRENT_ARTIFACTS(Strings.SELECT_CURRENT_ARTIFACTS_PREFIX + "= 1", getHintsOrderedFirstRows()), + LOAD_CURRENT_ARTIFACTS_WITH_DELETED(Strings.SELECT_CURRENT_ARTIFACTS_PREFIX + "in (1, 2)", getHintsOrderedFirstRows()), + + 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 <=?", getHintsOrderedFirstRows()), + 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 <=?", getHintsOrderedFirstRows()), + + 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 = ?", getHintsOrderedFirstRows()), + 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", getHintsOrderedFirstRows()), + 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", getHintsOrderedFirstRows()), + 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 =?"), + CHANGE_BRANCH_RELATION("SELECT%s txs1.mod_type, rel1.gamma_id, rel1.b_art_id, rel1.a_art_id, rel1.rationale, rel1.rel_link_id, rel1.rel_link_type_id, art.art_type_id from osee_txs txs1, osee_relation_link rel1, osee_artifact art where txs1.branch_id = ? AND txs1.transaction_id <> ? AND txs1.tx_current in (" + TxChange.DELETED.getValue() + ", " + TxChange.CURRENT.getValue() + ", " + TxChange.ARTIFACT_DELETED.getValue() + ") AND txs1.gamma_id = rel1.gamma_id AND rel1.a_art_id = art.art_id", getHintsOrderedFirstRows()), + CHANGE_TX_RELATION("SELECT txs.mod_type, rel.gamma_id, rel.b_art_id, rel.a_art_id, rel.rationale, rel.rel_link_id, rel.rel_link_type_id, art.art_type_id from osee_txs txs, osee_relation_link rel, osee_artifact art where txs.branch_id = ? AND txs.transaction_id = ? AND txs.gamma_id = rel.gamma_id AND rel.a_art_id = art.art_id"), + CHANGE_TX_RELATION_FOR_SPECIFIC_ARTIFACT(CHANGE_TX_RELATION.sql + " and (rel.a_art_id = ? or rel.b_art_id = ?)"), + 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() + ") ", getHintsOrderedFirstRows()), + 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", getHintsOrderedFirstRows()), + 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", getHintsOrderedFirstRows()), + + 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 = ?", getHintsOrderedFirstRows()), + QUERY_BUILDER("%s", getHintsOrderedFirstRows()); + + private final String sql; + private final String hints; + + private OseeSql(String sql, String hints) { + this.sql = sql; + this.hints = hints; + } + + private OseeSql(String sql) { + this(sql, null); + } + + public static Properties getSqlProperties(DatabaseMetaData metaData) throws OseeCoreException { + Properties sqlProperties = new Properties(); + boolean areHintsSupported = SupportedDatabase.areHintsSupported(metaData); + for (OseeSql oseeSql : OseeSql.values()) { + String sql; + + if (oseeSql.hints == null) { + sql = oseeSql.sql; + } else { + String hints = areHintsSupported ? oseeSql.hints : ""; + sql = String.format(oseeSql.sql, hints); + } + + sqlProperties.setProperty(oseeSql.toString(), sql); + } + return sqlProperties; + } + + private static String getHintsOrderedFirstRows() { + return "/*+ ordered */"; + + } + private static class Strings { + private static final String HINTS__ORDERED__INDEX__ARTIFACT_CONFLICT = + " /*+ ordered index(atr1) index(atr2) index(txs2) */"; + private static final String HINTS__ORDERED__INDEX__ATTRIBUTE_CONFLICT = + " /*+ 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 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 "; + + 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 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 "; + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/ServiceUtil.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/ServiceUtil.java index a746d464756..070b307c2c2 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/ServiceUtil.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/ServiceUtil.java @@ -10,14 +10,17 @@ *******************************************************************************/ package org.eclipse.osee.framework.skynet.core.internal; +import java.util.Properties; import java.util.logging.Level; import org.eclipse.core.runtime.Platform; import org.eclipse.osee.cache.admin.CacheAdmin; +import org.eclipse.osee.framework.core.client.ClientSessionManager; import org.eclipse.osee.framework.core.model.TransactionRecordFactory; import org.eclipse.osee.framework.core.services.IOseeCachingService; import org.eclipse.osee.framework.core.services.IOseeModelFactoryService; import org.eclipse.osee.framework.core.translation.IDataTranslationService; import org.eclipse.osee.framework.database.IOseeDatabaseService; +import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.Conditions; import org.eclipse.osee.framework.logging.OseeLog; @@ -97,4 +100,13 @@ public final class ServiceUtil { } return getService(AccessPolicy.class); } + + public static String getSql(OseeSql sqlEnum) throws OseeCoreException { + Properties properties = ClientSessionManager.getSqlProperties(); + String sql = properties.getProperty(sqlEnum.toString()); + if (sql != null) { + return sql; + } + throw new OseeArgumentException("Invalid sql key [%s]", sqlEnum.toString()); + } } diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/DatabaseTransactionRecordAccessor.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/DatabaseTransactionRecordAccessor.java index 3705d0028f9..14118e480b2 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/DatabaseTransactionRecordAccessor.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/DatabaseTransactionRecordAccessor.java @@ -2,7 +2,6 @@ package org.eclipse.osee.framework.skynet.core.internal.accessors; import java.util.Collection; import java.util.Date; -import org.eclipse.osee.framework.core.client.ClientSessionManager; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.enums.TransactionDetailsType; import org.eclipse.osee.framework.core.enums.TransactionVersion; @@ -14,10 +13,11 @@ import org.eclipse.osee.framework.core.model.cache.ITransactionDataAccessor; import org.eclipse.osee.framework.core.model.cache.TransactionCache; import org.eclipse.osee.framework.database.IOseeDatabaseService; import org.eclipse.osee.framework.database.core.IOseeStatement; -import org.eclipse.osee.framework.database.core.OseeSql; import org.eclipse.osee.framework.jdk.core.type.MutableInteger; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.type.OseeStateException; +import org.eclipse.osee.framework.skynet.core.internal.OseeSql; +import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil; import org.eclipse.osee.framework.skynet.core.utility.IdJoinQuery; import org.eclipse.osee.framework.skynet.core.utility.JoinUtility; @@ -170,7 +170,7 @@ public class DatabaseTransactionRecordAccessor implements ITransactionDataAccess @Override public TransactionRecord getHeadTransaction(TransactionCache cache, Branch branch) throws OseeCoreException { - String query = ClientSessionManager.getSql(OseeSql.TX_GET_MAX_AS_LARGEST_TX); + String query = ServiceUtil.getSql(OseeSql.TX_GET_MAX_AS_LARGEST_TX); return cache.getOrLoad(oseeDatabaseService.runPreparedQueryFetchObject(-1, query, branch.getUuid())); } } diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationTransactionData.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationTransactionData.java index 92c22b3e6ce..eb09d143b79 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationTransactionData.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/relation/RelationTransactionData.java @@ -14,10 +14,10 @@ import org.eclipse.osee.framework.core.enums.ModificationType; import org.eclipse.osee.framework.core.model.TransactionRecord; import org.eclipse.osee.framework.core.model.event.DefaultBasicUuidRelation; import org.eclipse.osee.framework.database.core.ConnectionHandler; -import org.eclipse.osee.framework.database.core.OseeSql; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.skynet.core.event.model.ArtifactEvent; import org.eclipse.osee.framework.skynet.core.event.model.EventBasicGuidRelation; +import org.eclipse.osee.framework.skynet.core.internal.OseeSql; import org.eclipse.osee.framework.skynet.core.transaction.BaseTransactionData; /** 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 db33c0e49c5..250a0f948d8 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 @@ -13,7 +13,6 @@ package org.eclipse.osee.framework.skynet.core.revision; import java.util.ArrayList; import java.util.Collection; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.osee.framework.core.client.ClientSessionManager; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.enums.BranchArchivedState; import org.eclipse.osee.framework.core.enums.BranchType; @@ -23,7 +22,6 @@ import org.eclipse.osee.framework.core.model.TransactionRecord; import org.eclipse.osee.framework.core.operation.IOperation; import org.eclipse.osee.framework.database.core.ConnectionHandler; import org.eclipse.osee.framework.database.core.IOseeStatement; -import org.eclipse.osee.framework.database.core.OseeSql; import org.eclipse.osee.framework.jdk.core.type.CompositeKeyHashMap; import org.eclipse.osee.framework.jdk.core.type.HashCollection; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; @@ -31,6 +29,8 @@ import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; import org.eclipse.osee.framework.skynet.core.change.ArtifactDelta; import org.eclipse.osee.framework.skynet.core.change.Change; +import org.eclipse.osee.framework.skynet.core.internal.OseeSql; +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.JoinUtility; @@ -122,7 +122,7 @@ public final class ChangeManager { joinQuery.store(); IOseeStatement chStmt = ConnectionHandler.getStatement(); try { - chStmt.runPreparedQuery(joinQuery.size() * 2, ClientSessionManager.getSql(OseeSql.CHANGE_TX_MODIFYING), + chStmt.runPreparedQuery(joinQuery.size() * 2, ServiceUtil.getSql(OseeSql.CHANGE_TX_MODIFYING), joinQuery.getQueryId()); while (chStmt.next()) { Branch branch = BranchManager.getBranch(chStmt.getLong("branch_id")); @@ -165,7 +165,7 @@ public final class ChangeManager { joinQuery.store(); IOseeStatement chStmt = ConnectionHandler.getStatement(); try { - chStmt.runPreparedQuery(joinQuery.size() * 2, ClientSessionManager.getSql(OseeSql.CHANGE_BRANCH_MODIFYING), + chStmt.runPreparedQuery(joinQuery.size() * 2, ServiceUtil.getSql(OseeSql.CHANGE_BRANCH_MODIFYING), joinQuery.getQueryId()); while (chStmt.next()) { if (chStmt.getInt("tx_count") > 0) { 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 ddd9946ffc4..d90da7f94ae 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 @@ -19,7 +19,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Set; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.osee.framework.core.client.ClientSessionManager; import org.eclipse.osee.framework.core.enums.ConflictStatus; import org.eclipse.osee.framework.core.enums.ModificationType; import org.eclipse.osee.framework.core.exception.BranchMergeException; @@ -27,7 +26,6 @@ import org.eclipse.osee.framework.core.model.Branch; import org.eclipse.osee.framework.core.model.TransactionRecord; import org.eclipse.osee.framework.database.core.ConnectionHandler; import org.eclipse.osee.framework.database.core.IOseeStatement; -import org.eclipse.osee.framework.database.core.OseeSql; import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; @@ -38,6 +36,8 @@ import org.eclipse.osee.framework.skynet.core.conflict.AttributeConflict; import org.eclipse.osee.framework.skynet.core.conflict.AttributeConflictBuilder; 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.OseeSql; +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.JoinUtility; @@ -65,7 +65,7 @@ public class ConflictManagerInternal { ArrayList<Conflict> conflicts = new ArrayList<Conflict>(); IOseeStatement chStmt = ConnectionHandler.getStatement(); try { - chStmt.runPreparedQuery(ClientSessionManager.getSql(OseeSql.CONFLICT_GET_HISTORICAL_ATTRIBUTES), + chStmt.runPreparedQuery(ServiceUtil.getSql(OseeSql.CONFLICT_GET_HISTORICAL_ATTRIBUTES), commitTransaction.getId()); while (chStmt.next()) { AttributeConflict attributeConflict = @@ -112,10 +112,10 @@ public class ConflictManagerInternal { TransactionRecord commonTransaction = findCommonTransaction(sourceBranch, destinationBranch); - loadArtifactVersionConflicts(ClientSessionManager.getSql(OseeSql.CONFLICT_GET_ARTIFACTS_DEST), sourceBranch, + loadArtifactVersionConflicts(ServiceUtil.getSql(OseeSql.CONFLICT_GET_ARTIFACTS_DEST), sourceBranch, destinationBranch, baselineTransaction, conflictBuilders, artIdSet, artIdSetDontShow, artIdSetDontAdd, monitor, commonTransaction); - loadArtifactVersionConflicts(ClientSessionManager.getSql(OseeSql.CONFLICT_GET_ARTIFACTS_SRC), sourceBranch, + loadArtifactVersionConflicts(ServiceUtil.getSql(OseeSql.CONFLICT_GET_ARTIFACTS_SRC), sourceBranch, destinationBranch, baselineTransaction, conflictBuilders, artIdSet, artIdSetDontShow, artIdSetDontAdd, monitor, commonTransaction); loadAttributeConflictsNew(sourceBranch, destinationBranch, baselineTransaction, conflictBuilders, artIdSet, @@ -229,7 +229,7 @@ public class ConflictManagerInternal { int commonTransactionNumber = transactionId != null ? transactionId.getId() : 0; long commonBranchId = transactionId != null ? transactionId.getBranchId() : 0; - chStmt.runPreparedQuery(ClientSessionManager.getSql(OseeSql.CONFLICT_GET_ATTRIBUTES), sourceBranch.getUuid(), + chStmt.runPreparedQuery(ServiceUtil.getSql(OseeSql.CONFLICT_GET_ATTRIBUTES), sourceBranch.getUuid(), sourceBranch.getBaseTransaction().getId(), destinationBranch.getUuid(), commonBranchId, commonTransactionNumber); diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/RevisionChangeLoader.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/RevisionChangeLoader.java index e04a7682f2e..cc07aca6063 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/RevisionChangeLoader.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/RevisionChangeLoader.java @@ -19,14 +19,12 @@ import java.util.Map.Entry; import java.util.Set; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.osee.framework.core.client.ClientSessionManager; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.enums.DeletionFlag; import org.eclipse.osee.framework.core.model.Branch; import org.eclipse.osee.framework.core.model.TransactionRecord; import org.eclipse.osee.framework.database.core.ConnectionHandler; import org.eclipse.osee.framework.database.core.IOseeStatement; -import org.eclipse.osee.framework.database.core.OseeSql; import org.eclipse.osee.framework.jdk.core.type.CompositeKeyHashMap; import org.eclipse.osee.framework.jdk.core.type.HashCollection; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; @@ -41,6 +39,8 @@ import org.eclipse.osee.framework.skynet.core.change.Change; import org.eclipse.osee.framework.skynet.core.change.ChangeBuilder; import org.eclipse.osee.framework.skynet.core.change.RelationChange; import org.eclipse.osee.framework.skynet.core.change.RelationChangeBuilder; +import org.eclipse.osee.framework.skynet.core.internal.OseeSql; +import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil; import org.eclipse.osee.framework.skynet.core.revision.acquirer.ArtifactChangeAcquirer; import org.eclipse.osee.framework.skynet.core.revision.acquirer.AttributeChangeAcquirer; import org.eclipse.osee.framework.skynet.core.revision.acquirer.RelationChangeAcquirer; @@ -97,14 +97,14 @@ public final class RevisionChangeLoader { private void loadTransactions(Branch branch, Artifact artifact, TransactionRecord transactionId, Set<TransactionRecord> transactionIds) throws OseeCoreException { IOseeStatement chStmt = ConnectionHandler.getStatement(); try { - chStmt.runPreparedQuery(ClientSessionManager.getSql(OseeSql.LOAD_REVISION_HISTORY_TRANSACTION_ATTR), + chStmt.runPreparedQuery(ServiceUtil.getSql(OseeSql.LOAD_REVISION_HISTORY_TRANSACTION_ATTR), artifact.getArtId(), branch.getUuid(), transactionId.getId()); while (chStmt.next()) { transactionIds.add(TransactionManager.getTransactionId(chStmt.getInt("transaction_id"))); } - chStmt.runPreparedQuery(ClientSessionManager.getSql(OseeSql.LOAD_REVISION_HISTORY_TRANSACTION_REL), + chStmt.runPreparedQuery(ServiceUtil.getSql(OseeSql.LOAD_REVISION_HISTORY_TRANSACTION_REL), artifact.getArtId(), artifact.getArtId(), branch.getUuid(), transactionId.getId()); while (chStmt.next()) { diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/acquirer/ArtifactChangeAcquirer.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/acquirer/ArtifactChangeAcquirer.java index 9136371d54b..2e46a475850 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/acquirer/ArtifactChangeAcquirer.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/acquirer/ArtifactChangeAcquirer.java @@ -15,19 +15,19 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.osee.framework.core.client.ClientSessionManager; import org.eclipse.osee.framework.core.enums.ModificationType; import org.eclipse.osee.framework.core.model.Branch; import org.eclipse.osee.framework.core.model.TransactionDelta; import org.eclipse.osee.framework.core.model.TransactionRecord; import org.eclipse.osee.framework.database.core.ConnectionHandler; import org.eclipse.osee.framework.database.core.IOseeStatement; -import org.eclipse.osee.framework.database.core.OseeSql; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager; import org.eclipse.osee.framework.skynet.core.change.ArtifactChangeBuilder; import org.eclipse.osee.framework.skynet.core.change.ChangeBuilder; +import org.eclipse.osee.framework.skynet.core.internal.OseeSql; +import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil; import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager; /** @@ -56,18 +56,18 @@ public class ArtifactChangeAcquirer extends ChangeAcquirer { fromTransactionId = getSourceBranch().getBaseTransaction(); toTransactionId = TransactionManager.getHeadTransaction(getSourceBranch()); - chStmt.runPreparedQuery(ClientSessionManager.getSql(OseeSql.CHANGE_BRANCH_ARTIFACT), - getSourceBranch().getUuid(), fromTransactionId.getId()); + chStmt.runPreparedQuery(ServiceUtil.getSql(OseeSql.CHANGE_BRANCH_ARTIFACT), getSourceBranch().getUuid(), + fromTransactionId.getId()); } else { //Changes per a transaction toTransactionId = getTransaction(); if (getSpecificArtifact() != null) { - chStmt.runPreparedQuery(ClientSessionManager.getSql(OseeSql.CHANGE_TX_ARTIFACT_FOR_SPECIFIC_ARTIFACT), + chStmt.runPreparedQuery(ServiceUtil.getSql(OseeSql.CHANGE_TX_ARTIFACT_FOR_SPECIFIC_ARTIFACT), toTransactionId.getBranchId(), toTransactionId.getId(), getSpecificArtifact().getArtId()); fromTransactionId = toTransactionId; } else { - chStmt.runPreparedQuery(ClientSessionManager.getSql(OseeSql.CHANGE_TX_ARTIFACT), - toTransactionId.getBranchId(), toTransactionId.getId()); + chStmt.runPreparedQuery(ServiceUtil.getSql(OseeSql.CHANGE_TX_ARTIFACT), toTransactionId.getBranchId(), + toTransactionId.getId()); fromTransactionId = TransactionManager.getPriorTransaction(toTransactionId); } } 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 1f89871006e..bc18c9c468c 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,7 +16,6 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.osee.framework.core.client.ClientSessionManager; import org.eclipse.osee.framework.core.data.IArtifactType; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.enums.ModificationType; @@ -27,7 +26,6 @@ import org.eclipse.osee.framework.core.model.TransactionRecord; import org.eclipse.osee.framework.core.model.type.AttributeType; import org.eclipse.osee.framework.database.core.ConnectionHandler; import org.eclipse.osee.framework.database.core.IOseeStatement; -import org.eclipse.osee.framework.database.core.OseeSql; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager; @@ -35,6 +33,8 @@ import org.eclipse.osee.framework.skynet.core.attribute.AttributeTypeManager; import org.eclipse.osee.framework.skynet.core.change.ArtifactChangeBuilder; 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.OseeSql; +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.JoinUtility; @@ -71,20 +71,19 @@ public class AttributeChangeAcquirer extends ChangeAcquirer { if (hasBranch) { fromTransactionId = getSourceBranch().getBaseTransaction(); toTransaction = TransactionManager.getHeadTransaction(getSourceBranch()); - chStmt.runPreparedQuery(ClientSessionManager.getSql(OseeSql.CHANGE_BRANCH_ATTRIBUTE_IS), + chStmt.runPreparedQuery(ServiceUtil.getSql(OseeSql.CHANGE_BRANCH_ATTRIBUTE_IS), getSourceBranch().getUuid(), fromTransactionId.getId()); }//Changes per transaction number else { toTransaction = getTransaction(); if (hasSpecificArtifact) { - chStmt.runPreparedQuery( - ClientSessionManager.getSql(OseeSql.CHANGE_TX_ATTRIBUTE_IS_FOR_SPECIFIC_ARTIFACT), + chStmt.runPreparedQuery(ServiceUtil.getSql(OseeSql.CHANGE_TX_ATTRIBUTE_IS_FOR_SPECIFIC_ARTIFACT), toTransaction.getBranchId(), toTransaction.getId(), getSpecificArtifact().getArtId()); fromTransactionId = getTransaction(); } else { - chStmt.runPreparedQuery(ClientSessionManager.getSql(OseeSql.CHANGE_TX_ATTRIBUTE_IS), - toTransaction.getBranchId(), toTransaction.getId()); + chStmt.runPreparedQuery(ServiceUtil.getSql(OseeSql.CHANGE_TX_ATTRIBUTE_IS), toTransaction.getBranchId(), + toTransaction.getId()); fromTransactionId = TransactionManager.getPriorTransaction(toTransaction); } } @@ -168,11 +167,11 @@ public class AttributeChangeAcquirer extends ChangeAcquirer { if (hasBranch) { wasValueBranch = sourceBranch; - sql = ClientSessionManager.getSql(OseeSql.CHANGE_BRANCH_ATTRIBUTE_WAS); + sql = ServiceUtil.getSql(OseeSql.CHANGE_BRANCH_ATTRIBUTE_WAS); sqlParamter = wasValueBranch.getUuid(); } else { wasValueBranch = transactionId.getBranch(); - sql = ClientSessionManager.getSql(OseeSql.CHANGE_TX_ATTRIBUTE_WAS); + sql = ServiceUtil.getSql(OseeSql.CHANGE_TX_ATTRIBUTE_WAS); sqlParamter = transactionId.getId(); } diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/acquirer/RelationChangeAcquirer.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/acquirer/RelationChangeAcquirer.java index ef452ac7efc..6f184a5f846 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/acquirer/RelationChangeAcquirer.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/acquirer/RelationChangeAcquirer.java @@ -13,19 +13,19 @@ package org.eclipse.osee.framework.skynet.core.revision.acquirer; import java.util.ArrayList; import java.util.Set; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.osee.framework.core.client.ClientSessionManager; import org.eclipse.osee.framework.core.enums.ModificationType; import org.eclipse.osee.framework.core.model.Branch; import org.eclipse.osee.framework.core.model.TransactionDelta; import org.eclipse.osee.framework.core.model.TransactionRecord; import org.eclipse.osee.framework.database.core.ConnectionHandler; import org.eclipse.osee.framework.database.core.IOseeStatement; -import org.eclipse.osee.framework.database.core.OseeSql; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager; import org.eclipse.osee.framework.skynet.core.change.ChangeBuilder; import org.eclipse.osee.framework.skynet.core.change.RelationChangeBuilder; +import org.eclipse.osee.framework.skynet.core.internal.OseeSql; +import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil; import org.eclipse.osee.framework.skynet.core.relation.RelationTypeManager; import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager; @@ -54,19 +54,19 @@ public class RelationChangeAcquirer extends ChangeAcquirer { if (hasBranch) { fromTransactionId = getSourceBranch().getBaseTransaction(); toTransactionId = TransactionManager.getHeadTransaction(getSourceBranch()); - chStmt.runPreparedQuery(ClientSessionManager.getSql(OseeSql.CHANGE_BRANCH_RELATION), - getSourceBranch().getUuid(), fromTransactionId.getId()); + chStmt.runPreparedQuery(ServiceUtil.getSql(OseeSql.CHANGE_BRANCH_RELATION), getSourceBranch().getUuid(), + fromTransactionId.getId()); } else {//Changes per a transaction toTransactionId = getTransaction(); if (getSpecificArtifact() != null) { - chStmt.runPreparedQuery(ClientSessionManager.getSql(OseeSql.CHANGE_TX_RELATION_FOR_SPECIFIC_ARTIFACT), + chStmt.runPreparedQuery(ServiceUtil.getSql(OseeSql.CHANGE_TX_RELATION_FOR_SPECIFIC_ARTIFACT), toTransactionId.getBranchId(), toTransactionId.getId(), getSpecificArtifact().getArtId(), getSpecificArtifact().getArtId()); fromTransactionId = toTransactionId; } else { - chStmt.runPreparedQuery(ClientSessionManager.getSql(OseeSql.CHANGE_TX_RELATION), - toTransactionId.getBranchId(), toTransactionId.getId()); + chStmt.runPreparedQuery(ServiceUtil.getSql(OseeSql.CHANGE_TX_RELATION), toTransactionId.getBranchId(), + toTransactionId.getId()); fromTransactionId = TransactionManager.getPriorTransaction(toTransactionId); } } diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/BaseTransactionData.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/BaseTransactionData.java index d9d9ff430d1..d78833c656f 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/BaseTransactionData.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/BaseTransactionData.java @@ -13,9 +13,9 @@ package org.eclipse.osee.framework.skynet.core.transaction; import org.eclipse.osee.framework.core.enums.ModificationType; import org.eclipse.osee.framework.core.enums.TxChange; import org.eclipse.osee.framework.core.model.TransactionRecord; -import org.eclipse.osee.framework.database.core.OseeSql; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.skynet.core.event.model.ArtifactEvent; +import org.eclipse.osee.framework.skynet.core.internal.OseeSql; /** * @author Jeff C. Phillips diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/StoreSkynetTransactionOperation.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/StoreSkynetTransactionOperation.java index c1748817a74..92e401a6245 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/StoreSkynetTransactionOperation.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/StoreSkynetTransactionOperation.java @@ -21,7 +21,6 @@ import java.util.Set; import java.util.logging.Level; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.osee.framework.core.client.ClientSessionManager; import org.eclipse.osee.framework.core.enums.BranchState; import org.eclipse.osee.framework.core.enums.TxChange; import org.eclipse.osee.framework.core.model.Branch; @@ -44,6 +43,7 @@ import org.eclipse.osee.framework.skynet.core.event.OseeEventManager; import org.eclipse.osee.framework.skynet.core.event.model.ArtifactEvent; import org.eclipse.osee.framework.skynet.core.event.model.EventModifiedBasicGuidArtifact; 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.transaction.BaseTransactionData.InsertDataCollector; /** @@ -173,7 +173,7 @@ public final class StoreSkynetTransactionOperation extends AbstractOperation imp private static void fetchTxNotCurrent(OseeConnection connection, Branch branch, BaseTransactionData transactionData, List<Object[]> results) throws OseeCoreException { IOseeStatement chStmt = ConnectionHandler.getStatement(connection); try { - String query = ClientSessionManager.getSql(transactionData.getSelectTxNotCurrentSql()); + String query = ServiceUtil.getSql(transactionData.getSelectTxNotCurrentSql()); chStmt.runPreparedQuery(query, transactionData.getItemId(), branch.getUuid()); while (chStmt.next()) { diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/TransactionManager.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/TransactionManager.java index bd3abd04649..bf083f587a4 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/TransactionManager.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/TransactionManager.java @@ -18,7 +18,6 @@ import java.util.Collection; import java.util.Date; import java.util.HashMap; import java.util.List; -import org.eclipse.osee.framework.core.client.ClientSessionManager; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.enums.TransactionDetailsType; import org.eclipse.osee.framework.core.exception.TransactionDoesNotExist; @@ -31,13 +30,13 @@ import org.eclipse.osee.framework.core.services.IOseeCachingService; import org.eclipse.osee.framework.database.core.ConnectionHandler; import org.eclipse.osee.framework.database.core.IOseeStatement; import org.eclipse.osee.framework.database.core.OseeConnection; -import org.eclipse.osee.framework.database.core.OseeSql; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.Conditions; import org.eclipse.osee.framework.jdk.core.util.GUID; import org.eclipse.osee.framework.jdk.core.util.time.GlobalTime; import org.eclipse.osee.framework.skynet.core.User; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; +import org.eclipse.osee.framework.skynet.core.internal.OseeSql; import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil; import org.eclipse.osee.framework.skynet.core.types.IArtifact; @@ -170,7 +169,7 @@ public final class TransactionManager { public static TransactionRecord getHeadTransaction(IOseeBranch branch) throws OseeCoreException { long branchUuid = branch.getUuid(); int transactionNumber = - ConnectionHandler.runPreparedQueryFetchInt(-1, ClientSessionManager.getSql(OseeSql.TX_GET_MAX_AS_LARGEST_TX), + ConnectionHandler.runPreparedQueryFetchInt(-1, ServiceUtil.getSql(OseeSql.TX_GET_MAX_AS_LARGEST_TX), branchUuid); if (transactionNumber == -1) { throw new TransactionDoesNotExist("No transactions where found in the database for branch: %d", branchUuid); @@ -256,7 +255,7 @@ public final class TransactionManager { try { if (useLocalConnection) { chStmt = ConnectionHandler.getStatement(); - chStmt.runPreparedQuery(ClientSessionManager.getSql(OseeSql.TX_GET_ALL_TRANSACTIONS), txId); + chStmt.runPreparedQuery(ServiceUtil.getSql(OseeSql.TX_GET_ALL_TRANSACTIONS), txId); if (!chStmt.next()) { throw new TransactionDoesNotExist("The transaction id %d does not exist in the databse.", txId); } |