Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2016-05-10 14:31:51 -0400
committerAngel Avila2016-05-10 14:31:51 -0400
commit36318fe10fed4674e3003523984dcb750f948f56 (patch)
tree16d8c26c2e05e2cb9e383e917c3a73d5603c7561 /plugins/org.eclipse.osee.orcs.db.test
parent15459a0553b8d6338a06056904679052d0af54d9 (diff)
downloadorg.eclipse.osee-36318fe10fed4674e3003523984dcb750f948f56.tar.gz
org.eclipse.osee-36318fe10fed4674e3003523984dcb750f948f56.tar.xz
org.eclipse.osee-36318fe10fed4674e3003523984dcb750f948f56.zip
refactor: Consolidate JDBC metadata to JdbcType
Diffstat (limited to 'plugins/org.eclipse.osee.orcs.db.test')
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/OseeInfoDataAccessorTest.java25
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderFactoryImplTest.java77
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContextFactoryImplTest.java771
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/BranchQuerySqlContextFactoryImplTest.java233
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/TxQuerySqlContextFactoryImplTest.java98
5 files changed, 579 insertions, 625 deletions
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/OseeInfoDataAccessorTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/OseeInfoDataAccessorTest.java
index 0460b0fe86..4481f98ec8 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/OseeInfoDataAccessorTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/OseeInfoDataAccessorTest.java
@@ -14,7 +14,6 @@ import org.eclipse.osee.framework.core.data.OseeClient;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.OseeStateException;
import org.eclipse.osee.orcs.core.ds.DataStoreConstants;
-import org.eclipse.osee.orcs.db.internal.SqlProvider;
import org.eclipse.osee.orcs.db.internal.accessor.OseeInfoDataAccessor;
import org.eclipse.osee.orcs.db.mocks.MockLog;
@@ -34,30 +33,6 @@ public class OseeInfoDataAccessorTest {
}
@org.junit.Test(expected = OseeStateException.class)
- public void testSetDatabaseHintsSupported() throws OseeCoreException {
- OseeInfoDataAccessor accessor = new OseeInfoDataAccessor();
- accessor.setLogger(new MockLog());
-
- accessor.putValue(SqlProvider.SQL_DATABASE_HINTS_SUPPORTED_KEY, "dummy");
- }
-
- @org.junit.Test(expected = OseeStateException.class)
- public void testSetSQLRecursiveKeyword() throws OseeCoreException {
- OseeInfoDataAccessor accessor = new OseeInfoDataAccessor();
- accessor.setLogger(new MockLog());
-
- accessor.putValue(SqlProvider.SQL_RECURSIVE_WITH_KEY, "dummy");
- }
-
- @org.junit.Test(expected = OseeStateException.class)
- public void testSetSQLRegExpPattern() throws OseeCoreException {
- OseeInfoDataAccessor accessor = new OseeInfoDataAccessor();
- accessor.setLogger(new MockLog());
-
- accessor.putValue(SqlProvider.SQL_REG_EXP_PATTERN_KEY, "dummy");
- }
-
- @org.junit.Test(expected = OseeStateException.class)
public void testSetCheckTagQueueOnStartupAllowed() throws OseeCoreException {
OseeInfoDataAccessor accessor = new OseeInfoDataAccessor();
accessor.setLogger(new MockLog());
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderFactoryImplTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderFactoryImplTest.java
index adacf50fb7..aa8e36c44e 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderFactoryImplTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderFactoryImplTest.java
@@ -30,7 +30,6 @@ import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
import org.eclipse.osee.framework.core.enums.DeletionFlag;
import org.eclipse.osee.framework.core.enums.LoadLevel;
-import org.eclipse.osee.framework.core.sql.OseeSql;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.jdbc.JdbcClient;
@@ -45,7 +44,6 @@ import org.eclipse.osee.orcs.core.ds.Options;
import org.eclipse.osee.orcs.core.ds.OptionsUtil;
import org.eclipse.osee.orcs.db.internal.IdentityManager;
import org.eclipse.osee.orcs.db.internal.OrcsObjectFactory;
-import org.eclipse.osee.orcs.db.internal.SqlProvider;
import org.eclipse.osee.orcs.db.internal.loader.criteria.CriteriaOrcsLoad;
import org.eclipse.osee.orcs.db.internal.sql.join.AbstractJoinQuery;
import org.eclipse.osee.orcs.db.internal.sql.join.ArtifactJoinQuery;
@@ -76,7 +74,6 @@ public class DataLoaderFactoryImplTest {
@Mock private JdbcStatement chStmt;
@Mock private IdentityManager identityService;
- @Mock private SqlProvider sqlProvider;
@Mock private LoadDataHandler builder;
@@ -106,14 +103,12 @@ public class DataLoaderFactoryImplTest {
String sessionId = GUID.create();
when(session.getGuid()).thenReturn(sessionId);
- LoaderModule module = new LoaderModule(logger, jdbcClient, identityService, sqlProvider, null, joinFactory);
+ LoaderModule module = new LoaderModule(logger, jdbcClient, identityService, null, joinFactory);
SqlObjectLoader loader = module.createSqlObjectLoader(rowDataFactory, null);
spyLoader = spy(loader);
factory = module.createDataLoaderFactory(spyLoader);
- when(sqlProvider.getSql(OseeSql.QUERY_BUILDER)).thenReturn("/*+ ordered */");
-
when(jdbcClient.getStatement()).thenReturn(chStmt);
when(jdbcClient.runPreparedQueryFetchObject(eq(-1), Matchers.anyString(), eq(COMMON_ID))).thenReturn(
EXPECTED_HEAD_TX_ID);
@@ -209,13 +204,13 @@ public class DataLoaderFactoryImplTest {
LoadLevel expectedLoadLevel = LoadLevel.ARTIFACT_DATA;
String expected =
"SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id, txs1.transaction_id as stripe_transaction_id,\n" + //
- " jart1.art_id, art1.art_type_id, art1.guid\n" + //
- " FROM \n" + //
- "osee_join_artifact jart1, osee_artifact art1, osee_txs txs1\n" + //
- " WHERE \n" + //
- "art1.art_id = jart1.art_id AND jart1.query_id = ? AND art1.gamma_id = txs1.gamma_id\n" + //
- " AND txs1.transaction_id <= jart1.transaction_id AND txs1.mod_type != 3 AND txs1.branch_id = jart1.branch_id\n" + //
- " ORDER BY txs1.branch_id, jart1.art_id, txs1.transaction_id desc";
+ " jart1.art_id, art1.art_type_id, art1.guid\n" + //
+ " FROM \n" + //
+ "osee_join_artifact jart1, osee_artifact art1, osee_txs txs1\n" + //
+ " WHERE \n" + //
+ "art1.art_id = jart1.art_id AND jart1.query_id = ? AND art1.gamma_id = txs1.gamma_id\n" + //
+ " AND txs1.transaction_id <= jart1.transaction_id AND txs1.mod_type != 3 AND txs1.branch_id = jart1.branch_id\n" + //
+ " ORDER BY txs1.branch_id, jart1.art_id, txs1.transaction_id desc";
DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3));
dataLoader.withLoadLevel(expectedLoadLevel);
@@ -233,13 +228,13 @@ public class DataLoaderFactoryImplTest {
LoadLevel expectedLoadLevel = LoadLevel.ARTIFACT_DATA;
String expected =
"SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id, txs1.transaction_id as stripe_transaction_id,\n" + //
- " jart1.art_id, art1.art_type_id, art1.guid\n" + //
- " FROM \n" + //
- "osee_join_artifact jart1, osee_artifact art1, osee_txs txs1\n" + //
- " WHERE \n" + //
- "art1.art_id = jart1.art_id AND jart1.query_id = ? AND art1.gamma_id = txs1.gamma_id\n" + //
- " AND txs1.transaction_id <= jart1.transaction_id AND txs1.branch_id = jart1.branch_id\n" + //
- " ORDER BY txs1.branch_id, jart1.art_id, txs1.transaction_id desc";
+ " jart1.art_id, art1.art_type_id, art1.guid\n" + //
+ " FROM \n" + //
+ "osee_join_artifact jart1, osee_artifact art1, osee_txs txs1\n" + //
+ " WHERE \n" + //
+ "art1.art_id = jart1.art_id AND jart1.query_id = ? AND art1.gamma_id = txs1.gamma_id\n" + //
+ " AND txs1.transaction_id <= jart1.transaction_id AND txs1.branch_id = jart1.branch_id\n" + //
+ " ORDER BY txs1.branch_id, jart1.art_id, txs1.transaction_id desc";
DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3));
dataLoader.withLoadLevel(expectedLoadLevel);
@@ -465,13 +460,13 @@ public class DataLoaderFactoryImplTest {
String expected =
"SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id, txs1.transaction_id as stripe_transaction_id,\n" + //
- " jart1.art_id, att1.attr_id, att1.attr_type_id, att1.value, att1.uri\n" + //
- " FROM \n" + //
- "osee_join_artifact jart1, osee_attribute att1, osee_txs txs1\n" + //
- " WHERE \n" + //
- "att1.art_id = jart1.art_id AND jart1.query_id = ? AND att1.gamma_id = txs1.gamma_id\n" + //
- " AND txs1.transaction_id <= jart1.transaction_id AND txs1.mod_type != 3 AND txs1.branch_id = jart1.branch_id\n" + //
- " ORDER BY txs1.branch_id, jart1.art_id, att1.attr_id, txs1.transaction_id desc";
+ " jart1.art_id, att1.attr_id, att1.attr_type_id, att1.value, att1.uri\n" + //
+ " FROM \n" + //
+ "osee_join_artifact jart1, osee_attribute att1, osee_txs txs1\n" + //
+ " WHERE \n" + //
+ "att1.art_id = jart1.art_id AND jart1.query_id = ? AND att1.gamma_id = txs1.gamma_id\n" + //
+ " AND txs1.transaction_id <= jart1.transaction_id AND txs1.mod_type != 3 AND txs1.branch_id = jart1.branch_id\n" + //
+ " ORDER BY txs1.branch_id, jart1.art_id, att1.attr_id, txs1.transaction_id desc";
DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3));
dataLoader.withLoadLevel(expectedLoadLevel);
@@ -490,13 +485,13 @@ public class DataLoaderFactoryImplTest {
String expected =
"SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id, txs1.transaction_id as stripe_transaction_id,\n" + //
- " jart1.art_id, att1.attr_id, att1.attr_type_id, att1.value, att1.uri\n" + //
- " FROM \n" + //
- "osee_join_artifact jart1, osee_attribute att1, osee_txs txs1\n" + //
- " WHERE \n" + //
- "att1.art_id = jart1.art_id AND jart1.query_id = ? AND att1.gamma_id = txs1.gamma_id\n" + //
- " AND txs1.transaction_id <= jart1.transaction_id AND txs1.branch_id = jart1.branch_id\n" + //
- " ORDER BY txs1.branch_id, jart1.art_id, att1.attr_id, txs1.transaction_id desc";
+ " jart1.art_id, att1.attr_id, att1.attr_type_id, att1.value, att1.uri\n" + //
+ " FROM \n" + //
+ "osee_join_artifact jart1, osee_attribute att1, osee_txs txs1\n" + //
+ " WHERE \n" + //
+ "att1.art_id = jart1.art_id AND jart1.query_id = ? AND att1.gamma_id = txs1.gamma_id\n" + //
+ " AND txs1.transaction_id <= jart1.transaction_id AND txs1.branch_id = jart1.branch_id\n" + //
+ " ORDER BY txs1.branch_id, jart1.art_id, att1.attr_id, txs1.transaction_id desc";
DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3));
dataLoader.withLoadLevel(expectedLoadLevel);
@@ -727,13 +722,13 @@ public class DataLoaderFactoryImplTest {
String expected =
"SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_id, txs1.app_id, txs1.transaction_id as stripe_transaction_id,\n" + //
- " jart1.art_id, rel1.rel_link_id, rel1.rel_link_type_id, rel1.a_art_id, rel1.b_art_id, rel1.rationale\n" + //
- " FROM \n" + //
- "osee_join_artifact jart1, osee_relation_link rel1, osee_txs txs1\n" + //
- " WHERE \n" + //
- "(rel1.a_art_id = jart1.art_id OR rel1.b_art_id = jart1.art_id) AND jart1.query_id = ? AND rel1.gamma_id = txs1.gamma_id\n" + //
- " AND txs1.transaction_id <= jart1.transaction_id AND txs1.mod_type != 3 AND txs1.branch_id = jart1.branch_id\n" + //
- " ORDER BY txs1.branch_id, jart1.art_id, rel1.rel_link_id, txs1.transaction_id desc";
+ " jart1.art_id, rel1.rel_link_id, rel1.rel_link_type_id, rel1.a_art_id, rel1.b_art_id, rel1.rationale\n" + //
+ " FROM \n" + //
+ "osee_join_artifact jart1, osee_relation_link rel1, osee_txs txs1\n" + //
+ " WHERE \n" + //
+ "(rel1.a_art_id = jart1.art_id OR rel1.b_art_id = jart1.art_id) AND jart1.query_id = ? AND rel1.gamma_id = txs1.gamma_id\n" + //
+ " AND txs1.transaction_id <= jart1.transaction_id AND txs1.mod_type != 3 AND txs1.branch_id = jart1.branch_id\n" + //
+ " ORDER BY txs1.branch_id, jart1.art_id, rel1.rel_link_id, txs1.transaction_id desc";
DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3));
dataLoader.withLoadLevel(expectedLoadLevel);
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContextFactoryImplTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContextFactoryImplTest.java
index 7fcd137830..a19cdee6b3 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContextFactoryImplTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContextFactoryImplTest.java
@@ -26,7 +26,6 @@ import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
import org.eclipse.osee.framework.core.enums.QueryOption;
-import org.eclipse.osee.framework.core.sql.OseeSql;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.logger.Log;
@@ -51,7 +50,6 @@ import org.eclipse.osee.orcs.core.ds.criteria.CriteriaRelationTypeNotExists;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaRelationTypeSideExists;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaRelationTypeSideNotExists;
import org.eclipse.osee.orcs.db.internal.IdentityLocator;
-import org.eclipse.osee.orcs.db.internal.SqlProvider;
import org.eclipse.osee.orcs.db.internal.search.QuerySqlContext;
import org.eclipse.osee.orcs.db.internal.search.QuerySqlContextFactory;
import org.eclipse.osee.orcs.db.internal.search.tagger.TagCollector;
@@ -73,7 +71,7 @@ import org.mockito.stubbing.Answer;
/**
* Test Case for {@link ArtifactQuerySqlContextFactoryImpl}
- *
+ *
* @author Roberto E. Escobar
*/
public class ArtifactQuerySqlContextFactoryImplTest {
@@ -113,10 +111,9 @@ public class ArtifactQuerySqlContextFactoryImplTest {
// @formatter:off
@Mock private Log logger;
- @Mock private SqlProvider sqlProvider;
@Mock private IdentityLocator identityService;
@Mock private TagProcessor tagProcessor;
-
+
@Mock private ExecutorAdmin executorAdmin;
@Mock private OrcsSession session;
@Mock private SqlJoinFactory joinFactory;
@@ -136,15 +133,13 @@ public class ArtifactQuerySqlContextFactoryImplTest {
when(session.getGuid()).thenReturn(sessionId);
SqlHandlerFactory handlerFactory = createArtifactSqlHandlerFactory(logger, identityService, tagProcessor);
- queryEngine = new ArtifactQuerySqlContextFactoryImpl(logger, joinFactory, sqlProvider, handlerFactory);
+ queryEngine = new ArtifactQuerySqlContextFactoryImpl(logger, joinFactory, null, handlerFactory);
CriteriaSet criteriaSet = new CriteriaSet();
Options options = OptionsUtil.createOptions();
criteriaSet.add(new CriteriaBranch(COMMON_ID));
queryData = new QueryData(criteriaSet, options);
- when(sqlProvider.getSql(OseeSql.QUERY_BUILDER)).thenReturn("/*+ ordered */");
-
doAnswer(new Answer<Void>() {
@Override
@@ -182,14 +177,14 @@ public class ArtifactQuerySqlContextFactoryImplTest {
@Test
public void testCount() throws Exception {
String expected = "SELECT/*+ ordered */ count(art2.art_id)\n" + //
- " FROM \n" + //
- "osee_join_id jid1, osee_artifact art1, osee_txs txs1, osee_join_char_id jch1, osee_artifact art2, osee_txs txs2\n" + //
- " WHERE \n" + //
- "art1.art_id = jid1.id AND jid1.query_id = ? AND art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
- " AND \n" + //
- "art2.guid = jch1.id AND jch1.query_id = ? AND art2.gamma_id = txs2.gamma_id AND txs2.tx_current = 1 AND txs2.branch_id = ?\n" + //
- " AND \n" + //
- "art1.art_type_id = ? AND art2.art_type_id = ?";
+ " FROM \n" + //
+ "osee_join_id jid1, osee_artifact art1, osee_txs txs1, osee_join_char_id jch1, osee_artifact art2, osee_txs txs2\n" + //
+ " WHERE \n" + //
+ "art1.art_id = jid1.id AND jid1.query_id = ? AND art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
+ " AND \n" + //
+ "art2.guid = jch1.id AND jch1.query_id = ? AND art2.gamma_id = txs2.gamma_id AND txs2.tx_current = 1 AND txs2.branch_id = ?\n" + //
+ " AND \n" + //
+ "art1.art_type_id = ? AND art2.art_type_id = ?";
queryData.addCriteria(GUIDS, IDS, TYPES);
@@ -214,15 +209,15 @@ public class ArtifactQuerySqlContextFactoryImplTest {
@Test
public void testCountHistorical() throws Exception {
String expected = "SELECT count(xTable.art_id) FROM (\n" + //
- " SELECT/*+ ordered */ max(txs1.transaction_id) as transaction_id, art1.art_id, txs1.branch_id\n" + //
- " FROM \n" + //
- "osee_artifact art1, osee_txs txs1\n" + //
- " WHERE \n" + //
- "art1.art_type_id = ? AND art1.gamma_id = txs1.gamma_id AND txs1.transaction_id <= ?\n" + //
- " AND \n" + //
- "txs1.mod_type <> 3 AND txs1.branch_id = ?\n" + //
- " GROUP BY art1.art_id, txs1.branch_id\n" + //
- ") xTable";
+ " SELECT/*+ ordered */ max(txs1.transaction_id) as transaction_id, art1.art_id, txs1.branch_id\n" + //
+ " FROM \n" + //
+ "osee_artifact art1, osee_txs txs1\n" + //
+ " WHERE \n" + //
+ "art1.art_type_id = ? AND art1.gamma_id = txs1.gamma_id AND txs1.transaction_id <= ?\n" + //
+ " AND \n" + //
+ "txs1.mod_type <> 3 AND txs1.branch_id = ?\n" + //
+ " GROUP BY art1.art_id, txs1.branch_id\n" + //
+ ") xTable";
OptionsUtil.setFromTransaction(queryData.getOptions(), EXPECTED_TX_ID);
queryData.addCriteria(TYPES);
@@ -246,15 +241,15 @@ public class ArtifactQuerySqlContextFactoryImplTest {
@Test
public void testQuery() throws Exception {
String expected = "SELECT/*+ ordered */ art2.art_id, txs2.branch_id\n" + //
- " FROM \n" + //
- "osee_join_id jid1, osee_artifact art1, osee_txs txs1, osee_join_char_id jch1, osee_artifact art2, osee_txs txs2\n" + //
- " WHERE \n" + //
- "art1.art_id = jid1.id AND jid1.query_id = ? AND art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
- " AND \n" + //
- "art2.guid = jch1.id AND jch1.query_id = ? AND art2.gamma_id = txs2.gamma_id AND txs2.tx_current = 1 AND txs2.branch_id = ?\n" + //
- " AND \n" + //
- "art1.art_type_id = ? AND art2.art_type_id = ?\n" + //
- " ORDER BY art2.art_id, txs2.branch_id";
+ " FROM \n" + //
+ "osee_join_id jid1, osee_artifact art1, osee_txs txs1, osee_join_char_id jch1, osee_artifact art2, osee_txs txs2\n" + //
+ " WHERE \n" + //
+ "art1.art_id = jid1.id AND jid1.query_id = ? AND art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
+ " AND \n" + //
+ "art2.guid = jch1.id AND jch1.query_id = ? AND art2.gamma_id = txs2.gamma_id AND txs2.tx_current = 1 AND txs2.branch_id = ?\n" + //
+ " AND \n" + //
+ "art1.art_type_id = ? AND art2.art_type_id = ?\n" + //
+ " ORDER BY art2.art_id, txs2.branch_id";
queryData.addCriteria(GUIDS, IDS, TYPES);
@@ -279,15 +274,15 @@ public class ArtifactQuerySqlContextFactoryImplTest {
@Test
public void testQuerySqlIncludeDeleted() throws OseeCoreException {
String expected = "SELECT/*+ ordered */ art2.art_id, txs2.branch_id\n" + //
- " FROM \n" + //
- "osee_join_id jid1, osee_artifact art1, osee_txs txs1, osee_join_char_id jch1, osee_artifact art2, osee_txs txs2\n" + //
- " WHERE \n" + //
- "art1.art_id = jid1.id AND jid1.query_id = ? AND art1.gamma_id = txs1.gamma_id AND txs1.tx_current IN (1, 2, 3) AND txs1.branch_id = ?\n" + //
- " AND \n" + //
- "art2.guid = jch1.id AND jch1.query_id = ? AND art2.gamma_id = txs2.gamma_id AND txs2.tx_current IN (1, 2, 3) AND txs2.branch_id = ?\n" + //
- " AND \n" + //
- "art1.art_type_id = ? AND art2.art_type_id = ?\n" + //
- " ORDER BY art2.art_id, txs2.branch_id";
+ " FROM \n" + //
+ "osee_join_id jid1, osee_artifact art1, osee_txs txs1, osee_join_char_id jch1, osee_artifact art2, osee_txs txs2\n" + //
+ " WHERE \n" + //
+ "art1.art_id = jid1.id AND jid1.query_id = ? AND art1.gamma_id = txs1.gamma_id AND txs1.tx_current IN (1, 2, 3) AND txs1.branch_id = ?\n" + //
+ " AND \n" + //
+ "art2.guid = jch1.id AND jch1.query_id = ? AND art2.gamma_id = txs2.gamma_id AND txs2.tx_current IN (1, 2, 3) AND txs2.branch_id = ?\n" + //
+ " AND \n" + //
+ "art1.art_type_id = ? AND art2.art_type_id = ?\n" + //
+ " ORDER BY art2.art_id, txs2.branch_id";
queryData.addCriteria(GUIDS, IDS, TYPES);
OptionsUtil.setIncludeDeletedArtifacts(queryData.getOptions(), true);
@@ -312,29 +307,29 @@ public class ArtifactQuerySqlContextFactoryImplTest {
@Test
public void testQueryHistorical() throws OseeCoreException {
String expected = "WITH artUuid1 AS ( \n" + //
- "SELECT max(txs.transaction_id) as transaction_id, art.art_id as art_id\n" + //
- " FROM osee_txs txs, osee_artifact art, osee_join_char_id id\n" + //
- " WHERE txs.gamma_id = art.gamma_id\n" + //
- " AND art.guid = id.id AND id.query_id = ? AND txs.transaction_id <= ? AND txs.branch_id = ?\n" + //
- " GROUP BY art.art_id\n" + //
- " )\n" + //
- "SELECT max(txs2.transaction_id) as transaction_id, art2.art_id, txs2.branch_id\n" + //
- " FROM \n" + //
- "osee_join_id jid1, osee_artifact art1, osee_txs txs1, osee_join_char_id jch1, osee_artifact art2, osee_txs txs2, artUuid1\n" + //
- " WHERE \n" + //
- "art1.art_id = jid1.id AND jid1.query_id = ? AND art1.gamma_id = txs1.gamma_id AND txs1.transaction_id <= ?\n" + //
- " AND \n" + //
- "txs1.mod_type <> 3 AND txs1.branch_id = ?\n" + //
- " AND \n" + //
- "art2.guid = jch1.id AND jch1.query_id = ?\n" + //
- " AND \n" + //
- "artUuid1.transaction_id = txs2.transaction_id AND artUuid1.art_id = art2.art_id AND art2.gamma_id = txs2.gamma_id AND txs2.transaction_id <= ?\n" + //
- " AND \n" + //"
- "txs2.mod_type <> 3 AND txs2.branch_id = ?\n" + //
- " AND \n" + //
- "art1.art_type_id = ? AND art2.art_type_id = ?\n" + //
- " GROUP BY art2.art_id, txs2.branch_id\n" + //
- " ORDER BY art2.art_id, txs2.branch_id";
+ "SELECT max(txs.transaction_id) as transaction_id, art.art_id as art_id\n" + //
+ " FROM osee_txs txs, osee_artifact art, osee_join_char_id id\n" + //
+ " WHERE txs.gamma_id = art.gamma_id\n" + //
+ " AND art.guid = id.id AND id.query_id = ? AND txs.transaction_id <= ? AND txs.branch_id = ?\n" + //
+ " GROUP BY art.art_id\n" + //
+ " )\n" + //
+ "SELECT max(txs2.transaction_id) as transaction_id, art2.art_id, txs2.branch_id\n" + //
+ " FROM \n" + //
+ "osee_join_id jid1, osee_artifact art1, osee_txs txs1, osee_join_char_id jch1, osee_artifact art2, osee_txs txs2, artUuid1\n" + //
+ " WHERE \n" + //
+ "art1.art_id = jid1.id AND jid1.query_id = ? AND art1.gamma_id = txs1.gamma_id AND txs1.transaction_id <= ?\n" + //
+ " AND \n" + //
+ "txs1.mod_type <> 3 AND txs1.branch_id = ?\n" + //
+ " AND \n" + //
+ "art2.guid = jch1.id AND jch1.query_id = ?\n" + //
+ " AND \n" + //
+ "artUuid1.transaction_id = txs2.transaction_id AND artUuid1.art_id = art2.art_id AND art2.gamma_id = txs2.gamma_id AND txs2.transaction_id <= ?\n" + //
+ " AND \n" + //"
+ "txs2.mod_type <> 3 AND txs2.branch_id = ?\n" + //
+ " AND \n" + //
+ "art1.art_type_id = ? AND art2.art_type_id = ?\n" + //
+ " GROUP BY art2.art_id, txs2.branch_id\n" + //
+ " ORDER BY art2.art_id, txs2.branch_id";
queryData.addCriteria(GUIDS, IDS, TYPES);
OptionsUtil.setFromTransaction(queryData.getOptions(), EXPECTED_TX_ID);
@@ -370,58 +365,58 @@ public class ArtifactQuerySqlContextFactoryImplTest {
@Test
public void testQueryHistoricalMultipleItems() throws OseeCoreException {
String expected = "WITH artUuid1 AS ( \n" + //
- "SELECT max(txs.transaction_id) as transaction_id, art.art_id as art_id\n" + //
- " FROM osee_txs txs, osee_artifact art, osee_join_char_id id\n" + //
- " WHERE txs.gamma_id = art.gamma_id\n" + //
- " AND art.guid = id.id AND id.query_id = ? AND txs.transaction_id <= ? AND txs.branch_id = ?\n" + //
- " GROUP BY art.art_id\n" + //
- " ), \n" + //
- " attrExt1 AS ( \n" + //
- "SELECT max(txs.transaction_id) as transaction_id, attr.art_id as art_id\n" + //
- " FROM osee_txs txs, osee_attribute attr\n" + //
- " WHERE txs.gamma_id = attr.gamma_id\n" + //
- " AND att.attr_type_id = ? AND txs.transaction_id <= ? AND txs.branch_id = ?\n" + //
- " GROUP BY attr.art_id\n" + //
- " )\n" + //
- "SELECT max(txs2.transaction_id) as transaction_id, art2.art_id, txs2.branch_id\n" + //
- " FROM \n" + //
- "osee_join_id jid1, osee_artifact art1, osee_txs txs1, osee_join_char_id jch1, osee_artifact art2, osee_txs txs2, osee_attribute att1, osee_txs txs3, osee_relation_link rel1, osee_txs txs4, artUuid1, attrExt1\n" + //
- " WHERE \n" + //
- "art1.art_id = jid1.id AND jid1.query_id = ? AND art1.gamma_id = txs1.gamma_id AND txs1.transaction_id <= ?\n" + //
- " AND \n" + //
- "txs1.mod_type <> 3 AND txs1.branch_id = ?\n" + //
- " AND \n" + //
- "art2.guid = jch1.id AND jch1.query_id = ?\n" + //
- " AND \n" + //
- "artUuid1.transaction_id = txs2.transaction_id AND artUuid1.art_id = art2.art_id AND art2.gamma_id = txs2.gamma_id AND txs2.transaction_id <= ?\n" + //
- " AND \n" + //
- "txs2.mod_type <> 3 AND txs2.branch_id = ?\n" + //
- " AND \n" + //
- "art1.art_type_id = ? AND art2.art_type_id = ?\n" + //
- " AND \n" + //
- "att1.attr_type_id = ?\n" + //
- " AND \n" + //
- "att1.art_id = art1.art_id AND att1.art_id = art2.art_id\n" + //
- " AND \n" + //
- "attrExt1.transaction_id = txs3.transaction_id AND attrExt1.art_id = att1.art_id\n" + //
- " AND \n" + //
- "att1.gamma_id = txs3.gamma_id AND txs3.transaction_id <= ?\n" + //
- " AND \n" + //
- "txs3.mod_type <> 3 AND txs3.branch_id = ?\n" + //
- " AND \n" + //
- "rel1.rel_link_type_id = ?\n" + //
- " AND \n" + //
- "(rel1.a_art_id = art1.art_id OR rel1.b_art_id = art1.art_id)\n" + //
- " AND \n" + //
- "(rel1.a_art_id = art2.art_id OR rel1.b_art_id = art2.art_id)\n" + //
- " AND \n" + //
- "rel1.gamma_id = txs4.gamma_id\n" + //
- " AND \n" + //
- "txs4.transaction_id <= ?\n" + //
- " AND \n" + //
- "txs4.mod_type <> 3 AND txs4.branch_id = ?\n" + //
- " GROUP BY art2.art_id, txs2.branch_id\n" + //
- " ORDER BY art2.art_id, txs2.branch_id";
+ "SELECT max(txs.transaction_id) as transaction_id, art.art_id as art_id\n" + //
+ " FROM osee_txs txs, osee_artifact art, osee_join_char_id id\n" + //
+ " WHERE txs.gamma_id = art.gamma_id\n" + //
+ " AND art.guid = id.id AND id.query_id = ? AND txs.transaction_id <= ? AND txs.branch_id = ?\n" + //
+ " GROUP BY art.art_id\n" + //
+ " ), \n" + //
+ " attrExt1 AS ( \n" + //
+ "SELECT max(txs.transaction_id) as transaction_id, attr.art_id as art_id\n" + //
+ " FROM osee_txs txs, osee_attribute attr\n" + //
+ " WHERE txs.gamma_id = attr.gamma_id\n" + //
+ " AND att.attr_type_id = ? AND txs.transaction_id <= ? AND txs.branch_id = ?\n" + //
+ " GROUP BY attr.art_id\n" + //
+ " )\n" + //
+ "SELECT max(txs2.transaction_id) as transaction_id, art2.art_id, txs2.branch_id\n" + //
+ " FROM \n" + //
+ "osee_join_id jid1, osee_artifact art1, osee_txs txs1, osee_join_char_id jch1, osee_artifact art2, osee_txs txs2, osee_attribute att1, osee_txs txs3, osee_relation_link rel1, osee_txs txs4, artUuid1, attrExt1\n" + //
+ " WHERE \n" + //
+ "art1.art_id = jid1.id AND jid1.query_id = ? AND art1.gamma_id = txs1.gamma_id AND txs1.transaction_id <= ?\n" + //
+ " AND \n" + //
+ "txs1.mod_type <> 3 AND txs1.branch_id = ?\n" + //
+ " AND \n" + //
+ "art2.guid = jch1.id AND jch1.query_id = ?\n" + //
+ " AND \n" + //
+ "artUuid1.transaction_id = txs2.transaction_id AND artUuid1.art_id = art2.art_id AND art2.gamma_id = txs2.gamma_id AND txs2.transaction_id <= ?\n" + //
+ " AND \n" + //
+ "txs2.mod_type <> 3 AND txs2.branch_id = ?\n" + //
+ " AND \n" + //
+ "art1.art_type_id = ? AND art2.art_type_id = ?\n" + //
+ " AND \n" + //
+ "att1.attr_type_id = ?\n" + //
+ " AND \n" + //
+ "att1.art_id = art1.art_id AND att1.art_id = art2.art_id\n" + //
+ " AND \n" + //
+ "attrExt1.transaction_id = txs3.transaction_id AND attrExt1.art_id = att1.art_id\n" + //
+ " AND \n" + //
+ "att1.gamma_id = txs3.gamma_id AND txs3.transaction_id <= ?\n" + //
+ " AND \n" + //
+ "txs3.mod_type <> 3 AND txs3.branch_id = ?\n" + //
+ " AND \n" + //
+ "rel1.rel_link_type_id = ?\n" + //
+ " AND \n" + //
+ "(rel1.a_art_id = art1.art_id OR rel1.b_art_id = art1.art_id)\n" + //
+ " AND \n" + //
+ "(rel1.a_art_id = art2.art_id OR rel1.b_art_id = art2.art_id)\n" + //
+ " AND \n" + //
+ "rel1.gamma_id = txs4.gamma_id\n" + //
+ " AND \n" + //
+ "txs4.transaction_id <= ?\n" + //
+ " AND \n" + //
+ "txs4.mod_type <> 3 AND txs4.branch_id = ?\n" + //
+ " GROUP BY art2.art_id, txs2.branch_id\n" + //
+ " ORDER BY art2.art_id, txs2.branch_id";
queryData.addCriteria(GUIDS, IDS, TYPES, ATTR_TYPE_EXITS, REL_TYPE_EXISTS);
OptionsUtil.setFromTransaction(queryData.getOptions(), EXPECTED_TX_ID);
@@ -466,11 +461,11 @@ public class ArtifactQuerySqlContextFactoryImplTest {
@Test
public void testQueryGuids() throws OseeCoreException {
String expected = "SELECT/*+ ordered */ art1.art_id, txs1.branch_id\n" + //
- " FROM \n" + //
- "osee_join_id jid1, osee_artifact art1, osee_txs txs1\n" + //
- " WHERE \n" + //
- "art1.art_id = jid1.id AND jid1.query_id = ? AND art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
- " ORDER BY art1.art_id, txs1.branch_id";
+ " FROM \n" + //
+ "osee_join_id jid1, osee_artifact art1, osee_txs txs1\n" + //
+ " WHERE \n" + //
+ "art1.art_id = jid1.id AND jid1.query_id = ? AND art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
+ " ORDER BY art1.art_id, txs1.branch_id";
queryData.addCriteria(IDS);
@@ -491,11 +486,11 @@ public class ArtifactQuerySqlContextFactoryImplTest {
@Test
public void testQueryArtifactTypes() throws OseeCoreException {
String expected = "SELECT/*+ ordered */ art1.art_id, txs1.branch_id\n" + //
- " FROM \n" + //
- "osee_artifact art1, osee_txs txs1\n" + //
- " WHERE \n" + //
- "art1.art_type_id = ? AND art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
- " ORDER BY art1.art_id, txs1.branch_id";
+ " FROM \n" + //
+ "osee_artifact art1, osee_txs txs1\n" + //
+ " WHERE \n" + //
+ "art1.art_type_id = ? AND art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
+ " ORDER BY art1.art_id, txs1.branch_id";
queryData.addCriteria(TYPES);
@@ -516,15 +511,15 @@ public class ArtifactQuerySqlContextFactoryImplTest {
@Test
public void testQueryAttribute() throws OseeCoreException {
String expected = "SELECT/*+ ordered */ art1.art_id, txs2.branch_id\n" + //
- " FROM \n" + //
- "osee_attribute att1, osee_txs txs1, osee_artifact art1, osee_txs txs2\n" + //
- " WHERE \n" + //
- "att1.attr_type_id = ? AND att1.value = ?\n" + //
- " AND \n" + //
- "art1.art_id = att1.art_id AND att1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
- " AND \n" + //
- "art1.gamma_id = txs2.gamma_id AND txs2.tx_current = 1 AND txs2.branch_id = ?\n" + //
- " ORDER BY art1.art_id, txs2.branch_id";
+ " FROM \n" + //
+ "osee_attribute att1, osee_txs txs1, osee_artifact art1, osee_txs txs2\n" + //
+ " WHERE \n" + //
+ "att1.attr_type_id = ? AND att1.value = ?\n" + //
+ " AND \n" + //
+ "art1.art_id = att1.art_id AND att1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
+ " AND \n" + //
+ "art1.gamma_id = txs2.gamma_id AND txs2.tx_current = 1 AND txs2.branch_id = ?\n" + //
+ " ORDER BY art1.art_id, txs2.branch_id";
queryData.addCriteria(ATTRIBUTE);
@@ -547,31 +542,31 @@ public class ArtifactQuerySqlContextFactoryImplTest {
@Test
public void testQueryAtttributeKeyword() throws OseeCoreException {
String expected = "WITH gamma1 AS ( \n" + //
- " ( \n" + //
- " SELECT gamma_id FROM osee_search_tags WHERE coded_tag_id = ?\n" + //
- " INTERSECT \n" + //
- " SELECT gamma_id FROM osee_search_tags WHERE coded_tag_id = ?\n" + //
- " INTERSECT \n" + //
- " SELECT gamma_id FROM osee_search_tags WHERE coded_tag_id = ?\n" + //
- " ) \n" + //
- " ), \n" + //
- " att1 AS ( \n" + //
- " SELECT art_id FROM osee_attribute att, osee_txs txs, osee_join_id jid1, gamma1\n" + //
- " WHERE \n" + //
- " att.gamma_id = gamma1.gamma_id AND att.attr_type_id = jid1.id AND jid1.query_id = ?\n" + //
- " AND \n" + //
- " att.gamma_id = txs.gamma_id AND txs.tx_current = 1 AND txs.branch_id = ?\n" + //
- " )\n" + //
- "SELECT art1.art_id, txs1.branch_id\n" + //
- " FROM \n" + //
- "osee_artifact art1, osee_txs txs1, att1\n" + //
- " WHERE \n" + //
- "art1.art_id = att1.art_id\n" + //
- " AND \n" + //
- "txs1.gamma_id = art1.gamma_id\n" + //
- " AND \n" + //
- "txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
- " ORDER BY art1.art_id, txs1.branch_id";
+ " ( \n" + //
+ " SELECT gamma_id FROM osee_search_tags WHERE coded_tag_id = ?\n" + //
+ " INTERSECT \n" + //
+ " SELECT gamma_id FROM osee_search_tags WHERE coded_tag_id = ?\n" + //
+ " INTERSECT \n" + //
+ " SELECT gamma_id FROM osee_search_tags WHERE coded_tag_id = ?\n" + //
+ " ) \n" + //
+ " ), \n" + //
+ " att1 AS ( \n" + //
+ " SELECT art_id FROM osee_attribute att, osee_txs txs, osee_join_id jid1, gamma1\n" + //
+ " WHERE \n" + //
+ " att.gamma_id = gamma1.gamma_id AND att.attr_type_id = jid1.id AND jid1.query_id = ?\n" + //
+ " AND \n" + //
+ " att.gamma_id = txs.gamma_id AND txs.tx_current = 1 AND txs.branch_id = ?\n" + //
+ " )\n" + //
+ "SELECT art1.art_id, txs1.branch_id\n" + //
+ " FROM \n" + //
+ "osee_artifact art1, osee_txs txs1, att1\n" + //
+ " WHERE \n" + //
+ "art1.art_id = att1.art_id\n" + //
+ " AND \n" + //
+ "txs1.gamma_id = art1.gamma_id\n" + //
+ " AND \n" + //
+ "txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
+ " ORDER BY art1.art_id, txs1.branch_id";
queryData.addCriteria(ATTRIBUTE_KEYWORD);
@@ -596,35 +591,35 @@ public class ArtifactQuerySqlContextFactoryImplTest {
@Test
public void testQueryAtttributeCombined() throws OseeCoreException {
String expected = "WITH gamma1 AS ( \n" + //
- " ( \n" + //
- " SELECT gamma_id FROM osee_search_tags WHERE coded_tag_id = ?\n" + //
- " INTERSECT \n" + //
- " SELECT gamma_id FROM osee_search_tags WHERE coded_tag_id = ?\n" + //
- " INTERSECT \n" + //
- " SELECT gamma_id FROM osee_search_tags WHERE coded_tag_id = ?\n" + //
- " ) \n" + //
- " ), \n" + //
- " att2 AS ( \n" + //
- " SELECT art_id FROM osee_attribute att, osee_txs txs, osee_join_id jid1, gamma1\n" + //
- " WHERE \n" + //
- " att.gamma_id = gamma1.gamma_id AND att.attr_type_id = jid1.id AND jid1.query_id = ?\n" + //
- " AND \n" + //
- " att.gamma_id = txs.gamma_id AND txs.tx_current = 1 AND txs.branch_id = ?\n" + //
- " )\n" + //
- "SELECT art1.art_id, txs2.branch_id\n" + //
- " FROM \n" + //
- "osee_attribute att1, osee_txs txs1, osee_artifact art1, osee_txs txs2, att2\n" + //
- " WHERE \n" + //
- "att1.attr_type_id = ? AND att1.value = ?\n" + //
- " AND \n" + //
- "art1.art_id = att1.art_id AND att1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
- " AND \n" + //
- "art1.gamma_id = txs2.gamma_id AND txs2.tx_current = 1 AND txs2.branch_id = ?\n" + //
- " AND \n" + //
- "art1.art_id = att2.art_id\n" + //
- " AND \n" + //
- "art1.art_type_id = ?\n" + //
- " ORDER BY art1.art_id, txs2.branch_id";
+ " ( \n" + //
+ " SELECT gamma_id FROM osee_search_tags WHERE coded_tag_id = ?\n" + //
+ " INTERSECT \n" + //
+ " SELECT gamma_id FROM osee_search_tags WHERE coded_tag_id = ?\n" + //
+ " INTERSECT \n" + //
+ " SELECT gamma_id FROM osee_search_tags WHERE coded_tag_id = ?\n" + //
+ " ) \n" + //
+ " ), \n" + //
+ " att2 AS ( \n" + //
+ " SELECT art_id FROM osee_attribute att, osee_txs txs, osee_join_id jid1, gamma1\n" + //
+ " WHERE \n" + //
+ " att.gamma_id = gamma1.gamma_id AND att.attr_type_id = jid1.id AND jid1.query_id = ?\n" + //
+ " AND \n" + //
+ " att.gamma_id = txs.gamma_id AND txs.tx_current = 1 AND txs.branch_id = ?\n" + //
+ " )\n" + //
+ "SELECT art1.art_id, txs2.branch_id\n" + //
+ " FROM \n" + //
+ "osee_attribute att1, osee_txs txs1, osee_artifact art1, osee_txs txs2, att2\n" + //
+ " WHERE \n" + //
+ "att1.attr_type_id = ? AND att1.value = ?\n" + //
+ " AND \n" + //
+ "art1.art_id = att1.art_id AND att1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
+ " AND \n" + //
+ "art1.gamma_id = txs2.gamma_id AND txs2.tx_current = 1 AND txs2.branch_id = ?\n" + //
+ " AND \n" + //
+ "art1.art_id = att2.art_id\n" + //
+ " AND \n" + //
+ "art1.art_type_id = ?\n" + //
+ " ORDER BY art1.art_id, txs2.branch_id";
queryData.addCriteria(ATTRIBUTE, ATTRIBUTE_KEYWORD, TYPES);
@@ -655,34 +650,34 @@ public class ArtifactQuerySqlContextFactoryImplTest {
public void testQueryExistsNoBranch() throws OseeCoreException {
String expected = "SELECT/*+ ordered */ art2.art_id, txs2.branch_id\n" + //
- " FROM \n" + //
- "osee_join_id jid1, osee_artifact art1, osee_txs txs1, " + //
- "osee_join_char_id jch1, osee_artifact art2, osee_txs txs2, " + //
- "osee_attribute att1, osee_txs txs3, " + //
- "osee_relation_link rel1, osee_txs txs4\n" + //
- " WHERE \n" + //
- "art1.art_id = jid1.id AND jid1.query_id = ? AND art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
- " AND \n" + //
- "art2.guid = jch1.id AND jch1.query_id = ? AND art2.gamma_id = txs2.gamma_id AND txs2.tx_current = 1 AND txs2.branch_id = ?\n" + //
- " AND \n" + //
- "art1.art_type_id = ? AND art2.art_type_id = ?\n" + //
- " AND \n" + //
- "att1.attr_type_id = ?\n" + //
- " AND \n" + //
- "att1.art_id = art1.art_id AND att1.art_id = art2.art_id\n" + //
- " AND \n" + //
- "att1.gamma_id = txs3.gamma_id AND txs3.tx_current = 1 AND txs3.branch_id = ?\n" + //
- " AND \n" + //
- "rel1.rel_link_type_id = ?\n" + //
- " AND \n" + //
- "(rel1.a_art_id = art1.art_id OR rel1.b_art_id = art1.art_id)\n" + //
- " AND \n" + //
- "(rel1.a_art_id = art2.art_id OR rel1.b_art_id = art2.art_id)\n" + //
- " AND \n" + //
- "rel1.gamma_id = txs4.gamma_id\n" + //
- " AND \n" + //
- "txs4.tx_current = 1 AND txs4.branch_id = ?\n" + //
- " ORDER BY art2.art_id, txs2.branch_id";
+ " FROM \n" + //
+ "osee_join_id jid1, osee_artifact art1, osee_txs txs1, " + //
+ "osee_join_char_id jch1, osee_artifact art2, osee_txs txs2, " + //
+ "osee_attribute att1, osee_txs txs3, " + //
+ "osee_relation_link rel1, osee_txs txs4\n" + //
+ " WHERE \n" + //
+ "art1.art_id = jid1.id AND jid1.query_id = ? AND art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
+ " AND \n" + //
+ "art2.guid = jch1.id AND jch1.query_id = ? AND art2.gamma_id = txs2.gamma_id AND txs2.tx_current = 1 AND txs2.branch_id = ?\n" + //
+ " AND \n" + //
+ "art1.art_type_id = ? AND art2.art_type_id = ?\n" + //
+ " AND \n" + //
+ "att1.attr_type_id = ?\n" + //
+ " AND \n" + //
+ "att1.art_id = art1.art_id AND att1.art_id = art2.art_id\n" + //
+ " AND \n" + //
+ "att1.gamma_id = txs3.gamma_id AND txs3.tx_current = 1 AND txs3.branch_id = ?\n" + //
+ " AND \n" + //
+ "rel1.rel_link_type_id = ?\n" + //
+ " AND \n" + //
+ "(rel1.a_art_id = art1.art_id OR rel1.b_art_id = art1.art_id)\n" + //
+ " AND \n" + //
+ "(rel1.a_art_id = art2.art_id OR rel1.b_art_id = art2.art_id)\n" + //
+ " AND \n" + //
+ "rel1.gamma_id = txs4.gamma_id\n" + //
+ " AND \n" + //
+ "txs4.tx_current = 1 AND txs4.branch_id = ?\n" + //
+ " ORDER BY art2.art_id, txs2.branch_id";
queryData.addCriteria(GUIDS, TYPES, REL_TYPE_EXISTS, IDS, ATTR_TYPE_EXITS);
@@ -709,34 +704,34 @@ public class ArtifactQuerySqlContextFactoryImplTest {
@Test
public void testQueryExistsWithBranch() throws OseeCoreException {
String expected = "SELECT/*+ ordered */ art2.art_id, txs2.branch_id\n" + //
- " FROM \n" + //
- "osee_join_id jid1, osee_artifact art1, osee_txs txs1, " + //
- "osee_join_char_id jch1, osee_artifact art2, osee_txs txs2, " + //
- "osee_attribute att1, osee_txs txs3, " + //
- "osee_relation_link rel1, osee_txs txs4\n" + //
- " WHERE \n" + //
- "art1.art_id = jid1.id AND jid1.query_id = ? AND art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
- " AND \n" + //
- "art2.guid = jch1.id AND jch1.query_id = ? AND art2.gamma_id = txs2.gamma_id AND txs2.tx_current = 1 AND txs2.branch_id = ?\n" + //
- " AND \n" + //
- "art1.art_type_id = ? AND art2.art_type_id = ?\n" + //
- " AND \n" + //
- "att1.attr_type_id = ?\n" + //
- " AND \n" + //
- "att1.art_id = art1.art_id AND att1.art_id = art2.art_id\n" + //
- " AND \n" + //
- "att1.gamma_id = txs3.gamma_id AND txs3.tx_current = 1 AND txs3.branch_id = ?\n" + //
- " AND \n" + //
- "rel1.rel_link_type_id = ?\n" + //
- " AND \n" + //
- "(rel1.a_art_id = art1.art_id OR rel1.b_art_id = art1.art_id)\n" + //
- " AND \n" + //
- "(rel1.a_art_id = art2.art_id OR rel1.b_art_id = art2.art_id)\n" + //
- " AND \n" + //
- "rel1.gamma_id = txs4.gamma_id\n" + //
- " AND \n" + //
- "txs4.tx_current = 1 AND txs4.branch_id = ?\n" + //
- " ORDER BY art2.art_id, txs2.branch_id";
+ " FROM \n" + //
+ "osee_join_id jid1, osee_artifact art1, osee_txs txs1, " + //
+ "osee_join_char_id jch1, osee_artifact art2, osee_txs txs2, " + //
+ "osee_attribute att1, osee_txs txs3, " + //
+ "osee_relation_link rel1, osee_txs txs4\n" + //
+ " WHERE \n" + //
+ "art1.art_id = jid1.id AND jid1.query_id = ? AND art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
+ " AND \n" + //
+ "art2.guid = jch1.id AND jch1.query_id = ? AND art2.gamma_id = txs2.gamma_id AND txs2.tx_current = 1 AND txs2.branch_id = ?\n" + //
+ " AND \n" + //
+ "art1.art_type_id = ? AND art2.art_type_id = ?\n" + //
+ " AND \n" + //
+ "att1.attr_type_id = ?\n" + //
+ " AND \n" + //
+ "att1.art_id = art1.art_id AND att1.art_id = art2.art_id\n" + //
+ " AND \n" + //
+ "att1.gamma_id = txs3.gamma_id AND txs3.tx_current = 1 AND txs3.branch_id = ?\n" + //
+ " AND \n" + //
+ "rel1.rel_link_type_id = ?\n" + //
+ " AND \n" + //
+ "(rel1.a_art_id = art1.art_id OR rel1.b_art_id = art1.art_id)\n" + //
+ " AND \n" + //
+ "(rel1.a_art_id = art2.art_id OR rel1.b_art_id = art2.art_id)\n" + //
+ " AND \n" + //
+ "rel1.gamma_id = txs4.gamma_id\n" + //
+ " AND \n" + //
+ "txs4.tx_current = 1 AND txs4.branch_id = ?\n" + //
+ " ORDER BY art2.art_id, txs2.branch_id";
queryData.addCriteria(GUIDS, TYPES, REL_TYPE_EXISTS, IDS, ATTR_TYPE_EXITS);
@@ -767,25 +762,25 @@ public class ArtifactQuerySqlContextFactoryImplTest {
@Test
public void testRelatedTo() throws OseeCoreException {
String expected = "SELECT/*+ ordered */ art2.art_id, txs2.branch_id\n" + //
- " FROM \n" + //
- "osee_join_id jid1, osee_artifact art1, osee_txs txs1, osee_join_char_id jch1, osee_artifact art2, osee_txs txs2, osee_join_id jid2, osee_relation_link rel1, osee_txs txs3\n" + //
- " WHERE \n" + //
- "art1.art_id = jid1.id AND jid1.query_id = ? AND art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
- " AND \n" + //
- "art2.guid = jch1.id AND jch1.query_id = ? AND art2.gamma_id = txs2.gamma_id AND txs2.tx_current = 1 AND txs2.branch_id = ?\n" + //
- " AND \n" + //
- "art1.art_type_id = ? AND art2.art_type_id = ?\n" + //
- " AND \n" + //
- "rel1.rel_link_type_id = ? AND rel1.b_art_id = jid2.id AND jid2.query_id = ?\n" + //
- " AND \n" + //
- "rel1.a_art_id = art1.art_id\n" + //
- " AND \n" + //
- "rel1.a_art_id = art2.art_id\n" + //
- " AND \n" + //
- "rel1.gamma_id = txs3.gamma_id\n" + //
- " AND \n" + //
- "txs3.tx_current = 1 AND txs3.branch_id = ?\n" + //
- " ORDER BY art2.art_id, txs2.branch_id";
+ " FROM \n" + //
+ "osee_join_id jid1, osee_artifact art1, osee_txs txs1, osee_join_char_id jch1, osee_artifact art2, osee_txs txs2, osee_join_id jid2, osee_relation_link rel1, osee_txs txs3\n" + //
+ " WHERE \n" + //
+ "art1.art_id = jid1.id AND jid1.query_id = ? AND art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
+ " AND \n" + //
+ "art2.guid = jch1.id AND jch1.query_id = ? AND art2.gamma_id = txs2.gamma_id AND txs2.tx_current = 1 AND txs2.branch_id = ?\n" + //
+ " AND \n" + //
+ "art1.art_type_id = ? AND art2.art_type_id = ?\n" + //
+ " AND \n" + //
+ "rel1.rel_link_type_id = ? AND rel1.b_art_id = jid2.id AND jid2.query_id = ?\n" + //
+ " AND \n" + //
+ "rel1.a_art_id = art1.art_id\n" + //
+ " AND \n" + //
+ "rel1.a_art_id = art2.art_id\n" + //
+ " AND \n" + //
+ "rel1.gamma_id = txs3.gamma_id\n" + //
+ " AND \n" + //
+ "txs3.tx_current = 1 AND txs3.branch_id = ?\n" + //
+ " ORDER BY art2.art_id, txs2.branch_id";
queryData.addCriteria(GUIDS, TYPES, IDS, RELATED_TO);
@@ -814,10 +809,10 @@ public class ArtifactQuerySqlContextFactoryImplTest {
@Test
public void testCountAllArtifactsFromBranch() throws OseeCoreException {
String expected = "SELECT/*+ ordered */ count(art1.art_id)\n" + //
- " FROM \n" + //
- "osee_artifact art1, osee_txs txs1\n" + //
- " WHERE \n" + //
- "art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?";
+ " FROM \n" + //
+ "osee_artifact art1, osee_txs txs1\n" + //
+ " WHERE \n" + //
+ "art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?";
queryData.addCriteria(ALL_ARTIFACTS);
@@ -837,15 +832,15 @@ public class ArtifactQuerySqlContextFactoryImplTest {
@Test
public void testCountAllArtifactsFromBranchHistorical() throws OseeCoreException {
String expected = "SELECT count(xTable.art_id) FROM (\n" + //
- " SELECT/*+ ordered */ max(txs1.transaction_id) as transaction_id, art1.art_id, txs1.branch_id\n" + //
- " FROM \n" + //
- "osee_artifact art1, osee_txs txs1\n" + //
- " WHERE \n" + //
- "art1.gamma_id = txs1.gamma_id AND txs1.transaction_id <= ?\n" + //
- " AND \n" + //
- "txs1.mod_type <> 3 AND txs1.branch_id = ?\n" + //
- " GROUP BY art1.art_id, txs1.branch_id\n" + //
- ") xTable";
+ " SELECT/*+ ordered */ max(txs1.transaction_id) as transaction_id, art1.art_id, txs1.branch_id\n" + //
+ " FROM \n" + //
+ "osee_artifact art1, osee_txs txs1\n" + //
+ " WHERE \n" + //
+ "art1.gamma_id = txs1.gamma_id AND txs1.transaction_id <= ?\n" + //
+ " AND \n" + //
+ "txs1.mod_type <> 3 AND txs1.branch_id = ?\n" + //
+ " GROUP BY art1.art_id, txs1.branch_id\n" + //
+ ") xTable";
OptionsUtil.setFromTransaction(queryData.getOptions(), EXPECTED_TX_ID);
queryData.addCriteria(ALL_ARTIFACTS);
@@ -867,11 +862,11 @@ public class ArtifactQuerySqlContextFactoryImplTest {
@Test
public void testQueryAllArtifactsFromBranch() throws OseeCoreException {
String expected = "SELECT/*+ ordered */ art1.art_id, txs1.branch_id\n" + //
- " FROM \n" + //
- "osee_artifact art1, osee_txs txs1\n" + //
- " WHERE \n" + //
- "art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
- " ORDER BY art1.art_id, txs1.branch_id";
+ " FROM \n" + //
+ "osee_artifact art1, osee_txs txs1\n" + //
+ " WHERE \n" + //
+ "art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
+ " ORDER BY art1.art_id, txs1.branch_id";
queryData.addCriteria(ALL_ARTIFACTS);
@@ -892,14 +887,14 @@ public class ArtifactQuerySqlContextFactoryImplTest {
public void testQueryAllArtifactsFromBranchHistorical() throws OseeCoreException {
String expected =
"SELECT/*+ ordered */ max(txs1.transaction_id) as transaction_id, art1.art_id, txs1.branch_id\n" + //
- " FROM \n" + //
- "osee_artifact art1, osee_txs txs1\n" + //
- " WHERE \n" + //
- "art1.gamma_id = txs1.gamma_id AND txs1.transaction_id <= ?\n" + //
- " AND \n" + //
- "txs1.mod_type <> 3 AND txs1.branch_id = ?\n" + //
- " GROUP BY art1.art_id, txs1.branch_id\n" + //
- " ORDER BY art1.art_id, txs1.branch_id";
+ " FROM \n" + //
+ "osee_artifact art1, osee_txs txs1\n" + //
+ " WHERE \n" + //
+ "art1.gamma_id = txs1.gamma_id AND txs1.transaction_id <= ?\n" + //
+ " AND \n" + //
+ "txs1.mod_type <> 3 AND txs1.branch_id = ?\n" + //
+ " GROUP BY art1.art_id, txs1.branch_id\n" + //
+ " ORDER BY art1.art_id, txs1.branch_id";
OptionsUtil.setFromTransaction(queryData.getOptions(), EXPECTED_TX_ID);
queryData.addCriteria(ALL_ARTIFACTS);
@@ -921,11 +916,11 @@ public class ArtifactQuerySqlContextFactoryImplTest {
@Test
public void testAllArtifactWithOtherCriteria() throws OseeCoreException {
String expected = "SELECT/*+ ordered */ art1.art_id, txs1.branch_id\n" + //
- " FROM \n" + //
- "osee_join_id jid1, osee_artifact art1, osee_txs txs1\n" + //
- " WHERE \n" + //
- "art1.art_id = jid1.id AND jid1.query_id = ? AND art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
- " ORDER BY art1.art_id, txs1.branch_id";
+ " FROM \n" + //
+ "osee_join_id jid1, osee_artifact art1, osee_txs txs1\n" + //
+ " WHERE \n" + //
+ "art1.art_id = jid1.id AND jid1.query_id = ? AND art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
+ " ORDER BY art1.art_id, txs1.branch_id";
queryData.addCriteria(ALL_ARTIFACTS, IDS);
@@ -946,19 +941,19 @@ public class ArtifactQuerySqlContextFactoryImplTest {
@Test
public void testRelationTypeNotExists() throws OseeCoreException {
String expected = "SELECT/*+ ordered */ art1.art_id, txs1.branch_id\n" + //
- " FROM \n" + //
- "osee_artifact art1, osee_txs txs1\n" + //
- " WHERE \n" + //
- "art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
- " AND \n" + //
- "NOT EXISTS (SELECT 1 FROM osee_relation_link rel, osee_txs txs WHERE rel.rel_link_type_id = ?\n" + //
- " AND \n" + //
- "(rel.a_art_id = art1.art_id OR rel.b_art_id = art1.art_id)\n" + //
- " AND \n" + //
- "rel.gamma_id = txs.gamma_id\n" + //
- " AND \n" + //
- "txs.tx_current = 1 AND txs.branch_id = ?)\n" + //
- " ORDER BY art1.art_id, txs1.branch_id";
+ " FROM \n" + //
+ "osee_artifact art1, osee_txs txs1\n" + //
+ " WHERE \n" + //
+ "art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
+ " AND \n" + //
+ "NOT EXISTS (SELECT 1 FROM osee_relation_link rel, osee_txs txs WHERE rel.rel_link_type_id = ?\n" + //
+ " AND \n" + //
+ "(rel.a_art_id = art1.art_id OR rel.b_art_id = art1.art_id)\n" + //
+ " AND \n" + //
+ "rel.gamma_id = txs.gamma_id\n" + //
+ " AND \n" + //
+ "txs.tx_current = 1 AND txs.branch_id = ?)\n" + //
+ " ORDER BY art1.art_id, txs1.branch_id";
Criteria relTypeNotExists = new CriteriaRelationTypeNotExists(CoreRelationTypes.Default_Hierarchical__Child);
queryData.addCriteria(relTypeNotExists);
@@ -976,19 +971,19 @@ public class ArtifactQuerySqlContextFactoryImplTest {
@Test
public void testRelationTypeSideNotExists() throws OseeCoreException {
String expected = "SELECT/*+ ordered */ art1.art_id, txs1.branch_id\n" + //
- " FROM \n" + //
- "osee_artifact art1, osee_txs txs1\n" + //
- " WHERE \n" + //
- "art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
- " AND \n" + //
- "NOT EXISTS (SELECT 1 FROM osee_relation_link rel, osee_txs txs WHERE rel.rel_link_type_id = ?\n" + //
- " AND \n" + //
- "rel.b_art_id = art1.art_id\n" + //
- " AND \n" + //
- "rel.gamma_id = txs.gamma_id\n" + //
- " AND \n" + //
- "txs.tx_current = 1 AND txs.branch_id = ?)\n" + //
- " ORDER BY art1.art_id, txs1.branch_id";
+ " FROM \n" + //
+ "osee_artifact art1, osee_txs txs1\n" + //
+ " WHERE \n" + //
+ "art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
+ " AND \n" + //
+ "NOT EXISTS (SELECT 1 FROM osee_relation_link rel, osee_txs txs WHERE rel.rel_link_type_id = ?\n" + //
+ " AND \n" + //
+ "rel.b_art_id = art1.art_id\n" + //
+ " AND \n" + //
+ "rel.gamma_id = txs.gamma_id\n" + //
+ " AND \n" + //
+ "txs.tx_current = 1 AND txs.branch_id = ?)\n" + //
+ " ORDER BY art1.art_id, txs1.branch_id";
Criteria relTypeSideNotExists =
new CriteriaRelationTypeSideNotExists(CoreRelationTypes.Default_Hierarchical__Child);
@@ -1007,19 +1002,19 @@ public class ArtifactQuerySqlContextFactoryImplTest {
@Test
public void testRelationTypeSideExists() throws OseeCoreException {
String expected = "SELECT/*+ ordered */ art1.art_id, txs1.branch_id\n" + //
- " FROM \n" + //
- "osee_artifact art1, osee_txs txs1, osee_relation_link rel1, osee_txs txs2\n" + //
- " WHERE \n" + //
- "art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
- " AND \n" + //
- "rel1.rel_link_type_id = ?\n" + //
- " AND \n" + //
- "rel1.b_art_id = art1.art_id\n" + //
- " AND \n" + //
- "rel1.gamma_id = txs2.gamma_id\n" + //
- " AND \n" + //
- "txs2.tx_current = 1 AND txs2.branch_id = ?\n" + //
- " ORDER BY art1.art_id, txs1.branch_id";
+ " FROM \n" + //
+ "osee_artifact art1, osee_txs txs1, osee_relation_link rel1, osee_txs txs2\n" + //
+ " WHERE \n" + //
+ "art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
+ " AND \n" + //
+ "rel1.rel_link_type_id = ?\n" + //
+ " AND \n" + //
+ "rel1.b_art_id = art1.art_id\n" + //
+ " AND \n" + //
+ "rel1.gamma_id = txs2.gamma_id\n" + //
+ " AND \n" + //
+ "txs2.tx_current = 1 AND txs2.branch_id = ?\n" + //
+ " ORDER BY art1.art_id, txs1.branch_id";
Criteria relTypeSideNotExists = new CriteriaRelationTypeSideExists(CoreRelationTypes.Default_Hierarchical__Child);
queryData.addCriteria(relTypeSideNotExists);
@@ -1037,15 +1032,15 @@ public class ArtifactQuerySqlContextFactoryImplTest {
@Test
public void testRelationTypeFollow() throws OseeCoreException {
String expected = "SELECT/*+ ordered */ art2.art_id, txs3.branch_id\n" + //
- " FROM \n" + //
- "osee_artifact art1, osee_txs txs1, osee_relation_link rel1, osee_txs txs2, osee_artifact art2, osee_txs txs3\n" + //
- " WHERE \n" + //
- "art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
- " AND \n" + //
- "rel1.rel_link_type_id = ? AND rel1.a_art_id = art1.art_id AND rel1.gamma_id = txs2.gamma_id AND txs2.tx_current = 1 AND txs2.branch_id = ?\n" + //
- " AND \n" + //
- "rel1.b_art_id = art2.art_id AND art2.gamma_id = txs3.gamma_id AND txs3.tx_current = 1 AND txs3.branch_id = ?\n" + //
- " ORDER BY art2.art_id, txs3.branch_id";
+ " FROM \n" + //
+ "osee_artifact art1, osee_txs txs1, osee_relation_link rel1, osee_txs txs2, osee_artifact art2, osee_txs txs3\n" + //
+ " WHERE \n" + //
+ "art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
+ " AND \n" + //
+ "rel1.rel_link_type_id = ? AND rel1.a_art_id = art1.art_id AND rel1.gamma_id = txs2.gamma_id AND txs2.tx_current = 1 AND txs2.branch_id = ?\n" + //
+ " AND \n" + //
+ "rel1.b_art_id = art2.art_id AND art2.gamma_id = txs3.gamma_id AND txs3.tx_current = 1 AND txs3.branch_id = ?\n" + //
+ " ORDER BY art2.art_id, txs3.branch_id";
queryData.addCriteria(FOLLOW_RELATION_TYPE);
@@ -1068,33 +1063,33 @@ public class ArtifactQuerySqlContextFactoryImplTest {
@Test
public void testRelationTypeFollowCombined() throws OseeCoreException {
String expected = "WITH gamma1 AS ( \n" + //
- " ( \n" + //
- " SELECT gamma_id FROM osee_search_tags WHERE coded_tag_id = ?\n" + //
- " INTERSECT \n" + //
- " SELECT gamma_id FROM osee_search_tags WHERE coded_tag_id = ?\n" + //
- " INTERSECT \n" + //
- " SELECT gamma_id FROM osee_search_tags WHERE coded_tag_id = ?\n" + //
- " ) \n" + //
- " ), \n" + //
- " att1 AS ( \n" + //
- " SELECT art_id FROM osee_attribute att, osee_txs txs, osee_join_id jid1, gamma1\n" + //
- " WHERE \n" + //
- " att.gamma_id = gamma1.gamma_id AND att.attr_type_id = jid1.id AND jid1.query_id = ?\n" + //
- " AND \n" + //
- " att.gamma_id = txs.gamma_id AND txs.tx_current = 1 AND txs.branch_id = ?\n" + //
- " )\n" + //
- "SELECT art2.art_id, txs3.branch_id\n" + //
- " FROM \n" + //
- "osee_join_char_id jch1, osee_artifact art1, osee_txs txs1, osee_relation_link rel1, osee_txs txs2, osee_artifact art2, osee_txs txs3, att1\n" + //
- " WHERE \n" + //
- "art1.guid = jch1.id AND jch1.query_id = ? AND art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
- " AND \n" + //
- "art1.art_id = att1.art_id\n" + //
- " AND \n" + //
- "rel1.rel_link_type_id = ? AND rel1.a_art_id = art1.art_id AND rel1.gamma_id = txs2.gamma_id AND txs2.tx_current = 1 AND txs2.branch_id = ?\n" + //
- " AND \n" + //
- "rel1.b_art_id = art2.art_id AND art2.gamma_id = txs3.gamma_id AND txs3.tx_current = 1 AND txs3.branch_id = ?\n" + //
- " ORDER BY art2.art_id, txs3.branch_id";
+ " ( \n" + //
+ " SELECT gamma_id FROM osee_search_tags WHERE coded_tag_id = ?\n" + //
+ " INTERSECT \n" + //
+ " SELECT gamma_id FROM osee_search_tags WHERE coded_tag_id = ?\n" + //
+ " INTERSECT \n" + //
+ " SELECT gamma_id FROM osee_search_tags WHERE coded_tag_id = ?\n" + //
+ " ) \n" + //
+ " ), \n" + //
+ " att1 AS ( \n" + //
+ " SELECT art_id FROM osee_attribute att, osee_txs txs, osee_join_id jid1, gamma1\n" + //
+ " WHERE \n" + //
+ " att.gamma_id = gamma1.gamma_id AND att.attr_type_id = jid1.id AND jid1.query_id = ?\n" + //
+ " AND \n" + //
+ " att.gamma_id = txs.gamma_id AND txs.tx_current = 1 AND txs.branch_id = ?\n" + //
+ " )\n" + //
+ "SELECT art2.art_id, txs3.branch_id\n" + //
+ " FROM \n" + //
+ "osee_join_char_id jch1, osee_artifact art1, osee_txs txs1, osee_relation_link rel1, osee_txs txs2, osee_artifact art2, osee_txs txs3, att1\n" + //
+ " WHERE \n" + //
+ "art1.guid = jch1.id AND jch1.query_id = ? AND art1.gamma_id = txs1.gamma_id AND txs1.tx_current = 1 AND txs1.branch_id = ?\n" + //
+ " AND \n" + //
+ "art1.art_id = att1.art_id\n" + //
+ " AND \n" + //
+ "rel1.rel_link_type_id = ? AND rel1.a_art_id = art1.art_id AND rel1.gamma_id = txs2.gamma_id AND txs2.tx_current = 1 AND txs2.branch_id = ?\n" + //
+ " AND \n" + //
+ "rel1.b_art_id = art2.art_id AND art2.gamma_id = txs3.gamma_id AND txs3.tx_current = 1 AND txs3.branch_id = ?\n" + //
+ " ORDER BY art2.art_id, txs3.branch_id";
queryData.addCriteria(ATTRIBUTE_KEYWORD, FOLLOW_RELATION_TYPE, GUIDS);
@@ -1125,22 +1120,22 @@ public class ArtifactQuerySqlContextFactoryImplTest {
public void testRelationTypeFollowHistorical() throws OseeCoreException {
String expected =
"SELECT/*+ ordered */ max(txs3.transaction_id) as transaction_id, art2.art_id, txs3.branch_id\n" + //
- " FROM \n" + //
- "osee_artifact art1, osee_txs txs1, osee_relation_link rel1, osee_txs txs2, osee_artifact art2, osee_txs txs3\n" + //
- " WHERE \n" + //
- "art1.gamma_id = txs1.gamma_id AND txs1.transaction_id <= ?\n" + //
- " AND \n" + //
- "txs1.mod_type <> 3 AND txs1.branch_id = ?\n" + //
- " AND \n" + //
- "rel1.rel_link_type_id = ? AND rel1.a_art_id = art1.art_id AND rel1.gamma_id = txs2.gamma_id AND txs2.transaction_id <= ?\n" + //
- " AND \n" + //
- "txs2.mod_type <> 3 AND txs2.branch_id = ?\n" + //
- " AND \n" + //
- "rel1.b_art_id = art2.art_id AND art2.gamma_id = txs3.gamma_id AND txs3.transaction_id <= ?\n" + //
- " AND \n" + //
- "txs3.mod_type <> 3 AND txs3.branch_id = ?\n" + //
- " GROUP BY art2.art_id, txs3.branch_id\n" + //
- " ORDER BY art2.art_id, txs3.branch_id";
+ " FROM \n" + //
+ "osee_artifact art1, osee_txs txs1, osee_relation_link rel1, osee_txs txs2, osee_artifact art2, osee_txs txs3\n" + //
+ " WHERE \n" + //
+ "art1.gamma_id = txs1.gamma_id AND txs1.transaction_id <= ?\n" + //
+ " AND \n" + //
+ "txs1.mod_type <> 3 AND txs1.branch_id = ?\n" + //
+ " AND \n" + //
+ "rel1.rel_link_type_id = ? AND rel1.a_art_id = art1.art_id AND rel1.gamma_id = txs2.gamma_id AND txs2.transaction_id <= ?\n" + //
+ " AND \n" + //
+ "txs2.mod_type <> 3 AND txs2.branch_id = ?\n" + //
+ " AND \n" + //
+ "rel1.b_art_id = art2.art_id AND art2.gamma_id = txs3.gamma_id AND txs3.transaction_id <= ?\n" + //
+ " AND \n" + //
+ "txs3.mod_type <> 3 AND txs3.branch_id = ?\n" + //
+ " GROUP BY art2.art_id, txs3.branch_id\n" + //
+ " ORDER BY art2.art_id, txs3.branch_id";
OptionsUtil.setFromTransaction(queryData.getOptions(), EXPECTED_TX_ID);
queryData.addCriteria(FOLLOW_RELATION_TYPE);
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/BranchQuerySqlContextFactoryImplTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/BranchQuerySqlContextFactoryImplTest.java
index 5a417c1e82..d1d1058bc0 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/BranchQuerySqlContextFactoryImplTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/BranchQuerySqlContextFactoryImplTest.java
@@ -27,9 +27,10 @@ import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.core.enums.BranchArchivedState;
import org.eclipse.osee.framework.core.enums.BranchState;
import org.eclipse.osee.framework.core.enums.BranchType;
-import org.eclipse.osee.framework.core.sql.OseeSql;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.GUID;
+import org.eclipse.osee.jdbc.JdbcClient;
+import org.eclipse.osee.jdbc.JdbcDbType;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.OrcsSession;
import org.eclipse.osee.orcs.core.ds.Criteria;
@@ -48,7 +49,6 @@ import org.eclipse.osee.orcs.core.ds.criteria.CriteriaBranchType;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaBranchUuids;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaMergeBranchFor;
import org.eclipse.osee.orcs.db.internal.IdentityLocator;
-import org.eclipse.osee.orcs.db.internal.SqlProvider;
import org.eclipse.osee.orcs.db.internal.search.Engines;
import org.eclipse.osee.orcs.db.internal.search.QuerySqlContext;
import org.eclipse.osee.orcs.db.internal.search.QuerySqlContextFactory;
@@ -64,7 +64,7 @@ import org.mockito.stubbing.Answer;
/**
* Test Case for {@link QuerySqlContextFactoryImpl}
- *
+ *
* @author Roberto E. Escobar
*/
public class BranchQuerySqlContextFactoryImplTest {
@@ -80,11 +80,10 @@ public class BranchQuerySqlContextFactoryImplTest {
// @formatter:off
@Mock private Log logger;
- @Mock private SqlProvider sqlProvider;
+ @Mock private SqlJoinFactory joinFactory;
@Mock private IdentityLocator identityService;
-
+ @Mock private JdbcClient jdbcClient;
@Mock private OrcsSession session;
- @Mock private SqlJoinFactory joinFactory;
// @formatter:on
private QuerySqlContextFactory queryEngine;
@@ -94,16 +93,14 @@ public class BranchQuerySqlContextFactoryImplTest {
public void setUp() throws OseeCoreException {
MockitoAnnotations.initMocks(this);
- String sessionId = GUID.create();
- when(session.getGuid()).thenReturn(sessionId);
-
- queryEngine = Engines.newBranchSqlContextFactory(logger, joinFactory, identityService, sqlProvider);
+ when(session.getGuid()).thenReturn(GUID.create());
+ queryEngine = Engines.newBranchSqlContextFactory(logger, joinFactory, identityService, jdbcClient);
+ when(jdbcClient.getDbType()).thenReturn(JdbcDbType.hsql);
CriteriaSet criteriaSet = new CriteriaSet();
Options options = OptionsUtil.createBranchOptions();
queryData = new QueryData(criteriaSet, options);
- when(sqlProvider.getSql(OseeSql.QUERY_BUILDER)).thenReturn("/*+ ordered */");
when(joinFactory.createIdJoinQuery()).thenAnswer(new Answer<IdJoinQuery>() {
@Override
@@ -117,12 +114,12 @@ public class BranchQuerySqlContextFactoryImplTest {
@Test
public void testCount() throws Exception {
String expected = "SELECT/*+ ordered */ count(br1.branch_id)\n" + //
- " FROM \n" + //
- "osee_join_id jid1, osee_branch br1, osee_join_id jid2\n" + //
- " WHERE \n" + //
- "br1.branch_id = jid1.id AND jid1.query_id = ?\n" + //
- " AND \n" + //
- "br1.branch_type = jid2.id AND jid2.query_id = ?";
+ " FROM \n" + //
+ "osee_join_id jid1, osee_branch br1, osee_join_id jid2\n" + //
+ " WHERE \n" + //
+ "br1.branch_id = jid1.id AND jid1.query_id = ?\n" + //
+ " AND \n" + //
+ "br1.branch_type = jid2.id AND jid2.query_id = ?";
queryData.addCriteria(UUIDS, TYPES);
@@ -145,13 +142,13 @@ public class BranchQuerySqlContextFactoryImplTest {
@Test
public void testQueryUuidIdsTypes() throws Exception {
String expected = "SELECT/*+ ordered */ br1.*\n" + //
- " FROM \n" + //
- "osee_join_id jid1, osee_branch br1, osee_join_id jid2\n" + //
- " WHERE \n" + //
- "br1.branch_id = jid1.id AND jid1.query_id = ?\n" + //
- " AND \n" + //
- "br1.branch_type = jid2.id AND jid2.query_id = ?\n" + //
- " ORDER BY br1.branch_id";
+ " FROM \n" + //
+ "osee_join_id jid1, osee_branch br1, osee_join_id jid2\n" + //
+ " WHERE \n" + //
+ "br1.branch_id = jid1.id AND jid1.query_id = ?\n" + //
+ " AND \n" + //
+ "br1.branch_type = jid2.id AND jid2.query_id = ?\n" + //
+ " ORDER BY br1.branch_id";
queryData.addCriteria(UUIDS, TYPES);
@@ -174,9 +171,9 @@ public class BranchQuerySqlContextFactoryImplTest {
@Test
public void testQueryAllBranches() throws Exception {
String expected = "SELECT/*+ ordered */ br1.*\n" + //
- " FROM \n" + //
- "osee_branch br1\n" + //
- " ORDER BY br1.branch_id";
+ " FROM \n" + //
+ "osee_branch br1\n" + //
+ " ORDER BY br1.branch_id";
queryData.addCriteria(ALL_BRANCHES);
@@ -193,13 +190,13 @@ public class BranchQuerySqlContextFactoryImplTest {
@Test
public void testQueryUuidIdsTypesSingles() throws Exception {
String expected = "SELECT/*+ ordered */ br1.*\n" + //
- " FROM \n" + //
- "osee_branch br1\n" + //
- " WHERE \n" + //
- "br1.branch_id = ?\n" + //
- " AND \n" + //
- "br1.branch_type = ?\n" + //
- " ORDER BY br1.branch_id";
+ " FROM \n" + //
+ "osee_branch br1\n" + //
+ " WHERE \n" + //
+ "br1.branch_id = ?\n" + //
+ " AND \n" + //
+ "br1.branch_type = ?\n" + //
+ " ORDER BY br1.branch_id";
queryData.addCriteria(uuid(2L), type(SYSTEM_ROOT));
@@ -220,11 +217,11 @@ public class BranchQuerySqlContextFactoryImplTest {
@Test
public void testQueryName() throws Exception {
String expected = "SELECT/*+ ordered */ br1.*\n" + //
- " FROM \n" + //
- "osee_branch br1\n" + //
- " WHERE \n" + //
- "br1.branch_name = ?\n" + //
- " ORDER BY br1.branch_id";
+ " FROM \n" + //
+ "osee_branch br1\n" + //
+ " WHERE \n" + //
+ "br1.branch_name = ?\n" + //
+ " ORDER BY br1.branch_id";
queryData.addCriteria(name("Hello"));
@@ -244,16 +241,14 @@ public class BranchQuerySqlContextFactoryImplTest {
@Test
public void testQueryNamePattern() throws Exception {
String expected = "SELECT/*+ ordered */ br1.*\n" + //
- " FROM \n" + //
- "osee_branch br1\n" + //
- " WHERE \n" + //
- "REGEXP_MATCHES (br1.branch_name, ?)\n" + //
- " ORDER BY br1.branch_id";
+ " FROM \n" + //
+ "osee_branch br1\n" + //
+ " WHERE \n" + //
+ "REGEXP_MATCHES (br1.branch_name, ?)\n" + //
+ " ORDER BY br1.branch_id";
queryData.addCriteria(NAME_PATTERN);
- when(sqlProvider.getSql(SqlProvider.SQL_REG_EXP_PATTERN_KEY)).thenReturn("REGEXP_MATCHES (%s, %s)");
-
QuerySqlContext context = queryEngine.createQueryContext(session, queryData);
assertEquals(expected, context.getSql());
@@ -270,13 +265,13 @@ public class BranchQuerySqlContextFactoryImplTest {
@Test
public void testQueryStateArchive() throws Exception {
String expected = "SELECT/*+ ordered */ br1.*\n" + //
- " FROM \n" + //
- "osee_join_id jid1, osee_branch br1\n" + //
- " WHERE \n" + //
- "br1.branch_state = jid1.id AND jid1.query_id = ?\n" + //
- " AND \n" + //
- "br1.archived = ?\n" + //
- " ORDER BY br1.branch_id";
+ " FROM \n" + //
+ "osee_join_id jid1, osee_branch br1\n" + //
+ " WHERE \n" + //
+ "br1.branch_state = jid1.id AND jid1.query_id = ?\n" + //
+ " AND \n" + //
+ "br1.archived = ?\n" + //
+ " ORDER BY br1.branch_id";
queryData.addCriteria(STATE, IS_ARCHIVED);
@@ -298,13 +293,13 @@ public class BranchQuerySqlContextFactoryImplTest {
@Test
public void testQuerySingleStateArchive() throws Exception {
String expected = "SELECT/*+ ordered */ br1.*\n" + //
- " FROM \n" + //
- "osee_branch br1\n" + //
- " WHERE \n" + //
- "br1.branch_state = ?\n" + //
- " AND \n" + //
- "br1.archived = ?\n" + //
- " ORDER BY br1.branch_id";
+ " FROM \n" + //
+ "osee_branch br1\n" + //
+ " WHERE \n" + //
+ "br1.branch_state = ?\n" + //
+ " AND \n" + //
+ "br1.archived = ?\n" + //
+ " ORDER BY br1.branch_id";
queryData.addCriteria(state(CREATION_IN_PROGRESS), IS_ARCHIVED);
@@ -324,18 +319,18 @@ public class BranchQuerySqlContextFactoryImplTest {
@Test
public void testQueryChildOf() throws OseeCoreException {
- String expected = "WITH chof1 (child_id, branch_level) AS ( \n" + //
- " SELECT anch_br1.branch_id, 0 as branch_level FROM osee_branch anch_br1, osee_branch anch_br2\n" + //
- " WHERE anch_br1.parent_branch_id = anch_br2.branch_id AND anch_br2.branch_id = ?\n" + //
- " UNION ALL \n" + //
- " SELECT branch_id, branch_level + 1 FROM chof1 recurse, osee_branch br WHERE recurse.child_id = br.parent_branch_id\n" + //
- " )\n" + //
- "SELECT br1.*\n" + //
- " FROM \n" + //
- "osee_branch br1, chof1\n" + //
- " WHERE \n" + //
- "br1.branch_id = chof1.child_id\n" + //
- " ORDER BY br1.branch_id";
+ String expected = "WITH RECURSIVE chof1 (child_id, branch_level) AS ( \n" + //
+ " SELECT anch_br1.branch_id, 0 as branch_level FROM osee_branch anch_br1, osee_branch anch_br2\n" + //
+ " WHERE anch_br1.parent_branch_id = anch_br2.branch_id AND anch_br2.branch_id = ?\n" + //
+ " UNION ALL \n" + //
+ " SELECT branch_id, branch_level + 1 FROM chof1 recurse, osee_branch br WHERE recurse.child_id = br.parent_branch_id\n" + //
+ " )\n" + //
+ "SELECT br1.*\n" + //
+ " FROM \n" + //
+ "osee_branch br1, chof1\n" + //
+ " WHERE \n" + //
+ "br1.branch_id = chof1.child_id\n" + //
+ " ORDER BY br1.branch_id";
queryData.addCriteria(childOf(COMMON));
@@ -354,18 +349,18 @@ public class BranchQuerySqlContextFactoryImplTest {
@Test
public void testQueryAncestorOf() throws OseeCoreException {
- String expected = "WITH anstrof1 (parent_id, branch_level) AS ( \n" + //
- " SELECT anch_br1.parent_branch_id, 0 as branch_level FROM osee_branch anch_br1\n" + //
- " WHERE anch_br1.branch_id = ?\n" + //
- " UNION ALL \n" + //
- " SELECT parent_branch_id, branch_level - 1 FROM anstrof1 recurse, osee_branch br WHERE br.branch_id = recurse.parent_id\n" + //
- " )\n" + //
- "SELECT br1.*\n" + //
- " FROM \n" + //
- "osee_branch br1, anstrof1\n" + //
- " WHERE \n" + //
- "br1.branch_id = anstrof1.parent_id\n" + //
- " ORDER BY br1.branch_id";
+ String expected = "WITH RECURSIVE anstrof1 (parent_id, branch_level) AS ( \n" + //
+ " SELECT anch_br1.parent_branch_id, 0 as branch_level FROM osee_branch anch_br1\n" + //
+ " WHERE anch_br1.branch_id = ?\n" + //
+ " UNION ALL \n" + //
+ " SELECT parent_branch_id, branch_level - 1 FROM anstrof1 recurse, osee_branch br WHERE br.branch_id = recurse.parent_id\n" + //
+ " )\n" + //
+ "SELECT br1.*\n" + //
+ " FROM \n" + //
+ "osee_branch br1, anstrof1\n" + //
+ " WHERE \n" + //
+ "br1.branch_id = anstrof1.parent_id\n" + //
+ " ORDER BY br1.branch_id";
queryData.addCriteria(ancestorOf(COMMON));
@@ -384,31 +379,29 @@ public class BranchQuerySqlContextFactoryImplTest {
@Test
public void testMultiples() throws OseeCoreException {
- String expected = "WITH chof1 (child_id, branch_level) AS ( \n" + //
- " SELECT anch_br1.branch_id, 0 as branch_level FROM osee_branch anch_br1, osee_branch anch_br2\n" + //
- " WHERE anch_br1.parent_branch_id = anch_br2.branch_id AND anch_br2.branch_id = ?\n" + //
- " UNION ALL \n" + //
- " SELECT branch_id, branch_level + 1 FROM chof1 recurse, osee_branch br WHERE recurse.child_id = br.parent_branch_id\n" + //
- " )\n" + //
- "SELECT br1.*\n" + //
- " FROM \n" + //
- "osee_branch br1, osee_join_id jid1, chof1\n" + //
- " WHERE \n" + //
- "br1.branch_id = chof1.child_id\n" + //
- " AND \n" + //
- "br1.branch_type = ?\n" + //
- " AND \n" + //
- "br1.branch_state = jid1.id AND jid1.query_id = ?\n" + //
- " AND \n" + //
- "br1.archived = ?\n" + //
- " AND \n" + //
- "REGEXP_MATCHES (br1.branch_name, ?)\n" + //
- " ORDER BY br1.branch_id";
+ String expected = "WITH RECURSIVE chof1 (child_id, branch_level) AS ( \n" + //
+ " SELECT anch_br1.branch_id, 0 as branch_level FROM osee_branch anch_br1, osee_branch anch_br2\n" + //
+ " WHERE anch_br1.parent_branch_id = anch_br2.branch_id AND anch_br2.branch_id = ?\n" + //
+ " UNION ALL \n" + //
+ " SELECT branch_id, branch_level + 1 FROM chof1 recurse, osee_branch br WHERE recurse.child_id = br.parent_branch_id\n" + //
+ " )\n" + //
+ "SELECT br1.*\n" + //
+ " FROM \n" + //
+ "osee_branch br1, osee_join_id jid1, chof1\n" + //
+ " WHERE \n" + //
+ "br1.branch_id = chof1.child_id\n" + //
+ " AND \n" + //
+ "br1.branch_type = ?\n" + //
+ " AND \n" + //
+ "br1.branch_state = jid1.id AND jid1.query_id = ?\n" + //
+ " AND \n" + //
+ "br1.archived = ?\n" + //
+ " AND \n" + //
+ "REGEXP_MATCHES (br1.branch_name, ?)\n" + //
+ " ORDER BY br1.branch_id";
queryData.addCriteria(STATE, IS_ARCHIVED, type(WORKING), childOf(COMMON), NAME_PATTERN);
- when(sqlProvider.getSql(SqlProvider.SQL_REG_EXP_PATTERN_KEY)).thenReturn("REGEXP_MATCHES (%s, %s)");
-
QuerySqlContext context = queryEngine.createQueryContext(session, queryData);
assertEquals(expected, context.getSql());
@@ -431,15 +424,15 @@ public class BranchQuerySqlContextFactoryImplTest {
@Test
public void testMergeBranchFor() throws Exception {
String expected = "SELECT/*+ ordered */ br1.*\n" + //
- " FROM \n" + //
- "osee_merge mbr1, osee_branch br1\n" + //
- " WHERE \n" + //
- "mbr1.source_branch_id = ?\n" + //
- " AND \n" + //
- "mbr1.dest_branch_id = ?\n" + //
- " AND \n" + //
- "mbr1.merge_branch_id = br1.branch_id\n" + //
- " ORDER BY br1.branch_id";
+ " FROM \n" + //
+ "osee_merge mbr1, osee_branch br1\n" + //
+ " WHERE \n" + //
+ "mbr1.source_branch_id = ?\n" + //
+ " AND \n" + //
+ "mbr1.dest_branch_id = ?\n" + //
+ " AND \n" + //
+ "mbr1.merge_branch_id = br1.branch_id\n" + //
+ " ORDER BY br1.branch_id";
queryData.addCriteria(new CriteriaMergeBranchFor(1L, 2L));
@@ -460,11 +453,11 @@ public class BranchQuerySqlContextFactoryImplTest {
@Test
public void testAssociatedArtId() throws Exception {
String expected = "SELECT/*+ ordered */ br1.*\n" + //
- " FROM \n" + //
- "osee_branch br1\n" + //
- " WHERE \n" + //
- "br1.associated_art_id = ?\n" + //
- " ORDER BY br1.branch_id";
+ " FROM \n" + //
+ "osee_branch br1\n" + //
+ " WHERE \n" + //
+ "br1.associated_art_id = ?\n" + //
+ " ORDER BY br1.branch_id";
queryData.addCriteria(new CriteriaAssociatedArtId(4));
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/TxQuerySqlContextFactoryImplTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/TxQuerySqlContextFactoryImplTest.java
index b0f9489793..3df265db5d 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/TxQuerySqlContextFactoryImplTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/TxQuerySqlContextFactoryImplTest.java
@@ -18,7 +18,6 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import org.eclipse.osee.framework.core.enums.TransactionDetailsType;
-import org.eclipse.osee.framework.core.sql.OseeSql;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.logger.Log;
@@ -38,7 +37,6 @@ import org.eclipse.osee.orcs.core.ds.criteria.CriteriaTxIdWithOperator;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaTxIds;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaTxType;
import org.eclipse.osee.orcs.db.internal.IdentityLocator;
-import org.eclipse.osee.orcs.db.internal.SqlProvider;
import org.eclipse.osee.orcs.db.internal.search.Engines;
import org.eclipse.osee.orcs.db.internal.search.QuerySqlContext;
import org.eclipse.osee.orcs.db.internal.search.QuerySqlContextFactory;
@@ -55,7 +53,7 @@ import org.mockito.stubbing.Answer;
/**
* Test Case for {@link QuerySqlContextFactoryImpl}
- *
+ *
* @author Roberto E. Escobar
*/
public class TxQuerySqlContextFactoryImplTest {
@@ -73,9 +71,8 @@ public class TxQuerySqlContextFactoryImplTest {
// @formatter:off
@Mock private Log logger;
- @Mock private SqlProvider sqlProvider;
@Mock private IdentityLocator identityService;
-
+
@Mock private OrcsSession session;
@Mock private SqlJoinFactory joinFactory;
@Mock private IdJoinQuery idJoinQuery;
@@ -91,13 +88,12 @@ public class TxQuerySqlContextFactoryImplTest {
String sessionId = GUID.create();
when(session.getGuid()).thenReturn(sessionId);
- queryEngine = Engines.newTxSqlContextFactory(logger, joinFactory, identityService, sqlProvider);
+ queryEngine = Engines.newTxSqlContextFactory(logger, joinFactory, identityService, null);
CriteriaSet criteriaSet = new CriteriaSet();
Options options = OptionsUtil.createOptions();
queryData = new QueryData(criteriaSet, options);
- when(sqlProvider.getSql(OseeSql.QUERY_BUILDER)).thenReturn("/*+ ordered */");
when(joinFactory.createIdJoinQuery()).thenAnswer(new Answer<IdJoinQuery>() {
@Override
@@ -111,10 +107,10 @@ public class TxQuerySqlContextFactoryImplTest {
@Test
public void testCount() throws Exception {
String expected = "SELECT/*+ ordered */ count(txd1.transaction_id)\n" + //
- " FROM \n" + //
- "osee_join_id jid1, osee_tx_details txd1\n" + //
- " WHERE \n" + //
- "txd1.transaction_id = jid1.id AND jid1.query_id = ?";
+ " FROM \n" + //
+ "osee_join_id jid1, osee_tx_details txd1\n" + //
+ " WHERE \n" + //
+ "txd1.transaction_id = jid1.id AND jid1.query_id = ?";
queryData.addCriteria(IDS);
QuerySqlContext context = queryEngine.createCountContext(session, queryData);
@@ -134,11 +130,11 @@ public class TxQuerySqlContextFactoryImplTest {
@Test
public void testQueryTxIds() throws Exception {
String expected = "SELECT/*+ ordered */ txd1.*\n" + //
- " FROM \n" + //
- "osee_join_id jid1, osee_tx_details txd1\n" + //
- " WHERE \n" + //
- "txd1.transaction_id = jid1.id AND jid1.query_id = ?\n" + //
- " ORDER BY txd1.transaction_id";
+ " FROM \n" + //
+ "osee_join_id jid1, osee_tx_details txd1\n" + //
+ " WHERE \n" + //
+ "txd1.transaction_id = jid1.id AND jid1.query_id = ?\n" + //
+ " ORDER BY txd1.transaction_id";
queryData.addCriteria(IDS);
@@ -159,11 +155,11 @@ public class TxQuerySqlContextFactoryImplTest {
@Test
public void testComment() throws Exception {
String expected = "SELECT/*+ ordered */ txd1.*\n" + //
- " FROM \n" + //
- "osee_tx_details txd1\n" + //
- " WHERE \n" + //
- "txd1.osee_comment = ?\n" + //
- " ORDER BY txd1.transaction_id";
+ " FROM \n" + //
+ "osee_tx_details txd1\n" + //
+ " WHERE \n" + //
+ "txd1.osee_comment = ?\n" + //
+ " ORDER BY txd1.transaction_id";
queryData.addCriteria(COMMENT);
@@ -179,11 +175,11 @@ public class TxQuerySqlContextFactoryImplTest {
@Test
public void testBranchType() throws Exception {
String expected = "SELECT/*+ ordered */ txd1.*\n" + //
- " FROM \n" + //
- "osee_join_id jid1, osee_tx_details txd1\n" + //
- " WHERE \n" + //
- "txd1.tx_type = jid1.id AND jid1.query_id = ?\n" + //
- " ORDER BY txd1.transaction_id";
+ " FROM \n" + //
+ "osee_join_id jid1, osee_tx_details txd1\n" + //
+ " WHERE \n" + //
+ "txd1.tx_type = jid1.id AND jid1.query_id = ?\n" + //
+ " ORDER BY txd1.transaction_id";
queryData.addCriteria(TYPES);
@@ -206,13 +202,13 @@ public class TxQuerySqlContextFactoryImplTest {
@Test
public void testBranchTypeAndTxId() throws Exception {
String expected = "SELECT/*+ ordered */ txd1.*\n" + //
- " FROM \n" + //
- "osee_join_id jid1, osee_tx_details txd1, osee_join_id jid2\n" + //
- " WHERE \n" + //
- "txd1.transaction_id = jid1.id AND jid1.query_id = ?\n" + //
- " AND \n" + //
- "txd1.tx_type = jid2.id AND jid2.query_id = ?\n" + //
- " ORDER BY txd1.transaction_id";
+ " FROM \n" + //
+ "osee_join_id jid1, osee_tx_details txd1, osee_join_id jid2\n" + //
+ " WHERE \n" + //
+ "txd1.transaction_id = jid1.id AND jid1.query_id = ?\n" + //
+ " AND \n" + //
+ "txd1.tx_type = jid2.id AND jid2.query_id = ?\n" + //
+ " ORDER BY txd1.transaction_id";
queryData.addCriteria(TYPES, IDS);
@@ -237,19 +233,19 @@ public class TxQuerySqlContextFactoryImplTest {
@Test
public void testSixItemQuery() throws Exception {
String expected = "SELECT/*+ ordered */ txd1.*\n" + //
- " FROM \n" + //
- "osee_tx_details txd1, osee_join_id jid1, osee_join_id jid2, osee_join_id jid3\n" + //
- " WHERE \n" + //
- "txd1.transaction_id < ?\n" + //
- " AND \n" + //
- "txd1.author = jid1.id AND jid1.query_id = ?\n" + //
- " AND \n" + //
- "txd1.commit_art_id = jid2.id AND jid2.query_id = ?\n" + //
- " AND \n" + //
- "txd1.time < ?\n" + //
- " AND \n" + //
- "txd1.branch_id = jid3.id AND jid3.query_id = ?\n" + //
- " ORDER BY txd1.transaction_id";
+ " FROM \n" + //
+ "osee_tx_details txd1, osee_join_id jid1, osee_join_id jid2, osee_join_id jid3\n" + //
+ " WHERE \n" + //
+ "txd1.transaction_id < ?\n" + //
+ " AND \n" + //
+ "txd1.author = jid1.id AND jid1.query_id = ?\n" + //
+ " AND \n" + //
+ "txd1.commit_art_id = jid2.id AND jid2.query_id = ?\n" + //
+ " AND \n" + //
+ "txd1.time < ?\n" + //
+ " AND \n" + //
+ "txd1.branch_id = jid3.id AND jid3.query_id = ?\n" + //
+ " ORDER BY txd1.transaction_id";
queryData.addCriteria(BRANCHIDS, IDS_WITH_OPERATOR, DATE_WITH_OPERATOR, AUTHORS, COMMITS);
@@ -279,11 +275,11 @@ public class TxQuerySqlContextFactoryImplTest {
@Test
public void testQueryTxPrior() throws Exception {
String expected = "SELECT/*+ ordered */ txd1.*\n" + //
- " FROM \n" + //
- "osee_tx_details txd1\n" + //
- " WHERE \n" + //
- "txd1.transaction_id = (SELECT max(td2.transaction_id) FROM osee_tx_details td1,osee_tx_details td2 WHERE td1.transaction_id = ? AND td1.branch_id = td2.branch_id AND td1.transaction_id > td2.transaction_id)\n" + //
- " ORDER BY txd1.transaction_id";
+ " FROM \n" + //
+ "osee_tx_details txd1\n" + //
+ " WHERE \n" + //
+ "txd1.transaction_id = (SELECT max(td2.transaction_id) FROM osee_tx_details td1,osee_tx_details td2 WHERE td1.transaction_id = ? AND td1.branch_id = td2.branch_id AND td1.transaction_id > td2.transaction_id)\n" + //
+ " ORDER BY txd1.transaction_id";
queryData.addCriteria(prior(3));

Back to the top