Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2013-08-06 18:47:22 +0000
committerRoberto E. Escobar2013-09-06 23:34:15 +0000
commit6db35df55f578bee44d28120a70b9eea229edd79 (patch)
tree9478e13b47a9e2aeb2c0bb6c2de592be58b2ea90 /plugins
parent087660ac52cd9f2b9853fa64fee8b9213f7bbcad (diff)
downloadorg.eclipse.osee-6db35df55f578bee44d28120a70b9eea229edd79.tar.gz
org.eclipse.osee-6db35df55f578bee44d28120a70b9eea229edd79.tar.xz
org.eclipse.osee-6db35df55f578bee44d28120a70b9eea229edd79.zip
refinement: ORCS loader & query improvements
- Simplify use of LoadDataHandlerAdapter - Clean-up LoadProcessor template - Add LoadDescription phase to loading to report load params and options - Remove dependencies to artifact and attribute readable from tagger and query post processor - Use loader within query engine and apply query post processing as rows are loaded from the datastore without requiring full artifacts. Change-Id: I18b716121a67c0d650db2df906cb9b35f5d3737b
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/ds/DsTestSuite.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/ds/LoadDataHandlerDecoratorTest.java81
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/search/QueryStatisticsTest.java12
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/ArtifactDataHandlerProvider.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeDataHandlerProvider.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeDataMatchHandler.java (renamed from plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DataPostProcessor.java)14
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/CriteriaSet.java25
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DataStoreContext.java7
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/HasOptions.java1
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/IndexedResource.java (renamed from plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DataPostProcessorFactory.java)12
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/LoadContext.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/LoadDataHandler.java8
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/LoadDataHandlerAdapter.java66
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/LoadDataHandlerDecorator.java83
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/LoadDescription.java28
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/Options.java1
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsDataHandler.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/QueryCollector.java (renamed from plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryCollector.java)3
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/QueryContext.java9
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/QueryEngine.java6
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/QueryPostProcessor.java71
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/RelationDataHandler.java19
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/RelationDataHandlerProvider.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaBranch.java48
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactBuilderImpl.java61
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/ArtifactMatchDataHandler.java150
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/CallableQueryFactory.java148
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryBuilderImpl.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryFactoryImpl.java8
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryModule.java9
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryStatsCollectorImpl.java1
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/AbstractArtifactSearchCallable.java34
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/AbstractSearchCallable.java92
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/DefaultQueryPostProcessor.java65
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/LocalIdSearchCallable.java123
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/SearchCallable.java90
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/SearchCountCallable.java100
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/SearchMatchesCallable.java88
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/LoaderTest.java43
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderFactoryImplTest.java112
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/LoaderSqlHandlerFactoryUtilTest.java (renamed from plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/LoaderSqlHandlerFactoryImplTest.java)13
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/LoaderTestSuite.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/QueryTestSuite.java5
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContextFactoryImplTest.java (renamed from plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/QueryEngineImplTest.java)64
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/EnginesTestSuite.java (renamed from plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeDataHandler.java)15
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/handlers/HandlersTestSuite.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerFactoryUtilTest.java63
-rw-r--r--plugins/org.eclipse.osee.orcs.db/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/DataModuleFactory.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/DataStoreAdminImpl.java88
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactoryImpl.java74
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderFactoryImpl.java24
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderImpl.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/LoadSqlContext.java15
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/LoadSqlWriter.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/LoadUtil.java42
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/SqlObjectLoader.java82
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/ArtifactDataImpl.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/AttributeDataImpl.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsDataFactory.java (renamed from plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/ArtifactDataHandler.java)9
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsObjectImpl.java98
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsVersionedObjectImpl.java141
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/RelationDataImpl.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/VersionObjectFactory.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/AbstractLoadExecutor.java20
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/LoadExecutor.java18
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/QueryContextLoadExecutor.java14
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/ArtifactLoadProcessor.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/AttributeLoadProcessor.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/LoadProcessor.java8
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/RelationLoadProcessor.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QueryCallableFactory.java27
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QueryEngineImpl.java81
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QueryFilterFactory.java27
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QueryModule.java50
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QuerySqlContext.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QuerySqlContextFactory.java (renamed from plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/HasDataPostProcessorFactory.java)16
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQueryCallableFactory.java152
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContext.java40
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContextFactoryImpl.java109
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlWriter.java (renamed from plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QuerySqlWriter.java)17
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/QueryEngineImpl.java41
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/QueryFilterFactoryImpl.java247
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/AttributeTokenSqlHandler.java19
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerFactoryUtil.java10
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/IndexedResourceLoader.java (renamed from plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/QueueToAttributeLoader.java)11
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/IndexerCallableFactoryImpl.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/callable/consumer/IndexingTaskDatabaseTxCallable.java56
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/data/GammaQueueIndexerDataSourceLoader.java (renamed from plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/data/QueueToAttributeLoaderImpl.java)61
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/data/IndexerDataSourceImpl.java (renamed from plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/data/AttributeForIndexingImpl.java)141
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/AbstractTagger.java (renamed from plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/BaseAttributeTagger.java)21
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/Tagger.java8
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/TextStreamTagger.java (renamed from plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/DefaultAttributeTagger.java)15
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/XmlTagger.java (renamed from plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/XmlAttributeTagger.java)22
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/AbstractQueryPostProcessor.java171
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/ArtifactDataCountHandler.java51
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/ArtifactMatch.java62
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/AttributeDataMatcher.java171
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/AttributeQueryPostProcessor.java37
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/BufferedLoadDataHandler.java53
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/DataPostProcessorFactoryImpl.java52
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/LoadDataBuffer.java98
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/SimpleOrPostProcessor.java66
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/TokenQueryPostProcessor.java42
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/AbstractSqlWriter.java33
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/OseeSql.java1
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/QueryType.java (renamed from plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QueryType.java)6
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/SqlContext.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/SqlContextImpl.java12
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/SqlHandlerFactoryImpl.java33
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/ComodificationCheck.java54
112 files changed, 2451 insertions, 2133 deletions
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/ds/DsTestSuite.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/ds/DsTestSuite.java
index 31445f5804..db2d30e2a3 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/ds/DsTestSuite.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/ds/DsTestSuite.java
@@ -17,7 +17,7 @@ import org.junit.runners.Suite;
* @author Roberto E. Escobar
*/
@RunWith(Suite.class)
-@Suite.SuiteClasses({OptionsTest.class, OptionsUtilTest.class})
+@Suite.SuiteClasses({LoadDataHandlerDecoratorTest.class, OptionsTest.class, OptionsUtilTest.class})
public class DsTestSuite {
// Test Suite
}
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/ds/LoadDataHandlerDecoratorTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/ds/LoadDataHandlerDecoratorTest.java
new file mode 100644
index 0000000000..062894c2e1
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/ds/LoadDataHandlerDecoratorTest.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * 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.core.ds;
+
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Test Case for {@link LoadDataHandlerForwarder}
+ *
+ * @author Roberto E. Escobar
+ */
+public class LoadDataHandlerDecoratorTest {
+
+ // @formatter:off
+ @Mock private LoadDataHandler handler;
+
+ @Mock private ArtifactData artData;
+ @Mock private AttributeData attrData;
+ @Mock private RelationData relData;
+ @Mock private LoadDescription description;
+ @Mock private MatchLocation match;
+
+
+ @Mock private OrcsDataHandler<ArtifactData> artDataHandler;
+ @Mock private OrcsDataHandler<AttributeData> attrDataHandler;
+ @Mock private OrcsDataHandler<RelationData> relDataHandler;
+ // @formatter:on
+
+ private LoadDataHandlerDecorator decorated;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+
+ decorated = new LoadDataHandlerDecorator(handler);
+
+ when(handler.getArtifactDataHandler()).thenReturn(artDataHandler);
+ when(handler.getAttributeDataHandler()).thenReturn(attrDataHandler);
+ when(handler.getRelationDataHandler()).thenReturn(relDataHandler);
+ }
+
+ @Test
+ public void testOnData() throws OseeCoreException {
+ decorated.onLoadStart();
+ verify(handler).onLoadStart();
+
+ decorated.onLoadDescription(description);
+ verify(handler).onLoadDescription(description);
+
+ decorated.onData(attrData, match);
+ verify(handler).onData(attrData, match);
+
+ decorated.onData(artData);
+ verify(artDataHandler).onData(artData);
+
+ decorated.onData(attrData);
+ verify(attrDataHandler).onData(attrData);
+
+ decorated.onData(relData);
+ verify(relDataHandler).onData(relData);
+
+ decorated.onLoadEnd();
+ verify(handler).onLoadEnd();
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/search/QueryStatisticsTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/search/QueryStatisticsTest.java
index 6dc8ba9beb..993aeadb56 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/search/QueryStatisticsTest.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/search/QueryStatisticsTest.java
@@ -13,10 +13,8 @@ package org.eclipse.osee.orcs.core.internal.search;
import java.util.Collection;
import java.util.Collections;
import org.eclipse.osee.framework.core.data.IAttributeType;
-import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.enums.CaseType;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
-import org.eclipse.osee.framework.core.enums.CoreBranches;
import org.eclipse.osee.framework.core.enums.MatchTokenCountType;
import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
import org.eclipse.osee.framework.core.enums.TokenOrderType;
@@ -45,13 +43,13 @@ public class QueryStatisticsTest {
@BeforeClass
public static void setup() {
- searchRequest1 = createQueryData(CoreBranches.COMMON, "[hello]");
- searchRequest2 = createQueryData(CoreBranches.SYSTEM_ROOT, "short search");
- searchRequest3 = createQueryData(CoreBranches.SYSTEM_ROOT, "long search");
+ searchRequest1 = createQueryData("[hello]");
+ searchRequest2 = createQueryData("short search");
+ searchRequest3 = createQueryData("long search");
}
- private static QueryData createQueryData(IOseeBranch branch, String value) {
- QueryData queryData = new QueryData(new CriteriaSet(branch), OptionsUtil.createOptions());
+ private static QueryData createQueryData(String value) {
+ QueryData queryData = new QueryData(new CriteriaSet(), OptionsUtil.createOptions());
Collection<? extends IAttributeType> types = Collections.singleton(CoreAttributeTypes.Name);
queryData.addCriteria(new CriteriaAttributeKeywords(false, types, null, value, TokenDelimiterMatch.ANY,
TokenOrderType.MATCH_ORDER, MatchTokenCountType.IGNORE_TOKEN_COUNT, CaseType.MATCH_CASE));
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/ArtifactDataHandlerProvider.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/ArtifactDataHandlerProvider.java
index df1c6755fb..6516fcbad2 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/ArtifactDataHandlerProvider.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/ArtifactDataHandlerProvider.java
@@ -15,6 +15,6 @@ package org.eclipse.osee.orcs.core.ds;
*/
public interface ArtifactDataHandlerProvider {
- ArtifactDataHandler getArtifactDataHandler();
+ OrcsDataHandler<ArtifactData> getArtifactDataHandler();
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeDataHandlerProvider.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeDataHandlerProvider.java
index 01f6c380e1..c38a6f6927 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeDataHandlerProvider.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeDataHandlerProvider.java
@@ -15,6 +15,6 @@ package org.eclipse.osee.orcs.core.ds;
*/
public interface AttributeDataHandlerProvider {
- AttributeDataHandler getAttributeDataHandler();
+ OrcsDataHandler<AttributeData> getAttributeDataHandler();
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DataPostProcessor.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeDataMatchHandler.java
index fb6c9331b1..64c2ef1fe6 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DataPostProcessor.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeDataMatchHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Boeing.
+ * 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
@@ -10,12 +10,14 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.ds;
-import java.util.concurrent.Callable;
-import org.eclipse.osee.executor.admin.HasCancellation;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
/**
* @author Roberto E. Escobar
*/
-public interface DataPostProcessor<T> extends Callable<T>, HasCancellation {
- //
-}
+public interface AttributeDataMatchHandler {
+
+ void onData(AttributeData data, MatchLocation match) throws OseeCoreException;
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/CriteriaSet.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/CriteriaSet.java
index 1524eb3b85..900d7cb102 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/CriteriaSet.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/CriteriaSet.java
@@ -12,7 +12,7 @@ package org.eclipse.osee.orcs.core.ds;
import java.util.Collection;
import java.util.Iterator;
-import org.eclipse.osee.framework.core.data.IOseeBranch;
+import java.util.Set;
import com.google.common.collect.HashMultimap;
/**
@@ -21,15 +21,6 @@ import com.google.common.collect.HashMultimap;
public class CriteriaSet implements Cloneable, Iterable<Criteria> {
private final HashMultimap<Class<? extends Criteria>, Criteria> criterias = HashMultimap.create();
- private final IOseeBranch branch;
-
- public CriteriaSet(IOseeBranch branch) {
- this.branch = branch;
- }
-
- public IOseeBranch getBranch() {
- return branch;
- }
public void add(Criteria criteria) {
criterias.put(criteria.getClass(), criteria);
@@ -47,13 +38,19 @@ public class CriteriaSet implements Cloneable, Iterable<Criteria> {
criterias.clear();
}
+ @SuppressWarnings("unchecked")
+ public <T extends Criteria> Set<T> getCriteriaByType(Class<T> type) {
+ return (Set<T>) criterias.get(type);
+ }
+
public boolean hasCriteriaType(Class<? extends Criteria> type) {
- return criterias.containsKey(type);
+ Set<Criteria> set = criterias.get(type);
+ return set != null && !set.isEmpty();
}
@Override
public CriteriaSet clone() {
- CriteriaSet clone = new CriteriaSet(this.branch);
+ CriteriaSet clone = new CriteriaSet();
clone.criterias.putAll(this.criterias);
return clone;
}
@@ -66,9 +63,7 @@ public class CriteriaSet implements Cloneable, Iterable<Criteria> {
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
- builder.append("branch=[");
- builder.append(branch);
- builder.append("] criterias=[");
+ builder.append("criterias=[");
builder.append(criterias.values());
builder.append("]");
return builder.toString();
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DataStoreContext.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DataStoreContext.java
index 8c40b7262b..4a653a5508 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DataStoreContext.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DataStoreContext.java
@@ -10,14 +10,11 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.ds;
-import java.util.List;
import org.eclipse.osee.orcs.data.HasSession;
/**
* @author Roberto E. Escobar
*/
-public interface DataStoreContext<P extends DataPostProcessor<?>> extends HasOptions, HasSession {
-
- List<P> getPostProcessors();
-
+public interface DataStoreContext extends HasOptions, HasSession {
+ //
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/HasOptions.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/HasOptions.java
index 57938c6310..556a0cd0fa 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/HasOptions.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/HasOptions.java
@@ -16,5 +16,4 @@ package org.eclipse.osee.orcs.core.ds;
public interface HasOptions {
Options getOptions();
-
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DataPostProcessorFactory.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/IndexedResource.java
index 0eed6face7..88811d6fc3 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DataPostProcessorFactory.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/IndexedResource.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Boeing.
+ * 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
@@ -10,11 +10,17 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.ds;
+import java.io.InputStream;
+import org.eclipse.osee.orcs.data.HasLocalId;
+import com.google.common.io.InputSupplier;
+
/**
* @author Roberto E. Escobar
*/
-public interface DataPostProcessorFactory<C extends Criteria> {
+public interface IndexedResource extends HasLocalId, InputSupplier<InputStream> {
+
+ long getGammaId();
- DataPostProcessor<?> createPostProcessor(C criteria, Options options);
+ long getTypeUuid();
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/LoadContext.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/LoadContext.java
index ba575ebb5c..f68a3f0bc5 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/LoadContext.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/LoadContext.java
@@ -13,6 +13,6 @@ package org.eclipse.osee.orcs.core.ds;
/**
* @author Roberto E. Escobar
*/
-public interface LoadContext extends DataStoreContext<DataPostProcessor<?>> {
+public interface LoadContext extends DataStoreContext {
//
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/LoadDataHandler.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/LoadDataHandler.java
index 4e886b8923..c433b7f84e 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/LoadDataHandler.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/LoadDataHandler.java
@@ -10,12 +10,16 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.ds;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+
/**
* @author Andrew M. Finkbeiner
*/
-public interface LoadDataHandler extends ArtifactDataHandlerProvider, RelationDataHandlerProvider, AttributeDataHandlerProvider {
+public interface LoadDataHandler extends ArtifactDataHandlerProvider, RelationDataHandlerProvider, AttributeDataHandlerProvider, AttributeDataMatchHandler {
+
+ void onLoadStart() throws OseeCoreException;
- void onLoadStart();
+ void onLoadDescription(LoadDescription data) throws OseeCoreException;
void onLoadEnd();
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/LoadDataHandlerAdapter.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/LoadDataHandlerAdapter.java
index 4634fe61e3..0a7d41c36e 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/LoadDataHandlerAdapter.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/LoadDataHandlerAdapter.java
@@ -10,58 +10,88 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.ds;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
+
/**
* @author Roberto E. Escobar
*/
-public abstract class LoadDataHandlerAdapter implements LoadDataHandler {
+public class LoadDataHandlerAdapter implements LoadDataHandler {
- private static final ArtifactDataHandler NOOP_ART_HANDLER = new ArtifactDataHandler() {
+ private final OrcsDataHandler<ArtifactData> artifactHandler = new OrcsDataHandler<ArtifactData>() {
@Override
- public void onData(ArtifactData data) {
- //
+ public void onData(ArtifactData data) throws OseeCoreException {
+ LoadDataHandlerAdapter.this.onData(data);
}
};
- private static final AttributeDataHandler NOOP_ATTR_HANDLER = new AttributeDataHandler() {
+ private final OrcsDataHandler<AttributeData> attributeHandler = new OrcsDataHandler<AttributeData>() {
@Override
- public void onData(AttributeData data) {
- //
+ public void onData(AttributeData data) throws OseeCoreException {
+ LoadDataHandlerAdapter.this.onData(data);
}
};
- private static final RelationDataHandler NOOP_REL_HANDLER = new RelationDataHandler() {
+ private final OrcsDataHandler<RelationData> relationHandler = new OrcsDataHandler<RelationData>() {
@Override
- public void onData(RelationData data) {
- //
+ public void onData(RelationData data) throws OseeCoreException {
+ LoadDataHandlerAdapter.this.onData(data);
}
};
@Override
- public ArtifactDataHandler getArtifactDataHandler() {
- return NOOP_ART_HANDLER;
+ public final OrcsDataHandler<ArtifactData> getArtifactDataHandler() {
+ return artifactHandler;
}
@Override
- public AttributeDataHandler getAttributeDataHandler() {
- return NOOP_ATTR_HANDLER;
+ public final OrcsDataHandler<AttributeData> getAttributeDataHandler() {
+ return attributeHandler;
}
@Override
- public RelationDataHandler getRelationDataHandler() {
- return NOOP_REL_HANDLER;
+ public final OrcsDataHandler<RelationData> getRelationDataHandler() {
+ return relationHandler;
}
+ @SuppressWarnings("unused")
@Override
- public void onLoadStart() {
+ public void onLoadStart() throws OseeCoreException {
//
}
+ @SuppressWarnings("unused")
@Override
- public void onLoadEnd() {
+ public void onLoadDescription(LoadDescription data) throws OseeCoreException {
+ //
+ }
+
+ @SuppressWarnings("unused")
+ public void onData(ArtifactData data) throws OseeCoreException {
//
}
+ @SuppressWarnings("unused")
+ public void onData(AttributeData data) throws OseeCoreException {
+ //
+ }
+
+ @SuppressWarnings("unused")
+ public void onData(RelationData data) throws OseeCoreException {
+ //
+ }
+
+ @Override
+ @SuppressWarnings("unused")
+ public void onData(AttributeData data, MatchLocation match) throws OseeCoreException {
+ //
+ }
+
+ @Override
+ public void onLoadEnd() {
+ //
+ }
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/LoadDataHandlerDecorator.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/LoadDataHandlerDecorator.java
new file mode 100644
index 0000000000..882c280f3a
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/LoadDataHandlerDecorator.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * 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.core.ds;
+
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class LoadDataHandlerDecorator extends LoadDataHandlerAdapter {
+
+ private final LoadDataHandler handler;
+
+ public LoadDataHandlerDecorator(LoadDataHandler handler) {
+ this.handler = handler;
+ }
+
+ public boolean hasValidHandler() {
+ return handler != null;
+ }
+
+ protected LoadDataHandler getHandler() {
+ return handler;
+ }
+
+ @Override
+ public void onLoadStart() throws OseeCoreException {
+ if (handler != null) {
+ handler.onLoadStart();
+ }
+ }
+
+ @Override
+ public void onData(AttributeData data, MatchLocation match) throws OseeCoreException {
+ if (handler != null) {
+ handler.onData(data, match);
+ }
+ }
+
+ @Override
+ public void onLoadDescription(LoadDescription data) throws OseeCoreException {
+ if (handler != null) {
+ handler.onLoadDescription(data);
+ }
+ }
+
+ @Override
+ public void onData(ArtifactData data) throws OseeCoreException {
+ if (handler != null) {
+ handler.getArtifactDataHandler().onData(data);
+ }
+ }
+
+ @Override
+ public void onData(AttributeData data) throws OseeCoreException {
+ if (handler != null) {
+ handler.getAttributeDataHandler().onData(data);
+ }
+ }
+
+ @Override
+ public void onData(RelationData data) throws OseeCoreException {
+ if (handler != null) {
+ handler.getRelationDataHandler().onData(data);
+ }
+ }
+
+ @Override
+ public void onLoadEnd() {
+ if (handler != null) {
+ handler.onLoadEnd();
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/LoadDescription.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/LoadDescription.java
new file mode 100644
index 0000000000..be1f41963a
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/LoadDescription.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * 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.core.ds;
+
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.orcs.data.HasBranch;
+import org.eclipse.osee.orcs.data.HasSession;
+import org.eclipse.osee.orcs.data.HasTransaction;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface LoadDescription extends HasOptions, HasSession, HasBranch, HasTransaction {
+
+ @Override
+ IOseeBranch getBranch();
+
+ boolean isMultiBranch();
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/Options.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/Options.java
index 19e22c665f..c28af39c8e 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/Options.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/Options.java
@@ -18,6 +18,7 @@ import java.util.Map;
* @author Roberto E. Escobar
*/
public class Options implements Cloneable {
+
private static final String EXCEPTION_MESSAGE = "No setting found for key: [%s]";
private final Map<String, String> data = new HashMap<String, String>();
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsDataHandler.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsDataHandler.java
index 70abcf076b..8b22be5c40 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsDataHandler.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsDataHandler.java
@@ -11,11 +11,12 @@
package org.eclipse.osee.orcs.core.ds;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.orcs.data.HasLocalId;
/**
* @author Roberto E. Escobar
*/
-public interface OrcsDataHandler<T extends OrcsData> {
+public interface OrcsDataHandler<T extends HasLocalId> {
void onData(T data) throws OseeCoreException;
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryCollector.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/QueryCollector.java
index 3eb4c7c3ea..8df0211f7f 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryCollector.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/QueryCollector.java
@@ -8,10 +8,9 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs.core.internal.search;
+package org.eclipse.osee.orcs.core.ds;
import org.eclipse.osee.orcs.OrcsSession;
-import org.eclipse.osee.orcs.core.ds.QueryData;
/**
* @author Roberto E. Escobar
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/QueryContext.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/QueryContext.java
index c412adcec6..36d7d7e74d 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/QueryContext.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/QueryContext.java
@@ -10,14 +10,9 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.ds;
-import java.util.List;
-
/**
* @author Roberto E. Escobar
*/
-public interface QueryContext extends DataStoreContext<QueryPostProcessor> {
-
- @Override
- List<QueryPostProcessor> getPostProcessors();
-
+public interface QueryContext extends DataStoreContext {
+ //
}
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 e9094847bc..5ae0c9c373 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
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.ds;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.executor.admin.CancellableCallable;
import org.eclipse.osee.orcs.OrcsSession;
/**
@@ -18,8 +18,8 @@ import org.eclipse.osee.orcs.OrcsSession;
*/
public interface QueryEngine {
- QueryContext createCount(OrcsSession session, QueryData queryData) throws OseeCoreException;
+ CancellableCallable<Integer> createArtifactCount(OrcsSession session, QueryData queryData);
- QueryContext create(OrcsSession session, QueryData queryData) throws OseeCoreException;
+ CancellableCallable<Integer> createArtifactQuery(OrcsSession session, QueryData queryData, LoadDataHandler handler);
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/QueryPostProcessor.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/QueryPostProcessor.java
deleted file mode 100644
index e558c90392..0000000000
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/QueryPostProcessor.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.orcs.core.ds;
-
-import java.util.List;
-import org.eclipse.osee.executor.admin.CancellableCallable;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.data.ArtifactReadable;
-import org.eclipse.osee.orcs.data.AttributeReadable;
-import org.eclipse.osee.orcs.data.AttributeTypes;
-import org.eclipse.osee.orcs.search.Match;
-
-/**
- * @author Roberto E. Escobar
- */
-public abstract class QueryPostProcessor extends CancellableCallable<List<Match<ArtifactReadable, AttributeReadable<?>>>> implements DataPostProcessor<List<Match<ArtifactReadable, AttributeReadable<?>>>> {
-
- private final Log logger;
- private List<ArtifactReadable> artifacts;
- private AttributeTypes types;
-
- protected QueryPostProcessor(Log logger) {
- this.logger = logger;
- }
-
- public void setItemsToProcess(List<ArtifactReadable> artifacts) {
- this.artifacts = artifacts;
- }
-
- protected List<ArtifactReadable> getItemsToProcess() {
- return artifacts;
- }
-
- protected Log getLogger() {
- return logger;
- }
-
- protected AttributeTypes getAttributeTypes() {
- return types;
- }
-
- public void setAttributeTypes(AttributeTypes types) {
- this.types = types;
- }
-
- @Override
- public final List<Match<ArtifactReadable, AttributeReadable<?>>> call() throws Exception {
- long startTime = 0;
- if (logger.isTraceEnabled()) {
- startTime = System.currentTimeMillis();
- }
- List<Match<ArtifactReadable, AttributeReadable<?>>> results = innerCall();
- checkForCancelled();
- if (logger.isTraceEnabled()) {
- logger.trace("Query post processor processed [%s] items in [%s]", getItemsToProcess().size(),
- Lib.getElapseString(startTime));
- }
- return results;
- }
-
- protected abstract List<Match<ArtifactReadable, AttributeReadable<?>>> innerCall() throws Exception;
-}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/RelationDataHandler.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/RelationDataHandler.java
deleted file mode 100644
index d4d7c0a43d..0000000000
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/RelationDataHandler.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.orcs.core.ds;
-
-
-/**
- * @author Andrew M. Finkbeiner
- */
-public interface RelationDataHandler extends OrcsDataHandler<RelationData> {
- //
-}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/RelationDataHandlerProvider.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/RelationDataHandlerProvider.java
index d7ad639ade..d7feeb4559 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/RelationDataHandlerProvider.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/RelationDataHandlerProvider.java
@@ -15,6 +15,6 @@ package org.eclipse.osee.orcs.core.ds;
*/
public interface RelationDataHandlerProvider {
- RelationDataHandler getRelationDataHandler();
+ OrcsDataHandler<RelationData> getRelationDataHandler();
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaBranch.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaBranch.java
new file mode 100644
index 0000000000..1b23df558d
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaBranch.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * 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.core.ds.criteria;
+
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.util.Conditions;
+import org.eclipse.osee.orcs.core.ds.Criteria;
+import org.eclipse.osee.orcs.core.ds.Options;
+import org.eclipse.osee.orcs.data.HasBranch;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class CriteriaBranch extends Criteria implements HasBranch {
+
+ private final IOseeBranch branch;
+
+ public CriteriaBranch(IOseeBranch branch) {
+ super();
+ this.branch = branch;
+ }
+
+ @Override
+ public void checkValid(Options options) throws OseeCoreException {
+ super.checkValid(options);
+ Conditions.checkNotNull(branch, "branch");
+ }
+
+ @Override
+ public IOseeBranch getBranch() {
+ return branch;
+ }
+
+ @Override
+ public String toString() {
+ return "CriteriaBranch [branch=" + branch + "]";
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java
index 9d2bbaf3b6..d3bd978e16 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java
@@ -156,8 +156,8 @@ public class OrcsApiImpl implements OrcsApi {
loaderFactory = new ArtifactLoaderFactoryImpl(module.getDataLoaderFactory(), builderFactory);
queryModule =
- new QueryModule(logger, module.getQueryEngine(), loaderFactory, module.getDataLoaderFactory(),
- orcsTypes.getArtifactTypes(), orcsTypes.getAttributeTypes());
+ new QueryModule(logger, module.getQueryEngine(), builderFactory, orcsTypes.getArtifactTypes(),
+ orcsTypes.getAttributeTypes());
indexerModule = new IndexerModule(logger, preferences, executorAdmin, dataStore.getQueryEngineIndexer());
indexerModule.start(getSystemSession(), orcsTypes.getAttributeTypes());
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactBuilderImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactBuilderImpl.java
index 6b726fdaaf..a870ecbfa6 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactBuilderImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactBuilderImpl.java
@@ -22,14 +22,13 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.util.Conditions;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.core.ds.ArtifactData;
-import org.eclipse.osee.orcs.core.ds.ArtifactDataHandler;
import org.eclipse.osee.orcs.core.ds.AttributeData;
-import org.eclipse.osee.orcs.core.ds.AttributeDataHandler;
+import org.eclipse.osee.orcs.core.ds.LoadDataHandlerAdapter;
+import org.eclipse.osee.orcs.core.ds.LoadDescription;
import org.eclipse.osee.orcs.core.ds.RelationData;
-import org.eclipse.osee.orcs.core.ds.RelationDataHandler;
import org.eclipse.osee.orcs.core.internal.ArtifactBuilder;
-import org.eclipse.osee.orcs.core.internal.artifact.ArtifactFactory;
import org.eclipse.osee.orcs.core.internal.artifact.Artifact;
+import org.eclipse.osee.orcs.core.internal.artifact.ArtifactFactory;
import org.eclipse.osee.orcs.core.internal.attribute.AttributeFactory;
import org.eclipse.osee.orcs.core.internal.attribute.AttributeManager;
import org.eclipse.osee.orcs.core.internal.proxy.ArtifactProxyFactory;
@@ -39,15 +38,11 @@ import org.eclipse.osee.orcs.data.ArtifactReadable;
/**
* @author Andrew M. Finkbeiner
*/
-public class ArtifactBuilderImpl implements ArtifactBuilder {
+public class ArtifactBuilderImpl extends LoadDataHandlerAdapter implements ArtifactBuilder {
private final Map<Integer, RelationContainer> relations = new HashMap<Integer, RelationContainer>();;
private final Map<Integer, AttributeManager> attributes = new HashMap<Integer, AttributeManager>();
- private final ArtifactDataHandler artifactAdaptor = new ArtifactDataAdaptor();
- private final AttributeDataHandler attributeAdaptor = new AttributeDataAdaptor();
- private final RelationDataHandler relationAdaptor = new RelationDataAdaptor();
-
private final Log logger;
private final ArtifactProxyFactory proxyFactory;
@@ -72,6 +67,11 @@ public class ArtifactBuilderImpl implements ArtifactBuilder {
}
@Override
+ public void onLoadDescription(LoadDescription data) {
+ //
+ };
+
+ @Override
public void onLoadStart() {
artifacts.clear();
created.clear();
@@ -103,21 +103,7 @@ public class ArtifactBuilderImpl implements ArtifactBuilder {
}
@Override
- public ArtifactDataHandler getArtifactDataHandler() {
- return artifactAdaptor;
- }
-
- @Override
- public AttributeDataHandler getAttributeDataHandler() {
- return attributeAdaptor;
- }
-
- @Override
- public RelationDataHandler getRelationDataHandler() {
- return relationAdaptor;
- }
-
- private void handle(ArtifactData data) throws OseeCoreException {
+ public void onData(ArtifactData data) throws OseeCoreException {
Artifact artifact = getCachedArtifact(data);
if (artifact == null) {
artifact = artifactFactory.createArtifact(data);
@@ -128,7 +114,8 @@ public class ArtifactBuilderImpl implements ArtifactBuilder {
relations.put(artifact.getLocalId(), artifact.getRelationContainer());
}
- private void handle(AttributeData data) throws OseeCoreException {
+ @Override
+ public void onData(AttributeData data) throws OseeCoreException {
AttributeManager container = attributes.get(data.getArtifactId());
if (container == null) {
logger.warn("Orphaned attribute detected - [%s]", data);
@@ -137,32 +124,12 @@ public class ArtifactBuilderImpl implements ArtifactBuilder {
}
}
- private void handle(RelationData data) throws OseeCoreException {
+ @Override
+ public void onData(RelationData data) throws OseeCoreException {
RelationContainer container = relations.get(data.getParentId());
Conditions.checkNotNull(container, "RelationContainer",
"Invalid relation data container not found - data[%s]. . ", data);
container.add(data);
}
- private final class ArtifactDataAdaptor implements ArtifactDataHandler {
- @Override
- public void onData(ArtifactData data) throws OseeCoreException {
- handle(data);
- }
- };
-
- private final class AttributeDataAdaptor implements AttributeDataHandler {
- @Override
- public void onData(AttributeData data) throws OseeCoreException {
- handle(data);
- }
-
- };
-
- private final class RelationDataAdaptor implements RelationDataHandler {
- @Override
- public void onData(RelationData data) throws OseeCoreException {
- handle(data);
- }
- };
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/ArtifactMatchDataHandler.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/ArtifactMatchDataHandler.java
new file mode 100644
index 0000000000..c3c8814385
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/ArtifactMatchDataHandler.java
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * 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.core.internal.search;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
+import org.eclipse.osee.orcs.core.ds.AttributeData;
+import org.eclipse.osee.orcs.core.ds.LoadDataHandlerDecorator;
+import org.eclipse.osee.orcs.core.internal.ArtifactBuilder;
+import org.eclipse.osee.orcs.data.ArtifactReadable;
+import org.eclipse.osee.orcs.data.AttributeReadable;
+import org.eclipse.osee.orcs.search.Match;
+import com.google.common.base.Supplier;
+import com.google.common.collect.ListMultimap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Multimaps;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class ArtifactMatchDataHandler extends LoadDataHandlerDecorator {
+
+ private final ArtifactBuilder handler;
+
+ private final Map<Integer, ArtifactMatch> matches = new HashMap<Integer, ArtifactMatch>();
+ private List<Match<ArtifactReadable, AttributeReadable<?>>> results;
+
+ public ArtifactMatchDataHandler(ArtifactBuilder handler) {
+ super(handler);
+ this.handler = handler;
+ }
+
+ @Override
+ public void onData(AttributeData data, MatchLocation match) throws OseeCoreException {
+ super.onData(data, match);
+ Integer artId = data.getArtifactId();
+ synchronized (matches) {
+ ArtifactMatch artifactMatch = matches.get(artId);
+ if (artifactMatch == null) {
+ artifactMatch = new ArtifactMatch();
+ artifactMatch.addLocation(data.getLocalId(), match);
+ }
+ matches.put(artId, artifactMatch);
+ }
+ }
+
+ @Override
+ public void onLoadEnd() {
+ super.onLoadEnd();
+ buildResults();
+ }
+
+ private void buildResults() {
+ List<ArtifactReadable> loaded = handler.getArtifacts();
+
+ if (loaded.isEmpty()) {
+ results = Collections.emptyList();
+ } else {
+ results = Lists.newLinkedList();
+ for (ArtifactReadable item : loaded) {
+ ArtifactMatch artifactMatch = matches.get(item.getLocalId());
+ if (artifactMatch != null) {
+ artifactMatch.setArtifactReadable(item);
+ }
+ results.add(artifactMatch);
+ }
+ }
+ matches.clear();
+ }
+
+ public List<Match<ArtifactReadable, AttributeReadable<?>>> getResults() {
+ return results;
+ }
+
+ private static <K, V> ListMultimap<K, V> newLinkedHashListMultimap() {
+ Map<K, Collection<V>> map = new LinkedHashMap<K, Collection<V>>();
+ return Multimaps.newListMultimap(map, new Supplier<List<V>>() {
+ @Override
+ public List<V> get() {
+ return Lists.newArrayList();
+ }
+ });
+ }
+
+ private static final class ArtifactMatch implements Match<ArtifactReadable, AttributeReadable<?>> {
+
+ private final ListMultimap<Integer, MatchLocation> matches = newLinkedHashListMultimap();
+ private ArtifactReadable item;
+
+ public ArtifactMatch() {
+ super();
+ }
+
+ public void setArtifactReadable(ArtifactReadable item) {
+ this.item = item;
+ }
+
+ public void addLocation(Integer attrId, MatchLocation location) {
+ matches.put(attrId, location);
+ }
+
+ @Override
+ public boolean hasLocationData() {
+ return !matches.isEmpty();
+ }
+
+ @Override
+ public ArtifactReadable getItem() {
+ return item;
+ }
+
+ @Override
+ public Collection<AttributeReadable<?>> getElements() throws OseeCoreException {
+ Collection<AttributeReadable<?>> filtered = Lists.newLinkedList();
+ List<AttributeReadable<Object>> attributes = item.getAttributes();
+ for (AttributeReadable<?> attribute : attributes) {
+ if (matches.containsKey(attribute.getId())) {
+ filtered.add(attribute);
+ }
+ }
+ return filtered;
+ }
+
+ @Override
+ public List<MatchLocation> getLocation(AttributeReadable<?> element) {
+ List<MatchLocation> toReturn = matches.get(element.getId());
+ return toReturn != null ? toReturn : Collections.<MatchLocation> emptyList();
+ }
+
+ @Override
+ public String toString() {
+ return "ArtifactMatch [item=" + item + ", matches=" + matches + "]";
+ }
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/CallableQueryFactory.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/CallableQueryFactory.java
index 4198884455..c89ba4e22c 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/CallableQueryFactory.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/CallableQueryFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
+ * 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
@@ -10,22 +10,25 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.internal.search;
+import java.util.LinkedList;
+import java.util.List;
import org.eclipse.osee.executor.admin.CancellableCallable;
import org.eclipse.osee.framework.core.data.ResultSet;
+import org.eclipse.osee.framework.core.data.ResultSetList;
import org.eclipse.osee.framework.core.enums.LoadLevel;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.OrcsSession;
-import org.eclipse.osee.orcs.core.ds.DataLoaderFactory;
+import org.eclipse.osee.orcs.core.ds.ArtifactData;
+import org.eclipse.osee.orcs.core.ds.LoadDataHandlerAdapter;
+import org.eclipse.osee.orcs.core.ds.OptionsUtil;
+import org.eclipse.osee.orcs.core.ds.QueryCollector;
import org.eclipse.osee.orcs.core.ds.QueryData;
import org.eclipse.osee.orcs.core.ds.QueryEngine;
-import org.eclipse.osee.orcs.core.internal.ArtifactLoaderFactory;
-import org.eclipse.osee.orcs.core.internal.search.callable.LocalIdSearchCallable;
-import org.eclipse.osee.orcs.core.internal.search.callable.SearchCallable;
-import org.eclipse.osee.orcs.core.internal.search.callable.SearchCountCallable;
-import org.eclipse.osee.orcs.core.internal.search.callable.SearchMatchesCallable;
+import org.eclipse.osee.orcs.core.internal.ArtifactBuilder;
+import org.eclipse.osee.orcs.core.internal.ArtifactBuilderFactory;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.AttributeReadable;
-import org.eclipse.osee.orcs.data.AttributeTypes;
import org.eclipse.osee.orcs.data.HasLocalId;
import org.eclipse.osee.orcs.search.Match;
@@ -36,36 +39,137 @@ public class CallableQueryFactory {
private final Log logger;
private final QueryEngine queryEngine;
- private final ArtifactLoaderFactory objectLoader;
private final QueryCollector collector;
- private final DataLoaderFactory dataLoader;
- private final AttributeTypes types;
+ private final ArtifactBuilderFactory builderFactory;
- public CallableQueryFactory(Log logger, QueryEngine queryEngine, QueryCollector collector, ArtifactLoaderFactory objectLoader, DataLoaderFactory dataLoader, AttributeTypes types) {
+ public CallableQueryFactory(Log logger, QueryEngine queryEngine, QueryCollector collector, ArtifactBuilderFactory builderFactory) {
super();
this.logger = logger;
this.queryEngine = queryEngine;
- this.objectLoader = objectLoader;
this.collector = collector;
- this.dataLoader = dataLoader;
- this.types = types;
+ this.builderFactory = builderFactory;
}
public CancellableCallable<Integer> createCount(OrcsSession session, QueryData queryData) {
- return new SearchCountCallable(logger, queryEngine, collector, objectLoader, session, LoadLevel.ATTRIBUTE,
- queryData, types);
+ return new AbstractSearchCallable<Integer>(session, queryData) {
+ @Override
+ protected Integer innerCall() throws Exception {
+ Integer results = queryEngine.createArtifactCount(getSession(), getQueryData()).call();
+ setItemsFound(results);
+ return results;
+ }
+ };
+ }
+
+ public CancellableCallable<ResultSet<HasLocalId>> createLocalIdSearch(OrcsSession session, QueryData queryData) {
+ return new AbstractSearchCallable<ResultSet<HasLocalId>>(session, queryData) {
+
+ @Override
+ protected ResultSet<HasLocalId> innerCall() throws Exception {
+ final List<HasLocalId> results = new LinkedList<HasLocalId>();
+ LoadDataHandlerAdapter handler = new LoadDataHandlerAdapter() {
+ @Override
+ public void onData(ArtifactData data) {
+ results.add(data);
+ }
+ };
+ OptionsUtil.setLoadLevel(getQueryData().getOptions(), LoadLevel.ATTRIBUTE);
+ queryEngine.createArtifactQuery(getSession(), getQueryData(), handler).call();
+ setItemsFound(results.size());
+ return new ResultSetList<HasLocalId>(results);
+ }
+ };
}
public CancellableCallable<ResultSet<ArtifactReadable>> createSearch(OrcsSession session, QueryData queryData) {
- return new SearchCallable(logger, queryEngine, collector, objectLoader, session, LoadLevel.FULL,
- queryData, types);
+ return new AbstractSearchCallable<ResultSet<ArtifactReadable>>(session, queryData) {
+
+ @Override
+ protected ResultSet<ArtifactReadable> innerCall() throws Exception {
+ ArtifactBuilder handler = builderFactory.createArtifactBuilder();
+ OptionsUtil.setLoadLevel(getQueryData().getOptions(), LoadLevel.FULL);
+ queryEngine.createArtifactQuery(getSession(), getQueryData(), handler).call();
+ List<ArtifactReadable> results = handler.getArtifacts();
+ setItemsFound(results.size());
+ return new ResultSetList<ArtifactReadable>(results);
+ }
+ };
}
public CancellableCallable<ResultSet<Match<ArtifactReadable, AttributeReadable<?>>>> createSearchWithMatches(OrcsSession session, QueryData queryData) {
- return new SearchMatchesCallable(logger, queryEngine, collector, objectLoader, session, LoadLevel.FULL, queryData, types);
+ return new AbstractSearchCallable<ResultSet<Match<ArtifactReadable, AttributeReadable<?>>>>(session, queryData) {
+
+ @Override
+ protected ResultSet<Match<ArtifactReadable, AttributeReadable<?>>> innerCall() throws Exception {
+ ArtifactBuilder builder = builderFactory.createArtifactBuilder();
+ ArtifactMatchDataHandler handler = new ArtifactMatchDataHandler(builder);
+ OptionsUtil.setLoadLevel(getQueryData().getOptions(), LoadLevel.FULL);
+ queryEngine.createArtifactQuery(getSession(), getQueryData(), handler).call();
+
+ List<Match<ArtifactReadable, AttributeReadable<?>>> results = handler.getResults();
+ setItemsFound(results.size());
+ return new ResultSetList<Match<ArtifactReadable, AttributeReadable<?>>>(results);
+ }
+ };
}
- public CancellableCallable<ResultSet<HasLocalId>> createLocalIdSearch(OrcsSession session, QueryData queryData) {
- return new LocalIdSearchCallable(logger, queryEngine, collector, objectLoader, dataLoader, session, queryData, types);
+ private abstract class AbstractSearchCallable<T> extends CancellableCallable<T> {
+
+ private final OrcsSession session;
+ private final QueryData queryData;
+ private int itemsFound = 0;
+
+ public AbstractSearchCallable(OrcsSession session, QueryData queryData) {
+ super();
+ this.session = session;
+ this.queryData = queryData;
+ }
+
+ protected OrcsSession getSession() {
+ return session;
+ }
+
+ protected QueryData getQueryData() {
+ return queryData;
+ }
+
+ protected void setItemsFound(int itemsFound) {
+ this.itemsFound = itemsFound;
+ }
+
+ @Override
+ public final T call() throws Exception {
+ long startTime = System.currentTimeMillis();
+ long endTime = startTime;
+ T result = null;
+ try {
+ if (logger.isTraceEnabled()) {
+ logger.trace("%s [start] - [%s]", getClass().getSimpleName(), queryData);
+ }
+ result = innerCall();
+ } finally {
+ endTime = System.currentTimeMillis() - startTime;
+ }
+ if (result != null) {
+ notifyStats(endTime);
+ }
+ if (logger.isTraceEnabled()) {
+ logger.trace("%s [%s] - completed [%s]", getClass().getSimpleName(), Lib.asTimeString(endTime), queryData);
+ }
+ return result;
+ }
+
+ private void notifyStats(long processingTime) {
+ if (collector != null) {
+ try {
+ collector.collect(session, itemsFound, processingTime, queryData);
+ } catch (Exception ex) {
+ logger.error(ex, "Error reporting search to search collector\n%s", queryData);
+ }
+ }
+ }
+
+ protected abstract T innerCall() throws Exception;
+
}
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryBuilderImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryBuilderImpl.java
index 15c4977441..d65e187b21 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryBuilderImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryBuilderImpl.java
@@ -36,6 +36,7 @@ import org.eclipse.osee.orcs.core.ds.CriteriaSet;
import org.eclipse.osee.orcs.core.ds.Options;
import org.eclipse.osee.orcs.core.ds.OptionsUtil;
import org.eclipse.osee.orcs.core.ds.QueryData;
+import org.eclipse.osee.orcs.core.ds.criteria.CriteriaBranch;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.AttributeReadable;
import org.eclipse.osee.orcs.data.HasLocalId;
@@ -369,7 +370,8 @@ public class QueryBuilderImpl implements QueryBuilder {
private QueryData checkAndCloneQueryData() throws OseeCoreException {
QueryData queryData = getQueryData().clone();
CriteriaSet criteriaSet = queryData.getCriteriaSet();
- if (criteriaSet.getBranch() != null && criteriaSet.getCriterias().isEmpty()) {
+ Collection<Criteria> criterias = criteriaSet.getCriterias();
+ if (criterias.isEmpty() || (criterias.size() == 1 && criteriaSet.hasCriteriaType(CriteriaBranch.class))) {
addAndCheck(queryData, criteriaFactory.createAllArtifactsCriteria());
}
return queryData;
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 e00a918413..af08a89550 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
@@ -22,6 +22,7 @@ import org.eclipse.osee.orcs.core.ds.CriteriaSet;
import org.eclipse.osee.orcs.core.ds.Options;
import org.eclipse.osee.orcs.core.ds.OptionsUtil;
import org.eclipse.osee.orcs.core.ds.QueryData;
+import org.eclipse.osee.orcs.core.ds.criteria.CriteriaBranch;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.search.QueryBuilder;
import org.eclipse.osee.orcs.search.QueryFactory;
@@ -44,15 +45,18 @@ public class QueryFactoryImpl implements QueryFactory {
private QueryBuilder createBuilder(IOseeBranch branch) {
Options options = OptionsUtil.createOptions();
- CriteriaSet criteriaSet = new CriteriaSet(branch);
+ CriteriaSet criteriaSet = new CriteriaSet();
+ if (branch != null) {
+ criteriaSet.add(new CriteriaBranch(branch));
+ }
QueryData queryData = new QueryData(criteriaSet, options);
QueryBuilder builder = new QueryBuilderImpl(queryFctry, criteriaFctry, context, queryData);
return builder;
}
- @SuppressWarnings("unused")
@Override
public QueryBuilder fromBranch(IOseeBranch branch) throws OseeCoreException {
+ Conditions.checkNotNull(branch, "branch");
return createBuilder(branch);
}
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 eb20843ecf..d82520e816 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
@@ -11,10 +11,9 @@
package org.eclipse.osee.orcs.core.internal.search;
import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.core.ds.DataLoaderFactory;
import org.eclipse.osee.orcs.OrcsSession;
import org.eclipse.osee.orcs.core.ds.QueryEngine;
-import org.eclipse.osee.orcs.core.internal.ArtifactLoaderFactory;
+import org.eclipse.osee.orcs.core.internal.ArtifactBuilderFactory;
import org.eclipse.osee.orcs.core.internal.HasStatistics;
import org.eclipse.osee.orcs.data.ArtifactTypes;
import org.eclipse.osee.orcs.data.AttributeTypes;
@@ -31,12 +30,10 @@ public class QueryModule implements HasStatistics<QueryStatistics> {
private final CriteriaFactory criteriaFctry;
private final CallableQueryFactory callableQueryFactory;
- public QueryModule(Log logger, QueryEngine queryEngine, ArtifactLoaderFactory objectLoader, DataLoaderFactory dataLoader, ArtifactTypes artifactTypeCache, AttributeTypes attributeTypeCache) {
+ public QueryModule(Log logger, QueryEngine queryEngine, ArtifactBuilderFactory builderFactory, ArtifactTypes artifactTypeCache, AttributeTypes attributeTypeCache) {
QueryStatsCollectorImpl queryStatsCollector = new QueryStatsCollectorImpl(statistics);
this.criteriaFctry = new CriteriaFactory(artifactTypeCache, attributeTypeCache);
- this.callableQueryFactory =
- new CallableQueryFactory(logger, queryEngine, queryStatsCollector, objectLoader, dataLoader,
- attributeTypeCache);
+ this.callableQueryFactory = new CallableQueryFactory(logger, queryEngine, queryStatsCollector, builderFactory);
}
public QueryFactory createQueryFactory(OrcsSession session) {
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryStatsCollectorImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryStatsCollectorImpl.java
index c42dd5c8f7..60b26d2996 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryStatsCollectorImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryStatsCollectorImpl.java
@@ -11,6 +11,7 @@
package org.eclipse.osee.orcs.core.internal.search;
import org.eclipse.osee.orcs.OrcsSession;
+import org.eclipse.osee.orcs.core.ds.QueryCollector;
import org.eclipse.osee.orcs.core.ds.QueryData;
/**
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/AbstractArtifactSearchCallable.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/AbstractArtifactSearchCallable.java
deleted file mode 100644
index e453424480..0000000000
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/AbstractArtifactSearchCallable.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 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.core.internal.search.callable;
-
-import org.eclipse.osee.framework.core.enums.LoadLevel;
-import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.OrcsSession;
-import org.eclipse.osee.orcs.core.ds.QueryData;
-import org.eclipse.osee.orcs.core.ds.QueryEngine;
-import org.eclipse.osee.orcs.core.internal.ArtifactLoaderFactory;
-import org.eclipse.osee.orcs.core.internal.search.QueryCollector;
-import org.eclipse.osee.orcs.data.AttributeTypes;
-
-/**
- * @author Roberto E. Escobar
- */
-public abstract class AbstractArtifactSearchCallable<T> extends AbstractSearchCallable<T> {
-
- protected final ArtifactLoaderFactory objectLoader;
-
- public AbstractArtifactSearchCallable(Log logger, QueryEngine queryEngine, QueryCollector collector, ArtifactLoaderFactory objectLoader, OrcsSession session, LoadLevel loadLevel, QueryData queryData, AttributeTypes types) {
- super(logger, queryEngine, collector, session, loadLevel, queryData, types);
- this.objectLoader = objectLoader;
- }
-
-}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/AbstractSearchCallable.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/AbstractSearchCallable.java
deleted file mode 100644
index f36741d18e..0000000000
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/AbstractSearchCallable.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.orcs.core.internal.search.callable;
-
-import org.eclipse.osee.executor.admin.CancellableCallable;
-import org.eclipse.osee.framework.core.enums.LoadLevel;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.OrcsSession;
-import org.eclipse.osee.orcs.core.ds.QueryData;
-import org.eclipse.osee.orcs.core.ds.QueryEngine;
-import org.eclipse.osee.orcs.core.internal.search.QueryCollector;
-import org.eclipse.osee.orcs.data.AttributeTypes;
-
-/**
- * @author Roberto E. Escobar
- */
-public abstract class AbstractSearchCallable<T> extends CancellableCallable<T> {
-
- protected final Log logger;
- protected final QueryEngine queryEngine;
- protected final OrcsSession session;
- protected final LoadLevel loadLevel;
- protected final QueryData queryData;
- private final QueryCollector collector;
- protected final AttributeTypes types;
-
- public AbstractSearchCallable(Log logger, QueryEngine queryEngine, QueryCollector collector, OrcsSession session, LoadLevel loadLevel, QueryData queryData, AttributeTypes types) {
- super();
- this.logger = logger;
- this.queryEngine = queryEngine;
- this.collector = collector;
- this.session = session;
- this.loadLevel = loadLevel;
- this.queryData = queryData;
- this.types = types;
- }
-
- protected OrcsSession getSession() {
- return session;
- }
-
- protected Log getLogger() {
- return logger;
- }
-
- @Override
- public final T call() throws Exception {
- long startTime = System.currentTimeMillis();
- long endTime = startTime;
- T result = null;
- try {
- if (logger.isTraceEnabled()) {
- logger.trace("%s [start] - [%s]", getClass().getSimpleName(), queryData);
- }
- result = innerCall();
- } finally {
- endTime = System.currentTimeMillis() - startTime;
- }
- if (result != null) {
- notifyStats(result, endTime);
- }
- if (logger.isTraceEnabled()) {
- logger.trace("%s [%s] - completed [%s]", getClass().getSimpleName(), Lib.asTimeString(endTime), queryData);
- }
- return result;
- }
-
- private void notifyStats(T result, long processingTime) {
- if (collector != null) {
- try {
- int itemsFound = getCount(result);
- collector.collect(session, itemsFound, processingTime, queryData);
- } catch (Exception ex) {
- logger.error(ex, "Error reporting search to search collector\n%s", queryData);
- }
- }
- }
-
- protected abstract int getCount(T results) throws Exception;
-
- protected abstract T innerCall() throws Exception;
-
-}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/DefaultQueryPostProcessor.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/DefaultQueryPostProcessor.java
deleted file mode 100644
index b6b08792e4..0000000000
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/DefaultQueryPostProcessor.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.orcs.core.internal.search.callable;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import org.eclipse.osee.framework.core.util.Conditions;
-import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
-import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.core.ds.QueryPostProcessor;
-import org.eclipse.osee.orcs.data.ArtifactReadable;
-import org.eclipse.osee.orcs.data.AttributeReadable;
-import org.eclipse.osee.orcs.search.Match;
-
-public class DefaultQueryPostProcessor extends QueryPostProcessor {
-
- public DefaultQueryPostProcessor(Log logger) {
- super(logger);
- }
-
- @Override
- public List<Match<ArtifactReadable, AttributeReadable<?>>> innerCall() throws Exception {
- Conditions.checkNotNull(getItemsToProcess(), "Query first pass results");
-
- List<Match<ArtifactReadable, AttributeReadable<?>>> results =
- new ArrayList<Match<ArtifactReadable, AttributeReadable<?>>>();
-
- for (final ArtifactReadable art : getItemsToProcess()) {
- checkForCancelled();
- results.add(new Match<ArtifactReadable, AttributeReadable<?>>() {
-
- @Override
- public boolean hasLocationData() {
- return false;
- }
-
- @Override
- public ArtifactReadable getItem() {
- return art;
- }
-
- @Override
- public Collection<AttributeReadable<?>> getElements() {
- return Collections.emptyList();
- }
-
- @Override
- public List<MatchLocation> getLocation(AttributeReadable<?> element) {
- return Collections.emptyList();
- }
- });
- }
- return results;
- }
-}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/LocalIdSearchCallable.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/LocalIdSearchCallable.java
deleted file mode 100644
index b0f90713f7..0000000000
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/LocalIdSearchCallable.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 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.core.internal.search.callable;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import org.eclipse.osee.framework.core.data.ResultSet;
-import org.eclipse.osee.framework.core.data.ResultSetList;
-import org.eclipse.osee.framework.core.enums.LoadLevel;
-import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.OrcsSession;
-import org.eclipse.osee.orcs.core.ds.ArtifactData;
-import org.eclipse.osee.orcs.core.ds.ArtifactDataHandler;
-import org.eclipse.osee.orcs.core.ds.DataLoader;
-import org.eclipse.osee.orcs.core.ds.DataLoaderFactory;
-import org.eclipse.osee.orcs.core.ds.LoadDataHandlerAdapter;
-import org.eclipse.osee.orcs.core.ds.QueryContext;
-import org.eclipse.osee.orcs.core.ds.QueryData;
-import org.eclipse.osee.orcs.core.ds.QueryEngine;
-import org.eclipse.osee.orcs.core.ds.QueryPostProcessor;
-import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAttributeKeywords;
-import org.eclipse.osee.orcs.core.internal.ArtifactLoader;
-import org.eclipse.osee.orcs.core.internal.ArtifactLoaderFactory;
-import org.eclipse.osee.orcs.core.internal.search.QueryCollector;
-import org.eclipse.osee.orcs.data.ArtifactReadable;
-import org.eclipse.osee.orcs.data.AttributeReadable;
-import org.eclipse.osee.orcs.data.AttributeTypes;
-import org.eclipse.osee.orcs.data.HasLocalId;
-import org.eclipse.osee.orcs.search.Match;
-
-/**
- * @author Roberto E. Escobar
- */
-public class LocalIdSearchCallable extends AbstractSearchCallable<ResultSet<HasLocalId>> {
-
- private final ArtifactLoaderFactory objectLoader;
- private final DataLoaderFactory dataLoaderFactory;
-
- public LocalIdSearchCallable(Log logger, QueryEngine queryEngine, QueryCollector collector, ArtifactLoaderFactory objectLoader, DataLoaderFactory dataLoaderFactory, OrcsSession session, QueryData queryData, AttributeTypes types) {
- super(logger, queryEngine, collector, session, LoadLevel.SHALLOW, queryData, types);
- this.dataLoaderFactory = dataLoaderFactory;
- this.objectLoader = objectLoader;
- }
-
- @Override
- protected int getCount(ResultSet<HasLocalId> results) throws Exception {
- return results.getList().size();
- }
-
- @Override
- protected ResultSet<HasLocalId> innerCall() throws Exception {
- QueryContext queryContext = queryEngine.create(getSession(), queryData);
-
- checkForCancelled();
-
- boolean requiresAttributeScan =
- queryData.hasCriteriaType(CriteriaAttributeKeywords.class) && !queryContext.getPostProcessors().isEmpty();
-
- List<HasLocalId> results = new ArrayList<HasLocalId>();
- if (requiresAttributeScan) {
- ArtifactLoader loader = objectLoader.fromQueryContext(getSession(), queryContext);
- loader.setOptions(queryData.getOptions());
- loader.setLoadLevel(LoadLevel.ATTRIBUTE);
- checkForCancelled();
-
- List<ArtifactReadable> artifacts = loader.load(this);
-
- checkForCancelled();
-
- if (!queryContext.getPostProcessors().isEmpty()) {
- for (QueryPostProcessor processor : queryContext.getPostProcessors()) {
- processor.setItemsToProcess(artifacts);
- processor.setAttributeTypes(types);
- checkForCancelled();
- List<Match<ArtifactReadable, AttributeReadable<?>>> matches = processor.call();
- for (Match<ArtifactReadable, AttributeReadable<?>> match : matches) {
- results.add(match.getItem());
- checkForCancelled();
- }
- }
- } else {
- results.addAll(artifacts);
- }
- } else {
- DataLoader loader = dataLoaderFactory.fromQueryContext(queryContext);
- loader.setOptions(queryData.getOptions());
- loader.setLoadLevel(LoadLevel.SHALLOW);
- loader.load(this, new AdapterBuidler(results));
- }
- checkForCancelled();
- return new ResultSetList<HasLocalId>(results);
- }
- private static final class AdapterBuidler extends LoadDataHandlerAdapter {
-
- private final Collection<HasLocalId> results;
-
- public AdapterBuidler(Collection<HasLocalId> results) {
- super();
- this.results = results;
- }
-
- @Override
- public ArtifactDataHandler getArtifactDataHandler() {
- return new ArtifactDataHandler() {
-
- @Override
- public void onData(ArtifactData data) {
- results.add(data);
- }
- };
- }
- }
-
-}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/SearchCallable.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/SearchCallable.java
deleted file mode 100644
index bd3aa9bcde..0000000000
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/SearchCallable.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.orcs.core.internal.search.callable;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.osee.framework.core.data.ResultSet;
-import org.eclipse.osee.framework.core.data.ResultSetList;
-import org.eclipse.osee.framework.core.enums.LoadLevel;
-import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.OrcsSession;
-import org.eclipse.osee.orcs.core.ds.QueryContext;
-import org.eclipse.osee.orcs.core.ds.QueryData;
-import org.eclipse.osee.orcs.core.ds.QueryEngine;
-import org.eclipse.osee.orcs.core.ds.QueryPostProcessor;
-import org.eclipse.osee.orcs.core.internal.ArtifactLoader;
-import org.eclipse.osee.orcs.core.internal.ArtifactLoaderFactory;
-import org.eclipse.osee.orcs.core.internal.search.QueryCollector;
-import org.eclipse.osee.orcs.data.ArtifactReadable;
-import org.eclipse.osee.orcs.data.AttributeReadable;
-import org.eclipse.osee.orcs.data.AttributeTypes;
-import org.eclipse.osee.orcs.search.Match;
-
-/**
- * @author Roberto E. Escobar
- */
-public class SearchCallable extends AbstractArtifactSearchCallable<ResultSet<ArtifactReadable>> {
-
- private QueryContext queryContext;
-
- public SearchCallable(Log logger, QueryEngine queryEngine, QueryCollector collector, ArtifactLoaderFactory objectLoader, OrcsSession session, LoadLevel loadLevel, QueryData queryData, AttributeTypes types) {
- super(logger, queryEngine, collector, objectLoader, session, loadLevel, queryData, types);
- }
-
- @Override
- protected ResultSet<ArtifactReadable> innerCall() throws Exception {
- QueryContext queryContext = queryEngine.create(session, queryData);
-
- checkForCancelled();
-
- ArtifactLoader loader = objectLoader.fromQueryContext(session, queryContext);
- loader.setOptions(queryData.getOptions());
- loader.setLoadLevel(loadLevel);
-
- List<ArtifactReadable> artifacts = loader.load(this);
-
- checkForCancelled();
-
- List<ArtifactReadable> results;
- if (!queryContext.getPostProcessors().isEmpty()) {
- results = new ArrayList<ArtifactReadable>();
- for (QueryPostProcessor processor : queryContext.getPostProcessors()) {
- processor.setItemsToProcess(artifacts);
- processor.setAttributeTypes(types);
- checkForCancelled();
- List<Match<ArtifactReadable, AttributeReadable<?>>> matches = processor.call();
- for (Match<ArtifactReadable, AttributeReadable<?>> match : matches) {
- checkForCancelled();
- results.add(match.getItem());
- }
- }
- } else {
- results = artifacts;
- }
- return new ResultSetList<ArtifactReadable>(results);
- }
-
- @Override
- public void setCancel(boolean isCancelled) {
- super.setCancel(isCancelled);
- if (queryContext != null && !queryContext.getPostProcessors().isEmpty()) {
- for (QueryPostProcessor processor : queryContext.getPostProcessors()) {
- processor.setCancel(true);
- }
- }
- }
-
- @Override
- protected int getCount(ResultSet<ArtifactReadable> results) throws Exception {
- return results.getList().size();
- }
-}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/SearchCountCallable.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/SearchCountCallable.java
deleted file mode 100644
index b38aa06e64..0000000000
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/SearchCountCallable.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.orcs.core.internal.search.callable;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.osee.framework.core.enums.LoadLevel;
-import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.OrcsSession;
-import org.eclipse.osee.orcs.core.ds.QueryContext;
-import org.eclipse.osee.orcs.core.ds.QueryData;
-import org.eclipse.osee.orcs.core.ds.QueryEngine;
-import org.eclipse.osee.orcs.core.ds.QueryPostProcessor;
-import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAttributeKeywords;
-import org.eclipse.osee.orcs.core.internal.ArtifactLoader;
-import org.eclipse.osee.orcs.core.internal.ArtifactLoaderFactory;
-import org.eclipse.osee.orcs.core.internal.search.QueryCollector;
-import org.eclipse.osee.orcs.data.ArtifactReadable;
-import org.eclipse.osee.orcs.data.AttributeReadable;
-import org.eclipse.osee.orcs.data.AttributeTypes;
-import org.eclipse.osee.orcs.search.Match;
-
-/**
- * @author Roberto E. Escobar
- */
-public class SearchCountCallable extends AbstractArtifactSearchCallable<Integer> {
-
- private QueryContext queryContext;
-
- public SearchCountCallable(Log logger, QueryEngine queryEngine, QueryCollector collector, ArtifactLoaderFactory objectLoader, OrcsSession session, LoadLevel loadLevel, QueryData queryData, AttributeTypes types) {
- super(logger, queryEngine, collector, objectLoader, session, loadLevel, queryData, types);
- }
-
- @Override
- protected Integer innerCall() throws Exception {
- int count = -1;
-
- if (queryData.hasCriteriaType(CriteriaAttributeKeywords.class)) {
- queryContext = queryEngine.create(session, queryData);
- checkForCancelled();
-
- ArtifactLoader loader = objectLoader.fromQueryContext(session, queryContext);
- loader.setOptions(queryData.getOptions());
- loader.setLoadLevel(loadLevel);
- checkForCancelled();
-
- List<ArtifactReadable> artifacts = loader.load(this);
-
- checkForCancelled();
-
- List<ArtifactReadable> results;
- if (!queryContext.getPostProcessors().isEmpty()) {
- results = new ArrayList<ArtifactReadable>();
- for (QueryPostProcessor processor : queryContext.getPostProcessors()) {
- processor.setItemsToProcess(artifacts);
- processor.setAttributeTypes(types);
- checkForCancelled();
- List<Match<ArtifactReadable, AttributeReadable<?>>> matches = processor.call();
- for (Match<ArtifactReadable, AttributeReadable<?>> match : matches) {
- results.add(match.getItem());
- checkForCancelled();
- }
- }
- } else {
- results = artifacts;
- }
- count = results.size();
- } else {
- queryContext = queryEngine.createCount(session, queryData);
- checkForCancelled();
-
- count = objectLoader.getCount(this, queryContext);
- checkForCancelled();
- }
- return count;
- }
-
- @Override
- public void setCancel(boolean isCancelled) {
- super.setCancel(isCancelled);
- if (queryContext != null && !queryContext.getPostProcessors().isEmpty()) {
- for (QueryPostProcessor processor : queryContext.getPostProcessors()) {
- processor.setCancel(true);
- }
- }
- }
-
- @Override
- protected int getCount(Integer count) {
- return count;
- }
-}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/SearchMatchesCallable.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/SearchMatchesCallable.java
deleted file mode 100644
index adfe9fc20e..0000000000
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/callable/SearchMatchesCallable.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.orcs.core.internal.search.callable;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import org.eclipse.osee.framework.core.data.ResultSet;
-import org.eclipse.osee.framework.core.data.ResultSetList;
-import org.eclipse.osee.framework.core.enums.LoadLevel;
-import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.OrcsSession;
-import org.eclipse.osee.orcs.core.ds.QueryContext;
-import org.eclipse.osee.orcs.core.ds.QueryData;
-import org.eclipse.osee.orcs.core.ds.QueryEngine;
-import org.eclipse.osee.orcs.core.ds.QueryPostProcessor;
-import org.eclipse.osee.orcs.core.internal.ArtifactLoader;
-import org.eclipse.osee.orcs.core.internal.ArtifactLoaderFactory;
-import org.eclipse.osee.orcs.core.internal.search.QueryCollector;
-import org.eclipse.osee.orcs.data.ArtifactReadable;
-import org.eclipse.osee.orcs.data.AttributeReadable;
-import org.eclipse.osee.orcs.data.AttributeTypes;
-import org.eclipse.osee.orcs.search.Match;
-
-/**
- * @author Roberto E. Escobar
- */
-public class SearchMatchesCallable extends AbstractArtifactSearchCallable<ResultSet<Match<ArtifactReadable, AttributeReadable<?>>>> {
-
- private Collection<QueryPostProcessor> processors;
-
- public SearchMatchesCallable(Log logger, QueryEngine queryEngine, QueryCollector collector, ArtifactLoaderFactory objectLoader, OrcsSession session, LoadLevel loadLevel, QueryData queryData, AttributeTypes types) {
- super(logger, queryEngine, collector, objectLoader, session, loadLevel, queryData, types);
- }
-
- @Override
- protected ResultSet<Match<ArtifactReadable, AttributeReadable<?>>> innerCall() throws Exception {
- QueryContext queryContext = queryEngine.create(session, queryData);
- checkForCancelled();
-
- ArtifactLoader loader = objectLoader.fromQueryContext(session, queryContext);
- loader.setOptions(queryData.getOptions());
- loader.setLoadLevel(loadLevel);
-
- List<ArtifactReadable> artifacts = loader.load(this);
-
- checkForCancelled();
-
- List<Match<ArtifactReadable, AttributeReadable<?>>> results =
- new ArrayList<Match<ArtifactReadable, AttributeReadable<?>>>();
-
- Collection<QueryPostProcessor> processors = queryContext.getPostProcessors();
- if (processors.isEmpty()) {
- processors = Collections.<QueryPostProcessor> singleton(new DefaultQueryPostProcessor(getLogger()));
- }
- for (QueryPostProcessor processor : processors) {
- processor.setItemsToProcess(artifacts);
- processor.setAttributeTypes(types);
- checkForCancelled();
- results.addAll(processor.call());
- }
- return new ResultSetList<Match<ArtifactReadable, AttributeReadable<?>>>(results);
- }
-
- @Override
- public void setCancel(boolean isCancelled) {
- super.setCancel(isCancelled);
- if (processors != null && !processors.isEmpty()) {
- for (QueryPostProcessor processor : processors) {
- processor.setCancel(true);
- }
- }
- }
-
- @Override
- protected int getCount(ResultSet<Match<ArtifactReadable, AttributeReadable<?>>> results) throws Exception {
- return results.getList().size();
- }
-}
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/LoaderTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/LoaderTest.java
index d202df005e..58a5fce325 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/LoaderTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/LoaderTest.java
@@ -20,6 +20,7 @@ import static org.eclipse.osee.framework.core.enums.ModificationType.NEW;
import static org.eclipse.osee.orcs.db.intergration.IntegrationUtil.integrationRule;
import static org.eclipse.osee.orcs.db.intergration.IntegrationUtil.sort;
import static org.eclipse.osee.orcs.db.intergration.IntegrationUtil.verifyData;
+import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -30,18 +31,17 @@ import org.eclipse.osee.framework.core.enums.LoadLevel;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.database.IOseeDatabaseService;
import org.eclipse.osee.framework.jdk.core.util.GUID;
-import org.eclipse.osee.orcs.OrcsTypes;
import org.eclipse.osee.orcs.OrcsSession;
+import org.eclipse.osee.orcs.OrcsTypes;
import org.eclipse.osee.orcs.core.ds.ArtifactData;
-import org.eclipse.osee.orcs.core.ds.ArtifactDataHandler;
import org.eclipse.osee.orcs.core.ds.AttributeData;
-import org.eclipse.osee.orcs.core.ds.AttributeDataHandler;
import org.eclipse.osee.orcs.core.ds.DataLoader;
import org.eclipse.osee.orcs.core.ds.DataLoaderFactory;
import org.eclipse.osee.orcs.core.ds.LoadDataHandler;
+import org.eclipse.osee.orcs.core.ds.LoadDescription;
+import org.eclipse.osee.orcs.core.ds.OrcsDataHandler;
import org.eclipse.osee.orcs.core.ds.OrcsDataStore;
import org.eclipse.osee.orcs.core.ds.RelationData;
-import org.eclipse.osee.orcs.core.ds.RelationDataHandler;
import org.eclipse.osee.orcs.data.ArtifactTypes;
import org.eclipse.osee.orcs.data.AttributeTypes;
import org.eclipse.osee.orcs.db.mock.OsgiService;
@@ -64,17 +64,18 @@ public class LoaderTest {
// @formatter:off
@OsgiService private IOseeDatabaseService dbService;
@OsgiService private OrcsDataStore dataStore;
- @Mock private LoadDataHandler builder;
- @Mock private ArtifactDataHandler artifactHandler;
- @Mock private AttributeDataHandler attributeHandler;
- @Mock private RelationDataHandler relationHandler;
+ @Mock private LoadDataHandler builder;
+ @Mock private OrcsDataHandler<ArtifactData> artifactHandler;
+ @Mock private OrcsDataHandler<AttributeData> attributeHandler;
+ @Mock private OrcsDataHandler<RelationData> relationHandler;
+ @Captor private ArgumentCaptor<LoadDescription> descriptorCaptor;
@Captor private ArgumentCaptor<ArtifactData> artifactCaptor;
@Captor private ArgumentCaptor<AttributeData> attributeCaptor;
@Captor private ArgumentCaptor<RelationData> relationCaptor;
- @Mock OrcsTypes types;
- @Mock ArtifactTypes artTypes;
- @Mock private OrcsSession session;
- @Mock AttributeTypes attrTypes;
+ @Mock private OrcsTypes types;
+ @Mock private ArtifactTypes artTypes;
+ @Mock private OrcsSession session;
+ @Mock private AttributeTypes attrTypes;
// @formatter:on
private HasCancellation cancellation;
@@ -112,9 +113,15 @@ public class LoaderTest {
loader.load(cancellation, builder);
+ verify(builder).onLoadStart();
+ verify(builder).onLoadDescription(descriptorCaptor.capture());
verify(builder).getArtifactDataHandler();
verify(builder).getAttributeDataHandler();
verify(builder).getRelationDataHandler();
+ verify(builder).onLoadEnd();
+
+ LoadDescription descriptor = descriptorCaptor.getValue();
+ assertEquals(CoreBranches.COMMON, descriptor.getBranch());
verify(artifactHandler, times(3)).onData(artifactCaptor.capture());
verify(attributeHandler, times(7)).onData(attributeCaptor.capture());
@@ -163,9 +170,15 @@ public class LoaderTest {
loader.load(cancellation, builder);
+ verify(builder).onLoadStart();
+ verify(builder).onLoadDescription(descriptorCaptor.capture());
verify(builder).getArtifactDataHandler();
verify(builder).getAttributeDataHandler();
verify(builder).getRelationDataHandler();
+ verify(builder).onLoadEnd();
+
+ LoadDescription descriptor = descriptorCaptor.getValue();
+ assertEquals(CoreBranches.COMMON, descriptor.getBranch());
verify(artifactHandler, times(3)).onData(artifactCaptor.capture());
verify(attributeHandler, times(3)).onData(attributeCaptor.capture());
@@ -209,9 +222,15 @@ public class LoaderTest {
loader.load(cancellation, builder);
+ verify(builder).onLoadStart();
+ verify(builder).onLoadDescription(descriptorCaptor.capture());
verify(builder).getArtifactDataHandler();
verify(builder).getAttributeDataHandler();
verify(builder).getRelationDataHandler();
+ verify(builder).onLoadEnd();
+
+ LoadDescription descriptor = descriptorCaptor.getValue();
+ assertEquals(CoreBranches.COMMON, descriptor.getBranch());
verify(artifactHandler, times(3)).onData(artifactCaptor.capture());
verify(attributeHandler, times(2)).onData(attributeCaptor.capture());
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 8122a20f36..e82d3fa1ea 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
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.loader;
+import static org.eclipse.osee.framework.core.enums.DeletionFlag.EXCLUDE_DELETED;
+import static org.eclipse.osee.framework.core.enums.DeletionFlag.INCLUDE_DELETED;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -27,6 +29,7 @@ import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.enums.CoreBranches;
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.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.cache.BranchCache;
@@ -41,6 +44,9 @@ import org.eclipse.osee.orcs.OrcsSession;
import org.eclipse.osee.orcs.core.ds.DataLoader;
import org.eclipse.osee.orcs.core.ds.DataLoaderFactory;
import org.eclipse.osee.orcs.core.ds.LoadDataHandler;
+import org.eclipse.osee.orcs.core.ds.LoadDescription;
+import org.eclipse.osee.orcs.core.ds.Options;
+import org.eclipse.osee.orcs.core.ds.OptionsUtil;
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;
@@ -49,18 +55,19 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
+import org.mockito.Matchers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
/**
- * Test Case for {@link DataLoaderFactoryImplTest}
+ * Test Case for {@link DataLoaderFactoryImpl}
*
* @author Roberto E. Escobar
*/
public class DataLoaderFactoryImplTest {
//@formatter:off
- @Mock private Log logger;
+ @Mock private Log logger;
@Mock private IOseeDatabaseService dbService;
@Mock private IOseeStatement chStmt;
@@ -74,15 +81,17 @@ public class DataLoaderFactoryImplTest {
@Mock private BranchCache branchCache;
@Mock private HasCancellation cancellation;
- @Captor ArgumentCaptor<LoadSqlContext> contextCaptor;
- @Captor ArgumentCaptor<ArtifactJoinQuery> joinCaptor;
- @Captor ArgumentCaptor<CriteriaOrcsLoad> criteriaCaptor;
+ @Captor private ArgumentCaptor<LoadSqlContext> contextCaptor;
+ @Captor private ArgumentCaptor<ArtifactJoinQuery> joinCaptor;
+ @Captor private ArgumentCaptor<CriteriaOrcsLoad> criteriaCaptor;
+ @Captor private ArgumentCaptor<LoadDescription> descriptionCaptor;
@Mock private OrcsSession session;
//@formatter:on
private final static int EXPECTED_BRANCH_ID = 65;
private final static int EXPECTED_TX_ID = 45678;
+ private final static int EXPECTED_HEAD_TX_ID = 50000;
private final static IOseeBranch BRANCH = CoreBranches.COMMON;
private DataLoaderFactory factory;
@@ -101,7 +110,7 @@ public class DataLoaderFactoryImplTest {
spyLoader = spy(loader);
factory = module.createDataLoaderFactory(spyLoader, branchCache);
- when(branchCache.getLocalId(CoreBranches.COMMON)).thenReturn(EXPECTED_BRANCH_ID);
+ when(branchCache.getLocalId(BRANCH)).thenReturn(EXPECTED_BRANCH_ID);
when(sqlProvider.getSql(OseeSql.QUERY_BUILDER)).thenReturn("/*+ ordered */");
when(identityService.getLocalId(CoreAttributeTypes.Annotation)).thenReturn(
@@ -117,6 +126,8 @@ public class DataLoaderFactoryImplTest {
CoreRelationTypes.Dependency__Artifact.getGuid().intValue());
when(dbService.getStatement()).thenReturn(chStmt);
+ when(dbService.runPreparedQueryFetchObject(eq(-1), Matchers.anyString(), eq(BRANCH.getGuid()))).thenReturn(
+ EXPECTED_HEAD_TX_ID);
}
@Test
@@ -132,6 +143,7 @@ public class DataLoaderFactoryImplTest {
dataLoader.load(cancellation, builder);
// @formatter:off
+ verify(spyLoader, times(0)).loadHeadTransactionId(BRANCH);
verify(spyLoader, times(1)).loadArtifacts(eq(builder), criteriaCaptor.capture(), contextCaptor.capture(), eq(200));
verify(spyLoader, times(1)).loadAttributes(eq(builder), criteriaCaptor.capture(), contextCaptor.capture(), eq(200));
verify(spyLoader, times(1)).loadRelations(eq(builder), criteriaCaptor.capture(), contextCaptor.capture(), eq(200));
@@ -157,7 +169,7 @@ public class DataLoaderFactoryImplTest {
dataLoader.load(cancellation, builder);
- verifyCommon(expected);
+ verifyCommon(EXPECTED_HEAD_TX_ID, expectedLoadLevel, EXCLUDE_DELETED, expected);
}
@Test
@@ -180,7 +192,7 @@ public class DataLoaderFactoryImplTest {
dataLoader.load(cancellation, builder);
- verifyCommon(expected);
+ verifyCommon(EXPECTED_HEAD_TX_ID, expectedLoadLevel, INCLUDE_DELETED, expected);
}
@Test
@@ -204,7 +216,7 @@ public class DataLoaderFactoryImplTest {
dataLoader.load(cancellation, builder);
- verifyCommon(expected);
+ verifyCommon(EXPECTED_TX_ID, expectedLoadLevel, EXCLUDE_DELETED, expected);
}
@Test
@@ -229,7 +241,7 @@ public class DataLoaderFactoryImplTest {
dataLoader.load(cancellation, builder);
- verifyCommon(expected);
+ verifyCommon(EXPECTED_TX_ID, expectedLoadLevel, INCLUDE_DELETED, expected);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -253,7 +265,7 @@ public class DataLoaderFactoryImplTest {
dataLoader.load(cancellation, builder);
- verifyCommon(expected);
+ verifyCommon(EXPECTED_HEAD_TX_ID, expectedLoadLevel, EXCLUDE_DELETED, expected);
}
@Test
@@ -278,7 +290,8 @@ public class DataLoaderFactoryImplTest {
dataLoader.load(cancellation, builder);
- verifyCommon(expected, CoreAttributeTypes.Annotation.getGuid().intValue());
+ verifyCommon(EXPECTED_HEAD_TX_ID, expectedLoadLevel, EXCLUDE_DELETED, expected,
+ CoreAttributeTypes.Annotation.getGuid().intValue());
}
@Test
@@ -304,6 +317,9 @@ public class DataLoaderFactoryImplTest {
dataLoader.load(cancellation, builder);
verifyCommon(
+ EXPECTED_HEAD_TX_ID,
+ expectedLoadLevel,
+ EXCLUDE_DELETED,
expected,
data(JQID),
list(data(CoreAttributeTypes.Annotation.getGuid().intValue(), CoreAttributeTypes.Category.getGuid().intValue())));
@@ -330,7 +346,7 @@ public class DataLoaderFactoryImplTest {
dataLoader.load(cancellation, builder);
- verifyCommon(expected, 45);
+ verifyCommon(EXPECTED_HEAD_TX_ID, expectedLoadLevel, EXCLUDE_DELETED, expected, 45);
}
@Test
@@ -355,7 +371,7 @@ public class DataLoaderFactoryImplTest {
dataLoader.load(cancellation, builder);
- verifyCommon(expected, data(JQID), list(data(45, 55)));
+ verifyCommon(EXPECTED_HEAD_TX_ID, expectedLoadLevel, EXCLUDE_DELETED, expected, data(JQID), list(data(45, 55)));
}
@Test
@@ -382,6 +398,9 @@ public class DataLoaderFactoryImplTest {
dataLoader.load(cancellation, builder);
verifyCommon(
+ EXPECTED_HEAD_TX_ID,
+ expectedLoadLevel,
+ EXCLUDE_DELETED,
expected,
data(JQID, JQID),
list(data(45, 55),
@@ -411,7 +430,8 @@ public class DataLoaderFactoryImplTest {
dataLoader.load(cancellation, builder);
- verifyCommon(expected, 45, CoreAttributeTypes.Annotation.getGuid().intValue());
+ verifyCommon(EXPECTED_HEAD_TX_ID, expectedLoadLevel, EXCLUDE_DELETED, expected, 45,
+ CoreAttributeTypes.Annotation.getGuid().intValue());
}
@Test
@@ -435,7 +455,7 @@ public class DataLoaderFactoryImplTest {
dataLoader.load(cancellation, builder);
- verifyCommon(expected);
+ verifyCommon(EXPECTED_HEAD_TX_ID, expectedLoadLevel, INCLUDE_DELETED, expected);
}
@Test
@@ -460,7 +480,7 @@ public class DataLoaderFactoryImplTest {
dataLoader.load(cancellation, builder);
- verifyCommon(expected);
+ verifyCommon(EXPECTED_TX_ID, expectedLoadLevel, EXCLUDE_DELETED, expected);
}
@Test
@@ -486,7 +506,7 @@ public class DataLoaderFactoryImplTest {
dataLoader.load(cancellation, builder);
- verifyCommon(expected);
+ verifyCommon(EXPECTED_TX_ID, expectedLoadLevel, INCLUDE_DELETED, expected);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -512,7 +532,7 @@ public class DataLoaderFactoryImplTest {
dataLoader.load(cancellation, builder);
- verifyCommon(expected);
+ verifyCommon(EXPECTED_HEAD_TX_ID, expectedLoadLevel, EXCLUDE_DELETED, expected);
}
@Test
@@ -537,7 +557,7 @@ public class DataLoaderFactoryImplTest {
dataLoader.load(cancellation, builder);
- verifyCommon(expected);
+ verifyCommon(EXPECTED_HEAD_TX_ID, expectedLoadLevel, INCLUDE_DELETED, expected);
}
@Test
@@ -562,7 +582,8 @@ public class DataLoaderFactoryImplTest {
dataLoader.load(cancellation, builder);
- verifyCommon(expected, CoreRelationTypes.Default_Hierarchical__Child.getGuid().intValue());
+ verifyCommon(EXPECTED_HEAD_TX_ID, expectedLoadLevel, EXCLUDE_DELETED, expected,
+ CoreRelationTypes.Default_Hierarchical__Child.getGuid().intValue());
}
@Test
@@ -588,6 +609,9 @@ public class DataLoaderFactoryImplTest {
dataLoader.load(cancellation, builder);
verifyCommon(
+ EXPECTED_HEAD_TX_ID,
+ expectedLoadLevel,
+ EXCLUDE_DELETED,
expected,
data(JQID),
list(data(CoreRelationTypes.Default_Hierarchical__Child.getGuid().intValue(),
@@ -616,7 +640,7 @@ public class DataLoaderFactoryImplTest {
dataLoader.load(cancellation, builder);
- verifyCommon(expected, 45);
+ verifyCommon(EXPECTED_HEAD_TX_ID, expectedLoadLevel, EXCLUDE_DELETED, expected, 45);
}
@Test
@@ -641,7 +665,7 @@ public class DataLoaderFactoryImplTest {
dataLoader.load(cancellation, builder);
- verifyCommon(expected, data(JQID), list(data(45, 55)));
+ verifyCommon(EXPECTED_HEAD_TX_ID, expectedLoadLevel, EXCLUDE_DELETED, expected, data(JQID), list(data(45, 55)));
}
@Test
@@ -668,6 +692,9 @@ public class DataLoaderFactoryImplTest {
dataLoader.load(cancellation, builder);
verifyCommon(
+ EXPECTED_HEAD_TX_ID,
+ expectedLoadLevel,
+ EXCLUDE_DELETED,
expected,
data(JQID, JQID),
list(
@@ -699,13 +726,24 @@ public class DataLoaderFactoryImplTest {
dataLoader.load(cancellation, builder);
- verifyCommon(expected, 45, CoreRelationTypes.Default_Hierarchical__Child.getGuid().intValue());
+ verifyCommon(EXPECTED_HEAD_TX_ID, expectedLoadLevel, EXCLUDE_DELETED, expected, 45,
+ CoreRelationTypes.Default_Hierarchical__Child.getGuid().intValue());
}
@Test
public void testLoadRelationsHistorical() throws OseeCoreException {
LoadLevel expectedLoadLevel = LoadLevel.RELATION;
+ String expected =
+ "SELECT/*+ ordered */ txs1.gamma_id, txs1.mod_type, txs1.branch_id, txs1.transaction_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.tx_current IN (1, 0) 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.fromBranchAndArtifactIds(session, BRANCH, Arrays.asList(1, 2, 3));
dataLoader.setLoadLevel(expectedLoadLevel);
dataLoader.fromTransaction(EXPECTED_TX_ID);
@@ -714,7 +752,7 @@ public class DataLoaderFactoryImplTest {
dataLoader.load(cancellation, builder);
- verify(spyLoader, times(0)).loadRelations(builder, null, null, 200);
+ verifyCommon(EXPECTED_TX_ID, expectedLoadLevel, EXCLUDE_DELETED, expected);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -729,14 +767,30 @@ public class DataLoaderFactoryImplTest {
return data;
}
- private void verifyCommon(String expectedSQL, Object... params) throws OseeCoreException {
- verifyCommon(expectedSQL, params, list());
+ private void verifyCommon(int txId, LoadLevel level, DeletionFlag includeDeleted, String expectedSQL, Object... params) throws OseeCoreException {
+ verifyCommon(txId, level, includeDeleted, expectedSQL, params, list());
}
- private void verifyCommon(String expectedSQL, Object[] params, List<Object[]> joinDatas) throws OseeCoreException {
+ private void verifyCommon(int txId, LoadLevel level, DeletionFlag includeDeleted, String expectedSQL, Object[] params, List<Object[]> joinDatas) throws OseeCoreException {
verify(spyLoader).loadArtifacts(eq(cancellation), eq(builder), joinCaptor.capture(), criteriaCaptor.capture(),
contextCaptor.capture(), eq(200));
+ verify(builder, times(1)).onLoadDescription(descriptionCaptor.capture());
+ LoadDescription descriptor = descriptionCaptor.getValue();
+
+ boolean isHeadTx = EXPECTED_HEAD_TX_ID == txId;
+
+ assertEquals(session, descriptor.getSession());
+ Options options = descriptor.getOptions();
+
+ assertEquals(BRANCH, descriptor.getBranch());
+ assertEquals(txId, descriptor.getTransaction());
+
+ assertEquals(isHeadTx, OptionsUtil.isHeadTransaction(options));
+ assertEquals(!isHeadTx, OptionsUtil.isHistorical(options));
+ assertEquals(level, OptionsUtil.getLoadLevel(options));
+ assertEquals(includeDeleted, OptionsUtil.getIncludeDeleted(options));
+
assertTrue(joinCaptor.getValue().wasStored());
assertEquals(3, joinCaptor.getValue().size());
@@ -744,7 +798,6 @@ public class DataLoaderFactoryImplTest {
assertEquals(session, context.getSession());
assertEquals(expectedSQL, context.getSql());
- assertTrue(context.getPostProcessors().isEmpty());
assertEquals(1 + params.length, context.getParameters().size());
@@ -772,5 +825,4 @@ public class DataLoaderFactoryImplTest {
assertEquals(data.length, jQuery.size());
}
}
-
}
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/LoaderSqlHandlerFactoryImplTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/LoaderSqlHandlerFactoryUtilTest.java
index 4a9c1730c6..06c17b6b95 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/LoaderSqlHandlerFactoryImplTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/LoaderSqlHandlerFactoryUtilTest.java
@@ -15,8 +15,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
-import org.eclipse.osee.framework.core.data.IOseeBranch;
-import org.eclipse.osee.framework.core.enums.CoreBranches;
import org.eclipse.osee.framework.core.services.IdentityService;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.core.ds.Criteria;
@@ -31,7 +29,6 @@ import org.eclipse.osee.orcs.db.internal.loader.handlers.RelationSqlHandler;
import org.eclipse.osee.orcs.db.internal.loader.handlers.SqlHandlerPriority;
import org.eclipse.osee.orcs.db.internal.sql.SqlHandler;
import org.eclipse.osee.orcs.db.internal.sql.SqlHandlerFactory;
-import org.eclipse.osee.orcs.db.internal.sql.SqlHandlerFactoryImpl;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -39,11 +36,11 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
/**
- * Test Case for {@link SqlHandlerFactoryImpl}
+ * Test Case for {@link LoaderSqlHandlerFactoryUtil}
*
* @author Roberto E. Escobar
*/
-public class LoaderSqlHandlerFactoryImplTest {
+public class LoaderSqlHandlerFactoryUtilTest {
// @formatter:off
@Mock private Log logger;
@@ -68,7 +65,7 @@ public class LoaderSqlHandlerFactoryImplTest {
Collections.shuffle(criteria);
- CriteriaSet criteriaSet = createCriteria(CoreBranches.COMMON, criteria);
+ CriteriaSet criteriaSet = createCriteria(criteria);
List<SqlHandler<?>> handlers = factory.createHandlers(criteriaSet);
Assert.assertEquals(3, handlers.size());
@@ -91,8 +88,8 @@ public class LoaderSqlHandlerFactoryImplTest {
Assert.assertEquals(priority.ordinal(), actual.getPriority());
}
- private static CriteriaSet createCriteria(IOseeBranch branch, Collection<? extends Criteria> criteria) {
- CriteriaSet set = new CriteriaSet(branch);
+ private static CriteriaSet createCriteria(Collection<? extends Criteria> criteria) {
+ CriteriaSet set = new CriteriaSet();
for (Criteria crit : criteria) {
set.add(crit);
}
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/LoaderTestSuite.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/LoaderTestSuite.java
index 0899a62738..4d234289b4 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/LoaderTestSuite.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/LoaderTestSuite.java
@@ -21,7 +21,7 @@ import org.junit.runners.Suite;
AttributeDataProxyFactoryTest.class,
DataFactoryImplTest.class,
DataLoaderFactoryImplTest.class,
- LoaderSqlHandlerFactoryImplTest.class})
+ LoaderSqlHandlerFactoryUtilTest.class})
public class LoaderTestSuite {
// Test Suite
}
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/QueryTestSuite.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/QueryTestSuite.java
index e972fc2310..cb935445c9 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/QueryTestSuite.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/QueryTestSuite.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.search;
+import org.eclipse.osee.orcs.db.internal.search.engines.EnginesTestSuite;
import org.eclipse.osee.orcs.db.internal.search.handlers.HandlersTestSuite;
import org.eclipse.osee.orcs.db.internal.search.language.LanguageTestSuite;
import org.eclipse.osee.orcs.db.internal.search.tagger.TaggerTestSuite;
@@ -22,11 +23,11 @@ import org.junit.runners.Suite;
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
+ EnginesTestSuite.class,
HandlersTestSuite.class,
LanguageTestSuite.class,
TaggerTestSuite.class,
- UtilityTestSuite.class,
- QueryEngineImplTest.class})
+ UtilityTestSuite.class})
public class QueryTestSuite {
// Test Suite
}
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/QueryEngineImplTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContextFactoryImplTest.java
index 9dcf2c7cac..cc7d7ae3c4 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/QueryEngineImplTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContextFactoryImplTest.java
@@ -8,7 +8,7 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs.db.internal.search;
+package org.eclipse.osee.orcs.db.internal.search.engines;
import static java.util.Arrays.asList;
import static org.eclipse.osee.orcs.db.internal.search.handlers.SqlHandlerFactoryUtil.createArtifactSqlHandlerFactory;
@@ -19,6 +19,7 @@ import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.when;
import java.util.Iterator;
import java.util.List;
+import org.eclipse.osee.executor.admin.ExecutorAdmin;
import org.eclipse.osee.framework.core.enums.CaseType;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
@@ -29,6 +30,7 @@ import org.eclipse.osee.framework.core.enums.Operator;
import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
import org.eclipse.osee.framework.core.enums.TokenOrderType;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.cache.AttributeTypeCache;
import org.eclipse.osee.framework.core.model.cache.BranchCache;
import org.eclipse.osee.framework.core.services.IdentityService;
import org.eclipse.osee.framework.database.IOseeDatabaseService;
@@ -38,7 +40,6 @@ import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.OrcsSession;
import org.eclipse.osee.orcs.core.ds.Criteria;
import org.eclipse.osee.orcs.core.ds.CriteriaSet;
-import org.eclipse.osee.orcs.core.ds.DataPostProcessorFactory;
import org.eclipse.osee.orcs.core.ds.Options;
import org.eclipse.osee.orcs.core.ds.OptionsUtil;
import org.eclipse.osee.orcs.core.ds.QueryData;
@@ -50,9 +51,12 @@ import org.eclipse.osee.orcs.core.ds.criteria.CriteriaArtifactType;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAttributeKeywords;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAttributeOther;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAttributeTypeExists;
+import org.eclipse.osee.orcs.core.ds.criteria.CriteriaBranch;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaRelatedTo;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaRelationTypeExists;
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;
import org.eclipse.osee.orcs.db.internal.search.tagger.TagProcessor;
import org.eclipse.osee.orcs.db.internal.sql.OseeSql;
@@ -66,11 +70,11 @@ import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
/**
- * Test Case for {@link QueryEngineImpl}
+ * Test Case for {@link ArtifactQuerySqlContextFactoryImpl}
*
* @author Roberto E. Escobar
*/
-public class QueryEngineImplTest {
+public class ArtifactQuerySqlContextFactoryImplTest {
private static final String QUICK_SEARCH_VALUE = "hello1_two_three";
private static final String WORD_1 = "hello";
@@ -86,7 +90,6 @@ public class QueryEngineImplTest {
private static final Criteria TYPES = new CriteriaArtifactType(null, asList(CoreArtifactTypes.CodeUnit), false);
private static final Criteria ATTRIBUTE = new CriteriaAttributeOther(CoreAttributeTypes.Name, asList("Hello"),
Operator.EQUAL);
-
private static final Criteria ATTR_TYPE_EXITS = new CriteriaAttributeTypeExists(asList(CoreAttributeTypes.Name));
private static final Criteria REL_TYPE_EXISTS = new CriteriaRelationTypeExists(
CoreRelationTypes.Default_Hierarchical__Child);
@@ -106,16 +109,17 @@ public class QueryEngineImplTest {
@Mock private SqlProvider sqlProvider;
@Mock private IdentityService identityService;
@Mock private TagProcessor tagProcessor;
- @Mock private DataPostProcessorFactory<CriteriaAttributeKeywords> postProcessorFactory;
-
+
+ @Mock private ExecutorAdmin executorAdmin;
@Mock private BranchCache branchCache;
+ @Mock private AttributeTypeCache attributeTypeCache;
@Mock private OrcsSession session;
// @formatter:on
private final static int EXPECTED_BRANCH_ID = 65;
private final static int EXPECTED_TX_ID = 45678;
- private QueryEngineImpl queryEngine;
+ private QuerySqlContextFactory queryEngine;
private QueryData queryData;
@Before
@@ -125,12 +129,12 @@ public class QueryEngineImplTest {
String sessionId = GUID.create();
when(session.getGuid()).thenReturn(sessionId);
- SqlHandlerFactory handlerFactory =
- createArtifactSqlHandlerFactory(logger, identityService, tagProcessor, postProcessorFactory);
- queryEngine = new QueryEngineImpl(logger, dbService, sqlProvider, branchCache, handlerFactory);
+ SqlHandlerFactory handlerFactory = createArtifactSqlHandlerFactory(logger, identityService, tagProcessor);
+ queryEngine = new ArtifactQuerySqlContextFactoryImpl(logger, dbService, sqlProvider, branchCache, handlerFactory);
- CriteriaSet criteriaSet = new CriteriaSet(CoreBranches.COMMON);
+ CriteriaSet criteriaSet = new CriteriaSet();
Options options = OptionsUtil.createOptions();
+ criteriaSet.add(new CriteriaBranch(CoreBranches.COMMON));
queryData = new QueryData(criteriaSet, options);
when(branchCache.getLocalId(CoreBranches.COMMON)).thenReturn(EXPECTED_BRANCH_ID);
@@ -177,7 +181,7 @@ public class QueryEngineImplTest {
queryData.addCriteria(GUIDS, IDS, HRIDS, TYPES);
- QuerySqlContext context = queryEngine.createCount(session, queryData);
+ QuerySqlContext context = queryEngine.createCountContext(session, queryData);
Assert.assertEquals(expected, context.getSql());
@@ -214,7 +218,7 @@ public class QueryEngineImplTest {
OptionsUtil.setFromTransaction(queryData.getOptions(), EXPECTED_TX_ID);
queryData.addCriteria(TYPES);
- QuerySqlContext context = queryEngine.createCount(session, queryData);
+ QuerySqlContext context = queryEngine.createCountContext(session, queryData);
Assert.assertEquals(expected, context.getSql());
@@ -248,7 +252,7 @@ public class QueryEngineImplTest {
queryData.addCriteria(GUIDS, IDS, HRIDS, TYPES);
- QuerySqlContext context = queryEngine.create(session, queryData);
+ QuerySqlContext context = queryEngine.createQueryContext(session, queryData);
Assert.assertEquals(expected, context.getSql());
@@ -288,7 +292,7 @@ public class QueryEngineImplTest {
queryData.addCriteria(GUIDS, IDS, HRIDS, TYPES);
OptionsUtil.setIncludeDeleted(queryData.getOptions(), true);
- QuerySqlContext context = queryEngine.create(session, queryData);
+ QuerySqlContext context = queryEngine.createQueryContext(session, queryData);
Assert.assertEquals(expected, context.getSql());
List<Object> parameters = context.getParameters();
@@ -334,7 +338,7 @@ public class QueryEngineImplTest {
queryData.addCriteria(GUIDS, IDS, HRIDS, TYPES);
OptionsUtil.setFromTransaction(queryData.getOptions(), EXPECTED_TX_ID);
- QuerySqlContext context = queryEngine.create(session, queryData);
+ QuerySqlContext context = queryEngine.createQueryContext(session, queryData);
Assert.assertEquals(expected, context.getSql());
List<Object> parameters = context.getParameters();
@@ -372,7 +376,7 @@ public class QueryEngineImplTest {
queryData.addCriteria(IDS);
- QuerySqlContext context = queryEngine.create(session, queryData);
+ QuerySqlContext context = queryEngine.createQueryContext(session, queryData);
Assert.assertEquals(expected, context.getSql());
List<Object> parameters = context.getParameters();
@@ -397,7 +401,7 @@ public class QueryEngineImplTest {
queryData.addCriteria(TYPES);
- QuerySqlContext context = queryEngine.create(session, queryData);
+ QuerySqlContext context = queryEngine.createQueryContext(session, queryData);
Assert.assertEquals(expected, context.getSql());
List<Object> parameters = context.getParameters();
@@ -426,7 +430,7 @@ public class QueryEngineImplTest {
queryData.addCriteria(ATTRIBUTE);
- QuerySqlContext context = queryEngine.create(session, queryData);
+ QuerySqlContext context = queryEngine.createQueryContext(session, queryData);
Assert.assertEquals(expected, context.getSql());
List<Object> parameters = context.getParameters();
@@ -465,7 +469,7 @@ public class QueryEngineImplTest {
queryData.addCriteria(ATTRIBUTE_KEYWORD);
- QuerySqlContext context = queryEngine.create(session, queryData);
+ QuerySqlContext context = queryEngine.createQueryContext(session, queryData);
Assert.assertEquals(expected, context.getSql());
List<Object> parameters = context.getParameters();
@@ -514,7 +518,7 @@ public class QueryEngineImplTest {
queryData.addCriteria(ATTRIBUTE, ATTRIBUTE_KEYWORD, TYPES);
- QuerySqlContext context = queryEngine.create(session, queryData);
+ QuerySqlContext context = queryEngine.createQueryContext(session, queryData);
Assert.assertEquals(expected, context.getSql());
List<Object> parameters = context.getParameters();
@@ -578,7 +582,7 @@ public class QueryEngineImplTest {
queryData.addCriteria(GUIDS, TYPES, REL_TYPE_EXISTS, IDS, ATTR_TYPE_EXITS, HRIDS);
- QuerySqlContext context = queryEngine.create(session, queryData);
+ QuerySqlContext context = queryEngine.createQueryContext(session, queryData);
Assert.assertEquals(expected, context.getSql());
List<Object> parameters = context.getParameters();
@@ -635,7 +639,7 @@ public class QueryEngineImplTest {
queryData.addCriteria(GUIDS, TYPES, REL_TYPE_EXISTS, IDS, ATTR_TYPE_EXITS, HRIDS);
- QuerySqlContext context = queryEngine.create(session, queryData);
+ QuerySqlContext context = queryEngine.createQueryContext(session, queryData);
Assert.assertEquals(expected, context.getSql());
List<Object> parameters = context.getParameters();
@@ -689,7 +693,7 @@ public class QueryEngineImplTest {
queryData.addCriteria(GUIDS, TYPES, IDS, RELATED_TO);
- QuerySqlContext context = queryEngine.create(session, queryData);
+ QuerySqlContext context = queryEngine.createQueryContext(session, queryData);
Assert.assertEquals(expected, context.getSql());
List<Object> parameters = context.getParameters();
@@ -721,7 +725,7 @@ public class QueryEngineImplTest {
queryData.addCriteria(ALL_ARTIFACTS);
- QuerySqlContext context = queryEngine.createCount(session, queryData);
+ QuerySqlContext context = queryEngine.createCountContext(session, queryData);
Assert.assertEquals(expected, context.getSql());
@@ -750,7 +754,7 @@ public class QueryEngineImplTest {
OptionsUtil.setFromTransaction(queryData.getOptions(), EXPECTED_TX_ID);
queryData.addCriteria(ALL_ARTIFACTS);
- QuerySqlContext context = queryEngine.createCount(session, queryData);
+ QuerySqlContext context = queryEngine.createCountContext(session, queryData);
Assert.assertEquals(expected, context.getSql());
@@ -775,7 +779,7 @@ public class QueryEngineImplTest {
queryData.addCriteria(ALL_ARTIFACTS);
- QuerySqlContext context = queryEngine.create(session, queryData);
+ QuerySqlContext context = queryEngine.createQueryContext(session, queryData);
Assert.assertEquals(expected, context.getSql());
@@ -804,7 +808,7 @@ public class QueryEngineImplTest {
OptionsUtil.setFromTransaction(queryData.getOptions(), EXPECTED_TX_ID);
queryData.addCriteria(ALL_ARTIFACTS);
- QuerySqlContext context = queryEngine.create(session, queryData);
+ QuerySqlContext context = queryEngine.createQueryContext(session, queryData);
Assert.assertEquals(expected, context.getSql());
@@ -830,7 +834,7 @@ public class QueryEngineImplTest {
queryData.addCriteria(ALL_ARTIFACTS, IDS);
- QuerySqlContext context = queryEngine.create(session, queryData);
+ QuerySqlContext context = queryEngine.createQueryContext(session, queryData);
Assert.assertEquals(expected, context.getSql());
List<Object> parameters = context.getParameters();
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeDataHandler.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/EnginesTestSuite.java
index 8a66a445d6..7bc4e65836 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeDataHandler.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/EnginesTestSuite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
+ * 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
@@ -8,11 +8,16 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs.core.ds;
+package org.eclipse.osee.orcs.db.internal.search.engines;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
/**
* @author Roberto E. Escobar
*/
-public interface AttributeDataHandler extends OrcsDataHandler<AttributeData> {
- //
-} \ No newline at end of file
+@RunWith(Suite.class)
+@Suite.SuiteClasses({ArtifactQuerySqlContextFactoryImplTest.class})
+public class EnginesTestSuite {
+ // Test Suite
+}
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/handlers/HandlersTestSuite.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/handlers/HandlersTestSuite.java
index 3c9cb1f2c5..482fd01270 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/handlers/HandlersTestSuite.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/handlers/HandlersTestSuite.java
@@ -17,7 +17,7 @@ import org.junit.runners.Suite;
* @author Roberto E. Escobar
*/
@RunWith(Suite.class)
-@Suite.SuiteClasses({SqlHandlerFactoryUtilTest.class,})
+@Suite.SuiteClasses({SqlHandlerFactoryUtilTest.class})
public class HandlersTestSuite {
// Test Suite
}
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerFactoryUtilTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerFactoryUtilTest.java
index 4a5a5584a4..30dad56f7b 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerFactoryUtilTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerFactoryUtilTest.java
@@ -11,18 +11,16 @@
package org.eclipse.osee.orcs.db.internal.search.handlers;
import static org.eclipse.osee.orcs.db.internal.search.handlers.SqlHandlerFactoryUtil.createArtifactSqlHandlerFactory;
+import static org.mockito.MockitoAnnotations.initMocks;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
-import org.eclipse.osee.framework.core.data.IOseeBranch;
-import org.eclipse.osee.framework.core.enums.CoreBranches;
import org.eclipse.osee.framework.core.services.IdentityService;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.core.ds.Criteria;
import org.eclipse.osee.orcs.core.ds.CriteriaSet;
-import org.eclipse.osee.orcs.core.ds.DataPostProcessorFactory;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAllArtifacts;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaArtifactGuids;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaArtifactHrids;
@@ -33,19 +31,17 @@ import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAttributeOther;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAttributeTypeExists;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaRelatedTo;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaRelationTypeExists;
+import org.eclipse.osee.orcs.db.internal.search.tagger.HasTagProcessor;
import org.eclipse.osee.orcs.db.internal.search.tagger.TagProcessor;
-import org.eclipse.osee.orcs.db.internal.sql.HasDataPostProcessorFactory;
import org.eclipse.osee.orcs.db.internal.sql.SqlHandler;
import org.eclipse.osee.orcs.db.internal.sql.SqlHandlerFactory;
-import org.eclipse.osee.orcs.db.internal.sql.SqlHandlerFactoryImpl;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
/**
- * Test Case for {@link SqlHandlerFactoryImpl}
+ * Test Case for {@link SqlHandlerFactoryUtil}
*
* @author Roberto E. Escobar
*/
@@ -58,16 +54,14 @@ public class SqlHandlerFactoryUtilTest {
// @formatter:on
private SqlHandlerFactory factory;
- private DataPostProcessorFactory<CriteriaAttributeKeywords> postProcessorFactory;
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
+ initMocks(this);
- factory = createArtifactSqlHandlerFactory(logger, identityService, tagProcessor, postProcessorFactory);
+ factory = createArtifactSqlHandlerFactory(logger, identityService, tagProcessor);
}
- @SuppressWarnings("unchecked")
@Test
public void testQueryModuleFactory() throws Exception {
List<Criteria> criteria = new ArrayList<Criteria>();
@@ -84,44 +78,45 @@ public class SqlHandlerFactoryUtilTest {
Collections.shuffle(criteria);
- CriteriaSet criteriaSet = createCriteria(CoreBranches.COMMON, criteria);
+ CriteriaSet criteriaSet = createCriteria(criteria);
List<SqlHandler<?>> handlers = factory.createHandlers(criteriaSet);
Assert.assertEquals(10, handlers.size());
Iterator<SqlHandler<?>> iterator = handlers.iterator();
- assertSqlHandler(iterator.next(), ArtifactIdsSqlHandler.class, SqlHandlerPriority.ARTIFACT_ID);
- assertSqlHandler(iterator.next(), ArtifactGuidSqlHandler.class, SqlHandlerPriority.ARTIFACT_GUID);
- assertSqlHandler(iterator.next(), ArtifactHridsSqlHandler.class, SqlHandlerPriority.ARTIFACT_HRID);
- assertSqlHandler(iterator.next(), AttributeOtherSqlHandler.class, SqlHandlerPriority.ATTRIBUTE_VALUE);
-
- SqlHandler<?> tokenHandler = iterator.next();
- assertSqlHandler(tokenHandler, AttributeTokenSqlHandler.class, SqlHandlerPriority.ATTRIBUTE_TOKENIZED_VALUE);
- Assert.assertTrue(tokenHandler instanceof HasDataPostProcessorFactory);
- Assert.assertEquals(postProcessorFactory,
- ((HasDataPostProcessorFactory<CriteriaAttributeKeywords>) tokenHandler).getDataPostProcessorFactory());
-
- assertSqlHandler(iterator.next(), ArtifactTypeSqlHandler.class, SqlHandlerPriority.ARTIFACT_TYPE);
- assertSqlHandler(iterator.next(), AttributeTypeExistsSqlHandler.class, SqlHandlerPriority.ATTRIBUTE_TYPE_EXISTS);
- assertSqlHandler(iterator.next(), RelationTypeExistsSqlHandler.class, SqlHandlerPriority.RELATION_TYPE_EXISTS);
- assertSqlHandler(iterator.next(), RelatedToSqlHandler.class, SqlHandlerPriority.RELATED_TO_ART_IDS);
- assertSqlHandler(iterator.next(), AllArtifactsSqlHandler.class, SqlHandlerPriority.ALL_ARTIFACTS);
+ assertHandler(iterator.next(), ArtifactIdsSqlHandler.class, SqlHandlerPriority.ARTIFACT_ID);
+ assertHandler(iterator.next(), ArtifactGuidSqlHandler.class, SqlHandlerPriority.ARTIFACT_GUID);
+ assertHandler(iterator.next(), ArtifactHridsSqlHandler.class, SqlHandlerPriority.ARTIFACT_HRID);
+ assertHandler(iterator.next(), AttributeOtherSqlHandler.class, SqlHandlerPriority.ATTRIBUTE_VALUE);
+
+ assertHandler(iterator.next(), AttributeTokenSqlHandler.class, SqlHandlerPriority.ATTRIBUTE_TOKENIZED_VALUE,
+ tagProcessor);
+ assertHandler(iterator.next(), ArtifactTypeSqlHandler.class, SqlHandlerPriority.ARTIFACT_TYPE);
+ assertHandler(iterator.next(), AttributeTypeExistsSqlHandler.class, SqlHandlerPriority.ATTRIBUTE_TYPE_EXISTS);
+ assertHandler(iterator.next(), RelationTypeExistsSqlHandler.class, SqlHandlerPriority.RELATION_TYPE_EXISTS);
+ assertHandler(iterator.next(), RelatedToSqlHandler.class, SqlHandlerPriority.RELATED_TO_ART_IDS);
+ assertHandler(iterator.next(), AllArtifactsSqlHandler.class, SqlHandlerPriority.ALL_ARTIFACTS);
}
- private void assertSqlHandler(SqlHandler<?> handler, Class<? extends SqlHandler<?>> clazz, SqlHandlerPriority priority) {
- assertHandler(handler, clazz, priority, logger, identityService);
+ private void assertHandler(SqlHandler<?> actual, Class<?> type, SqlHandlerPriority priority) {
+ assertHandler(actual, type, priority, null);
}
- private static void assertHandler(SqlHandler<?> actual, Class<?> type, SqlHandlerPriority priority, Log logger, IdentityService idService) {
+ private void assertHandler(SqlHandler<?> actual, Class<?> type, SqlHandlerPriority priority, TagProcessor actualProcessor) {
Assert.assertNotNull(actual);
Assert.assertEquals(type, actual.getClass());
Assert.assertEquals(logger, actual.getLogger());
- Assert.assertEquals(idService, actual.getIdentityService());
+ Assert.assertEquals(identityService, actual.getIdentityService());
Assert.assertEquals(priority.ordinal(), actual.getPriority());
+
+ if (actualProcessor != null) {
+ HasTagProcessor hasProcessor = (HasTagProcessor) actual;
+ Assert.assertEquals(actualProcessor, hasProcessor.getTagProcessor());
+ }
}
- private static CriteriaSet createCriteria(IOseeBranch branch, Collection<? extends Criteria> criteria) {
- CriteriaSet set = new CriteriaSet(branch);
+ private static CriteriaSet createCriteria(Collection<? extends Criteria> criteria) {
+ CriteriaSet set = new CriteriaSet();
for (Criteria crit : criteria) {
set.add(crit);
}
diff --git a/plugins/org.eclipse.osee.orcs.db/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.db/META-INF/MANIFEST.MF
index 07f8cfe82a..b1708c9bb7 100644
--- a/plugins/org.eclipse.osee.orcs.db/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs.db/META-INF/MANIFEST.MF
@@ -48,6 +48,7 @@ Import-Package: org.eclipse.emf.common.notify,
org.eclipse.osee.orcs.core.ds.criteria,
org.eclipse.osee.orcs.data,
org.eclipse.osee.orcs.search,
+ org.eclipse.osee.orcs.utility,
org.osgi.framework
Bundle-ActivationPolicy: lazy
Require-Bundle: org.eclipse.core.runtime,
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/DataModuleFactory.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/DataModuleFactory.java
index 735cc0eb5b..fc31f64df7 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/DataModuleFactory.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/DataModuleFactory.java
@@ -55,7 +55,7 @@ public class DataModuleFactory {
OrcsObjectFactory objectFactory = loaderModule.createOrcsObjectFactory(attributeTypes);
final DataFactory dataFactory = loaderModule.createDataFactory(objectFactory, artifactTypes);
final DataLoaderFactory dataLoaderFactory = loaderModule.createDataLoaderFactory(objectFactory, branchCache);
- final QueryEngine queryEngine = queryModule.createQueryEngine(branchCache);
+ final QueryEngine queryEngine = queryModule.createQueryEngine(dataLoaderFactory, branchCache, attributeTypes);
final BranchDataStore branchDataStore = branchModule.createBranchDataStore(dataLoaderFactory);
final TxDataStore txDataStore = txModule.createTransactionStore(dataLoaderFactory, indexer, attributeTypes);
final DataStoreAdmin dataStoreAdmin = adminModule.createDataStoreAdmin(branchDataStore);
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/DataStoreAdminImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/DataStoreAdminImpl.java
deleted file mode 100644
index 0eca2f0e3e..0000000000
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/DataStoreAdminImpl.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.orcs.db.internal;
-
-import java.util.Map;
-import java.util.concurrent.Callable;
-import org.eclipse.osee.database.schema.SchemaOptions;
-import org.eclipse.osee.database.schema.SchemaResourceProvider;
-import org.eclipse.osee.framework.core.services.IdentityService;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.OrcsSession;
-import org.eclipse.osee.orcs.core.SystemPreferences;
-import org.eclipse.osee.orcs.core.ds.BranchDataStore;
-import org.eclipse.osee.orcs.core.ds.DataStoreAdmin;
-import org.eclipse.osee.orcs.core.ds.DataStoreInfo;
-import org.eclipse.osee.orcs.db.internal.callable.FetchDatastoreInfoCallable;
-import org.eclipse.osee.orcs.db.internal.callable.InitializeDatastoreCallable;
-import org.eclipse.osee.orcs.db.internal.util.DynamicSchemaResourceProvider;
-
-/**
- * @author Roberto E. Escobar
- */
-public class DataStoreAdminImpl implements DataStoreAdmin {
-
- private final Log logger;
- private final IOseeDatabaseService dbService;
- private final IdentityService identityService;
- private final BranchDataStore branchStore;
- private final SystemPreferences preferences;
-
- public DataStoreAdminImpl(Log logger, IOseeDatabaseService dbService, IdentityService identityService, BranchDataStore branchStore, SystemPreferences preferences) {
- super();
- this.logger = logger;
- this.dbService = dbService;
- this.identityService = identityService;
- this.branchStore = branchStore;
- this.preferences = preferences;
- }
-
- @Override
- public Callable<DataStoreInfo> createDataStore(OrcsSession session, Map<String, String> parameters) {
- String tableDataSpace = getOption(parameters, DataStoreConfigConstants.SCHEMA_TABLE_DATA_NAMESPACE, "");
- String indexDataSpace = getOption(parameters, DataStoreConfigConstants.SCHEMA_INDEX_DATA_NAMESPACE, "");
- boolean useFileSpecifiedSchemas =
- getOption(parameters, DataStoreConfigConstants.SCHEMA_USER_FILE_SPECIFIED_NAMESPACE, false);
-
- SchemaResourceProvider schemaProvider = new DynamicSchemaResourceProvider(logger);
-
- SchemaOptions options = new SchemaOptions(tableDataSpace, indexDataSpace, useFileSpecifiedSchemas);
- return new InitializeDatastoreCallable(session, logger, dbService, identityService, branchStore, preferences,
- schemaProvider, options);
- }
-
- @Override
- public Callable<DataStoreInfo> getDataStoreInfo(OrcsSession session) {
- SchemaResourceProvider schemaProvider = new DynamicSchemaResourceProvider(logger);
- return new FetchDatastoreInfoCallable(logger, session, dbService, schemaProvider, preferences);
- }
-
- private boolean getOption(Map<String, String> parameters, String key, boolean defaultValue) {
- boolean toReturn = defaultValue;
- String value = parameters.get(key);
- if (Strings.isValid(value)) {
- toReturn = Boolean.parseBoolean(value);
- }
- return toReturn;
- }
-
- private String getOption(Map<String, String> parameters, String key, String defaultValue) {
- String toReturn = defaultValue;
- String value = parameters.get(key);
- if (Strings.isValid(value)) {
- toReturn = value;
- }
- return toReturn;
- }
-
-}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactoryImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactoryImpl.java
index bd477f5a1f..eeb0aa4b4c 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactoryImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactoryImpl.java
@@ -28,15 +28,12 @@ import org.eclipse.osee.framework.core.model.change.RelationChangeItem;
import org.eclipse.osee.framework.core.services.IdentityService;
import org.eclipse.osee.orcs.OrcsSession;
import org.eclipse.osee.orcs.core.ds.ArtifactData;
-import org.eclipse.osee.orcs.core.ds.ArtifactDataHandler;
import org.eclipse.osee.orcs.core.ds.AttributeData;
-import org.eclipse.osee.orcs.core.ds.AttributeDataHandler;
import org.eclipse.osee.orcs.core.ds.DataLoader;
import org.eclipse.osee.orcs.core.ds.DataLoaderFactory;
import org.eclipse.osee.orcs.core.ds.LoadDataHandlerAdapter;
import org.eclipse.osee.orcs.core.ds.OrcsData;
import org.eclipse.osee.orcs.core.ds.RelationData;
-import org.eclipse.osee.orcs.core.ds.RelationDataHandler;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Multimap;
@@ -97,14 +94,8 @@ public class MissingChangeItemFactoryImpl implements MissingChangeItemFactory {
loader.load(cancellation, new LoadDataHandlerAdapter() {
@Override
- public ArtifactDataHandler getArtifactDataHandler() {
- return new ArtifactDataHandler() {
-
- @Override
- public void onData(ArtifactData data) {
- missingArtIds.remove(data.getLocalId());
- }
- };
+ public void onData(ArtifactData data) {
+ missingArtIds.remove(data.getLocalId());
}
});
return missingArtIds;
@@ -122,45 +113,26 @@ public class MissingChangeItemFactoryImpl implements MissingChangeItemFactory {
loader.load(cancellation, new LoadDataHandlerAdapter() {
@Override
- public ArtifactDataHandler getArtifactDataHandler() {
- return new ArtifactDataHandler() {
-
- @Override
- public void onData(ArtifactData data) throws OseeCoreException {
- if (!modifiedArtIds.contains(data.getLocalId())) {
- toReturn.add(createArtifactChangeItem(data));
- }
- }
- };
-
+ public void onData(ArtifactData data) throws OseeCoreException {
+ if (!modifiedArtIds.contains(data.getLocalId())) {
+ toReturn.add(createArtifactChangeItem(data));
+ }
}
@Override
- public RelationDataHandler getRelationDataHandler() {
- return new RelationDataHandler() {
-
- @Override
- public void onData(RelationData data) {
- int localId = data.getLocalId();
- if (!modifiedRels.get(data.getArtIdA()).contains(localId) && !modifiedRels.get(data.getArtIdB()).contains(
- localId)) {
- relations.add(data);
- }
- }
- };
+ public void onData(RelationData data) {
+ int localId = data.getLocalId();
+ if (!modifiedRels.get(data.getArtIdA()).contains(localId) && !modifiedRels.get(data.getArtIdB()).contains(
+ localId)) {
+ relations.add(data);
+ }
}
@Override
- public AttributeDataHandler getAttributeDataHandler() {
- return new AttributeDataHandler() {
-
- @Override
- public void onData(AttributeData data) throws OseeCoreException {
- if (!modifiedAttrIds.get(data.getArtifactId()).contains(data.getLocalId())) {
- toReturn.add(createAttributeChangeItem(data));
- }
- }
- };
+ public void onData(AttributeData data) throws OseeCoreException {
+ if (!modifiedAttrIds.get(data.getArtifactId()).contains(data.getLocalId())) {
+ toReturn.add(createAttributeChangeItem(data));
+ }
}
});
@@ -194,16 +166,10 @@ public class MissingChangeItemFactoryImpl implements MissingChangeItemFactory {
loader.load(cancellation, new LoadDataHandlerAdapter() {
@Override
- public ArtifactDataHandler getArtifactDataHandler() {
- return new ArtifactDataHandler() {
-
- @Override
- public void onData(ArtifactData data) throws OseeCoreException {
- for (RelationData relData : relationChangesToAdd.get(data.getLocalId())) {
- toReturn.add(createRelationChangeItem(relData));
- }
- }
- };
+ public void onData(ArtifactData data) throws OseeCoreException {
+ for (RelationData relData : relationChangesToAdd.get(data.getLocalId())) {
+ toReturn.add(createRelationChangeItem(relData));
+ }
}
});
return toReturn;
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderFactoryImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderFactoryImpl.java
index 66609009c0..65a2c73544 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderFactoryImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderFactoryImpl.java
@@ -32,6 +32,7 @@ import org.eclipse.osee.orcs.db.internal.loader.executors.AbstractLoadExecutor;
import org.eclipse.osee.orcs.db.internal.loader.executors.LoadExecutor;
import org.eclipse.osee.orcs.db.internal.loader.executors.QueryContextLoadExecutor;
import org.eclipse.osee.orcs.db.internal.search.QuerySqlContext;
+import org.eclipse.osee.orcs.db.internal.search.engines.ArtifactQuerySqlContext;
/**
* @author Roberto E. Escobar
@@ -53,7 +54,7 @@ public class DataLoaderFactoryImpl implements DataLoaderFactory {
@Override
public int getCount(HasCancellation cancellation, QueryContext queryContext) throws OseeCoreException {
- QuerySqlContext context = toSqlContext(queryContext);
+ QuerySqlContext context = adapt(QuerySqlContext.class, queryContext);
int count = -1;
long startTime = 0;
@@ -89,7 +90,7 @@ public class DataLoaderFactoryImpl implements DataLoaderFactory {
@Override
public DataLoader fromQueryContext(QueryContext queryContext) throws OseeCoreException {
- QuerySqlContext sqlQueryContext = toSqlContext(queryContext);
+ ArtifactQuerySqlContext sqlQueryContext = adapt(ArtifactQuerySqlContext.class, queryContext);
AbstractLoadExecutor executor = new QueryContextLoadExecutor(loader, dbService, sqlQueryContext);
Options options = OptionsUtil.createOptions();
return new DataLoaderImpl(logger, executor, options);
@@ -97,10 +98,10 @@ public class DataLoaderFactoryImpl implements DataLoaderFactory {
@Override
public DataLoader fromBranchAndArtifactIds(OrcsSession session, IOseeBranch branch, Collection<Integer> artifactIds) throws OseeCoreException {
+ Conditions.checkNotNull(branch, "branch");
Conditions.checkNotNullOrEmpty(artifactIds, "artifactIds");
- int branchId = branchCache.getLocalId(branch);
- AbstractLoadExecutor executor = new LoadExecutor(loader, dbService, session, branchId, artifactIds);
+ AbstractLoadExecutor executor = new LoadExecutor(loader, dbService, branchCache, session, branch, artifactIds);
Options options = OptionsUtil.createOptions();
return new DataLoaderImpl(logger, executor, options);
}
@@ -110,15 +111,16 @@ public class DataLoaderFactoryImpl implements DataLoaderFactory {
return fromBranchAndArtifactIds(session, branch, toCollection(artifactIds));
}
- private QuerySqlContext toSqlContext(QueryContext queryContext) throws OseeCoreException {
- QuerySqlContext sqlContext = null;
- if (queryContext instanceof QuerySqlContext) {
- sqlContext = (QuerySqlContext) queryContext;
+ @SuppressWarnings("unchecked")
+ private <T> T adapt(Class<T> clazz, QueryContext queryContext) throws OseeCoreException {
+ T toReturn = null;
+ if (clazz.isAssignableFrom(queryContext.getClass())) {
+ toReturn = (T) queryContext;
} else {
- throw new OseeCoreException("Invalid query context type [%s] - expected SqlContext",
- queryContext.getClass().getName());
+ throw new OseeCoreException("Invalid query context type [%s] - expected [%s]",
+ queryContext.getClass().getName(), clazz.getName());
}
- return sqlContext;
+ return toReturn;
}
private Collection<Integer> toCollection(int... ids) {
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderImpl.java
index 091e8a4b7e..eae6928c14 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderImpl.java
@@ -196,8 +196,8 @@ public class DataLoaderImpl implements DataLoader {
startTime = System.currentTimeMillis();
logger.trace("%s [start] - [%s] [%s]", getClass().getSimpleName(), criteria, options);
}
- handler.onLoadStart();
try {
+ handler.onLoadStart();
loadExecutor.load(cancellation, handler, criteria, options);
} finally {
handler.onLoadEnd();
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/LoadSqlContext.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/LoadSqlContext.java
index 74b2dbe297..19e7fbfdd3 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/LoadSqlContext.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/LoadSqlContext.java
@@ -10,19 +10,28 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.loader;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.orcs.OrcsSession;
-import org.eclipse.osee.orcs.core.ds.DataPostProcessor;
import org.eclipse.osee.orcs.core.ds.LoadContext;
import org.eclipse.osee.orcs.core.ds.Options;
+import org.eclipse.osee.orcs.data.HasBranch;
import org.eclipse.osee.orcs.db.internal.sql.SqlContextImpl;
/**
* @author Roberto E. Escobar
*/
-public class LoadSqlContext extends SqlContextImpl<DataPostProcessor<?>> implements LoadContext {
+public class LoadSqlContext extends SqlContextImpl implements LoadContext, HasBranch {
- public LoadSqlContext(OrcsSession session, Options options) {
+ private final IOseeBranch branch;
+
+ public LoadSqlContext(OrcsSession session, Options options, IOseeBranch branch) {
super(session, options);
+ this.branch = branch;
+ }
+
+ @Override
+ public IOseeBranch getBranch() {
+ return branch;
}
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/LoadSqlWriter.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/LoadSqlWriter.java
index b22714ecfd..6963ffb6b9 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/LoadSqlWriter.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/LoadSqlWriter.java
@@ -15,7 +15,6 @@ import org.eclipse.osee.framework.core.enums.TxChange;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.database.IOseeDatabaseService;
import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.core.ds.DataPostProcessor;
import org.eclipse.osee.orcs.core.ds.Options;
import org.eclipse.osee.orcs.core.ds.OptionsUtil;
import org.eclipse.osee.orcs.db.internal.SqlProvider;
@@ -29,7 +28,7 @@ import org.eclipse.osee.orcs.db.internal.sql.TableEnum;
*/
public class LoadSqlWriter extends AbstractSqlWriter {
- public LoadSqlWriter(Log logger, IOseeDatabaseService dbService, SqlProvider sqlProvider, SqlContext<DataPostProcessor<?>> context) {
+ public LoadSqlWriter(Log logger, IOseeDatabaseService dbService, SqlProvider sqlProvider, SqlContext context) {
super(logger, dbService, sqlProvider, context);
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/LoadUtil.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/LoadUtil.java
new file mode 100644
index 0000000000..f920e863dd
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/LoadUtil.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.loader;
+
+import org.eclipse.osee.orcs.db.internal.sql.RelationalConstants;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class LoadUtil {
+
+ private static final int MINIMUM_FETCH_SIZE = 10;
+ private static final int APPROXIMATE_NUMBER_OF_SUB_ITEMS = 20;
+
+ private LoadUtil() {
+ // Utility class
+ }
+
+ public static int computeFetchSize(int initialSize) {
+ int fetchSize = initialSize;
+ if (fetchSize < MINIMUM_FETCH_SIZE) {
+ fetchSize = MINIMUM_FETCH_SIZE;
+ }
+
+ // Account for attribute and relation loading
+ fetchSize *= APPROXIMATE_NUMBER_OF_SUB_ITEMS;
+
+ if (fetchSize < 0 || fetchSize > RelationalConstants.MAX_FETCH_SIZE) {
+ fetchSize = RelationalConstants.MAX_FETCH_SIZE;
+ }
+ return fetchSize;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/SqlObjectLoader.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/SqlObjectLoader.java
index cfa1208e5b..00a5a1e59a 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/SqlObjectLoader.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/SqlObjectLoader.java
@@ -12,6 +12,7 @@ package org.eclipse.osee.orcs.db.internal.loader;
import java.util.concurrent.CancellationException;
import org.eclipse.osee.executor.admin.HasCancellation;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.enums.LoadLevel;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.database.IOseeDatabaseService;
@@ -20,23 +21,28 @@ import org.eclipse.osee.framework.database.core.ArtifactJoinQuery;
import org.eclipse.osee.framework.database.core.IOseeStatement;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.core.ds.ArtifactDataHandler;
-import org.eclipse.osee.orcs.core.ds.AttributeDataHandler;
+import org.eclipse.osee.orcs.OrcsSession;
+import org.eclipse.osee.orcs.core.ds.ArtifactData;
+import org.eclipse.osee.orcs.core.ds.AttributeData;
import org.eclipse.osee.orcs.core.ds.Criteria;
import org.eclipse.osee.orcs.core.ds.LoadDataHandler;
+import org.eclipse.osee.orcs.core.ds.LoadDescription;
+import org.eclipse.osee.orcs.core.ds.Options;
import org.eclipse.osee.orcs.core.ds.OptionsUtil;
-import org.eclipse.osee.orcs.core.ds.OrcsData;
import org.eclipse.osee.orcs.core.ds.OrcsDataHandler;
-import org.eclipse.osee.orcs.core.ds.RelationDataHandler;
+import org.eclipse.osee.orcs.core.ds.RelationData;
+import org.eclipse.osee.orcs.data.HasLocalId;
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.loader.data.VersionObjectFactory;
+import org.eclipse.osee.orcs.db.internal.loader.data.OrcsDataFactory;
import org.eclipse.osee.orcs.db.internal.loader.processor.ArtifactLoadProcessor;
import org.eclipse.osee.orcs.db.internal.loader.processor.AttributeLoadProcessor;
import org.eclipse.osee.orcs.db.internal.loader.processor.LoadProcessor;
import org.eclipse.osee.orcs.db.internal.loader.processor.RelationLoadProcessor;
import org.eclipse.osee.orcs.db.internal.sql.AbstractSqlWriter;
+import org.eclipse.osee.orcs.db.internal.sql.OseeSql;
+import org.eclipse.osee.orcs.db.internal.sql.RelationalConstants;
import org.eclipse.osee.orcs.db.internal.sql.SqlHandler;
import org.eclipse.osee.orcs.db.internal.sql.SqlHandlerFactory;
@@ -97,6 +103,7 @@ public class SqlObjectLoader {
try {
join.store();
criteria.setQueryId(join.getQueryId());
+
loadArtifacts(cancellation, builder, criteria, loadContext, fetchSize);
} finally {
join.delete();
@@ -107,7 +114,10 @@ public class SqlObjectLoader {
}
}
- public void loadArtifacts(HasCancellation cancellation, LoadDataHandler builder, CriteriaOrcsLoad criteria, LoadSqlContext loadContext, int fetchSize) throws OseeCoreException {
+ private void loadArtifacts(HasCancellation cancellation, LoadDataHandler builder, CriteriaOrcsLoad criteria, LoadSqlContext loadContext, int fetchSize) throws OseeCoreException {
+ checkCancelled(cancellation);
+ loadDescription(builder, loadContext);
+
checkCancelled(cancellation);
loadArtifacts(builder, criteria.getArtifactCriteria(), loadContext, fetchSize);
@@ -118,8 +128,24 @@ public class SqlObjectLoader {
loadRelations(builder, criteria.getRelationCriteria(), loadContext, fetchSize);
}
+ protected void loadDescription(LoadDataHandler builder, final LoadSqlContext loadContext) throws OseeCoreException {
+ OrcsSession session = loadContext.getSession();
+ Options options = loadContext.getOptions();
+ IOseeBranch branch = loadContext.getBranch();
+
+ int transactionLoaded;
+ if (OptionsUtil.isHeadTransaction(options)) {
+ transactionLoaded = loadHeadTransactionId(branch);
+ } else {
+ transactionLoaded = OptionsUtil.getFromTransaction(options);
+ }
+
+ LoadDescription description = createDescription(session, options, branch, transactionLoaded);
+ builder.onLoadDescription(description);
+ }
+
protected void loadArtifacts(LoadDataHandler builder, Criteria criteria, LoadSqlContext loadContext, int fetchSize) throws OseeCoreException {
- ArtifactDataHandler artHandler = builder.getArtifactDataHandler();
+ OrcsDataHandler<ArtifactData> artHandler = builder.getArtifactDataHandler();
writeSql(criteria, loadContext);
load(artifactProcessor, artHandler, loadContext, fetchSize);
}
@@ -127,7 +153,7 @@ public class SqlObjectLoader {
protected void loadAttributes(LoadDataHandler builder, Criteria criteria, LoadSqlContext loadContext, int fetchSize) throws OseeCoreException {
LoadLevel loadLevel = OptionsUtil.getLoadLevel(loadContext.getOptions());
if (isAttributeLoadingAllowed(loadLevel)) {
- AttributeDataHandler attrHandler = builder.getAttributeDataHandler();
+ OrcsDataHandler<AttributeData> attrHandler = builder.getAttributeDataHandler();
writeSql(criteria, loadContext);
load(attributeProcessor, attrHandler, loadContext, fetchSize);
}
@@ -136,13 +162,19 @@ public class SqlObjectLoader {
protected void loadRelations(LoadDataHandler builder, Criteria criteria, LoadSqlContext loadContext, int fetchSize) throws OseeCoreException {
LoadLevel loadLevel = OptionsUtil.getLoadLevel(loadContext.getOptions());
if (isRelationLoadingAllowed(loadLevel)) {
- RelationDataHandler relHandler = builder.getRelationDataHandler();
+ OrcsDataHandler<RelationData> relHandler = builder.getRelationDataHandler();
writeSql(criteria, loadContext);
load(relationProcessor, relHandler, loadContext, fetchSize);
}
}
- protected <D extends OrcsData, F extends VersionObjectFactory, H extends OrcsDataHandler<D>> void load(LoadProcessor<D, F, H> processor, H handler, LoadSqlContext loadContext, int fetchSize) throws OseeCoreException {
+ protected int loadHeadTransactionId(IOseeBranch branch) throws OseeCoreException {
+ String sql = sqlProvider.getSql(OseeSql.TX_GET_MAX_AS_LARGEST_TX_WITH_BRANCH_GUID);
+ return getDatabaseService().runPreparedQueryFetchObject(RelationalConstants.TRANSACTION_SENTINEL, sql,
+ branch.getGuid());
+ }
+
+ protected <D extends HasLocalId, F extends OrcsDataFactory> void load(LoadProcessor<D, F> processor, OrcsDataHandler<D> handler, LoadSqlContext loadContext, int fetchSize) throws OseeCoreException {
try {
for (AbstractJoinQuery join : loadContext.getJoins()) {
join.store();
@@ -179,4 +211,34 @@ public class SqlObjectLoader {
}
}
}
+
+ private static LoadDescription createDescription(final OrcsSession session, final Options options, final IOseeBranch branch, final int transactionLoaded) {
+ return new LoadDescription() {
+
+ @Override
+ public OrcsSession getSession() {
+ return session;
+ }
+
+ @Override
+ public Options getOptions() {
+ return options;
+ }
+
+ @Override
+ public IOseeBranch getBranch() {
+ return branch;
+ }
+
+ @Override
+ public int getTransaction() {
+ return transactionLoaded;
+ }
+
+ @Override
+ public boolean isMultiBranch() {
+ return getBranch() == null;
+ }
+ };
+ }
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/ArtifactDataImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/ArtifactDataImpl.java
index cc4a860a36..bddc30103a 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/ArtifactDataImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/ArtifactDataImpl.java
@@ -17,7 +17,7 @@ import org.eclipse.osee.orcs.db.internal.sql.RelationalConstants;
/**
* @author Roberto E. Escobar
*/
-public class ArtifactDataImpl extends OrcsObjectImpl implements ArtifactData {
+public class ArtifactDataImpl extends OrcsVersionedObjectImpl implements ArtifactData {
private String guid = RelationalConstants.DEFAULT_GUID;
private String humanReadableId = RelationalConstants.HUMAN_READABLE_ID;
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/AttributeDataImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/AttributeDataImpl.java
index 04a3183515..5b43a197e8 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/AttributeDataImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/AttributeDataImpl.java
@@ -18,7 +18,7 @@ import org.eclipse.osee.orcs.db.internal.sql.RelationalConstants;
/**
* @author Roberto E. Escobar
*/
-public class AttributeDataImpl extends OrcsObjectImpl implements AttributeData {
+public class AttributeDataImpl extends OrcsVersionedObjectImpl implements AttributeData {
private int artifactId = RelationalConstants.ART_ID_SENTINEL;
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/ArtifactDataHandler.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsDataFactory.java
index 6bacc7fb2c..fe1c4a9f4b 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/ArtifactDataHandler.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsDataFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
+ * 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
@@ -8,12 +8,11 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs.core.ds;
-
+package org.eclipse.osee.orcs.db.internal.loader.data;
/**
* @author Roberto E. Escobar
*/
-public interface ArtifactDataHandler extends OrcsDataHandler<ArtifactData> {
+public interface OrcsDataFactory {
//
-}
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsObjectImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsObjectImpl.java
index 3c7d150836..79a6a8b41d 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsObjectImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsObjectImpl.java
@@ -10,29 +10,18 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.loader.data;
-import org.eclipse.osee.framework.core.enums.ModificationType;
-import org.eclipse.osee.orcs.core.ds.OrcsData;
-import org.eclipse.osee.orcs.core.ds.VersionData;
+import org.eclipse.osee.orcs.data.HasLocalId;
import org.eclipse.osee.orcs.db.internal.sql.RelationalConstants;
/**
* @author Roberto E. Escobar
*/
-public abstract class OrcsObjectImpl implements OrcsData {
+public abstract class OrcsObjectImpl implements HasLocalId {
private int localId = RelationalConstants.DEFAULT_ITEM_ID;
- private long typeUuid = RelationalConstants.DEFAULT_TYPE_UUID;
- private long baseTypeUuid = RelationalConstants.DEFAULT_TYPE_UUID;
- private ModificationType baseModType = RelationalConstants.DEFAULT_MODIFICATION_TYPE;
- private ModificationType previousModType = RelationalConstants.DEFAULT_MODIFICATION_TYPE;
- private ModificationType currentModType = RelationalConstants.DEFAULT_MODIFICATION_TYPE;
-
- private final VersionData version;
-
- protected OrcsObjectImpl(VersionData version) {
+ protected OrcsObjectImpl() {
super();
- this.version = version;
}
@Override
@@ -40,80 +29,15 @@ public abstract class OrcsObjectImpl implements OrcsData {
return localId;
}
- @Override
public void setLocalId(int localId) {
this.localId = localId;
}
@Override
- public long getTypeUuid() {
- return typeUuid;
- }
-
- @Override
- public void setTypeUuid(long typeUuid) {
- this.typeUuid = typeUuid;
- }
-
- @Override
- public long getBaseTypeUuid() {
- return baseTypeUuid;
- }
-
- @Override
- public void setBaseTypeUuid(long baseTypeUuid) {
- this.baseTypeUuid = baseTypeUuid;
- }
-
- @Override
- public void setBaseModType(ModificationType modType) {
- baseModType = modType;
- }
-
- @Override
- public ModificationType getModType() {
- return currentModType;
- }
-
- @Override
- public void setModType(ModificationType modType) {
- previousModType = currentModType;
- this.currentModType = modType;
- }
-
- @Override
- public ModificationType getPreviousModType() {
- return previousModType;
- }
-
- @Override
- public ModificationType getBaseModType() {
- return baseModType;
- }
-
- @Override
- public boolean hasTypeUuidChange() {
- return getBaseTypeUuid() != getTypeUuid();
- }
-
- @Override
- public boolean hasModTypeChange() {
- return getBaseModType() != getModType();
- }
-
- @Override
- public VersionData getVersion() {
- return version;
- }
-
- @Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + localId;
- result = prime * result + ((baseModType == null) ? 0 : baseModType.hashCode());
- result = prime * result + (int) (baseTypeUuid ^ (baseTypeUuid >>> 32));
- result = prime * result + ((version == null) ? 0 : version.hashCode());
return result;
}
@@ -132,25 +56,11 @@ public abstract class OrcsObjectImpl implements OrcsData {
if (localId != other.localId) {
return false;
}
- if (baseModType != other.baseModType) {
- return false;
- }
- if (baseTypeUuid != other.baseTypeUuid) {
- return false;
- }
- if (version == null) {
- if (other.version != null) {
- return false;
- }
- } else if (!version.equals(other.version)) {
- return false;
- }
return true;
}
@Override
public String toString() {
- return "OrcsObject [localId=" + localId + ", typeUuid=" + typeUuid + ", baseTypeUuid=" + baseTypeUuid + ", modType=" + currentModType + ", previousModType=" + previousModType + ", baseModType=" + baseModType + ", version=" + version + "]";
+ return "OrcsObject [localId=" + localId + "]";
}
-
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsVersionedObjectImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsVersionedObjectImpl.java
new file mode 100644
index 0000000000..cdc779dcaa
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsVersionedObjectImpl.java
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.loader.data;
+
+import org.eclipse.osee.framework.core.enums.ModificationType;
+import org.eclipse.osee.orcs.core.ds.OrcsData;
+import org.eclipse.osee.orcs.core.ds.VersionData;
+import org.eclipse.osee.orcs.db.internal.sql.RelationalConstants;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public abstract class OrcsVersionedObjectImpl extends OrcsObjectImpl implements OrcsData {
+
+ private long typeUuid = RelationalConstants.DEFAULT_TYPE_UUID;
+ private long baseTypeUuid = RelationalConstants.DEFAULT_TYPE_UUID;
+
+ private ModificationType baseModType = RelationalConstants.DEFAULT_MODIFICATION_TYPE;
+ private ModificationType previousModType = RelationalConstants.DEFAULT_MODIFICATION_TYPE;
+ private ModificationType currentModType = RelationalConstants.DEFAULT_MODIFICATION_TYPE;
+
+ private final VersionData version;
+
+ protected OrcsVersionedObjectImpl(VersionData version) {
+ super();
+ this.version = version;
+ }
+
+ @Override
+ public long getTypeUuid() {
+ return typeUuid;
+ }
+
+ @Override
+ public void setTypeUuid(long typeUuid) {
+ this.typeUuid = typeUuid;
+ }
+
+ @Override
+ public long getBaseTypeUuid() {
+ return baseTypeUuid;
+ }
+
+ @Override
+ public void setBaseTypeUuid(long baseTypeUuid) {
+ this.baseTypeUuid = baseTypeUuid;
+ }
+
+ @Override
+ public void setBaseModType(ModificationType modType) {
+ baseModType = modType;
+ }
+
+ @Override
+ public ModificationType getModType() {
+ return currentModType;
+ }
+
+ @Override
+ public void setModType(ModificationType modType) {
+ previousModType = currentModType;
+ this.currentModType = modType;
+ }
+
+ @Override
+ public ModificationType getPreviousModType() {
+ return previousModType;
+ }
+
+ @Override
+ public ModificationType getBaseModType() {
+ return baseModType;
+ }
+
+ @Override
+ public boolean hasTypeUuidChange() {
+ return getBaseTypeUuid() != getTypeUuid();
+ }
+
+ @Override
+ public boolean hasModTypeChange() {
+ return getBaseModType() != getModType();
+ }
+
+ @Override
+ public VersionData getVersion() {
+ return version;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((baseModType == null) ? 0 : baseModType.hashCode());
+ result = prime * result + (int) (baseTypeUuid ^ (baseTypeUuid >>> 32));
+ result = prime * result + ((version == null) ? 0 : version.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ OrcsVersionedObjectImpl other = (OrcsVersionedObjectImpl) obj;
+ if (baseModType != other.baseModType) {
+ return false;
+ }
+ if (baseTypeUuid != other.baseTypeUuid) {
+ return false;
+ }
+ if (version == null) {
+ if (other.version != null) {
+ return false;
+ }
+ } else if (!version.equals(other.version)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "OrcsVersionedObject [" + super.toString() + ", typeUuid=" + typeUuid + ", baseTypeUuid=" + baseTypeUuid + ", modType=" + currentModType + ", previousModType=" + previousModType + ", baseModType=" + baseModType + ", version=" + version + "]";
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/RelationDataImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/RelationDataImpl.java
index 791f97037a..79d9e3a09c 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/RelationDataImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/RelationDataImpl.java
@@ -18,7 +18,7 @@ import org.eclipse.osee.orcs.db.internal.sql.RelationalConstants;
/**
* @author Andrew M. Finkbeiner
*/
-public class RelationDataImpl extends OrcsObjectImpl implements RelationData {
+public class RelationDataImpl extends OrcsVersionedObjectImpl implements RelationData {
private int parentId = RelationalConstants.ART_ID_SENTINEL;
private int artIdA = RelationalConstants.ART_ID_SENTINEL;
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/VersionObjectFactory.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/VersionObjectFactory.java
index c327130e73..af48c428d9 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/VersionObjectFactory.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/VersionObjectFactory.java
@@ -16,7 +16,7 @@ import org.eclipse.osee.orcs.core.ds.VersionData;
/**
* @author Roberto E. Escobar
*/
-public interface VersionObjectFactory {
+public interface VersionObjectFactory extends OrcsDataFactory {
VersionData createDefaultVersionData();
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/AbstractLoadExecutor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/AbstractLoadExecutor.java
index 50ccd1a66a..d969c4afd9 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/AbstractLoadExecutor.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/AbstractLoadExecutor.java
@@ -20,7 +20,6 @@ import org.eclipse.osee.orcs.core.ds.Options;
import org.eclipse.osee.orcs.db.internal.loader.LoadSqlContext;
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.sql.RelationalConstants;
/**
* @author Andrew M. Finkbeiner
@@ -42,8 +41,8 @@ public abstract class AbstractLoadExecutor {
return dbService;
}
- protected void loadFromJoin(ArtifactJoinQuery join, HasCancellation cancellation, LoadDataHandler builder, CriteriaOrcsLoad criteria, LoadSqlContext loadContext, int fetchSize) throws OseeCoreException {
- loader.loadArtifacts(cancellation, builder, join, criteria, loadContext, fetchSize);
+ protected void loadFromJoin(ArtifactJoinQuery join, HasCancellation cancellation, LoadDataHandler handler, CriteriaOrcsLoad criteria, LoadSqlContext loadContext, int fetchSize) throws OseeCoreException {
+ loader.loadArtifacts(cancellation, handler, join, criteria, loadContext, fetchSize);
}
protected void checkCancelled(HasCancellation cancellation) throws CancellationException {
@@ -52,19 +51,4 @@ public abstract class AbstractLoadExecutor {
}
}
- protected int computeFetchSize(int initialSize) {
- int fetchSize = initialSize;
-
- if (fetchSize < 10) {
- fetchSize = 10;
- }
-
- // Account for attribute and relation loading
- fetchSize *= 20;
-
- if (fetchSize < 0 || fetchSize > RelationalConstants.MAX_FETCH_SIZE) {
- fetchSize = RelationalConstants.MAX_FETCH_SIZE;
- }
- return fetchSize;
- }
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/LoadExecutor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/LoadExecutor.java
index 6da7ec9563..3dc4e4fe2d 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/LoadExecutor.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/LoadExecutor.java
@@ -12,7 +12,9 @@ package org.eclipse.osee.orcs.db.internal.loader.executors;
import java.util.Collection;
import org.eclipse.osee.executor.admin.HasCancellation;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.cache.BranchCache;
import org.eclipse.osee.framework.database.IOseeDatabaseService;
import org.eclipse.osee.framework.database.core.ArtifactJoinQuery;
import org.eclipse.osee.framework.database.core.JoinUtility;
@@ -21,6 +23,7 @@ import org.eclipse.osee.orcs.core.ds.LoadDataHandler;
import org.eclipse.osee.orcs.core.ds.Options;
import org.eclipse.osee.orcs.core.ds.OptionsUtil;
import org.eclipse.osee.orcs.db.internal.loader.LoadSqlContext;
+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;
@@ -29,14 +32,16 @@ import org.eclipse.osee.orcs.db.internal.loader.criteria.CriteriaOrcsLoad;
*/
public class LoadExecutor extends AbstractLoadExecutor {
+ private final BranchCache branchCache;
private final OrcsSession session;
- private final int branchId;
+ private final IOseeBranch branch;
private final Collection<Integer> artifactIds;
- public LoadExecutor(SqlObjectLoader loader, IOseeDatabaseService dbService, OrcsSession session, int branchId, Collection<Integer> artifactIds) {
+ public LoadExecutor(SqlObjectLoader loader, IOseeDatabaseService dbService, BranchCache branchCache, OrcsSession session, IOseeBranch branch, Collection<Integer> artifactIds) {
super(loader, dbService);
+ this.branchCache = branchCache;
this.session = session;
- this.branchId = branchId;
+ this.branch = branch;
this.artifactIds = artifactIds;
}
@@ -44,15 +49,16 @@ public class LoadExecutor extends AbstractLoadExecutor {
public void load(HasCancellation cancellation, LoadDataHandler handler, CriteriaOrcsLoad criteria, Options options) throws OseeCoreException {
checkCancelled(cancellation);
+ int branchId = branchCache.getLocalId(branch);
+
ArtifactJoinQuery join = JoinUtility.createArtifactJoinQuery(getDatabaseService());
Integer transactionId = OptionsUtil.getFromTransaction(options);
for (Integer artId : artifactIds) {
join.add(artId, branchId, transactionId);
}
- LoadSqlContext loadContext = new LoadSqlContext(session, options);
- int fetchSize = computeFetchSize(artifactIds.size());
+ LoadSqlContext loadContext = new LoadSqlContext(session, options, branch);
+ int fetchSize = LoadUtil.computeFetchSize(artifactIds.size());
loadFromJoin(join, cancellation, handler, criteria, loadContext, fetchSize);
}
-
}
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 c6b4cc810a..9852cf3d13 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
@@ -22,9 +22,10 @@ import org.eclipse.osee.orcs.core.ds.LoadDataHandler;
import org.eclipse.osee.orcs.core.ds.Options;
import org.eclipse.osee.orcs.core.ds.OptionsUtil;
import org.eclipse.osee.orcs.db.internal.loader.LoadSqlContext;
+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.search.engines.ArtifactQuerySqlContext;
import org.eclipse.osee.orcs.db.internal.sql.RelationalConstants;
import org.eclipse.osee.orcs.db.internal.sql.SqlContext;
@@ -33,9 +34,9 @@ import org.eclipse.osee.orcs.db.internal.sql.SqlContext;
*/
public class QueryContextLoadExecutor extends AbstractLoadExecutor {
- private final QuerySqlContext queryContext;
+ private final ArtifactQuerySqlContext queryContext;
- public QueryContextLoadExecutor(SqlObjectLoader loader, IOseeDatabaseService dbService, QuerySqlContext queryContext) {
+ public QueryContextLoadExecutor(SqlObjectLoader loader, IOseeDatabaseService dbService, ArtifactQuerySqlContext queryContext) {
super(loader, dbService);
this.queryContext = queryContext;
}
@@ -45,16 +46,17 @@ public class QueryContextLoadExecutor extends AbstractLoadExecutor {
int fetchSize = computeFetchSize(queryContext);
ArtifactJoinQuery join = createArtifactIdJoin(getDatabaseService(), cancellation, fetchSize);
- LoadSqlContext loadContext = new LoadSqlContext(queryContext.getSession(), options);
+
+ LoadSqlContext loadContext = new LoadSqlContext(queryContext.getSession(), options, queryContext.getBranch());
loadFromJoin(join, cancellation, handler, criteria, loadContext, fetchSize);
}
- private int computeFetchSize(SqlContext<?> sqlContext) {
+ private int computeFetchSize(SqlContext sqlContext) {
int fetchSize = RelationalConstants.MIN_FETCH_SIZE;
for (AbstractJoinQuery join : sqlContext.getJoins()) {
fetchSize = Math.max(fetchSize, join.size());
}
- return computeFetchSize(fetchSize);
+ return LoadUtil.computeFetchSize(fetchSize);
}
private ArtifactJoinQuery createArtifactIdJoin(IOseeDatabaseService dbService, HasCancellation cancellation, int fetchSize) throws OseeCoreException {
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/ArtifactLoadProcessor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/ArtifactLoadProcessor.java
index a6ae932663..5d60bca4c3 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/ArtifactLoadProcessor.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/ArtifactLoadProcessor.java
@@ -14,7 +14,6 @@ import org.eclipse.osee.framework.core.enums.ModificationType;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.database.core.IOseeStatement;
import org.eclipse.osee.orcs.core.ds.ArtifactData;
-import org.eclipse.osee.orcs.core.ds.ArtifactDataHandler;
import org.eclipse.osee.orcs.core.ds.Options;
import org.eclipse.osee.orcs.core.ds.OptionsUtil;
import org.eclipse.osee.orcs.core.ds.VersionData;
@@ -23,7 +22,7 @@ import org.eclipse.osee.orcs.db.internal.loader.data.ArtifactObjectFactory;
/**
* @author Ryan D. Brooks
*/
-public class ArtifactLoadProcessor extends LoadProcessor<ArtifactData, ArtifactObjectFactory, ArtifactDataHandler> {
+public class ArtifactLoadProcessor extends LoadProcessor<ArtifactData, ArtifactObjectFactory> {
public ArtifactLoadProcessor(ArtifactObjectFactory factory) {
super(factory);
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/AttributeLoadProcessor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/AttributeLoadProcessor.java
index 7e11f23508..da087a5199 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/AttributeLoadProcessor.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/AttributeLoadProcessor.java
@@ -14,7 +14,6 @@ import org.eclipse.osee.framework.core.enums.ModificationType;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.database.core.IOseeStatement;
import org.eclipse.osee.orcs.core.ds.AttributeData;
-import org.eclipse.osee.orcs.core.ds.AttributeDataHandler;
import org.eclipse.osee.orcs.core.ds.Options;
import org.eclipse.osee.orcs.core.ds.OptionsUtil;
import org.eclipse.osee.orcs.core.ds.VersionData;
@@ -23,7 +22,7 @@ import org.eclipse.osee.orcs.db.internal.loader.data.AttributeObjectFactory;
/**
* @author Roberto E. Escobar
*/
-public class AttributeLoadProcessor extends LoadProcessor<AttributeData, AttributeObjectFactory, AttributeDataHandler> {
+public class AttributeLoadProcessor extends LoadProcessor<AttributeData, AttributeObjectFactory> {
public AttributeLoadProcessor(AttributeObjectFactory factory) {
super(factory);
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/LoadProcessor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/LoadProcessor.java
index 8555a2ea73..9678642864 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/LoadProcessor.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/LoadProcessor.java
@@ -13,14 +13,14 @@ package org.eclipse.osee.orcs.db.internal.loader.processor;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.database.core.IOseeStatement;
import org.eclipse.osee.orcs.core.ds.Options;
-import org.eclipse.osee.orcs.core.ds.OrcsData;
import org.eclipse.osee.orcs.core.ds.OrcsDataHandler;
-import org.eclipse.osee.orcs.db.internal.loader.data.VersionObjectFactory;
+import org.eclipse.osee.orcs.data.HasLocalId;
+import org.eclipse.osee.orcs.db.internal.loader.data.OrcsDataFactory;
/**
* @author Roberto E. Escobar
*/
-public abstract class LoadProcessor<D extends OrcsData, F extends VersionObjectFactory, H extends OrcsDataHandler<D>> {
+public abstract class LoadProcessor<D extends HasLocalId, F extends OrcsDataFactory> {
private final F factory;
@@ -28,7 +28,7 @@ public abstract class LoadProcessor<D extends OrcsData, F extends VersionObjectF
this.factory = factory;
}
- public final int processResultSet(H handler, IOseeStatement chStmt, Options options) throws OseeCoreException {
+ public final int processResultSet(OrcsDataHandler<D> handler, IOseeStatement chStmt, Options options) throws OseeCoreException {
int rowCount = 0;
Object conditions = createPreConditions();
while (chStmt.next()) {
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/RelationLoadProcessor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/RelationLoadProcessor.java
index 6eb47a6c6c..904ebe5026 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/RelationLoadProcessor.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/RelationLoadProcessor.java
@@ -16,14 +16,13 @@ import org.eclipse.osee.framework.database.core.IOseeStatement;
import org.eclipse.osee.orcs.core.ds.Options;
import org.eclipse.osee.orcs.core.ds.OptionsUtil;
import org.eclipse.osee.orcs.core.ds.RelationData;
-import org.eclipse.osee.orcs.core.ds.RelationDataHandler;
import org.eclipse.osee.orcs.core.ds.VersionData;
import org.eclipse.osee.orcs.db.internal.loader.data.RelationObjectFactory;
/**
* @author Ryan D. Brooks
*/
-public class RelationLoadProcessor extends LoadProcessor<RelationData, RelationObjectFactory, RelationDataHandler> {
+public class RelationLoadProcessor extends LoadProcessor<RelationData, RelationObjectFactory> {
public RelationLoadProcessor(RelationObjectFactory factory) {
super(factory);
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QueryCallableFactory.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QueryCallableFactory.java
new file mode 100644
index 0000000000..5fbb0ee814
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QueryCallableFactory.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.osee.executor.admin.CancellableCallable;
+import org.eclipse.osee.orcs.OrcsSession;
+import org.eclipse.osee.orcs.core.ds.LoadDataHandler;
+import org.eclipse.osee.orcs.core.ds.QueryData;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface QueryCallableFactory {
+
+ CancellableCallable<Integer> createCount(OrcsSession session, QueryData queryData);
+
+ CancellableCallable<Integer> createQuery(OrcsSession session, QueryData queryData, LoadDataHandler handler);
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QueryEngineImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QueryEngineImpl.java
deleted file mode 100644
index 0b009ad0a3..0000000000
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QueryEngineImpl.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.orcs.db.internal.search;
-
-import java.util.List;
-import org.eclipse.osee.framework.core.data.IOseeBranch;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.model.cache.BranchCache;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.OrcsSession;
-import org.eclipse.osee.orcs.core.ds.CriteriaSet;
-import org.eclipse.osee.orcs.core.ds.Options;
-import org.eclipse.osee.orcs.core.ds.QueryData;
-import org.eclipse.osee.orcs.core.ds.QueryEngine;
-import org.eclipse.osee.orcs.core.ds.QueryPostProcessor;
-import org.eclipse.osee.orcs.db.internal.SqlProvider;
-import org.eclipse.osee.orcs.db.internal.sql.AbstractSqlWriter;
-import org.eclipse.osee.orcs.db.internal.sql.SqlContext;
-import org.eclipse.osee.orcs.db.internal.sql.SqlHandler;
-import org.eclipse.osee.orcs.db.internal.sql.SqlHandlerFactory;
-
-/**
- * @author Roberto E. Escobar
- */
-public class QueryEngineImpl implements QueryEngine {
-
- private final Log logger;
- private final BranchCache branchCache;
- private final SqlHandlerFactory handlerFactory;
- private final SqlProvider sqlProvider;
- private final IOseeDatabaseService dbService;
-
- public QueryEngineImpl(Log logger, IOseeDatabaseService dbService, SqlProvider sqlProvider, BranchCache branchCache, SqlHandlerFactory handlerFactory) {
- super();
- this.logger = logger;
- this.dbService = dbService;
- this.sqlProvider = sqlProvider;
- this.branchCache = branchCache;
- this.handlerFactory = handlerFactory;
- }
-
- @Override
- public QuerySqlContext createCount(OrcsSession session, QueryData queryData) throws OseeCoreException {
- return createQuery(session, queryData, QueryType.COUNT_ARTIFACTS);
- }
-
- @Override
- public QuerySqlContext create(OrcsSession session, QueryData queryData) throws OseeCoreException {
- return createQuery(session, queryData, QueryType.SELECT_ARTIFACTS);
- }
-
- private QuerySqlContext createQuery(OrcsSession session, QueryData queryData, QueryType queryType) throws OseeCoreException {
- QuerySqlContext context = createContext(session, queryData.getOptions());
- CriteriaSet criteriaSet = queryData.getCriteriaSet();
-
- AbstractSqlWriter writer = createQueryWriter(context, queryType, criteriaSet.getBranch());
-
- List<SqlHandler<?>> handlers = handlerFactory.createHandlers(criteriaSet);
- writer.build(handlers);
- return context;
- }
-
- private QuerySqlContext createContext(OrcsSession session, Options options) {
- return new QuerySqlContext(session, options);
- }
-
- private AbstractSqlWriter createQueryWriter(SqlContext<QueryPostProcessor> context, QueryType queryType, IOseeBranch branch) throws OseeCoreException {
- int branchId = branchCache.getLocalId(branch);
- return new QuerySqlWriter(logger, dbService, sqlProvider, context, queryType, branchId);
- }
-
-}
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
new file mode 100644
index 0000000000..cb59fcff87
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QueryFilterFactory.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.osee.executor.admin.HasCancellation;
+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
+ */
+public interface QueryFilterFactory {
+
+ boolean isFilterRequired(QueryData queryData);
+
+ ArtifactDataCountHandler 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/QueryModule.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QueryModule.java
index 74fbe81403..228ce23e0e 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QueryModule.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QueryModule.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.search;
-import static org.eclipse.osee.orcs.db.internal.search.handlers.SqlHandlerFactoryUtil.createArtifactSqlHandlerFactory;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.osee.executor.admin.ExecutorAdmin;
@@ -19,27 +18,33 @@ import org.eclipse.osee.framework.core.services.IdentityService;
import org.eclipse.osee.framework.database.IOseeDatabaseService;
import org.eclipse.osee.framework.resource.management.IResourceManager;
import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.core.ds.DataPostProcessorFactory;
+import org.eclipse.osee.orcs.core.ds.DataLoaderFactory;
+import org.eclipse.osee.orcs.core.ds.QueryEngine;
import org.eclipse.osee.orcs.core.ds.QueryEngineIndexer;
-import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAttributeKeywords;
+import org.eclipse.osee.orcs.data.AttributeTypes;
import org.eclipse.osee.orcs.db.internal.SqlProvider;
+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.QueryEngineImpl;
+import org.eclipse.osee.orcs.db.internal.search.engines.QueryFilterFactoryImpl;
+import org.eclipse.osee.orcs.db.internal.search.handlers.SqlHandlerFactoryUtil;
+import org.eclipse.osee.orcs.db.internal.search.indexer.IndexedResourceLoader;
import org.eclipse.osee.orcs.db.internal.search.indexer.IndexerCallableFactory;
import org.eclipse.osee.orcs.db.internal.search.indexer.IndexerCallableFactoryImpl;
import org.eclipse.osee.orcs.db.internal.search.indexer.IndexerConstants;
import org.eclipse.osee.orcs.db.internal.search.indexer.IndexingTaskConsumer;
import org.eclipse.osee.orcs.db.internal.search.indexer.IndexingTaskConsumerImpl;
import org.eclipse.osee.orcs.db.internal.search.indexer.QueryEngineIndexerImpl;
-import org.eclipse.osee.orcs.db.internal.search.indexer.QueueToAttributeLoader;
-import org.eclipse.osee.orcs.db.internal.search.indexer.data.QueueToAttributeLoaderImpl;
+import org.eclipse.osee.orcs.db.internal.search.indexer.data.GammaQueueIndexerDataSourceLoader;
import org.eclipse.osee.orcs.db.internal.search.language.EnglishLanguage;
-import org.eclipse.osee.orcs.db.internal.search.tagger.DefaultAttributeTagger;
import org.eclipse.osee.orcs.db.internal.search.tagger.StreamMatcher;
import org.eclipse.osee.orcs.db.internal.search.tagger.TagEncoder;
import org.eclipse.osee.orcs.db.internal.search.tagger.TagProcessor;
import org.eclipse.osee.orcs.db.internal.search.tagger.Tagger;
import org.eclipse.osee.orcs.db.internal.search.tagger.TaggingEngine;
-import org.eclipse.osee.orcs.db.internal.search.tagger.XmlAttributeTagger;
-import org.eclipse.osee.orcs.db.internal.search.util.DataPostProcessorFactoryImpl;
+import org.eclipse.osee.orcs.db.internal.search.tagger.TextStreamTagger;
+import org.eclipse.osee.orcs.db.internal.search.tagger.XmlTagger;
+import org.eclipse.osee.orcs.db.internal.search.util.AttributeDataMatcher;
import org.eclipse.osee.orcs.db.internal.search.util.MatcherFactory;
import org.eclipse.osee.orcs.db.internal.sql.SqlHandlerFactory;
@@ -82,12 +87,19 @@ public class QueryModule {
return queryIndexer;
}
- public QueryEngineImpl createQueryEngine(BranchCache branchCache) {
- DataPostProcessorFactory<CriteriaAttributeKeywords> postProcessor =
- createAttributeKeywordPostProcessor(taggingEngine);
+ public QueryEngine createQueryEngine(DataLoaderFactory objectLoader, BranchCache branchCache, AttributeTypes attrTypes) {
+ ArtifactQueryCallableFactory factory1 = createArtifactQueryEngine(objectLoader, branchCache, attrTypes);
+ return new QueryEngineImpl(factory1);
+ }
+
+ protected ArtifactQueryCallableFactory createArtifactQueryEngine(DataLoaderFactory objectLoader, BranchCache branchCache, AttributeTypes attrTypes) {
SqlHandlerFactory handlerFactory =
- createArtifactSqlHandlerFactory(logger, idService, taggingEngine.getTagProcessor(), postProcessor);
- return new QueryEngineImpl(logger, dbService, sqlProvider, branchCache, handlerFactory);
+ SqlHandlerFactoryUtil.createArtifactSqlHandlerFactory(logger, idService, taggingEngine.getTagProcessor());
+ QuerySqlContextFactory sqlContextFactory =
+ new ArtifactQuerySqlContextFactoryImpl(logger, dbService, sqlProvider, branchCache, handlerFactory);
+ AttributeDataMatcher matcher = new AttributeDataMatcher(logger, taggingEngine, attrTypes);
+ QueryFilterFactoryImpl filterFactory = new QueryFilterFactoryImpl(logger, executorAdmin, matcher);
+ return new ArtifactQueryCallableFactory(logger, objectLoader, sqlContextFactory, filterFactory);
}
protected TaggingEngine createTaggingEngine() {
@@ -95,23 +107,19 @@ public class QueryModule {
Map<String, Tagger> taggers = new HashMap<String, Tagger>();
StreamMatcher matcher = MatcherFactory.createMatcher();
- taggers.put("DefaultAttributeTaggerProvider", new DefaultAttributeTagger(tagProcessor, matcher));
- taggers.put("XmlAttributeTaggerProvider", new XmlAttributeTagger(tagProcessor, matcher));
+ taggers.put("DefaultAttributeTaggerProvider", new TextStreamTagger(tagProcessor, matcher));
+ taggers.put("XmlAttributeTaggerProvider", new XmlTagger(tagProcessor, matcher));
return new TaggingEngine(taggers, tagProcessor);
}
protected QueryEngineIndexer createQueryEngineIndexer(TaggingEngine taggingEngine, IResourceManager resourceManager) {
- QueueToAttributeLoader resourceLoader =
- new QueueToAttributeLoaderImpl(logger, dbService, idService, resourceManager);
+ IndexedResourceLoader resourceLoader =
+ new GammaQueueIndexerDataSourceLoader(logger, dbService, idService, resourceManager);
IndexerCallableFactory callableFactory =
new IndexerCallableFactoryImpl(logger, dbService, taggingEngine, resourceLoader);
IndexingTaskConsumer indexConsumer = new IndexingTaskConsumerImpl(executorAdmin, callableFactory);
return new QueryEngineIndexerImpl(logger, dbService, idService, indexConsumer);
}
- protected DataPostProcessorFactory<CriteriaAttributeKeywords> createAttributeKeywordPostProcessor(TaggingEngine taggingEngine) {
- return new DataPostProcessorFactoryImpl(logger, taggingEngine, executorAdmin);
- }
-
}
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 5e99431722..41c0fbe9d9 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
@@ -13,13 +13,12 @@ package org.eclipse.osee.orcs.db.internal.search;
import org.eclipse.osee.orcs.OrcsSession;
import org.eclipse.osee.orcs.core.ds.Options;
import org.eclipse.osee.orcs.core.ds.QueryContext;
-import org.eclipse.osee.orcs.core.ds.QueryPostProcessor;
import org.eclipse.osee.orcs.db.internal.sql.SqlContextImpl;
/**
* @author Roberto E. Escobar
*/
-public class QuerySqlContext extends SqlContextImpl<QueryPostProcessor> implements QueryContext {
+public class QuerySqlContext extends SqlContextImpl implements QueryContext {
public QuerySqlContext(OrcsSession session, Options options) {
super(session, options);
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/HasDataPostProcessorFactory.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QuerySqlContextFactory.java
index fdca665b46..f0a4c6a714 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/HasDataPostProcessorFactory.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QuerySqlContextFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Boeing.
+ * 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
@@ -8,18 +8,18 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs.db.internal.sql;
+package org.eclipse.osee.orcs.db.internal.search;
-import org.eclipse.osee.orcs.core.ds.Criteria;
-import org.eclipse.osee.orcs.core.ds.DataPostProcessorFactory;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.orcs.OrcsSession;
+import org.eclipse.osee.orcs.core.ds.QueryData;
/**
* @author Roberto E. Escobar
*/
-public interface HasDataPostProcessorFactory<C extends Criteria> {
+public interface QuerySqlContextFactory {
- void setDataPostProcessorFactory(DataPostProcessorFactory<C> factory);
-
- DataPostProcessorFactory<C> getDataPostProcessorFactory();
+ QuerySqlContext createCountContext(OrcsSession session, QueryData queryData) throws OseeCoreException;
+ QuerySqlContext createQueryContext(OrcsSession session, QueryData queryData) throws OseeCoreException;
}
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/ArtifactQueryCallableFactory.java
new file mode 100644
index 0000000000..71d5f073b3
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQueryCallableFactory.java
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ * 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.engines;
+
+import org.eclipse.osee.executor.admin.CancellableCallable;
+import org.eclipse.osee.framework.core.enums.LoadLevel;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.logger.Log;
+import org.eclipse.osee.orcs.OrcsSession;
+import org.eclipse.osee.orcs.core.ds.DataLoader;
+import org.eclipse.osee.orcs.core.ds.DataLoaderFactory;
+import org.eclipse.osee.orcs.core.ds.LoadDataHandler;
+import org.eclipse.osee.orcs.core.ds.QueryData;
+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 {
+
+ 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) {
+ super();
+ this.logger = logger;
+ this.objectLoader = objectLoader;
+ this.queryContextFactory = queryEngine;
+ this.factory = factory;
+ }
+
+ @Override
+ public CancellableCallable<Integer> createCount(OrcsSession session, QueryData queryData) {
+ return new AbstractSearchCallable(session, queryData) {
+
+ @Override
+ protected Integer innerCall() throws Exception {
+ int count = -1;
+ if (isPostProcessRequired()) {
+ count = loadAndGetArtifactCount(null, true);
+ } else {
+ count = getCount();
+ }
+ checkForCancelled();
+ return count;
+ }
+
+ protected int getCount() throws OseeCoreException {
+ QuerySqlContext queryContext = queryContextFactory.createCountContext(getSession(), getQueryData());
+ checkForCancelled();
+ return objectLoader.getCount(this, queryContext);
+ }
+
+ };
+ }
+
+ @Override
+ public CancellableCallable<Integer> createQuery(OrcsSession session, final QueryData queryData, final LoadDataHandler handler) {
+ return new AbstractSearchCallable(session, queryData) {
+
+ @Override
+ protected Integer innerCall() throws Exception {
+ boolean enableFilter = isPostProcessRequired();
+ return loadAndGetArtifactCount(handler, enableFilter);
+ }
+ };
+ }
+
+ private abstract class AbstractSearchCallable extends CancellableCallable<Integer> {
+
+ private final OrcsSession session;
+ private final QueryData queryData;
+
+ public AbstractSearchCallable(OrcsSession session, QueryData queryData) {
+ super();
+ this.session = session;
+ this.queryData = queryData;
+ }
+
+ protected OrcsSession getSession() {
+ return session;
+ }
+
+ protected QueryData getQueryData() {
+ return queryData;
+ }
+
+ @Override
+ public final Integer call() throws Exception {
+ long startTime = System.currentTimeMillis();
+ long endTime = startTime;
+ Integer result = null;
+ try {
+ if (logger.isTraceEnabled()) {
+ logger.trace("%s [start] - [%s]", getClass().getSimpleName(), queryData);
+ }
+ result = innerCall();
+ } finally {
+ endTime = System.currentTimeMillis() - startTime;
+ }
+ if (logger.isTraceEnabled()) {
+ logger.trace("%s [%s] - completed [%s]", getClass().getSimpleName(), Lib.asTimeString(endTime), queryData);
+ }
+ return result;
+ }
+
+ protected abstract Integer innerCall() throws Exception;
+
+ private boolean isLoadLevelTooLow(LoadLevel level) {
+ return LoadLevel.SHALLOW == level;
+ }
+
+ protected boolean isPostProcessRequired() {
+ return factory.isFilterRequired(queryData);
+ }
+
+ protected int loadAndGetArtifactCount(LoadDataHandler handler, boolean enableFilter) throws Exception {
+ QuerySqlContext queryContext = queryContextFactory.createQueryContext(getSession(), getQueryData());
+ checkForCancelled();
+
+ DataLoader loader = objectLoader.fromQueryContext(queryContext);
+ loader.setOptions(getQueryData().getOptions());
+
+ if (enableFilter) {
+ // Ensure we will receive attribute data for post-process
+ LoadLevel level = loader.getLoadLevel();
+ if (isLoadLevelTooLow(level)) {
+ loader.setLoadLevel(LoadLevel.ATTRIBUTE);
+ }
+ }
+ ArtifactDataCountHandler countingHandler = factory.createHandler(this, queryData, queryContext, handler);
+ loader.load(this, countingHandler);
+ return countingHandler.getArtifactCount();
+ }
+ }
+
+}
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
new file mode 100644
index 0000000000..d0c04add72
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContext.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.db.internal.search.engines;
+
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.orcs.OrcsSession;
+import org.eclipse.osee.orcs.core.ds.Options;
+import org.eclipse.osee.orcs.data.HasBranch;
+import org.eclipse.osee.orcs.db.internal.search.QuerySqlContext;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class ArtifactQuerySqlContext extends QuerySqlContext implements HasBranch {
+
+ private final IOseeBranch branch;
+
+ public ArtifactQuerySqlContext(OrcsSession session, IOseeBranch branch, Options options) {
+ super(session, options);
+ this.branch = branch;
+ }
+
+ @Override
+ public IOseeBranch getBranch() {
+ return branch;
+ }
+
+ @Override
+ public String toString() {
+ return "ArtifactQuerySqlContext [branch=" + branch + "(" + super.toString() + ")]";
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContextFactoryImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContextFactoryImpl.java
new file mode 100644
index 0000000000..6bca8d9501
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContextFactoryImpl.java
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * 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.engines;
+
+import java.util.List;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.cache.BranchCache;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
+import org.eclipse.osee.logger.Log;
+import org.eclipse.osee.orcs.OrcsSession;
+import org.eclipse.osee.orcs.core.ds.Criteria;
+import org.eclipse.osee.orcs.core.ds.CriteriaSet;
+import org.eclipse.osee.orcs.core.ds.QueryData;
+import org.eclipse.osee.orcs.data.HasBranch;
+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.sql.AbstractSqlWriter;
+import org.eclipse.osee.orcs.db.internal.sql.QueryType;
+import org.eclipse.osee.orcs.db.internal.sql.SqlContext;
+import org.eclipse.osee.orcs.db.internal.sql.SqlHandler;
+import org.eclipse.osee.orcs.db.internal.sql.SqlHandlerFactory;
+import com.google.common.base.Optional;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class ArtifactQuerySqlContextFactoryImpl implements QuerySqlContextFactory {
+
+ private final Log logger;
+ private final BranchCache branchCache;
+ private final SqlHandlerFactory handlerFactory;
+ private final SqlProvider sqlProvider;
+ private final IOseeDatabaseService dbService;
+
+ public ArtifactQuerySqlContextFactoryImpl(Log logger, IOseeDatabaseService dbService, SqlProvider sqlProvider, BranchCache branchCache, SqlHandlerFactory handlerFactory) {
+ super();
+ this.logger = logger;
+ this.dbService = dbService;
+ this.sqlProvider = sqlProvider;
+ this.branchCache = branchCache;
+ this.handlerFactory = handlerFactory;
+ }
+
+ @Override
+ public QuerySqlContext createCountContext(OrcsSession session, QueryData queryData) throws OseeCoreException {
+ return createQueryContext(session, queryData, QueryType.COUNT);
+ }
+
+ @Override
+ public QuerySqlContext createQueryContext(OrcsSession session, QueryData queryData) throws OseeCoreException {
+ return createQueryContext(session, queryData, QueryType.SELECT);
+ }
+
+ private QuerySqlContext createQueryContext(OrcsSession session, QueryData queryData, QueryType queryType) throws OseeCoreException {
+ QuerySqlContext context = createContext(session, queryData);
+ CriteriaSet criteriaSet = queryData.getCriteriaSet();
+
+ AbstractSqlWriter writer = createQueryWriter(context, queryData, queryType);
+ List<SqlHandler<?>> handlers = handlerFactory.createHandlers(criteriaSet);
+ writer.build(handlers);
+ return context;
+ }
+
+ private QuerySqlContext createContext(OrcsSession session, QueryData queryData) throws OseeCoreException {
+ IOseeBranch branch = getBranchToSearch(queryData);
+ return new ArtifactQuerySqlContext(session, branch, queryData.getOptions());
+ }
+
+ private AbstractSqlWriter createQueryWriter(SqlContext context, QueryData queryData, QueryType queryType) throws OseeCoreException {
+ int branchId = -1;
+ IOseeBranch branch = getBranchToSearch(queryData);
+ if (branch != null) {
+ branchId = branchCache.getLocalId(branch);
+ }
+ return new ArtifactQuerySqlWriter(logger, dbService, sqlProvider, context, queryType, branchId);
+ }
+
+ private IOseeBranch getBranchToSearch(QueryData queryData) throws OseeCoreException {
+ IOseeBranch branch = null;
+
+ Iterable<? extends Criteria> criterias = queryData.getCriteriaSet();
+ Optional<? extends Criteria> item = Iterables.tryFind(criterias, new Predicate<Criteria>() {
+
+ @Override
+ public boolean apply(Criteria criteria) {
+ return HasBranch.class.isAssignableFrom(criteria.getClass());
+ }
+
+ });
+ if (item.isPresent()) {
+ HasBranch criteria = (HasBranch) item.get();
+ branch = criteria.getBranch();
+ }
+ return branch;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QuerySqlWriter.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlWriter.java
index e91ef47616..ecc1aa2246 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QuerySqlWriter.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlWriter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
+ * 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
@@ -8,27 +8,30 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs.db.internal.search;
+package org.eclipse.osee.orcs.db.internal.search.engines;
import java.util.List;
import org.eclipse.osee.framework.core.enums.TxChange;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.database.IOseeDatabaseService;
import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.core.ds.DataPostProcessor;
import org.eclipse.osee.orcs.core.ds.OptionsUtil;
import org.eclipse.osee.orcs.db.internal.SqlProvider;
import org.eclipse.osee.orcs.db.internal.sql.AbstractSqlWriter;
+import org.eclipse.osee.orcs.db.internal.sql.QueryType;
import org.eclipse.osee.orcs.db.internal.sql.SqlContext;
import org.eclipse.osee.orcs.db.internal.sql.SqlHandler;
import org.eclipse.osee.orcs.db.internal.sql.TableEnum;
-public class QuerySqlWriter extends AbstractSqlWriter {
+/**
+ * @author Roberto E. Escobar
+ */
+public class ArtifactQuerySqlWriter extends AbstractSqlWriter {
private final int branchId;
private final QueryType queryType;
- public QuerySqlWriter(Log logger, IOseeDatabaseService dbService, SqlProvider sqlProvider, SqlContext<? extends DataPostProcessor<?>> context, QueryType queryType, int branchId) {
+ public ArtifactQuerySqlWriter(Log logger, IOseeDatabaseService dbService, SqlProvider sqlProvider, SqlContext context, QueryType queryType, int branchId) {
super(logger, dbService, sqlProvider, context);
this.queryType = queryType;
this.branchId = branchId;
@@ -48,7 +51,7 @@ public class QuerySqlWriter extends AbstractSqlWriter {
@Override
public void writeSelect(List<SqlHandler<?>> handlers) throws OseeCoreException {
- if (queryType == QueryType.COUNT_ARTIFACTS) {
+ if (queryType == QueryType.COUNT) {
if (OptionsUtil.isHistorical(getOptions())) {
write("SELECT count(xTable.art_id) FROM (\n ");
writeSelectHelper();
@@ -69,7 +72,7 @@ public class QuerySqlWriter extends AbstractSqlWriter {
write("\n GROUP BY %s.art_id, %s.branch_id", artAlias, txAlias);
}
- if (queryType != QueryType.COUNT_ARTIFACTS) {
+ if (queryType != QueryType.COUNT) {
String txAlias = getAliasManager().getFirstAlias(TableEnum.TXS_TABLE);
String artAlias = getAliasManager().getFirstAlias(TableEnum.ARTIFACT_TABLE);
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
new file mode 100644
index 0000000000..5f3bfa5401
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/QueryEngineImpl.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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.engines;
+
+import org.eclipse.osee.executor.admin.CancellableCallable;
+import org.eclipse.osee.orcs.OrcsSession;
+import org.eclipse.osee.orcs.core.ds.LoadDataHandler;
+import org.eclipse.osee.orcs.core.ds.QueryData;
+import org.eclipse.osee.orcs.core.ds.QueryEngine;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class QueryEngineImpl implements QueryEngine {
+
+ private final ArtifactQueryCallableFactory factory1;
+
+ public QueryEngineImpl(ArtifactQueryCallableFactory factory1) {
+ super();
+ this.factory1 = factory1;
+ }
+
+ @Override
+ public CancellableCallable<Integer> createArtifactCount(OrcsSession session, QueryData queryData) {
+ return factory1.createCount(session, queryData);
+ }
+
+ @Override
+ public CancellableCallable<Integer> createArtifactQuery(OrcsSession session, QueryData queryData, LoadDataHandler handler) {
+ return factory1.createQuery(session, queryData, handler);
+ }
+
+}
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
new file mode 100644
index 0000000000..2eeda14134
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/QueryFilterFactoryImpl.java
@@ -0,0 +1,247 @@
+/*******************************************************************************
+ * 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.engines;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.concurrent.Future;
+import org.eclipse.osee.executor.admin.CancellableCallable;
+import org.eclipse.osee.executor.admin.ExecutorAdmin;
+import org.eclipse.osee.executor.admin.HasCancellation;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.enums.QueryOption;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeExceptions;
+import org.eclipse.osee.framework.database.core.AbstractJoinQuery;
+import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
+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.CriteriaSet;
+import org.eclipse.osee.orcs.core.ds.LoadDataHandler;
+import org.eclipse.osee.orcs.core.ds.OrcsDataHandler;
+import org.eclipse.osee.orcs.core.ds.QueryData;
+import org.eclipse.osee.orcs.core.ds.RelationData;
+import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAttributeKeywords;
+import org.eclipse.osee.orcs.db.internal.loader.LoadUtil;
+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;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class QueryFilterFactoryImpl implements QueryFilterFactory {
+
+ private final Log logger;
+ private final ExecutorAdmin executorAdmin;
+ private final AttributeDataMatcher matcher;
+
+ public QueryFilterFactoryImpl(Log logger, ExecutorAdmin executorAdmin, AttributeDataMatcher matcher) {
+ super();
+ this.logger = logger;
+ this.executorAdmin = executorAdmin;
+ this.matcher = matcher;
+ }
+
+ @Override
+ public boolean isFilterRequired(QueryData queryData) {
+ return queryData.hasCriteriaType(CriteriaAttributeKeywords.class);
+ }
+
+ @Override
+ public ArtifactDataCountHandler createHandler(HasCancellation cancellation, QueryData queryData, QuerySqlContext queryContext, LoadDataHandler handler) throws Exception {
+ CriteriaSet criteriaSet = queryData.getCriteriaSet();
+ Set<CriteriaAttributeKeywords> criterias = criteriaSet.getCriteriaByType(CriteriaAttributeKeywords.class);
+ ArtifactDataCountHandler countingHandler;
+ if (criterias.isEmpty()) {
+ countingHandler = new ArtifactDataCountHandler(handler);
+ } else {
+ countingHandler = createFilteringHandler(cancellation, criterias, queryContext, handler);
+ }
+ 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);
+ ConsumerFactory factory = new ConsumerFactoryImpl(criterias);
+ return new AttributeDataProducer(logger, cancellation, buffer, handler, factory);
+ }
+
+ private int computeFetchSize(SqlContext sqlContext) {
+ int fetchSize = RelationalConstants.MIN_FETCH_SIZE;
+ for (AbstractJoinQuery join : sqlContext.getJoins()) {
+ fetchSize = Math.max(fetchSize, join.size());
+ }
+ return LoadUtil.computeFetchSize(fetchSize);
+ }
+
+ private interface ConsumerFactory {
+ List<Future<?>> createConsumer(final AttributeData data, final LoadDataHandler handler) throws Exception;
+ }
+
+ private class ConsumerFactoryImpl implements ConsumerFactory {
+ private final Set<CriteriaAttributeKeywords> criterias;
+
+ public ConsumerFactoryImpl(Set<CriteriaAttributeKeywords> criterias) {
+ super();
+ this.criterias = criterias;
+ }
+
+ @Override
+ public List<Future<?>> createConsumer(final AttributeData data, final LoadDataHandler handler) throws Exception {
+ List<Future<?>> futures = new LinkedList<Future<?>>();
+ for (CriteriaAttributeKeywords criteria : criterias) {
+ final Collection<String> valuesToMatch = criteria.getValues();
+ final Collection<? extends IAttributeType> typesFilter = criteria.getTypes();
+ final QueryOption[] options = criteria.getOptions();
+
+ Callable<?> consumer = new CancellableCallable<Void>() {
+ @Override
+ public Void call() throws Exception {
+ checkForCancelled();
+ matcher.process(this, handler, data, valuesToMatch, typesFilter, options);
+ return null;
+ }
+ };
+ Future<?> future = executorAdmin.schedule(consumer);
+ futures.add(future);
+ }
+ return futures;
+ }
+ }
+
+ private static final class AttributeDataProducer extends BufferedLoadDataHandler {
+
+ private final Log logger;
+ private final HasCancellation cancellation;
+ private final ConsumerFactory consumerFactory;
+
+ private List<Future<?>> futures;
+ private final Set<Integer> acceptedArtIds = new CopyOnWriteArraySet<Integer>();
+
+ public AttributeDataProducer(Log logger, HasCancellation cancellation, LoadDataBuffer buffer, LoadDataHandler handler, ConsumerFactory consumerFactory) {
+ super(handler, buffer);
+ this.logger = logger;
+ this.cancellation = cancellation;
+ this.consumerFactory = consumerFactory;
+ }
+
+ private void reset() {
+ acceptedArtIds.clear();
+ getBuffer().clear();
+ futures = null;
+ }
+
+ @Override
+ public void onLoadStart() throws OseeCoreException {
+ reset();
+ super.onLoadStart();
+ }
+
+ @Override
+ public void onData(AttributeData data) throws OseeCoreException {
+ super.onData(data);
+ if (futures == null) {
+ futures = new LinkedList<Future<?>>();
+ }
+ try {
+ futures.addAll(consumerFactory.createConsumer(data, this));
+ } catch (Exception ex) {
+ OseeExceptions.wrapAndThrow(ex);
+ } finally {
+ if (futures != null && cancellation.isCancelled()) {
+ for (Future<?> future : futures) {
+ future.cancel(true);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onData(AttributeData data, MatchLocation match) throws OseeCoreException {
+ acceptedArtIds.add(data.getArtifactId());
+ forwardArtifacts(data.getArtifactId());
+ super.onData(data, match);
+ }
+
+ private void forwardArtifacts(int artifactId) throws OseeCoreException {
+ LoadDataBuffer buffer = getBuffer();
+ LoadDataHandler handler = getHandler();
+ if (handler != null) {
+ ArtifactData art = buffer.removeArtifactByArtId(artifactId);
+ Iterable<AttributeData> attrs = buffer.removeAttributesByArtId(artifactId);
+ Iterable<RelationData> rels = buffer.removeRelationsByArtId(artifactId);
+ if (art != null) {
+ handler.getArtifactDataHandler().onData(art);
+ }
+ if (attrs != null) {
+ OrcsDataHandler<AttributeData> attributeDataHandler = handler.getAttributeDataHandler();
+ for (AttributeData attr : attrs) {
+ attributeDataHandler.onData(attr);
+ }
+ }
+ if (rels != null) {
+ OrcsDataHandler<RelationData> relationDataHandler = handler.getRelationDataHandler();
+ for (RelationData rel : rels) {
+ relationDataHandler.onData(rel);
+ }
+ }
+ }
+ }
+
+ private void forwardArtifacts() throws OseeCoreException {
+ // Ensure all data required by the artifact is forwarded to the handler
+ // This needs to be done in order to avoid missing relation data
+ // coming in after the artifact data has been forwarded.
+ for (int artifactId : acceptedArtIds) {
+ forwardArtifacts(artifactId);
+ }
+ }
+
+ @Override
+ public void onLoadEnd() {
+ try {
+ waitForResults();
+ forwardArtifacts();
+ } catch (Exception ex) {
+ logger.error(ex, "Error waiting for query post process results");
+ } finally {
+ getCounter().getAndSet(acceptedArtIds.size());
+ reset();
+ super.onLoadEnd();
+ }
+ }
+
+ private void waitForResults() throws Exception {
+ if (futures != null) {
+ for (Future<?> future : futures) {
+ if (cancellation.isCancelled()) {
+ future.cancel(true);
+ } else {
+ // Wait for execution
+ future.get();
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/AttributeTokenSqlHandler.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/AttributeTokenSqlHandler.java
index 8ff9b1f970..e79191c72d 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/AttributeTokenSqlHandler.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/AttributeTokenSqlHandler.java
@@ -19,14 +19,11 @@ import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.database.core.AbstractJoinQuery;
import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.orcs.core.ds.DataPostProcessor;
-import org.eclipse.osee.orcs.core.ds.DataPostProcessorFactory;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAttributeKeywords;
import org.eclipse.osee.orcs.db.internal.search.tagger.HasTagProcessor;
import org.eclipse.osee.orcs.db.internal.search.tagger.TagCollector;
import org.eclipse.osee.orcs.db.internal.search.tagger.TagProcessor;
import org.eclipse.osee.orcs.db.internal.sql.AbstractSqlWriter;
-import org.eclipse.osee.orcs.db.internal.sql.HasDataPostProcessorFactory;
import org.eclipse.osee.orcs.db.internal.sql.SqlHandler;
import org.eclipse.osee.orcs.db.internal.sql.TableEnum;
import org.eclipse.osee.orcs.db.internal.sql.WithClause;
@@ -35,7 +32,7 @@ import org.eclipse.osee.orcs.db.internal.sql.WithClause.WithAlias;
/**
* @author Roberto E. Escobar
*/
-public class AttributeTokenSqlHandler extends SqlHandler<CriteriaAttributeKeywords> implements HasTagProcessor, HasDataPostProcessorFactory<CriteriaAttributeKeywords> {
+public class AttributeTokenSqlHandler extends SqlHandler<CriteriaAttributeKeywords> implements HasTagProcessor {
private CriteriaAttributeKeywords criteria;
@@ -43,20 +40,9 @@ public class AttributeTokenSqlHandler extends SqlHandler<CriteriaAttributeKeywor
private String attrAlias;
private String txsAlias;
- private DataPostProcessorFactory<CriteriaAttributeKeywords> factory;
private TagProcessor tagProcessor;
@Override
- public void setDataPostProcessorFactory(DataPostProcessorFactory<CriteriaAttributeKeywords> factory) {
- this.factory = factory;
- }
-
- @Override
- public DataPostProcessorFactory<CriteriaAttributeKeywords> getDataPostProcessorFactory() {
- return factory;
- }
-
- @Override
public void setTagProcessor(TagProcessor tagProcessor) {
this.tagProcessor = tagProcessor;
}
@@ -158,9 +144,6 @@ public class AttributeTokenSqlHandler extends SqlHandler<CriteriaAttributeKeywor
@Override
public boolean addPredicates(AbstractSqlWriter writer) throws OseeCoreException {
- DataPostProcessor<?> processor = getDataPostProcessorFactory().createPostProcessor(criteria, writer.getOptions());
- writer.addPostProcessor(processor);
-
if (!Strings.isValid(artAlias)) {
artAlias = writer.getAliases(TableEnum.ARTIFACT_TABLE).iterator().next();
}
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 10b443aaaf..71be1e9cf9 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
@@ -15,7 +15,6 @@ import java.util.Map;
import org.eclipse.osee.framework.core.services.IdentityService;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.core.ds.Criteria;
-import org.eclipse.osee.orcs.core.ds.DataPostProcessorFactory;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAllArtifacts;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaArtifactGuids;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaArtifactHrids;
@@ -40,13 +39,10 @@ public final class SqlHandlerFactoryUtil {
// Static Utility
}
- public static SqlHandlerFactory createArtifactSqlHandlerFactory(Log logger, IdentityService identityService, TagProcessor tagProcessor, DataPostProcessorFactory<CriteriaAttributeKeywords> postProcessorFactory) {
+ public static SqlHandlerFactory createArtifactSqlHandlerFactory(Log logger, IdentityService identityService, TagProcessor tagProcessor) {
Map<Class<? extends Criteria>, Class<? extends SqlHandler<?>>> handleMap =
new HashMap<Class<? extends Criteria>, Class<? extends SqlHandler<?>>>();
- Map<Class<? extends SqlHandler<?>>, DataPostProcessorFactory<?>> factoryMap =
- new HashMap<Class<? extends SqlHandler<?>>, DataPostProcessorFactory<?>>();
-
handleMap.put(CriteriaArtifactGuids.class, ArtifactGuidSqlHandler.class);
handleMap.put(CriteriaArtifactHrids.class, ArtifactHridsSqlHandler.class);
handleMap.put(CriteriaArtifactIds.class, ArtifactIdsSqlHandler.class);
@@ -58,8 +54,6 @@ public final class SqlHandlerFactoryUtil {
handleMap.put(CriteriaAttributeKeywords.class, AttributeTokenSqlHandler.class);
handleMap.put(CriteriaAllArtifacts.class, AllArtifactsSqlHandler.class);
- factoryMap.put(AttributeTokenSqlHandler.class, postProcessorFactory);
-
- return new SqlHandlerFactoryImpl(logger, identityService, tagProcessor, handleMap, factoryMap);
+ return new SqlHandlerFactoryImpl(logger, identityService, tagProcessor, handleMap);
}
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/QueueToAttributeLoader.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/IndexedResourceLoader.java
index 09e42fcb1c..494db9740f 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/QueueToAttributeLoader.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/IndexedResourceLoader.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
+ * 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
@@ -10,16 +10,15 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.search.indexer;
-import java.util.Collection;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.database.core.OseeConnection;
-import org.eclipse.osee.orcs.data.AttributeReadable;
+import org.eclipse.osee.orcs.core.ds.IndexedResource;
+import org.eclipse.osee.orcs.core.ds.OrcsDataHandler;
/**
* @author Roberto E. Escobar
*/
-public interface QueueToAttributeLoader {
+public interface IndexedResourceLoader {
- void loadAttributes(OseeConnection connection, int tagQueueQueryId, Collection<AttributeReadable<?>> attributeDatas) throws OseeCoreException;
+ void loadSource(OrcsDataHandler<IndexedResource> handler, int tagQueueQueryId) throws OseeCoreException;
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/IndexerCallableFactoryImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/IndexerCallableFactoryImpl.java
index 15a3304b46..6fb65f17b5 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/IndexerCallableFactoryImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/IndexerCallableFactoryImpl.java
@@ -27,9 +27,9 @@ public class IndexerCallableFactoryImpl implements IndexerCallableFactory {
private final Log logger;
private final IOseeDatabaseService dbService;
private final TaggingEngine taggingEngine;
- private final QueueToAttributeLoader loader;
+ private final IndexedResourceLoader loader;
- public IndexerCallableFactoryImpl(Log logger, IOseeDatabaseService dbService, TaggingEngine taggingEngine, QueueToAttributeLoader loader) {
+ public IndexerCallableFactoryImpl(Log logger, IOseeDatabaseService dbService, TaggingEngine taggingEngine, IndexedResourceLoader loader) {
super();
this.logger = logger;
this.dbService = dbService;
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/callable/consumer/IndexingTaskDatabaseTxCallable.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/callable/consumer/IndexingTaskDatabaseTxCallable.java
index d867260ea6..1df47d1e34 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/callable/consumer/IndexingTaskDatabaseTxCallable.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/callable/consumer/IndexingTaskDatabaseTxCallable.java
@@ -14,20 +14,23 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.database.IOseeDatabaseService;
import org.eclipse.osee.framework.database.core.DatabaseJoinAccessor.JoinItem;
import org.eclipse.osee.framework.database.core.OseeConnection;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.OrcsSession;
-import org.eclipse.osee.orcs.data.AttributeReadable;
+import org.eclipse.osee.orcs.core.ds.IndexedResource;
+import org.eclipse.osee.orcs.core.ds.OrcsDataHandler;
import org.eclipse.osee.orcs.data.AttributeTypes;
import org.eclipse.osee.orcs.db.internal.callable.AbstractDatastoreTxCallable;
-import org.eclipse.osee.orcs.db.internal.search.indexer.QueueToAttributeLoader;
+import org.eclipse.osee.orcs.db.internal.search.indexer.IndexedResourceLoader;
import org.eclipse.osee.orcs.db.internal.search.tagger.TagCollector;
import org.eclipse.osee.orcs.db.internal.search.tagger.Tagger;
import org.eclipse.osee.orcs.db.internal.search.tagger.TaggingEngine;
@@ -43,7 +46,7 @@ public final class IndexingTaskDatabaseTxCallable extends AbstractDatastoreTxCal
private static final String DELETE_SEARCH_TAGS = "delete from osee_search_tags where gamma_id = ?";
- private final QueueToAttributeLoader loader;
+ private final IndexedResourceLoader loader;
private final TaggingEngine taggingEngine;
private final IndexerCollector collector;
private final int tagQueueQueryId;
@@ -55,7 +58,7 @@ public final class IndexingTaskDatabaseTxCallable extends AbstractDatastoreTxCal
private long startTime;
private long waitTime;
- public IndexingTaskDatabaseTxCallable(Log logger, OrcsSession session, IOseeDatabaseService dbService, QueueToAttributeLoader loader, TaggingEngine taggingEngine, IndexerCollector collector, int tagQueueQueryId, boolean isCacheAll, int cacheLimit, AttributeTypes attributeTypes) {
+ public IndexingTaskDatabaseTxCallable(Log logger, OrcsSession session, IOseeDatabaseService dbService, IndexedResourceLoader loader, TaggingEngine taggingEngine, IndexerCollector collector, int tagQueueQueryId, boolean isCacheAll, int cacheLimit, AttributeTypes attributeTypes) {
super(logger, session, dbService, "Attribute to Tag Database Transaction");
waitStartTime = System.currentTimeMillis();
@@ -72,18 +75,29 @@ public final class IndexingTaskDatabaseTxCallable extends AbstractDatastoreTxCal
return tagQueueQueryId;
}
+ private OrcsDataHandler<IndexedResource> createCollector(final Collection<IndexedResource> sources) {
+ return new OrcsDataHandler<IndexedResource>() {
+
+ @Override
+ public void onData(IndexedResource data) {
+ sources.add(data);
+ }
+ };
+ }
+
@Override
protected Long handleTxWork(OseeConnection connection) throws OseeCoreException {
getLogger().debug("Tagging: [%s]", getTagQueueQueryId());
long totalTags = -1;
try {
- Collection<AttributeReadable<?>> attributes = new HashSet<AttributeReadable<?>>();
- loader.loadAttributes(connection, getTagQueueQueryId(), attributes);
+ Collection<IndexedResource> sources = new LinkedHashSet<IndexedResource>();
+ OrcsDataHandler<IndexedResource> handler = createCollector(sources);
+ loader.loadSource(handler, getTagQueueQueryId());
- if (!attributes.isEmpty()) {
+ if (!sources.isEmpty()) {
try {
- deleteTags(connection, attributes);
- totalTags = createTags(connection, attributes);
+ deleteTags(connection, sources);
+ totalTags = createTags(connection, sources);
removeIndexingTaskFromQueue(connection);
} catch (Exception ex) {
throw new OseeCoreException(ex, "Unable to store tags - tagQueueQueryId [%d]", getTagQueueQueryId());
@@ -97,23 +111,29 @@ public final class IndexingTaskDatabaseTxCallable extends AbstractDatastoreTxCal
return totalTags;
}
- private long createTags(OseeConnection connection, Collection<AttributeReadable<?>> attributes) throws OseeCoreException {
+ private String getTaggerIdByTypeUuid(long typeUuid) throws OseeCoreException {
+ IAttributeType type = attributeTypes.getByUuid(typeUuid);
+ return attributeTypes.getTaggerId(type);
+ }
+
+ private long createTags(OseeConnection connection, Collection<IndexedResource> sources) throws OseeCoreException {
SearchTagCollector tagCollector = new SearchTagCollector();
Set<Long> processed = new HashSet<Long>();
Map<Long, Collection<Long>> toStore = new HashMap<Long, Collection<Long>>();
- for (AttributeReadable<?> attributeData : attributes) {
+ for (IndexedResource source : sources) {
long startItemTime = System.currentTimeMillis();
- Long gamma = attributeData.getGammaId();
+ Long gamma = source.getGammaId();
if (processed.add(gamma)) {
Set<Long> tags = new HashSet<Long>();
toStore.put(gamma, tags);
tagCollector.setCurrentTag(gamma, tags);
try {
- String taggerId = attributeTypes.getTaggerId(attributeData.getAttributeType());
+ long typeUuid = source.getTypeUuid();
+ String taggerId = getTaggerIdByTypeUuid(typeUuid);
Tagger tagger = taggingEngine.getTagger(taggerId);
- tagger.tagIt(attributeData, tagCollector);
+ tagger.tagIt(source, tagCollector);
if (isStorageAllowed(toStore)) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Stored a - [%s] - connectionId[%s] - [%s]", getTagQueueQueryId(), connection,
@@ -179,12 +199,12 @@ public final class IndexingTaskDatabaseTxCallable extends AbstractDatastoreTxCal
return needsStorage;
}
- public int deleteTags(OseeConnection connection, Collection<AttributeReadable<?>> attributes) throws OseeCoreException {
+ public int deleteTags(OseeConnection connection, Collection<IndexedResource> sources) throws OseeCoreException {
int numberDeleted = 0;
- if (!attributes.isEmpty()) {
+ if (!sources.isEmpty()) {
List<Object[]> datas = new ArrayList<Object[]>();
- for (AttributeReadable<?> attribute : attributes) {
- datas.add(new Object[] {attribute.getGammaId()});
+ for (IndexedResource source : sources) {
+ datas.add(new Object[] {source.getGammaId()});
}
numberDeleted = getDatabaseService().runBatchUpdate(connection, DELETE_SEARCH_TAGS, datas);
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/data/QueueToAttributeLoaderImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/data/GammaQueueIndexerDataSourceLoader.java
index 7ed980eaff..c132e89171 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/data/QueueToAttributeLoaderImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/data/GammaQueueIndexerDataSourceLoader.java
@@ -10,24 +10,21 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.search.indexer.data;
-import java.util.Collection;
-import org.eclipse.osee.framework.core.data.IAttributeType;
-import org.eclipse.osee.framework.core.data.TokenFactory;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.services.IdentityService;
import org.eclipse.osee.framework.database.IOseeDatabaseService;
import org.eclipse.osee.framework.database.core.IOseeStatement;
-import org.eclipse.osee.framework.database.core.OseeConnection;
import org.eclipse.osee.framework.resource.management.IResourceManager;
import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.data.AttributeReadable;
+import org.eclipse.osee.orcs.core.ds.IndexedResource;
+import org.eclipse.osee.orcs.core.ds.OrcsDataHandler;
+import org.eclipse.osee.orcs.db.internal.search.indexer.IndexedResourceLoader;
import org.eclipse.osee.orcs.db.internal.search.indexer.IndexerConstants;
-import org.eclipse.osee.orcs.db.internal.search.indexer.QueueToAttributeLoader;
/**
* @author Roberto E. Escobar
*/
-public class QueueToAttributeLoaderImpl implements QueueToAttributeLoader {
+public class GammaQueueIndexerDataSourceLoader implements IndexedResourceLoader {
private static final String LOAD_ATTRIBUTE =
"SELECT attr1.gamma_id, attr1.VALUE, attr1.uri, attr1.attr_type_id, attr1.attr_id FROM osee_attribute attr1, osee_tag_gamma_queue tgq1 WHERE attr1.gamma_id = tgq1.gamma_id AND tgq1.query_id = ?";
@@ -36,7 +33,7 @@ public class QueueToAttributeLoaderImpl implements QueueToAttributeLoader {
private final IdentityService idService;
private final IResourceManager resourceManager;
- public QueueToAttributeLoaderImpl(Log logger, IOseeDatabaseService dbService, IdentityService idService, IResourceManager resourceManager) {
+ public GammaQueueIndexerDataSourceLoader(Log logger, IOseeDatabaseService dbService, IdentityService idService, IResourceManager resourceManager) {
super();
this.logger = logger;
this.dbService = dbService;
@@ -44,52 +41,48 @@ public class QueueToAttributeLoaderImpl implements QueueToAttributeLoader {
this.resourceManager = resourceManager;
}
- private IOseeDatabaseService getDatabaseService() {
- return dbService;
- }
-
- private IdentityService getIdentityService() {
- return idService;
- }
-
- private IResourceManager getResourceManager() {
- return resourceManager;
- }
-
- private void loadAttributeData(Collection<AttributeReadable<?>> attributeDatas, OseeConnection connection, int tagQueueQueryId) throws OseeCoreException {
- IOseeStatement chStmt = getDatabaseService().getStatement(connection);
+ private boolean loadData(OrcsDataHandler<IndexedResource> handler, int tagQueueQueryId) throws OseeCoreException {
+ boolean loaded = false;
+ IOseeStatement chStmt = dbService.getStatement();
try {
chStmt.runPreparedQuery(LOAD_ATTRIBUTE, tagQueueQueryId);
- IdentityService idService = getIdentityService();
while (chStmt.next()) {
- int localId = chStmt.getInt("attr_type_id");
+ loaded = true;
- Long uuid = idService.getUniversalId(localId);
- IAttributeType attributeType = TokenFactory.createAttributeType(uuid, "N/A");
+ int itemId = chStmt.getInt("attr_id");
+ long typeUuid = idService.getUniversalId(chStmt.getInt("attr_type_id"));
+ long gammaId = chStmt.getLong("gamma_id");
+ String uri = chStmt.getString("uri");
+ String value = chStmt.getString("value");
- attributeDatas.add(new AttributeForIndexingImpl(getResourceManager(), chStmt.getInt("attr_id"),
- chStmt.getLong("gamma_id"), attributeType, chStmt.getString("value"), chStmt.getString("uri")));
+ IndexedResource data = createData(itemId, typeUuid, gammaId, value, uri);
+ handler.onData(data);
}
} finally {
chStmt.close();
}
+ return loaded;
}
@Override
- public void loadAttributes(OseeConnection connection, int tagQueueQueryId, Collection<AttributeReadable<?>> attributeDatas) throws OseeCoreException {
- loadAttributeData(attributeDatas, connection, tagQueueQueryId);
-
+ public void loadSource(OrcsDataHandler<IndexedResource> handler, int tagQueueQueryId) throws OseeCoreException {
+ boolean loadSuccess = loadData(handler, tagQueueQueryId);
// Re-try in case query id hasn't been committed to the database
int retry = 0;
- while (attributeDatas.isEmpty() && retry < IndexerConstants.INDEX_QUERY_ID_LOADER_TOTAL_RETRIES) {
+ while (!loadSuccess && retry < IndexerConstants.INDEX_QUERY_ID_LOADER_TOTAL_RETRIES) {
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {
// Do Nothing
}
- logger.debug("Retrying attribute load from gammas - queryId[%s] attempt[%s]", tagQueueQueryId, retry);
- loadAttributeData(attributeDatas, connection, tagQueueQueryId);
+ logger.debug("Retrying attribute load from gammas - queryId[%s] attempt[%s of %s]", tagQueueQueryId, retry,
+ IndexerConstants.INDEX_QUERY_ID_LOADER_TOTAL_RETRIES);
+ loadSuccess = loadData(handler, tagQueueQueryId);
retry++;
}
}
+
+ private IndexedResource createData(int localId, long typeUuid, long gammaId, String value, String uri) {
+ return new IndexerDataSourceImpl(resourceManager, localId, typeUuid, gammaId, value, uri);
+ }
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/data/AttributeForIndexingImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/data/IndexerDataSourceImpl.java
index a56e20f8a9..da07ae22cd 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/data/AttributeForIndexingImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/data/IndexerDataSourceImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
+ * 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
@@ -10,13 +10,11 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.search.indexer.data;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
-import org.eclipse.osee.framework.core.data.IAttributeType;
-import org.eclipse.osee.framework.core.enums.ModificationType;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeExceptions;
import org.eclipse.osee.framework.jdk.core.type.PropertyStore;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.jdk.core.util.Strings;
@@ -24,82 +22,93 @@ import org.eclipse.osee.framework.resource.management.IResource;
import org.eclipse.osee.framework.resource.management.IResourceLocator;
import org.eclipse.osee.framework.resource.management.IResourceManager;
import org.eclipse.osee.framework.resource.management.StandardOptions;
-import org.eclipse.osee.orcs.data.AttributeReadable;
+import org.eclipse.osee.orcs.core.ds.IndexedResource;
import org.eclipse.osee.orcs.db.internal.resource.ResourceConstants;
/**
* @author Roberto E. Escobar
*/
-public class AttributeForIndexingImpl implements AttributeReadable<String> {
+public class IndexerDataSourceImpl implements IndexedResource {
private final IResourceManager resourceManager;
- private final int attrId;
+ private final int localId;
+ private final long typeUuid;
private final long gammaId;
- private final IAttributeType attributeType;
-
private final String value;
private final String uri;
- public AttributeForIndexingImpl(IResourceManager resourceManager, int attrId, long gammaId, IAttributeType attributeType, String value, String uri) {
+ public IndexerDataSourceImpl(IResourceManager resourceManager, int localId, long typeUuid, long gammaId, String value, String uri) {
super();
this.resourceManager = resourceManager;
- this.attrId = attrId;
+ this.localId = localId;
+ this.typeUuid = typeUuid;
this.gammaId = gammaId;
- this.attributeType = attributeType;
this.value = value;
this.uri = uri;
}
- public int getArtId() {
- throw new UnsupportedOperationException();
- }
-
- public int getBranchId() {
- throw new UnsupportedOperationException();
+ @Override
+ public int getLocalId() {
+ return localId;
}
@Override
- public ModificationType getModificationType() {
- throw new UnsupportedOperationException();
+ public long getGammaId() {
+ return gammaId;
}
@Override
- public int getId() {
- return attrId;
+ public long getTypeUuid() {
+ return typeUuid;
}
- @Override
- public long getGammaId() {
- return gammaId;
+ private String getStringValue() {
+ return value;
}
- @Override
- public IAttributeType getAttributeType() {
- return attributeType;
+ private String getUri() {
+ return uri;
}
- @Override
- public boolean isOfType(IAttributeType otherAttributeType) {
- return getAttributeType().equals(otherAttributeType);
+ private boolean isUriValid() {
+ boolean toReturn = false;
+ try {
+ String value = getUri();
+ if (Strings.isValid(value)) {
+ URI uri = new URI(value);
+ if (uri.toASCIIString().startsWith(ResourceConstants.ATTRIBUTE_RESOURCE_PROTOCOL)) {
+ toReturn = true;
+ }
+ }
+ } catch (Exception ex) {
+ // DO NOTHING
+ }
+ return toReturn;
}
@Override
- public String getValue() throws OseeCoreException {
- String toReturn = null;
+ public InputStream getInput() throws IOException {
+ InputStream toReturn = null;
if (isUriValid()) {
- InputStream inputStream = null;
try {
- inputStream = getExtendedDataAsStream();
- toReturn = Lib.inputStreamToString(inputStream);
- } catch (IOException ex) {
- OseeExceptions.wrapAndThrow(ex);
+ PropertyStore options = new PropertyStore();
+ options.put(StandardOptions.DecompressOnAquire.name(), true);
+ IResourceLocator locator = resourceManager.getResourceLocator(getUri());
+ IResource resource = resourceManager.acquire(locator, options);
+ toReturn = resource.getContent();
+ } catch (OseeCoreException ex) {
+ throw new IOException(ex);
} finally {
- Lib.close(inputStream);
+ Lib.close(toReturn);
}
} else {
- toReturn = getStringValue();
+ try {
+ toReturn = new ByteArrayInputStream(getStringValue().getBytes("UTF-8"));
+ } finally {
+ Lib.close(toReturn);
+ }
}
return toReturn;
}
@@ -120,8 +129,8 @@ public class AttributeForIndexingImpl implements AttributeReadable<String> {
if (obj == null) {
return false;
}
- if (obj instanceof AttributeReadable<?>) {
- AttributeReadable<?> other = (AttributeReadable<?>) obj;
+ if (obj instanceof IndexedResource) {
+ IndexedResource other = (IndexedResource) obj;
if (getGammaId() != other.getGammaId()) {
return false;
} else {
@@ -132,55 +141,9 @@ public class AttributeForIndexingImpl implements AttributeReadable<String> {
}
}
- private String getStringValue() {
- return value;
- }
-
- private String getUri() {
- return uri;
- }
-
- private InputStream getExtendedDataAsStream() throws OseeCoreException {
- InputStream toReturn = null;
- if (isUriValid()) {
- PropertyStore options = new PropertyStore();
- options.put(StandardOptions.DecompressOnAquire.name(), true);
- IResourceLocator locator = resourceManager.getResourceLocator(getUri());
- IResource resource = resourceManager.acquire(locator, options);
- toReturn = resource.getContent();
- }
- return toReturn;
- }
-
- public boolean isUriValid() {
- boolean toReturn = false;
- try {
- String value = getUri();
- if (Strings.isValid(value)) {
- URI uri = new URI(value);
- if (uri.toASCIIString().startsWith(ResourceConstants.ATTRIBUTE_RESOURCE_PROTOCOL)) {
- toReturn = true;
- }
- }
- } catch (Exception ex) {
- // DO NOTHING
- }
- return toReturn;
- }
-
- @Override
- public String getDisplayableString() throws OseeCoreException {
- return getValue();
- }
-
@Override
public String toString() {
- return String.format("attrId:[%s] gammaId:[%s] uri:[%s] attrType:[%s] isValidUri:[%s]", getId(), getGammaId(),
- getUri(), getAttributeType(), isUriValid());
+ return "IndexerDataSourceImpl [localId=" + localId + ", typeUuid=" + typeUuid + ", gammaId=" + gammaId + ", uri=" + uri + ", value=" + value + "]";
}
- @Override
- public boolean isDeleted() {
- return false;
- }
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/BaseAttributeTagger.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/AbstractTagger.java
index 0e20e89304..f5c89a149f 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/BaseAttributeTagger.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/AbstractTagger.java
@@ -10,22 +10,16 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.search.tagger;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeExceptions;
-import org.eclipse.osee.orcs.data.AttributeReadable;
/**
* @author Roberto E. Escobar
*/
-public abstract class BaseAttributeTagger implements Tagger {
+public abstract class AbstractTagger implements Tagger {
private final StreamMatcher matcher;
private final TagProcessor tagProcessor;
- protected BaseAttributeTagger(TagProcessor tagProcessor, StreamMatcher matcher) {
+ protected AbstractTagger(TagProcessor tagProcessor, StreamMatcher matcher) {
super();
this.tagProcessor = tagProcessor;
this.matcher = matcher;
@@ -39,15 +33,4 @@ public abstract class BaseAttributeTagger implements Tagger {
return matcher;
}
- protected InputStream getValueAsStream(AttributeReadable<?> attribute) throws OseeCoreException {
- String content = String.valueOf(attribute.getValue());
- InputStream inputStream = null;
- try {
- inputStream = new ByteArrayInputStream(content.getBytes("UTF-8"));
- } catch (UnsupportedEncodingException ex) {
- OseeExceptions.wrapAndThrow(ex);
- }
- return inputStream;
- }
-
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/Tagger.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/Tagger.java
index 3afa92bd8b..f84397e7bd 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/Tagger.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/Tagger.java
@@ -10,19 +10,19 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.search.tagger;
+import java.io.InputStream;
import java.util.List;
import org.eclipse.osee.framework.core.enums.QueryOption;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
-import org.eclipse.osee.orcs.data.AttributeReadable;
+import com.google.common.io.InputSupplier;
/**
* @author Roberto E. Escobar
*/
public interface Tagger {
- void tagIt(AttributeReadable<?> attribute, TagCollector collector) throws OseeCoreException;
+ void tagIt(InputSupplier<? extends InputStream> provider, TagCollector collector) throws Exception;
- List<MatchLocation> find(AttributeReadable<?> attribute, String toSearch, boolean matchAllLocations, QueryOption... options) throws OseeCoreException;
+ List<MatchLocation> find(InputSupplier<? extends InputStream> provider, String toSearch, boolean matchAllLocations, QueryOption... options) throws Exception;
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/DefaultAttributeTagger.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/TextStreamTagger.java
index b832ba2f07..a8496c91d2 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/DefaultAttributeTagger.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/TextStreamTagger.java
@@ -14,26 +14,25 @@ import java.io.InputStream;
import java.util.Collections;
import java.util.List;
import org.eclipse.osee.framework.core.enums.QueryOption;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.orcs.data.AttributeReadable;
+import com.google.common.io.InputSupplier;
/**
* @author Roberto E. Escobar
*/
-public class DefaultAttributeTagger extends BaseAttributeTagger {
+public class TextStreamTagger extends AbstractTagger {
- public DefaultAttributeTagger(TagProcessor tagProcessor, StreamMatcher matcher) {
+ public TextStreamTagger(TagProcessor tagProcessor, StreamMatcher matcher) {
super(tagProcessor, matcher);
}
@Override
- public void tagIt(AttributeReadable<?> attribute, TagCollector collector) throws OseeCoreException {
+ public void tagIt(InputSupplier<? extends InputStream> provider, TagCollector collector) throws Exception {
InputStream inputStream = null;
try {
- inputStream = getValueAsStream(attribute);
+ inputStream = provider.getInput();
getTagProcessor().collectFromInputStream(inputStream, collector);
} finally {
Lib.close(inputStream);
@@ -41,12 +40,12 @@ public class DefaultAttributeTagger extends BaseAttributeTagger {
}
@Override
- public List<MatchLocation> find(AttributeReadable<?> attribute, String toSearch, boolean matchAllLocations, QueryOption... options) throws OseeCoreException {
+ public List<MatchLocation> find(InputSupplier<? extends InputStream> provider, String toSearch, boolean matchAllLocations, QueryOption... options) throws Exception {
List<MatchLocation> toReturn;
if (Strings.isValid(toSearch)) {
InputStream inputStream = null;
try {
- inputStream = getValueAsStream(attribute);
+ inputStream = provider.getInput();
toReturn = getMatcher().findInStream(inputStream, toSearch, matchAllLocations, options);
} finally {
Lib.close(inputStream);
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/XmlAttributeTagger.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/XmlTagger.java
index b9aeadf297..e72bc10aee 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/XmlAttributeTagger.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/XmlTagger.java
@@ -10,44 +10,44 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.search.tagger;
+import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.List;
import org.eclipse.osee.framework.core.enums.QueryOption;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.jdk.core.util.io.xml.XmlTextInputStream;
-import org.eclipse.osee.orcs.data.AttributeReadable;
+import com.google.common.io.InputSupplier;
/**
* @author Roberto E. Escobar
*/
-public class XmlAttributeTagger extends BaseAttributeTagger {
+public class XmlTagger extends AbstractTagger {
- public XmlAttributeTagger(TagProcessor tagProcessor, StreamMatcher matcher) {
+ public XmlTagger(TagProcessor tagProcessor, StreamMatcher matcher) {
super(tagProcessor, matcher);
}
@Override
- public void tagIt(AttributeReadable<?> attribute, TagCollector collector) throws OseeCoreException {
+ public void tagIt(InputSupplier<? extends InputStream> provider, TagCollector collector) throws Exception {
InputStream inputStream = null;
try {
- inputStream = getValueAsStream(attribute);
- getTagProcessor().collectFromInputStream(new XmlTextInputStream(inputStream), collector);
+ inputStream = getStream(provider);
+ getTagProcessor().collectFromInputStream(inputStream, collector);
} finally {
Lib.close(inputStream);
}
}
@Override
- public List<MatchLocation> find(AttributeReadable<?> attribute, String toSearch, boolean matchAllLocations, QueryOption... options) throws OseeCoreException {
+ public List<MatchLocation> find(InputSupplier<? extends InputStream> provider, String toSearch, boolean matchAllLocations, QueryOption... options) throws Exception {
List<MatchLocation> toReturn;
if (Strings.isValid(toSearch)) {
InputStream inputStream = null;
try {
- inputStream = new XmlTextInputStream(getValueAsStream(attribute));
+ inputStream = getStream(provider);
toReturn = getMatcher().findInStream(inputStream, toSearch, matchAllLocations, options);
} finally {
Lib.close(inputStream);
@@ -57,4 +57,8 @@ public class XmlAttributeTagger extends BaseAttributeTagger {
}
return toReturn;
}
+
+ private InputStream getStream(InputSupplier<? extends InputStream> provider) throws IOException {
+ return new XmlTextInputStream(provider.getInput());
+ }
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/AbstractQueryPostProcessor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/AbstractQueryPostProcessor.java
deleted file mode 100644
index 4623f53ad9..0000000000
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/AbstractQueryPostProcessor.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.orcs.db.internal.search.util;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.concurrent.Future;
-import org.eclipse.osee.executor.admin.CancellableCallable;
-import org.eclipse.osee.executor.admin.ExecutorAdmin;
-import org.eclipse.osee.executor.admin.WorkUtility;
-import org.eclipse.osee.executor.admin.WorkUtility.PartitionFactory;
-import org.eclipse.osee.framework.core.data.IAttributeType;
-import org.eclipse.osee.framework.core.enums.DeletionFlag;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.util.Conditions;
-import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
-import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.core.ds.Options;
-import org.eclipse.osee.orcs.core.ds.OptionsUtil;
-import org.eclipse.osee.orcs.core.ds.QueryPostProcessor;
-import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAttributeKeywords;
-import org.eclipse.osee.orcs.data.ArtifactReadable;
-import org.eclipse.osee.orcs.data.AttributeReadable;
-import org.eclipse.osee.orcs.data.AttributeTypes;
-import org.eclipse.osee.orcs.db.internal.search.tagger.Tagger;
-import org.eclipse.osee.orcs.search.Match;
-
-/**
- * @author Roberto E. Escobar
- */
-public abstract class AbstractQueryPostProcessor extends QueryPostProcessor implements PartitionFactory<ArtifactReadable, Match<ArtifactReadable, AttributeReadable<?>>> {
-
- private final Options options;
- private final CriteriaAttributeKeywords criteria;
- private final ExecutorAdmin executorAdmin;
- private List<Future<Collection<Match<ArtifactReadable, AttributeReadable<?>>>>> futures;
-
- protected AbstractQueryPostProcessor(Log logger, ExecutorAdmin executorAdmin, CriteriaAttributeKeywords criteria, Options options) {
- super(logger);
- this.executorAdmin = executorAdmin;
- this.criteria = criteria;
- this.options = options;
- }
-
- protected Collection<? extends IAttributeType> getTypes() {
- return criteria.getTypes();
- }
-
- protected String getQuery() {
- return criteria.getValues().iterator().next();
- }
-
- protected Options getOptions() {
- return options;
- }
-
- @Override
- public List<Match<ArtifactReadable, AttributeReadable<?>>> innerCall() throws Exception {
- Conditions.checkNotNull(getItemsToProcess(), "Query first pass results");
-
- futures = WorkUtility.partitionAndScheduleWork(executorAdmin, this, getItemsToProcess());
-
- checkForCancelled();
-
- List<Match<ArtifactReadable, AttributeReadable<?>>> results =
- new ArrayList<Match<ArtifactReadable, AttributeReadable<?>>>();
- for (Future<Collection<Match<ArtifactReadable, AttributeReadable<?>>>> future : futures) {
- results.addAll(future.get());
- checkForCancelled();
- }
- return results;
- }
-
- @Override
- public void setCancel(boolean isCancelled) {
- super.setCancel(isCancelled);
- if (futures != null) {
- for (Future<?> future : futures) {
- future.cancel(true);
- }
- }
- }
-
- protected abstract Tagger getTagger(String taggerId) throws OseeCoreException;
-
- @Override
- public Callable<Collection<Match<ArtifactReadable, AttributeReadable<?>>>> createWorker(Collection<ArtifactReadable> toProcess) {
- return new PostProcessorWorker(toProcess);
- }
-
- private class PostProcessorWorker extends CancellableCallable<Collection<Match<ArtifactReadable, AttributeReadable<?>>>> {
-
- private final Collection<ArtifactReadable> artifacts;
-
- public PostProcessorWorker(Collection<ArtifactReadable> artifacts) {
- this.artifacts = artifacts;
- }
-
- @Override
- public Collection<Match<ArtifactReadable, AttributeReadable<?>>> call() throws Exception {
- List<Match<ArtifactReadable, AttributeReadable<?>>> results =
- new ArrayList<Match<ArtifactReadable, AttributeReadable<?>>>();
-
- AttributeTypes attributeTypes = getAttributeTypes();
-
- DeletionFlag includeDeleted = OptionsUtil.getIncludeDeleted(options);
- Map<AttributeReadable<?>, List<MatchLocation>> matchedAttributes = null;
- for (ArtifactReadable artifact : artifacts) {
- checkForCancelled();
- for (AttributeReadable<Object> attribute : getAttributes(artifact, includeDeleted)) {
- checkForCancelled();
- try {
- if (getTypes().contains(attribute.getAttributeType())) {
- checkForCancelled();
-
- String taggerId = attributeTypes.getTaggerId(attribute.getAttributeType());
- Tagger tagger = getTagger(taggerId);
- if (tagger != null) {
- checkForCancelled();
- List<MatchLocation> locations = tagger.find(attribute, getQuery(), true, criteria.getOptions());
- if (!locations.isEmpty()) {
- if (matchedAttributes == null) {
- matchedAttributes = new HashMap<AttributeReadable<?>, List<MatchLocation>>();
- }
- matchedAttributes.put(attribute, locations);
- }
- }
- }
- } catch (Exception ex) {
- getLogger().error(ex, "Error processing: [%s]", attribute);
- }
- }
- if (matchedAttributes != null && !matchedAttributes.isEmpty()) {
- results.add(new ArtifactMatch(artifact, matchedAttributes));
- matchedAttributes = null;
- }
- }
- return results;
- }
-
- private List<AttributeReadable<Object>> getAttributes(ArtifactReadable artifact, DeletionFlag includeDeleted) throws OseeCoreException {
- List<AttributeReadable<Object>> toReturn;
-
- Collection<? extends IAttributeType> toCheck = getTypes();
- if (toCheck != null && !toCheck.isEmpty()) {
- toReturn = new ArrayList<AttributeReadable<Object>>();
- for (IAttributeType attributeType : toCheck) {
- for (AttributeReadable<Object> attr : artifact.getAttributes(attributeType, includeDeleted)) {
- toReturn.add(attr);
- checkForCancelled();
- }
- }
- } else {
- toReturn = artifact.getAttributes(includeDeleted);
- }
- return toReturn;
- }
- }
-}
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.db/src/org/eclipse/osee/orcs/db/internal/search/util/ArtifactDataCountHandler.java
new file mode 100644
index 0000000000..c04418579c
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/ArtifactDataCountHandler.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * 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 java.util.concurrent.atomic.AtomicInteger;
+import org.eclipse.osee.framework.core.exception.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 {
+
+ private final AtomicInteger counter;
+
+ public ArtifactDataCountHandler(LoadDataHandler handler) {
+ super(handler);
+ this.counter = new AtomicInteger();
+ }
+
+ protected AtomicInteger getCounter() {
+ return counter;
+ }
+
+ public int getArtifactCount() {
+ return getCounter().get();
+ }
+
+ @Override
+ public void onLoadStart() throws OseeCoreException {
+ getCounter().set(0);
+ super.onLoadStart();
+ }
+
+ @Override
+ public void onData(ArtifactData data) throws OseeCoreException {
+ 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/search/util/ArtifactMatch.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/ArtifactMatch.java
deleted file mode 100644
index 04f5dfe6c5..0000000000
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/ArtifactMatch.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.orcs.db.internal.search.util;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
-import org.eclipse.osee.orcs.data.ArtifactReadable;
-import org.eclipse.osee.orcs.data.AttributeReadable;
-import org.eclipse.osee.orcs.search.Match;
-
-/**
- * @author Roberto E. Escobar
- */
-public class ArtifactMatch implements Match<ArtifactReadable, AttributeReadable<?>> {
-
- private final Map<AttributeReadable<?>, List<MatchLocation>> matchedAttributes;
- private final ArtifactReadable item;
-
- public ArtifactMatch(ArtifactReadable item, Map<AttributeReadable<?>, List<MatchLocation>> matchedAttributes) {
- super();
- this.item = item;
- this.matchedAttributes = matchedAttributes;
- }
-
- @Override
- public boolean hasLocationData() {
- return !matchedAttributes.isEmpty();
- }
-
- @Override
- public ArtifactReadable getItem() {
- return item;
- }
-
- @Override
- public Collection<AttributeReadable<?>> getElements() {
- return matchedAttributes.keySet();
- }
-
- @Override
- public List<MatchLocation> getLocation(AttributeReadable<?> element) {
- List<MatchLocation> toReturn = matchedAttributes.get(element);
- return toReturn != null ? toReturn : Collections.<MatchLocation> emptyList();
- }
-
- @Override
- public String toString() {
- return "ArtifactMatch [item=" + item + ", matchedAttributes=" + matchedAttributes + "]";
- }
-
-}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/AttributeDataMatcher.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/AttributeDataMatcher.java
new file mode 100644
index 0000000000..f1c94c8c1a
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/AttributeDataMatcher.java
@@ -0,0 +1,171 @@
+/*******************************************************************************
+ * 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 java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.Collection;
+import java.util.List;
+import org.eclipse.osee.executor.admin.HasCancellation;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.enums.QueryOption;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.logger.Log;
+import org.eclipse.osee.orcs.core.ds.AttributeData;
+import org.eclipse.osee.orcs.core.ds.AttributeDataMatchHandler;
+import org.eclipse.osee.orcs.core.ds.BinaryDataProxy;
+import org.eclipse.osee.orcs.core.ds.CharacterDataProxy;
+import org.eclipse.osee.orcs.core.ds.DataProxy;
+import org.eclipse.osee.orcs.core.ds.IndexedResource;
+import org.eclipse.osee.orcs.data.AttributeTypes;
+import org.eclipse.osee.orcs.db.internal.search.tagger.Tagger;
+import org.eclipse.osee.orcs.db.internal.search.tagger.TaggingEngine;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AttributeDataMatcher {
+
+ private final Log logger;
+ private final TaggingEngine engine;
+ private final AttributeTypes attrTypes;
+
+ public AttributeDataMatcher(Log logger, TaggingEngine engine, AttributeTypes attrTypes) {
+ this.logger = logger;
+ this.engine = engine;
+ this.attrTypes = attrTypes;
+ }
+
+ protected Tagger getTagger(String taggerId) throws OseeCoreException {
+ Tagger toReturn = null;
+ if (Strings.isValid(taggerId)) {
+ toReturn = engine.getTagger(taggerId);
+ }
+ return toReturn;
+ }
+
+ public void process(HasCancellation cancellation, AttributeDataMatchHandler handler, AttributeData data, Collection<String> valuesToMatch, Collection<? extends IAttributeType> typesFilter, QueryOption... options) throws Exception {
+ logger.debug("Attribute Data match for attr[%s] - [%s]", data.getLocalId(), valuesToMatch);
+ int valueCount = valuesToMatch.size();
+ if (valueCount > 1) {
+ matchValuesExactly(cancellation, handler, data, valuesToMatch);
+ } else if (valueCount == 1) {
+ String toMatch = valuesToMatch.iterator().next();
+ matchTokenizedValue(cancellation, handler, data, toMatch, typesFilter, options);
+ }
+ }
+
+ private void checkCancelled(HasCancellation cancellation) {
+ if (cancellation != null) {
+ cancellation.checkForCancelled();
+ }
+ }
+
+ private void matchValuesExactly(HasCancellation cancellation, AttributeDataMatchHandler handler, AttributeData data, Iterable<String> valuesToMatch) throws Exception {
+ String value = getValue(data);
+ for (String toMatch : valuesToMatch) {
+ checkCancelled(cancellation);
+ if (value.equals(toMatch)) {
+ MatchLocation matchLocation = new MatchLocation(1, value.length());
+ handler.onData(data, matchLocation);
+ }
+ }
+ }
+
+ private void matchTokenizedValue(HasCancellation cancellation, AttributeDataMatchHandler handler, AttributeData data, String toMatch, Collection<? extends IAttributeType> typesFilter, QueryOption... options) throws Exception {
+ AttributeIndexedResource source = adapt(data);
+ IAttributeType attrType = attrTypes.getByUuid(source.getTypeUuid());
+ if (typesFilter.contains(attrType)) {
+ checkCancelled(cancellation);
+ String taggerId = attrTypes.getTaggerId(attrType);
+ Tagger tagger = getTagger(taggerId);
+ if (tagger != null) {
+ checkCancelled(cancellation);
+ List<MatchLocation> matched = tagger.find(source, toMatch, true, options);
+ for (MatchLocation matchLocation : matched) {
+ checkCancelled(cancellation);
+ handler.onData(data, matchLocation);
+ }
+ }
+ }
+ }
+
+ private AttributeIndexedResource adapt(AttributeData data) {
+ return new AttributeIndexedResource(data);
+ }
+
+ private String getValue(AttributeData data) throws OseeCoreException {
+ String value = "";
+ DataProxy dataProxy = data.getDataProxy();
+ if (dataProxy instanceof CharacterDataProxy) {
+ value = ((CharacterDataProxy) dataProxy).getValueAsString();
+ } else {
+ value = dataProxy.toString();
+ }
+ return value;
+ }
+
+ private final class AttributeIndexedResource implements IndexedResource {
+ private final AttributeData attrData;
+
+ public AttributeIndexedResource(AttributeData attrData) {
+ super();
+ this.attrData = attrData;
+ }
+
+ @Override
+ public int getLocalId() {
+ return attrData.getLocalId();
+ }
+
+ @Override
+ public long getTypeUuid() {
+ return attrData.getTypeUuid();
+ }
+
+ @Override
+ public long getGammaId() {
+ return attrData.getVersion().getGammaId();
+ }
+
+ @Override
+ public InputStream getInput() throws IOException {
+ InputStream stream = null;
+ DataProxy dataProxy = attrData.getDataProxy();
+ if (dataProxy instanceof BinaryDataProxy) {
+ ByteBuffer valueAsBytes;
+ try {
+ valueAsBytes = ((BinaryDataProxy) dataProxy).getValueAsBytes();
+ } catch (OseeCoreException ex) {
+ throw new IOException(ex);
+ }
+ stream = new ByteArrayInputStream(valueAsBytes.array());
+ } else {
+ String value = null;
+ if (dataProxy instanceof CharacterDataProxy) {
+ try {
+ value = ((CharacterDataProxy) dataProxy).getValueAsString();
+ } catch (OseeCoreException ex) {
+ throw new IOException(ex);
+ }
+ } else {
+ value = dataProxy.toString();
+ }
+ stream = new ByteArrayInputStream(value.getBytes("UTF-8"));
+ }
+ return stream;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/AttributeQueryPostProcessor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/AttributeQueryPostProcessor.java
deleted file mode 100644
index 65d4631ad8..0000000000
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/AttributeQueryPostProcessor.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.orcs.db.internal.search.util;
-
-import org.eclipse.osee.executor.admin.ExecutorAdmin;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.core.ds.Options;
-import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAttributeKeywords;
-import org.eclipse.osee.orcs.db.internal.search.tagger.Tagger;
-import org.eclipse.osee.orcs.db.internal.search.tagger.TaggingEngine;
-
-/**
- * @author Roberto E. Escobar
- */
-public class AttributeQueryPostProcessor extends AbstractQueryPostProcessor {
-
- private final TaggingEngine engine;
-
- public AttributeQueryPostProcessor(Log logger, ExecutorAdmin executorAdmin, TaggingEngine engine, CriteriaAttributeKeywords criteria, Options options) {
- super(logger, executorAdmin, criteria, options);
- this.engine = engine;
- }
-
- @Override
- protected Tagger getTagger(String taggerId) throws OseeCoreException {
- return engine.getDefaultTagger();
- }
-}
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
new file mode 100644
index 0000000000..5c752f8c41
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/BufferedLoadDataHandler.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * 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.core.exception.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;
+ }
+
+ @SuppressWarnings("unused")
+ @Override
+ public void onData(ArtifactData data) throws OseeCoreException {
+ buffer.addData(data);
+ }
+
+ @SuppressWarnings("unused")
+ @Override
+ public void onData(AttributeData data) throws OseeCoreException {
+ buffer.addData(data);
+ }
+
+ @SuppressWarnings("unused")
+ @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/search/util/DataPostProcessorFactoryImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/DataPostProcessorFactoryImpl.java
deleted file mode 100644
index 68e8b026bf..0000000000
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/DataPostProcessorFactoryImpl.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 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.executor.admin.ExecutorAdmin;
-import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.core.ds.DataPostProcessor;
-import org.eclipse.osee.orcs.core.ds.DataPostProcessorFactory;
-import org.eclipse.osee.orcs.core.ds.Options;
-import org.eclipse.osee.orcs.core.ds.OptionsUtil;
-import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAttributeKeywords;
-import org.eclipse.osee.orcs.db.internal.search.tagger.TaggingEngine;
-
-/**
- * @author Roberto E. Escobar
- */
-public class DataPostProcessorFactoryImpl implements DataPostProcessorFactory<CriteriaAttributeKeywords> {
-
- private final Log logger;
- private final TaggingEngine taggingEngine;
- private final ExecutorAdmin executorAdmin;
-
- public DataPostProcessorFactoryImpl(Log logger, TaggingEngine taggingEngine, ExecutorAdmin executorAdmin) {
- super();
- this.logger = logger;
- this.taggingEngine = taggingEngine;
- this.executorAdmin = executorAdmin;
- }
-
- @Override
- public DataPostProcessor<?> createPostProcessor(CriteriaAttributeKeywords criteria, Options options) {
- DataPostProcessor<?> processor;
- // if (criteria.getStringOp().isTokenized()) {
- if (criteria.getValues().size() > 1) {
- processor = new SimpleOrPostProcessor(logger, criteria, OptionsUtil.getIncludeDeleted(options));
- } else {
- processor = new TokenQueryPostProcessor(logger, executorAdmin, taggingEngine, criteria, options);
- }
- // } else {
- // processor = new AttributeQueryPostProcessor(logger, executorAdmin, taggingEngine, criteria, options);
- // }
- return processor;
- }
-}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/LoadDataBuffer.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/LoadDataBuffer.java
new file mode 100644
index 0000000000..57c26c3089
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/LoadDataBuffer.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * 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 java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import org.eclipse.osee.orcs.core.ds.ArtifactData;
+import org.eclipse.osee.orcs.core.ds.AttributeData;
+import org.eclipse.osee.orcs.core.ds.RelationData;
+import com.google.common.base.Supplier;
+import com.google.common.collect.ListMultimap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Multimap;
+import com.google.common.collect.Multimaps;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class LoadDataBuffer {
+
+ private final Map<Integer, ArtifactData> artifacts;
+ private final Multimap<Integer, AttributeData> attributes;
+ private final Multimap<Integer, RelationData> relations;
+
+ public LoadDataBuffer(int initialSize) {
+ artifacts = new LinkedHashMap<Integer, ArtifactData>(initialSize);
+ attributes = newLinkedHashListMultimap(initialSize);
+ relations = newLinkedHashListMultimap(initialSize);
+ }
+
+ public synchronized void clear() {
+ artifacts.clear();
+ attributes.clear();
+ relations.clear();
+ }
+
+ public void addData(ArtifactData data) {
+ synchronized (artifacts) {
+ artifacts.put(data.getLocalId(), data);
+ }
+ }
+
+ public void addData(AttributeData data) {
+ synchronized (attributes) {
+ attributes.put(data.getArtifactId(), data);
+ }
+ }
+
+ public void addData(RelationData data) {
+ synchronized (relations) {
+ relations.put(data.getParentId(), data);
+ }
+ }
+
+ public ArtifactData removeArtifactByArtId(int artifactId) {
+ ArtifactData art = null;
+ synchronized (artifacts) {
+ art = artifacts.remove(artifactId);
+ }
+ return art;
+ }
+
+ public Iterable<AttributeData> removeAttributesByArtId(int artifactId) {
+ Collection<AttributeData> data = null;
+ synchronized (attributes) {
+ data = attributes.removeAll(artifactId);
+ }
+ return data;
+ }
+
+ public Iterable<RelationData> removeRelationsByArtId(int artifactId) {
+ Collection<RelationData> rels = null;
+ synchronized (relations) {
+ rels = relations.removeAll(artifactId);
+ }
+ return rels;
+ }
+
+ private static <K, V> ListMultimap<K, V> newLinkedHashListMultimap(int fetchSize) {
+ Map<K, Collection<V>> map = new LinkedHashMap<K, Collection<V>>(fetchSize);
+ return Multimaps.newListMultimap(map, new Supplier<List<V>>() {
+ @Override
+ public List<V> get() {
+ return Lists.newArrayList();
+ }
+ });
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/SimpleOrPostProcessor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/SimpleOrPostProcessor.java
deleted file mode 100644
index d5c8954f30..0000000000
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/SimpleOrPostProcessor.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Created on Apr 24, 2013
- *
- * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
- */
-package org.eclipse.osee.orcs.db.internal.search.util;
-
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import org.eclipse.osee.framework.core.data.IAttributeType;
-import org.eclipse.osee.framework.core.enums.DeletionFlag;
-import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
-import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.core.ds.QueryPostProcessor;
-import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAttributeKeywords;
-import org.eclipse.osee.orcs.data.ArtifactReadable;
-import org.eclipse.osee.orcs.data.AttributeReadable;
-import org.eclipse.osee.orcs.search.Match;
-
-public class SimpleOrPostProcessor extends QueryPostProcessor {
-
- private final CriteriaAttributeKeywords criteria;
- private final DeletionFlag deletionFlag;
-
- protected SimpleOrPostProcessor(Log logger, CriteriaAttributeKeywords criteria, DeletionFlag deletionFlag) {
- super(logger);
- this.criteria = criteria;
- this.deletionFlag = deletionFlag;
- }
-
- @Override
- protected List<Match<ArtifactReadable, AttributeReadable<?>>> innerCall() throws Exception {
- List<Match<ArtifactReadable, AttributeReadable<?>>> toReturn =
- new LinkedList<Match<ArtifactReadable, AttributeReadable<?>>>();
-
- Map<AttributeReadable<?>, List<MatchLocation>> matchedAttributes =
- new LinkedHashMap<AttributeReadable<?>, List<MatchLocation>>();
-
- IAttributeType type = criteria.getTypes().iterator().next();
- List<ArtifactReadable> toProcess = getItemsToProcess();
-
- for (ArtifactReadable toCheck : toProcess) {
- List<AttributeReadable<Object>> attributes = toCheck.getAttributes(type, deletionFlag);
-
- for (AttributeReadable<Object> attribute : attributes) {
- String value = String.valueOf(attribute);
-
- for (String toMatch : criteria.getValues()) {
- if (value.equals(toMatch)) {
- MatchLocation loc = new MatchLocation(1, value.length());
- List<MatchLocation> list = matchedAttributes.get(attribute);
- if (list == null) {
- list = new LinkedList<MatchLocation>();
- matchedAttributes.put(attribute, list);
- }
- list.add(loc);
- }
- }
- }
- toReturn.add(new ArtifactMatch(toCheck, matchedAttributes));
- }
- return toReturn;
- }
-}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/TokenQueryPostProcessor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/TokenQueryPostProcessor.java
deleted file mode 100644
index c2199a437f..0000000000
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/TokenQueryPostProcessor.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.orcs.db.internal.search.util;
-
-import org.eclipse.osee.executor.admin.ExecutorAdmin;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.core.ds.Options;
-import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAttributeKeywords;
-import org.eclipse.osee.orcs.db.internal.search.tagger.Tagger;
-import org.eclipse.osee.orcs.db.internal.search.tagger.TaggingEngine;
-
-/**
- * @author Roberto E. Escobar
- */
-public class TokenQueryPostProcessor extends AbstractQueryPostProcessor {
-
- private final TaggingEngine engine;
-
- public TokenQueryPostProcessor(Log logger, ExecutorAdmin executorAdmin, TaggingEngine engine, CriteriaAttributeKeywords criteria, Options options) {
- super(logger, executorAdmin, criteria, options);
- this.engine = engine;
- }
-
- @Override
- protected Tagger getTagger(String taggerId) throws OseeCoreException {
- Tagger toReturn = null;
- if (Strings.isValid(taggerId)) {
- toReturn = engine.getTagger(taggerId);
- }
- return toReturn;
- }
-}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/AbstractSqlWriter.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/AbstractSqlWriter.java
index 7c90f75f3e..77eadb2a0a 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/AbstractSqlWriter.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/AbstractSqlWriter.java
@@ -23,7 +23,6 @@ import org.eclipse.osee.framework.database.core.IdJoinQuery;
import org.eclipse.osee.framework.database.core.JoinUtility;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.core.ds.DataPostProcessor;
import org.eclipse.osee.orcs.core.ds.HasOptions;
import org.eclipse.osee.orcs.core.ds.Options;
import org.eclipse.osee.orcs.db.internal.SqlProvider;
@@ -43,9 +42,9 @@ public abstract class AbstractSqlWriter implements HasOptions {
private final Log logger;
private final IOseeDatabaseService dbService;
private final SqlProvider sqlProvider;
- private final SqlContext<? extends DataPostProcessor<?>> context;
+ private final SqlContext context;
- public AbstractSqlWriter(Log logger, IOseeDatabaseService dbService, SqlProvider sqlProvider, SqlContext<? extends DataPostProcessor<?>> context) {
+ public AbstractSqlWriter(Log logger, IOseeDatabaseService dbService, SqlProvider sqlProvider, SqlContext context) {
this.logger = logger;
this.dbService = dbService;
this.sqlProvider = sqlProvider;
@@ -60,6 +59,16 @@ public abstract class AbstractSqlWriter implements HasOptions {
Conditions.checkNotNullOrEmpty(handlers, "SqlHandlers");
output.delete(0, output.length());
+ write(handlers);
+
+ context.setSql(toString());
+
+ if (logger.isTraceEnabled()) {
+ logger.trace("Sql Writer - [%s]", context);
+ }
+ }
+
+ protected void write(List<SqlHandler<?>> handlers) throws OseeCoreException {
computeTables(handlers);
computeWithClause(handlers);
@@ -70,15 +79,9 @@ public abstract class AbstractSqlWriter implements HasOptions {
write("\n WHERE \n");
writePredicates(handlers);
writeGroupAndOrder();
-
- context.setSql(toString());
-
- if (logger.isTraceEnabled()) {
- logger.trace("Sql Writer - [%s]", context);
- }
}
- private void writeWithClause() throws OseeCoreException {
+ protected void writeWithClause() throws OseeCoreException {
if (Conditions.hasValues(withClauses)) {
write("WITH ");
int size = withClauses.size();
@@ -117,7 +120,7 @@ public abstract class AbstractSqlWriter implements HasOptions {
return aliasManager;
}
- public SqlContext<? extends DataPostProcessor<?>> getContext() {
+ public SqlContext getContext() {
return context;
}
@@ -159,7 +162,7 @@ public abstract class AbstractSqlWriter implements HasOptions {
write(AND_WITH_NEWLINES);
}
- private void removeDanglingSeparator(String token) {
+ protected void removeDanglingSeparator(String token) {
int length = output.length();
int index = output.lastIndexOf(token);
if (index == length - token.length()) {
@@ -221,12 +224,6 @@ public abstract class AbstractSqlWriter implements HasOptions {
return getContext().getOptions();
}
- @SuppressWarnings("unchecked")
- public void addPostProcessor(DataPostProcessor<?> processor) {
- List<DataPostProcessor<?>> processors = (List<DataPostProcessor<?>>) getContext().getPostProcessors();
- processors.add(processor);
- }
-
protected String getSqlHint() throws OseeCoreException {
String hint = Strings.EMPTY_STRING;
if (!Conditions.hasValues(withClauses)) {
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/OseeSql.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/OseeSql.java
index aefacc319b..4e3d9e8fdf 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/OseeSql.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/OseeSql.java
@@ -21,6 +21,7 @@ public enum OseeSql {
TX_GET_ALL_TRANSACTIONS("SELECT * FROM osee_tx_details WHERE transaction_id = ?"),
TX_GET_MAX_AS_LARGEST_TX("SELECT max(transaction_id) as largest_transaction_id FROM osee_tx_details WHERE branch_id = ?"),
+ TX_GET_MAX_AS_LARGEST_TX_WITH_BRANCH_GUID("SELECT max(txd.transaction_id) as largest_transaction_id FROM osee_tx_details txd, osee_branch ob WHERE ob.branch_guid = ? AND txd.branch_id = ob.branch_id"),
MERGE_GET_ARTIFACTS_FOR_BRANCH("SELECT art.art_id FROM osee_txs txs, osee_artifact art WHERE txs.branch_id = ? and txs.gamma_id = art.gamma_id"),
MERGE_GET_ATTRIBUTES_FOR_BRANCH("SELECT atr.art_id, atr.attr_id FROM osee_txs txs, osee_attribute atr WHERE txs.branch_id = ? and txs.gamma_id = atr.gamma_id"),
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QueryType.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/QueryType.java
index a28631f54e..42656e3bc5 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/QueryType.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/QueryType.java
@@ -8,12 +8,12 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs.db.internal.search;
+package org.eclipse.osee.orcs.db.internal.sql;
/**
* @author Roberto E. Escobar
*/
public enum QueryType {
- COUNT_ARTIFACTS,
- SELECT_ARTIFACTS;
+ COUNT,
+ SELECT;
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/SqlContext.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/SqlContext.java
index 2270095187..1d1000616c 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/SqlContext.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/SqlContext.java
@@ -12,13 +12,12 @@ package org.eclipse.osee.orcs.db.internal.sql;
import java.util.List;
import org.eclipse.osee.framework.database.core.AbstractJoinQuery;
-import org.eclipse.osee.orcs.core.ds.DataPostProcessor;
import org.eclipse.osee.orcs.core.ds.DataStoreContext;
/**
* @author Roberto E. Escobar
*/
-public interface SqlContext<P extends DataPostProcessor<?>> extends DataStoreContext<P> {
+public interface SqlContext extends DataStoreContext {
String getSql();
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/SqlContextImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/SqlContextImpl.java
index 0ffb656a03..3c757f0783 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/SqlContextImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/SqlContextImpl.java
@@ -15,18 +15,16 @@ import java.util.List;
import org.eclipse.osee.framework.database.core.AbstractJoinQuery;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.orcs.OrcsSession;
-import org.eclipse.osee.orcs.core.ds.DataPostProcessor;
import org.eclipse.osee.orcs.core.ds.Options;
/**
* @author Roberto E. Escobar
*/
-public class SqlContextImpl<P extends DataPostProcessor<?>> implements SqlContext<P> {
+public class SqlContextImpl implements SqlContext {
private String sql;
private final List<Object> parameters = new ArrayList<Object>();
private final List<AbstractJoinQuery> joinTables = new ArrayList<AbstractJoinQuery>();
- private final List<P> processors = new ArrayList<P>();
private final OrcsSession session;
private final Options options;
@@ -67,21 +65,15 @@ public class SqlContextImpl<P extends DataPostProcessor<?>> implements SqlContex
}
@Override
- public List<P> getPostProcessors() {
- return processors;
- }
-
- @Override
public void clear() {
setSql(null);
parameters.clear();
joinTables.clear();
- processors.clear();
}
@Override
public String toString() {
- return "SqlContextImpl [session=" + session + ", sql=" + (Strings.isValid(sql) ? sql.replaceAll("\n", "") : "") + ", parameters=" + parameters + ", joinTables=" + joinTables + ", processors=" + processors + ", options=" + options + "]";
+ return "SqlContextImpl [session=" + session + ", sql=" + (Strings.isValid(sql) ? sql.replaceAll("\n", "") : "") + ", parameters=" + parameters + ", joinTables=" + joinTables + ", options=" + options + "]";
}
}
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 b917cf05d3..8840f48c03 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
@@ -21,7 +21,6 @@ import org.eclipse.osee.framework.jdk.core.util.PriorityComparator;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.core.ds.Criteria;
import org.eclipse.osee.orcs.core.ds.CriteriaSet;
-import org.eclipse.osee.orcs.core.ds.DataPostProcessorFactory;
import org.eclipse.osee.orcs.db.internal.search.tagger.HasTagProcessor;
import org.eclipse.osee.orcs.db.internal.search.tagger.TagProcessor;
@@ -33,21 +32,19 @@ public class SqlHandlerFactoryImpl implements SqlHandlerFactory {
private static final PriorityComparator comparator = new PriorityComparator();
private final Map<Class<? extends Criteria>, Class<? extends SqlHandler<?>>> handleMap;
- private final Map<Class<? extends SqlHandler<?>>, DataPostProcessorFactory<?>> factoryMap;
private final Log logger;
private final IdentityService idService;
private final TagProcessor tagProcessor;
public SqlHandlerFactoryImpl(Log logger, IdentityService idService, Map<Class<? extends Criteria>, Class<? extends SqlHandler<?>>> handleMap) {
- this(logger, idService, null, handleMap, null);
+ this(logger, idService, null, handleMap);
}
- public SqlHandlerFactoryImpl(Log logger, IdentityService idService, TagProcessor tagProcessor, Map<Class<? extends Criteria>, Class<? extends SqlHandler<?>>> handleMap, Map<Class<? extends SqlHandler<?>>, DataPostProcessorFactory<?>> factoryMap) {
+ public SqlHandlerFactoryImpl(Log logger, IdentityService idService, TagProcessor tagProcessor, Map<Class<? extends Criteria>, Class<? extends SqlHandler<?>>> handleMap) {
this.logger = logger;
this.idService = idService;
this.handleMap = handleMap;
- this.factoryMap = factoryMap;
this.tagProcessor = tagProcessor;
}
@@ -56,7 +53,9 @@ public class SqlHandlerFactoryImpl implements SqlHandlerFactory {
List<SqlHandler<?>> handlers = new ArrayList<SqlHandler<?>>();
for (Criteria criteria : criteriaSet) {
SqlHandler<?> handler = createHandler(criteria);
- handlers.add(handler);
+ if (handler != null) {
+ handlers.add(handler);
+ }
}
Collections.sort(handlers, comparator);
return handlers;
@@ -67,10 +66,13 @@ public class SqlHandlerFactoryImpl implements SqlHandlerFactory {
public SqlHandler<?> createHandler(Criteria criteria) throws OseeCoreException {
Class<? extends Criteria> key = criteria.getClass();
Class<? extends SqlHandler> item = handleMap.get(key);
- return createHandler(criteria, item);
+ SqlHandler<?> toReturn = null;
+ if (item != null) {
+ toReturn = createHandler(criteria, item);
+ }
+ return toReturn;
}
- @SuppressWarnings("unchecked")
private <C extends Criteria, H extends SqlHandler<C>> SqlHandler<C> createHandler(C criteria, Class<H> item) throws OseeCoreException {
SqlHandler<C> handler = null;
try {
@@ -83,19 +85,10 @@ public class SqlHandlerFactoryImpl implements SqlHandlerFactory {
handler.setIdentityService(idService);
handler.setLogger(logger);
- if (factoryMap != null) {
- DataPostProcessorFactory<C> factory = (DataPostProcessorFactory<C>) factoryMap.get(item);
- if (factory != null) {
- HasDataPostProcessorFactory<C> hasFactory = (HasDataPostProcessorFactory<C>) handler;
- hasFactory.setDataPostProcessorFactory(factory);
- }
- }
-
- if (tagProcessor != null) {
- if (handler instanceof HasTagProcessor) {
- ((HasTagProcessor) handler).setTagProcessor(tagProcessor);
- }
+ if (handler instanceof HasTagProcessor) {
+ ((HasTagProcessor) handler).setTagProcessor(tagProcessor);
}
return handler;
}
+
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/ComodificationCheck.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/ComodificationCheck.java
index bb330ec608..9ff1ef4778 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/ComodificationCheck.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/ComodificationCheck.java
@@ -18,16 +18,13 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeStateException;
import org.eclipse.osee.orcs.OrcsSession;
import org.eclipse.osee.orcs.core.ds.ArtifactData;
-import org.eclipse.osee.orcs.core.ds.ArtifactDataHandler;
import org.eclipse.osee.orcs.core.ds.AttributeData;
-import org.eclipse.osee.orcs.core.ds.AttributeDataHandler;
import org.eclipse.osee.orcs.core.ds.DataLoader;
import org.eclipse.osee.orcs.core.ds.DataLoaderFactory;
-import org.eclipse.osee.orcs.core.ds.LoadDataHandler;
+import org.eclipse.osee.orcs.core.ds.LoadDataHandlerAdapter;
import org.eclipse.osee.orcs.core.ds.OrcsData;
import org.eclipse.osee.orcs.core.ds.OrcsVisitor;
import org.eclipse.osee.orcs.core.ds.RelationData;
-import org.eclipse.osee.orcs.core.ds.RelationDataHandler;
import org.eclipse.osee.orcs.core.ds.TransactionData;
/**
@@ -57,7 +54,7 @@ public class ComodificationCheck implements TransactionProcessor {
}
}
- private final class OnLoadChecker implements LoadDataHandler, OrcsVisitor {
+ private final class OnLoadChecker extends LoadDataHandlerAdapter implements OrcsVisitor {
private final Map<Integer, ArtifactData> artifacts = new HashMap<Integer, ArtifactData>();
private final Map<Integer, AttributeData> attributes = new HashMap<Integer, AttributeData>();
@@ -106,51 +103,22 @@ public class ComodificationCheck implements TransactionProcessor {
}
@Override
- public ArtifactDataHandler getArtifactDataHandler() {
- return new ArtifactDataHandler() {
-
- @Override
- public void onData(ArtifactData data) throws OseeCoreException {
- ArtifactData modified = artifacts.get(data.getLocalId());
- checkCoModified(data, modified);
- }
- };
+ public void onData(ArtifactData data) throws OseeCoreException {
+ ArtifactData modified = artifacts.get(data.getLocalId());
+ checkCoModified(data, modified);
}
@Override
- public RelationDataHandler getRelationDataHandler() {
- return new RelationDataHandler() {
-
- @Override
- public void onData(RelationData data) throws OseeCoreException {
- RelationData modified = relations.get(data.getLocalId());
- checkCoModified(data, modified);
- }
- };
+ public void onData(RelationData data) throws OseeCoreException {
+ RelationData modified = relations.get(data.getLocalId());
+ checkCoModified(data, modified);
}
@Override
- public AttributeDataHandler getAttributeDataHandler() {
- return new AttributeDataHandler() {
-
- @Override
- public void onData(AttributeData data) throws OseeCoreException {
- AttributeData modified = attributes.get(data.getLocalId());
- checkCoModified(data, modified);
- }
- };
+ public void onData(AttributeData data) throws OseeCoreException {
+ AttributeData modified = attributes.get(data.getLocalId());
+ checkCoModified(data, modified);
}
-
- @Override
- public void onLoadStart() {
- // Do Nothing
- }
-
- @Override
- public void onLoadEnd() {
- // Do Nothing
- }
-
}
}

Back to the top