Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/SearchEngineServlet.java140
-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.search.engine/src/org/eclipse/osee/framework/search/engine/ArtifactMatch.java63
-rw-r--r--plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/IAttributeTaggerProvider.java3
-rw-r--r--plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/IAttributeTaggerProviderManager.java3
-rw-r--r--plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/SearchResult.java113
-rw-r--r--plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/SearchResultToXmlOperation.java128
-rw-r--r--plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/attribute/AttributeDataStore.java6
-rw-r--r--plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/AttributeTaggerProviderManagerImpl.java4
-rw-r--r--plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/search/AttributeSearch.java20
-rw-r--r--plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/search/ISearchFactory.java14
-rw-r--r--plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/search/SearchEngine.java71
-rw-r--r--plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/search/SearchStatistics.java24
-rw-r--r--plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/services/SearchEngineRegHandler.java13
-rw-r--r--plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/tagger/DefaultAttributeTaggerProvider.java4
-rw-r--r--plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/tagger/XmlAttributeTaggerProvider.java4
-rw-r--r--plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/WordOrderMatcher.java9
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactMatch.java24
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java19
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactXmlQueryResultParser.java202
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/HttpArtifactQuery.java239
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/AbstractArtifactSearchQuery.java22
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/QuickSearchView.java24
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/RemoteArtifactSearch.java48
25 files changed, 265 insertions, 936 deletions
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
index b6f6a12810b..6d9edadd097 100644
--- 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
@@ -11,27 +11,20 @@
package org.eclipse.osee.framework.manager.servlet;
import java.io.IOException;
-import java.io.StringWriter;
+import java.io.InputStream;
import java.util.logging.Level;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.eclipse.osee.framework.core.model.cache.AttributeTypeCache;
-import org.eclipse.osee.framework.core.model.type.AttributeType;
-import org.eclipse.osee.framework.core.operation.IOperation;
-import org.eclipse.osee.framework.core.operation.Operations;
+import org.eclipse.osee.framework.core.enums.CoreTranslatorId;
+import org.eclipse.osee.framework.core.message.SearchRequest;
+import org.eclipse.osee.framework.core.message.SearchResponse;
import org.eclipse.osee.framework.core.server.ISessionManager;
import org.eclipse.osee.framework.core.server.SecureOseeHttpServlet;
-import org.eclipse.osee.framework.database.core.JoinUtility;
-import org.eclipse.osee.framework.database.core.JoinUtility.ArtifactJoinQuery;
+import org.eclipse.osee.framework.core.translation.IDataTranslationService;
import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.logging.OseeLog;
-import org.eclipse.osee.framework.manager.servlet.data.HttpSearchInfo;
import org.eclipse.osee.framework.manager.servlet.internal.Activator;
import org.eclipse.osee.framework.search.engine.ISearchEngine;
-import org.eclipse.osee.framework.search.engine.SearchOptions.SearchOptionsEnum;
-import org.eclipse.osee.framework.search.engine.SearchResult;
-import org.eclipse.osee.framework.search.engine.SearchResultToXmlOperation;
/**
* @author Roberto E. Escobar
@@ -41,95 +34,80 @@ public class SearchEngineServlet extends SecureOseeHttpServlet {
private static final long serialVersionUID = 3722992788943330970L;
private final ISearchEngine searchEngine;
- private final AttributeTypeCache attributeTypeCache;
+ private final IDataTranslationService translationService;
- public SearchEngineServlet(ISessionManager sessionManager, ISearchEngine searchEngine, AttributeTypeCache attributeTypeCache) {
+ public SearchEngineServlet(ISessionManager sessionManager, ISearchEngine searchEngine, IDataTranslationService translationService) {
super(sessionManager);
this.searchEngine = searchEngine;
- this.attributeTypeCache = attributeTypeCache;
+ this.translationService = translationService;
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
- HttpSearchInfo searchInfo = HttpSearchInfo.loadFromPost(request);
+ SearchRequest searchRequest =
+ translationService.convert(request.getInputStream(), CoreTranslatorId.SEARCH_REQUEST);
- String clientVersion = ModCompatible.getClientVersion(getSessionManager(), request.getParameter("sessionId"));
- boolean isCompatible = ModCompatible.is_0_9_2_Compatible(clientVersion);
-
- executeSearch(isCompatible, searchInfo, response);
- } catch (Exception ex) {
- response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
- response.setContentType("text/plain");
- OseeLog.log(Activator.class, Level.SEVERE,
- String.format("Failed to respond to a search engine servlet request [%s]", request.getRequestURL()), ex);
- response.getWriter().write(Lib.exceptionToString(ex));
- }
- }
-
- private void executeSearch(boolean isCompatible, HttpSearchInfo searchInfo, HttpServletResponse response) throws IOException {
- try {
- String[] attributeTypeGuids = searchInfo.getAttributeTypeGuids();
- AttributeType[] attributeTypes = new AttributeType[attributeTypeGuids.length];
-
- int index = 0;
- for (String attributeTypeValue : attributeTypeGuids) {
- if (!isCompatible) {
- attributeTypes[index++] = attributeTypeCache.getBySoleName(attributeTypeValue);
- } else {
- attributeTypes[index++] = attributeTypeCache.getByGuid(attributeTypeValue);
- }
- }
-
- SearchResult results =
- searchEngine.search(searchInfo.getQuery(), searchInfo.getId(), searchInfo.getOptions(), attributeTypes);
- StringWriter writer = new StringWriter();
- IOperation operation = new SearchResultToXmlOperation(results, writer);
- Operations.executeWork(operation);
+ SearchResponse searchResponse = new SearchResponse();
+ searchEngine.search(searchRequest, searchResponse);
response.setStatus(HttpServletResponse.SC_ACCEPTED);
- response.setCharacterEncoding("UTF-8");
response.setContentType("text/xml");
- response.getWriter().write(writer.toString());
+ response.setCharacterEncoding("UTF-8");
- if (results.isEmpty() && Strings.isValid(results.getErrorMessage())) {
+ InputStream inputStream = translationService.convertToStream(searchResponse, CoreTranslatorId.SEARCH_RESPONSE);
+ Lib.inputStreamToOutputStream(inputStream, response.getOutputStream());
- sendEmptyAsXml(response, results);
- } else if (!results.isEmpty()) {
- long start = System.currentTimeMillis();
- if (!searchInfo.getOptions().getBoolean(SearchOptionsEnum.as_xml.asStringOption())) {
- sendAsDbJoin(response, results);
- } else {
- response.setCharacterEncoding("UTF-8");
- response.setContentType("text/xml");
- sendAsXml(response, results);
- }
- System.out.println(String.format("Search for [%s] - [%d results sent in %d ms]", searchInfo.getQuery(),
- results.size(), System.currentTimeMillis() - start));
- } else {
- response.setCharacterEncoding("UTF-8");
- response.setContentType("text/plain");
- }
} catch (Exception ex) {
+ OseeLog.log(Activator.class, Level.SEVERE,
+ String.format("Failed to respond to a search engine servlet request [%s]", request.getRequestURL()), ex);
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
response.setContentType("text/plain");
- OseeLog.log(Activator.class, Level.SEVERE,
- String.format("Failed to respond to a search engine servlet request [%s]", searchInfo.toString()), ex);
response.getWriter().write(Lib.exceptionToString(ex));
+ response.getWriter().flush();
+ response.getWriter().close();
}
}
- private void sendAsDbJoin(HttpServletResponse response, SearchResult results) throws Exception {
- response.setCharacterEncoding("UTF-8");
- response.setContentType("text/plain");
+ // StringWriter writer = new StringWriter();
+ // IOperation operation = new SearchResultToXmlOperation(results, writer);
+ // Operations.executeWork(operation);
+ //
+ // response.setStatus(HttpServletResponse.SC_ACCEPTED);
+ // response.setCharacterEncoding("UTF-8");
+ // response.setContentType("text/xml");
+ // response.getWriter().write(writer.toString());
+ //
+ // if (results.isEmpty() && Strings.isValid(results.getErrorMessage())) {
+ //
+ // sendEmptyAsXml(response, results);
+ // } else if (!results.isEmpty()) {
+ // long start = System.currentTimeMillis();
+ // if (!searchInfo.getOptions().getBoolean(SearchOptionsEnum.as_xml.asStringOption())) {
+ // sendAsDbJoin(response, results);
+ // } else {
+ // response.setCharacterEncoding("UTF-8");
+ // response.setContentType("text/xml");
+ // sendAsXml(response, results);
+ // }
+ // System.out.println(String.format("Search for [%s] - [%d results sent in %d ms]", searchInfo.getQuery(),
+ // results.size(), System.currentTimeMillis() - start));
+ // } else {
+ // response.setCharacterEncoding("UTF-8");
+ // response.setContentType("text/plain");
+ // }
+ // private void sendAsDbJoin(HttpServletResponse response, SearchResult results) throws Exception {
+ // response.setCharacterEncoding("UTF-8");
+ // response.setContentType("text/plain");
+ //
+ // ArtifactJoinQuery joinQuery = JoinUtility.createArtifactJoinQuery();
+ // for (Integer branchId : results.getBranchIds()) {
+ // for (Integer artId : results.getArtifactIds(branchId)) {
+ // joinQuery.add(artId, branchId);
+ // }
+ // }
+ // joinQuery.store();
+ // response.getWriter().write(String.format("%d,%d", joinQuery.getQueryId(), joinQuery.size()));
+ // }
- ArtifactJoinQuery joinQuery = JoinUtility.createArtifactJoinQuery();
- for (Integer branchId : results.getBranchIds()) {
- for (Integer artId : results.getArtifactIds(branchId)) {
- joinQuery.add(artId, branchId);
- }
- }
- joinQuery.store();
- response.getWriter().write(String.format("%d,%d", joinQuery.getQueryId(), joinQuery.size()));
- }
}
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 d7a1555b245..e71c13d56f2 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
@@ -118,8 +118,7 @@ public class ServletRegistrationHandler extends AbstractTrackingHandler {
OseeServerContext.BRANCH_EXCHANGE_CONTEXT);
register(new BranchManagerServlet(sessionManager, branchService, translationService),
OseeServerContext.BRANCH_CONTEXT);
- register(new SearchEngineServlet(sessionManager, search, caching.getAttributeTypeCache()),
- OseeServerContext.SEARCH_CONTEXT);
+ register(new SearchEngineServlet(sessionManager, search, translationService), OseeServerContext.SEARCH_CONTEXT);
register(new SearchEngineTaggerServlet(sessionManager, tagger), OseeServerContext.SEARCH_TAGGING_CONTEXT);
register(new ServerLookupServlet(serverLookup, appServerManager), OseeServerContext.LOOKUP_CONTEXT);
register(new SessionManagementServlet(sessionManager, authenticationManager), OseeServerContext.SESSION_CONTEXT);
diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/ArtifactMatch.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/ArtifactMatch.java
deleted file mode 100644
index dbbb5bfe5e2..00000000000
--- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/ArtifactMatch.java
+++ /dev/null
@@ -1,63 +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.search.engine;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
-import org.eclipse.osee.framework.jdk.core.type.HashCollection;
-
-/**
- * @author Roberto E. Escobar
- */
-public class ArtifactMatch {
- private final int artId;
- private final int branchId;
- private boolean hasMatchLocations;
- private final HashCollection<Long, MatchLocation> attributes;
-
- public ArtifactMatch(int branchId, int artId) {
- this.artId = artId;
- this.branchId = branchId;
- attributes = new HashCollection<Long, MatchLocation>();
- hasMatchLocations = false;
- }
-
- void addAttribute(long gammaId, Collection<MatchLocation> matches) {
- if (matches != null && !matches.isEmpty()) {
- hasMatchLocations = true;
- }
- if (matches == null) {
- matches = Collections.emptyList();
- }
- attributes.put(gammaId, matches);
- }
-
- public Set<Long> getAttributes() {
- return attributes.keySet();
- }
-
- public Collection<MatchLocation> getMatchLocations(long gammaId) {
- return attributes.getValues(gammaId);
- }
-
- public boolean hasMatchLocations() {
- return hasMatchLocations;
- }
-
- public int getArtId() {
- return artId;
- }
-
- public int getId() {
- return branchId;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/IAttributeTaggerProvider.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/IAttributeTaggerProvider.java
index 677355af873..ae57ba4ebb8 100644
--- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/IAttributeTaggerProvider.java
+++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/IAttributeTaggerProvider.java
@@ -12,6 +12,8 @@ package org.eclipse.osee.framework.search.engine;
import java.util.List;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.message.SearchOptions;
+import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
import org.eclipse.osee.framework.search.engine.attribute.AttributeData;
import org.eclipse.osee.framework.search.engine.utility.ITagCollector;
@@ -33,6 +35,7 @@ public interface IAttributeTaggerProvider {
*
* @param attributeData attribute to search in
* @param value to search in attribute content
+ * @param options search options
* @return match location
*/
public List<MatchLocation> find(AttributeData attributeData, String toSearch, SearchOptions options) throws OseeCoreException;
diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/IAttributeTaggerProviderManager.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/IAttributeTaggerProviderManager.java
index 3799effac38..b680c994de0 100644
--- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/IAttributeTaggerProviderManager.java
+++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/IAttributeTaggerProviderManager.java
@@ -11,6 +11,8 @@
package org.eclipse.osee.framework.search.engine;
import java.util.List;
+import org.eclipse.osee.framework.core.message.SearchOptions;
+import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
import org.eclipse.osee.framework.search.engine.attribute.AttributeData;
import org.eclipse.osee.framework.search.engine.utility.ITagCollector;
@@ -42,6 +44,7 @@ public interface IAttributeTaggerProviderManager {
*
* @param attributeData attribute to search in
* @param value to search in attribute content
+ * @param options search options
* @return match location
*/
public List<MatchLocation> find(AttributeData attributeData, String toSearch, SearchOptions options) throws Exception;
diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/SearchResult.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/SearchResult.java
deleted file mode 100644
index 8cd7602fd93..00000000000
--- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/SearchResult.java
+++ /dev/null
@@ -1,113 +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.search.engine;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.framework.search.engine.utility.ITagCollector;
-
-/**
- * @author Roberto E. Escobar
- */
-public class SearchResult implements ITagCollector {
-
- private final String rawSearch;
- private final Map<String, Long> searchTags = new LinkedHashMap<String, Long>();
- private final Map<Integer, Map<Integer, ArtifactMatch>> entries =
- new HashMap<Integer, Map<Integer, ArtifactMatch>>();
- private int size;
- private String errorMessage;
-
- public SearchResult(String rawSearch) {
- this.rawSearch = rawSearch;
- this.errorMessage = Strings.emptyString();
- this.size = 0;
- }
-
- public String getRawSearch() {
- return rawSearch;
- }
-
- public Map<String, Long> getSearchTags() {
- return searchTags;
- }
-
- public void add(int branchId, int artId, long gammaId) {
- add(branchId, artId, gammaId, null);
- }
-
- public void add(int branchId, int artId, long gammaId, List<MatchLocation> matches) {
- Map<Integer, ArtifactMatch> match = entries.get(branchId);
- ArtifactMatch artifact = null;
- if (match == null) {
- match = new HashMap<Integer, ArtifactMatch>();
- entries.put(branchId, match);
- } else {
- artifact = match.get(artId);
- }
-
- if (artifact == null) {
- artifact = new ArtifactMatch(branchId, artId);
- match.put(artId, artifact);
- size++;
- }
-
- artifact.addAttribute(gammaId, matches);
- }
-
- public Set<Integer> getBranchIds() {
- return entries.keySet();
- }
-
- public Set<Integer> getArtifactIds(int branch) {
- Map<Integer, ArtifactMatch> toReturn = entries.get(branch);
- if (toReturn == null) {
- return Collections.emptySet();
- }
- return toReturn.keySet();
- }
-
- public Collection<ArtifactMatch> getArtifacts(int branch) {
- Map<Integer, ArtifactMatch> toReturn = entries.get(branch);
- if (toReturn == null) {
- return Collections.emptyList();
- }
- return toReturn.values();
- }
-
- public int size() {
- return size;
- }
-
- public boolean isEmpty() {
- return size() == 0;
- }
-
- public String getErrorMessage() {
- return errorMessage;
- }
-
- public void setErrorMessage(String errorMessage) {
- this.errorMessage = errorMessage != null ? errorMessage : Strings.emptyString();
- }
-
- @Override
- public void addTag(String word, Long codedTag) {
- this.searchTags.put(word, codedTag);
- }
-
-}
diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/SearchResultToXmlOperation.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/SearchResultToXmlOperation.java
deleted file mode 100644
index 96eea7018ca..00000000000
--- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/SearchResultToXmlOperation.java
+++ /dev/null
@@ -1,128 +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.search.engine;
-
-import java.io.Writer;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Map.Entry;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.core.operation.AbstractOperation;
-import org.eclipse.osee.framework.core.util.Conditions;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.framework.search.engine.internal.Activator;
-
-public class SearchResultToXmlOperation extends AbstractOperation {
-
- private final SearchResult searchResult;
- private final Writer writer;
-
- public SearchResultToXmlOperation(SearchResult searchResult, Writer writer) {
- super("Write Search Results", Activator.PLUGIN_ID);
- this.searchResult = searchResult;
- this.writer = writer;
- }
-
- @Override
- protected void doWork(IProgressMonitor monitor) throws Exception {
- Conditions.checkNotNull(searchResult, "searchResult");
- Conditions.checkNotNull(writer, "writer");
-
- XMLOutputFactory factory = XMLOutputFactory.newInstance();
- XMLStreamWriter xmlWriter = null;
- try {
- xmlWriter = factory.createXMLStreamWriter(writer);
- xmlWriter.writeStartDocument();
-
- writeRawSearch(xmlWriter, searchResult.getRawSearch());
- writeSearchWords(xmlWriter, searchResult.getSearchTags());
- writeErrorMessage(xmlWriter, searchResult.getErrorMessage());
- writeSearchData(xmlWriter, searchResult);
- xmlWriter.writeEndElement();
- xmlWriter.writeEndDocument();
- } finally {
- if (xmlWriter != null) {
- xmlWriter.close();
- }
- }
- }
-
- private void writeSearchWords(XMLStreamWriter xmlWriter, Map<String, Long> searchTags) throws XMLStreamException {
- xmlWriter.writeStartElement("searchTags");
- for (Entry<String, Long> word : searchTags.entrySet()) {
- xmlWriter.writeStartElement("word");
- xmlWriter.writeCharacters(word.getKey());
- xmlWriter.writeEndElement();
- xmlWriter.writeStartElement("tag");
- xmlWriter.writeCharacters(String.valueOf(word.getValue()));
- xmlWriter.writeEndElement();
- }
- xmlWriter.writeEndElement();
- }
-
- private void writeRawSearch(XMLStreamWriter xmlWriter, String rawSearch) throws XMLStreamException {
- xmlWriter.writeStartElement("rawSearch");
- if (Strings.isValid(rawSearch)) {
- xmlWriter.writeCData(rawSearch);
- }
- xmlWriter.writeEndElement();
- }
-
- private void writeErrorMessage(XMLStreamWriter xmlWriter, String errorMessage) throws XMLStreamException {
- xmlWriter.writeStartElement("error");
- if (Strings.isValid(errorMessage)) {
- xmlWriter.writeCData(errorMessage);
- }
- xmlWriter.writeEndElement();
- }
-
- private void writeSearchData(XMLStreamWriter xmlWriter, SearchResult results) throws Exception {
- for (Integer branchId : results.getBranchIds()) {
- xmlWriter.writeStartElement("match");
- xmlWriter.writeAttribute("branchId", String.valueOf(branchId));
- for (ArtifactMatch artifactMatch : results.getArtifacts(branchId)) {
- writeArtifactMatch(xmlWriter, artifactMatch);
- }
- xmlWriter.writeEndElement();
- }
- }
-
- private void writeArtifactMatch(XMLStreamWriter xmlWriter, ArtifactMatch artifactMatch) throws XMLStreamException {
- xmlWriter.writeStartElement("art");
- xmlWriter.writeAttribute("artId", String.valueOf(artifactMatch.getArtId()));
- for (Long gammaId : artifactMatch.getAttributes()) {
- Collection<MatchLocation> locations = artifactMatch.getMatchLocations(gammaId);
- writeAttributes(xmlWriter, gammaId, locations);
- }
- xmlWriter.writeEndElement();
- }
-
- private void writeAttributes(XMLStreamWriter xmlWriter, Long gammaId, Collection<MatchLocation> locations) throws XMLStreamException {
- xmlWriter.writeStartElement("attr");
- xmlWriter.writeAttribute("gammaId", String.valueOf(gammaId));
- if (locations != null) {
- for (MatchLocation location : locations) {
- writeLocationData(xmlWriter, location);
- }
- }
- xmlWriter.writeEndElement();
- }
-
- private void writeLocationData(XMLStreamWriter xmlWriter, MatchLocation location) throws XMLStreamException {
- xmlWriter.writeStartElement("location");
- xmlWriter.writeAttribute("start", String.valueOf(location.getStartPosition()));
- xmlWriter.writeAttribute("end", String.valueOf(location.getEndPosition()));
- xmlWriter.writeEndElement();
- }
-}
diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/attribute/AttributeDataStore.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/attribute/AttributeDataStore.java
index 7bb1aea93fd..662c4c9ec1e 100644
--- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/attribute/AttributeDataStore.java
+++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/attribute/AttributeDataStore.java
@@ -16,6 +16,7 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import org.eclipse.osee.framework.core.enums.DeletionFlag;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
import org.eclipse.osee.framework.core.model.type.AttributeType;
@@ -67,7 +68,7 @@ public final class AttributeDataStore {
return attributeData;
}
- public static Set<AttributeData> getAttributesByTags(int branchId, boolean includeDeleted, final Collection<Long> tagData, final AttributeType... attributeTypes) throws OseeCoreException {
+ public static Set<AttributeData> getAttributesByTags(int branchId, DeletionFlag deletionFlag, final Collection<Long> tagData, final AttributeType... attributeTypes) throws OseeCoreException {
final Set<AttributeData> toReturn = new HashSet<AttributeData>();
IdJoinQuery oseeIdJoin = null;
@@ -75,7 +76,8 @@ public final class AttributeDataStore {
boolean useAttrTypeJoin = attributeTypes.length > 1;
try {
- String sqlQuery = searchTagQueryBuilder.getQuery(tagData.size(), useAttrTypeJoin, branchId, includeDeleted);
+ String sqlQuery =
+ searchTagQueryBuilder.getQuery(tagData.size(), useAttrTypeJoin, branchId, deletionFlag.areDeletedAllowed());
List<Object> params = new ArrayList<Object>();
params.addAll(tagData);
diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/AttributeTaggerProviderManagerImpl.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/AttributeTaggerProviderManagerImpl.java
index fe0cc084bae..61d9d48b3a6 100644
--- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/AttributeTaggerProviderManagerImpl.java
+++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/AttributeTaggerProviderManagerImpl.java
@@ -15,12 +15,12 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.eclipse.osee.framework.core.exception.InvalidTaggerException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.message.SearchOptions;
import org.eclipse.osee.framework.core.model.cache.AttributeTypeCache;
import org.eclipse.osee.framework.core.model.type.AttributeType;
+import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
import org.eclipse.osee.framework.search.engine.IAttributeTaggerProvider;
import org.eclipse.osee.framework.search.engine.IAttributeTaggerProviderManager;
-import org.eclipse.osee.framework.search.engine.MatchLocation;
-import org.eclipse.osee.framework.search.engine.SearchOptions;
import org.eclipse.osee.framework.search.engine.attribute.AttributeData;
import org.eclipse.osee.framework.search.engine.utility.ITagCollector;
diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/search/AttributeSearch.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/search/AttributeSearch.java
deleted file mode 100644
index f1e4b1ded7b..00000000000
--- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/search/AttributeSearch.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Created on Aug 25, 2010
- *
- * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
- */
-package org.eclipse.osee.framework.search.engine.internal.search;
-
-import java.util.Collection;
-import org.eclipse.osee.framework.search.engine.attribute.AttributeData;
-
-public class AttributeSearch implements ISearchFactory {
-
- @Override
- public Collection<AttributeData> queryMatches() {
- // AttributeSearch attributeSearch =
- // new AttributeSearch(tagProcessor, attributeAccessor, searchString, branchId, options, attributeTypes);
- // return attributeSearch.
- return null;
- }
-}
diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/search/ISearchFactory.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/search/ISearchFactory.java
deleted file mode 100644
index 49ca86edad3..00000000000
--- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/search/ISearchFactory.java
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * Created on Aug 25, 2010
- *
- * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
- */
-package org.eclipse.osee.framework.search.engine.internal.search;
-
-import java.util.Collection;
-import org.eclipse.osee.framework.search.engine.attribute.AttributeData;
-
-public interface ISearchFactory {
-
- Collection<AttributeData> queryMatches();
-}
diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/search/SearchEngine.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/search/SearchEngine.java
index ee044026388..67a70dc1bd5 100644
--- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/search/SearchEngine.java
+++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/search/SearchEngine.java
@@ -14,17 +14,22 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+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.AttributeTypeCache;
+import org.eclipse.osee.framework.core.model.cache.BranchCache;
+import org.eclipse.osee.framework.core.model.type.AttributeType;
+import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.search.engine.IAttributeTaggerProviderManager;
import org.eclipse.osee.framework.search.engine.ISearchEngine;
-import org.eclipse.osee.framework.search.engine.MatchLocation;
-import org.eclipse.osee.framework.search.engine.SearchOptions.SearchOptionsEnum;
-import org.eclipse.osee.framework.search.engine.SearchResult;
import org.eclipse.osee.framework.search.engine.attribute.AttributeData;
import org.eclipse.osee.framework.search.engine.attribute.AttributeDataStore;
import org.eclipse.osee.framework.search.engine.internal.Activator;
+import org.eclipse.osee.framework.search.engine.utility.ITagCollector;
import org.eclipse.osee.framework.search.engine.utility.TagProcessor;
/**
@@ -35,30 +40,54 @@ public class SearchEngine implements ISearchEngine {
private final SearchStatistics statistics;
private final TagProcessor tagProcessor;
private final IAttributeTaggerProviderManager taggingManager;
+ private final AttributeTypeCache attributeTypeCache;
+ private final BranchCache branchCache;
- public SearchEngine(SearchStatistics statistics, TagProcessor tagProcessor, IAttributeTaggerProviderManager taggingManager) {
+ public SearchEngine(SearchStatistics statistics, TagProcessor tagProcessor, IAttributeTaggerProviderManager taggingManager, AttributeTypeCache attributeTypeCache, BranchCache branchCache) {
this.statistics = statistics;
this.tagProcessor = tagProcessor;
this.taggingManager = taggingManager;
+ this.attributeTypeCache = attributeTypeCache;
+ this.branchCache = branchCache;
+ }
+
+ private AttributeType[] getAttributeTypes(Collection<IAttributeType> tokens) throws OseeCoreException {
+ AttributeType[] attributeTypes = new AttributeType[tokens.size()];
+ int index = 0;
+ for (IAttributeType identity : tokens) {
+ attributeTypes[index++] = attributeTypeCache.get(identity);
+ }
+ return attributeTypes;
}
@Override
- public void search(SearchRequest searchRequest, SearchResponse searchResponse) throws Exception {
+ public void search(SearchRequest searchRequest, final SearchResponse searchResponse) throws Exception {
String searchString = searchRequest.getRawSearch();
- SearchResult results = new SearchResult(searchString);
-
long startTime = System.currentTimeMillis();
- tagProcessor.collectFromString(results.getRawSearch(), results);
- Map<String, Long> searchTags = results.getSearchTags();
+ final Map<String, Long> searchTags = searchResponse.getSearchTags();
+ tagProcessor.collectFromString(searchString, new ITagCollector() {
+
+ @Override
+ public void addTag(String word, Long codedTag) {
+ searchTags.put(word, codedTag);
+ }
+ });
+
if (searchTags.isEmpty()) {
- results.setErrorMessage("No words found in search string. Please try again.");
+ searchResponse.setErrorMessage("No words found in search string. Please try again.");
} else {
long startDataStoreSearch = System.currentTimeMillis();
+
+ SearchOptions options = searchRequest.getOptions();
+ Collection<IAttributeType> attributeTypeTokens = options.getAttributeTypeFilter();
+ AttributeType[] attributeTypes = getAttributeTypes(attributeTypeTokens);
+
+ int branchId = branchCache.get(searchRequest.getBranch()).getId();
Collection<AttributeData> tagMatches =
- AttributeDataStore.getAttributesByTags(searchRequest.getBranchId(), searchRequest.isIncludeDeleted(),
- searchTags.values(), attributeTypes);
+ AttributeDataStore.getAttributesByTags(branchId, options.getDeletionFlag(), searchTags.values(),
+ attributeTypes);
String message =
String.format("Attribute Search Query found [%d] in [%d] ms", tagMatches.size(),
System.currentTimeMillis() - startDataStoreSearch);
@@ -67,18 +96,18 @@ public class SearchEngine implements ISearchEngine {
long timeAfterPass1 = System.currentTimeMillis() - startTime;
long secondPass = System.currentTimeMillis();
- boolean bypassSecondPass = !options.getBoolean(SearchOptionsEnum.match_word_order.asStringOption());
+ boolean bypassSecondPass = !options.isMatchWordOrder();
if (bypassSecondPass) {
for (AttributeData attributeData : tagMatches) {
- results.add(attributeData.getBranchId(), attributeData.getArtId(), attributeData.getGammaId());
+ searchResponse.add(attributeData.getBranchId(), attributeData.getArtId(), attributeData.getGammaId());
}
} else {
for (AttributeData attributeData : tagMatches) {
try {
List<MatchLocation> locations = taggingManager.find(attributeData, searchString, options);
if (!locations.isEmpty()) {
- results.add(attributeData.getBranchId(), attributeData.getArtId(), attributeData.getGammaId(),
- locations);
+ searchResponse.add(attributeData.getBranchId(), attributeData.getArtId(),
+ attributeData.getGammaId(), locations);
}
} catch (Exception ex) {
OseeLog.log(Activator.class, Level.SEVERE, String.format("Error processing: [%s]", attributeData));
@@ -88,15 +117,15 @@ public class SearchEngine implements ISearchEngine {
secondPass = System.currentTimeMillis() - secondPass;
String firstPassMsg =
- String.format("Pass 1: [%d items in %d ms]);", bypassSecondPass ? results.size() : tagMatches.size(),
- timeAfterPass1);
- String secondPassMsg = String.format(" Pass 2: [%d items in %d ms]", results.size(), secondPass);
+ String.format("Pass 1: [%d items in %d ms] -",
+ bypassSecondPass ? searchResponse.matches() : tagMatches.size(), timeAfterPass1);
+
+ String secondPassMsg = String.format(" Pass 2: [%d items in %d ms]", searchResponse.matches(), secondPass);
System.out.println(String.format("Search for [%s] - %s%s", searchString, firstPassMsg,
bypassSecondPass ? "" : secondPassMsg));
- statistics.addEntry(searchString, branchId, options, results.size(), System.currentTimeMillis() - startTime);
+ statistics.addEntry(searchRequest, searchResponse.matches(), System.currentTimeMillis() - startTime);
}
- return results;
}
@Override
diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/search/SearchStatistics.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/search/SearchStatistics.java
index a8561f7ff44..c76f9c828c6 100644
--- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/search/SearchStatistics.java
+++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/search/SearchStatistics.java
@@ -10,14 +10,16 @@
*******************************************************************************/
package org.eclipse.osee.framework.search.engine.internal.search;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.message.SearchRequest;
+import org.eclipse.osee.framework.core.util.Conditions;
import org.eclipse.osee.framework.search.engine.ISearchStatistics;
-import org.eclipse.osee.framework.search.engine.SearchOptions;
/**
* @author Roberto E. Escobar
*/
public class SearchStatistics implements Cloneable, ISearchStatistics {
- public static final SearchStatistics EMPTY_STATS = new SearchStatistics();
+ public static final SearchStatistics EMPTY_STATS = new EmptyStats();
private static final String EMPTY_STRING = "";
private long averageProcessingTime;
private int totalProcessed;
@@ -57,20 +59,21 @@ public class SearchStatistics implements Cloneable, ISearchStatistics {
return longestQuery;
}
- public void addEntry(String queryString, int branchId, SearchOptions options, int found, long processingTime) {
+ public void addEntry(SearchRequest searchRequest, int found, long processingTime) throws OseeCoreException {
+ Conditions.checkNotNull(searchRequest, "searchRequest");
this.totalProcessed++;
this.totalProcessingTime += processingTime;
+
this.averageProcessingTime = totalProcessingTime / this.totalProcessed;
if (processingTime > this.longestProcessingTime) {
- this.longestQuery =
- String.format("Query:[%s] BranchId:[%d] Options:[%s] Found:[%d in %d ms]", queryString, branchId,
- options.toString(), found, processingTime);
+ this.longestProcessingTime = processingTime;
+ this.longestQuery = String.format("%s - [%d in %d ms]", searchRequest.toString(), found, processingTime);
}
}
@Override
- protected SearchStatistics clone() throws CloneNotSupportedException {
+ public SearchStatistics clone() throws CloneNotSupportedException {
SearchStatistics other = (SearchStatistics) super.clone();
other.averageProcessingTime = this.averageProcessingTime;
other.totalProcessed = this.totalProcessed;
@@ -79,4 +82,11 @@ public class SearchStatistics implements Cloneable, ISearchStatistics {
other.longestQuery = this.longestQuery;
return other;
}
+
+ private static final class EmptyStats extends SearchStatistics {
+ @Override
+ public void addEntry(SearchRequest searchRequest, int found, long processingTime) {
+ throw new UnsupportedOperationException();
+ }
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/services/SearchEngineRegHandler.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/services/SearchEngineRegHandler.java
index 1fb74af1b4c..d37ff9fd325 100644
--- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/services/SearchEngineRegHandler.java
+++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/services/SearchEngineRegHandler.java
@@ -11,6 +11,9 @@
package org.eclipse.osee.framework.search.engine.internal.services;
import java.util.Map;
+import org.eclipse.osee.framework.core.model.cache.AttributeTypeCache;
+import org.eclipse.osee.framework.core.model.cache.BranchCache;
+import org.eclipse.osee.framework.core.services.IOseeCachingService;
import org.eclipse.osee.framework.core.util.AbstractTrackingHandler;
import org.eclipse.osee.framework.core.util.OsgiUtil;
import org.eclipse.osee.framework.database.IOseeDatabaseService;
@@ -30,6 +33,7 @@ public class SearchEngineRegHandler extends AbstractTrackingHandler {
//@formatter:off
private static final Class<?>[] SERVICE_DEPENDENCIES = new Class<?>[] {
IAttributeTaggerProviderManager.class,
+ IOseeCachingService.class,
IOseeDatabaseService.class
};
//@formatter:on
@@ -48,12 +52,17 @@ public class SearchEngineRegHandler extends AbstractTrackingHandler {
@Override
public void onActivate(BundleContext context, Map<Class<?>, Object> services) {
- // IOseeDatabaseService databaseService = getService(IOseeDatabaseService.class, services);
IAttributeTaggerProviderManager taggingManager = getService(IAttributeTaggerProviderManager.class, services);
+ IOseeCachingService cachingService = getService(IOseeCachingService.class, services);
+ // IOseeDatabaseService databaseService = getService(IOseeDatabaseService.class, services);
SearchStatistics searchStatistics = new SearchStatistics();
- ISearchEngine searchEngine = new SearchEngine(searchStatistics, processor, taggingManager);
+ AttributeTypeCache attributeTypeCache = cachingService.getAttributeTypeCache();
+ BranchCache branchCache = cachingService.getBranchCache();
+
+ ISearchEngine searchEngine =
+ new SearchEngine(searchStatistics, processor, taggingManager, attributeTypeCache, branchCache);
serviceRegistration = context.registerService(ISearchEngine.class.getName(), searchEngine, null);
}
diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/tagger/DefaultAttributeTaggerProvider.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/tagger/DefaultAttributeTaggerProvider.java
index cf1f5f1c343..ac094ca7575 100644
--- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/tagger/DefaultAttributeTaggerProvider.java
+++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/tagger/DefaultAttributeTaggerProvider.java
@@ -14,12 +14,12 @@ import java.io.InputStream;
import java.util.Collections;
import java.util.List;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.message.SearchOptions;
+import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.resource.management.IResourceLocatorManager;
import org.eclipse.osee.framework.resource.management.IResourceManager;
-import org.eclipse.osee.framework.search.engine.MatchLocation;
-import org.eclipse.osee.framework.search.engine.SearchOptions;
import org.eclipse.osee.framework.search.engine.attribute.AttributeData;
import org.eclipse.osee.framework.search.engine.utility.ITagCollector;
import org.eclipse.osee.framework.search.engine.utility.TagProcessor;
diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/tagger/XmlAttributeTaggerProvider.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/tagger/XmlAttributeTaggerProvider.java
index e6543d198b5..77561667975 100644
--- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/tagger/XmlAttributeTaggerProvider.java
+++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/tagger/XmlAttributeTaggerProvider.java
@@ -14,13 +14,13 @@ import java.io.InputStream;
import java.util.Collections;
import java.util.List;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.message.SearchOptions;
+import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.jdk.core.util.io.xml.XmlTextInputStream;
import org.eclipse.osee.framework.resource.management.IResourceLocatorManager;
import org.eclipse.osee.framework.resource.management.IResourceManager;
-import org.eclipse.osee.framework.search.engine.MatchLocation;
-import org.eclipse.osee.framework.search.engine.SearchOptions;
import org.eclipse.osee.framework.search.engine.attribute.AttributeData;
import org.eclipse.osee.framework.search.engine.utility.ITagCollector;
import org.eclipse.osee.framework.search.engine.utility.TagProcessor;
diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/WordOrderMatcher.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/WordOrderMatcher.java
index f9ea8257942..dcf2b028298 100644
--- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/WordOrderMatcher.java
+++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/utility/WordOrderMatcher.java
@@ -19,10 +19,9 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeExceptions;
+import org.eclipse.osee.framework.core.message.SearchOptions;
+import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.framework.search.engine.MatchLocation;
-import org.eclipse.osee.framework.search.engine.SearchOptions;
-import org.eclipse.osee.framework.search.engine.SearchOptions.SearchOptionsEnum;
/**
* @author Roberto E. Escobar
@@ -38,7 +37,7 @@ public final class WordOrderMatcher {
Reader reader = null;
try {
reader = new InputStreamReader(inputStream, "UTF-8");
- boolean isCaseInsensitive = !options.getBoolean(SearchOptionsEnum.case_sensitive.asStringOption());
+ boolean isCaseInsensitive = !options.isCaseSensitive();
char[] charsToSearch = WordsUtil.removeExtraSpacesAndSpecialCharacters(toSearch, isCaseInsensitive);
int charCount = 0;
int index = 0;
@@ -89,7 +88,7 @@ public final class WordOrderMatcher {
matchLocation.setEndPosition(charCount);
matchLocations.add(matchLocation.clone());
index = 0;
- if (!options.getBoolean(SearchOptionsEnum.find_all_locations.asStringOption())) {
+ if (!options.isFindAllLocationsEnabled()) {
break;
}
}
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 c36ff7fd756..b27a9bedeaa 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,31 +10,28 @@
*******************************************************************************/
package org.eclipse.osee.framework.skynet.core.artifact.search;
-import java.util.Collection;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
+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.HashCollection;
+import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
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.ArtifactXmlQueryResultParser.MatchLocation;
/**
* @author Roberto E. Escobar
*/
public class ArtifactMatch {
private final Artifact artifact;
- private HashCollection<Long, MatchLocation> attributeMatches;
+ private final ArtifactMatchMetaData matchMetaData;
- protected ArtifactMatch(Artifact artifact) {
+ public ArtifactMatch(Artifact artifact, ArtifactMatchMetaData matchMetaData) {
this.artifact = artifact;
- this.attributeMatches = null;
+ this.matchMetaData = matchMetaData;
}
public boolean hasMatchData() {
- return attributeMatches != null;
- }
-
- protected void addMatches(HashCollection<Long, MatchLocation> attributeMatches) {
- this.attributeMatches = attributeMatches;
+ return matchMetaData != null;
}
public Artifact getArtifact() {
@@ -43,11 +40,10 @@ public class ArtifactMatch {
public HashCollection<Attribute<?>, MatchLocation> getMatchData() throws OseeCoreException {
HashCollection<Attribute<?>, MatchLocation> matchData = new HashCollection<Attribute<?>, MatchLocation>();
-
for (Attribute<?> attribute : artifact.getAttributes()) {
- Collection<MatchLocation> locations = attributeMatches.getValues((long) attribute.getGammaId());
- if (locations != null) {
- matchData.put(attribute, locations);
+ AttributeMatchMetaData match = matchMetaData.getAttributeMatch((long) attribute.getGammaId());
+ if (match != null) {
+ matchData.put(attribute, match.getLocations());
}
}
return matchData;
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 70781e76735..980d927d334 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
@@ -30,6 +30,8 @@ import org.eclipse.osee.framework.core.exception.ArtifactDoesNotExist;
import org.eclipse.osee.framework.core.exception.MultipleArtifactsExist;
import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.message.SearchOptions;
+import org.eclipse.osee.framework.core.message.SearchRequest;
import org.eclipse.osee.framework.core.model.TransactionRecord;
import org.eclipse.osee.framework.core.model.event.IBasicGuidArtifact;
import org.eclipse.osee.framework.core.model.type.ArtifactType;
@@ -431,9 +433,15 @@ public class ArtifactQuery {
* @param allowDeleted <b>true</b> includes deleted artifacts in results; <b>false</b> omits deleted artifacts
* @return a collection of the artifacts found or an empty collection if none are found
*/
- public static List<Artifact> getArtifactListFromAttributeKeywords(IOseeBranch branch, String queryString, boolean matchWordOrder, DeletionFlag allowDeleted, boolean isCaseSensitive, IAttributeType... attributeTypes) throws OseeCoreException {
- return new HttpArtifactQuery(branch, queryString, matchWordOrder, allowDeleted, isCaseSensitive, attributeTypes).getArtifacts(
- FULL, null, INCLUDE_CACHE, false, allowDeleted);
+ public static List<Artifact> getArtifactListFromAttributeKeywords(IOseeBranch branch, String queryString, boolean isMatchWordOrder, DeletionFlag deletionFlag, boolean isCaseSensitive, IAttributeType... attributeTypes) throws OseeCoreException {
+ SearchOptions options = new SearchOptions();
+ options.setAttributeTypeFilter(attributeTypes);
+ options.setCaseSensive(isCaseSensitive);
+ options.setDeletedIncluded(deletionFlag);
+ options.setMatchWordOrder(isMatchWordOrder);
+
+ SearchRequest searchRequest = new SearchRequest(branch, queryString);
+ return new HttpArtifactQuery(searchRequest).getArtifacts(FULL, INCLUDE_CACHE);
}
/**
@@ -444,9 +452,8 @@ 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(IOseeBranch branch, String queryString, boolean matchWordOrder, DeletionFlag allowDeleted, boolean findAllMatchLocations, boolean isCaseSensitive, IAttributeType... attributeTypes) throws OseeCoreException {
- return new HttpArtifactQuery(branch, queryString, matchWordOrder, allowDeleted, isCaseSensitive, attributeTypes).getArtifactsWithMatches(
- FULL, null, INCLUDE_CACHE, false, allowDeleted, findAllMatchLocations);
+ public static List<ArtifactMatch> getArtifactMatchesFromAttributeKeywords(SearchRequest searchRequest) throws OseeCoreException {
+ return new HttpArtifactQuery(searchRequest).getArtifactsWithMatches(FULL, INCLUDE_CACHE);
}
public static Artifact reloadArtifactFromId(int artId, IOseeBranch branch) throws OseeCoreException {
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactXmlQueryResultParser.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactXmlQueryResultParser.java
deleted file mode 100644
index 233ba98ef21..00000000000
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactXmlQueryResultParser.java
+++ /dev/null
@@ -1,202 +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.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-import org.eclipse.osee.framework.database.core.JoinUtility;
-import org.eclipse.osee.framework.database.core.JoinUtility.ArtifactJoinQuery;
-import org.eclipse.osee.framework.jdk.core.type.HashCollection;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.framework.jdk.core.util.io.xml.AbstractSaxHandler;
-import org.eclipse.osee.framework.logging.OseeLog;
-import org.eclipse.osee.framework.skynet.core.internal.Activator;
-import org.xml.sax.Attributes;
-
-/**
- * <pre>
- * &lt;search&gt;
- * &lt;match branchId=&quot;15&quot;&gt;
- * &lt;art artId=&quot;87577&quot;&gt;
- * &lt;attr gammaId=&quot;292554&quot;&gt;
- * &lt;location start=&quot;27036&quot; end=&quot;27045&quot;/&gt;
- * &lt;location start=&quot;28570&quot; end=&quot;28579&quot;/&gt;
- * &lt;/attr&gt;
- * &lt;/art&gt;
- * &lt;/match&gt;
- * &lt;/search&gt;
- * </pre>
- *
- * @author Roberto E. Escobar
- */
-public class ArtifactXmlQueryResultParser extends AbstractSaxHandler {
-
- private final List<XmlArtifactSearchResult> results;
- private XmlArtifactSearchResult currentResult;
- private long currentAttribute;
- private int currentArtifact;
-
- public ArtifactXmlQueryResultParser() {
- this.results = new ArrayList<XmlArtifactSearchResult>();
- this.currentResult = null;
- this.currentAttribute = -1;
- this.currentArtifact = -1;
- }
-
- private void handleError(Throwable ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- }
-
- public List<XmlArtifactSearchResult> getResults() {
- return results;
- }
-
- @Override
- public void startElementFound(String uri, String localName, String name, Attributes attributes) {
- try {
- if (name.equalsIgnoreCase("search")) {
- currentResult = new XmlArtifactSearchResult();
- } else if (name.equalsIgnoreCase("match")) {
- handleMatch(attributes);
- } else if (name.equalsIgnoreCase("art")) {
- handleArtifact(attributes);
- } else if (name.equalsIgnoreCase("attr")) {
- handleAttribute(attributes);
- } else if (name.equalsIgnoreCase("location")) {
- handleMatchLocation(attributes);
- }
- } catch (Throwable ex) {
- handleError(ex);
- }
- }
-
- private void handleMatch(Attributes attributes) {
- String branchIdStr = attributes.getValue("branchId");
- if (Strings.isValid(branchIdStr)) {
- if (currentResult != null) {
- currentResult.setBranchId(Integer.parseInt(branchIdStr));
- }
- }
- }
-
- private void handleArtifact(Attributes attributes) {
- String artIdStr = attributes.getValue("artId");
- if (Strings.isValid(artIdStr)) {
- currentArtifact = Integer.parseInt(artIdStr);
- if (currentResult != null) {
- currentResult.addArtifact(currentArtifact);
- }
- }
- }
-
- private void handleAttribute(Attributes attributes) {
- String gammaId = attributes.getValue("gammaId");
- if (Strings.isValid(gammaId)) {
- currentAttribute = Long.parseLong(gammaId);
- }
- }
-
- private void handleMatchLocation(Attributes attributes) {
- String startAt = attributes.getValue("start");
- String stopAt = attributes.getValue("end");
- if (currentResult != null && currentArtifact > -1 && currentAttribute > -1 && Strings.isValid(startAt) && Strings.isValid(stopAt)) {
- int start = Integer.parseInt(startAt);
- int stop = Integer.parseInt(stopAt);
- currentResult.addAttribute(currentArtifact, currentAttribute, start, stop);
- }
- }
-
- @Override
- public void endElementFound(String uri, String localName, String name) {
- try {
- if (name.equalsIgnoreCase("search")) {
- // do nothing
- } else if (name.equalsIgnoreCase("match")) {
- if (currentResult != null) {
- results.add(currentResult);
- currentResult = null;
- }
- } else if (name.equalsIgnoreCase("art")) {
- currentArtifact = -1;
- } else if (name.equalsIgnoreCase("attr")) {
- currentAttribute = -1;
- }
- } catch (Throwable ex) {
- handleError(ex);
- }
- }
-
- public static final class XmlArtifactSearchResult {
- private final ArtifactJoinQuery artifactJoinQuery;
- private int branchId;
- private final Map<Integer, HashCollection<Long, MatchLocation>> attributeMatches;
-
- public XmlArtifactSearchResult() {
- this.artifactJoinQuery = JoinUtility.createArtifactJoinQuery();
- this.branchId = -1;
- this.attributeMatches = new HashMap<Integer, HashCollection<Long, MatchLocation>>();
- }
-
- private void setBranchId(int branchId) {
- this.branchId = branchId;
- }
-
- private void addArtifact(int artifactId) {
- artifactJoinQuery.add(artifactId, branchId);
- }
-
- private void addAttribute(int artifactId, long gammaId, int start, int end) {
- HashCollection<Long, MatchLocation> matches = attributeMatches.get(artifactId);
- if (matches == null) {
- matches = new HashCollection<Long, MatchLocation>();
- attributeMatches.put(artifactId, matches);
- }
- matches.put(gammaId, new MatchLocation(start, end));
- }
-
- public ArtifactJoinQuery getJoinQuery() {
- return artifactJoinQuery;
- }
-
- public int getId() {
- return branchId;
- }
-
- public boolean hasAttriuteMatches() {
- return !attributeMatches.isEmpty();
- }
-
- public HashCollection<Long, MatchLocation> getAttributeMatches(int artifactId) {
- return attributeMatches.get(artifactId);
- }
- }
-
- public static class MatchLocation {
- private final int startPosition;
- private final int endPosition;
-
- public MatchLocation(int startPosition, int endPosition) {
- this.startPosition = startPosition;
- this.endPosition = endPosition;
- }
-
- public int getStartPosition() {
- return startPosition;
- }
-
- public int getEndPosition() {
- return endPosition;
- }
- }
-}
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
index 3fa60a6a48d..4ca65ea5cb0 100644
--- 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
@@ -10,242 +10,69 @@
*******************************************************************************/
package org.eclipse.osee.framework.skynet.core.artifact.search;
-import static org.eclipse.osee.framework.core.enums.DeletionFlag.INCLUDE_DELETED;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.HttpURLConnection;
-import java.net.URL;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.eclipse.osee.framework.core.client.ClientSessionManager;
-import org.eclipse.osee.framework.core.client.server.HttpUrlBuilderClient;
-import org.eclipse.osee.framework.core.data.IAttributeType;
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.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.core.exception.OseeExceptions;
-import org.eclipse.osee.framework.core.util.HttpProcessor;
-import org.eclipse.osee.framework.core.util.HttpProcessor.AcquireResult;
-import org.eclipse.osee.framework.database.core.JoinUtility;
-import org.eclipse.osee.framework.jdk.core.type.HashCollection;
-import org.eclipse.osee.framework.jdk.core.type.Pair;
-import org.eclipse.osee.framework.jdk.core.type.PropertyStore;
-import org.eclipse.osee.framework.jdk.core.type.PropertyStoreWriter;
+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.core.util.Conditions;
import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.framework.jdk.core.util.io.CharBackedInputStream;
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.ISearchConfirmer;
+import org.eclipse.osee.framework.skynet.core.artifact.HttpClientMessage;
import org.eclipse.osee.framework.skynet.core.artifact.LoadLevel;
import org.eclipse.osee.framework.skynet.core.artifact.LoadType;
-import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactXmlQueryResultParser.MatchLocation;
-import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactXmlQueryResultParser.XmlArtifactSearchResult;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.XMLReaderFactory;
/**
* @author Roberto E. Escobar
*/
final class HttpArtifactQuery {
- private final String queryString;
- private final boolean matchWordOrder;
- private final IAttributeType[] attributeTypes;
- private final DeletionFlag includeDeleted;
- private final IOseeBranch branch;
- private final boolean isCaseSensitive;
+ private final SearchRequest searchRequest;
- protected HttpArtifactQuery(IOseeBranch branch, String queryString, boolean matchWordOrder, DeletionFlag includeDeleted, boolean isCaseSensitive, IAttributeType... attributeTypes) {
- this.branch = branch;
- this.matchWordOrder = matchWordOrder;
- this.includeDeleted = includeDeleted;
- this.attributeTypes = attributeTypes;
- this.queryString = queryString;
- this.isCaseSensitive = isCaseSensitive;
+ protected HttpArtifactQuery(SearchRequest searchRequest) {
+ this.searchRequest = searchRequest;
}
- private String getSearchUrl(String sessionId) throws OseeDataStoreException {
- Map<String, String> parameters = new HashMap<String, String>();
- parameters.put("sessionId", sessionId);
- return HttpUrlBuilderClient.getInstance().getOsgiServletServiceUrl(OseeServerContext.SEARCH_CONTEXT, parameters);
+ 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;
}
- private CharBackedInputStream getSearchParameters(String sessionId, boolean withMatches, boolean findAllMatchLocations) throws IOException, OseeCoreException {
- CharBackedInputStream backedInputStream = new CharBackedInputStream();
-
- PropertyStore propertyStore = new PropertyStore(sessionId);
- propertyStore.put("branchId", BranchManager.getBranchId(branch));
- propertyStore.put("query", queryString);
- propertyStore.put("include deleted", includeDeleted == INCLUDE_DELETED ? true : false);
- propertyStore.put("match word order", matchWordOrder);
-
- String[] attributeTypeGuids = new String[attributeTypes.length];
- int index = 0;
- for (IAttributeType attributeType : attributeTypes) {
- attributeTypeGuids[index++] = attributeType.getGuid();
- }
- propertyStore.put("attributeType", attributeTypeGuids);
- propertyStore.put("case sensitive", isCaseSensitive);
-
- if (matchWordOrder) {
- propertyStore.put("as xml", withMatches);
- if (withMatches) {
- propertyStore.put("find all locations", findAllMatchLocations);
- }
- }
- PropertyStoreWriter writer = new PropertyStoreWriter();
- writer.save(propertyStore, backedInputStream.getWriter());
-
- return backedInputStream;
- }
-
- public List<Artifact> getArtifacts(LoadLevel loadLevel, ISearchConfirmer confirmer, LoadType reload, boolean historical, DeletionFlag allowDeleted) throws OseeCoreException {
- List<Artifact> toReturn = null;
- Pair<String, ByteArrayOutputStream> data = executeSearch(false, false);
- if (data != null) {
- try {
- Pair<Integer, Integer> queryIdAndSize = handleAsDbJoin(data.getSecond());
- if (queryIdAndSize != null && queryIdAndSize.getSecond() > 0) {
- try {
- toReturn =
- ArtifactLoader.loadArtifactsFromQueryId(queryIdAndSize.getFirst(), loadLevel, confirmer,
- queryIdAndSize.getSecond(), reload, historical, allowDeleted);
- } finally {
- JoinUtility.deleteQuery(JoinUtility.JoinItem.ARTIFACT, queryIdAndSize.getFirst().intValue());
- }
- }
- } catch (Exception ex) {
- OseeExceptions.wrapAndThrow(ex);
- }
- }
- if (toReturn == null) {
- toReturn = java.util.Collections.emptyList();
- }
- return toReturn;
+ public List<Artifact> getArtifacts(LoadLevel loadLevel, LoadType reload) throws OseeCoreException {
+ SearchResponse response = executeSearch();
+ return loadArtifacts(response, loadLevel, reload);
}
- public List<ArtifactMatch> getArtifactsWithMatches(LoadLevel loadLevel, ISearchConfirmer confirmer, LoadType reload, boolean historical, DeletionFlag allowDeleted, boolean findAllMatchLocations) throws OseeCoreException {
+ public List<ArtifactMatch> getArtifactsWithMatches(LoadLevel loadLevel, LoadType reload) throws OseeCoreException {
List<ArtifactMatch> toReturn = new ArrayList<ArtifactMatch>();
- Pair<String, ByteArrayOutputStream> data = executeSearch(true, findAllMatchLocations);
- if (data != null) {
-
- try {
- if (data.getFirst().endsWith("xml")) {
- String errorMessage = isErrorMessage(data.getSecond());
- if (Strings.isValid(errorMessage)) {
- throw new OseeArgumentException(errorMessage);
- } else {
- List<XmlArtifactSearchResult> results = handleAsXmlResults(data.getSecond());
- for (XmlArtifactSearchResult result : results) {
- try {
- result.getJoinQuery().store();
- List<Artifact> artifacts =
- ArtifactLoader.loadArtifactsFromQueryId(result.getJoinQuery().getQueryId(), loadLevel,
- confirmer, result.getJoinQuery().size(), reload, historical, allowDeleted);
- for (Artifact artifact : artifacts) {
- ArtifactMatch artMatch = new ArtifactMatch(artifact);
- HashCollection<Long, MatchLocation> attributeMatches =
- result.getAttributeMatches(artifact.getArtId());
- if (attributeMatches != null) {
- artMatch.addMatches(attributeMatches);
- }
- toReturn.add(artMatch);
- }
- } finally {
- result.getJoinQuery().delete();
- }
- }
- }
- } else if (data.getFirst().endsWith("plain")) {
- Pair<Integer, Integer> queryIdAndSize = handleAsDbJoin(data.getSecond());
- if (queryIdAndSize != null && queryIdAndSize.getSecond() > 0) {
- try {
- List<Artifact> artifactList =
- ArtifactLoader.loadArtifactsFromQueryId(queryIdAndSize.getFirst(), loadLevel, confirmer,
- queryIdAndSize.getSecond(), reload, historical, allowDeleted);
- for (Artifact artifact : artifactList) {
- toReturn.add(new ArtifactMatch(artifact));
- }
- } finally {
- JoinUtility.deleteQuery(JoinUtility.JoinItem.ARTIFACT, queryIdAndSize.getFirst().intValue());
- }
- }
- }
- } catch (Exception ex) {
- OseeExceptions.wrapAndThrow(ex);
- }
+ SearchResponse response = executeSearch();
+ List<Artifact> artifacts = loadArtifacts(response, loadLevel, reload);
+ for (Artifact artifact : artifacts) {
+ ArtifactMatchMetaData match = response.getArtifactMatch(artifact.getBranch().getId(), artifact.getArtId());
+ toReturn.add(new ArtifactMatch(artifact, match));
}
return toReturn;
}
- private static Pattern errorMessagePattern = Pattern.compile("<errorMessage=\"(.*?)\">");
-
- private String isErrorMessage(ByteArrayOutputStream outputStream) {
- String results = outputStream.toString();
- Matcher matcher = errorMessagePattern.matcher(results);
- if (matcher.find()) {
- String message = matcher.group(1);
- return message;
- }
- return null;
- }
-
- private Pair<String, ByteArrayOutputStream> executeSearch(boolean withMatches, boolean findAllMatchLocations) throws OseeCoreException {
- Pair<String, ByteArrayOutputStream> toReturn = null;
- String sessionId = ClientSessionManager.getSessionId();
- CharBackedInputStream inputStream = null;
- try {
- inputStream = getSearchParameters(sessionId, withMatches, findAllMatchLocations);
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- AcquireResult httpRequestResult =
- HttpProcessor.post(new URL(getSearchUrl(sessionId)), inputStream, "application/xml", "UTF-8", outputStream);
- if (httpRequestResult.getCode() == HttpURLConnection.HTTP_ACCEPTED) {
- toReturn = new Pair<String, ByteArrayOutputStream>(httpRequestResult.getContentType(), outputStream);
- } else if (httpRequestResult.getCode() != HttpURLConnection.HTTP_NO_CONTENT) {
- throw new OseeCoreException(String.format("Search error due to bad request: url[%s] status code: [%s]",
- inputStream.toString(), httpRequestResult.getCode()));
- }
- } catch (Exception ex) {
- OseeExceptions.wrapAndThrow(ex);
- } finally {
- if (inputStream != null) {
- try {
- inputStream.close();
- } catch (Exception ex) {
- OseeExceptions.wrapAndThrow(ex);
- }
- }
- }
- return toReturn;
- }
-
- private List<XmlArtifactSearchResult> handleAsXmlResults(ByteArrayOutputStream outputStream) throws SAXException, IOException {
- ArtifactXmlQueryResultParser parser = new ArtifactXmlQueryResultParser();
- XMLReader xmlReader = XMLReaderFactory.createXMLReader();
- xmlReader.setContentHandler(parser);
- xmlReader.parse(new InputSource(new ByteArrayInputStream(outputStream.toByteArray())));
- return parser.getResults();
- }
-
- private Pair<Integer, Integer> handleAsDbJoin(ByteArrayOutputStream outputStream) throws UnsupportedEncodingException {
- Pair<Integer, Integer> toReturn = null;
- String queryIdString = outputStream.toString("UTF-8");
- if (Strings.isValid(queryIdString)) {
- String[] entries = queryIdString.split(",\\s*");
- if (entries.length >= 2) {
- toReturn = new Pair<Integer, Integer>(new Integer(entries[0]), new Integer(entries[1]));
- }
+ private List<Artifact> loadArtifacts(SearchResponse response, LoadLevel loadLevel, LoadType reload) throws OseeCoreException {
+ List<Artifact> toReturn = new ArrayList<Artifact>();
+ for (Integer 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.ui.skynet/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF
index f5db77b59ad..3a35063158c 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF
@@ -48,6 +48,7 @@ Import-Package: com.lowagie.text;version="2.1.7",
org.eclipse.osee.framework.core.data,
org.eclipse.osee.framework.core.enums,
org.eclipse.osee.framework.core.exception,
+ org.eclipse.osee.framework.core.message,
org.eclipse.osee.framework.core.model,
org.eclipse.osee.framework.core.model.access,
org.eclipse.osee.framework.core.model.cache,
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/AbstractArtifactSearchQuery.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/AbstractArtifactSearchQuery.java
index c91d9a09735..b2dda72ddd4 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/AbstractArtifactSearchQuery.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/search/AbstractArtifactSearchQuery.java
@@ -38,11 +38,25 @@ public abstract class AbstractArtifactSearchQuery implements ISearchQuery {
public abstract IStatus run(final IProgressMonitor pm);
public String getResultLabel() {
- String branch = "";
- if (aResult.getArtifactResults() != null && !aResult.getArtifactResults().isEmpty()) {
- branch = " on Branch: \"" + aResult.getArtifactResults().get(0).getBranch().getShortName() + "\"";
+ StringBuilder builder = new StringBuilder();
+ builder.append(getCriteriaLabel());
+ builder.append(" - ");
+ if (doneRunning) {
+ builder.append(aResult.getMatchCount());
+ if (aResult.getMatchCount() > 0) {
+ builder.append(" matches");
+ } else {
+ builder.append(" match");
+ }
+ if (aResult.getArtifactResults() != null && !aResult.getArtifactResults().isEmpty()) {
+ builder.append(" on Branch: \"");
+ builder.append(aResult.getArtifactResults().get(0).getBranch().getShortName());
+ builder.append("\"");
+ }
+ } else {
+ builder.append("busy");
}
- return getCriteriaLabel() + " - " + (doneRunning ? aResult.getMatchCount() + " matches" + branch : "busy");
+ return builder.toString();
}
public abstract String getCriteriaLabel();
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 f32ff2322f6..acd34419f3d 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,6 +20,8 @@ import java.util.List;
import org.eclipse.jface.action.Action;
import org.eclipse.osee.framework.core.enums.DeletionFlag;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
+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.jdk.core.util.Strings;
import org.eclipse.osee.framework.plugin.core.IActionable;
@@ -34,6 +36,7 @@ import org.eclipse.osee.framework.ui.skynet.widgets.XBranchSelectWidget;
import org.eclipse.osee.framework.ui.swt.ALayout;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.osee.framework.ui.swt.Widgets;
+import org.eclipse.search.ui.ISearchQuery;
import org.eclipse.search.ui.NewSearchUI;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
@@ -244,17 +247,22 @@ public class QuickSearchView extends ViewPart implements IActionable, Listener {
} else if (Widgets.isAccessible(searchComposite) && searchComposite.isExecuteSearchEvent(event) && Widgets.isAccessible(optionsComposite)) {
DeletionFlag allowDeleted = optionsComposite.isIncludeDeletedEnabled() ? INCLUDE_DELETED : EXCLUDE_DELETED;
NewSearchUI.activateSearchResultView();
+
+ ISearchQuery query;
if (optionsComposite.isSearchByIdEnabled()) {
- NewSearchUI.runQueryInBackground(new IdArtifactSearch(searchComposite.getQuery(), branch, allowDeleted));
+ query = new IdArtifactSearch(searchComposite.getQuery(), branch, allowDeleted);
} else {
- NewSearchUI.runQueryInBackground(new RemoteArtifactSearch(searchComposite.getQuery(), //
- branch, //
- allowDeleted, //
- optionsComposite.isMatchWordOrderEnabled(), //
- optionsComposite.isMatchAllLocationsEnabled(),//
- optionsComposite.isCaseSensitiveEnabled(),//
- optionsComposite.getAttributeTypeFilter()));
+ SearchOptions options = new SearchOptions();
+ options.setDeletedIncluded(allowDeleted);
+ options.setAttributeTypeFilter(optionsComposite.getAttributeTypeFilter());
+ options.setCaseSensive(optionsComposite.isCaseSensitiveEnabled());
+ options.setFindAllLocationsEnabled(optionsComposite.isMatchAllLocationsEnabled());
+ options.setMatchWordOrder(optionsComposite.isMatchWordOrderEnabled());
+
+ SearchRequest searchRequest = new SearchRequest(branch, searchComposite.getQuery(), options);
+ query = new RemoteArtifactSearch(searchRequest);
}
+ NewSearchUI.runQueryInBackground(query);
} else {
// branch has been selected; allow user to set up search string
compositeEnablement(searchComposite, true);
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 1377b901da5..53de905b9ea 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
@@ -10,19 +10,17 @@
*******************************************************************************/
package org.eclipse.osee.framework.ui.skynet.search;
-import static org.eclipse.osee.framework.core.enums.DeletionFlag.INCLUDE_DELETED;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
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.data.IAttributeType;
-import org.eclipse.osee.framework.core.enums.DeletionFlag;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.model.Branch;
+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.util.Lib;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.jdk.core.util.io.xml.XmlTextInputStream;
@@ -32,7 +30,6 @@ 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.ArtifactXmlQueryResultParser.MatchLocation;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.skynet.search.page.AttributeLineElement;
import org.eclipse.osee.framework.ui.skynet.search.page.AttributeMatch;
@@ -44,52 +41,41 @@ import org.eclipse.search.ui.text.Match;
* @author Roberto E. Escobar
*/
final class RemoteArtifactSearch extends AbstractArtifactSearchQuery {
- private final String queryString;
- private final IAttributeType[] attributeTypes;
- private final DeletionFlag includeDeleted;
- private final boolean matchWordOrder;
- private final Branch branch;
- private final boolean findAllMatchLocations;
- private final boolean isCaseSensitive;
+ private final SearchRequest searchRequest;
- RemoteArtifactSearch(String queryString, Branch branch, DeletionFlag includeDeleted, boolean matchWordOrder, boolean findAllMatchLocations, boolean isCaseSensitive, IAttributeType... attributeTypes) {
- this.branch = branch;
- this.includeDeleted = includeDeleted;
- this.attributeTypes = attributeTypes;
- this.queryString = queryString;
- this.matchWordOrder = matchWordOrder;
- this.findAllMatchLocations = findAllMatchLocations;
- this.isCaseSensitive = isCaseSensitive;
+ RemoteArtifactSearch(SearchRequest searchRequest) {
+ this.searchRequest = searchRequest;
}
@Override
public String getCriteriaLabel() {
+ SearchOptions options = searchRequest.getOptions();
List<String> optionsList = new ArrayList<String>();
- if (includeDeleted == INCLUDE_DELETED) {
+ if (options.getDeletionFlag().areDeletedAllowed()) {
optionsList.add("Include Deleted");
}
- if (matchWordOrder) {
+ if (options.isMatchWordOrder()) {
optionsList.add("Match Word Order");
- if (findAllMatchLocations) {
+ if (options.isFindAllLocationsEnabled()) {
optionsList.add("All Matches");
} else {
optionsList.add("1st Match Only");
}
}
- if (isCaseSensitive) {
+ if (options.isCaseSensitive()) {
optionsList.add("Case Sensitive");
}
- if (attributeTypes != null && attributeTypes.length > 0) {
- optionsList.add(String.format("Attribute Type Filter:%s", Arrays.deepToString(attributeTypes)));
+ if (options.isAttributeTypeFiltered()) {
+ optionsList.add(String.format("Attribute Type Filter:%s", options.getAttributeTypeFilter()));
}
- String options =
+ String optionsLabel =
String.format(" - Options:[%s]",
org.eclipse.osee.framework.jdk.core.util.Collections.toString(", ", optionsList));
- return String.format("%s%s", queryString, optionsList.size() > 0 ? options : "");
+ return String.format("%s%s", searchRequest.getRawSearch(), optionsList.size() > 0 ? optionsLabel : "");
}
@Override
@@ -102,9 +88,7 @@ final class RemoteArtifactSearch extends AbstractArtifactSearchQuery {
long endOfloadTime = startTime;
int lineMatches = 0;
try {
- List<ArtifactMatch> matches =
- ArtifactQuery.getArtifactMatchesFromAttributeKeywords(branch, queryString, matchWordOrder, includeDeleted,
- findAllMatchLocations, isCaseSensitive, attributeTypes);
+ List<ArtifactMatch> matches = ArtifactQuery.getArtifactMatchesFromAttributeKeywords(searchRequest);
endOfloadTime = System.currentTimeMillis();

Back to the top