Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.mylyn.tasks.core')
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataState.java6
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/GetTaskHistoryJob.java87
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java47
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskHistory.java80
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskRevision.java129
5 files changed, 346 insertions, 3 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataState.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataState.java
index 016e0f776..523562086 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataState.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataState.java
@@ -189,12 +189,12 @@ public class TaskDataState implements ITaskDataWorkingCopy {
setRepositoryData(createCopy(oldState.getRepositoryData()));
}
- private TaskData createCopy(TaskData oldData) {
+ public static TaskData createCopy(TaskData oldData) {
if (oldData == null) {
return null;
}
- TaskData newData = new TaskData(oldData.getAttributeMapper(), getConnectorKind(), getRepositoryUrl(),
- getTaskId());
+ TaskData newData = new TaskData(oldData.getAttributeMapper(), oldData.getConnectorKind(),
+ oldData.getRepositoryUrl(), oldData.getTaskId());
newData.setVersion(oldData.getVersion());
for (TaskAttribute child : oldData.getRoot().getAttributes().values()) {
newData.getRoot().deepAddCopy(child);
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/GetTaskHistoryJob.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/GetTaskHistoryJob.java
new file mode 100644
index 000000000..67c34af1c
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/GetTaskHistoryJob.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.tasks.core.sync;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.mylyn.commons.core.StatusHandler;
+import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
+import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
+import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.data.TaskHistory;
+import org.eclipse.mylyn.tasks.core.sync.TaskJob;
+
+/**
+ * @author Steffen Pingel
+ */
+public class GetTaskHistoryJob extends TaskJob {
+
+ private final TaskRepository repository;
+
+ private final ITask task;
+
+ private final AbstractRepositoryConnector connector;
+
+ private IStatus errorStatus;
+
+ private TaskHistory history;
+
+ public GetTaskHistoryJob(AbstractRepositoryConnector connector, TaskRepository repository, ITask task) {
+ super("Retrieving History");
+ this.connector = connector;
+ this.repository = repository;
+ this.task = task;
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor jobMonitor) {
+ try {
+ monitor.setCanceled(false);
+ monitor.attach(jobMonitor);
+ try {
+ history = connector.getTaskHistory(repository, task, monitor);
+ } catch (CoreException e) {
+ errorStatus = e.getStatus();
+ } catch (OperationCanceledException e) {
+ errorStatus = Status.CANCEL_STATUS;
+ } catch (Exception e) {
+ StatusHandler.log(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN,
+ "Unexpected error while retrieving task history", e)); //$NON-NLS-1$
+ errorStatus = new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN, "Unexpected error: " //$NON-NLS-1$
+ + e.getMessage(), e);
+ } finally {
+ monitor.done();
+ }
+ return (errorStatus == Status.CANCEL_STATUS) ? Status.CANCEL_STATUS : Status.OK_STATUS;
+ } finally {
+ monitor.detach(jobMonitor);
+ }
+ }
+
+ public TaskHistory getHistory() {
+ return history;
+ }
+
+ @Override
+ public IStatus getStatus() {
+ return errorStatus;
+ }
+
+ public ITask getTask() {
+ return task;
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java
index 7404967fb..2136df56a 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java
@@ -25,6 +25,7 @@ import org.eclipse.mylyn.tasks.core.data.AbstractTaskAttachmentHandler;
import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
import org.eclipse.mylyn.tasks.core.data.TaskData;
import org.eclipse.mylyn.tasks.core.data.TaskDataCollector;
+import org.eclipse.mylyn.tasks.core.data.TaskHistory;
import org.eclipse.mylyn.tasks.core.data.TaskMapper;
import org.eclipse.mylyn.tasks.core.data.TaskRelation;
import org.eclipse.mylyn.tasks.core.sync.ISynchronizationSession;
@@ -58,6 +59,16 @@ public abstract class AbstractRepositoryConnector {
public abstract boolean canCreateTaskFromKey(TaskRepository repository);
/**
+ * Returns true, if the connector supports retrieval of task history for <code>task</code>.
+ *
+ * @see #getHistory(TaskRepository, ITask, IProgressMonitor)
+ * @since 3.6
+ */
+ public boolean canGetTaskHistory(TaskRepository repository, ITask task) {
+ return false;
+ }
+
+ /**
* @since 3.0
*/
public boolean canQuery(TaskRepository repository) {
@@ -386,4 +397,40 @@ public abstract class AbstractRepositoryConnector {
return false;
}
+ /**
+ * Retrieves the history for <code>task</code>. Throws {@link UnsupportedOperationException} by default.
+ *
+ * @param repository
+ * the repository
+ * @param task
+ * the task to retrieve history for
+ * @param monitor
+ * a progress monitor
+ * @return the history for <code>task</code>
+ * @throws CoreException
+ * thrown in case retrieval fails
+ * @see #canGetHistory(TaskRepository, ITask)
+ * @since 3.6
+ */
+ public TaskHistory getTaskHistory(TaskRepository repository, ITask task, IProgressMonitor monitor)
+ throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+// /**
+// * Returns a specific revision of a task. Sub-classes may override.
+// *
+// * @return null, if the revision is not found
+// * @since 3.6
+// * @see TaskHistory
+// * @see #getTaskHistory(TaskRepository, ITask, IProgressMonitor)
+// */
+// public TaskData getTaskData(TaskRepository repository, ITask task, String revisionId, IProgressMonitor monitor)
+// throws CoreException {
+// Assert.isNotNull(repository);
+// Assert.isNotNull(task);
+// Assert.isNotNull(revisionId);
+// return null;
+// }
+
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskHistory.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskHistory.java
new file mode 100644
index 000000000..715bb9c77
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskHistory.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.tasks.core.data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+
+/**
+ * A model that describes the history of changes to a task.
+ *
+ * @author Steffen Pingel
+ * @since 3.6
+ */
+public class TaskHistory {
+
+ private final TaskRepository repository;
+
+ private final List<TaskRevision> revisions;
+
+ private final ITask task;
+
+ public TaskHistory(TaskRepository repository, ITask task) {
+ Assert.isNotNull(repository);
+ Assert.isNotNull(task);
+ this.repository = repository;
+ this.task = task;
+ this.revisions = new ArrayList<TaskRevision>();
+ }
+
+ public void add(TaskRevision entry) {
+ revisions.add(entry);
+ }
+
+ public TaskRepository getRepository() {
+ return repository;
+ }
+
+ public List<TaskRevision> getRevisions() {
+ return new ArrayList<TaskRevision>(revisions);
+ }
+
+ /**
+ * Returns a specific revision for this task history.
+ *
+ * @param id
+ * the id of the revision
+ * @return the revision matching <code>id</code> or null, if no matching revision was found
+ * @see TaskRevision#getId()
+ */
+ public TaskRevision getRevision(String id) {
+ for (TaskRevision revision : revisions) {
+ if (revision.getId().equals(id)) {
+ return revision;
+ }
+ }
+ return null;
+ }
+
+ public ITask getTask() {
+ return task;
+ }
+
+ public void remove(TaskRevision entry) {
+ revisions.remove(entry);
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskRevision.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskRevision.java
new file mode 100644
index 000000000..cef4c925e
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskRevision.java
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.tasks.core.data;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.mylyn.tasks.core.IRepositoryPerson;
+
+/**
+ * Describes a revision of a task in its history.
+ *
+ * @author Steffen Pingel
+ * @since 3.6
+ */
+public class TaskRevision {
+
+ /**
+ * @author Steffen Pingel
+ */
+ public static class Change {
+
+ private final String added;
+
+ private final String attributeId;
+
+ private final String field;
+
+ private final String removed;
+
+ /**
+ * Constructs a field change.
+ *
+ * @param attributeId
+ * the id of the attribute that has changed, must not be null
+ * @param field
+ * the label of the attribute that has changed, must not be null
+ * @param removed
+ * the values that were removed
+ * @param added
+ * the values that were added
+ */
+ public Change(String attributeId, String field, String removed, String added) {
+ Assert.isNotNull(attributeId);
+ Assert.isNotNull(field);
+ this.attributeId = attributeId;
+ this.field = field;
+ this.removed = removed;
+ this.added = added;
+ }
+
+ public String getAdded() {
+ return added;
+ }
+
+ public String getAttributeId() {
+ return attributeId;
+ }
+
+ public String getField() {
+ return field;
+ }
+
+ public String getRemoved() {
+ return removed;
+ }
+
+ }
+
+ private final IRepositoryPerson author;
+
+ private final List<TaskRevision.Change> changes;
+
+ private final Date date;
+
+ private final String id;
+
+ /**
+ * @param id
+ * id that identifies the revisions, it must be unique on a per task basis
+ * @param date
+ * the time the revision was created
+ * @param author
+ * the person that made changes for this revision
+ */
+ public TaskRevision(String id, Date date, IRepositoryPerson author) {
+ Assert.isNotNull(id);
+ this.id = id;
+ this.date = date;
+ this.author = author;
+ this.changes = new ArrayList<TaskRevision.Change>();
+ }
+
+ public void add(TaskRevision.Change change) {
+ changes.add(change);
+ }
+
+ public IRepositoryPerson getAuthor() {
+ return author;
+ }
+
+ public List<TaskRevision.Change> getChanges() {
+ return new ArrayList<TaskRevision.Change>(changes);
+ }
+
+ public Date getDate() {
+ return date;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void remove(TaskRevision.Change change) {
+ changes.remove(change);
+ }
+
+} \ No newline at end of file

Back to the top