Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmisinco2013-12-09 15:46:25 +0000
committerjmisinco2013-12-12 20:38:09 +0000
commitb080a40051b990baea9340fbd326b1bd823cfb63 (patch)
treec8ea64b216854feaac7e39fbc154f05caef25789 /plugins/org.eclipse.osee.orcs.rest
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/org.eclipse.osee.orcs.rest')
-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
2 files changed, 42 insertions, 17 deletions
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);

Back to the top