Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Davis2014-10-06 17:24:16 -0400
committerSam Davis2015-03-11 17:02:17 -0400
commitdd62414dd526d7a08da6f8f3ecd85dd52d049e2f (patch)
tree5e3d168f2af0714f415309137815bd33a6ff74a7 /org.eclipse.mylyn.tasks.core/src/org
parent66369afb5c49a63829059cb2ec1d9663f2159833 (diff)
downloadorg.eclipse.mylyn.tasks-dd62414dd526d7a08da6f8f3ecd85dd52d049e2f.tar.gz
org.eclipse.mylyn.tasks-dd62414dd526d7a08da6f8f3ecd85dd52d049e2f.tar.xz
org.eclipse.mylyn.tasks-dd62414dd526d7a08da6f8f3ecd85dd52d049e2f.zip
446091: [api] allow clients to determine when the current user owns an
ITask Change-Id: Ie6fb5d4c27fd31be4f4127be7fc82e892b503466 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=446091
Diffstat (limited to 'org.eclipse.mylyn.tasks.core/src/org')
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/AbstractTask.java14
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java9
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITask.java18
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITaskMapping.java5
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskInitializationData.java11
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskMapping.java8
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskMapper.java30
7 files changed, 89 insertions, 6 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/AbstractTask.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/AbstractTask.java
index a632c09bf..6eeefead6 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/AbstractTask.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/AbstractTask.java
@@ -93,6 +93,8 @@ public abstract class AbstractTask extends AbstractTaskContainer implements ITas
private boolean changed;
+ private String ownerId;
+
public AbstractTask(String repositoryUrl, String taskId, String summary) {
super(RepositoryTaskHandleUtil.getHandle(repositoryUrl, taskId));
this.repositoryUrl = repositoryUrl;
@@ -172,6 +174,18 @@ public abstract class AbstractTask extends AbstractTaskContainer implements ITas
}
}
+ public String getOwnerId() {
+ return ownerId;
+ }
+
+ public void setOwnerId(String ownerId) {
+ if (!areEqual(this.ownerId, ownerId)) {
+ String oldValue = this.ownerId;
+ this.ownerId = (ownerId != null) ? ownerId.intern() : null;
+ firePropertyChange("ownerId", oldValue, ownerId); //$NON-NLS-1$
+ }
+ }
+
/**
* Return the status, such as an error or warning, associated with this 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 9a6ca49b3..80df14c36 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
@@ -605,10 +605,8 @@ public abstract class AbstractRepositoryConnector {
* @since 3.5
*/
public boolean isOwnedByUser(@NonNull TaskRepository repository, @NonNull ITask task) {
- if (task.getOwner() != null) {
- return task.getOwner().equals(repository.getUserName());
- }
- return false;
+ return (task.getOwner() != null && task.getOwner().equals(repository.getUserName()))
+ || (task.getOwnerId() != null && task.getOwnerId().equals(repository.getUserName()));
}
/**
@@ -647,7 +645,8 @@ public abstract class AbstractRepositoryConnector {
* @since 3.11
*/
@NonNull
- public RepositoryInfo validateRepository(@NonNull TaskRepository repository, @Nullable IProgressMonitor monitor) throws CoreException {
+ public RepositoryInfo validateRepository(@NonNull TaskRepository repository, @Nullable IProgressMonitor monitor)
+ throws CoreException {
throw new UnsupportedOperationException();
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITask.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITask.java
index 6cf012962..d2a9d1598 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITask.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITask.java
@@ -15,6 +15,7 @@ import java.util.Date;
import org.eclipse.core.runtime.Assert;
import org.eclipse.mylyn.internal.tasks.core.Messages;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
/**
* @author Mik Kersten
@@ -280,11 +281,23 @@ public interface ITask extends IRepositoryElement, IAttributeContainer {
public abstract Date getModificationDate();
/**
+ * Returns the label of the owner, that is, the <i>option label</i> corresponding to the value of the
+ * {@link TaskAttribute#USER_ASSIGNED} attribute in the TaskData. If the connector does not provide option labels
+ * for this attribute, the {@link #getOwnerId() ID} is returned instead.
+ *
* @since 3.0
*/
public abstract String getOwner();
/**
+ * Returns the ID of the owner, that is, the <i>value</i> of the {@link TaskAttribute#USER_ASSIGNED} attribute in
+ * the TaskData.
+ *
+ * @since 3.15
+ */
+ public abstract String getOwnerId();
+
+ /**
* @since 3.0
*/
public abstract String getPriority();
@@ -358,6 +371,11 @@ public interface ITask extends IRepositoryElement, IAttributeContainer {
public abstract void setOwner(String owner);
/**
+ * @since 3.15
+ */
+ public abstract void setOwnerId(String ownerId);
+
+ /**
* @since 3.0
*/
public abstract void setPriority(String priority);
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITaskMapping.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITaskMapping.java
index 5d6972e68..414770b82 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITaskMapping.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITaskMapping.java
@@ -45,6 +45,11 @@ public interface ITaskMapping {
public abstract String getOwner();
+ /**
+ * @since 3.15
+ */
+ public abstract String getOwnerId();
+
public abstract String getPriority();
public abstract PriorityLevel getPriorityLevel();
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskInitializationData.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskInitializationData.java
index 39c3f1f51..0b3efbf25 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskInitializationData.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskInitializationData.java
@@ -109,6 +109,17 @@ public class TaskInitializationData implements ITaskMapping {
}
+ /**
+ * Returns <code>null</code>.
+ *
+ * @since 3.15
+ */
+ @Nullable
+ public String getOwnerId() {
+ return null;
+
+ }
+
@Nullable
public String getPriority() {
return attributesById.getAttribute(TaskAttribute.PRIORITY);
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskMapping.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskMapping.java
index 7b63369c1..f9f2f885c 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskMapping.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskMapping.java
@@ -89,6 +89,14 @@ public class TaskMapping implements ITaskMapping {
}
/**
+ * @since 3.15
+ */
+ public String getOwnerId() {
+ // ignore
+ return null;
+ }
+
+ /**
* @since 3.0
*/
public PriorityLevel getPriorityLevel() {
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskMapper.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskMapper.java
index c9b35586f..ff5dbe7ef 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskMapper.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskMapper.java
@@ -64,6 +64,10 @@ public class TaskMapper implements ITaskMapping {
task.setOwner(getOwner());
changed = true;
}
+ if (hasChanges(task.getOwnerId(), getOwnerId(), TaskAttribute.USER_ASSIGNED)) {
+ task.setOwnerId(getOwnerId());
+ changed = true;
+ }
if (hasChanges(task.getPriority(), getPriorityLevelString(), TaskAttribute.PRIORITY)) {
task.setPriority(getPriorityLevelString());
changed = true;
@@ -135,7 +139,7 @@ public class TaskMapper implements ITaskMapping {
* <li>description
* </ul>
* Other attribute values are only set if they exist on <code>sourceTaskData</code> and <code>targetTaskData</code>.
- *
+ *
* @param sourceTaskData
* the source task data values are copied from, the connector kind of repository of
* <code>sourceTaskData</code> can be different from <code>targetTaskData</code>
@@ -265,6 +269,14 @@ public class TaskMapper implements ITaskMapping {
return getValue(TaskAttribute.USER_ASSIGNED);
}
+ /**
+ * @since 3.15
+ */
+ @Nullable
+ public String getOwnerId() {
+ return getValueId(TaskAttribute.USER_ASSIGNED);
+ }
+
@Nullable
public String getPriority() {
return getValue(TaskAttribute.PRIORITY);
@@ -334,6 +346,9 @@ public class TaskMapper implements ITaskMapping {
return getValue(TaskAttribute.TASK_URL);
}
+ /**
+ * Returns the label of the attribute value.
+ */
@Nullable
public String getValue(@NonNull String attributeKey) {
TaskAttribute attribute = taskData.getRoot().getMappedAttribute(attributeKey);
@@ -343,6 +358,18 @@ public class TaskMapper implements ITaskMapping {
return null;
}
+ /**
+ * Returns the id of the attribute value.
+ */
+ @Nullable
+ private String getValueId(@NonNull String attributeKey) {
+ TaskAttribute attribute = taskData.getRoot().getMappedAttribute(attributeKey);
+ if (attribute != null) {
+ return taskData.getAttributeMapper().getValue(attribute);
+ }
+ return null;
+ }
+
@Nullable
private List<String> getValues(@NonNull String attributeKey) {
TaskAttribute attribute = taskData.getRoot().getMappedAttribute(attributeKey);
@@ -367,6 +394,7 @@ public class TaskMapper implements ITaskMapping {
changed |= hasChanges(task.getModificationDate(), getModificationDate(), TaskAttribute.DATE_MODIFICATION);
changed |= hasChanges(task.getDueDate(), getDueDate(), TaskAttribute.DATE_DUE);
changed |= hasChanges(task.getOwner(), getOwner(), TaskAttribute.USER_ASSIGNED);
+ changed |= hasChanges(task.getOwnerId(), getOwnerId(), TaskAttribute.USER_ASSIGNED);
changed |= hasChanges(task.getPriority(), getPriorityLevelString(), TaskAttribute.PRIORITY);
changed |= hasChanges(task.getSummary(), getSummary(), TaskAttribute.SUMMARY);
changed |= hasChanges(task.getTaskKey(), getTaskKey(), TaskAttribute.TASK_KEY);

Back to the top