Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimur Achmetow2012-09-11 18:04:05 -0400
committerSteffen Pingel2012-09-12 14:05:34 -0400
commit2ae43597001255763babb158ef43b1e96d48b166 (patch)
tree39ee03d9b64376a4df0f8a46c218065723050b2b /org.eclipse.mylyn.tasks.activity.core
parent8e0212d19495b6827fae5b4354775437d9a1ebf9 (diff)
downloadorg.eclipse.mylyn.tasks-2ae43597001255763babb158ef43b1e96d48b166.tar.gz
org.eclipse.mylyn.tasks-2ae43597001255763babb158ef43b1e96d48b166.tar.xz
org.eclipse.mylyn.tasks-2ae43597001255763babb158ef43b1e96d48b166.zip
378101: add activity provider for related tasks such as reviews
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=378101 Change-Id: Ib63e5f52780d82cf90364921edecb0ac5c38e627
Diffstat (limited to 'org.eclipse.mylyn.tasks.activity.core')
-rw-r--r--org.eclipse.mylyn.tasks.activity.core/META-INF/MANIFEST.MF7
-rw-r--r--org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityCoreInternal.java1
-rw-r--r--org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityManager.java16
-rw-r--r--org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityStream.java25
-rw-r--r--org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/TaskActivityProvider.java70
-rw-r--r--org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/tasks/activity/core/ActivityEvent.java16
-rw-r--r--org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/tasks/activity/core/IActivityStream.java17
7 files changed, 101 insertions, 51 deletions
diff --git a/org.eclipse.mylyn.tasks.activity.core/META-INF/MANIFEST.MF b/org.eclipse.mylyn.tasks.activity.core/META-INF/MANIFEST.MF
index 229008ceb..ae58bf895 100644
--- a/org.eclipse.mylyn.tasks.activity.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.tasks.activity.core/META-INF/MANIFEST.MF
@@ -6,8 +6,11 @@ Bundle-Version: 3.9.0.qualifier
Bundle-Vendor: %Bundle-Vendor
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: org.eclipse.core.runtime,
- org.eclipse.mylyn.tasks.core;bundle-version="3.8.0"
+ org.eclipse.mylyn.tasks.core;bundle-version="3.8.0",
+ org.eclipse.mylyn.tasks.index.ui;bundle-version="3.9.0",
+ org.eclipse.mylyn.tasks.index.core;bundle-version="3.9.0",
+ org.eclipse.mylyn.commons.core;bundle-version="3.9.0"
Bundle-Localization: plugin
Export-Package: org.eclipse.mylyn.internal.tasks.activity.core;x-internal:=true,
org.eclipse.mylyn.tasks.activity.core;x-internal:=true,
- org.eclipse.mylyn.tasks.activity.core.spi
+ org.eclipse.mylyn.tasks.activity.core.spi
diff --git a/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityCoreInternal.java b/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityCoreInternal.java
index 78fbc93d8..0783e5c64 100644
--- a/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityCoreInternal.java
+++ b/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityCoreInternal.java
@@ -11,7 +11,6 @@
package org.eclipse.mylyn.internal.tasks.activity.core;
-
/**
* @author Steffen Pingel
*/
diff --git a/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityManager.java b/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityManager.java
index ecb278670..17962ef7f 100644
--- a/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityManager.java
+++ b/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityManager.java
@@ -12,8 +12,9 @@
package org.eclipse.mylyn.internal.tasks.activity.core;
import java.util.Collection;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
+import java.util.Collections;
+import java.util.Set;
+import java.util.TreeSet;
import org.eclipse.mylyn.tasks.activity.core.ActivityEvent;
import org.eclipse.mylyn.tasks.activity.core.ActivityScope;
@@ -26,14 +27,14 @@ import org.eclipse.mylyn.tasks.activity.core.spi.IActivitySession;
*/
public class ActivityManager implements IActivityManager, IActivitySession {
- private final Map<String, ActivityEvent> events;
+ private final Set<ActivityEvent> events;
public ActivityManager() {
- this.events = new ConcurrentHashMap<String, ActivityEvent>();
+ this.events = Collections.synchronizedSet(new TreeSet<ActivityEvent>());
}
public Collection<ActivityEvent> getEvents(ActivityScope scope) {
- return events.values();
+ return events;
}
public IActivityStream getStream(ActivityScope scope) {
@@ -45,7 +46,6 @@ public class ActivityManager implements IActivityManager, IActivitySession {
}
public void fireActivityEvent(ActivityEvent event) {
- events.put(event.getHandle(), event);
+ events.add(event);
}
-
-}
+} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityStream.java b/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityStream.java
index cf5a4210a..90377e229 100644
--- a/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityStream.java
+++ b/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityStream.java
@@ -11,10 +11,13 @@
package org.eclipse.mylyn.internal.tasks.activity.core;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.Collections;
+import java.util.Set;
+import java.util.TreeSet;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.mylyn.tasks.activity.core.ActivityEvent;
import org.eclipse.mylyn.tasks.activity.core.ActivityScope;
import org.eclipse.mylyn.tasks.activity.core.IActivityManager;
@@ -22,10 +25,11 @@ import org.eclipse.mylyn.tasks.activity.core.IActivityStream;
/**
* @author Steffen Pingel
+ * @author Timur Achmetow
*/
public class ActivityStream implements IActivityStream {
- private final List<ActivityEvent> events;
+ private final Set<ActivityEvent> events;
private final ActivityScope scope;
@@ -36,7 +40,7 @@ public class ActivityStream implements IActivityStream {
Assert.isNotNull(scope);
this.manager = manager;
this.scope = scope;
- this.events = new CopyOnWriteArrayList<ActivityEvent>();
+ this.events = Collections.synchronizedSet(new TreeSet<ActivityEvent>());
initialize();
}
@@ -44,11 +48,19 @@ public class ActivityStream implements IActivityStream {
events.addAll(manager.getEvents(scope));
}
+ public void query(IProgressMonitor monitor) throws CoreException {
+ TaskActivityProvider reviewTaskProvider = new TaskActivityProvider();
+ reviewTaskProvider.open(manager);
+ reviewTaskProvider.query(scope, monitor);
+
+ initialize();
+ }
+
public void addEvent(ActivityEvent event) {
events.add(event);
}
- public List<ActivityEvent> getEvents() {
+ public Set<ActivityEvent> getEvents() {
return events;
}
@@ -63,5 +75,4 @@ public class ActivityStream implements IActivityStream {
public void removeEvent(ActivityEvent event) {
events.remove(event);
}
-
-}
+} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/TaskActivityProvider.java b/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/TaskActivityProvider.java
index 0ddcd9c15..3c97d4a75 100644
--- a/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/TaskActivityProvider.java
+++ b/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/TaskActivityProvider.java
@@ -11,38 +11,32 @@
package org.eclipse.mylyn.internal.tasks.activity.core;
-import org.eclipse.core.runtime.Assert;
+import java.util.HashMap;
+import java.util.Map;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.mylyn.internal.tasks.core.TaskList;
+import org.eclipse.mylyn.internal.tasks.index.core.TaskListIndex;
+import org.eclipse.mylyn.internal.tasks.index.core.TaskListIndex.TaskCollector;
+import org.eclipse.mylyn.internal.tasks.index.ui.IndexReference;
import org.eclipse.mylyn.tasks.activity.core.ActivityEvent;
import org.eclipse.mylyn.tasks.activity.core.ActivityScope;
import org.eclipse.mylyn.tasks.activity.core.TaskActivityScope;
import org.eclipse.mylyn.tasks.activity.core.spi.ActivityProvider;
import org.eclipse.mylyn.tasks.activity.core.spi.IActivitySession;
-import org.eclipse.mylyn.tasks.core.IRepositoryManager;
import org.eclipse.mylyn.tasks.core.ITask;
/**
* @author Steffen Pingel
+ * @author Timur Achmetow
*/
+@SuppressWarnings("restriction")
public class TaskActivityProvider extends ActivityProvider {
- public static final String ID_PROVIDER = "org.eclipse.mylyn.tasks.activity.core.providers.TaskActivityProvider"; //$NON-NLS-1$
+ private static final String UNKNOWN = "Unknown"; //$NON-NLS-1$
private IActivitySession session;
- private final IRepositoryManager repositoryManager;
-
- private final TaskList taskList;
-
- public TaskActivityProvider(IRepositoryManager repositoryManager, TaskList taskList) {
- Assert.isNotNull(repositoryManager);
- Assert.isNotNull(taskList);
- this.repositoryManager = repositoryManager;
- this.taskList = taskList;
- }
-
@Override
public void open(IActivitySession session) {
this.session = session;
@@ -52,12 +46,14 @@ public class TaskActivityProvider extends ActivityProvider {
public void query(ActivityScope scope, IProgressMonitor monitor) throws CoreException {
if (scope instanceof TaskActivityScope) {
ITask scopeTask = ((TaskActivityScope) scope).getTask();
- for (ITask task : taskList.getAllTasks()) {
- if (task.getSummary().contains(scopeTask.getTaskId())) {
- ActivityEvent event = new ActivityEvent(task.getHandleIdentifier(), ID_PROVIDER, task.getSummary(),
- task.getCreationDate(), null);
- session.fireActivityEvent(event);
- }
+
+ GetAssociatedTasks collector = new GetAssociatedTasks(session);
+ IndexReference reference = new IndexReference();
+ try {
+ TaskListIndex taskListIndex = reference.index();
+ taskListIndex.find(scopeTask.getTaskKey(), collector, 50);
+ } finally {
+ reference.dispose();
}
}
}
@@ -66,4 +62,36 @@ public class TaskActivityProvider extends ActivityProvider {
public void close() {
}
+ private static class GetAssociatedTasks extends TaskCollector {
+ private final IActivitySession session;
+
+ public GetAssociatedTasks(IActivitySession session) {
+ this.session = session;
+ }
+
+ @Override
+ public void collect(ITask task) {
+
+ Map<String, String> attrMap = new HashMap<String, String>();
+ attrMap.put("author", getAuthor(task)); //$NON-NLS-1$
+ attrMap.put("taskId", getTaskId(task)); //$NON-NLS-1$
+ ActivityEvent activityEvent = new ActivityEvent(task.getHandleIdentifier(), task.getConnectorKind(),
+ task.getSummary(), task.getCreationDate(), attrMap);
+ session.fireActivityEvent(activityEvent);
+ }
+
+ private String getTaskId(ITask task) {
+ if (task.getTaskId() == null) {
+ return UNKNOWN;
+ }
+ return task.getTaskId();
+ }
+
+ private String getAuthor(ITask task) {
+ if (task.getOwner() == null) {
+ return UNKNOWN;
+ }
+ return task.getOwner();
+ }
+ }
}
diff --git a/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/tasks/activity/core/ActivityEvent.java b/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/tasks/activity/core/ActivityEvent.java
index 05a81dd9d..6344f45a3 100644
--- a/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/tasks/activity/core/ActivityEvent.java
+++ b/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/tasks/activity/core/ActivityEvent.java
@@ -15,11 +15,13 @@ import java.util.Date;
import java.util.Map;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.mylyn.commons.core.CoreUtil;
/**
* @author Steffen Pingel
+ * @author Timur Achmetow
*/
-public class ActivityEvent {
+public class ActivityEvent implements Comparable<ActivityEvent> {
private final String handle;
@@ -32,10 +34,9 @@ public class ActivityEvent {
private final Map<String, String> attributes;
public ActivityEvent(String handle, String kind, String summary, Date date, Map<String, String> attributes) {
- Assert.isNotNull(handle);
- Assert.isNotNull(kind);
- Assert.isNotNull(summary);
- Assert.isNotNull(date);
+ Assert.isNotNull("Handle must not be null", handle); //$NON-NLS-1$
+ Assert.isNotNull("Task kind must not be null", kind); //$NON-NLS-1$
+ Assert.isNotNull("Task summary must not be null", summary); //$NON-NLS-1$
this.handle = handle;
this.kind = kind;
this.summary = summary;
@@ -93,4 +94,7 @@ public class ActivityEvent {
return true;
}
-}
+ public int compareTo(ActivityEvent object) {
+ return CoreUtil.compare(date, object.getDate());
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/tasks/activity/core/IActivityStream.java b/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/tasks/activity/core/IActivityStream.java
index c48d588df..9ce2137fa 100644
--- a/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/tasks/activity/core/IActivityStream.java
+++ b/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/tasks/activity/core/IActivityStream.java
@@ -1,7 +1,3 @@
-package org.eclipse.mylyn.tasks.activity.core;
-
-import java.util.List;
-
/*******************************************************************************
* Copyright (c) 2012 Tasktop Technologies and others.
* All rights reserved. This program and the accompanying materials
@@ -13,15 +9,24 @@ import java.util.List;
* Tasktop Technologies - initial API and implementation
*******************************************************************************/
+package org.eclipse.mylyn.tasks.activity.core;
+
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
/**
* Defines a stream of {@link ActivityEvent}s that
*
- * @author spingel
+ * @author Steffen Pingel
+ * @author Timur Achmetow
*/
public interface IActivityStream {
- List<ActivityEvent> getEvents();
+ Set<ActivityEvent> getEvents();
ActivityScope getScope();
+ void query(IProgressMonitor monitor) throws CoreException;
}

Back to the top