NEW - bug 191522: Provide full text search functionality over task
comments
https://bugs.eclipse.org/bugs/show_bug.cgi?id=191522
diff --git a/org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/TaskListIndex.java b/org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/TaskListIndex.java
index 63569f2..d7ba3a9 100644
--- a/org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/TaskListIndex.java
+++ b/org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/TaskListIndex.java
@@ -97,7 +97,7 @@
ASSIGNEE(true, TaskAttribute.USER_ASSIGNED), //
REPORTER(true, TaskAttribute.USER_REPORTER), //
PERSON(true, null), //
- COMPONTENT(true, TaskAttribute.COMPONENT), //
+ COMPONENT(true, TaskAttribute.COMPONENT), //
COMPLETION_DATE(true, null), //
CREATION_DATE(true, null), //
DUE_DATE(true, null), //
@@ -584,7 +584,9 @@
}
private void addIndexedAttribute(Document document, IndexField indexField, String value) {
-
+ if (value == null) {
+ return;
+ }
Field field = document.getField(indexField.fieldName());
if (field == null) {
field = new Field(indexField.fieldName(), value, Store.YES, org.apache.lucene.document.Field.Index.ANALYZED);
@@ -601,6 +603,9 @@
if (date == null) {
return;
}
+ // FIXME: date tools converts dates to GMT, and we don't really want that. So
+ // move the date by the GMT offset if there is any
+
String value = DateTools.dateToString(date, Resolution.HOUR);
Field field = document.getField(indexField.fieldName());
if (field == null) {
diff --git a/org.eclipse.mylyn.tasks.index.tests/src/org/eclipse/mylyn/internal/tasks/index/tests/TaskListIndexTest.java b/org.eclipse.mylyn.tasks.index.tests/src/org/eclipse/mylyn/internal/tasks/index/tests/TaskListIndexTest.java
index 5781fdf..58f77db 100644
--- a/org.eclipse.mylyn.tasks.index.tests/src/org/eclipse/mylyn/internal/tasks/index/tests/TaskListIndexTest.java
+++ b/org.eclipse.mylyn.tasks.index.tests/src/org/eclipse/mylyn/internal/tasks/index/tests/TaskListIndexTest.java
@@ -18,7 +18,9 @@
import java.io.File;
import java.io.IOException;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
@@ -201,4 +203,26 @@
assertTrue(collector.getTasks().contains(task));
}
+ @Test
+ public void testMatchesRepositoryTaskOnCreationDate() throws InterruptedException, CoreException {
+ setupIndex();
+
+ ITask task = context.createRepositoryTask();
+
+ Date creationDate = task.getCreationDate();
+ assertNotNull(creationDate);
+
+ index.waitUntilIdle();
+
+ assertFalse(index.matches(task, IndexField.CREATION_DATE.fieldName() + ":[20010101 TO 20010105]"));
+
+ String matchDate = new SimpleDateFormat("yyyyMMdd").format(creationDate);
+ matchDate = Integer.toString(Integer.parseInt(matchDate) + 2);
+
+ String patternString = IndexField.CREATION_DATE.fieldName() + ":[20111019 TO " + matchDate + "]";
+
+ System.out.println(patternString);
+
+ assertTrue(index.matches(task, patternString));
+ }
}