Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2011-09-28 05:39:15 +0000
committerRoberto E. Escobar2011-09-28 05:39:15 +0000
commit7800f360fcc81e53a7f5d3101e554348e1cf0b11 (patch)
tree5be3a2ab68660d530e54c9e40734737a6538d1d8
parentaca18902f3b241aec2fa2c4e834870957143685a (diff)
downloadorg.eclipse.osee-7800f360fcc81e53a7f5d3101e554348e1cf0b11.tar.gz
org.eclipse.osee-7800f360fcc81e53a7f5d3101e554348e1cf0b11.tar.xz
org.eclipse.osee-7800f360fcc81e53a7f5d3101e554348e1cf0b11.zip
feature[ats_Q9NLC]: Create AttributeLoader
-rw-r--r--plugins/org.eclipse.osee.orcs.core/META-INF/MANIFEST.MF8
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/Attribute.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.db/META-INF/MANIFEST.MF5
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/SqlProvider.java24
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/attribute/AttributeLoader.java99
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/attribute/LoadOptions.java76
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/OseeSql.java113
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/StaticSqlProvider.java93
-rw-r--r--plugins/org.eclipse.osee.orcs/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/HasVersion.java (renamed from plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/HasVersion.java)2
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/Identifiable.java (renamed from plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/Identifiable.java)2
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/Readable.java (renamed from plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/Readable.java)2
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/ReadableArtifact.java (renamed from plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/ReadableArtifact.java)2
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/ReadableAttribute.java (renamed from plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/ReadableAttribute.java)2
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/ReadableRelation.java (renamed from plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/ReadableRelation.java)2
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/Writable.java (renamed from plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/Writable.java)2
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/WritableArtifact.java (renamed from plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/WritableArtifact.java)2
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/WritableAttribute.java (renamed from plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/WritableAttribute.java)2
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/WritableRelation.java (renamed from plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/WritableRelation.java)2
19 files changed, 431 insertions, 12 deletions
diff --git a/plugins/org.eclipse.osee.orcs.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.core/META-INF/MANIFEST.MF
index 8b160ec6107..a305d3098e6 100644
--- a/plugins/org.eclipse.osee.orcs.core/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs.core/META-INF/MANIFEST.MF
@@ -5,6 +5,7 @@ Bundle-SymbolicName: org.eclipse.osee.orcs.core
Bundle-Version: 0.9.9.qualifier
Bundle-Vendor: Eclipse Open System Engineering Environment
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+<<<<<<< HEAD
Service-Component: OSGI-INF/*.xml
Import-Package: org.eclipse.osee.framework.core.data,
org.eclipse.osee.framework.core.enums,
@@ -17,3 +18,10 @@ Import-Package: org.eclipse.osee.framework.core.data,
org.eclipse.osee.orcs
Export-Package: org.eclipse.osee.orcs.core,
org.eclipse.osee.orcs.core.ds
+=======
+Import-Package: org.osgi.framework;version="1.3.0"
+Require-Bundle: org.eclipse.osee.framework.core,
+ org.eclipse.osee.orcs,
+ org.eclipse.osee.framework.core.model,
+ org.eclipse.osee.framework.jdk.core
+>>>>>>> bd229ed... feature[ats_8KF8L]: Get programs and builds web backend
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/Attribute.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/Attribute.java
index c7ccb660f47..fc4db844cb4 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/Attribute.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/Attribute.java
@@ -22,9 +22,9 @@ import org.eclipse.osee.framework.core.model.type.AttributeType;
import org.eclipse.osee.framework.core.util.Conditions;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.WritableAttribute;
import org.eclipse.osee.orcs.core.ds.AttributeContainer;
import org.eclipse.osee.orcs.core.ds.DataProxy;
+import org.eclipse.osee.orcs.data.WritableAttribute;
/**
* @author Ryan D. Brooks
diff --git a/plugins/org.eclipse.osee.orcs.db/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.db/META-INF/MANIFEST.MF
index 439be6478cc..723e134c65c 100644
--- a/plugins/org.eclipse.osee.orcs.db/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs.db/META-INF/MANIFEST.MF
@@ -5,6 +5,7 @@ Bundle-SymbolicName: org.eclipse.osee.orcs.db
Bundle-Version: 0.9.9.qualifier
Bundle-Vendor: Eclipse Open System Engineering Environment
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+<<<<<<< HEAD
Service-Component: OSGI-INF/*.xml
Import-Package: org.eclipse.osee.framework.core.enums,
org.eclipse.osee.framework.core.exception,
@@ -16,3 +17,7 @@ Import-Package: org.eclipse.osee.framework.core.enums,
org.eclipse.osee.logger,
org.eclipse.osee.orcs.core,
org.eclipse.osee.orcs.core.ds
+=======
+Import-Package: org.osgi.framework;version="1.3.0"
+Require-Bundle: org.eclipse.osee.framework.core.model
+>>>>>>> bd229ed... feature[ats_8KF8L]: Get programs and builds web backend
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/SqlProvider.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/SqlProvider.java
new file mode 100644
index 00000000000..61830279ab7
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/SqlProvider.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * 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.orcs.db.internal;
+
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.orcs.db.internal.sql.OseeSql;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface SqlProvider {
+
+ String getSql(String key) throws OseeCoreException;
+
+ String getSql(OseeSql key) throws OseeCoreException;
+}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/attribute/AttributeLoader.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/attribute/AttributeLoader.java
new file mode 100644
index 00000000000..1e9f45d6adb
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/attribute/AttributeLoader.java
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * 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.orcs.db.internal.attribute;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.osee.framework.core.enums.ModificationType;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.services.IdentityService;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
+import org.eclipse.osee.framework.database.core.IOseeStatement;
+import org.eclipse.osee.orcs.core.ds.AttributeRow;
+import org.eclipse.osee.orcs.core.ds.AttributeRowHandler;
+import org.eclipse.osee.orcs.db.internal.SqlProvider;
+import org.eclipse.osee.orcs.db.internal.sql.OseeSql;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AttributeLoader {
+
+ private final SqlProvider sqlProvider;
+ private final IOseeDatabaseService dbService;
+ private final IdentityService identityService;
+
+ public AttributeLoader(SqlProvider sqlProvider, IOseeDatabaseService dbService, IdentityService identityService) {
+ this.sqlProvider = sqlProvider;
+ this.dbService = dbService;
+ this.identityService = identityService;
+ }
+
+ public String getSql(LoadOptions options) throws OseeCoreException {
+ OseeSql sqlKey;
+ if (options.isHistorical()) {
+ sqlKey = OseeSql.LOAD_HISTORICAL_ATTRIBUTES;
+ } else if (options.getLoadLevel().isHead()) {
+ sqlKey = OseeSql.LOAD_ALL_CURRENT_ATTRIBUTES;
+ } else if (options.areDeletedAllowed()) {
+ sqlKey = OseeSql.LOAD_CURRENT_ATTRIBUTES_WITH_DELETED;
+ } else {
+ sqlKey = OseeSql.LOAD_CURRENT_ATTRIBUTES;
+ }
+ return sqlProvider.getSql(sqlKey);
+ }
+
+ public void loadAttributeData(int fetchSize, AttributeRowHandler handler, LoadOptions options, int queryId) throws OseeCoreException {
+ if (options.getLoadLevel().isShallow() || options.getLoadLevel().isRelationsOnly()) {
+ return;
+ }
+
+ IOseeStatement chStmt = dbService.getStatement();
+ try {
+ String sql = getSql(options);
+ chStmt.runPreparedQuery(fetchSize, sql, queryId);
+
+ AttributeRow previousAttr = new AttributeRow();
+
+ List<AttributeRow> currentAttributes = new ArrayList<AttributeRow>();
+ while (chStmt.next()) {
+ AttributeRow nextAttr = new AttributeRow();
+ nextAttr.setArtifactId(chStmt.getInt("art_id"));
+ nextAttr.setBranchId(chStmt.getInt("branch_id"));
+ nextAttr.setAttrId(chStmt.getInt("attr_id"));
+ nextAttr.setGammaId(chStmt.getInt("gamma_id"));
+ nextAttr.setTransactionId(chStmt.getInt("transaction_id"));
+ nextAttr.setValue(chStmt.getString("value"));
+ nextAttr.setUri(chStmt.getString("uri"));
+ nextAttr.setHistorical(options.isHistorical());
+
+ nextAttr.setModType(ModificationType.getMod(chStmt.getInt("mod_type")));
+ int localAttributeTypeId = chStmt.getInt("attr_type_id");
+ long attributeTypeUuid = identityService.getUniversalId(localAttributeTypeId);
+ nextAttr.setAttrTypeUuid(attributeTypeUuid);
+
+ if (options.isHistorical()) {
+ nextAttr.setStripeId(chStmt.getInt("stripe_transaction_id"));
+ }
+
+ if (!previousAttr.isSameArtifact(nextAttr)) {
+ handler.onRow(currentAttributes);
+ currentAttributes.clear();
+ }
+ currentAttributes.add(nextAttr);
+ previousAttr = nextAttr;
+ }
+ handler.onRow(currentAttributes);
+ } finally {
+ chStmt.close();
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/attribute/LoadOptions.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/attribute/LoadOptions.java
new file mode 100644
index 00000000000..506a39b8f34
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/attribute/LoadOptions.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * 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.orcs.db.internal.attribute;
+
+import org.eclipse.osee.framework.core.enums.DeletionFlag;
+import org.eclipse.osee.framework.core.enums.LoadLevel;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class LoadOptions {
+ private static final int MAX_FETCH_SIZE = 10000;
+
+ private boolean historical;
+ private DeletionFlag allowDeletedArtifacts;
+ private LoadLevel loadLevel;
+ private int fetchSize;
+
+ public LoadOptions() {
+ this(MAX_FETCH_SIZE, false, DeletionFlag.EXCLUDE_DELETED, LoadLevel.SHALLOW);
+ }
+
+ public LoadOptions(int fetchSize, boolean historical, DeletionFlag allowDeletedArtifacts, LoadLevel loadLevel) {
+ super();
+ this.fetchSize = fetchSize;
+ this.historical = historical;
+ this.allowDeletedArtifacts = allowDeletedArtifacts;
+ this.loadLevel = loadLevel;
+ }
+
+ public int getFetchSize() {
+ return fetchSize;
+ }
+
+ public boolean isHistorical() {
+ return historical;
+ }
+
+ public boolean areDeletedAllowed() {
+ return allowDeletedArtifacts.areDeletedAllowed();
+ }
+
+ public LoadLevel getLoadLevel() {
+ return loadLevel;
+ }
+
+ public void setFetchSize(int fetchSize) {
+ this.fetchSize = fetchSize;
+ }
+
+ public void setHistorical(boolean historical) {
+ this.historical = historical;
+ }
+
+ public void setAllowDeletedArtifacts(DeletionFlag allowDeletedArtifacts) {
+ this.allowDeletedArtifacts = allowDeletedArtifacts;
+ }
+
+ public void setLoadLevel(LoadLevel loadLevel) {
+ this.loadLevel = loadLevel;
+ }
+
+ @Override
+ public String toString() {
+ return "LoadOptions [historical=" + historical + ", allowDeletedArtifacts=" + allowDeletedArtifacts + ", loadLevel=" + loadLevel + ", fetchSize=" + fetchSize + "]";
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/OseeSql.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/OseeSql.java
new file mode 100644
index 00000000000..fdf210ba1a2
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/OseeSql.java
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * 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.orcs.db.internal.sql;
+
+import org.eclipse.osee.framework.core.enums.ConflictStatus;
+import org.eclipse.osee.framework.core.enums.ModificationType;
+import org.eclipse.osee.framework.core.enums.TxChange;
+
+/**
+ * @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 txs.transaction_id = ?)) OR txs2.tx_current = 2)", 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.transaction_id = ?)) OR txs2.tx_current = 2)", 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 = 1 AND txs2.gamma_id not in (SELECT txs.gamma_id FROM osee_txs txs WHERE txs.transaction_id = ? )) OR txs2.tx_current = 2) 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", true),
+
+ LOAD_HISTORICAL_ARTIFACTS("SELECT%s aj.art_id, txs.branch_id, txs.gamma_id, txs.mod_type, art_type_id, guid, human_readable_id, 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", Strings.HINTS__THE_INDEX),
+ 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", true),
+ 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", true),
+ 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", true),
+
+ 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", true),
+ LOAD_CURRENT_ARTIFACTS(Strings.SELECT_CURRENT_ARTIFACTS_PREFIX + "= 1", true),
+ LOAD_CURRENT_ARTIFACTS_WITH_DELETED(Strings.SELECT_CURRENT_ARTIFACTS_PREFIX + "in (1, 2)", true),
+
+ 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 <=?", true),
+ 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 <=?", true),
+
+ 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 = ?", true),
+ 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", true),
+ 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", true),
+ 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", true),
+ 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() + ") ", true),
+ 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", true),
+ 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", true),
+
+ 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 = ?", true),
+ QUERY_BUILDER("%s", true);
+
+ private final String sql;
+ private final String hints;
+ private final boolean isDynamicHint;
+
+ private OseeSql(String sql, String hints) {
+ this.sql = sql;
+ this.hints = hints;
+ this.isDynamicHint = false;
+ }
+
+ private OseeSql(String sql) {
+ this(sql, null);
+ }
+
+ private OseeSql(String sql, boolean isDynamicHint) {
+ this.sql = sql;
+ this.hints = null;
+ this.isDynamicHint = isDynamicHint;
+ }
+
+ protected String getSql() {
+ return sql;
+ }
+
+ protected String getHints() {
+ return hints;
+ }
+
+ protected boolean getIsDynamicHint() {
+ return isDynamicHint;
+ }
+
+ private static class Strings {
+ private static final String HINTS__THE_INDEX = "/*+ INDEX(txs OSEE_TXS_B_G_C_M_T_IDX) */";
+
+ 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, human_readable_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 AND txs.tx_current ";
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/StaticSqlProvider.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/StaticSqlProvider.java
new file mode 100644
index 00000000000..e5d5c40f3a1
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/StaticSqlProvider.java
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * 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.orcs.db.internal.sql;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.util.Conditions;
+import org.eclipse.osee.logger.Log;
+import org.eclipse.osee.orcs.core.SystemPreferences;
+import org.eclipse.osee.orcs.db.internal.SqlProvider;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class StaticSqlProvider implements SqlProvider {
+
+ private final Map<String, String> sqlMap = new HashMap<String, String>();
+ private final Log logger;
+ private final SystemPreferences preferences;
+ private boolean wasPopulated;
+
+ public StaticSqlProvider(Log logger, SystemPreferences preferences) {
+ super();
+ this.logger = logger;
+ this.preferences = preferences;
+ this.wasPopulated = false;
+ }
+
+ @Override
+ public String getSql(String key) throws OseeCoreException {
+ Conditions.checkNotNull(key, "Sql Key");
+ ensurePopulated();
+ return sqlMap.get(key);
+ }
+
+ @Override
+ public String getSql(OseeSql key) throws OseeCoreException {
+ Conditions.checkNotNull(key, "Sql Key");
+ ensurePopulated();
+ return getSql(key.toString());
+ }
+
+ public boolean areHintsSupported() throws OseeCoreException {
+ return preferences.isBoolean("hintsSupported");
+ }
+
+ private synchronized void ensurePopulated() throws OseeCoreException {
+ if (!wasPopulated) {
+ synchronized (sqlMap) {
+ boolean areHintsSupported = areHintsSupported();
+ for (OseeSql oseeSql : OseeSql.values()) {
+ String sql = oseeSql.getSql();
+ String hints = oseeSql.getHints();
+ if (areHintsSupported) {
+ if (oseeSql.getIsDynamicHint()) {
+ hints = getHintsOrderedFirstRows();
+ }
+ }
+ if (hints == null) {
+ hints = "";
+ }
+ sql = String.format(sql, hints);
+
+ sqlMap.put(oseeSql.toString(), sql);
+ }
+ }
+ wasPopulated = true;
+ }
+ }
+
+ private String getHintsOrderedFirstRows() {
+ // better for performance when using branch_id indexes
+ String toReturn = "/*+ ordered */";
+ try {
+ // necessary performance when using gamma_id indexes
+ if (preferences.isBoolean("useOrderedFirstRows")) {
+ toReturn = "/*+ ordered FIRST_ROWS */";
+ }
+ } catch (OseeCoreException ex) {
+ logger.error(ex, "Error getHintEnabled setting");
+ }
+ return toReturn;
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs/META-INF/MANIFEST.MF
index 15dfdf2debb..8590acfa23b 100644
--- a/plugins/org.eclipse.osee.orcs/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs/META-INF/MANIFEST.MF
@@ -9,4 +9,5 @@ Import-Package: org.eclipse.osee.framework.core.data,
org.eclipse.osee.framework.core.enums,
org.eclipse.osee.framework.core.exception,
org.eclipse.osee.framework.jdk.core.util
-Export-Package: org.eclipse.osee.orcs
+Export-Package: org.eclipse.osee.orcs,
+ org.eclipse.osee.orcs.data
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/HasVersion.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/HasVersion.java
index e21c9341aeb..70362b1088d 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/HasVersion.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/HasVersion.java
@@ -8,7 +8,7 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs;
+package org.eclipse.osee.orcs.data;
import org.eclipse.osee.framework.core.enums.ModificationType;
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/Identifiable.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/Identifiable.java
index f58ac1ca16d..332b8046d1a 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/Identifiable.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/Identifiable.java
@@ -8,7 +8,7 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs;
+package org.eclipse.osee.orcs.data;
import org.eclipse.osee.framework.core.data.Identity;
import org.eclipse.osee.framework.core.data.Named;
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/Readable.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/Readable.java
index 9d8f0ba7fee..f7d61c01681 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/Readable.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/Readable.java
@@ -8,7 +8,7 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs;
+package org.eclipse.osee.orcs.data;
/**
* @author Roberto E. Escobar
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/ReadableArtifact.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/ReadableArtifact.java
index 6056ffa255d..cb7b47be7a2 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/ReadableArtifact.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/ReadableArtifact.java
@@ -8,7 +8,7 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs;
+package org.eclipse.osee.orcs.data;
import java.util.Collection;
import java.util.List;
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/ReadableAttribute.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/ReadableAttribute.java
index 6b603ebe8dd..029a35f0900 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/ReadableAttribute.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/ReadableAttribute.java
@@ -8,7 +8,7 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs;
+package org.eclipse.osee.orcs.data;
import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/ReadableRelation.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/ReadableRelation.java
index 594be0447ba..6da9cc3552c 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/ReadableRelation.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/ReadableRelation.java
@@ -8,7 +8,7 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs;
+package org.eclipse.osee.orcs.data;
/**
* @author Roberto E. Escobar
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/Writable.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/Writable.java
index 8f24b5dca3d..fe4dbb3aca2 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/Writable.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/Writable.java
@@ -8,7 +8,7 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs;
+package org.eclipse.osee.orcs.data;
/**
* @author Roberto E. Escobar
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/WritableArtifact.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/WritableArtifact.java
index d5c470de65f..cdcbde55c9c 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/WritableArtifact.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/WritableArtifact.java
@@ -8,7 +8,7 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs;
+package org.eclipse.osee.orcs.data;
/**
* @author Roberto E. Escobar
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/WritableAttribute.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/WritableAttribute.java
index 1f45e473390..d358e2f7779 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/WritableAttribute.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/WritableAttribute.java
@@ -8,7 +8,7 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs;
+package org.eclipse.osee.orcs.data;
/**
* @author Roberto E. Escobar
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/WritableRelation.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/WritableRelation.java
index 8ed450ea010..7514c608a32 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/WritableRelation.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/WritableRelation.java
@@ -8,7 +8,7 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs;
+package org.eclipse.osee.orcs.data;
/**
* @author Roberto E. Escobar

Back to the top