Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Green2012-10-16 17:36:27 +0000
committerSteffen Pingel2012-10-30 11:09:06 +0000
commit69fc142feb6892ec2ae7c15c3b622c7478d18032 (patch)
treed3f26ea35cfe8ba85b1849a7a1725a429112ee06
parent8f8a84b050f645df615c00acf1bcaf778026c6d5 (diff)
downloadorg.eclipse.mylyn.tasks-69fc142feb6892ec2ae7c15c3b622c7478d18032.tar.gz
org.eclipse.mylyn.tasks-69fc142feb6892ec2ae7c15c3b622c7478d18032.tar.xz
org.eclipse.mylyn.tasks-69fc142feb6892ec2ae7c15c3b622c7478d18032.zip
392100: task list index should include attachment names
Add attachment name as a field to the index. Add attachment descriptions to the content field. Change-Id: Ice69e2e5a26cbc2c070fa2ef08e0637a2d91ae5b Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=392100
-rw-r--r--org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/Messages.java2
-rw-r--r--org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/TaskListIndex.java48
-rw-r--r--org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/messages.properties1
-rw-r--r--org.eclipse.mylyn.tasks.index.tests/src/org/eclipse/mylyn/internal/tasks/index/tests/TaskListIndexTest.java37
-rw-r--r--org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/ContentProposalProvider.java2
5 files changed, 76 insertions, 14 deletions
diff --git a/org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/Messages.java b/org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/Messages.java
index 29a67d95a..048c931d4 100644
--- a/org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/Messages.java
+++ b/org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/Messages.java
@@ -18,6 +18,8 @@ import org.eclipse.osgi.util.NLS;
class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.tasks.index.core.messages"; //$NON-NLS-1$
+ public static String TaskListIndex_field_attachment;
+
public static String TaskListIndex_field_content;
public static String TaskListIndex_field_identifier;
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 0d1d7ff31..9842e7d00 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
@@ -72,13 +72,13 @@ import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.ITaskList;
import org.eclipse.mylyn.internal.tasks.core.ITaskListChangeListener;
import org.eclipse.mylyn.internal.tasks.core.ITaskListRunnable;
+import org.eclipse.mylyn.internal.tasks.core.TaskAttachment;
import org.eclipse.mylyn.internal.tasks.core.TaskComment;
import org.eclipse.mylyn.internal.tasks.core.TaskContainerDelta;
import org.eclipse.mylyn.internal.tasks.core.TaskList;
import org.eclipse.mylyn.internal.tasks.core.data.ITaskDataManagerListener;
import org.eclipse.mylyn.internal.tasks.core.data.TaskDataManager;
import org.eclipse.mylyn.internal.tasks.core.data.TaskDataManagerEvent;
-import org.eclipse.mylyn.internal.tasks.index.core.TaskListIndex.TaskCollector;
import org.eclipse.mylyn.tasks.core.IRepositoryElement;
import org.eclipse.mylyn.tasks.core.IRepositoryListener;
import org.eclipse.mylyn.tasks.core.IRepositoryManager;
@@ -128,6 +128,8 @@ public class TaskListIndex implements ITaskDataManagerListener, ITaskListChangeL
private static final String TASK_ATTRIBUTE_PERSON = INDEX_TASK_ATTRIBUTE_PREFIX + "person"; //$NON-NLS-1$
+ private static final String TASK_ATTRIBUTE_ATTACHMENT_NAME = INDEX_TASK_ATTRIBUTE_PREFIX + "attachment"; //$NON-NLS-1$
+
public static final org.eclipse.mylyn.tasks.core.data.AbstractTaskSchema.Field FIELD_IDENTIFIER = new AbstractTaskSchema.Field(
TASK_ATTRIBUTE_IDENTIFIER, Messages.TaskListIndex_field_identifier, TaskAttribute.TYPE_SHORT_TEXT,
"identifier"); //$NON-NLS-1$
@@ -146,6 +148,10 @@ public class TaskListIndex implements ITaskDataManagerListener, ITaskListChangeL
public static final org.eclipse.mylyn.tasks.core.data.AbstractTaskSchema.Field FIELD_SUMMARY = DefaultTaskSchema.getInstance().SUMMARY;
+ public static final org.eclipse.mylyn.tasks.core.data.AbstractTaskSchema.Field FIELD_ATTACHMENT_NAME = new AbstractTaskSchema.Field(
+ TASK_ATTRIBUTE_ATTACHMENT_NAME, Messages.TaskListIndex_field_attachment, TaskAttribute.TYPE_SHORT_TEXT,
+ "attachment"); //$NON-NLS-1$
+
private class MaintainIndexJob extends Job {
public MaintainIndexJob() {
@@ -192,12 +198,14 @@ public class TaskListIndex implements ITaskDataManagerListener, ITaskListChangeL
specialFields.add(FIELD_CONTENT);
specialFields.add(FIELD_PERSON);
specialFields.add(FIELD_TASK_KEY);
+ specialFields.add(FIELD_ATTACHMENT_NAME);
addIndexedField(FIELD_IDENTIFIER);
addIndexedField(FIELD_TASK_KEY);
addIndexedField(FIELD_REPOSITORY_URL);
addIndexedField(FIELD_SUMMARY);
addIndexedField(FIELD_CONTENT);
+ addIndexedField(FIELD_ATTACHMENT_NAME);
addIndexedField(DefaultTaskSchema.getInstance().USER_ASSIGNED);
addIndexedField(DefaultTaskSchema.getInstance().USER_REPORTER);
addIndexedField(FIELD_PERSON);
@@ -218,8 +226,6 @@ public class TaskListIndex implements ITaskDataManagerListener, ITaskListChangeL
STARTUP, REINDEX
}
- // FIXME: document concurrency model
-
private Directory directory;
private MaintainIndexJob maintainIndexJob;
@@ -840,14 +846,15 @@ public class TaskListIndex implements ITaskDataManagerListener, ITaskListChangeL
addIndexedDateAttributes(document, task);
- List<TaskAttribute> commentAttributes = root.getTaskData()
- .getAttributeMapper()
- .getAttributesByType(root.getTaskData(), TaskAttribute.TYPE_COMMENT);
+ TaskData taskData = root.getTaskData();
+
+ List<TaskAttribute> commentAttributes = taskData.getAttributeMapper().getAttributesByType(taskData,
+ TaskAttribute.TYPE_COMMENT);
for (TaskAttribute commentAttribute : commentAttributes) {
- TaskComment taskComment = new TaskComment(root.getTaskData().getAttributeMapper().getTaskRepository(),
- task, commentAttribute);
- root.getTaskData().getAttributeMapper().updateTaskComment(taskComment, commentAttribute);
+ TaskComment taskComment = new TaskComment(taskData.getAttributeMapper().getTaskRepository(), task,
+ commentAttribute);
+ taskData.getAttributeMapper().updateTaskComment(taskComment, commentAttribute);
String text = taskComment.getText();
if (text.length() != 0) {
@@ -859,13 +866,30 @@ public class TaskListIndex implements ITaskDataManagerListener, ITaskListChangeL
}
}
- List<TaskAttribute> personAttributes = root.getTaskData()
- .getAttributeMapper()
- .getAttributesByType(root.getTaskData(), TaskAttribute.TYPE_PERSON);
+ List<TaskAttribute> personAttributes = taskData.getAttributeMapper().getAttributesByType(taskData,
+ TaskAttribute.TYPE_PERSON);
for (TaskAttribute personAttribute : personAttributes) {
addIndexedAttribute(document, FIELD_PERSON, personAttribute);
}
+ TaskRepository repository = getRepositoryManager().getRepository(task.getConnectorKind(),
+ task.getRepositoryUrl());
+
+ if (repository != null) {
+ List<TaskAttribute> attachmentAttributes = taskData.getAttributeMapper().getAttributesByType(taskData,
+ TaskAttribute.TYPE_ATTACHMENT);
+ Set<String> attachmentNames = new HashSet<String>();
+ for (TaskAttribute attribute : attachmentAttributes) {
+ TaskAttachment taskAttachment = new TaskAttachment(repository, task, attribute);
+ taskData.getAttributeMapper().updateTaskAttachment(taskAttachment, attribute);
+
+ if (attachmentNames.add(taskAttachment.getFileName())) {
+ addIndexedAttribute(document, FIELD_ATTACHMENT_NAME, taskAttachment.getFileName());
+ }
+ addIndexedAttribute(document, FIELD_CONTENT, taskAttachment.getDescription());
+ }
+ }
+
for (AbstractTaskSchema.Field field : indexedFields) {
if (!specialFields.contains(field)) {
addIndexedAttribute(document, field, root.getMappedAttribute(field.getKey()));
diff --git a/org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/messages.properties b/org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/messages.properties
index bbba9f80f..aa751acb0 100644
--- a/org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/messages.properties
+++ b/org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal/tasks/index/core/messages.properties
@@ -8,6 +8,7 @@
# Contributors:
# Tasktop Technologies - initial API and implementation
###############################################################################
+TaskListIndex_field_attachment=Attachment Name
TaskListIndex_field_content=Content
TaskListIndex_indexerJob=Task List Indexer
TaskListIndex_task_rebuilding_index=Indexing tasks
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 5d5ac6baa..22f6e4466 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
@@ -44,6 +44,7 @@ import org.eclipse.mylyn.internal.tasks.index.core.TaskListIndex;
import org.eclipse.mylyn.internal.tasks.index.core.TaskListIndex.TaskCollector;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.data.DefaultTaskSchema;
+import org.eclipse.mylyn.tasks.core.data.TaskAttachmentMapper;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskData;
import org.eclipse.mylyn.tasks.core.data.TaskMapper;
@@ -446,6 +447,40 @@ public class TaskListIndexTest extends AbstractTaskListIndexTest {
}
}
+ @Test
+ public void testFindByTaskAttachmentName() throws CoreException, InterruptedException {
+ setupIndex();
+
+ ITask repositoryTask = context.createRepositoryTask();
+
+ index.waitUntilIdle();
+
+ index.setDefaultField(TaskListIndex.FIELD_CONTENT);
+
+ TaskData taskData = context.getDataManager().getTaskData(repositoryTask);
+
+ TaskAttribute attachmentAttribute = taskData.getRoot().createAttribute("attachment-0");
+ attachmentAttribute.getMetaData().setType(TaskAttribute.TYPE_ATTACHMENT);
+
+ TaskAttachmentMapper attachmentMapper = TaskAttachmentMapper.createFrom(attachmentAttribute);
+ attachmentMapper.setFileName("test-file.txt");
+ attachmentMapper.setDescription("test file " + System.currentTimeMillis());
+ attachmentMapper.applyTo(attachmentAttribute);
+
+ context.getDataManager().putSubmittedTaskData(repositoryTask, taskData, new DelegatingProgressMonitor());
+ context.getTaskList().notifyElementsChanged(Collections.singleton(repositoryTask));
+
+ index.waitUntilIdle();
+
+ assertTrue(index.matches(repositoryTask, "\"" + attachmentMapper.getDescription() + "\""));
+ assertTrue(index.matches(repositoryTask, TaskListIndex.FIELD_ATTACHMENT_NAME.getIndexKey() + ":\""
+ + attachmentMapper.getFileName() + "\""));
+ assertFalse(index.matches(repositoryTask,
+ TaskListIndex.FIELD_CONTENT.getIndexKey() + ":\"" + attachmentMapper.getFileName() + "\""));
+ assertFalse(index.matches(repositoryTask, TaskListIndex.FIELD_ATTACHMENT_NAME.getIndexKey() + ":\""
+ + attachmentMapper.getDescription() + "\""));
+ }
+
private void assertCanFindTask(ITask task) {
TestTaskCollector collector = new TestTaskCollector();
index.find(task.getSummary(), collector, 1000);
@@ -454,4 +489,4 @@ public class TaskListIndexTest extends AbstractTaskListIndexTest {
assertTrue(collector.getTasks().contains(task));
}
-} \ No newline at end of file
+}
diff --git a/org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/ContentProposalProvider.java b/org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/ContentProposalProvider.java
index 19d004098..a3ecc483b 100644
--- a/org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/ContentProposalProvider.java
+++ b/org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/ContentProposalProvider.java
@@ -87,7 +87,7 @@ public class ContentProposalProvider implements IContentProposalProvider {
// suggest field name prefixes
for (Field field : reference.index().getIndexedFields()) {
- // searching on URL is not useful
+ // searching on identifier field (task handle) is not useful
if (field.equals(TaskListIndex.FIELD_IDENTIFIER)) {
continue;
}

Back to the top