diff options
author | David Green | 2012-10-16 17:36:27 +0000 |
---|---|---|
committer | Steffen Pingel | 2012-10-30 11:09:06 +0000 |
commit | 69fc142feb6892ec2ae7c15c3b622c7478d18032 (patch) | |
tree | d3f26ea35cfe8ba85b1849a7a1725a429112ee06 /org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal | |
parent | 8f8a84b050f645df615c00acf1bcaf778026c6d5 (diff) | |
download | org.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
Diffstat (limited to 'org.eclipse.mylyn.tasks.index.core/src/org/eclipse/mylyn/internal')
3 files changed, 39 insertions, 12 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 |