Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2014-11-04 19:26:36 +0000
committerAngel Avila2014-11-04 19:26:36 +0000
commit5faf29b350179699263cdd9e3f95775781d63c53 (patch)
treea2491e1043e478e55d65af55255b66c77fb53326
parentb27b17920e99169afa59455e53f7f2db7d052a21 (diff)
downloadorg.eclipse.osee-5faf29b350179699263cdd9e3f95775781d63c53.tar.gz
org.eclipse.osee-5faf29b350179699263cdd9e3f95775781d63c53.tar.xz
org.eclipse.osee-5faf29b350179699263cdd9e3f95775781d63c53.zip
feature[ats_ATS47363]: Generalize DB ArtifactQuery
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/CountingLoadDataHandler.java (renamed from plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/ArtifactDataCountHandler.java)17
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/QueryContextLoadExecutor.java25
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/Engines.java16
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QueryFilterFactory.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QuerySqlContext.java16
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContext.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ObjectQueryCallableFactory.java (renamed from plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQueryCallableFactory.java)24
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/QueryFilterFactoryImpl.java66
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/QuerySqlContextFactoryImpl.java7
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerFactoryUtil.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/BufferedLoadDataHandler.java50
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/SqlHandlerComparator.java29
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/SqlHandlerFactoryImpl.java17
13 files changed, 136 insertions, 141 deletions
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/ArtifactDataCountHandler.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/CountingLoadDataHandler.java
index 647491ec4f0..60762c02fc1 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/ArtifactDataCountHandler.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/CountingLoadDataHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 Boeing.
+ * Copyright (c) 2014 Boeing.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,22 +8,19 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs.db.internal.search.util;
+package org.eclipse.osee.orcs.core.ds;
import java.util.concurrent.atomic.AtomicInteger;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.orcs.core.ds.ArtifactData;
-import org.eclipse.osee.orcs.core.ds.LoadDataHandler;
-import org.eclipse.osee.orcs.core.ds.LoadDataHandlerDecorator;
/**
* @author Roberto E. Escobar
*/
-public class ArtifactDataCountHandler extends LoadDataHandlerDecorator {
+public abstract class CountingLoadDataHandler extends LoadDataHandlerDecorator {
private final AtomicInteger counter;
- public ArtifactDataCountHandler(LoadDataHandler handler) {
+ public CountingLoadDataHandler(LoadDataHandler handler) {
super(handler);
this.counter = new AtomicInteger();
}
@@ -32,7 +29,7 @@ public class ArtifactDataCountHandler extends LoadDataHandlerDecorator {
return counter;
}
- public int getArtifactCount() {
+ public int getCount() {
return getCounter().get();
}
@@ -42,10 +39,8 @@ public class ArtifactDataCountHandler extends LoadDataHandlerDecorator {
super.onLoadStart();
}
- @Override
- public void onData(ArtifactData data) throws OseeCoreException {
+ protected void incrementCount() {
getCounter().incrementAndGet();
- super.onData(data);
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/QueryContextLoadExecutor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/QueryContextLoadExecutor.java
index f0902f2b45c..8795db8619c 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/QueryContextLoadExecutor.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/QueryContextLoadExecutor.java
@@ -15,14 +15,13 @@ import org.eclipse.osee.executor.admin.HasCancellation;
import org.eclipse.osee.framework.database.IOseeDatabaseService;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.OseeStateException;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.orcs.core.ds.LoadDataHandler;
import org.eclipse.osee.orcs.core.ds.Options;
import org.eclipse.osee.orcs.db.internal.loader.LoadUtil;
import org.eclipse.osee.orcs.db.internal.loader.SqlObjectLoader;
import org.eclipse.osee.orcs.db.internal.loader.criteria.CriteriaOrcsLoad;
import org.eclipse.osee.orcs.db.internal.search.QuerySqlContext;
-import org.eclipse.osee.orcs.db.internal.sql.TableEnum;
+import org.eclipse.osee.orcs.db.internal.search.QuerySqlContext.ObjectQueryType;
/**
* @author Andrew M. Finkbeiner
@@ -39,7 +38,7 @@ public class QueryContextLoadExecutor extends AbstractLoadExecutor {
@Override
public void load(HasCancellation cancellation, LoadDataHandler handler, CriteriaOrcsLoad criteria, Options options) throws OseeCoreException {
int fetchSize = LoadUtil.computeFetchSize(MIN_FETCH_SIZE);
- OrcsObjectTypes typeToLoad = getObjectToLoad();
+ ObjectQueryType typeToLoad = queryContext.getOrcsObjectType();
switch (typeToLoad) {
case TX:
getLoader().loadTransactions(cancellation, handler, queryContext, fetchSize);
@@ -52,24 +51,4 @@ public class QueryContextLoadExecutor extends AbstractLoadExecutor {
}
}
- // This will be improved once we add the ability to specify what to load in the loader code.
- private OrcsObjectTypes getObjectToLoad() {
- OrcsObjectTypes type = OrcsObjectTypes.UNKNOWN;
- String sql = queryContext.getSql();
- if (Strings.isValid(sql)) {
- if (sql.contains(TableEnum.TX_DETAILS_TABLE.getName())) {
- type = OrcsObjectTypes.TX;
- } else if (sql.contains(TableEnum.BRANCH_TABLE.getName())) {
- type = OrcsObjectTypes.BRANCH;
- }
- }
- return type;
- }
-
- private static enum OrcsObjectTypes {
- ARTIFACT,
- BRANCH,
- TX,
- UNKNOWN;
- }
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/Engines.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/Engines.java
index 80a0b2e33c0..d2a89570c3b 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/Engines.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/Engines.java
@@ -30,9 +30,10 @@ import org.eclipse.osee.orcs.core.ds.TxOrcsData;
import org.eclipse.osee.orcs.data.AttributeTypes;
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.ObjectQueryType;
import org.eclipse.osee.orcs.db.internal.search.engines.AbstractSimpleQueryCallableFactory;
-import org.eclipse.osee.orcs.db.internal.search.engines.ArtifactQueryCallableFactory;
import org.eclipse.osee.orcs.db.internal.search.engines.ArtifactQuerySqlContextFactoryImpl;
+import org.eclipse.osee.orcs.db.internal.search.engines.ObjectQueryCallableFactory;
import org.eclipse.osee.orcs.db.internal.search.engines.QueryFilterFactoryImpl;
import org.eclipse.osee.orcs.db.internal.search.engines.QuerySqlContextFactoryImpl;
import org.eclipse.osee.orcs.db.internal.search.indexer.IndexedResourceLoader;
@@ -64,14 +65,14 @@ public final class Engines {
//
}
- public static ArtifactQueryCallableFactory newArtifactQueryEngine(Log logger, IOseeDatabaseService dbService, IdentityLocator idService, SqlProvider sqlProvider, TaggingEngine taggingEngine, ExecutorAdmin executorAdmin, DataLoaderFactory objectLoader, AttributeTypes attrTypes) {
+ public static ObjectQueryCallableFactory newArtifactQueryEngine(Log logger, IOseeDatabaseService dbService, IdentityLocator idService, SqlProvider sqlProvider, TaggingEngine taggingEngine, ExecutorAdmin executorAdmin, DataLoaderFactory objectLoader, AttributeTypes attrTypes) {
SqlHandlerFactory handlerFactory =
createArtifactSqlHandlerFactory(logger, idService, taggingEngine.getTagProcessor());
QuerySqlContextFactory sqlContextFactory =
new ArtifactQuerySqlContextFactoryImpl(logger, dbService, sqlProvider, handlerFactory);
AttributeDataMatcher matcher = new AttributeDataMatcher(logger, taggingEngine, attrTypes);
QueryFilterFactoryImpl filterFactory = new QueryFilterFactoryImpl(logger, executorAdmin, matcher);
- return new ArtifactQueryCallableFactory(logger, objectLoader, sqlContextFactory, filterFactory);
+ return new ObjectQueryCallableFactory(logger, objectLoader, sqlContextFactory, filterFactory);
}
public static QueryCallableFactory newBranchQueryEngine(Log logger, IOseeDatabaseService dbService, IdentityLocator idService, SqlProvider sqlProvider, DataLoaderFactory objectLoader) {
@@ -117,19 +118,20 @@ public final class Engines {
return new TaggingEngine(taggers, tagProcessor);
}
- public static QuerySqlContextFactory newSqlContextFactory(Log logger, IOseeDatabaseService dbService, SqlProvider sqlProvider, TableEnum table, String idColumn, SqlHandlerFactory handlerFactory) {
- return new QuerySqlContextFactoryImpl(logger, dbService, sqlProvider, handlerFactory, table, idColumn);
+ public static QuerySqlContextFactory newSqlContextFactory(Log logger, IOseeDatabaseService dbService, SqlProvider sqlProvider, TableEnum table, String idColumn, SqlHandlerFactory handlerFactory, ObjectQueryType type) {
+ return new QuerySqlContextFactoryImpl(logger, dbService, sqlProvider, handlerFactory, table, idColumn, type);
}
public static QuerySqlContextFactory newBranchSqlContextFactory(Log logger, IOseeDatabaseService dbService, IdentityLocator idService, SqlProvider sqlProvider) {
SqlHandlerFactory handlerFactory = createBranchSqlHandlerFactory(logger, idService);
- return newSqlContextFactory(logger, dbService, sqlProvider, TableEnum.BRANCH_TABLE, "branch_id", handlerFactory);
+ return newSqlContextFactory(logger, dbService, sqlProvider, TableEnum.BRANCH_TABLE, "branch_id", handlerFactory,
+ ObjectQueryType.BRANCH);
}
public static QuerySqlContextFactory newTxSqlContextFactory(Log logger, IOseeDatabaseService dbService, IdentityLocator idService, SqlProvider sqlProvider) {
SqlHandlerFactory handlerFactory = createTxSqlHandlerFactory(logger, idService);
return newSqlContextFactory(logger, dbService, sqlProvider, TableEnum.TX_DETAILS_TABLE, "transaction_id",
- handlerFactory);
+ handlerFactory, ObjectQueryType.TX);
}
public static QueryEngineIndexer newIndexingEngine(Log logger, IOseeDatabaseService dbService, IdentityLocator idService, TaggingEngine taggingEngine, ExecutorAdmin executorAdmin, IResourceManager resourceManager) {
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QueryFilterFactory.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QueryFilterFactory.java
index cb59fcff870..5c55b7fb176 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QueryFilterFactory.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QueryFilterFactory.java
@@ -11,9 +11,9 @@
package org.eclipse.osee.orcs.db.internal.search;
import org.eclipse.osee.executor.admin.HasCancellation;
+import org.eclipse.osee.orcs.core.ds.CountingLoadDataHandler;
import org.eclipse.osee.orcs.core.ds.LoadDataHandler;
import org.eclipse.osee.orcs.core.ds.QueryData;
-import org.eclipse.osee.orcs.db.internal.search.util.ArtifactDataCountHandler;
/**
* @author Roberto E. Escobar
@@ -22,6 +22,6 @@ public interface QueryFilterFactory {
boolean isFilterRequired(QueryData queryData);
- ArtifactDataCountHandler createHandler(HasCancellation cancellation, QueryData queryData, QuerySqlContext queryContext, LoadDataHandler handler) throws Exception;
+ CountingLoadDataHandler createHandler(HasCancellation cancellation, QueryData queryData, QuerySqlContext queryContext, LoadDataHandler handler) throws Exception;
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QuerySqlContext.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QuerySqlContext.java
index 41c0fbe9d95..5580a831a4b 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QuerySqlContext.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QuerySqlContext.java
@@ -20,8 +20,22 @@ import org.eclipse.osee.orcs.db.internal.sql.SqlContextImpl;
*/
public class QuerySqlContext extends SqlContextImpl implements QueryContext {
- public QuerySqlContext(OrcsSession session, Options options) {
+ public static enum ObjectQueryType {
+ ARTIFACT,
+ BRANCH,
+ TX,
+ DYNAMIC_OBJECT,
+ UNKNOWN;
+ }
+
+ private final ObjectQueryType objectType;
+
+ public QuerySqlContext(OrcsSession session, Options options, ObjectQueryType objectType) {
super(session, options);
+ this.objectType = objectType;
}
+ public ObjectQueryType getOrcsObjectType() {
+ return objectType;
+ }
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContext.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContext.java
index df798d4242a..5d150aa195c 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContext.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContext.java
@@ -24,7 +24,7 @@ public class ArtifactQuerySqlContext extends QuerySqlContext implements HasBranc
private final IOseeBranch branch;
public ArtifactQuerySqlContext(OrcsSession session, IOseeBranch branch, Options options) {
- super(session, options);
+ super(session, options, ObjectQueryType.ARTIFACT);
this.branch = branch;
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQueryCallableFactory.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ObjectQueryCallableFactory.java
index 6b73c7f3d4f..45a1dcec2a3 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQueryCallableFactory.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ObjectQueryCallableFactory.java
@@ -15,6 +15,7 @@ import org.eclipse.osee.framework.core.enums.LoadLevel;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.OrcsSession;
+import org.eclipse.osee.orcs.core.ds.CountingLoadDataHandler;
import org.eclipse.osee.orcs.core.ds.DataLoader;
import org.eclipse.osee.orcs.core.ds.DataLoaderFactory;
import org.eclipse.osee.orcs.core.ds.LoadDataHandler;
@@ -23,19 +24,18 @@ import org.eclipse.osee.orcs.db.internal.search.QueryCallableFactory;
import org.eclipse.osee.orcs.db.internal.search.QueryFilterFactory;
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.util.ArtifactDataCountHandler;
/**
* @author Roberto E. Escobar
*/
-public class ArtifactQueryCallableFactory implements QueryCallableFactory {
+public class ObjectQueryCallableFactory implements QueryCallableFactory {
private final Log logger;
private final DataLoaderFactory objectLoader;
private final QuerySqlContextFactory queryContextFactory;
private final QueryFilterFactory factory;
- public ArtifactQueryCallableFactory(Log logger, DataLoaderFactory objectLoader, QuerySqlContextFactory queryEngine, QueryFilterFactoryImpl factory) {
+ public ObjectQueryCallableFactory(Log logger, DataLoaderFactory objectLoader, QuerySqlContextFactory queryEngine, QueryFilterFactoryImpl factory) {
super();
this.logger = logger;
this.objectLoader = objectLoader;
@@ -45,13 +45,13 @@ public class ArtifactQueryCallableFactory implements QueryCallableFactory {
@Override
public CancellableCallable<Integer> createCount(OrcsSession session, QueryData queryData) {
- return new AbstractArtifactSearchCallable(logger, session, queryData) {
+ return new AbstractObjectSearchCallable(logger, session, queryData) {
@Override
protected Integer innerCall() throws Exception {
int count = -1;
if (isPostProcessRequired()) {
- count = loadAndGetArtifactCount(null, true);
+ count = loadAndGetCount(null, true);
} else {
count = getCount();
}
@@ -70,19 +70,19 @@ public class ArtifactQueryCallableFactory implements QueryCallableFactory {
@Override
public CancellableCallable<Integer> createQuery(OrcsSession session, final QueryData queryData, final LoadDataHandler handler) {
- return new AbstractArtifactSearchCallable(logger, session, queryData) {
+ return new AbstractObjectSearchCallable(logger, session, queryData) {
@Override
protected Integer innerCall() throws Exception {
boolean enableFilter = isPostProcessRequired();
- return loadAndGetArtifactCount(handler, enableFilter);
+ return loadAndGetCount(handler, enableFilter);
}
};
}
- private abstract class AbstractArtifactSearchCallable extends AbstractSearchCallable {
+ private abstract class AbstractObjectSearchCallable extends AbstractSearchCallable {
- public AbstractArtifactSearchCallable(Log logger, OrcsSession session, QueryData queryData) {
+ public AbstractObjectSearchCallable(Log logger, OrcsSession session, QueryData queryData) {
super(logger, session, queryData);
}
@@ -94,7 +94,7 @@ public class ArtifactQueryCallableFactory implements QueryCallableFactory {
return factory.isFilterRequired(getQueryData());
}
- protected int loadAndGetArtifactCount(LoadDataHandler handler, boolean enableFilter) throws Exception {
+ protected int loadAndGetCount(LoadDataHandler handler, boolean enableFilter) throws Exception {
QuerySqlContext queryContext = queryContextFactory.createQueryContext(getSession(), getQueryData());
checkForCancelled();
@@ -108,9 +108,9 @@ public class ArtifactQueryCallableFactory implements QueryCallableFactory {
loader.withLoadLevel(LoadLevel.ARTIFACT_AND_ATTRIBUTE_DATA);
}
}
- ArtifactDataCountHandler countingHandler = factory.createHandler(this, getQueryData(), queryContext, handler);
+ CountingLoadDataHandler countingHandler = factory.createHandler(this, getQueryData(), queryContext, handler);
loader.load(this, countingHandler);
- return countingHandler.getArtifactCount();
+ return countingHandler.getCount();
}
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/QueryFilterFactoryImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/QueryFilterFactoryImpl.java
index 0459f815f2a..f401ca2a864 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/QueryFilterFactoryImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/QueryFilterFactoryImpl.java
@@ -29,6 +29,7 @@ import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.core.ds.ArtifactData;
import org.eclipse.osee.orcs.core.ds.AttributeData;
+import org.eclipse.osee.orcs.core.ds.CountingLoadDataHandler;
import org.eclipse.osee.orcs.core.ds.CriteriaSet;
import org.eclipse.osee.orcs.core.ds.LoadDataHandler;
import org.eclipse.osee.orcs.core.ds.QueryData;
@@ -38,9 +39,7 @@ import org.eclipse.osee.orcs.db.internal.loader.LoadUtil;
import org.eclipse.osee.orcs.db.internal.loader.data.AttributeDataImpl;
import org.eclipse.osee.orcs.db.internal.search.QueryFilterFactory;
import org.eclipse.osee.orcs.db.internal.search.QuerySqlContext;
-import org.eclipse.osee.orcs.db.internal.search.util.ArtifactDataCountHandler;
import org.eclipse.osee.orcs.db.internal.search.util.AttributeDataMatcher;
-import org.eclipse.osee.orcs.db.internal.search.util.BufferedLoadDataHandler;
import org.eclipse.osee.orcs.db.internal.search.util.LoadDataBuffer;
import org.eclipse.osee.orcs.db.internal.sql.RelationalConstants;
import org.eclipse.osee.orcs.db.internal.sql.SqlContext;
@@ -67,25 +66,23 @@ public class QueryFilterFactoryImpl implements QueryFilterFactory {
}
@Override
- public ArtifactDataCountHandler createHandler(HasCancellation cancellation, QueryData queryData, QuerySqlContext queryContext, LoadDataHandler handler) throws Exception {
+ public CountingLoadDataHandler createHandler(HasCancellation cancellation, QueryData queryData, QuerySqlContext queryContext, LoadDataHandler handler) throws Exception {
CriteriaSet criteriaSet = queryData.getLastCriteriaSet();
Set<CriteriaAttributeKeywords> criterias = criteriaSet.getCriteriaByType(CriteriaAttributeKeywords.class);
- ArtifactDataCountHandler countingHandler;
+ CountingLoadDataHandler countingHandler;
if (criterias.isEmpty()) {
- countingHandler = new ArtifactDataCountHandler(handler);
+ // Nothing to Loading
+ countingHandler = new ObjectCountingHandler(handler);
} else {
- countingHandler = createFilteringHandler(cancellation, criterias, queryContext, handler);
+ int initialSize = computeFetchSize(queryContext);
+ LoadDataBuffer buffer = new LoadDataBuffer(initialSize);
+
+ Consumer consumer = new ConsumerImpl(cancellation, criterias);
+ countingHandler = new AttributeDataProducer(buffer, handler, consumer);
}
return countingHandler;
}
- private ArtifactDataCountHandler createFilteringHandler(final HasCancellation cancellation, final Set<CriteriaAttributeKeywords> criterias, QuerySqlContext queryContext, final LoadDataHandler handler) throws Exception {
- int initialSize = computeFetchSize(queryContext);
- LoadDataBuffer buffer = new LoadDataBuffer(initialSize);
- Consumer consumer = new ConsumerImpl(cancellation, criterias);
- return new AttributeDataProducer(buffer, handler, consumer);
- }
-
private int computeFetchSize(SqlContext sqlContext) {
int fetchSize = RelationalConstants.MIN_FETCH_SIZE;
for (AbstractJoinQuery join : sqlContext.getJoins()) {
@@ -317,4 +314,47 @@ public class QueryFilterFactoryImpl implements QueryFilterFactory {
}
}
+ private static class ObjectCountingHandler extends CountingLoadDataHandler {
+
+ public ObjectCountingHandler(LoadDataHandler handler) {
+ super(handler);
+ }
+
+ @Override
+ public void onData(ArtifactData data) throws OseeCoreException {
+ incrementCount();
+ super.onData(data);
+ }
+
+ }
+
+ private static class BufferedLoadDataHandler extends ObjectCountingHandler {
+
+ private final LoadDataBuffer buffer;
+
+ public BufferedLoadDataHandler(LoadDataHandler handler, LoadDataBuffer buffer) {
+ super(handler);
+ this.buffer = buffer;
+ }
+
+ protected LoadDataBuffer getBuffer() {
+ return buffer;
+ }
+
+ @Override
+ public void onData(ArtifactData data) throws OseeCoreException {
+ buffer.addData(data);
+ }
+
+ @Override
+ public void onData(AttributeData data) throws OseeCoreException {
+ buffer.addData(data);
+ }
+
+ @Override
+ public void onData(RelationData data) throws OseeCoreException {
+ buffer.addData(data);
+ }
+
+ }
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/QuerySqlContextFactoryImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/QuerySqlContextFactoryImpl.java
index 6dadf689adf..13e4ed3b420 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/QuerySqlContextFactoryImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/QuerySqlContextFactoryImpl.java
@@ -18,6 +18,7 @@ import org.eclipse.osee.orcs.OrcsSession;
import org.eclipse.osee.orcs.core.ds.QueryData;
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.QuerySqlContext.ObjectQueryType;
import org.eclipse.osee.orcs.db.internal.search.QuerySqlContextFactory;
import org.eclipse.osee.orcs.db.internal.sql.AbstractSqlWriter;
import org.eclipse.osee.orcs.db.internal.sql.QueryType;
@@ -36,14 +37,16 @@ public class QuerySqlContextFactoryImpl implements QuerySqlContextFactory {
private final IOseeDatabaseService dbService;
private final TableEnum table;
private final String idColumn;
+ private final ObjectQueryType type;
- public QuerySqlContextFactoryImpl(Log logger, IOseeDatabaseService dbService, SqlProvider sqlProvider, SqlHandlerFactory handlerFactory, TableEnum table, String idColumn) {
+ public QuerySqlContextFactoryImpl(Log logger, IOseeDatabaseService dbService, SqlProvider sqlProvider, SqlHandlerFactory handlerFactory, TableEnum table, String idColumn, ObjectQueryType type) {
this.logger = logger;
this.dbService = dbService;
this.sqlProvider = sqlProvider;
this.handlerFactory = handlerFactory;
this.table = table;
this.idColumn = idColumn;
+ this.type = type;
}
@Override
@@ -57,7 +60,7 @@ public class QuerySqlContextFactoryImpl implements QuerySqlContextFactory {
}
private QuerySqlContext createQueryContext(OrcsSession session, QueryData queryData, QueryType queryType) throws OseeCoreException {
- QuerySqlContext context = new QuerySqlContext(session, queryData.getOptions());
+ QuerySqlContext context = new QuerySqlContext(session, queryData.getOptions(), type);
AbstractSqlWriter writer =
new QuerySqlWriter(logger, dbService, sqlProvider, context, queryType, table, idColumn);
List<SqlHandler<?>> handlers = handlerFactory.createHandlers(queryData.getCriteriaSets());
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerFactoryUtil.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerFactoryUtil.java
index e15077b5151..bfe8afd6362 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerFactoryUtil.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerFactoryUtil.java
@@ -98,7 +98,7 @@ public final class SqlHandlerFactoryUtil {
handleMap.put(CriteriaBranchAncestorOf.class, BranchAncestorOfSqlHandler.class);
handleMap.put(CriteriaAllBranches.class, AllBranchesSqlHandler.class);
- return new SqlHandlerFactoryImpl(logger, identityService, handleMap);
+ return new SqlHandlerFactoryImpl(logger, identityService, null, handleMap);
}
public static SqlHandlerFactory createTxSqlHandlerFactory(Log logger, IdentityLocator identityService) {
@@ -120,6 +120,6 @@ public final class SqlHandlerFactoryUtil {
handleMap.put(CriteriaTxGetHead.class, TxGetHeadSqlHandler.class);
handleMap.put(CriteriaTxGetPrior.class, TxGetPriorSqlHandler.class);
- return new SqlHandlerFactoryImpl(logger, identityService, handleMap);
+ return new SqlHandlerFactoryImpl(logger, identityService, null, handleMap);
}
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/BufferedLoadDataHandler.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/BufferedLoadDataHandler.java
deleted file mode 100644
index 5939f1f47ce..00000000000
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/BufferedLoadDataHandler.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.orcs.db.internal.search.util;
-
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.orcs.core.ds.ArtifactData;
-import org.eclipse.osee.orcs.core.ds.AttributeData;
-import org.eclipse.osee.orcs.core.ds.LoadDataHandler;
-import org.eclipse.osee.orcs.core.ds.RelationData;
-
-/**
- * @author Roberto E. Escobar
- */
-public class BufferedLoadDataHandler extends ArtifactDataCountHandler {
-
- private final LoadDataBuffer buffer;
-
- public BufferedLoadDataHandler(LoadDataHandler handler, LoadDataBuffer buffer) {
- super(handler);
- this.buffer = buffer;
- }
-
- protected LoadDataBuffer getBuffer() {
- return buffer;
- }
-
- @Override
- public void onData(ArtifactData data) throws OseeCoreException {
- buffer.addData(data);
- }
-
- @Override
- public void onData(AttributeData data) throws OseeCoreException {
- buffer.addData(data);
- }
-
- @Override
- public void onData(RelationData data) throws OseeCoreException {
- buffer.addData(data);
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/SqlHandlerComparator.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/SqlHandlerComparator.java
new file mode 100644
index 00000000000..eccadcdf153
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/SqlHandlerComparator.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.db.internal.sql;
+
+import java.util.Comparator;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class SqlHandlerComparator implements Comparator<SqlHandler<?>> {
+
+ @Override
+ public int compare(SqlHandler<?> left, SqlHandler<?> right) {
+ int result = left.getLevel() - right.getLevel();
+ if (result == 0) {
+ result = left.getPriority() - right.getPriority();
+ }
+ return result;
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/SqlHandlerFactoryImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/SqlHandlerFactoryImpl.java
index a013e0abfdf..964d17e75c3 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/SqlHandlerFactoryImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/SqlHandlerFactoryImpl.java
@@ -13,7 +13,6 @@ package org.eclipse.osee.orcs.db.internal.sql;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
import java.util.Map;
import org.eclipse.osee.framework.core.exception.OseeExceptions;
@@ -38,10 +37,6 @@ public class SqlHandlerFactoryImpl implements SqlHandlerFactory {
private final IdentityLocator idService;
private final TagProcessor tagProcessor;
- public SqlHandlerFactoryImpl(Log logger, IdentityLocator idService, Map<Class<? extends Criteria>, Class<? extends SqlHandler<?>>> handleMap) {
- this(logger, idService, null, handleMap);
- }
-
public SqlHandlerFactoryImpl(Log logger, IdentityLocator idService, TagProcessor tagProcessor, Map<Class<? extends Criteria>, Class<? extends SqlHandler<?>>> handleMap) {
this.logger = logger;
this.idService = idService;
@@ -106,16 +101,4 @@ public class SqlHandlerFactoryImpl implements SqlHandlerFactory {
return handler;
}
- private static final class SqlHandlerComparator implements Comparator<SqlHandler<?>> {
-
- @Override
- public int compare(SqlHandler<?> left, SqlHandler<?> right) {
- int result = left.getLevel() - right.getLevel();
- if (result == 0) {
- result = left.getPriority() - right.getPriority();
- }
- return result;
- }
-
- }
}

Back to the top