Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmisinco2013-12-09 10:46:25 -0500
committerjmisinco2013-12-12 15:38:09 -0500
commitb080a40051b990baea9340fbd326b1bd823cfb63 (patch)
treec8ea64b216854feaac7e39fbc154f05caef25789 /plugins
parentfe5e2d94c5a592a23ddbd7b6ae5ff60f9a449d49 (diff)
downloadorg.eclipse.osee-b080a40051b990baea9340fbd326b1bd823cfb63.tar.gz
org.eclipse.osee-b080a40051b990baea9340fbd326b1bd823cfb63.tar.xz
org.eclipse.osee-b080a40051b990baea9340fbd326b1bd823cfb63.zip
feature[ats_EPQBU]: Add support for match locations to search REST API
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/health/ValidateAtsIds.java2
-rw-r--r--plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactQueryTest.java6
-rw-r--r--plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/data/DataTestSuite.java2
-rw-r--r--plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/data/SearchResponseTest.java150
-rw-r--r--plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/mocks/DataAsserts.java39
-rw-r--r--plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/DataTranslationServiceFactoryTest.java5
-rw-r--r--plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/SearchRequestTranslatorTest.java83
-rw-r--r--plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/SearchResponseTranslatorTest.java69
-rw-r--r--plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/TranslationTestSuite.java2
-rw-r--r--plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/SearchResponse.java256
-rw-r--r--plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DataTranslationServiceFactory.java5
-rw-r--r--plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/SearchRequestTranslator.java101
-rw-r--r--plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/SearchResponseTranslator.java130
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/OseeServerContext.java1
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/MatchLocation.java3
-rw-r--r--plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/SearchEngineServlet.java120
-rw-r--r--plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/internal/ServletRegistrationHandler.java3
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/search/SearchRequestTest.java (renamed from plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/data/SearchRequestTest.java)24
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactMatch.java22
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java76
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQueryBuilder.java10
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/HttpArtifactQuery.java79
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/QueryBuilderArtifact.java2
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/SearchOptions.java (renamed from plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/SearchOptions.java)2
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/SearchRequest.java (renamed from plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/SearchRequest.java)2
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/QuickSearchView.java4
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/RemoteArtifactSearch.java6
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/QueryBuilder.java11
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryBuilderImpl.java10
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryExecutor.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryExecutorV1.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/RequestType.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchMatch.java64
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchResponse.java14
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchResult.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/ArtifactSearch_V1.java57
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/PredicateHandlerUtil.java2
-rw-r--r--plugins/org.eclipse.osee.x.server.integration.tests/src/org/eclipse/osee/x/server/integration/tests/performance/OseeClientQueryTest.java39
38 files changed, 282 insertions, 1131 deletions
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/health/ValidateAtsIds.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/health/ValidateAtsIds.java
index 48ffb1b0f5..417fc1621c 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/health/ValidateAtsIds.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/health/ValidateAtsIds.java
@@ -96,7 +96,7 @@ public class ValidateAtsIds extends AbstractBlam {
SkynetTransaction tx = null;
QueryBuilderArtifact builder = ArtifactQuery.createQueryBuilder(CoreBranches.COMMON);
builder.andIsOfType(toCheck);
- List<Integer> result = builder.getSearchResult().getIds();
+ List<Integer> result = builder.getIds();
for (int i = startNumber; i < result.size(); i += partitionSize) {
if (persist) {
tx = TransactionManager.createTransaction(CoreBranches.COMMON, "Update AtsId Attribute");
diff --git a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactQueryTest.java b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactQueryTest.java
index be07c2d757..05d06ab7b6 100644
--- a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactQueryTest.java
+++ b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactQueryTest.java
@@ -28,8 +28,6 @@ import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.enums.DeletionFlag;
import org.eclipse.osee.framework.core.exception.ArtifactDoesNotExist;
-import org.eclipse.osee.framework.core.message.SearchOptions;
-import org.eclipse.osee.framework.core.message.SearchRequest;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.TransactionRecord;
import org.eclipse.osee.framework.core.model.cache.BranchFilter;
@@ -47,6 +45,8 @@ import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactSearchCriteria;
import org.eclipse.osee.framework.skynet.core.artifact.search.AttributeCriteria;
import org.eclipse.osee.framework.skynet.core.artifact.search.QueryOptions;
+import org.eclipse.osee.framework.skynet.core.artifact.search.SearchOptions;
+import org.eclipse.osee.framework.skynet.core.artifact.search.SearchRequest;
import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager;
import org.junit.Assert;
import org.junit.Rule;
@@ -249,7 +249,7 @@ public class ArtifactQueryTest {
options.setIsSearchAll(true);
options.setCaseSensive(false);
SearchRequest request = new SearchRequest(DemoBranches.SAW_Bld_1, "robot", options);
- List<ArtifactMatch> matches = ArtifactQuery.getArtifactMatchesFromAttributeKeywords(request);
+ Iterable<ArtifactMatch> matches = ArtifactQuery.getArtifactMatchesFromAttributeKeywords(request);
boolean found = false;
for (ArtifactMatch match : matches) {
if (match.getArtifact().getName().equals("Read-Write Minimum Rate")) {
diff --git a/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/data/DataTestSuite.java b/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/data/DataTestSuite.java
index 9d6ecb2f08..22abe7ac5b 100644
--- a/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/data/DataTestSuite.java
+++ b/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/data/DataTestSuite.java
@@ -20,8 +20,6 @@ import org.junit.runners.Suite;
BranchCommitResponseTest.class,
CacheUpdateRequestTest.class,
PurgeBranchRequestTest.class,
- SearchRequestTest.class,
- SearchResponseTest.class,
TransactionCacheUpdateResponseTest.class,})
/**
* @author Roberto E. Escobar
diff --git a/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/data/SearchResponseTest.java b/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/data/SearchResponseTest.java
deleted file mode 100644
index a6b75dbbfd..0000000000
--- a/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/data/SearchResponseTest.java
+++ /dev/null
@@ -1,150 +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.framework.core.message.test.data;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import org.eclipse.osee.framework.core.message.SearchResponse;
-import org.eclipse.osee.framework.core.message.SearchResponse.ArtifactMatchMetaData;
-import org.eclipse.osee.framework.core.message.SearchResponse.AttributeMatchMetaData;
-import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
-import org.eclipse.osee.framework.jdk.core.util.Compare;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * Test Case for {@link SearchResponse}
- *
- * @author Roberto E. Escobar
- */
-public class SearchResponseTest {
-
- @Test
- public void testSetGetErrorMessage() {
- SearchResponse searchResponse = new SearchResponse();
- Assert.assertEquals("", searchResponse.getErrorMessage());
-
- searchResponse.setErrorMessage(null);
- Assert.assertEquals("", searchResponse.getErrorMessage());
-
- searchResponse.setErrorMessage("An error");
- Assert.assertEquals("An error", searchResponse.getErrorMessage());
- }
-
- @Test
- public void testSearchTags() {
- SearchResponse searchResponse = new SearchResponse();
- Assert.assertEquals(0, searchResponse.getSearchTags().size());
-
- Map<String, Long> tags = searchResponse.getSearchTags();
- tags.put("Hello", 45L);
- tags.put("dude", 54L);
- tags.put("Hello", 63L);
-
- Assert.assertEquals(2, searchResponse.getSearchTags().size());
- Set<String> words = tags.keySet();
- Assert.assertEquals(2, words.size());
- Iterator<String> iterator = words.iterator();
- Assert.assertEquals("Hello", iterator.next());
- Assert.assertEquals("dude", iterator.next());
-
- Collection<Long> codes = tags.values();
- Assert.assertEquals(2, codes.size());
- Iterator<Long> codeIterator = codes.iterator();
- Assert.assertEquals(63L, (long) codeIterator.next());
- Assert.assertEquals(54L, (long) codeIterator.next());
- }
-
- @Test
- public void testAddMatch() {
- MatchLocation loc1 = new MatchLocation(3, 6);
- MatchLocation loc2 = new MatchLocation(11, 20);
-
- SearchResponse searchResponse = new SearchResponse();
- searchResponse.add(1, 2, 3);
- searchResponse.add(1, 2, 4);
- searchResponse.add(1, 2, 5);
- searchResponse.add(1, 2, 5);
-
- searchResponse.add(2, 1, 6);
- searchResponse.add(2, 1, 8);
- searchResponse.add(2, 3, 8, Arrays.asList(loc1, loc2));
- searchResponse.add(2, 3, 8, 4, 5);
- searchResponse.add(2, 3, 8, 4, 5);
-
- Assert.assertEquals(8, searchResponse.matches());
-
- Assert.assertFalse(Compare.isDifferent(Arrays.asList(1L, 2L), searchResponse.getBranchIds()));
-
- // Check Branch 1
- Collection<Integer> data1 = searchResponse.getArtifactIds(1);
- Assert.assertEquals(1, data1.size());
- Assert.assertEquals(2, (int) data1.iterator().next());
-
- Collection<ArtifactMatchMetaData> arts1 = searchResponse.getArtifacts(1);
- Assert.assertEquals(1, arts1.size());
-
- ArtifactMatchMetaData match1 = searchResponse.getArtifactMatch(1, 2);
- Assert.assertNotNull(match1);
-
- Assert.assertEquals(arts1.iterator().next(), match1);
- checkArtMatch(match1, 1, 2, 3L, 4L, 5L);
-
- // Check Branch 2
- Collection<Integer> data2 = searchResponse.getArtifactIds(2);
- Assert.assertEquals(2, data2.size());
-
- Collection<ArtifactMatchMetaData> arts = searchResponse.getArtifacts(2);
- Assert.assertEquals(2, arts.size());
-
- ArtifactMatchMetaData match2 = searchResponse.getArtifactMatch(2, 1);
- Assert.assertNotNull(match2);
-
- ArtifactMatchMetaData match3 = searchResponse.getArtifactMatch(2, 3);
- Assert.assertNotNull(match3);
-
- Assert.assertFalse(Compare.isDifferent(Arrays.asList(match2, match3), arts));
-
- checkArtMatch(match2, 2, 1, 6L, 8L);
-
- Assert.assertEquals(3, match3.getArtId());
- Assert.assertEquals(2, match3.getBranchId());
- Assert.assertEquals(3, match3.matches());
-
- AttributeMatchMetaData attrMatch = match3.getAttributeMatch(8L);
- checkAttrMatch(attrMatch, 3, 8L, loc1, loc2, new MatchLocation(4, 5));
-
- Assert.assertFalse(Compare.isDifferent(Arrays.asList(match1, match2, match3), searchResponse.getAll()));
- }
-
- private static void checkArtMatch(ArtifactMatchMetaData data, int expectedBranchId, int expectedArtId, long... attrs) {
- Assert.assertEquals(expectedArtId, data.getArtId());
- Assert.assertEquals(expectedBranchId, data.getBranchId());
- Assert.assertEquals(attrs.length, data.matches());
- Assert.assertEquals(attrs.length, data.size());
- for (long attr : attrs) {
- AttributeMatchMetaData attrData = data.getAttributeMatch(attr);
- Assert.assertNotNull("Can't get attrData id: " + attr, attrData);
- checkAttrMatch(attrData, expectedArtId, attr);
- }
- }
-
- private static void checkAttrMatch(AttributeMatchMetaData data, int expectedArtId, long expectedGammaId, MatchLocation... expectedLocs) {
- Assert.assertEquals(expectedArtId, data.getArtId());
- Assert.assertEquals(expectedGammaId, data.getGammaId());
- Collection<MatchLocation> actualLocs = data.getLocations();
- Assert.assertEquals(expectedLocs.length, actualLocs.size());
- Assert.assertFalse(Compare.isDifferent(Arrays.asList(expectedLocs), actualLocs));
- }
-}
diff --git a/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/mocks/DataAsserts.java b/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/mocks/DataAsserts.java
index eabb0d7396..123457c588 100644
--- a/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/mocks/DataAsserts.java
+++ b/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/mocks/DataAsserts.java
@@ -21,9 +21,6 @@ import org.eclipse.osee.framework.core.message.ChangeBranchStateRequest;
import org.eclipse.osee.framework.core.message.ChangeBranchTypeRequest;
import org.eclipse.osee.framework.core.message.DatastoreInitRequest;
import org.eclipse.osee.framework.core.message.PurgeBranchRequest;
-import org.eclipse.osee.framework.core.message.SearchOptions;
-import org.eclipse.osee.framework.core.message.SearchRequest;
-import org.eclipse.osee.framework.core.message.SearchResponse;
import org.eclipse.osee.framework.core.model.AbstractOseeType;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.IBasicArtifact;
@@ -36,7 +33,6 @@ import org.eclipse.osee.framework.core.model.change.ChangeVersion;
import org.eclipse.osee.framework.core.model.type.AttributeType;
import org.eclipse.osee.framework.core.model.type.RelationType;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.framework.jdk.core.util.Compare;
import org.junit.Assert;
@@ -282,39 +278,4 @@ public final class DataAsserts {
Assert.assertEquals(expected.isUseFileSpecifiedSchemas(), actual.isUseFileSpecifiedSchemas());
}
- public static void assertEquals(SearchRequest expected, SearchRequest actual) {
- if (expected == null) {
- Assert.assertNull(actual);
- } else {
- Assert.assertEquals(expected.getBranch(), actual.getBranch());
- Assert.assertEquals(expected.getRawSearch(), actual.getRawSearch());
- assertEquals(expected.getOptions(), actual.getOptions());
- }
- }
-
- public static void assertEquals(SearchOptions expected, SearchOptions actual) {
- if (expected == null) {
- Assert.assertNull(actual);
- } else {
- Assert.assertEquals(expected.isSearchAll(), actual.isSearchAll());
- Assert.assertEquals(expected.isCaseSensitive(), actual.isCaseSensitive());
- Assert.assertEquals(expected.isFindAllLocationsEnabled(), actual.isFindAllLocationsEnabled());
- Assert.assertEquals(expected.getDeletionFlag(), actual.getDeletionFlag());
- Assert.assertEquals(expected.isMatchWordOrder(), actual.isMatchWordOrder());
-
- Assert.assertTrue(Collections.isEqual(expected.getAttributeTypeFilter(), actual.getAttributeTypeFilter()));
- }
- }
-
- public static void assertEquals(SearchResponse expected, SearchResponse actual) {
- if (expected == null) {
- Assert.assertNull(actual);
- } else {
- Assert.assertEquals(expected.getErrorMessage(), actual.getErrorMessage());
- Assert.assertFalse(Compare.isDifferent(expected.getSearchTags(), actual.getSearchTags()));
- Assert.assertEquals(expected.matches(), actual.matches());
- Assert.assertFalse(Compare.isDifferent(expected.getAll(), actual.getAll()));
- }
- }
-
}
diff --git a/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/DataTranslationServiceFactoryTest.java b/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/DataTranslationServiceFactoryTest.java
index 1b86125fd3..fe5e0293cd 100644
--- a/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/DataTranslationServiceFactoryTest.java
+++ b/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/DataTranslationServiceFactoryTest.java
@@ -31,8 +31,6 @@ import org.eclipse.osee.framework.core.message.internal.translation.OseeEnumType
import org.eclipse.osee.framework.core.message.internal.translation.OseeImportModelRequestTranslator;
import org.eclipse.osee.framework.core.message.internal.translation.OseeImportModelResponseTranslator;
import org.eclipse.osee.framework.core.message.internal.translation.RelationTypeCacheUpdateResponseTranslator;
-import org.eclipse.osee.framework.core.message.internal.translation.SearchRequestTranslator;
-import org.eclipse.osee.framework.core.message.internal.translation.SearchResponseTranslator;
import org.eclipse.osee.framework.core.message.internal.translation.TableDataTranslator;
import org.eclipse.osee.framework.core.message.internal.translation.TransactionCacheUpdateResponseTranslator;
import org.eclipse.osee.framework.core.message.internal.translation.TransactionRecordTranslator;
@@ -98,9 +96,6 @@ public class DataTranslationServiceFactoryTest {
checkExists(srvc, DatastoreInitRequestTranslator.class, CoreTranslatorId.OSEE_DATASTORE_INIT_REQUEST);
- checkExists(srvc, SearchRequestTranslator.class, CoreTranslatorId.SEARCH_REQUEST);
- checkExists(srvc, SearchResponseTranslator.class, CoreTranslatorId.SEARCH_RESPONSE);
-
srvc.stop();
}
diff --git a/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/SearchRequestTranslatorTest.java b/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/SearchRequestTranslatorTest.java
deleted file mode 100644
index 10a634a38b..0000000000
--- a/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/SearchRequestTranslatorTest.java
+++ /dev/null
@@ -1,83 +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.framework.core.message.test.translation;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
-import org.eclipse.osee.framework.core.enums.CoreBranches;
-import org.eclipse.osee.framework.core.enums.DeletionFlag;
-import org.eclipse.osee.framework.core.message.SearchOptions;
-import org.eclipse.osee.framework.core.message.SearchRequest;
-import org.eclipse.osee.framework.core.message.internal.translation.SearchRequestTranslator;
-import org.eclipse.osee.framework.core.message.test.mocks.DataAsserts;
-import org.eclipse.osee.framework.core.translation.ITranslator;
-import org.junit.Assert;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-/**
- * Test Case For {@link SearchRequestTranslator}
- *
- * @author Roberto E. Escobar
- */
-@RunWith(Parameterized.class)
-public class SearchRequestTranslatorTest extends BaseTranslatorTest<SearchRequest> {
-
- public SearchRequestTranslatorTest(SearchRequest data, ITranslator<SearchRequest> translator) {
- super(data, translator);
- }
-
- @Override
- protected void checkEquals(SearchRequest expected, SearchRequest actual) {
- Assert.assertNotSame(expected, actual);
- DataAsserts.assertEquals(expected, actual);
- }
-
- @Parameters
- public static Collection<Object[]> data() {
- ITranslator<SearchRequest> translator = new SearchRequestTranslator();
- List<Object[]> data = new ArrayList<Object[]>();
-
- SearchOptions options = new SearchOptions();
- data.add(new Object[] {new SearchRequest(CoreBranches.COMMON, "", options), translator});
-
- options = new SearchOptions();
- options.setDeletedIncluded(DeletionFlag.INCLUDE_DELETED);
- options.setCaseSensive(true);
- options.setFindAllLocationsEnabled(false);
- options.setMatchWordOrder(false);
- options.setAttributeTypeFilter(CoreAttributeTypes.Active);
-
- data.add(new Object[] {
- new SearchRequest(CoreBranches.SYSTEM_ROOT, "a search &&!@#$%!%@!$^!$^!.+", options),
- translator});
-
- options = new SearchOptions();
- options.setDeletedIncluded(DeletionFlag.EXCLUDE_DELETED);
- options.setCaseSensive(false);
- options.setFindAllLocationsEnabled(true);
- options.setMatchWordOrder(false);
- options.setAttributeTypeFilter(CoreAttributeTypes.Afha, CoreAttributeTypes.Annotation);
- data.add(new Object[] {new SearchRequest(CoreBranches.SYSTEM_ROOT, "a search string", options), translator});
-
- options = new SearchOptions();
- options.setDeletedIncluded(DeletionFlag.INCLUDE_DELETED);
- options.setCaseSensive(false);
- options.setFindAllLocationsEnabled(false);
- options.setMatchWordOrder(true);
- options.setAttributeTypeFilter(CoreAttributeTypes.ContentUrl, CoreAttributeTypes.Country);
- data.add(new Object[] {new SearchRequest(CoreBranches.COMMON, "one more", options), translator});
- return data;
- }
-}
diff --git a/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/SearchResponseTranslatorTest.java b/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/SearchResponseTranslatorTest.java
deleted file mode 100644
index d338b1bd1a..0000000000
--- a/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/SearchResponseTranslatorTest.java
+++ /dev/null
@@ -1,69 +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.framework.core.message.test.translation;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import org.eclipse.osee.framework.core.message.SearchResponse;
-import org.eclipse.osee.framework.core.message.internal.translation.SearchResponseTranslator;
-import org.eclipse.osee.framework.core.message.test.mocks.DataAsserts;
-import org.eclipse.osee.framework.core.translation.ITranslator;
-import org.junit.Assert;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-/**
- * Test Case For {@link SearchResponseTranslator}
- *
- * @author Roberto E. Escobar
- */
-@RunWith(Parameterized.class)
-public class SearchResponseTranslatorTest extends BaseTranslatorTest<SearchResponse> {
-
- public SearchResponseTranslatorTest(SearchResponse data, ITranslator<SearchResponse> translator) {
- super(data, translator);
- }
-
- @Override
- protected void checkEquals(SearchResponse expected, SearchResponse actual) {
- Assert.assertNotSame(expected, actual);
- DataAsserts.assertEquals(expected, actual);
- }
-
- @Parameters
- public static Collection<Object[]> data() {
- ITranslator<SearchResponse> translator = new SearchResponseTranslator();
- List<Object[]> data = new ArrayList<Object[]>();
- createTest(data, translator, null, false, false);
- createTest(data, translator, "An Error", false, true);
- createTest(data, translator, null, true, true);
- return data;
- }
-
- private static void createTest(Collection<Object[]> data, ITranslator<SearchResponse> translator, String errorMessage, boolean hasSearchTags, boolean addMatchData) {
- SearchResponse response = new SearchResponse();
- response.setErrorMessage(errorMessage);
-
- if (hasSearchTags) {
- response.getSearchTags().put("one", -123141L);
- response.getSearchTags().put("two", -123141L);
- }
- if (addMatchData) {
- response.add(0, 1, 1);
- response.add(0, 1, 2);
- response.add(1, 2, 3, 1, 2);
- response.add(1, 3, 4, 3, 4);
- }
- data.add(new Object[] {response, translator});
- }
-}
diff --git a/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/TranslationTestSuite.java b/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/TranslationTestSuite.java
index cf45f1acca..e3eca0bab2 100644
--- a/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/TranslationTestSuite.java
+++ b/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/translation/TranslationTestSuite.java
@@ -26,8 +26,6 @@ import org.junit.runners.Suite;
DataTranslationServiceTest.class,
OseeImportModelRequestTranslatorTest.class,
OseeImportModelResponseTranslatorTest.class,
- SearchRequestTranslatorTest.class,
- SearchResponseTranslatorTest.class,
TableDataTranslatorTest.class,
TransactionCacheUpdateResponseTranslatorTest.class,
TransactionRecordTranslatorTest.class,
diff --git a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/SearchResponse.java b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/SearchResponse.java
deleted file mode 100644
index 8f407744ea..0000000000
--- a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/SearchResponse.java
+++ /dev/null
@@ -1,256 +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.framework.core.message;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Set;
-import org.eclipse.osee.framework.jdk.core.type.CompositeKeyHashMap;
-import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
-import org.eclipse.osee.framework.jdk.core.type.Pair;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-
-/**
- * @author Roberto E. Escobar
- */
-public class SearchResponse {
-
- private final Map<String, Long> searchTags = new LinkedHashMap<String, Long>();
- private final CompositeKeyHashMap<Long, Integer, ArtifactMatchMetaData> data =
- new CompositeKeyHashMap<Long, Integer, ArtifactMatchMetaData>();
-
- private String errorMessage;
-
- public SearchResponse() {
- this.errorMessage = Strings.emptyString();
- }
-
- public String getErrorMessage() {
- return errorMessage;
- }
-
- public void setErrorMessage(String errorMessage) {
- this.errorMessage = errorMessage != null ? errorMessage : Strings.emptyString();
- }
-
- public Map<String, Long> getSearchTags() {
- return searchTags;
- }
-
- public AttributeMatchMetaData add(long branchId, int artId, long gammaId) {
- ArtifactMatchMetaData artifact = getOrCreateArtifactMatch(branchId, artId);
- return artifact.getOrCreate(artId, gammaId);
- }
-
- public void add(long branchId, int artId, long gammaId, int startPosition, int endPosition) {
- AttributeMatchMetaData attribute = add(branchId, artId, gammaId);
- attribute.addLocation(startPosition, endPosition);
- }
-
- public void add(long branchId, int artId, long gammaId, Collection<MatchLocation> matches) {
- AttributeMatchMetaData attribute = add(branchId, artId, gammaId);
- attribute.addLocations(matches);
- }
-
- private ArtifactMatchMetaData getOrCreateArtifactMatch(long branchId, int artId) {
- ArtifactMatchMetaData artifact = getArtifactMatch(branchId, artId);
- if (artifact == null) {
- artifact = new ArtifactMatchMetaData(branchId, artId);
- data.put(branchId, artId, artifact);
- }
- return artifact;
- }
-
- public Collection<ArtifactMatchMetaData> getAll() {
- return data.values();
- }
-
- public int matches() {
- int count = 0;
- for (ArtifactMatchMetaData meta : data.values()) {
- count += meta.matches();
- }
- return count;
- }
-
- public Set<Long> getBranchIds() {
- Set<Long> branchIds = new HashSet<Long>();
- for (Pair<Long, Integer> entry : data.getEnumeratedKeys()) {
- branchIds.add(entry.getFirst());
- }
- return branchIds;
- }
-
- public Collection<Integer> getArtifactIds(long branchId) {
- return data.getKeyedValues(branchId).keySet();
- }
-
- public Collection<ArtifactMatchMetaData> getArtifacts(long branchId) {
- return data.getValues(branchId);
- }
-
- public ArtifactMatchMetaData getArtifactMatch(long branchId, int artId) {
- return data.get(branchId, artId);
- }
-
- public boolean isEmpty() {
- return data.isEmpty();
- }
-
- public static final class ArtifactMatchMetaData {
- private final int artId;
- private final Long branchId;
- private final Map<Long, AttributeMatchMetaData> attributeMatch = new HashMap<Long, AttributeMatchMetaData>();
-
- public ArtifactMatchMetaData(long branchId, int artId) {
- this.branchId = branchId;
- this.artId = artId;
- }
-
- public int getArtId() {
- return artId;
- }
-
- public long getBranchId() {
- return branchId;
- }
-
- public Collection<AttributeMatchMetaData> getAll() {
- return attributeMatch.values();
- }
-
- AttributeMatchMetaData getOrCreate(int artId, Long gammaId) {
- AttributeMatchMetaData attribute = getAttributeMatch(gammaId);
- if (attribute == null) {
- attribute = new AttributeMatchMetaData(artId, gammaId);
- attributeMatch.put(gammaId, attribute);
- }
- return attribute;
- }
-
- public AttributeMatchMetaData getAttributeMatch(Long gammaId) {
- return attributeMatch.get(gammaId);
- }
-
- public int size() {
- return attributeMatch.size();
- }
-
- public int matches() {
- int count = 0;
- for (AttributeMatchMetaData match : attributeMatch.values()) {
- count += match.matches();
- }
- return count;
- }
-
- @Override
- public int hashCode() {
- final int prime = 11;
- int result = 1;
- result = prime * result + (artId * 53);
- result = prime * result + (branchId.hashCode() * 11);
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- ArtifactMatchMetaData other = (ArtifactMatchMetaData) obj;
- if (artId != other.artId) {
- return false;
- }
- if (branchId != other.branchId) {
- return false;
- }
- return true;
- }
-
- }
-
- public static final class AttributeMatchMetaData {
- private final int artId;
- private final long gammaId;
- private final Set<MatchLocation> matches = new HashSet<MatchLocation>(0);
-
- public AttributeMatchMetaData(int artId, long gammaId) {
- this.artId = artId;
- this.gammaId = gammaId;
- }
-
- public int getArtId() {
- return artId;
- }
-
- public long getGammaId() {
- return gammaId;
- }
-
- public void addLocation(int start, int stop) {
- matches.add(new MatchLocation(start, stop));
- }
-
- public void addLocations(Collection<MatchLocation> locations) {
- matches.addAll(locations);
- }
-
- public Collection<MatchLocation> getLocations() {
- return matches;
- }
-
- public int matches() {
- int locData = matches.size();
- return locData == 0 ? 1 : locData;
- }
-
- @Override
- public int hashCode() {
- final int prime = 17;
- int result = 1;
- result = prime * result + (int) (gammaId ^ (gammaId >>> 32));
- result = prime * result + (artId * 53);
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- AttributeMatchMetaData other = (AttributeMatchMetaData) obj;
- if (gammaId != other.gammaId) {
- return false;
- }
- if (artId != other.artId) {
- return false;
- }
- return true;
- }
- }
-
-}
diff --git a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DataTranslationServiceFactory.java b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DataTranslationServiceFactory.java
index d7a3507c66..b43548fe11 100644
--- a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DataTranslationServiceFactory.java
+++ b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DataTranslationServiceFactory.java
@@ -31,8 +31,6 @@ import org.eclipse.osee.framework.core.message.internal.translation.OseeImportMo
import org.eclipse.osee.framework.core.message.internal.translation.OseeImportModelResponseTranslator;
import org.eclipse.osee.framework.core.message.internal.translation.PurgeBranchRequestTranslator;
import org.eclipse.osee.framework.core.message.internal.translation.RelationTypeCacheUpdateResponseTranslator;
-import org.eclipse.osee.framework.core.message.internal.translation.SearchRequestTranslator;
-import org.eclipse.osee.framework.core.message.internal.translation.SearchResponseTranslator;
import org.eclipse.osee.framework.core.message.internal.translation.TableDataTranslator;
import org.eclipse.osee.framework.core.message.internal.translation.TransactionCacheUpdateResponseTranslator;
import org.eclipse.osee.framework.core.message.internal.translation.TransactionRecordTranslator;
@@ -97,8 +95,5 @@ public class DataTranslationServiceFactory {
service.addTranslator(new TableDataTranslator(), CoreTranslatorId.TABLE_DATA);
service.addTranslator(new DatastoreInitRequestTranslator(), CoreTranslatorId.OSEE_DATASTORE_INIT_REQUEST);
-
- service.addTranslator(new SearchRequestTranslator(), CoreTranslatorId.SEARCH_REQUEST);
- service.addTranslator(new SearchResponseTranslator(), CoreTranslatorId.SEARCH_RESPONSE);
}
}
diff --git a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/SearchRequestTranslator.java b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/SearchRequestTranslator.java
deleted file mode 100644
index 8213d6bebd..0000000000
--- a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/SearchRequestTranslator.java
+++ /dev/null
@@ -1,101 +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.framework.core.message.internal.translation;
-
-import java.util.Collection;
-import org.eclipse.osee.framework.core.data.IAttributeType;
-import org.eclipse.osee.framework.core.data.IOseeBranch;
-import org.eclipse.osee.framework.core.data.TokenFactory;
-import org.eclipse.osee.framework.core.enums.DeletionFlag;
-import org.eclipse.osee.framework.core.message.SearchOptions;
-import org.eclipse.osee.framework.core.message.SearchRequest;
-import org.eclipse.osee.framework.core.translation.ITranslator;
-import org.eclipse.osee.framework.jdk.core.type.PropertyStore;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-
-/**
- * @author Roberto E. Escobar
- */
-public class SearchRequestTranslator implements ITranslator<SearchRequest> {
-
- private static enum Entry {
- BRANCH_GUID,
- BRANCH_NAME,
- RAW_SEARCH,
- OPTION_IS_CASE_SENSITIVE,
- OPTION_MATCH_WORD_ORDER,
- OPTION_IS_INCLUDE_DELETED,
- OPTION_FIND_ALL_LOCATIONS,
- OPTION_ATTRIBUTE_TYPE_FILTER_GUIDS,
- OPTION_ATTRIBUTE_TYPE_FILTER_NAMES
- }
-
- @Override
- public SearchRequest convert(PropertyStore store) {
- String guid = store.get(Entry.BRANCH_GUID.name());
- String name = store.get(Entry.BRANCH_NAME.name());
- IOseeBranch branch = TokenFactory.createBranch(guid, name);
-
- String rawSearch = store.get(Entry.RAW_SEARCH.name());
- SearchOptions options = new SearchOptions();
-
- options.setCaseSensive(store.getBoolean(Entry.OPTION_IS_CASE_SENSITIVE.name()));
- options.setFindAllLocationsEnabled(store.getBoolean(Entry.OPTION_FIND_ALL_LOCATIONS.name()));
- options.setMatchWordOrder(store.getBoolean(Entry.OPTION_MATCH_WORD_ORDER.name()));
-
- boolean areDeletedAllowed = store.getBoolean(Entry.OPTION_IS_INCLUDE_DELETED.name());
- options.setDeletedIncluded(DeletionFlag.allowDeleted(areDeletedAllowed));
-
- String[] typeFilterGuids = store.getArray(Entry.OPTION_ATTRIBUTE_TYPE_FILTER_GUIDS.name());
- String[] typeFilterNames = store.getArray(Entry.OPTION_ATTRIBUTE_TYPE_FILTER_NAMES.name());
- if (typeFilterGuids.length > 0 && typeFilterNames.length > 0) {
- for (int index = 0; index < typeFilterGuids.length; index++) {
- long id = Long.valueOf(typeFilterGuids[index]);
- name = index < typeFilterNames.length ? typeFilterNames[index] : Strings.emptyString();
- IAttributeType type = TokenFactory.createAttributeType(id, name);
- options.addAttributeTypeFilter(type);
- }
- }
- return new SearchRequest(branch, rawSearch, options);
- }
-
- @Override
- public PropertyStore convert(SearchRequest object) {
- PropertyStore store = new PropertyStore();
- IOseeBranch branch = object.getBranch();
-
- store.put(Entry.BRANCH_GUID.name(), branch.getGuid());
- store.put(Entry.BRANCH_NAME.name(), branch.getName());
-
- store.put(Entry.RAW_SEARCH.name(), object.getRawSearch());
- SearchOptions options = object.getOptions();
- if (options != null) {
- store.put(Entry.OPTION_IS_CASE_SENSITIVE.name(), options.isCaseSensitive());
- store.put(Entry.OPTION_MATCH_WORD_ORDER.name(), options.isMatchWordOrder());
- store.put(Entry.OPTION_IS_INCLUDE_DELETED.name(), options.getDeletionFlag().areDeletedAllowed());
- store.put(Entry.OPTION_FIND_ALL_LOCATIONS.name(), options.isFindAllLocationsEnabled());
-
- Collection<IAttributeType> types = options.getAttributeTypeFilter();
- String[] guids = new String[types.size()];
- String[] names = new String[types.size()];
- int index = 0;
- for (IAttributeType type : types) {
- guids[index] = String.valueOf(type.getGuid());
- names[index] = type.getName();
- index++;
- }
- store.put(Entry.OPTION_ATTRIBUTE_TYPE_FILTER_GUIDS.name(), guids);
- store.put(Entry.OPTION_ATTRIBUTE_TYPE_FILTER_NAMES.name(), names);
-
- }
- return store;
- }
-}
diff --git a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/SearchResponseTranslator.java b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/SearchResponseTranslator.java
deleted file mode 100644
index 2b74cd6c00..0000000000
--- a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/SearchResponseTranslator.java
+++ /dev/null
@@ -1,130 +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.framework.core.message.internal.translation;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Map.Entry;
-import org.eclipse.osee.framework.core.message.SearchResponse;
-import org.eclipse.osee.framework.core.message.SearchResponse.ArtifactMatchMetaData;
-import org.eclipse.osee.framework.core.message.SearchResponse.AttributeMatchMetaData;
-import org.eclipse.osee.framework.core.message.TranslationUtil;
-import org.eclipse.osee.framework.core.translation.ITranslator;
-import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
-import org.eclipse.osee.framework.jdk.core.type.PropertyStore;
-
-/**
- * @author Roberto E. Escobar
- */
-public class SearchResponseTranslator implements ITranslator<SearchResponse> {
-
- private static final int WITH_MATCH_LOCATION_ROW_SIZE = 5;
- private static final int NO_MATCH_LOCATION_ROW_SIZE = 3;
-
- private static enum Key {
- ERROR_MSG,
- SEARCH_TAGS_COUNT,
- SEARCH_TAG,
- MATCH_DATA,
- MATCH_LOCATION,
- MATCH_COUNT
- }
-
- @Override
- public SearchResponse convert(PropertyStore propertyStore) {
- SearchResponse response = new SearchResponse();
- response.setErrorMessage(propertyStore.get(Key.ERROR_MSG.name()));
-
- int count = propertyStore.getInt(Key.MATCH_COUNT.name());
- for (int index = 0; index < count; index++) {
- String key = TranslationUtil.createKey(Key.MATCH_DATA, index);
- int[] data = asIntArray(propertyStore.getArray(key));
- int branchId = data[0];
- int artId = data[1];
- int gammaId = data[2];
- if (data.length == WITH_MATCH_LOCATION_ROW_SIZE) {
- response.add(branchId, artId, gammaId, data[3], data[4]);
- } else {
- response.add(branchId, artId, gammaId);
- }
- }
-
- count = propertyStore.getInt(Key.SEARCH_TAGS_COUNT.name());
- Map<String, Long> codedWords = response.getSearchTags();
- for (int index = 0; index < count; index++) {
- String key = TranslationUtil.createKey(Key.SEARCH_TAG, index);
- String[] data = propertyStore.getArray(key);
- codedWords.put(data[0], Long.parseLong(data[1]));
- }
- return response;
- }
-
- @Override
- public PropertyStore convert(SearchResponse object) {
- PropertyStore store = new PropertyStore();
- store.put(Key.ERROR_MSG.name(), object.getErrorMessage());
- Collection<String[]> data = toArray(object);
- int count = 0;
- for (String[] row : data) {
- String key = TranslationUtil.createKey(Key.MATCH_DATA, count);
- store.put(key, row);
- count++;
- }
- store.put(Key.MATCH_COUNT.name(), data.size());
-
- Map<String, Long> codedWords = object.getSearchTags();
- count = 0;
- for (Entry<String, Long> entry : codedWords.entrySet()) {
- String key = TranslationUtil.createKey(Key.SEARCH_TAG, count);
- store.put(key, new String[] {entry.getKey(), String.valueOf(entry.getValue())});
- count++;
- }
- store.put(Key.SEARCH_TAGS_COUNT.name(), codedWords.size());
- return store;
- }
-
- private int[] asIntArray(String[] data) {
- int[] toReturn = new int[data.length];
- for (int index = 0; index < data.length; index++) {
- toReturn[index] = Integer.valueOf(data[index]);
- }
- return toReturn;
- }
-
- private Collection<String[]> toArray(SearchResponse object) {
- Collection<String[]> toReturn = new ArrayList<String[]>();
- for (ArtifactMatchMetaData artMeta : object.getAll()) {
- long branchId = artMeta.getBranchId();
- for (AttributeMatchMetaData attrMeta : artMeta.getAll()) {
- Collection<MatchLocation> locs = attrMeta.getLocations();
- if (!locs.isEmpty()) {
- for (MatchLocation location : locs) {
- String[] row = new String[WITH_MATCH_LOCATION_ROW_SIZE];
- row[0] = String.valueOf(branchId);
- row[1] = String.valueOf(attrMeta.getArtId());
- row[2] = String.valueOf(attrMeta.getGammaId());
- row[3] = String.valueOf(location.getStartPosition());
- row[4] = String.valueOf(location.getEndPosition());
- toReturn.add(row);
- }
- } else {
- String[] row = new String[NO_MATCH_LOCATION_ROW_SIZE];
- row[0] = String.valueOf(branchId);
- row[1] = String.valueOf(attrMeta.getArtId());
- row[2] = String.valueOf(attrMeta.getGammaId());
- toReturn.add(row);
- }
- }
- }
- return toReturn;
- }
-}
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/OseeServerContext.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/OseeServerContext.java
index 87b8141c80..71ffa8db03 100644
--- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/OseeServerContext.java
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/OseeServerContext.java
@@ -18,7 +18,6 @@ public class OseeServerContext {
private static final String BASE_CONTEXT = "osee";
public static final String PROCESS_CONTEXT = "GET.ARTIFACT"; // For backwards compatibility must remain without base context.
- public static final String SEARCH_CONTEXT = asAbsoluteContext("search");
public static final String MANAGER_CONTEXT = asAbsoluteContext("manager");
public static final String BRANCH_CONTEXT = asAbsoluteContext("branch");
public static final String BRANCH_EXCHANGE_CONTEXT = asAbsoluteContext("branch/exchange");
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/MatchLocation.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/MatchLocation.java
index 0bc6457536..5e8bc5c0ae 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/MatchLocation.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/MatchLocation.java
@@ -10,9 +10,12 @@
*******************************************************************************/
package org.eclipse.osee.framework.jdk.core.type;
+import javax.xml.bind.annotation.XmlRootElement;
+
/**
* @author Roberto E. Escobar
*/
+@XmlRootElement(name = "MatchLocation")
public class MatchLocation {
private int startPosition;
private int endPosition;
diff --git a/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/SearchEngineServlet.java b/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/SearchEngineServlet.java
deleted file mode 100644
index a80059f419..0000000000
--- a/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/SearchEngineServlet.java
+++ /dev/null
@@ -1,120 +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.framework.manager.servlet;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.Collections;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.eclipse.osee.framework.core.data.IAttributeType;
-import org.eclipse.osee.framework.core.enums.CaseType;
-import org.eclipse.osee.framework.core.enums.CoreTranslatorId;
-import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
-import org.eclipse.osee.framework.core.enums.TokenOrderType;
-import org.eclipse.osee.framework.core.message.SearchOptions;
-import org.eclipse.osee.framework.core.message.SearchRequest;
-import org.eclipse.osee.framework.core.message.SearchResponse;
-import org.eclipse.osee.framework.core.model.cache.BranchCache;
-import org.eclipse.osee.framework.core.server.ISessionManager;
-import org.eclipse.osee.framework.core.server.SecureOseeHttpServlet;
-import org.eclipse.osee.framework.core.translation.IDataTranslationService;
-import org.eclipse.osee.framework.jdk.core.type.ResultSet;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.framework.manager.servlet.internal.ApplicationContextFactory;
-import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.ApplicationContext;
-import org.eclipse.osee.orcs.OrcsApi;
-import org.eclipse.osee.orcs.data.ArtifactReadable;
-import org.eclipse.osee.orcs.data.AttributeReadable;
-import org.eclipse.osee.orcs.search.Match;
-import org.eclipse.osee.orcs.search.QueryBuilder;
-import org.eclipse.osee.orcs.search.QueryFactory;
-
-/**
- * @author Roberto E. Escobar
- */
-public class SearchEngineServlet extends SecureOseeHttpServlet {
-
- private static final long serialVersionUID = 3722992788943330970L;
-
- private final IDataTranslationService translationService;
- private final OrcsApi orcsApi;
-
- public SearchEngineServlet(Log logger, ISessionManager sessionManager, IDataTranslationService translationService, OrcsApi orcsApi) {
- super(logger, sessionManager);
- this.translationService = translationService;
- this.orcsApi = orcsApi;
- }
-
- private ApplicationContext getContext(HttpServletRequest req) {
- return ApplicationContextFactory.createContext(getSessionId(req));
- }
-
- @Override
- protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
- try {
- SearchRequest searchRequest =
- translationService.convert(request.getInputStream(), CoreTranslatorId.SEARCH_REQUEST);
- SearchOptions options = searchRequest.getOptions();
-
- TokenOrderType operator = options.isMatchWordOrder() ? TokenOrderType.MATCH_ORDER : TokenOrderType.ANY_ORDER;
- CaseType caseType = options.isCaseSensitive() ? CaseType.MATCH_CASE : CaseType.IGNORE_CASE;
-
- QueryFactory factory = orcsApi.getQueryFactory(getContext(request));
- QueryBuilder builder = factory.fromBranch(searchRequest.getBranch());
- builder.includeDeletedArtifacts(options.getDeletionFlag().areDeletedAllowed());
-
- Collection<IAttributeType> attributeTypes = options.getAttributeTypeFilter();
- if (attributeTypes.isEmpty()) {
- attributeTypes = Collections.singleton(QueryBuilder.ANY_ATTRIBUTE_TYPE);
- }
- builder.and(attributeTypes, searchRequest.getRawSearch(), TokenDelimiterMatch.ANY, operator, caseType);
-
- BranchCache branchCache = orcsApi.getBranchCache();
-
- SearchResponse searchResponse = new SearchResponse();
- if (options.isFindAllLocationsEnabled()) {
- ResultSet<Match<ArtifactReadable, AttributeReadable<?>>> results = builder.getMatches();
- for (Match<ArtifactReadable, AttributeReadable<?>> match : results) {
- ArtifactReadable artifact = match.getItem();
- long branchId = branchCache.getLocalId(artifact.getBranch());
- for (AttributeReadable<?> attribute : match.getElements()) {
- searchResponse.add(branchId, artifact.getLocalId(), attribute.getGammaId(),
- match.getLocation(attribute));
- }
- }
- } else {
- ResultSet<ArtifactReadable> results = builder.getResults();
- for (ArtifactReadable artifact : results) {
- long branchId = branchCache.getLocalId(artifact.getBranch());
- searchResponse.add(branchId, artifact.getLocalId(), -1);
- }
- }
-
- response.setStatus(HttpServletResponse.SC_ACCEPTED);
- response.setContentType("text/xml");
- response.setCharacterEncoding("UTF-8");
-
- InputStream inputStream = translationService.convertToStream(searchResponse, CoreTranslatorId.SEARCH_RESPONSE);
- Lib.inputStreamToOutputStream(inputStream, response.getOutputStream());
-
- } catch (Exception ex) {
- getLogger().error(ex, "Failed to respond to a search engine servlet request [%s]", request.getRequestURL());
- response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
- response.setContentType("text/plain");
- response.getWriter().write(Lib.exceptionToString(ex));
- response.getWriter().flush();
- response.getWriter().close();
- }
- }
-}
diff --git a/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/internal/ServletRegistrationHandler.java b/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/internal/ServletRegistrationHandler.java
index 9d6975cb8d..51cbad0e12 100644
--- a/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/internal/ServletRegistrationHandler.java
+++ b/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/internal/ServletRegistrationHandler.java
@@ -31,7 +31,6 @@ import org.eclipse.osee.framework.manager.servlet.DataServlet;
import org.eclipse.osee.framework.manager.servlet.OseeCacheServlet;
import org.eclipse.osee.framework.manager.servlet.OseeModelServlet;
import org.eclipse.osee.framework.manager.servlet.ResourceManagerServlet;
-import org.eclipse.osee.framework.manager.servlet.SearchEngineServlet;
import org.eclipse.osee.framework.manager.servlet.SearchEngineTaggerServlet;
import org.eclipse.osee.framework.manager.servlet.SessionClientLoopbackServlet;
import org.eclipse.osee.framework.manager.servlet.SessionManagementServlet;
@@ -127,8 +126,6 @@ public class ServletRegistrationHandler {
OseeServerContext.BRANCH_EXCHANGE_CONTEXT);
register(new BranchManagerServlet(logger, sessionManager, translationService, orcsApi),
OseeServerContext.BRANCH_CONTEXT);
- register(new SearchEngineServlet(logger, sessionManager, translationService, orcsApi),
- OseeServerContext.SEARCH_CONTEXT);
register(new SearchEngineTaggerServlet(logger, sessionManager, orcsApi), OseeServerContext.SEARCH_TAGGING_CONTEXT);
register(new SessionManagementServlet(logger, sessionManager, authenticationManager),
OseeServerContext.SESSION_CONTEXT);
diff --git a/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/data/SearchRequestTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/search/SearchRequestTest.java
index 9eb8683641..e34cfffddc 100644
--- a/plugins/org.eclipse.osee.framework.core.message.test/src/org/eclipse/osee/framework/core/message/test/data/SearchRequestTest.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/artifact/search/SearchRequestTest.java
@@ -8,12 +8,10 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.framework.core.message.test.data;
+package org.eclipse.osee.framework.skynet.core.artifact.search;
import org.eclipse.osee.framework.core.enums.CoreBranches;
-import org.eclipse.osee.framework.core.message.SearchOptions;
-import org.eclipse.osee.framework.core.message.SearchRequest;
-import org.eclipse.osee.framework.core.message.test.mocks.DataAsserts;
+import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.junit.Assert;
import org.junit.Test;
@@ -29,7 +27,7 @@ public class SearchRequestTest {
SearchRequest request = new SearchRequest(CoreBranches.COMMON, "Search", new SearchOptions());
Assert.assertEquals(CoreBranches.COMMON, request.getBranch());
Assert.assertEquals("Search", request.getRawSearch());
- DataAsserts.assertEquals(new SearchOptions(), request.getOptions());
+ assertEquals(new SearchOptions(), request.getOptions());
}
@Test
@@ -37,6 +35,20 @@ public class SearchRequestTest {
SearchRequest request = new SearchRequest(CoreBranches.COMMON, "Search", new SearchOptions());
Assert.assertEquals(CoreBranches.COMMON, request.getBranch());
Assert.assertEquals("Search", request.getRawSearch());
- DataAsserts.assertEquals(new SearchOptions(), request.getOptions());
+ assertEquals(new SearchOptions(), request.getOptions());
+ }
+
+ private static void assertEquals(SearchOptions expected, SearchOptions actual) {
+ if (expected == null) {
+ Assert.assertNull(actual);
+ } else {
+ Assert.assertEquals(expected.isSearchAll(), actual.isSearchAll());
+ Assert.assertEquals(expected.isCaseSensitive(), actual.isCaseSensitive());
+ Assert.assertEquals(expected.isFindAllLocationsEnabled(), actual.isFindAllLocationsEnabled());
+ Assert.assertEquals(expected.getDeletionFlag(), actual.getDeletionFlag());
+ Assert.assertEquals(expected.isMatchWordOrder(), actual.isMatchWordOrder());
+
+ Assert.assertTrue(Collections.isEqual(expected.getAttributeTypeFilter(), actual.getAttributeTypeFilter()));
+ }
}
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactMatch.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactMatch.java
index 5412ceeeb4..80fbbaedb2 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactMatch.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactMatch.java
@@ -10,8 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.framework.skynet.core.artifact.search;
-import org.eclipse.osee.framework.core.message.SearchResponse.ArtifactMatchMetaData;
-import org.eclipse.osee.framework.core.message.SearchResponse.AttributeMatchMetaData;
+import java.util.Collection;
import org.eclipse.osee.framework.jdk.core.type.HashCollection;
import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
@@ -23,15 +22,15 @@ import org.eclipse.osee.framework.skynet.core.artifact.Attribute;
*/
public class ArtifactMatch {
private final Artifact artifact;
- private final ArtifactMatchMetaData matchMetaData;
+ private final HashCollection<Attribute<?>, MatchLocation> matchData =
+ new HashCollection<Attribute<?>, MatchLocation>();
- public ArtifactMatch(Artifact artifact, ArtifactMatchMetaData matchMetaData) {
+ public ArtifactMatch(Artifact artifact) {
this.artifact = artifact;
- this.matchMetaData = matchMetaData;
}
public boolean hasMatchData() {
- return matchMetaData != null;
+ return !matchData.isEmpty();
}
public Artifact getArtifact() {
@@ -39,13 +38,10 @@ public class ArtifactMatch {
}
public HashCollection<Attribute<?>, MatchLocation> getMatchData() throws OseeCoreException {
- HashCollection<Attribute<?>, MatchLocation> matchData = new HashCollection<Attribute<?>, MatchLocation>();
- for (Attribute<?> attribute : artifact.getAttributes()) {
- AttributeMatchMetaData match = matchMetaData.getAttributeMatch((long) attribute.getGammaId());
- if (match != null) {
- matchData.put(attribute, match.getLocations());
- }
- }
return matchData;
}
+
+ public void addMatchData(Attribute<?> attr, Collection<MatchLocation> locations) {
+ matchData.put(attr, locations);
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java
index 82607d6c92..7ecccba073 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java
@@ -21,9 +21,11 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.osee.framework.core.data.IArtifactToken;
@@ -41,7 +43,6 @@ import org.eclipse.osee.framework.core.enums.RelationSide;
import org.eclipse.osee.framework.core.enums.TokenOrderType;
import org.eclipse.osee.framework.core.exception.ArtifactDoesNotExist;
import org.eclipse.osee.framework.core.exception.MultipleArtifactsExist;
-import org.eclipse.osee.framework.core.message.SearchRequest;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.TransactionRecord;
import org.eclipse.osee.framework.core.model.event.IBasicGuidArtifact;
@@ -50,10 +51,12 @@ import org.eclipse.osee.framework.jdk.core.type.HashCollection;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.ResultSet;
import org.eclipse.osee.framework.jdk.core.type.ResultSets;
+import org.eclipse.osee.framework.jdk.core.util.Conditions;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.ArtifactCache;
import org.eclipse.osee.framework.skynet.core.artifact.ArtifactLoader;
import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager;
+import org.eclipse.osee.framework.skynet.core.artifact.Attribute;
import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
import org.eclipse.osee.framework.skynet.core.event.OseeEventManager;
import org.eclipse.osee.framework.skynet.core.event.model.EventBasicGuidArtifact;
@@ -61,6 +64,8 @@ import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil;
import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager;
import org.eclipse.osee.orcs.rest.client.OseeClient;
import org.eclipse.osee.orcs.rest.client.QueryBuilder;
+import org.eclipse.osee.orcs.rest.model.search.RequestType;
+import org.eclipse.osee.orcs.rest.model.search.SearchMatch;
import org.eclipse.osee.orcs.rest.model.search.SearchParameters;
import org.eclipse.osee.orcs.rest.model.search.SearchResult;
@@ -529,20 +534,18 @@ public class ArtifactQuery {
* @param findAllMatchLocations when set to <b>true</b> returns all match locations instead of just returning the
* first one. When returning all match locations, search performance may be slow.
*/
- public static List<ArtifactMatch> getArtifactMatchesFromAttributeKeywords(SearchRequest searchRequest) throws OseeCoreException {
- determineSearchAll(searchRequest);
- return new HttpArtifactQuery(searchRequest).getArtifactsWithMatches(ALL, INCLUDE_CACHE);
- }
+ public static Iterable<ArtifactMatch> getArtifactMatchesFromAttributeKeywords(SearchRequest searchRequest) throws OseeCoreException {
+ QueryBuilderArtifact queryBuilder = createQueryBuilder(searchRequest.getBranch());
+ SearchOptions options = searchRequest.getOptions();
+ queryBuilder.includeDeleted(options.getDeletionFlag().areDeletedAllowed());
+ QueryOption matchCase = CaseType.getCaseType(options.isCaseSensitive());
+ QueryOption matchWordOrder = TokenOrderType.getTokenOrderType(options.isMatchWordOrder());
- /**
- * Since the application server can support non taggable attribute types, the artifact query is filtering only
- * taggable types here.
- */
- private static void determineSearchAll(SearchRequest searchRequest) {
- if (searchRequest.getOptions().getAttributeTypeFilter().isEmpty()) {
- searchRequest.getOptions().setIsSearchAll(true);
- searchRequest.getOptions().addAttributeTypeFilter(QueryBuilder.ANY_ATTRIBUTE_TYPE);
- }
+ Collection<IAttributeType> typesToSearch =
+ Conditions.hasValues(options.getAttributeTypeFilter()) ? options.getAttributeTypeFilter() : Collections.singleton(QueryBuilder.ANY_ATTRIBUTE_TYPE);
+ queryBuilder.and(typesToSearch, searchRequest.getRawSearch(), matchCase, matchWordOrder);
+
+ return queryBuilder.getMatches();
}
public static Artifact reloadArtifactFromId(int artId, IOseeBranch branch) throws OseeCoreException {
@@ -646,7 +649,7 @@ public class ArtifactQuery {
// this method is called from invoke in the localMethod case
@SuppressWarnings("unused")
public ResultSet<Artifact> getResults() throws OseeCoreException {
- SearchResult result = proxied.getSearchResult();
+ SearchResult result = proxied.getSearchResult(RequestType.IDS);
SearchParameters searchParameters = result.getSearchParameters();
IOseeBranch branch = TokenFactory.createBranch(searchParameters.getBranchUuid(), "N/A");
@@ -669,5 +672,48 @@ public class ArtifactQuery {
}
return toReturn;
}
+
+ // this method is called from invoke in the localMethod case
+ @SuppressWarnings("unused")
+ public ResultSet<ArtifactMatch> getMatches() throws OseeCoreException {
+ SearchResult result = proxied.getSearchResult(RequestType.MATCHES);
+ SearchParameters searchParameters = result.getSearchParameters();
+
+ IOseeBranch branch = TokenFactory.createBranch(searchParameters.getBranchUuid(), "N/A");
+
+ TransactionRecord tx = null;
+ if (searchParameters.getFromTx() > 0) {
+ tx = TransactionManager.getTransactionId(searchParameters.getFromTx());
+ }
+ DeletionFlag deletionFlag =
+ searchParameters.isIncludeDeleted() ? DeletionFlag.INCLUDE_DELETED : DeletionFlag.EXCLUDE_DELETED;
+
+ Map<Integer, Artifact> artIdToArtifact = new HashMap<Integer, Artifact>();
+
+ List<Artifact> loadedArtifacts =
+ ArtifactLoader.loadArtifacts(result.getIds(), branch, LoadLevel.ALL, INCLUDE_CACHE, deletionFlag, tx);
+
+ for (Artifact art : loadedArtifacts) {
+ artIdToArtifact.put(art.getArtId(), art);
+ }
+
+ Map<Artifact, ArtifactMatch> matches = new HashMap<Artifact, ArtifactMatch>();
+ for (SearchMatch match : result.getSearchMatches()) {
+ int artId = match.getArtId();
+ int attrId = match.getAttrId();
+ Artifact art = artIdToArtifact.get(artId);
+ if (art != null) {
+ ArtifactMatch toAddTo = matches.get(art);
+ if (toAddTo == null) {
+ toAddTo = new ArtifactMatch(art);
+ matches.put(art, toAddTo);
+ }
+ Attribute<?> attribute = art.getAttributeById(attrId, searchParameters.isIncludeDeleted());
+ toAddTo.addMatchData(attribute, match.getLocations());
+ }
+ }
+
+ return ResultSets.newResultSet(matches.values());
+ }
}
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQueryBuilder.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQueryBuilder.java
index 87ff17e3af..7178fa83cd 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQueryBuilder.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQueryBuilder.java
@@ -271,7 +271,7 @@ public class ArtifactQueryBuilder {
}
private List<Artifact> loadArtifactsFromServerIds(LoadType reload) throws OseeCoreException {
- List<Integer> ids = createOrcsQuery().getSearchResult().getIds();
+ List<Integer> ids = createOrcsQuery().getIds();
List<Artifact> artifacts;
if (ids != null && !ids.isEmpty()) {
artifacts = ArtifactLoader.loadArtifacts(ids, branch, loadLevel, reload, allowDeleted, transactionId);
@@ -291,7 +291,7 @@ public class ArtifactQueryBuilder {
}
public List<Integer> selectArtifacts(int artifactCountEstimate) throws OseeCoreException {
- return createOrcsQuery().getSearchResult().getIds();
+ return createOrcsQuery().getIds();
}
public int countArtifacts() throws OseeCoreException {
@@ -438,6 +438,12 @@ public class ArtifactQueryBuilder {
public void andLocalIds(Collection<Integer> artifactIds) {
localIds.addAll(artifactIds);
}
+
+ @SuppressWarnings("unused")
+ public List<Integer> getIds() {
+ return new LinkedList<Integer>(localIds);
+ }
+
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/HttpArtifactQuery.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/HttpArtifactQuery.java
deleted file mode 100644
index ed9cc50956..0000000000
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/HttpArtifactQuery.java
+++ /dev/null
@@ -1,79 +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.framework.skynet.core.artifact.search;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import org.eclipse.osee.framework.core.data.IOseeBranch;
-import org.eclipse.osee.framework.core.data.OseeServerContext;
-import org.eclipse.osee.framework.core.enums.CoreTranslatorId;
-import org.eclipse.osee.framework.core.enums.DeletionFlag;
-import org.eclipse.osee.framework.core.enums.LoadLevel;
-import org.eclipse.osee.framework.core.message.SearchRequest;
-import org.eclipse.osee.framework.core.message.SearchResponse;
-import org.eclipse.osee.framework.core.message.SearchResponse.ArtifactMatchMetaData;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.Conditions;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.ArtifactLoader;
-import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
-import org.eclipse.osee.framework.skynet.core.artifact.HttpClientMessage;
-import org.eclipse.osee.framework.skynet.core.artifact.LoadType;
-
-/**
- * @author Roberto E. Escobar
- */
-final class HttpArtifactQuery {
- private final SearchRequest searchRequest;
-
- protected HttpArtifactQuery(SearchRequest searchRequest) {
- this.searchRequest = searchRequest;
- }
-
- private SearchResponse executeSearch() throws OseeCoreException {
- SearchResponse response =
- HttpClientMessage.send(OseeServerContext.SEARCH_CONTEXT, new HashMap<String, String>(),
- CoreTranslatorId.SEARCH_REQUEST, searchRequest, CoreTranslatorId.SEARCH_RESPONSE);
- String errorMessage = response.getErrorMessage();
- Conditions.checkExpressionFailOnTrue(Strings.isValid(errorMessage), errorMessage);
- return response;
- }
-
- public List<Artifact> getArtifacts(LoadLevel loadLevel, LoadType reload) throws OseeCoreException {
- SearchResponse response = executeSearch();
- return loadArtifacts(response, loadLevel, reload);
- }
-
- public List<ArtifactMatch> getArtifactsWithMatches(LoadLevel loadLevel, LoadType reload) throws OseeCoreException {
- List<ArtifactMatch> toReturn = new ArrayList<ArtifactMatch>();
- SearchResponse response = executeSearch();
- List<Artifact> artifacts = loadArtifacts(response, loadLevel, reload);
- for (Artifact artifact : artifacts) {
- ArtifactMatchMetaData match = response.getArtifactMatch(artifact.getFullBranch().getId(), artifact.getArtId());
- toReturn.add(new ArtifactMatch(artifact, match));
- }
- return toReturn;
- }
-
- private List<Artifact> loadArtifacts(SearchResponse response, LoadLevel loadLevel, LoadType reload) throws OseeCoreException {
- List<Artifact> toReturn = new ArrayList<Artifact>();
- for (Long branchId : response.getBranchIds()) {
- IOseeBranch branch = BranchManager.getBranch(branchId);
- Collection<Integer> artsIds = response.getArtifactIds(branchId);
- DeletionFlag deletionFlag = searchRequest.getOptions().getDeletionFlag();
- toReturn.addAll(ArtifactLoader.loadArtifacts(artsIds, branch, loadLevel, reload, deletionFlag));
- }
- return toReturn;
- }
-}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/QueryBuilderArtifact.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/QueryBuilderArtifact.java
index 3854db6cb9..21fceacd55 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/QueryBuilderArtifact.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/QueryBuilderArtifact.java
@@ -22,4 +22,6 @@ public interface QueryBuilderArtifact extends QueryBuilder {
ResultSet<Artifact> getResults() throws OseeCoreException;
+ ResultSet<ArtifactMatch> getMatches();
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/SearchOptions.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/SearchOptions.java
index ca9fd6601b..efc2765324 100644
--- a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/SearchOptions.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/SearchOptions.java
@@ -8,7 +8,7 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.framework.core.message;
+package org.eclipse.osee.framework.skynet.core.artifact.search;
import java.util.Collection;
import java.util.HashSet;
diff --git a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/SearchRequest.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/SearchRequest.java
index b7884dcec0..7c7f7cef09 100644
--- a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/SearchRequest.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/SearchRequest.java
@@ -8,7 +8,7 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.framework.core.message;
+package org.eclipse.osee.framework.skynet.core.artifact.search;
import org.eclipse.osee.framework.core.data.HasBranch;
import org.eclipse.osee.framework.core.data.IOseeBranch;
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/QuickSearchView.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/QuickSearchView.java
index 53c9c4d776..4f62927d36 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/QuickSearchView.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/QuickSearchView.java
@@ -20,13 +20,13 @@ import java.util.List;
import org.eclipse.jface.action.Action;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.enums.DeletionFlag;
-import org.eclipse.osee.framework.core.message.SearchOptions;
-import org.eclipse.osee.framework.core.message.SearchRequest;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.help.ui.OseeHelpContext;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
+import org.eclipse.osee.framework.skynet.core.artifact.search.SearchOptions;
+import org.eclipse.osee.framework.skynet.core.artifact.search.SearchRequest;
import org.eclipse.osee.framework.ui.skynet.FrameworkImage;
import org.eclipse.osee.framework.ui.skynet.OseeStatusContributionItemFactory;
import org.eclipse.osee.framework.ui.skynet.panels.SearchComposite;
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/RemoteArtifactSearch.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/RemoteArtifactSearch.java
index 0b0c43e6db..23fc60b6d0 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/RemoteArtifactSearch.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/RemoteArtifactSearch.java
@@ -16,8 +16,6 @@ import java.util.logging.Level;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.osee.framework.core.message.SearchOptions;
-import org.eclipse.osee.framework.core.message.SearchRequest;
import org.eclipse.osee.framework.jdk.core.type.HashCollection;
import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
@@ -30,6 +28,8 @@ import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.Attribute;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactMatch;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.skynet.core.artifact.search.SearchOptions;
+import org.eclipse.osee.framework.skynet.core.artifact.search.SearchRequest;
import org.eclipse.osee.framework.ui.skynet.internal.Activator;
import org.eclipse.osee.framework.ui.skynet.search.page.AttributeLineElement;
import org.eclipse.osee.framework.ui.skynet.search.page.AttributeMatch;
@@ -92,7 +92,7 @@ public final class RemoteArtifactSearch extends AbstractArtifactSearchQuery {
long endOfloadTime = startTime;
int lineMatches = 0;
try {
- List<ArtifactMatch> matches = ArtifactQuery.getArtifactMatchesFromAttributeKeywords(searchRequest);
+ Iterable<ArtifactMatch> matches = ArtifactQuery.getArtifactMatchesFromAttributeKeywords(searchRequest);
endOfloadTime = System.currentTimeMillis();
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/QueryBuilder.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/QueryBuilder.java
index 6947447707..8c05d10a10 100644
--- a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/QueryBuilder.java
+++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/QueryBuilder.java
@@ -11,6 +11,7 @@
package org.eclipse.osee.orcs.rest.client;
import java.util.Collection;
+import java.util.List;
import org.eclipse.osee.framework.core.data.IArtifactToken;
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.data.IAttributeType;
@@ -20,6 +21,7 @@ import org.eclipse.osee.framework.core.data.TokenFactory;
import org.eclipse.osee.framework.core.enums.Operator;
import org.eclipse.osee.framework.core.enums.QueryOption;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.orcs.rest.model.search.RequestType;
import org.eclipse.osee.orcs.rest.model.search.SearchResult;
/**
@@ -178,10 +180,17 @@ public interface QueryBuilder {
*
* @return artifact search results
*/
- SearchResult getSearchResult() throws OseeCoreException;
+ SearchResult getSearchResult(RequestType request) throws OseeCoreException;
/**
* Count search results
*/
int getCount() throws OseeCoreException;
+
+ /**
+ * Convenience method for getting art ids of results
+ *
+ * @return artifact search ids
+ */
+ List<Integer> getIds();
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryBuilderImpl.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryBuilderImpl.java
index 1e28c9d03b..0ef368b886 100644
--- a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryBuilderImpl.java
+++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryBuilderImpl.java
@@ -27,6 +27,7 @@ import org.eclipse.osee.framework.core.enums.QueryOption;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.orcs.rest.client.QueryBuilder;
import org.eclipse.osee.orcs.rest.model.search.Predicate;
+import org.eclipse.osee.orcs.rest.model.search.RequestType;
import org.eclipse.osee.orcs.rest.model.search.SearchResult;
/**
@@ -220,9 +221,9 @@ public class QueryBuilderImpl implements QueryBuilder {
}
@Override
- public SearchResult getSearchResult() throws OseeCoreException {
+ public SearchResult getSearchResult(RequestType request) throws OseeCoreException {
QueryOptions qOptions = options.clone();
- return executor.getResults(branch, predicates, qOptions);
+ return executor.getResults(request, branch, predicates, qOptions);
}
@Override
@@ -231,4 +232,9 @@ public class QueryBuilderImpl implements QueryBuilder {
return executor.getCount(branch, predicates, qOptions);
}
+ @Override
+ public List<Integer> getIds() {
+ return getSearchResult(RequestType.IDS).getIds();
+ }
+
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryExecutor.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryExecutor.java
index 41d7227363..be3bce5e07 100644
--- a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryExecutor.java
+++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryExecutor.java
@@ -14,6 +14,7 @@ import java.util.List;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.orcs.rest.model.search.Predicate;
+import org.eclipse.osee.orcs.rest.model.search.RequestType;
import org.eclipse.osee.orcs.rest.model.search.SearchResult;
/**
@@ -23,5 +24,5 @@ public interface QueryExecutor {
int getCount(IOseeBranch branch, List<Predicate> predicates, QueryOptions options) throws OseeCoreException;
- SearchResult getResults(IOseeBranch branch, List<Predicate> predicates, QueryOptions options) throws OseeCoreException;
+ SearchResult getResults(RequestType request, IOseeBranch branch, List<Predicate> predicates, QueryOptions options) throws OseeCoreException;
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryExecutorV1.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryExecutorV1.java
index eed9eefc70..b1d47ebcbf 100644
--- a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryExecutorV1.java
+++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryExecutorV1.java
@@ -48,8 +48,8 @@ public class QueryExecutorV1 implements QueryExecutor {
}
@Override
- public SearchResult getResults(IOseeBranch branch, List<Predicate> predicates, QueryOptions options) throws OseeCoreException {
- SearchResponse result = performSearch(RequestType.IDS, OutputFormat.XML, branch, predicates, options);
+ public SearchResult getResults(RequestType request, IOseeBranch branch, List<Predicate> predicates, QueryOptions options) throws OseeCoreException {
+ SearchResponse result = performSearch(request, OutputFormat.XML, branch, predicates, options);
return result;
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/RequestType.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/RequestType.java
index c2e031a7d4..da3a7bc708 100644
--- a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/RequestType.java
+++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/RequestType.java
@@ -15,5 +15,6 @@ package org.eclipse.osee.orcs.rest.model.search;
*/
public enum RequestType {
COUNT,
- IDS;
+ IDS,
+ MATCHES;
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchMatch.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchMatch.java
new file mode 100644
index 0000000000..bb9c3cebef
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchMatch.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * 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.rest.model.search;
+
+import java.util.List;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
+
+/**
+ * @author John Misinco
+ */
+@XmlRootElement(name = "SearchMatch")
+public class SearchMatch {
+
+ private int artId;
+ private int attrId;
+
+ @XmlTransient
+ private List<MatchLocation> locations;
+
+ public SearchMatch() {
+ // default constructor
+ }
+
+ public SearchMatch(int artId, int attrId, List<MatchLocation> locations) {
+ this.artId = artId;
+ this.attrId = attrId;
+ this.locations = locations;
+ }
+
+ public int getArtId() {
+ return artId;
+ }
+
+ public void setArtId(int artId) {
+ this.artId = artId;
+ }
+
+ public int getAttrId() {
+ return attrId;
+ }
+
+ public void setAttrId(int attrId) {
+ this.attrId = attrId;
+ }
+
+ public List<MatchLocation> getLocations() {
+ return locations;
+ }
+
+ public void setLocations(List<MatchLocation> locations) {
+ this.locations = locations;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchResponse.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchResponse.java
index 47f74d3eab..4581d30fc2 100644
--- a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchResponse.java
+++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchResponse.java
@@ -32,6 +32,9 @@ public class SearchResponse implements SearchResult {
@XmlTransient
private List<Integer> ids = new LinkedList<Integer>();
+ @XmlTransient
+ private List<SearchMatch> searchMatches = new LinkedList<SearchMatch>();
+
public void setSearchRequest(SearchRequest searchRequest) {
this.searchRequest = searchRequest;
}
@@ -86,4 +89,15 @@ public class SearchResponse implements SearchResult {
return getSearchRequest();
}
+ public void setMatches(List<SearchMatch> searchMatches) {
+ this.searchMatches = searchMatches;
+ }
+
+ @Override
+ @XmlElementWrapper(name = "matches")
+ @XmlElement(name = "match")
+ public List<SearchMatch> getSearchMatches() {
+ return searchMatches;
+ }
+
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchResult.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchResult.java
index 7a6107529f..15628f86cb 100644
--- a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchResult.java
+++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/SearchResult.java
@@ -28,4 +28,6 @@ public interface SearchResult {
List<Integer> getIds();
+ List<SearchMatch> getSearchMatches();
+
}
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/ArtifactSearch_V1.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/ArtifactSearch_V1.java
index e82378c8b2..4ad3ed52d3 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/ArtifactSearch_V1.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/ArtifactSearch_V1.java
@@ -20,14 +20,21 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.UriInfo;
+import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.type.ResultSet;
+import org.eclipse.osee.orcs.data.ArtifactReadable;
+import org.eclipse.osee.orcs.data.AttributeReadable;
import org.eclipse.osee.orcs.data.HasLocalId;
import org.eclipse.osee.orcs.rest.internal.OrcsApplication;
import org.eclipse.osee.orcs.rest.internal.search.dsl.DslFactory;
import org.eclipse.osee.orcs.rest.internal.search.dsl.DslTranslator;
import org.eclipse.osee.orcs.rest.internal.search.dsl.SearchQueryBuilder;
+import org.eclipse.osee.orcs.rest.model.search.RequestType;
+import org.eclipse.osee.orcs.rest.model.search.SearchMatch;
import org.eclipse.osee.orcs.rest.model.search.SearchRequest;
import org.eclipse.osee.orcs.rest.model.search.SearchResponse;
+import org.eclipse.osee.orcs.search.Match;
import org.eclipse.osee.orcs.search.QueryBuilder;
import org.eclipse.osee.orcs.search.QueryFactory;
@@ -125,23 +132,41 @@ public class ArtifactSearch_V1 extends ArtifactSearch {
builder.fromTransaction(params.getFromTx());
}
- SearchResponse result;
- if (params.getFields().equals("count")) {
- result = new SearchResponse();
- int total = builder.getCount();
- result.setTotal(total);
-
- } else if (params.getFields().equals("ids")) {
- List<Integer> localIds = new LinkedList<Integer>();
- for (HasLocalId art : builder.getResultsAsLocalIds()) {
- localIds.add(art.getLocalId());
- }
- result = new SearchResponse();
- result.setIds(localIds);
- result.setTotal(localIds.size());
- } else {
- throw new UnsupportedOperationException();
+ SearchResponse result = new SearchResponse();
+ RequestType request = RequestType.valueOf(params.getFields().toUpperCase());
+ List<Integer> localIds = new LinkedList<Integer>();
+ switch (request) {
+ case COUNT:
+ int total = builder.getCount();
+ result.setTotal(total);
+ break;
+ case IDS:
+ for (HasLocalId art : builder.getResultsAsLocalIds()) {
+ localIds.add(art.getLocalId());
+ }
+ result.setIds(localIds);
+ result.setTotal(localIds.size());
+ break;
+ case MATCHES:
+ ResultSet<Match<ArtifactReadable, AttributeReadable<?>>> matches = builder.getMatches();
+ List<SearchMatch> searchMatches = new LinkedList<SearchMatch>();
+ for (Match<ArtifactReadable, AttributeReadable<?>> match : matches) {
+ int artId = match.getItem().getLocalId();
+ localIds.add(artId);
+ for (AttributeReadable<?> attribute : match.getElements()) {
+ int attrId = attribute.getLocalId();
+ List<MatchLocation> locations = match.getLocation(attribute);
+ searchMatches.add(new SearchMatch(artId, attrId, locations));
+ }
+ }
+ result.setIds(localIds);
+ result.setMatches(searchMatches);
+ result.setTotal(searchMatches.size());
+ break;
+ default:
+ throw new UnsupportedOperationException();
}
+
result.setSearchRequest(params);
result.setSearchTime(System.currentTimeMillis() - startTime);
return result;
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/PredicateHandlerUtil.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/PredicateHandlerUtil.java
index 12f9519a43..ff83b5ba08 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/PredicateHandlerUtil.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/PredicateHandlerUtil.java
@@ -78,7 +78,7 @@ public class PredicateHandlerUtil {
}
private static long parseUuid(String uuid) throws OseeCoreException {
- if (uuid.matches("\\d+")) {
+ if (uuid.matches("-?\\d+")) {
return Long.parseLong(uuid);
} else if (HexUtil.isHexString(uuid)) {
return HexUtil.toLong(uuid);
diff --git a/plugins/org.eclipse.osee.x.server.integration.tests/src/org/eclipse/osee/x/server/integration/tests/performance/OseeClientQueryTest.java b/plugins/org.eclipse.osee.x.server.integration.tests/src/org/eclipse/osee/x/server/integration/tests/performance/OseeClientQueryTest.java
index 2a22142d62..d0e652c20c 100644
--- a/plugins/org.eclipse.osee.x.server.integration.tests/src/org/eclipse/osee/x/server/integration/tests/performance/OseeClientQueryTest.java
+++ b/plugins/org.eclipse.osee.x.server.integration.tests/src/org/eclipse/osee/x/server/integration/tests/performance/OseeClientQueryTest.java
@@ -30,6 +30,7 @@ import org.eclipse.osee.framework.core.enums.TokenOrderType;
import org.eclipse.osee.framework.jdk.core.type.Identity;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.orcs.rest.client.OseeClient;
+import org.eclipse.osee.orcs.rest.model.search.RequestType;
import org.eclipse.osee.orcs.rest.model.search.SearchResult;
import org.junit.BeforeClass;
import org.junit.Rule;
@@ -70,13 +71,14 @@ public class OseeClientQueryTest {
createClient = IntegrationUtil.createClient();
// Establish initial connection to the db using this random query
- createClient.createQueryBuilder(COMMON).andIds(SystemUser.OseeSystem).getSearchResult();
+ createClient.createQueryBuilder(COMMON).andIds(SystemUser.OseeSystem).getSearchResult(RequestType.IDS);
}
@Test
public void searchForAttributeTypeByTokenId() throws OseeCoreException {
final int EXPECTED_RESULTS = 1;
- SearchResult results = createClient.createQueryBuilder(COMMON).andIds(SystemUser.OseeSystem).getSearchResult();
+ SearchResult results =
+ createClient.createQueryBuilder(COMMON).andIds(SystemUser.OseeSystem).getSearchResult(RequestType.IDS);
assertEquals(EXPECTED_RESULTS, results.getTotal());
}
@@ -84,42 +86,45 @@ public class OseeClientQueryTest {
public void searchForAttributeTypeByTokenIds() throws OseeCoreException {
final int EXPECTED_RESULTS = 2;
SearchResult results =
- createClient.createQueryBuilder(COMMON).andIds(SystemUser.OseeSystem, SystemUser.Guest).getSearchResult();
+ createClient.createQueryBuilder(COMMON).andIds(SystemUser.OseeSystem, SystemUser.Guest).getSearchResult(
+ RequestType.IDS);
assertEquals(EXPECTED_RESULTS, results.getTotal());
}
@Test
public void searchForArtifactByGuid() throws OseeCoreException {
final int EXPECTED_RESULTS = 1;
- SearchResult results = createClient.createQueryBuilder(COMMON).andGuids(GUID1).getSearchResult();
+ SearchResult results = createClient.createQueryBuilder(COMMON).andGuids(GUID1).getSearchResult(RequestType.IDS);
assertEquals(EXPECTED_RESULTS, results.getTotal());
}
@Test
public void searchForArtifactByGuids() throws OseeCoreException {
final int EXPECTED_RESULTS = 2;
- SearchResult results = createClient.createQueryBuilder(COMMON).andGuids(GUID1, GUID2).getSearchResult();
+ SearchResult results =
+ createClient.createQueryBuilder(COMMON).andGuids(GUID1, GUID2).getSearchResult(RequestType.IDS);
assertEquals(EXPECTED_RESULTS, results.getTotal());
}
@Test
public void searchForArtifactByLocalId() throws OseeCoreException {
final int EXPECTED_RESULTS = 1;
- SearchResult results = createClient.createQueryBuilder(COMMON).andLocalId(9).getSearchResult();
+ SearchResult results = createClient.createQueryBuilder(COMMON).andLocalId(9).getSearchResult(RequestType.IDS);
assertEquals(EXPECTED_RESULTS, results.getTotal());
}
@Test
public void searchForArtifactByLocalIds() throws OseeCoreException {
final int EXPECTED_RESULTS = 2;
- SearchResult results = createClient.createQueryBuilder(COMMON).andLocalId(19, 9).getSearchResult();
+ SearchResult results = createClient.createQueryBuilder(COMMON).andLocalId(19, 9).getSearchResult(RequestType.IDS);
assertEquals(EXPECTED_RESULTS, results.getTotal());
}
@Test
public void searchForArtifactByName() throws OseeCoreException {
final int EXPECTED_RESULTS = 1;
- SearchResult results = createClient.createQueryBuilder(COMMON).andNameEquals("Joe Smith").getSearchResult();
+ SearchResult results =
+ createClient.createQueryBuilder(COMMON).andNameEquals("Joe Smith").getSearchResult(RequestType.IDS);
assertEquals(EXPECTED_RESULTS, results.getTotal());
}
@@ -128,14 +133,16 @@ public class OseeClientQueryTest {
final int EXPECTED_RESULTS = 43;
SearchResult results =
createClient.createQueryBuilder(COMMON).and(CoreAttributeTypes.Name, "SAW", CaseType.IGNORE_CASE,
- TokenOrderType.MATCH_ORDER, TokenDelimiterMatch.ANY, MatchTokenCountType.IGNORE_TOKEN_COUNT).getSearchResult();
+ TokenOrderType.MATCH_ORDER, TokenDelimiterMatch.ANY, MatchTokenCountType.IGNORE_TOKEN_COUNT).getSearchResult(
+ RequestType.IDS);
assertEquals(EXPECTED_RESULTS, results.getTotal());
}
@Test
public void searchForArtifactType() throws OseeCoreException {
final int EXPECTED_RESULTS = 7;
- SearchResult results = createClient.createQueryBuilder(SAW_1).andTypeEquals(Folder).getSearchResult();
+ SearchResult results =
+ createClient.createQueryBuilder(SAW_1).andTypeEquals(Folder).getSearchResult(RequestType.IDS);
assertEquals(EXPECTED_RESULTS, results.getTotal());
}
@@ -143,7 +150,8 @@ public class OseeClientQueryTest {
public void searchForArtifactTypes() throws OseeCoreException {
final int EXPECTED_RESULTS = 24;
SearchResult results =
- createClient.createQueryBuilder(SAW_1).andTypeEquals(GeneralData, GeneralDocument, SoftwareRequirement).getSearchResult();
+ createClient.createQueryBuilder(SAW_1).andTypeEquals(GeneralData, GeneralDocument, SoftwareRequirement).getSearchResult(
+ RequestType.IDS);
assertEquals(EXPECTED_RESULTS, results.getTotal());
}
@@ -151,14 +159,15 @@ public class OseeClientQueryTest {
public void searchForArtifactTypesIncludeTypeInheritance() throws OseeCoreException {
final int EXPECTED_RESULTS = 150;
SearchResult results =
- createClient.createQueryBuilder(SAW_1).andIsOfType(GeneralData, GeneralDocument, Requirement).getSearchResult();
+ createClient.createQueryBuilder(SAW_1).andIsOfType(GeneralData, GeneralDocument, Requirement).getSearchResult(
+ RequestType.IDS);
assertEquals(EXPECTED_RESULTS, results.getTotal());
}
@Test
public void searchForExistenceOfAttributeType() throws OseeCoreException {
final int EXPECTED_RESULTS = 28;
- SearchResult results = createClient.createQueryBuilder(COMMON).andExists(Active).getSearchResult();
+ SearchResult results = createClient.createQueryBuilder(COMMON).andExists(Active).getSearchResult(RequestType.IDS);
assertEquals(EXPECTED_RESULTS, results.getTotal());
}
@@ -166,7 +175,7 @@ public class OseeClientQueryTest {
public void searchForExistenceOfAttributeTypeIncludeDeleted() throws OseeCoreException {
final int EXPECTED_RESULTS = 28;
SearchResult results =
- createClient.createQueryBuilder(COMMON).andExists(Active).includeDeleted().getSearchResult();
+ createClient.createQueryBuilder(COMMON).andExists(Active).includeDeleted().getSearchResult(RequestType.IDS);
assertEquals(EXPECTED_RESULTS, results.getTotal());
}
@@ -174,7 +183,7 @@ public class OseeClientQueryTest {
public void searchForExistenceOfAttributeTypes() throws OseeCoreException {
final int EXPECTED_RESULTS = 28;
SearchResult results =
- createClient.createQueryBuilder(COMMON).andExists(Active, AccessContextId).getSearchResult();
+ createClient.createQueryBuilder(COMMON).andExists(Active, AccessContextId).getSearchResult(RequestType.IDS);
assertEquals(EXPECTED_RESULTS, results.getTotal());
}

Back to the top