Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchris.poon2015-11-26 18:42:37 -0500
committerGerrit Code Review @ Eclipse.org2015-11-30 14:54:36 -0500
commit262b4f0876b7abae93c83d7747295f0b3d1d268c (patch)
tree52ee15a955edcb2a5d126cf022703d80191b4f28 /org.eclipse.mylyn.tasks.core/src/org
parent11fb814632a825d3ee291ff6fdd53dd0a3a627ad (diff)
downloadorg.eclipse.mylyn.tasks-262b4f0876b7abae93c83d7747295f0b3d1d268c.tar.gz
org.eclipse.mylyn.tasks-262b4f0876b7abae93c83d7747295f0b3d1d268c.tar.xz
org.eclipse.mylyn.tasks-262b4f0876b7abae93c83d7747295f0b3d1d268c.zip
463022: [api] add support for storing usernames on RepositoryPerson
Change-Id: Id565b10626461759e0322bcbbbd37e628e27eafb Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=463022 Signed-off-by: chris.poon <chris.poon@tasktop.com>
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/RepositoryPerson.java28
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/IRepositoryPerson.java27
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttribute.java42
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttributeMapper.java4
4 files changed, 82 insertions, 19 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/RepositoryPerson.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/RepositoryPerson.java
index 87358d841..817e64c76 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/RepositoryPerson.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/RepositoryPerson.java
@@ -11,8 +11,14 @@
package org.eclipse.mylyn.internal.tasks.core;
+import java.util.HashMap;
+import java.util.Map;
+
import org.eclipse.mylyn.tasks.core.IRepositoryPerson;
import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+
+import com.google.common.collect.ImmutableMap;
/**
* @author Steffen Pingel
@@ -25,6 +31,8 @@ public class RepositoryPerson implements IRepositoryPerson {
private final TaskRepository taskRepository;
+ private final Map<String, String> attributes = new HashMap<>();
+
public RepositoryPerson(TaskRepository taskRepository, String personId) {
this.taskRepository = taskRepository;
this.personId = personId;
@@ -50,10 +58,30 @@ public class RepositoryPerson implements IRepositoryPerson {
return taskRepository;
}
+ public String getAttribute(String key) {
+ return attributes.get(key);
+ }
+
+ public Map<String, String> getAttributes() {
+ return ImmutableMap.copyOf(attributes);
+ }
+
public void setName(String name) {
this.name = name;
}
+ public void setAttribute(String key, String value) {
+ attributes.put(key, value);
+ }
+
+ public boolean matchesUsername(String username) {
+ String thisUsername = attributes.get(TaskAttribute.PERSON_USERNAME);
+ if (thisUsername != null) {
+ return thisUsername.equals(username);
+ }
+ return getPersonId().equals(username);
+ }
+
@Override
public String toString() {
if (getName() == null) {
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/IRepositoryPerson.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/IRepositoryPerson.java
index 7dd8079e6..0964f4271 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/IRepositoryPerson.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/IRepositoryPerson.java
@@ -11,6 +11,10 @@
package org.eclipse.mylyn.tasks.core;
+import java.util.Map;
+
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+
/**
* @author Steffen Pingel
* @since 3.0
@@ -49,4 +53,27 @@ public interface IRepositoryPerson {
*/
public abstract void setName(String name);
+ /**
+ * Compares persons using the {@link TaskAttribute#PERSON_USERNAME} if defined, or the {@link #getPersonId() person
+ * ID} otherwise.
+ *
+ * @since 3.18
+ */
+ public abstract boolean matchesUsername(String username);
+
+ /**
+ * @since 3.18
+ */
+ public abstract String getAttribute(String key);
+
+ /**
+ * @since 3.18
+ */
+ public abstract void setAttribute(String key, String value);
+
+ /**
+ * @since 3.18
+ */
+ public abstract Map<String, String> getAttributes();
+
} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttribute.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttribute.java
index c805090cd..1a3519dc7 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttribute.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttribute.java
@@ -18,10 +18,11 @@ import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.mylyn.internal.tasks.core.RepositoryPerson;
/**
* Encapsulates attributes for task data.
- *
+ *
* @author Rob Elves
* @author Steffen Pingel
* @author Miles Parker
@@ -111,7 +112,7 @@ public final class TaskAttribute {
/**
* A {@link TaskAttributeMetaData#getKind() kind} used to indicate that the field is related to a description.
- *
+ *
* @since 3.11
*/
public static final String KIND_DESCRIPTION = "task.common.kind.description"; //$NON-NLS-1$
@@ -134,7 +135,7 @@ public final class TaskAttribute {
* <br>
* Example: In Bugzilla we have COMPONENT, VERSION, TARGET_MILESTONE as depends on the PRODUCT. We can so update the
* options of the attributes to match the definition of the PRODUCT.
- *
+ *
* @see #BugzillaRestCreateTaskSchema
* @since 3.17
*/
@@ -142,11 +143,11 @@ public final class TaskAttribute {
/**
* A key for {@link TaskAttributeMetaData} that is used for specifying the media type of a
- * {@link #TYPE_LONG_RICH_TEXT} or {@link #TYPE_SHORT_RICH_TEXT}. The media type if specified must be a valid
- * <a href="http://en.wikipedia.org/wiki/Internet_media_type">Internet Media Type</a> (also known as Content-Type,
- * mime-type) according to <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a> and
- * <a href="http://www.ietf.org/rfc/rfc2046.txt">RFC 2046</a>.
- *
+ * {@link #TYPE_LONG_RICH_TEXT} or {@link #TYPE_SHORT_RICH_TEXT}. The media type if specified must be a valid <a
+ * href="http://en.wikipedia.org/wiki/Internet_media_type">Internet Media Type</a> (also known as Content-Type,
+ * mime-type) according to <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a> and <a
+ * href="http://www.ietf.org/rfc/rfc2046.txt">RFC 2046</a>.
+ *
* @see #TYPE_LONG_RICH_TEXT
* @see #TYPE_SHORT_RICH_TEXT
* @see #META_ATTRIBUTE_TYPE
@@ -166,7 +167,7 @@ public final class TaskAttribute {
* Key for {@link TaskAttributeMetaData} used to specify that a field requires a value before it can be submitted to
* the server. This meta-data is used by the framework as a UI hint and does not guarantee that a connector will
* enforce compliance before attempting to post task data.
- *
+ *
* @since 3.11
*/
public static final String META_REQUIRED = "task.meta.required"; //$NON-NLS-1$
@@ -179,7 +180,7 @@ public final class TaskAttribute {
/**
* Key for the meta datum that determines if an attribute is disabled. This is used to indicate that an attribute
* should not be modified, e.g. due to work-flow state but it may still be generally writeable.
- *
+ *
* @since 3.5
* @see TaskAttributeMetaData#isDisabled()
*/
@@ -187,7 +188,7 @@ public final class TaskAttribute {
/**
* Key for the meta datum that provides a description of an attribute, e.g. for display in a tooltip.
- *
+ *
* @since 3.5
* @see TaskAttributeMetaData
*/
@@ -198,7 +199,7 @@ public final class TaskAttribute {
* content. Provides a way for connectors to specify non-standard attributes as plain-text indexable. By default,
* {@link #SUMMARY summary} and {@link #DESCRIPTION description} are indexed. Note that setting this meta-data is
* advisory only and will not guarantee that content is indexed.
- *
+ *
* @since 3.7
*/
public static final String META_INDEXED_AS_CONTENT = "task.meta.index.content"; //$NON-NLS-1$
@@ -212,6 +213,14 @@ public final class TaskAttribute {
public static final String PERSON_NAME = "task.common.person.name"; //$NON-NLS-1$
+ /**
+ * Key for {@link RepositoryPerson} used to store the human-readable username used to log into the repository, if it
+ * is different than the ID used to identify the person in {@link TaskData}.
+ *
+ * @since 3.18
+ */
+ public static final String PERSON_USERNAME = "task.common.person.username"; //$NON-NLS-1$
+
public static final String PREFIX_ATTACHMENT = "task.common.attachment-"; //$NON-NLS-1$
public static final String PREFIX_COMMENT = "task.common.comment-"; //$NON-NLS-1$
@@ -485,9 +494,8 @@ public final class TaskAttribute {
public TaskAttribute getMappedAttribute(String attributeId) {
Assert.isNotNull(attributeId);
- return (attributeById != null)
- ? attributeById.get(getTaskData().getAttributeMapper().mapToRepositoryKey(this, attributeId))
- : null;
+ return (attributeById != null) ? attributeById.get(getTaskData().getAttributeMapper().mapToRepositoryKey(this,
+ attributeId)) : null;
}
public TaskAttribute getMappedAttribute(String[] path) {
@@ -570,7 +578,7 @@ public final class TaskAttribute {
* testing whether or not {@link #getValue()} returns an empty string, as it is possible that an empty string value
* has been explicitly set for the attribute. Call {@link #clearValues()} to return the attribute to the unset
* state.
- *
+ *
* @return true if any value is set (may be an empty string), false if no value is set.
* @since 3.9
*/
@@ -597,7 +605,7 @@ public final class TaskAttribute {
/**
* Adds an attribute option value
- *
+ *
* @param key
* The option value used when sending the form to the server
* @param value
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttributeMapper.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttributeMapper.java
index 257fe0f92..8922609a3 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttributeMapper.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskAttributeMapper.java
@@ -39,8 +39,8 @@ public class TaskAttributeMapper {
@NonNull
public TaskAttribute createTaskAttachment(@NonNull TaskData taskData) {
- TaskAttribute taskAttribute = taskData.getRoot()
- .createAttribute(mapToRepositoryKey(taskData.getRoot(), TaskAttribute.NEW_ATTACHMENT));
+ TaskAttribute taskAttribute = taskData.getRoot().createAttribute(
+ mapToRepositoryKey(taskData.getRoot(), TaskAttribute.NEW_ATTACHMENT));
// TaskAttachmentMapper mapper = TaskAttachmentMapper.createFrom(taskAttribute);
// mapper.setContentType("");
// mapper.setFileName("");

Back to the top