Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/QueryEngine.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/ApplicabilityQueryImpl.java (renamed from plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ApplicabilityQueryImpl.java)50
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryFactoryImpl.java6
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryModule.java5
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/QueryEngineImpl.java8
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/TupleQueryImpl.java31
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/TupleQuery.java6
7 files changed, 53 insertions, 56 deletions
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/QueryEngine.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/QueryEngine.java
index ad303a6d124..0201504dfb8 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/QueryEngine.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/QueryEngine.java
@@ -12,7 +12,6 @@ package org.eclipse.osee.orcs.core.ds;
import org.eclipse.osee.executor.admin.CancellableCallable;
import org.eclipse.osee.orcs.OrcsSession;
-import org.eclipse.osee.orcs.search.ApplicabilityQuery;
import org.eclipse.osee.orcs.search.TupleQuery;
/**
@@ -30,8 +29,6 @@ public interface QueryEngine {
TupleQuery createTupleQuery();
- ApplicabilityQuery createApplicabilityQuery(TupleQuery tupleQuery);
-
CancellableCallable<Integer> createTxCount(OrcsSession session, QueryData queryData);
CancellableCallable<Integer> createTxQuery(OrcsSession session, QueryData queryData, LoadDataHandler handler);
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ApplicabilityQueryImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/ApplicabilityQueryImpl.java
index 0df83dd0019..9a7d951de44 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ApplicabilityQueryImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/ApplicabilityQueryImpl.java
@@ -8,20 +8,16 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs.db.internal.search.engines;
+package org.eclipse.osee.orcs.core.internal.search;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.function.BiConsumer;
import org.eclipse.osee.framework.core.data.ApplicabilityToken;
import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.core.enums.CoreTupleTypes;
-import org.eclipse.osee.jdbc.JdbcClient;
-import org.eclipse.osee.orcs.db.internal.sql.join.IdJoinQuery;
-import org.eclipse.osee.orcs.db.internal.sql.join.SqlJoinFactory;
import org.eclipse.osee.orcs.search.ApplicabilityQuery;
import org.eclipse.osee.orcs.search.TupleQuery;
@@ -29,54 +25,36 @@ import org.eclipse.osee.orcs.search.TupleQuery;
* @author Ryan D. Brooks
*/
public class ApplicabilityQueryImpl implements ApplicabilityQuery {
- private static final String SELECT_APPLIC_FOR_ART =
- "SELECT distinct e2, value FROM osee_artifact art, osee_txs txs1, osee_tuple2 app, osee_txs txs2, osee_key_value WHERE art_id = ? and art.gamma_id = txs1.gamma_id and txs1.branch_id = ? AND txs1.tx_current = 1 and tuple_type = 2 AND e2 = txs1.app_id AND app.gamma_id = txs2.gamma_id AND txs2.branch_id = txs1.branch_id AND txs2.tx_current = 1 AND e2 = key";
-
- private static final String SELECT_APPLIC_FOR_ARTS =
- "SELECT distinct e2, value, art.art_id FROM osee_artifact art, osee_txs txs1, osee_tuple2 app, osee_txs txs2, osee_key_value, osee_join_id jid WHERE art_id = jid.id and jid.query_id =? and art.gamma_id = txs1.gamma_id and txs1.branch_id = ? AND txs1.tx_current = 1 and tuple_type = 2 AND e2 = txs1.app_id AND app.gamma_id = txs2.gamma_id AND txs2.branch_id = txs1.branch_id AND txs2.tx_current = 1 AND e2 = key";
-
private final TupleQuery tupleQuery;
- private final JdbcClient jdbcClient;
- private final SqlJoinFactory sqlJoinFactory;
- public ApplicabilityQueryImpl(JdbcClient jdbcClient, SqlJoinFactory sqlJoinFactory, TupleQuery tupleQuery) {
- this.jdbcClient = jdbcClient;
- this.sqlJoinFactory = sqlJoinFactory;
+ public ApplicabilityQueryImpl(TupleQuery tupleQuery) {
this.tupleQuery = tupleQuery;
}
@Override
public ApplicabilityToken getApplicabilityToken(ArtifactId artId, BranchId branch) {
- ApplicabilityToken[] result = new ApplicabilityToken[] {ApplicabilityToken.BASE};
- jdbcClient.runQuery(stmt -> result[0] = new ApplicabilityToken(stmt.getLong("e2"), stmt.getString("value")),
- SELECT_APPLIC_FOR_ART, artId, branch);
- return result[0];
+ List<ApplicabilityToken> result = new ArrayList<>();
+ BiConsumer<Long, String> consumer = (id, name) -> result.add(new ApplicabilityToken(id, name));
+ tupleQuery.getTupleType2ForArtifactId(artId, branch, consumer);
+
+ return result.get(0);
}
@Override
public List<ApplicabilityToken> getApplicabilityTokens(List<ArtifactId> artIds, BranchId branch) {
- IdJoinQuery idJoin = sqlJoinFactory.createIdJoinQuery();
- for (ArtifactId artId : artIds) {
- idJoin.add(artId.getId());
- }
- idJoin.store();
-
- Map<Long, ApplicabilityToken> artIdToApplic = new HashMap<>();
- jdbcClient.runQuery(
- stmt -> artIdToApplic.put(stmt.getLong("art_id"),
- new ApplicabilityToken(stmt.getLong("e2"), stmt.getString("value"))),
- SELECT_APPLIC_FOR_ARTS, idJoin.getQueryId(), branch);
-
- idJoin.delete();
-
List<ApplicabilityToken> toReturn = new ArrayList<>();
+ List<ApplicabilityToken> result = new ArrayList<>();
+ BiConsumer<Long, String> consumer = (id, name) -> result.add(new ApplicabilityToken(id, name));
+ tupleQuery.getTupleType2ForArtifactIds(artIds, branch, consumer);
+
for (ArtifactId artId : artIds) {
- if (artIdToApplic.containsKey(artId.getId())) {
- toReturn.add(artIdToApplic.get(artId.getId()));
+ if (result.contains(artId.getId())) {
+ toReturn.add(result.get(result.indexOf(artId.getId())));
} else {
toReturn.add(ApplicabilityToken.BASE);
}
}
+
return toReturn;
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryFactoryImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryFactoryImpl.java
index 96d047154f7..eccbbefa129 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryFactoryImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryFactoryImpl.java
@@ -43,10 +43,9 @@ public class QueryFactoryImpl implements QueryFactory {
private final BranchCallableQueryFactory branchQueryFactory;
private final TransactionCallableQueryFactory txQueryFactory;
private final TransactionCriteriaFactory txCriteriaFactory;
- private final ApplicabilityQuery applicabilityQuery;
private final TupleQuery tupleQuery;
- public QueryFactoryImpl(OrcsSession context, CriteriaFactory criteriaFctry, CallableQueryFactory queryFctry, BranchCriteriaFactory branchCriteriaFactory, BranchCallableQueryFactory branchQueryFactory, TransactionCallableQueryFactory txQueryFactory, TransactionCriteriaFactory txCriteriaFactory, TupleQuery tupleQuery, ApplicabilityQuery applicabilityQuery) {
+ public QueryFactoryImpl(OrcsSession context, CriteriaFactory criteriaFctry, CallableQueryFactory queryFctry, BranchCriteriaFactory branchCriteriaFactory, BranchCallableQueryFactory branchQueryFactory, TransactionCallableQueryFactory txQueryFactory, TransactionCriteriaFactory txCriteriaFactory, TupleQuery tupleQuery) {
super();
this.context = context;
this.criteriaFctry = criteriaFctry;
@@ -55,7 +54,6 @@ public class QueryFactoryImpl implements QueryFactory {
this.branchQueryFactory = branchQueryFactory;
this.txQueryFactory = txQueryFactory;
this.txCriteriaFactory = txCriteriaFactory;
- this.applicabilityQuery = applicabilityQuery;
this.tupleQuery = tupleQuery;
}
@@ -123,6 +121,6 @@ public class QueryFactoryImpl implements QueryFactory {
@Override
public ApplicabilityQuery applicabilityQuery() {
- return applicabilityQuery;
+ return new ApplicabilityQueryImpl(tupleQuery);
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryModule.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryModule.java
index ceffe8c655a..bc1f65cb712 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryModule.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryModule.java
@@ -19,7 +19,6 @@ import org.eclipse.osee.orcs.core.internal.graph.GraphProvider;
import org.eclipse.osee.orcs.core.internal.proxy.ExternalArtifactManager;
import org.eclipse.osee.orcs.data.ArtifactTypes;
import org.eclipse.osee.orcs.data.AttributeTypes;
-import org.eclipse.osee.orcs.search.ApplicabilityQuery;
import org.eclipse.osee.orcs.search.QueryFactory;
import org.eclipse.osee.orcs.search.TupleQuery;
import org.eclipse.osee.orcs.statistics.QueryStatistics;
@@ -40,7 +39,6 @@ public class QueryModule implements HasStatistics<QueryStatistics> {
private final TransactionCallableQueryFactory txQueryFactory;
private final TransactionCriteriaFactory txCriteriaFactory;
private final TupleQuery tupleQuery;
- private final ApplicabilityQuery applicabilityQuery;
public static interface QueryModuleProvider {
QueryFactory getQueryFactory(OrcsSession session);
@@ -58,12 +56,11 @@ public class QueryModule implements HasStatistics<QueryStatistics> {
txQueryFactory = new TransactionCallableQueryFactory(logger, queryEngine, queryStatsCollector);
txCriteriaFactory = new TransactionCriteriaFactory();
tupleQuery = queryEngine.createTupleQuery();
- applicabilityQuery = queryEngine.createApplicabilityQuery(tupleQuery);
}
public QueryFactory createQueryFactory(OrcsSession session) {
return new QueryFactoryImpl(session, criteriaFctry, artQueryFactory, branchCriteriaFactory, branchQueryFactory,
- txQueryFactory, txCriteriaFactory, tupleQuery, applicabilityQuery);
+ txQueryFactory, txCriteriaFactory, tupleQuery);
}
@Override
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/QueryEngineImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/QueryEngineImpl.java
index ffa2c96adb5..02e7212475e 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/QueryEngineImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/QueryEngineImpl.java
@@ -18,7 +18,6 @@ import org.eclipse.osee.orcs.core.ds.QueryData;
import org.eclipse.osee.orcs.core.ds.QueryEngine;
import org.eclipse.osee.orcs.db.internal.search.QueryCallableFactory;
import org.eclipse.osee.orcs.db.internal.sql.join.SqlJoinFactory;
-import org.eclipse.osee.orcs.search.ApplicabilityQuery;
import org.eclipse.osee.orcs.search.TupleQuery;
/**
@@ -84,11 +83,6 @@ public class QueryEngineImpl implements QueryEngine {
@Override
public TupleQuery createTupleQuery() {
- return new TupleQueryImpl(jdbcClient);
- }
-
- @Override
- public ApplicabilityQuery createApplicabilityQuery(TupleQuery tupleQuery) {
- return new ApplicabilityQueryImpl(jdbcClient, sqlJoinFactory, tupleQuery);
+ return new TupleQueryImpl(jdbcClient, sqlJoinFactory);
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/TupleQueryImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/TupleQueryImpl.java
index 738d3c4d88e..2eaafc7766d 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/TupleQueryImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/TupleQueryImpl.java
@@ -14,10 +14,13 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.function.BiConsumer;
+import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.core.data.Tuple2Type;
import org.eclipse.osee.framework.core.data.Tuple3Type;
import org.eclipse.osee.jdbc.JdbcClient;
+import org.eclipse.osee.orcs.db.internal.sql.join.IdJoinQuery;
+import org.eclipse.osee.orcs.db.internal.sql.join.SqlJoinFactory;
import org.eclipse.osee.orcs.search.TupleQuery;
/**
@@ -26,6 +29,8 @@ import org.eclipse.osee.orcs.search.TupleQuery;
public class TupleQueryImpl implements TupleQuery {
private final JdbcClient jdbcClient;
+ private final SqlJoinFactory sqlJoinFactory;
+
private static final String SELECT_E2_FROM_E1 =
"select e2, value from osee_txs txs, osee_tuple2 app, osee_key_value where app.tuple_type = ? and e1 = ? and app.gamma_id = txs.gamma_id and branch_id = ? and tx_current = 1 and e2 = key";
@@ -44,8 +49,15 @@ public class TupleQueryImpl implements TupleQuery {
private static final String SELECT_TUPLE3_GAMMA_FROM_E1 =
"select app.gamma_id from osee_txs txs, osee_tuple3 app where app.tuple_type = ? and app.gamma_id = txs.gamma_id and branch_id = ? and tx_current = 1 and e1 = ?";
- public TupleQueryImpl(JdbcClient jdbcClient) {
+ private static final String SELECT_APPLIC_FOR_ART =
+ "SELECT distinct e2, value FROM osee_artifact art, osee_txs txs1, osee_tuple2 app, osee_txs txs2, osee_key_value WHERE art_id = ? and art.gamma_id = txs1.gamma_id and txs1.branch_id = ? AND txs1.tx_current = 1 and tuple_type = 2 AND e2 = txs1.app_id AND app.gamma_id = txs2.gamma_id AND txs2.branch_id = txs1.branch_id AND txs2.tx_current = 1 AND e2 = key";
+
+ private static final String SELECT_APPLIC_FOR_ARTS =
+ "SELECT distinct e2, value, art.art_id FROM osee_artifact art, osee_txs txs1, osee_tuple2 app, osee_txs txs2, osee_key_value, osee_join_id jid WHERE art_id = jid.id and jid.query_id =? and art.gamma_id = txs1.gamma_id and txs1.branch_id = ? AND txs1.tx_current = 1 and tuple_type = 2 AND e2 = txs1.app_id AND app.gamma_id = txs2.gamma_id AND txs2.branch_id = txs1.branch_id AND txs2.tx_current = 1 AND e2 = key";
+
+ TupleQueryImpl(JdbcClient jdbcClient, SqlJoinFactory sqlJoinFactory) {
this.jdbcClient = jdbcClient;
+ this.sqlJoinFactory = sqlJoinFactory;
}
@SuppressWarnings("unchecked")
@@ -71,6 +83,22 @@ public class TupleQueryImpl implements TupleQuery {
runQuery(consumer, SELECT_E2_BY_TUPLE_TYPE, "e2", tupleType, branchId);
}
+ @Override
+ public <E1, E2> void getTupleType2ForArtifactId(ArtifactId artId, BranchId branchId, BiConsumer<Long, String> consumer) {
+ runQuery(consumer, SELECT_APPLIC_FOR_ART, "e2", artId, branchId);
+ }
+
+ @Override
+ public <E1, E2> void getTupleType2ForArtifactIds(List<ArtifactId> artIds, BranchId branchId, BiConsumer<Long, String> consumer) {
+ IdJoinQuery idJoin = sqlJoinFactory.createIdJoinQuery();
+ for (ArtifactId artId : artIds) {
+ idJoin.add(artId.getId());
+ }
+ idJoin.store();
+ runQuery(consumer, SELECT_APPLIC_FOR_ARTS, "e2", idJoin.getQueryId(), branchId);
+ idJoin.delete();
+ }
+
////// Tuple3 //////
@Override
public <E1, E2, E3> void getTuple3UniqueE1Pair(Tuple3Type<E1, E2, E3> tupleType, BranchId branchId, BiConsumer<Long, String> consumer) {
@@ -99,5 +127,4 @@ public class TupleQueryImpl implements TupleQuery {
private void runQuery(String column, List<Long> consumer, String query, Object... data) {
jdbcClient.runQuery(stmt -> consumer.add(stmt.getLong(column)), query, data);
}
-
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/TupleQuery.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/TupleQuery.java
index 2fa9ec3180d..2341799a0a0 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/TupleQuery.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/TupleQuery.java
@@ -12,6 +12,7 @@ package org.eclipse.osee.orcs.search;
import java.util.List;
import java.util.function.BiConsumer;
+import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.core.data.Tuple2Type;
import org.eclipse.osee.framework.core.data.Tuple3Type;
@@ -27,6 +28,10 @@ public interface TupleQuery {
<E1, E2> void getTuple2NamedId(Tuple2Type<E1, E2> tupleType, BranchId branchId, E1 e1, BiConsumer<Long, String> consumer);
+ <E1, E2> void getTupleType2ForArtifactId(ArtifactId artId, BranchId branchId, BiConsumer<Long, String> consumer);
+
+ <E1, E2> void getTupleType2ForArtifactIds(List<ArtifactId> artIds, BranchId branch, BiConsumer<Long, String> consumer);
+
/**
* Get each unique E2 (Id and associated String value) for a particular TupleType regardless of E1
*
@@ -41,4 +46,5 @@ public interface TupleQuery {
<E1, E2, E3> void getTuple3NamedId(Tuple3Type<E1, E2, E3> tupleType, BranchId branchId, Long e1, BiConsumer<Long, String> consumer);
<E1, E2, E3> void getTuple3GammaFromE1(Tuple3Type<E1, E2, E3> tupleType, BranchId branchId, Long e1, List<Long> consumer);
+
} \ No newline at end of file

Back to the top