Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Muskalla2012-11-16 11:53:13 +0000
committerSteffen Pingel2013-07-04 21:09:42 +0000
commit4de53483f9cbdc8556101045d7dfa4d3402caf54 (patch)
tree0fc91a8cb9d991ef94293eba56619ec278cba32e /org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks
parentf82af84a906206b9f3cdbf92132bf0db1f4832f9 (diff)
downloadorg.eclipse.mylyn.tasks-4de53483f9cbdc8556101045d7dfa4d3402caf54.tar.gz
org.eclipse.mylyn.tasks-4de53483f9cbdc8556101045d7dfa4d3402caf54.tar.xz
org.eclipse.mylyn.tasks-4de53483f9cbdc8556101045d7dfa4d3402caf54.zip
386764: [api] TaskMapping should be able to handle custom attributes
Added new API called TaskInitializationData to provide common mutators for ITaskMapping to be used for task data initialization. Also-By: Steffen Pingel <steffen.pingel@tasktop.com> Change-Id: I13c88b5e33a8ab097953833627383ae85cfa692f Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=386764 Signed-off-by: Benjamin Muskalla <benjamin.muskalla@tasktop.com>
Diffstat (limited to 'org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks')
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskInitializationData.java249
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/AbstractTaskDataHandler.java12
2 files changed, 261 insertions, 0 deletions
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
new file mode 100644
index 000000000..6f8e4ea05
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskInitializationData.java
@@ -0,0 +1,249 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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;
+
+import java.util.Date;
+import java.util.List;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.mylyn.internal.tasks.core.AttributeMap;
+import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel;
+import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.core.data.TaskData;
+
+/**
+ * TaskInitialzationData should be used as alternative to implementing {@link ITaskMapping} when passing initialization
+ * data into {@link AbstractTaskDataHandler#initializeTaskData()}. It provides common accessors and mutators for a set
+ * of fields used during task data initialization. Only attributes of type {@link String} are supported, other accessors
+ * throw {@link UnsupportedOperationException} as documented for each method.
+ *
+ * @author Benjamin Muskalla
+ * @since 3.10
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class TaskInitializationData implements ITaskMapping {
+
+ private final AttributeMap attributesById = new AttributeMap();
+
+ @Nullable
+ public String getAttribute(String key) {
+ return attributesById.getAttribute(key);
+ }
+
+ /**
+ * Throws {@link UnsupportedOperationException}.
+ */
+ @Nullable
+ public List<String> getCc() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Throws {@link UnsupportedOperationException}.
+ */
+ @Nullable
+ public Date getCompletionDate() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Nullable
+ public String getComponent() {
+ return attributesById.getAttribute(TaskAttribute.COMPONENT);
+ }
+
+ /**
+ * Throws {@link UnsupportedOperationException}.
+ */
+ @Nullable
+ public Date getCreationDate() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Nullable
+ public String getDescription() {
+ return attributesById.getAttribute(TaskAttribute.DESCRIPTION);
+ }
+
+ /**
+ * Throws {@link UnsupportedOperationException}.
+ */
+ @Nullable
+ public Date getDueDate() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Throws {@link UnsupportedOperationException}.
+ */
+ @Nullable
+ public List<String> getKeywords() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Throws {@link UnsupportedOperationException}.
+ */
+ @Nullable
+ public Date getModificationDate() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Throws {@link UnsupportedOperationException}.
+ */
+ @Nullable
+ public String getOwner() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Nullable
+ public String getPriority() {
+ return attributesById.getAttribute(TaskAttribute.PRIORITY);
+ }
+
+ /**
+ * Throws {@link UnsupportedOperationException}.
+ */
+ @Nullable
+ public PriorityLevel getPriorityLevel() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Nullable
+ public String getProduct() {
+ return attributesById.getAttribute(TaskAttribute.PRODUCT);
+ }
+
+ @Nullable
+ public String getReporter() {
+ return attributesById.getAttribute(TaskAttribute.USER_REPORTER);
+ }
+
+ @Nullable
+ public String getResolution() {
+ return attributesById.getAttribute(TaskAttribute.RESOLUTION);
+ }
+
+ @Nullable
+ public String getSeverity() {
+ return attributesById.getAttribute(TaskAttribute.SEVERITY);
+ }
+
+ @Nullable
+ public String getStatus() {
+ return attributesById.getAttribute(TaskAttribute.STATUS);
+ }
+
+ @Nullable
+ public String getSummary() {
+ return attributesById.getAttribute(TaskAttribute.SUMMARY);
+ }
+
+ /**
+ * Throws {@link UnsupportedOperationException}.
+ */
+ @Nullable
+ public TaskData getTaskData() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Nullable
+ public String getTaskKey() {
+ return attributesById.getAttribute(TaskAttribute.TASK_KEY);
+ }
+
+ @Nullable
+ public String getTaskKind() {
+ return attributesById.getAttribute(TaskAttribute.TASK_KIND);
+ }
+
+ /**
+ * Does not map to a common attribute and hence throws {@link UnsupportedOperationException}.
+ */
+ @Nullable
+ public String getTaskStatus() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Nullable
+ public String getTaskUrl() {
+ return attributesById.getAttribute(TaskAttribute.TASK_URL);
+ }
+
+ @Nullable
+ public String getVersion() {
+ return attributesById.getAttribute(TaskAttribute.VERSION);
+ }
+
+ /**
+ * Throws {@link UnsupportedOperationException}.
+ */
+ @Nullable
+ public void merge(ITaskMapping source) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setAttribute(@NonNull String key, @Nullable String value) {
+ attributesById.setAttribute(key, value);
+ }
+
+ public void setComponent(@Nullable String newComponent) {
+ attributesById.setAttribute(TaskAttribute.COMPONENT, newComponent);
+ }
+
+ public void setDescription(@Nullable String description) {
+ attributesById.setAttribute(TaskAttribute.DESCRIPTION, description);
+ }
+
+ public void setPriority(@Nullable String priority) {
+ attributesById.setAttribute(TaskAttribute.PRIORITY, priority);
+ }
+
+ public void setProduct(@Nullable String product) {
+ attributesById.setAttribute(TaskAttribute.PRODUCT, product);
+ }
+
+ public void setResolution(@Nullable String resolution) {
+ attributesById.setAttribute(TaskAttribute.RESOLUTION, resolution);
+ }
+
+ public void setSeverity(@Nullable String severity) {
+ attributesById.setAttribute(TaskAttribute.SEVERITY, severity);
+ }
+
+ public void setStatus(@Nullable String status) {
+ attributesById.setAttribute(TaskAttribute.STATUS, status);
+ }
+
+ public void setSummary(@Nullable String summary) {
+ attributesById.setAttribute(TaskAttribute.SUMMARY, summary);
+ }
+
+ public void setTaskKey(@Nullable String taskKey) {
+ attributesById.setAttribute(TaskAttribute.TASK_KEY, taskKey);
+ }
+
+ public void setTaskKind(@Nullable String taskKind) {
+ attributesById.setAttribute(TaskAttribute.TASK_KIND, taskKind);
+ }
+
+ public void setTaskUrl(@Nullable String newKind) {
+ attributesById.setAttribute(TaskAttribute.TASK_URL, newKind);
+ }
+
+ public void setVersion(@Nullable String version) {
+ attributesById.setAttribute(TaskAttribute.VERSION, version);
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/AbstractTaskDataHandler.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/AbstractTaskDataHandler.java
index 05d70a238..a3781abc1 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/AbstractTaskDataHandler.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/AbstractTaskDataHandler.java
@@ -21,6 +21,7 @@ import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITaskMapping;
import org.eclipse.mylyn.tasks.core.RepositoryResponse;
+import org.eclipse.mylyn.tasks.core.TaskInitializationData;
import org.eclipse.mylyn.tasks.core.TaskRepository;
/**
@@ -55,6 +56,17 @@ public abstract class AbstractTaskDataHandler {
/**
* Initialize a new task data object with default attributes and values
*
+ * @param repository
+ * The {@code TaskRepository} the taskdata belongs to.
+ * @param data
+ * The {@code TaskData} to be initialized
+ * @param initializationData
+ * the {@link ITaskMapping} to initialize the {@link TaskData}. It is recommended to pass in a
+ * {@link TaskInitializationData}.
+ * @param monitor
+ * The {@link IProgressMonitor} that will be used during initialization.
+ * @return whether the initialization of the {@code TaskData} was successful. Implementations can alternativly throw
+ * a {@code CoreException} with further details.
* @since 3.0
*/
public abstract boolean initializeTaskData(@NonNull TaskRepository repository, @NonNull TaskData data,

Back to the top