Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2018-02-26 18:35:45 +0000
committerRyan D. Brooks2020-12-15 22:27:58 +0000
commitfea5e7c0b3bce10759c37618b4aaf87743eea7f0 (patch)
tree422f9e781225edb242e343cb5db6ab16a83da844
parent41981e24896ce2bc54332fa6dbc1df4b69cdbf7a (diff)
downloadorg.eclipse.osee-fea5e7c0b3bce10759c37618b4aaf87743eea7f0.tar.gz
org.eclipse.osee-fea5e7c0b3bce10759c37618b4aaf87743eea7f0.tar.xz
org.eclipse.osee-fea5e7c0b3bce10759c37618b4aaf87743eea7f0.zip
refactor: Replace TagCollector with Consumer
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/console/IndexStatusDisplayCollector.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/SearchAsserts.java13
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/tagger/TagEncoderTest.java18
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/tagger/TagProcessorTest.java34
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/mocks/MockTagCollector.java35
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/AttributeTokenSqlHandler.java13
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/IndexerCollectorNotifier.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/callable/consumer/IndexingTaskDatabaseTxCallable.java12
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/TagCollector.java22
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/TagEncoder.java9
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/TagProcessor.java17
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/Tagger.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/TextStreamTagger.java5
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/XmlTagger.java5
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/IndexerCollector.java2
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/IndexerCollectorAdapter.java2
16 files changed, 55 insertions, 143 deletions
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/console/IndexStatusDisplayCollector.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/console/IndexStatusDisplayCollector.java
index 3cecc7308a6..c6ed0bd6894 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/console/IndexStatusDisplayCollector.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/console/IndexStatusDisplayCollector.java
@@ -106,9 +106,9 @@ public final class IndexStatusDisplayCollector extends IndexerCollectorAdapter {
}
@Override
- public void onIndexItemAdded(int indexerId, long itemId, String word, long codedTag) {
+ public void onIndexItemAdded(int indexerId, long itemId, long codedTag) {
if (printTags) {
- console.writeln("indexerId:[%s] itemId:[%s] word:[%s] tag:[%s]", indexerId, itemId, word, codedTag);
+ console.writeln("indexerId:[%s] itemId:[%s] tag:[%s]", indexerId, itemId, codedTag);
}
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/SearchAsserts.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/SearchAsserts.java
index 7d53a45f8c0..40c870e4731 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/SearchAsserts.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/SearchAsserts.java
@@ -28,14 +28,6 @@ public final class SearchAsserts {
// Test Utility Class
}
- public static void assertTagsEqual(List<Pair<String, Long>> expected, List<Pair<String, Long>> actual) {
- Assert.assertEquals(expected.size(), actual.size());
-
- for (int index = 0; index < expected.size(); index++) {
- assertEquals(expected.get(index), actual.get(index));
- }
- }
-
public static void assertEquals(List<MatchLocation> expected, List<MatchLocation> actual) {
Assert.assertEquals(expected.size(), actual.size());
@@ -44,11 +36,6 @@ public final class SearchAsserts {
}
}
- public static void assertEquals(Pair<String, Long> expected, Pair<String, Long> actual) {
- Assert.assertEquals(expected.getFirst(), actual.getFirst());
- Assert.assertEquals(expected.getSecond(), actual.getSecond());
- }
-
public static void assertEquals(MatchLocation expected, MatchLocation actual) {
if (expected == null) {
Assert.assertNull(actual);
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/tagger/TagEncoderTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/tagger/TagEncoderTest.java
index ed33f7eab88..7811e14e096 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/tagger/TagEncoderTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/tagger/TagEncoderTest.java
@@ -16,9 +16,8 @@ package org.eclipse.osee.orcs.db.internal.search.tagger;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import org.eclipse.osee.framework.jdk.core.type.Pair;
import org.eclipse.osee.orcs.db.internal.search.SearchAsserts;
-import org.eclipse.osee.orcs.db.mocks.MockTagCollector;
+import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -26,17 +25,17 @@ import org.junit.runners.Parameterized.Parameters;
/**
* Test Case for {@link TagEncoder}
- *
+ *
* @author Roberto E. Escobar
*/
@RunWith(Parameterized.class)
public class TagEncoderTest {
- private final List<Pair<String, Long>> expected;
+ private final List<Long> expected;
private final String toEncode;
private final TagEncoder encoder;
- public TagEncoderTest(String toEncode, List<Pair<String, Long>> expected) {
+ public TagEncoderTest(String toEncode, List<Long> expected) {
this.toEncode = toEncode;
this.expected = expected;
this.encoder = new TagEncoder();
@@ -44,9 +43,9 @@ public class TagEncoderTest {
@Test
public void testTagEncoder() {
- List<Pair<String, Long>> actualTags = new ArrayList<>();
- encoder.encode(toEncode, new MockTagCollector(actualTags));
- SearchAsserts.assertTagsEqual(expected, actualTags);
+ List<Long> actualTags = new ArrayList<>();
+ encoder.encode(toEncode, actualTags::add);
+ Assert.assertEquals(expected, actualTags);
}
@Parameters
@@ -58,5 +57,4 @@ public class TagEncoderTest {
SearchAsserts.asTags("what happens when we have a long string", 2080358399, -545259521, 290692031)});
return data;
}
-
-}
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/tagger/TagProcessorTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/tagger/TagProcessorTest.java
index 928c5b596fe..8c6afb4b9ff 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/tagger/TagProcessorTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/tagger/TagProcessorTest.java
@@ -23,10 +23,9 @@ import java.util.Scanner;
import org.eclipse.osee.framework.jdk.core.type.Pair;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.jdk.core.util.io.xml.XmlTextInputStream;
-import org.eclipse.osee.orcs.db.internal.search.SearchAsserts;
import org.eclipse.osee.orcs.db.internal.search.language.EnglishLanguage;
import org.eclipse.osee.orcs.db.mocks.MockLog;
-import org.eclipse.osee.orcs.db.mocks.MockTagCollector;
+import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -34,7 +33,7 @@ import org.junit.runners.Parameterized.Parameters;
/**
* Test Case for {@link TagProcessor}
- *
+ *
* @author Roberto E. Escobar
*/
@RunWith(Parameterized.class)
@@ -55,10 +54,9 @@ public class TagProcessorTest {
@Test
public void testCollectFromString() {
- List<Pair<String, Long>> actual = new ArrayList<>();
- TagCollector tagCollector = new MockTagCollector(actual);
- tagProcessor.collectFromString(expectedParsed, tagCollector);
- SearchAsserts.assertTagsEqual(expected, actual);
+ List<Long> actualTags = new ArrayList<>();
+ tagProcessor.collectFromString(expectedParsed, actualTags::add);
+ Assert.assertEquals(expected, actualTags);
}
@Test
@@ -66,10 +64,9 @@ public class TagProcessorTest {
InputStream inputStream = null;
try {
inputStream = new XmlTextInputStream(rawData);
- List<Pair<String, Long>> actual = new ArrayList<>();
- TagCollector tagCollector = new MockTagCollector(actual);
- tagProcessor.collectFromInputStream(inputStream, tagCollector);
- SearchAsserts.assertTagsEqual(expected, actual);
+ List<Long> actualTags = new ArrayList<>();
+ tagProcessor.collectFromInputStream(inputStream, actualTags::add);
+ Assert.assertEquals(expected, actualTags);
} finally {
Lib.close(inputStream);
}
@@ -77,17 +74,10 @@ public class TagProcessorTest {
@Test
public void testCollectFromScanner() throws UnsupportedEncodingException {
- Scanner sourceScanner = null;
- try {
- sourceScanner = new Scanner(new XmlTextInputStream(rawData), "UTF-8");
- List<Pair<String, Long>> actual = new ArrayList<>();
- TagCollector tagCollector = new MockTagCollector(actual);
- tagProcessor.collectFromScanner(sourceScanner, tagCollector);
- SearchAsserts.assertTagsEqual(expected, actual);
- } finally {
- if (sourceScanner != null) {
- sourceScanner.close();
- }
+ try (Scanner sourceScanner = new Scanner(new XmlTextInputStream(rawData), "UTF-8")) {
+ List<Long> actualTags = new ArrayList<>();
+ tagProcessor.collectFromScanner(sourceScanner, actualTags::add);
+ Assert.assertEquals(expected, actualTags);
}
}
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/mocks/MockTagCollector.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/mocks/MockTagCollector.java
deleted file mode 100644
index b0a03415c0b..00000000000
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/mocks/MockTagCollector.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*********************************************************************
- * Copyright (c) 2004, 2007 Boeing
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Boeing - initial API and implementation
- **********************************************************************/
-
-package org.eclipse.osee.orcs.db.mocks;
-
-import java.util.Collection;
-import org.eclipse.osee.framework.jdk.core.type.Pair;
-import org.eclipse.osee.orcs.db.internal.search.tagger.TagCollector;
-
-/**
- * @author Roberto E. Escobar
- */
-public class MockTagCollector implements TagCollector {
-
- private final Collection<Pair<String, Long>> actualTags;
-
- public MockTagCollector(Collection<Pair<String, Long>> actualTags) {
- this.actualTags = actualTags;
- }
-
- @Override
- public void addTag(String word, Long codedTag) {
- actualTags.add(new Pair<>(word, codedTag));
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/AttributeTokenSqlHandler.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/AttributeTokenSqlHandler.java
index 2dec626837b..9ca2af52f1a 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/AttributeTokenSqlHandler.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/AttributeTokenSqlHandler.java
@@ -23,7 +23,6 @@ import org.eclipse.osee.framework.core.enums.SqlTable;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAttributeKeywords;
import org.eclipse.osee.orcs.db.internal.search.tagger.HasTagProcessor;
-import org.eclipse.osee.orcs.db.internal.search.tagger.TagCollector;
import org.eclipse.osee.orcs.db.internal.search.tagger.TagProcessor;
import org.eclipse.osee.orcs.db.internal.sql.AbstractSqlWriter;
import org.eclipse.osee.orcs.db.internal.sql.SqlHandler;
@@ -80,7 +79,7 @@ public class AttributeTokenSqlHandler extends SqlHandler<CriteriaAttributeKeywor
String jIdAlias = null;
for (String value : values) {
List<Long> tags = new ArrayList<>();
- tokenize(value, tags);
+ getTagProcessor().collectFromString(value, tags::add);
int tagsSize = tags.size();
writer.write(" ( \n");
if (tagsSize == 0) {
@@ -167,14 +166,4 @@ public class AttributeTokenSqlHandler extends SqlHandler<CriteriaAttributeKeywor
public int getPriority() {
return SqlHandlerPriority.ATTRIBUTE_TOKENIZED_VALUE.ordinal();
}
-
- private void tokenize(String value, final Collection<Long> codedTags) {
- TagCollector collector = new TagCollector() {
- @Override
- public void addTag(String word, Long codedTag) {
- codedTags.add(codedTag);
- }
- };
- getTagProcessor().collectFromString(value, collector);
- }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/IndexerCollectorNotifier.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/IndexerCollectorNotifier.java
index 1ad34b6440b..306b26b6123 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/IndexerCollectorNotifier.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/IndexerCollectorNotifier.java
@@ -92,10 +92,10 @@ public class IndexerCollectorNotifier implements IndexerCollector {
}
@Override
- public void onIndexItemAdded(int indexerId, long itemId, String word, long codedTag) {
+ public void onIndexItemAdded(int indexerId, long itemId, long codedTag) {
for (IndexerCollector collector : listeners) {
try {
- collector.onIndexItemAdded(indexerId, itemId, word, codedTag);
+ collector.onIndexItemAdded(indexerId, itemId, codedTag);
} catch (Exception ex) {
handleError(collector, ex);
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/callable/consumer/IndexingTaskDatabaseTxCallable.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/callable/consumer/IndexingTaskDatabaseTxCallable.java
index ec08f8ec72d..efb6f56760b 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/callable/consumer/IndexingTaskDatabaseTxCallable.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/callable/consumer/IndexingTaskDatabaseTxCallable.java
@@ -23,6 +23,7 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.osee.framework.core.OrcsTokenService;
+import java.util.function.Consumer;
import org.eclipse.osee.framework.core.data.GammaId;
import org.eclipse.osee.framework.core.data.TaggerTypeToken;
import org.eclipse.osee.framework.core.enums.JoinItem;
@@ -35,7 +36,6 @@ import org.eclipse.osee.orcs.core.ds.IndexedResource;
import org.eclipse.osee.orcs.core.ds.OrcsDataHandler;
import org.eclipse.osee.orcs.db.internal.callable.AbstractDatastoreTxCallable;
import org.eclipse.osee.orcs.db.internal.search.indexer.IndexedResourceLoader;
-import org.eclipse.osee.orcs.db.internal.search.tagger.TagCollector;
import org.eclipse.osee.orcs.db.internal.search.tagger.Tagger;
import org.eclipse.osee.orcs.db.internal.search.tagger.TaggingEngine;
import org.eclipse.osee.orcs.search.IndexerCollector;
@@ -236,13 +236,13 @@ public final class IndexingTaskDatabaseTxCallable extends AbstractDatastoreTxCal
}
}
- private void notifyOnIndexItemAdded(long gammaId, String word, long codedTag) {
+ private void notifyOnIndexItemAdded(long gammaId, long codedTag) {
if (collector != null) {
- collector.onIndexItemAdded(getTagQueueQueryId(), gammaId, word, codedTag);
+ collector.onIndexItemAdded(getTagQueueQueryId(), gammaId, codedTag);
}
}
- private final class SearchTagCollector implements TagCollector {
+ private final class SearchTagCollector implements Consumer<Long> {
private Long gammaId;
private Set<Long> currentTag;
@@ -262,11 +262,11 @@ public final class IndexingTaskDatabaseTxCallable extends AbstractDatastoreTxCal
}
@Override
- public void addTag(String word, Long codedTag) {
+ public void accept(Long codedTag) {
if (currentTag != null && gammaId != null) {
if (currentTag.add(codedTag)) {
totalTags++;
- notifyOnIndexItemAdded(gammaId, word, codedTag);
+ notifyOnIndexItemAdded(gammaId, codedTag);
}
}
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/TagCollector.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/TagCollector.java
deleted file mode 100644
index 1d8c2e040e7..00000000000
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/TagCollector.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*********************************************************************
- * Copyright (c) 2004, 2007 Boeing
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Boeing - initial API and implementation
- **********************************************************************/
-
-package org.eclipse.osee.orcs.db.internal.search.tagger;
-
-/**
- * @author Roberto E. Escobar
- */
-public interface TagCollector {
-
- public void addTag(String word, Long codedTag);
-}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/TagEncoder.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/TagEncoder.java
index 4ad47b9b136..78fbaed02de 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/TagEncoder.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/TagEncoder.java
@@ -14,6 +14,7 @@
package org.eclipse.osee.orcs.db.internal.search.tagger;
import java.util.Arrays;
+import java.util.function.Consumer;
/**
* @author Roberto E. Escobar
@@ -59,7 +60,7 @@ public class TagEncoder {
* represent up to 12 characters (5-bits per character). Longer search tags will be turned into consecutive search
* tags
*/
- public void encode(String text, TagCollector collector) {
+ public void encode(String text, Consumer<Long> consumer) {
int tagBitsPos = 0;
long tagBits = 0;
for (int index = 0; index < text.length(); index++) {
@@ -67,7 +68,7 @@ public class TagEncoder {
if (c == '\t' || c == '\n' || c == '\r' || tagBitsPos == 60) {
if (tagBitsPos > 10) {
- collector.addTag(text, tagBits);
+ consumer.accept(tagBits);
}
tagBits = 0;
tagBitsPos = 0;
@@ -85,7 +86,7 @@ public class TagEncoder {
}
}
if (tagBits != 0) {
- collector.addTag(text, tagBits);
+ consumer.accept(tagBits);
}
}
@@ -101,7 +102,7 @@ public class TagEncoder {
"ImportTraceUnitsTest3"};
for (String text : tests) {
System.out.print(text + " ");
- tagEncoder.encode(text, (word, codedTag) -> System.out.print(codedTag));
+ tagEncoder.encode(text, tag -> System.out.print(tag + " "));
System.out.println();
}
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/TagProcessor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/TagProcessor.java
index 139a76077b6..ad50582f26f 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/TagProcessor.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/TagProcessor.java
@@ -15,6 +15,7 @@ package org.eclipse.osee.orcs.db.internal.search.tagger;
import java.io.InputStream;
import java.util.Scanner;
+import java.util.function.Consumer;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.orcs.db.internal.search.util.WordsUtil;
@@ -31,22 +32,22 @@ public class TagProcessor {
this.encoder = encoder;
}
- public void collectFromString(String value, TagCollector tagCollector) {
+ public void collectFromString(String value, Consumer<Long> consumer) {
if (Strings.isValid(value)) {
Scanner scanner = new Scanner(value);
while (scanner.hasNext()) {
- processWord(scanner.next(), tagCollector);
+ processWord(scanner.next(), consumer);
}
scanner.close();
}
}
- public void collectFromInputStream(InputStream inputStream, TagCollector tagCollector) {
+ public void collectFromInputStream(InputStream inputStream, Consumer<Long> consumer) {
if (inputStream != null) {
Scanner scanner = new Scanner(inputStream, "UTF-8");
try {
while (scanner.hasNext()) {
- processWord(scanner.next(), tagCollector);
+ processWord(scanner.next(), consumer);
}
} finally {
scanner.close();
@@ -54,7 +55,7 @@ public class TagProcessor {
}
}
- public void collectFromScanner(Scanner sourceScanner, TagCollector tagCollector) {
+ public void collectFromScanner(Scanner sourceScanner, Consumer<Long> consumer) {
try {
while (sourceScanner.hasNext()) {
String entry = sourceScanner.next();
@@ -62,7 +63,7 @@ public class TagProcessor {
Scanner innerScanner = new Scanner(entry);
while (innerScanner.hasNext()) {
String entry1 = innerScanner.next();
- processWord(entry1, tagCollector);
+ processWord(entry1, consumer);
}
innerScanner.close();
}
@@ -72,13 +73,13 @@ public class TagProcessor {
}
}
- private void processWord(String original, TagCollector tagCollector) {
+ private void processWord(String original, Consumer<Long> consumer) {
if (Strings.isValid(original) && (original.length() >= 2 || 0 == WordsUtil.countPuntuation(original))) {
original = original.toLowerCase();
for (String toEncode : WordsUtil.splitOnPunctuation(original)) {
if (language.isWord(toEncode)) {
String target = language.toSingular(toEncode);
- encoder.encode(target, tagCollector);
+ encoder.encode(target, consumer);
}
}
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/Tagger.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/Tagger.java
index b0332110390..deebd9172f2 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/Tagger.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/Tagger.java
@@ -15,6 +15,7 @@ package org.eclipse.osee.orcs.db.internal.search.tagger;
import java.io.InputStream;
import java.util.List;
+import java.util.function.Consumer;
import org.eclipse.osee.framework.core.enums.QueryOption;
import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
@@ -23,7 +24,7 @@ import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
*/
public interface Tagger {
- void tagIt(InputStream provider, TagCollector collector) throws Exception;
+ void tagIt(InputSupplier<? extends InputStream> provider, TagCollector collector) throws Exception; void tagIt(InputStream provider, Consumer<Long> consumer) throws Exception; void tagIt(InputSupplier<? extends InputStream> provider, TagCollector collector) throws Exception;
List<MatchLocation> find(InputStream provider, String toSearch, boolean matchAllLocations, QueryOption... options) throws Exception;
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/TextStreamTagger.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/TextStreamTagger.java
index c5b7e681573..16230a39564 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/TextStreamTagger.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/TextStreamTagger.java
@@ -16,6 +16,7 @@ package org.eclipse.osee.orcs.db.internal.search.tagger;
import java.io.InputStream;
import java.util.Collections;
import java.util.List;
+import java.util.function.Consumer;
import org.eclipse.osee.framework.core.enums.QueryOption;
import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
import org.eclipse.osee.framework.jdk.core.util.Lib;
@@ -31,11 +32,11 @@ public class TextStreamTagger extends AbstractTagger {
}
@Override
- public void tagIt(InputStream provider, TagCollector collector) throws Exception {
+ public void tagIt(InputStream provider, Consumer<Long> consumer) throws Exception {
InputStream inputStream = null;
try {
inputStream = provider;
- getTagProcessor().collectFromInputStream(inputStream, collector);
+ getTagProcessor().collectFromInputStream(inputStream, consumer);
} finally {
Lib.close(inputStream);
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/XmlTagger.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/XmlTagger.java
index 68de70b3340..1470d848790 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/XmlTagger.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/tagger/XmlTagger.java
@@ -17,6 +17,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.List;
+import java.util.function.Consumer;
import org.eclipse.osee.framework.core.enums.QueryOption;
import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
import org.eclipse.osee.framework.jdk.core.util.Lib;
@@ -33,11 +34,11 @@ public class XmlTagger extends AbstractTagger {
}
@Override
- public void tagIt(InputStream provider, TagCollector collector) throws Exception {
+ public void tagIt(InputStream provider, Consumer<Long> consumer) throws Exception {
InputStream inputStream = null;
try {
inputStream = getStream(provider);
- getTagProcessor().collectFromInputStream(inputStream, collector);
+ getTagProcessor().collectFromInputStream(inputStream, consumer);
} finally {
Lib.close(inputStream);
}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/IndexerCollector.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/IndexerCollector.java
index 8de337fd58c..c49645cbca1 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/IndexerCollector.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/IndexerCollector.java
@@ -26,7 +26,7 @@ public interface IndexerCollector {
void onIndexTaskComplete(int indexerId, long waitTime, long processingTime);
- void onIndexItemAdded(int indexerId, long itemId, String word, long codedTag);
+ void onIndexItemAdded(int indexerId, long itemId, long codedTag);
void onIndexItemComplete(int indexerId, long itemId, int totalTags, long processingTime);
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/IndexerCollectorAdapter.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/IndexerCollectorAdapter.java
index 92603352c2f..0c0156dea5c 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/IndexerCollectorAdapter.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/IndexerCollectorAdapter.java
@@ -39,7 +39,7 @@ public class IndexerCollectorAdapter implements IndexerCollector {
}
@Override
- public void onIndexItemAdded(int indexerId, long itemId, String word, long codedTag) {
+ public void onIndexItemAdded(int indexerId, long itemId, long codedTag) {
// Empty
}

Back to the top