Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmisinco2013-12-18 16:47:59 +0000
committerRoberto E. Escobar2014-01-03 21:28:31 +0000
commitbd741be618b6c0f88acd2022ec3ca13e364108e8 (patch)
tree0e45512ac7d11764e4bfba7fc4e8504cba027a3a /plugins
parentb3f1333e5abbf4df11687361627b3632b95bf730 (diff)
downloadorg.eclipse.osee-bd741be618b6c0f88acd2022ec3ca13e364108e8.tar.gz
org.eclipse.osee-bd741be618b6c0f88acd2022ec3ca13e364108e8.tar.xz
org.eclipse.osee-bd741be618b6c0f88acd2022ec3ca13e364108e8.zip
bug[ats_SG7ZV]: Quick Search results do not highlight the search string
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/TokenDelimiterMatch.java31
-rw-r--r--plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/io/xml/XmlTextInputStream.java1
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/SecondPassMatcherTest.java12
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/SecondPassScannerTest.java103
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/UtilityTestSuite.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/AnyTokenOrderProcessor.java5
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/CheckedOptions.java5
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/MatchTokenOrderProcessor.java7
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/SecondPassMatcher.java13
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/SecondPassScanner.java147
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/TokenOrderProcessor.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/OptionConverter.java14
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/PredicateFactoryImpl.java22
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/Predicate.java11
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslatorImplTest.java11
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchDslTest.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/AttributeTypePredicateHandlerTest.java30
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/ExistsTypePredicateHandlerTest.java24
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/RelatedToPredicateHandlerTest.java14
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslatorImpl_V1.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/AttributeTypePredicateHandler.java4
21 files changed, 353 insertions, 114 deletions
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/TokenDelimiterMatch.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/TokenDelimiterMatch.java
index 2eaf1762c6..5a4cc3c13d 100644
--- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/TokenDelimiterMatch.java
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/enums/TokenDelimiterMatch.java
@@ -10,33 +10,28 @@
*******************************************************************************/
package org.eclipse.osee.framework.core.enums;
-import java.util.regex.Pattern;
-
/**
* @author John Misinco
*/
-public class TokenDelimiterMatch implements QueryOption {
- public static final TokenDelimiterMatch EXACT = new TokenDelimiterMatch(Pattern.compile(""));
- public static final TokenDelimiterMatch WHITESPACE = new TokenDelimiterMatch(Pattern.compile("\\s+"));
- public static final TokenDelimiterMatch ANY = new TokenDelimiterMatch(Pattern.compile("([^a-zA-Z0-9])+"));
-
- private final Pattern pattern;
-
- private TokenDelimiterMatch(Pattern pattern) {
- this.pattern = pattern;
- }
-
- public Pattern getPattern() {
- return pattern;
- }
+public enum TokenDelimiterMatch implements QueryOption {
+ EXACT,
+ WHITESPACE,
+ ANY;
@Override
public void accept(OptionVisitor visitor) {
visitor.asTokenDelimiterMatch(this);
}
- public static TokenDelimiterMatch custom(String regex) {
- return new TokenDelimiterMatch(Pattern.compile(regex));
+ public static TokenDelimiterMatch fromString(String delimiter) {
+ TokenDelimiterMatch toReturn = ANY;
+ for (TokenDelimiterMatch value : values()) {
+ if (value.name().equals(delimiter)) {
+ toReturn = value;
+ break;
+ }
+ }
+ return toReturn;
}
}
diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/io/xml/XmlTextInputStream.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/io/xml/XmlTextInputStream.java
index 6273a9bbcd..3627502898 100644
--- a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/io/xml/XmlTextInputStream.java
+++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/util/io/xml/XmlTextInputStream.java
@@ -261,6 +261,7 @@ public class XmlTextInputStream extends BufferedInputStream {
}
}
}
+
if (available() <= 0) {
value = -1;
}
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/SecondPassMatcherTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/SecondPassMatcherTest.java
index 05270a9f54..c47dad391d 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/SecondPassMatcherTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/SecondPassMatcherTest.java
@@ -89,12 +89,6 @@ public class SecondPassMatcherTest {
getLocs());
addTest(data, matcher, "What does", "what does", CaseType.IGNORE_CASE, TokenDelimiterMatch.WHITESPACE,
TokenOrderType.MATCH_ORDER, MatchTokenCountType.MATCH_TOKEN_COUNT, false, getLocs(1, 13));
- addTest(data, matcher, "What->does] this mean", "what does this", CaseType.IGNORE_CASE,
- TokenDelimiterMatch.custom("(->|\\s|])+"), TokenOrderType.MATCH_ORDER, MatchTokenCountType.IGNORE_TOKEN_COUNT,
- false, getLocs(1, 16));
- addTest(data, matcher, "What->does] this mean", "what does this", CaseType.IGNORE_CASE,
- TokenDelimiterMatch.custom("(->|\\s|])+"), TokenOrderType.MATCH_ORDER, MatchTokenCountType.MATCH_TOKEN_COUNT,
- false, getLocs());
addTest(data, matcher, "What->does] .this. mean", "What does tHis", CaseType.IGNORE_CASE,
TokenDelimiterMatch.ANY, TokenOrderType.MATCH_ORDER, MatchTokenCountType.IGNORE_TOKEN_COUNT, false,
getLocs(1, 17));
@@ -136,12 +130,6 @@ public class SecondPassMatcherTest {
getLocs());
addTest(data, matcher, "What does", "what does", CaseType.IGNORE_CASE, TokenDelimiterMatch.WHITESPACE,
TokenOrderType.MATCH_ORDER, MatchTokenCountType.MATCH_TOKEN_COUNT, true, getLocs(1, 13));
- addTest(data, matcher, "What->does] this mean", "what does this", CaseType.IGNORE_CASE,
- TokenDelimiterMatch.custom("(->|\\s|])+"), TokenOrderType.MATCH_ORDER, MatchTokenCountType.IGNORE_TOKEN_COUNT,
- true, getLocs(1, 16));
- addTest(data, matcher, "What->does] this mean", "what does this", CaseType.IGNORE_CASE,
- TokenDelimiterMatch.custom("(->|\\s|])+"), TokenOrderType.MATCH_ORDER, MatchTokenCountType.MATCH_TOKEN_COUNT,
- true, getLocs());
addTest(data, matcher, "What->does] .this. mean", "What does tHis", CaseType.IGNORE_CASE,
TokenDelimiterMatch.ANY, TokenOrderType.MATCH_ORDER, MatchTokenCountType.IGNORE_TOKEN_COUNT, true,
getLocs(1, 17));
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/SecondPassScannerTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/SecondPassScannerTest.java
new file mode 100644
index 0000000000..da728eb08a
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/SecondPassScannerTest.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.db.internal.search.util;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
+import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
+import org.eclipse.osee.framework.jdk.core.type.Pair;
+import org.eclipse.osee.orcs.db.internal.search.SearchAsserts;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+/**
+ * @author John Misinco
+ */
+@RunWith(Parameterized.class)
+public class SecondPassScannerTest {
+
+ private final String input;
+ private final List<Pair<String, MatchLocation>> expectedMatches;
+ private final TokenDelimiterMatch delimiter;
+
+ public SecondPassScannerTest(String input, List<Pair<String, MatchLocation>> expectedMatches, TokenDelimiterMatch delimiter) {
+ this.input = input;
+ this.expectedMatches = expectedMatches;
+ this.delimiter = delimiter;
+ }
+
+ private void testResult(Pair<String, MatchLocation> expected, String next, MatchLocation match) {
+ Assert.assertEquals(expected.getFirst(), next);
+ SearchAsserts.assertEquals(expected.getSecond(), match);
+ }
+
+ @Test
+ public void testScanner() {
+ SecondPassScanner scanner = new SecondPassScanner(input, delimiter);
+ int i = 0;
+ while (scanner.hasNext()) {
+ String next = scanner.next();
+ MatchLocation match = scanner.match();
+ testResult(expectedMatches.get(i++), next, match);
+ }
+ Assert.assertEquals(expectedMatches.size(), i);
+ }
+
+ @Parameters
+ public static Collection<Object[]> data() {
+ List<Object[]> data = new ArrayList<Object[]>();
+
+ data.add(new Object[] {
+ "What->does] .this. mean",
+ getExpected(Arrays.asList("What", "does", "this", "mean"), 0, 4, 6, 10, 13, 17, 19, 23),
+ TokenDelimiterMatch.ANY});
+ data.add(new Object[] {
+ "Wh\ndo\rth. r",
+ getExpected(Arrays.asList("Wh", "do", "th", "r"), 0, 2, 3, 5, 6, 8, 10, 11),
+ TokenDelimiterMatch.ANY});
+ data.add(new Object[] {
+ "Â ® …tags… the",
+ getExpected(Arrays.asList("tags", "the"), 5, 9, 11, 14),
+ TokenDelimiterMatch.ANY});
+ data.add(new Object[] {
+ "What does this mean",
+ getExpected(Arrays.asList("What", "does", "this", "mean"), 0, 4, 7, 11, 14, 18, 19, 23),
+ TokenDelimiterMatch.WHITESPACE});
+ data.add(new Object[] {
+ "at->do]",
+ getExpected(Arrays.asList("a", "t", "-", ">", "d", "o", "]"), 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7),
+ TokenDelimiterMatch.EXACT});
+ data.add(new Object[] {
+ "Â ® …ta]",
+ getExpected(Arrays.asList(" ", " ", "t", "a", "]"), 1, 2, 3, 4, 5, 6, 6, 7, 7, 8),
+ TokenDelimiterMatch.EXACT});
+
+ return data;
+ }
+
+ private static List<Pair<String, MatchLocation>> getExpected(List<String> tokens, int... locations) {
+ List<Pair<String, MatchLocation>> toReturn = new LinkedList<Pair<String, MatchLocation>>();
+ List<MatchLocation> matchLocs = SearchAsserts.asLocations(locations);
+ for (int i = 0; i < tokens.size(); i++) {
+ Pair<String, MatchLocation> pair = new Pair<String, MatchLocation>(tokens.get(i), matchLocs.get(i));
+ toReturn.add(pair);
+ }
+ return toReturn;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/UtilityTestSuite.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/UtilityTestSuite.java
index 893835fd20..c3c8c8efaa 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/UtilityTestSuite.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/util/UtilityTestSuite.java
@@ -17,7 +17,7 @@ import org.junit.runners.Suite;
* @author Roberto E. Escobar
*/
@RunWith(Suite.class)
-@Suite.SuiteClasses({SecondPassMatcherTest.class, WordsUtilTest.class})
+@Suite.SuiteClasses({SecondPassMatcherTest.class, WordsUtilTest.class, SecondPassScannerTest.class})
public class UtilityTestSuite {
// Test Suite
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/AnyTokenOrderProcessor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/AnyTokenOrderProcessor.java
index 28d064f0d2..44ea2b9a5b 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/AnyTokenOrderProcessor.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/AnyTokenOrderProcessor.java
@@ -14,7 +14,6 @@ import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.regex.MatchResult;
import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
import org.eclipse.osee.framework.jdk.core.type.MutableInteger;
@@ -44,9 +43,9 @@ public class AnyTokenOrderProcessor implements TokenOrderProcessor {
}
@Override
- public boolean processToken(String token, MatchResult match) {
+ public boolean processToken(String token, MatchLocation match) {
if (trackingSet.found(token)) {
- locations.add(createMatchLocation(match.start(), match.end()));
+ locations.add(createMatchLocation(match.getStartPosition(), match.getEndPosition()));
}
return trackingSet.areAllFound();
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/CheckedOptions.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/CheckedOptions.java
index 610755920f..98a6751aa6 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/CheckedOptions.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/CheckedOptions.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.search.util;
-import java.util.regex.Pattern;
import org.eclipse.osee.framework.core.enums.CaseType;
import org.eclipse.osee.framework.core.enums.MatchTokenCountType;
import org.eclipse.osee.framework.core.enums.OptionVisitor;
@@ -51,8 +50,8 @@ public class CheckedOptions implements OptionVisitor {
return countType;
}
- public Pattern getDelimiter() {
- return delimiter.getPattern();
+ public TokenDelimiterMatch getDelimiter() {
+ return delimiter;
}
public void accept(QueryOption... options) {
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/MatchTokenOrderProcessor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/MatchTokenOrderProcessor.java
index 85f287646c..67f5c70910 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/MatchTokenOrderProcessor.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/MatchTokenOrderProcessor.java
@@ -13,7 +13,6 @@ package org.eclipse.osee.orcs.db.internal.search.util;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
-import java.util.regex.MatchResult;
import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
/**
@@ -45,18 +44,18 @@ public class MatchTokenOrderProcessor implements TokenOrderProcessor {
}
@Override
- public boolean processToken(String token, MatchResult match) {
+ public boolean processToken(String token, MatchLocation match) {
if (!tokensToSearch.get(matchIdx).equals(token)) {
matchIdx = 0;
}
if (tokensToSearch.get(matchIdx).equals(token)) {
if (matchIdx == 0) {
- matchStart = match.start();
+ matchStart = match.getStartPosition();
}
matchIdx++;
if (matchIdx == numTokensToMatch) {
- locations.add(createMatchLocation(matchStart, match.end()));
+ locations.add(createMatchLocation(matchStart, match.getEndPosition()));
matchIdx = 0;
}
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/SecondPassMatcher.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/SecondPassMatcher.java
index 3077a8c072..2cb56229bf 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/SecondPassMatcher.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/SecondPassMatcher.java
@@ -12,8 +12,6 @@ package org.eclipse.osee.orcs.db.internal.search.util;
import java.io.InputStream;
import java.util.List;
-import java.util.Scanner;
-import java.util.regex.MatchResult;
import org.eclipse.osee.framework.core.enums.CaseType;
import org.eclipse.osee.framework.core.enums.MatchTokenCountType;
import org.eclipse.osee.framework.core.enums.QueryOption;
@@ -49,9 +47,8 @@ public class SecondPassMatcher implements StreamMatcher {
}
private void parseSearchString(TokenOrderProcessor processor, String toSearch, CheckedOptions options) {
- Scanner toSearchScanner = new Scanner(toSearch);
+ SecondPassScanner toSearchScanner = new SecondPassScanner(toSearch, options.getDelimiter());
try {
- toSearchScanner.useDelimiter(options.getDelimiter());
while (toSearchScanner.hasNext()) {
String next = toSearchScanner.next();
next = normalizeCase(options.getCaseType(), next);
@@ -63,9 +60,8 @@ public class SecondPassMatcher implements StreamMatcher {
}
private void searchStream(TokenOrderProcessor processor, InputStream inputStream, CheckedOptions options, boolean findAllMatchLocations) {
- Scanner inputStreamScanner = new Scanner(inputStream);
+ SecondPassScanner inputStreamScanner = new SecondPassScanner(inputStream, options.getDelimiter());
try {
- inputStreamScanner.useDelimiter(options.getDelimiter());
int numTokensProcessed = 0;
boolean isProcessorDone = false;
while (inputStreamScanner.hasNext()) {
@@ -78,7 +74,7 @@ public class SecondPassMatcher implements StreamMatcher {
/**
* the purpose of this here is to allow one more token to be read after the processor has signaled that it
- * is complete. the if statement above will catch the case when too many tokens are present.
+ * is complete. The if statement above will catch the case when too many tokens are present.
*/
if (isProcessorDone && !findAllMatchLocations) {
break;
@@ -86,8 +82,7 @@ public class SecondPassMatcher implements StreamMatcher {
String next = inputStreamScanner.next();
next = normalizeCase(options.getCaseType(), next);
-
- MatchResult match = inputStreamScanner.match();
+ MatchLocation match = inputStreamScanner.match();
isProcessorDone = processor.processToken(next, match);
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/SecondPassScanner.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/SecondPassScanner.java
new file mode 100644
index 0000000000..5d0d30b03c
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/SecondPassScanner.java
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.db.internal.search.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
+import org.eclipse.osee.framework.core.exception.OseeExceptions;
+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;
+
+/**
+ * This class was created instead of using java.util.Scanner only due to the fact that the locations returned from the
+ * Scanner's match() function are relative to the Scanner's internal buffer. There are no methods provided to determine
+ * how many bytes have been read to get an offset.
+ *
+ * @author John Misinco
+ * @author Mark Joy
+ */
+public final class SecondPassScanner {
+
+ private InputStream input;
+ private final TokenDelimiterMatch delimiter;
+ private String next;
+ private int start, end = -1, bytesRead = 0;
+ private boolean eof = false;
+ private final StringBuilder buffer = new StringBuilder();
+
+ public SecondPassScanner(InputStream input, TokenDelimiterMatch delimiter) {
+ this.input = input;
+ this.delimiter = delimiter;
+ }
+
+ public SecondPassScanner(String input, TokenDelimiterMatch delimiter) {
+ try {
+ this.input = Lib.stringToInputStream(input);
+ } catch (UnsupportedEncodingException ex) {
+ OseeExceptions.wrapAndThrow(ex);
+ }
+
+ this.delimiter = delimiter;
+ }
+
+ /**
+ * <pre>
+ * UTF-8 definition:
+ * 00..7F - plain old ASCII
+ * 80..BF - non-initial bytes of multibyte code
+ * C2..FD - initial bytes of multibyte code (C0, C1 are not legal!)
+ * FE, FF - never used (so, free for byte-order marks).
+ * </pre>
+ */
+ private boolean isMultibyteStart(int read) {
+ return (read >= 0xC2 && read <= 0xFD);
+ }
+
+ private boolean isMultibyte(int read) {
+ return (read >= 0x80 && read <= 0xBF);
+ }
+
+ public boolean hasNext() {
+ int read = -1;
+ buffer.delete(0, buffer.length());
+ while (!eof) {
+ try {
+ read = input.read();
+ } catch (IOException ex) {
+ OseeExceptions.wrapAndThrow(ex);
+ }
+
+ if (!isMultibyte(read)) { // increment byte count for anything that's not a non-initial multibyte char
+ if (read == -1) {
+ eof = true;
+ } else {
+ bytesRead++;
+ }
+ if (!isMultibyteStart(read) && processChar(read)) { // only process chars that are not multibyte
+ break;
+ }
+ }
+ }
+
+ next = buffer.toString();
+ return Strings.isValid(next);
+ }
+
+ private boolean processChar(int read) {
+ boolean done = false;
+ switch (delimiter) {
+ case ANY:
+ if (Character.isLetterOrDigit(read)) {
+ buffer.append((char) read);
+ } else {
+ if (buffer.length() != 0) {
+ end = start + buffer.length();
+ done = true;
+ }
+ }
+ break;
+ case EXACT:
+ if (read != -1) {
+ end = bytesRead;
+ buffer.append((char) read);
+ }
+ done = true;
+ break;
+ case WHITESPACE:
+ if (Character.isWhitespace((char) read) || read == -1) {
+ if (buffer.length() != 0) {
+ end = start + buffer.length();
+ done = true;
+ }
+ } else {
+ buffer.append((char) read);
+ }
+ break;
+ }
+
+ if (buffer.length() == 1) {
+ start = bytesRead - 1;
+ }
+
+ return done;
+ }
+
+ public String next() {
+ return next;
+ }
+
+ public MatchLocation match() {
+ return new MatchLocation(start, end);
+ }
+
+ public void close() {
+ Lib.close(input);
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/TokenOrderProcessor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/TokenOrderProcessor.java
index 13266562bc..dd023f12ae 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/TokenOrderProcessor.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/util/TokenOrderProcessor.java
@@ -11,7 +11,6 @@
package org.eclipse.osee.orcs.db.internal.search.util;
import java.util.List;
-import java.util.regex.MatchResult;
import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
/**
@@ -26,7 +25,7 @@ public interface TokenOrderProcessor {
/**
* Returns true when all match criteria have been met
*/
- boolean processToken(String token, MatchResult match);
+ boolean processToken(String token, MatchLocation match);
List<MatchLocation> getLocations();
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/OptionConverter.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/OptionConverter.java
index 56c99aec32..0f6ac17ca0 100644
--- a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/OptionConverter.java
+++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/OptionConverter.java
@@ -26,7 +26,7 @@ import org.eclipse.osee.orcs.rest.model.search.SearchFlag;
*/
public class OptionConverter implements OptionVisitor, RestSearchOptions {
private final List<SearchFlag> flags = new LinkedList<SearchFlag>();
- private String delimiter;
+ private TokenDelimiterMatch delimiter;
private StringBuilder buffer;
@@ -35,10 +35,8 @@ public class OptionConverter implements OptionVisitor, RestSearchOptions {
for (QueryOption option : options) {
option.accept(this);
}
- if (buffer == null) {
- delimiter = TokenDelimiterMatch.ANY.getPattern().pattern();
- } else {
- delimiter = buffer.toString();
+ if (delimiter == null) {
+ delimiter = TokenDelimiterMatch.ANY;
}
}
@@ -73,7 +71,7 @@ public class OptionConverter implements OptionVisitor, RestSearchOptions {
if (buffer == null) {
buffer = new StringBuilder();
}
- buffer.append(option.getPattern().pattern());
+ buffer.append(option.name());
}
@Override
@@ -82,8 +80,8 @@ public class OptionConverter implements OptionVisitor, RestSearchOptions {
}
@Override
- public String getDelimiter() {
- return delimiter.toString();
+ public TokenDelimiterMatch getDelimiter() {
+ return delimiter;
}
}; \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/PredicateFactoryImpl.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/PredicateFactoryImpl.java
index 2786967277..fad3d676f9 100644
--- a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/PredicateFactoryImpl.java
+++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/PredicateFactoryImpl.java
@@ -27,7 +27,6 @@ import org.eclipse.osee.framework.core.enums.QueryOption;
import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
import org.eclipse.osee.framework.core.enums.TokenOrderType;
import org.eclipse.osee.framework.jdk.core.type.Identity;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.orcs.rest.model.search.Predicate;
import org.eclipse.osee.orcs.rest.model.search.SearchFlag;
import org.eclipse.osee.orcs.rest.model.search.SearchMethod;
@@ -45,7 +44,7 @@ public class PredicateFactoryImpl implements PredicateFactory {
List<SearchFlag> getFlags();
- String getDelimiter();
+ TokenDelimiterMatch getDelimiter();
}
@Override
@@ -73,21 +72,21 @@ public class PredicateFactoryImpl implements PredicateFactory {
}
private Predicate createIdsSearch(SearchMethod method, List<String> ids) {
- return new Predicate(method, emptyStringList, SearchOp.EQUALS, emptySearchFlagList, Strings.EMPTY_STRING, ids);
+ return new Predicate(method, emptyStringList, SearchOp.EQUALS, emptySearchFlagList, null, ids);
}
@Override
public Predicate createIsOfTypeSearch(Collection<? extends IArtifactType> artifactType) {
List<String> typeIds = getLongIds(artifactType);
- return new Predicate(SearchMethod.IS_OF_TYPE, emptyStringList, SearchOp.EQUALS, emptySearchFlagList,
- Strings.EMPTY_STRING, typeIds);
+ return new Predicate(SearchMethod.IS_OF_TYPE, emptyStringList, SearchOp.EQUALS, emptySearchFlagList, null,
+ typeIds);
}
@Override
public Predicate createTypeEqualsSearch(Collection<? extends IArtifactType> artifactType) {
List<String> typeIds = getLongIds(artifactType);
- return new Predicate(SearchMethod.TYPE_EQUALS, emptyStringList, SearchOp.EQUALS, emptySearchFlagList,
- Strings.EMPTY_STRING, typeIds);
+ return new Predicate(SearchMethod.TYPE_EQUALS, emptyStringList, SearchOp.EQUALS, emptySearchFlagList, null,
+ typeIds);
}
@Override
@@ -111,8 +110,7 @@ public class PredicateFactoryImpl implements PredicateFactory {
option.getDelimiter(), valuesList);
} else {
SearchOp op = convertToSearchOp(operator);
- return new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeIds, op, emptySearchFlagList, Strings.EMPTY_STRING,
- valuesList);
+ return new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeIds, op, emptySearchFlagList, null, valuesList);
}
}
@@ -121,14 +119,14 @@ public class PredicateFactoryImpl implements PredicateFactory {
public Predicate createAttributeExistsSearch(Collection<? extends IAttributeType> attributeTypes) {
List<String> typeIds = getLongIds(attributeTypes);
return new Predicate(SearchMethod.EXISTS_TYPE, Arrays.asList("attrType"), SearchOp.EQUALS, emptySearchFlagList,
- Strings.EMPTY_STRING, typeIds);
+ null, typeIds);
}
@Override
public Predicate createRelationExistsSearch(Collection<? extends IRelationType> relationTypes) {
List<String> typeIds = getLongIds(relationTypes);
return new Predicate(SearchMethod.EXISTS_TYPE, Arrays.asList("relType"), SearchOp.EQUALS, emptySearchFlagList,
- Strings.EMPTY_STRING, typeIds);
+ null, typeIds);
}
@Override
@@ -143,7 +141,7 @@ public class PredicateFactoryImpl implements PredicateFactory {
}
}
return new Predicate(SearchMethod.RELATED_TO, Arrays.asList(side + relationTypeSide.getGuid().toString()),
- SearchOp.EQUALS, emptySearchFlagList, Strings.EMPTY_STRING, values);
+ SearchOp.EQUALS, emptySearchFlagList, null, values);
}
private List<String> getLongIds(Collection<? extends Identity<Long>> types) {
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/Predicate.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/Predicate.java
index e25dff1bbc..7d9a5ebce2 100644
--- a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/Predicate.java
+++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/search/Predicate.java
@@ -12,6 +12,7 @@ package org.eclipse.osee.orcs.rest.model.search;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
+import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
import org.eclipse.osee.framework.jdk.core.util.Collections;
/**
@@ -25,12 +26,12 @@ public class Predicate {
private SearchOp op;
private List<SearchFlag> flags;
private List<String> values;
- private String delimiter;
+ private TokenDelimiterMatch delimiter;
public Predicate() {
}
- public Predicate(SearchMethod type, List<String> typeParameters, SearchOp op, List<SearchFlag> flags, String delimiter, List<String> values) {
+ public Predicate(SearchMethod type, List<String> typeParameters, SearchOp op, List<SearchFlag> flags, TokenDelimiterMatch delimiter, List<String> values) {
this.type = type;
this.typeParameters = typeParameters;
this.op = op;
@@ -39,8 +40,8 @@ public class Predicate {
this.delimiter = delimiter;
}
- public void setDelimiter(String regex) {
- this.delimiter = regex;
+ public void setDelimiter(TokenDelimiterMatch delimiter) {
+ this.delimiter = delimiter;
}
public void setType(SearchMethod type) {
@@ -83,7 +84,7 @@ public class Predicate {
return values;
}
- public String getDelimiter() {
+ public TokenDelimiterMatch getDelimiter() {
return delimiter;
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslatorImplTest.java b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslatorImplTest.java
index 5d679eb39d..75e2fc5c5b 100644
--- a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslatorImplTest.java
+++ b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslatorImplTest.java
@@ -12,13 +12,14 @@ package org.eclipse.osee.orcs.rest.internal.search.dsl;
import java.util.List;
import java.util.Random;
-import org.junit.Assert;
+import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.orcs.rest.model.search.Predicate;
import org.eclipse.osee.orcs.rest.model.search.SearchFlag;
import org.eclipse.osee.orcs.rest.model.search.SearchMethod;
import org.eclipse.osee.orcs.rest.model.search.SearchOp;
+import org.junit.Assert;
import org.junit.Test;
/**
@@ -160,19 +161,19 @@ public class DslTranslatorImplTest {
Assert.assertEquals(SearchOp.GREATER_THAN, predicate.getOp());
Assert.assertTrue(predicate.getValues().contains("AtsAdmin"));
- test = "[t:ids&tp:1000000000000070&op:<&v:AtsAdmin&d:'bo'b]''']";
- test += "&[t:attrType&tp:1000000000000070&op:==&v:TestAdmin&d:'bo'b]'[]&]'']";
+ test = "[t:ids&tp:1000000000000070&op:<&v:AtsAdmin&d:ANY']";
+ test += "&[t:attrType&tp:1000000000000070&op:==&v:TestAdmin&d:ANY']";
predicates = translator.translate(test);
Assert.assertEquals(2, predicates.size());
predicate = predicates.get(0);
Assert.assertEquals(SearchMethod.IDS, predicate.getType());
Assert.assertEquals(SearchOp.LESS_THAN, predicate.getOp());
Assert.assertTrue(predicate.getValues().contains("AtsAdmin"));
- Assert.assertEquals("bo'b]''", predicate.getDelimiter());
+ Assert.assertEquals(TokenDelimiterMatch.ANY, predicate.getDelimiter());
predicate = predicates.get(1);
Assert.assertEquals(SearchMethod.ATTRIBUTE_TYPE, predicate.getType());
Assert.assertEquals(SearchOp.EQUALS, predicate.getOp());
Assert.assertTrue(predicate.getValues().contains("TestAdmin"));
- Assert.assertEquals("bo'b]'[]&]'", predicate.getDelimiter());
+ Assert.assertEquals(TokenDelimiterMatch.ANY, predicate.getDelimiter());
}
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchDslTest.java b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchDslTest.java
index 42107cbf20..46d5456017 100644
--- a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchDslTest.java
+++ b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/dsl/SearchDslTest.java
@@ -65,8 +65,8 @@ public class SearchDslTest {
when(queryFactory.fromBranch(any(IOseeBranch.class))).thenReturn(builder);
Predicate predicate =
- new Predicate(SearchMethod.ATTRIBUTE_TYPE, Arrays.asList("1000000000000070"), SearchOp.EQUALS, null,
- Strings.EMPTY_STRING, Arrays.asList("AtsAdmin"));
+ new Predicate(SearchMethod.ATTRIBUTE_TYPE, Arrays.asList("1000000000000070"), SearchOp.EQUALS, null, null,
+ Arrays.asList("AtsAdmin"));
SearchRequest params =
new SearchRequest(BRANCH.getGuid(), Arrays.asList(predicate), Strings.EMPTY_STRING, Strings.EMPTY_STRING, 0,
false);
diff --git a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/AttributeTypePredicateHandlerTest.java b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/AttributeTypePredicateHandlerTest.java
index e3112606cd..cb6713b817 100644
--- a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/AttributeTypePredicateHandlerTest.java
+++ b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/AttributeTypePredicateHandlerTest.java
@@ -10,13 +10,15 @@
*******************************************************************************/
package org.eclipse.osee.orcs.rest.internal.search.predicate;
-import static org.mockito.Matchers.*;
-import static org.mockito.Mockito.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyCollectionOf;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.verify;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import org.junit.Assert;
import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.enums.CaseType;
import org.eclipse.osee.framework.core.enums.MatchTokenCountType;
@@ -29,6 +31,7 @@ import org.eclipse.osee.orcs.rest.model.search.SearchFlag;
import org.eclipse.osee.orcs.rest.model.search.SearchMethod;
import org.eclipse.osee.orcs.rest.model.search.SearchOp;
import org.eclipse.osee.orcs.search.QueryBuilder;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -44,7 +47,7 @@ public class AttributeTypePredicateHandlerTest {
@Mock
private QueryBuilder builder;
@Captor
- private ArgumentCaptor<TokenDelimiterMatch> pattern;
+ private ArgumentCaptor<TokenDelimiterMatch> delimiter;
@Captor
private ArgumentCaptor<Collection<String>> valueCaptor;
@@ -59,20 +62,20 @@ public class AttributeTypePredicateHandlerTest {
List<String> typeParameters = Collections.singletonList("0x0123");
List<SearchFlag> flags = Collections.emptyList();
List<String> values = Collections.singletonList("value");
- String delimiter = "delim";
Predicate testPredicate =
- new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.EQUALS, flags, delimiter, values);
+ new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.EQUALS, flags, TokenDelimiterMatch.ANY,
+ values);
handler.handle(builder, testPredicate);
- verify(builder).and(anyCollectionOf(IAttributeType.class), eq("value"), pattern.capture(),
+ verify(builder).and(anyCollectionOf(IAttributeType.class), eq("value"), delimiter.capture(),
eq(CaseType.IGNORE_CASE), eq(TokenOrderType.ANY_ORDER), eq(MatchTokenCountType.IGNORE_TOKEN_COUNT));
- Assert.assertTrue(delimiter.equals(pattern.getValue().getPattern().pattern()));
reset(builder);
flags = Arrays.asList(SearchFlag.values());
testPredicate =
- new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.EQUALS, flags, "delim", values);
+ new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.EQUALS, flags, TokenDelimiterMatch.ANY,
+ values);
handler.handle(builder, testPredicate);
- verify(builder).and(anyCollectionOf(IAttributeType.class), eq("value"), pattern.capture(),
+ verify(builder).and(anyCollectionOf(IAttributeType.class), eq("value"), delimiter.capture(),
eq(CaseType.MATCH_CASE), eq(TokenOrderType.MATCH_ORDER), eq(MatchTokenCountType.MATCH_TOKEN_COUNT));
}
@@ -83,13 +86,16 @@ public class AttributeTypePredicateHandlerTest {
List<SearchFlag> flags = Arrays.asList(SearchFlag.MATCH_CASE);
List<String> values = Collections.singletonList("value");
Predicate testPredicate =
- new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.GREATER_THAN, flags, "", values);
+ new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.GREATER_THAN, flags,
+ TokenDelimiterMatch.ANY, values);
handler.handle(builder, testPredicate);
verify(builder).and(any(IAttributeType.class), eq(Operator.GREATER_THAN), valueCaptor.capture());
Assert.assertEquals(values, valueCaptor.getValue());
reset(builder);
- testPredicate = new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.LESS_THAN, flags, "", values);
+ testPredicate =
+ new Predicate(SearchMethod.ATTRIBUTE_TYPE, typeParameters, SearchOp.LESS_THAN, flags, TokenDelimiterMatch.ANY,
+ values);
handler.handle(builder, testPredicate);
verify(builder).and(any(IAttributeType.class), eq(Operator.LESS_THAN), valueCaptor.capture());
Assert.assertEquals(values, valueCaptor.getValue());
diff --git a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/ExistsTypePredicateHandlerTest.java b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/ExistsTypePredicateHandlerTest.java
index 9c720cf4d4..fe5e838a70 100644
--- a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/ExistsTypePredicateHandlerTest.java
+++ b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/ExistsTypePredicateHandlerTest.java
@@ -10,23 +10,27 @@
*******************************************************************************/
package org.eclipse.osee.orcs.rest.internal.search.predicate;
-import static org.mockito.Matchers.*;
-import static org.mockito.Mockito.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyCollectionOf;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import org.junit.Assert;
import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.data.IRelationType;
import org.eclipse.osee.framework.core.data.IRelationTypeSide;
+import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.orcs.rest.model.search.Predicate;
import org.eclipse.osee.orcs.rest.model.search.SearchFlag;
import org.eclipse.osee.orcs.rest.model.search.SearchMethod;
import org.eclipse.osee.orcs.rest.model.search.SearchOp;
import org.eclipse.osee.orcs.search.QueryBuilder;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -138,7 +142,8 @@ public class ExistsTypePredicateHandlerTest {
String attrType2 = "34567";
List<String> values = Arrays.asList(attrType1, attrType2);
Predicate testPredicate =
- new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, SearchOp.EQUALS, flags, "", values);
+ new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, SearchOp.EQUALS, flags, TokenDelimiterMatch.ANY,
+ values);
handler.handle(builder, testPredicate);
verify(builder).andExists(attrTypeSideCaptor.capture());
@@ -157,14 +162,17 @@ public class ExistsTypePredicateHandlerTest {
String value = "12A4G";
List<String> values = Collections.singletonList(value);
Predicate testPredicate =
- new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, SearchOp.EQUALS, flags, "", values);
+ new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, SearchOp.EQUALS, flags, TokenDelimiterMatch.ANY,
+ values);
handler.handle(builder, testPredicate);
verify(builder, never()).andExists(anyCollectionOf(IAttributeType.class));
value = "12A4G";
typeParameters = Collections.singletonList("relType");
values = Collections.singletonList(value);
- testPredicate = new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, SearchOp.EQUALS, flags, "", values);
+ testPredicate =
+ new Predicate(SearchMethod.EXISTS_TYPE, typeParameters, SearchOp.EQUALS, flags, TokenDelimiterMatch.ANY,
+ values);
handler.handle(builder, testPredicate);
verify(builder, never()).andExists(any(IRelationTypeSide.class));
}
@@ -173,8 +181,8 @@ public class ExistsTypePredicateHandlerTest {
public void testBadValuesThrowException() throws OseeCoreException {
ExistsTypePredicateHandler handler = new ExistsTypePredicateHandler();
Predicate testPredicate =
- new Predicate(SearchMethod.ATTRIBUTE_TYPE, Collections.singletonList("relType"), SearchOp.EQUALS, null, "",
- Collections.singletonList("A12A4G"));
+ new Predicate(SearchMethod.ATTRIBUTE_TYPE, Collections.singletonList("relType"), SearchOp.EQUALS, null,
+ TokenDelimiterMatch.ANY, Collections.singletonList("A12A4G"));
handler.handle(builder, testPredicate);
}
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/RelatedToPredicateHandlerTest.java b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/RelatedToPredicateHandlerTest.java
index 87c36ec902..46a944e707 100644
--- a/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/RelatedToPredicateHandlerTest.java
+++ b/plugins/org.eclipse.osee.orcs.rest.test/src/org/eclipse/osee/orcs/rest/internal/search/predicate/RelatedToPredicateHandlerTest.java
@@ -10,14 +10,15 @@
*******************************************************************************/
package org.eclipse.osee.orcs.rest.internal.search.predicate;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import org.junit.Assert;
import org.eclipse.osee.framework.core.data.IRelationTypeSide;
import org.eclipse.osee.framework.core.enums.RelationSide;
+import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.orcs.rest.model.search.Predicate;
@@ -25,6 +26,7 @@ import org.eclipse.osee.orcs.rest.model.search.SearchFlag;
import org.eclipse.osee.orcs.rest.model.search.SearchMethod;
import org.eclipse.osee.orcs.rest.model.search.SearchOp;
import org.eclipse.osee.orcs.search.QueryBuilder;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -54,8 +56,8 @@ public class RelatedToPredicateHandlerTest {
RelatedToPredicateHandler handler = new RelatedToPredicateHandler();
List<SearchFlag> emptySearchFlags = Collections.emptyList();
Predicate testPredicate =
- new Predicate(SearchMethod.RELATED_TO, Arrays.asList("A1", "B2"), SearchOp.EQUALS, emptySearchFlags, "",
- Arrays.asList("4", "5"));
+ new Predicate(SearchMethod.RELATED_TO, Arrays.asList("A1", "B2"), SearchOp.EQUALS, emptySearchFlags,
+ TokenDelimiterMatch.ANY, Arrays.asList("4", "5"));
handler.handle(builder, testPredicate);
verify(builder, times(2)).andRelatedToLocalIds(rtsCaptor.capture(), idsCaptor.capture());
List<IRelationTypeSide> rts = rtsCaptor.getAllValues();
@@ -73,8 +75,8 @@ public class RelatedToPredicateHandlerTest {
RelatedToPredicateHandler handler = new RelatedToPredicateHandler();
List<SearchFlag> emptySearchFlags = Collections.emptyList();
Predicate testPredicate =
- new Predicate(SearchMethod.RELATED_TO, Arrays.asList("A1", "B2"), SearchOp.EQUALS, emptySearchFlags, "",
- Arrays.asList(GUID.create()));
+ new Predicate(SearchMethod.RELATED_TO, Arrays.asList("A1", "B2"), SearchOp.EQUALS, emptySearchFlags,
+ TokenDelimiterMatch.ANY, Arrays.asList(GUID.create()));
handler.handle(builder, testPredicate);
}
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslatorImpl_V1.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslatorImpl_V1.java
index b29f7e6985..13cec04199 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslatorImpl_V1.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/dsl/DslTranslatorImpl_V1.java
@@ -16,6 +16,7 @@ import java.util.List;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.orcs.rest.model.search.Predicate;
@@ -89,7 +90,8 @@ public class DslTranslatorImpl_V1 implements DslTranslator {
List<String> values = Arrays.asList(value.split(",\\s*"));
List<String> typeParams = Arrays.asList(typeParameters.split(",\\s*"));
- return new Predicate(searchMethod, typeParams, searchOp, searchFlags, delimiter, values);
+ TokenDelimiterMatch delim = TokenDelimiterMatch.fromString(delimiter);
+ return new Predicate(searchMethod, typeParams, searchOp, searchFlags, delim, values);
}
private String getMatch(Matcher m) {
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/AttributeTypePredicateHandler.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/AttributeTypePredicateHandler.java
index f6c9c2d207..5f69242ea3 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/AttributeTypePredicateHandler.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/predicate/AttributeTypePredicateHandler.java
@@ -17,7 +17,6 @@ import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.enums.CaseType;
import org.eclipse.osee.framework.core.enums.MatchTokenCountType;
import org.eclipse.osee.framework.core.enums.Operator;
-import org.eclipse.osee.framework.core.enums.TokenDelimiterMatch;
import org.eclipse.osee.framework.core.enums.TokenOrderType;
import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
@@ -53,8 +52,7 @@ public class AttributeTypePredicateHandler implements PredicateHandler {
MatchTokenCountType countType = getMatchTokenCountType(flags);
if (values.size() == 1) {
builder =
- builder.and(attributeTypes, values.iterator().next(),
- TokenDelimiterMatch.custom(predicate.getDelimiter()), ct, orderType, countType);
+ builder.and(attributeTypes, values.iterator().next(), predicate.getDelimiter(), ct, orderType, countType);
} else {
for (IAttributeType type : attributeTypes) {
builder = builder.and(type, getOperator(op), values);

Back to the top