Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2008-01-27 02:47:43 -0500
committerspingel2008-01-27 02:47:43 -0500
commit4b755c38d3b9db19cea0d5ae0ee6e7547761b1eb (patch)
treecfda5de0febd36177e94ffad74e43460a63e025c /org.eclipse.mylyn.trac.core
parent3b6919a146ed0ad1870cd0d282c84669eb029eef (diff)
downloadorg.eclipse.mylyn.tasks-4b755c38d3b9db19cea0d5ae0ee6e7547761b1eb.tar.gz
org.eclipse.mylyn.tasks-4b755c38d3b9db19cea0d5ae0ee6e7547761b1eb.tar.xz
org.eclipse.mylyn.tasks-4b755c38d3b9db19cea0d5ae0ee6e7547761b1eb.zip
NEW - bug 216525: trac connector grouping of tasks
https://bugs.eclipse.org/bugs/show_bug.cgi?id=216525
Diffstat (limited to 'org.eclipse.mylyn.trac.core')
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracRepositoryConnector.java34
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTask.java82
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java38
3 files changed, 118 insertions, 36 deletions
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracRepositoryConnector.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracRepositoryConnector.java
index 50d3a0966..4da5f94d8 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracRepositoryConnector.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracRepositoryConnector.java
@@ -153,6 +153,20 @@ public class TracRepositoryConnector extends AbstractRepositoryConnector {
}
@Override
+ public boolean updateTaskFromQueryHit(TaskRepository repository, AbstractTask existingTask, AbstractTask queryHit) {
+ if (hasRichEditor(repository)) {
+ // handled by updateTaskFromTaskData
+ return false;
+ }
+
+ boolean changed = super.updateTaskFromQueryHit(repository, existingTask, queryHit);
+ if (existingTask instanceof TracTask) {
+ ((TracTask)existingTask).setSupportsSubtasks(false);
+ }
+ return changed;
+ }
+
+ @Override
public IStatus performQuery(AbstractRepositoryQuery query, TaskRepository repository, IProgressMonitor monitor,
ITaskCollector resultCollector) {
@@ -277,23 +291,25 @@ public class TracRepositoryConnector extends AbstractRepositoryConnector {
}
@Override
- public void updateTaskFromTaskData(TaskRepository taskRepository, AbstractTask repositoryTask,
+ public void updateTaskFromTaskData(TaskRepository taskRepository, AbstractTask task,
RepositoryTaskData taskData) {
// API 3.0 taskData should never be null
- if (taskData != null) {
+ if (taskData != null && task instanceof TracTask) {
ITracClient client = getClientManager().getRepository(taskRepository);
- repositoryTask.setSummary(taskData.getSummary());
- repositoryTask.setOwner(taskData.getAttributeValue(RepositoryTaskAttribute.USER_ASSIGNED));
- repositoryTask.setCompleted(TracTask.isCompleted(taskData.getStatus()));
- repositoryTask.setUrl(taskRepository.getUrl() + ITracClient.TICKET_URL + taskData.getId());
+ task.setSummary(taskData.getSummary());
+ task.setOwner(taskData.getAttributeValue(RepositoryTaskAttribute.USER_ASSIGNED));
+ task.setCompleted(TracTask.isCompleted(taskData.getStatus()));
+ task.setUrl(taskRepository.getUrl() + ITracClient.TICKET_URL + taskData.getId());
String priority = taskData.getAttributeValue(Attribute.PRIORITY.getTracKey());
TracPriority[] tracPriorities = client.getPriorities();
- repositoryTask.setPriority(TracTask.getTaskPriority(priority, tracPriorities));
+ task.setPriority(TracTask.getTaskPriority(priority, tracPriorities));
Kind kind = TracTask.Kind.fromType(taskData.getAttributeValue(Attribute.TYPE.getTracKey()));
- repositoryTask.setTaskKind((kind != null) ? kind.toString() : null);
+ task.setTaskKind((kind != null) ? kind.toString() : null);
+
+ ((TracTask)task).setSupportsSubtasks(taskDataHandler.canInitializeSubTaskData(null, taskData));
// TODO: Completion Date
}
}
@@ -338,6 +354,8 @@ public class TracRepositoryConnector extends AbstractRepositoryConnector {
task.setCreationDate(ticket.getCreated());
}
+ task.setSupportsSubtasks(ticket.getCustomValue(TracTaskDataHandler.ATTRIBUTE_BLOCKING) != null);
+
if (notify) {
taskList.notifyTaskChanged(task, false);
}
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTask.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTask.java
index 23be9763e..ca3127033 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTask.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTask.java
@@ -20,26 +20,34 @@ public class TracTask extends AbstractTask {
DEFECT, ENHANCEMENT, TASK;
public static Kind fromString(String type) {
- if (type == null)
+ if (type == null) {
return null;
- if (type.equals("Defect"))
+ }
+ if (type.equals("Defect")) {
return DEFECT;
- if (type.equals("Enhancement"))
+ }
+ if (type.equals("Enhancement")) {
return ENHANCEMENT;
- if (type.equals("Task"))
+ }
+ if (type.equals("Task")) {
return TASK;
+ }
return null;
}
public static Kind fromType(String type) {
- if (type == null)
+ if (type == null) {
return null;
- if (type.equals("defect"))
+ }
+ if (type.equals("defect")) {
return DEFECT;
- if (type.equals("enhancement"))
+ }
+ if (type.equals("enhancement")) {
return ENHANCEMENT;
- if (type.equals("task"))
+ }
+ if (type.equals("task")) {
return TASK;
+ }
return null;
}
@@ -58,21 +66,26 @@ public class TracTask extends AbstractTask {
}
}
-
+
public enum Status {
ASSIGNED, CLOSED, NEW, REOPENED;
public static Status fromStatus(String status) {
- if (status == null)
+ if (status == null) {
return null;
- if (status.equals("new"))
+ }
+ if (status.equals("new")) {
return NEW;
- if (status.equals("assigned"))
+ }
+ if (status.equals("assigned")) {
return ASSIGNED;
- if (status.equals("reopened"))
+ }
+ if (status.equals("reopened")) {
return REOPENED;
- if (status.equals("closed"))
+ }
+ if (status.equals("closed")) {
return CLOSED;
+ }
return null;
}
@@ -113,21 +126,27 @@ public class TracTask extends AbstractTask {
BLOCKER, CRITICAL, MAJOR, MINOR, TRIVIAL;
public static TracPriorityLevel fromPriority(String priority) {
- if (priority == null)
+ if (priority == null) {
return null;
- if (priority.equals("blocker"))
+ }
+ if (priority.equals("blocker")) {
return BLOCKER;
- if (priority.equals("critical"))
+ }
+ if (priority.equals("critical")) {
return CRITICAL;
- if (priority.equals("major"))
+ }
+ if (priority.equals("major")) {
return MAJOR;
- if (priority.equals("minor"))
+ }
+ if (priority.equals("minor")) {
return MINOR;
- if (priority.equals("trivial"))
+ }
+ if (priority.equals("trivial")) {
return TRIVIAL;
+ }
return null;
}
-
+
public PriorityLevel toPriorityLevel() {
switch (this) {
case BLOCKER:
@@ -142,7 +161,7 @@ public class TracTask extends AbstractTask {
return PriorityLevel.P5;
default:
return null;
- }
+ }
}
@Override
@@ -162,7 +181,7 @@ public class TracTask extends AbstractTask {
return null;
}
}
-
+
}
private static int TASK_PRIORITY_LEVELS = 5;
@@ -183,13 +202,13 @@ public class TracTask extends AbstractTask {
int range = tracPriorities[tracPriorities.length - 1].getValue() - minValue;
for (TracPriority tracPriority : tracPriorities) {
if (priority.equals(tracPriority.getName())) {
- float relativeValue = (float)(tracPriority.getValue() - minValue) / range;
- int value = (int)(relativeValue * TASK_PRIORITY_LEVELS) + 1;
+ float relativeValue = (float) (tracPriority.getValue() - minValue) / range;
+ int value = (int) (relativeValue * TASK_PRIORITY_LEVELS) + 1;
return AbstractTask.PriorityLevel.fromLevel(value).toString();
}
}
}
-
+
return getTaskPriority(priority);
}
@@ -198,6 +217,8 @@ public class TracTask extends AbstractTask {
return status == TracTask.Status.CLOSED;
}
+ private boolean supportsSubtasks = false;
+
public TracTask(String repositoryUrl, String id, String label) {
super(repositoryUrl, id, label);
setUrl(repositoryUrl + ITracClient.TICKET_URL + id);
@@ -207,11 +228,18 @@ public class TracTask extends AbstractTask {
public String getConnectorKind() {
return TracCorePlugin.REPOSITORY_KIND;
}
-
@Override
public boolean isLocal() {
return false;
}
+ public boolean getSupportsSubtasks() {
+ return supportsSubtasks;
+ }
+
+ public void setSupportsSubtasks(boolean supportsSubtasks) {
+ this.supportsSubtasks = supportsSubtasks;
+ }
+
}
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java
index 267f12825..9da8a0e91 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java
@@ -12,6 +12,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -19,6 +20,7 @@ import java.util.StringTokenizer;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.mylyn.internal.trac.core.TracAttributeFactory.Attribute;
@@ -29,9 +31,11 @@ import org.eclipse.mylyn.internal.trac.core.model.TracTicketField;
import org.eclipse.mylyn.internal.trac.core.model.TracTicket.Key;
import org.eclipse.mylyn.internal.trac.core.util.TracUtils;
import org.eclipse.mylyn.tasks.core.AbstractAttributeFactory;
+import org.eclipse.mylyn.tasks.core.AbstractTask;
import org.eclipse.mylyn.tasks.core.AbstractTaskDataHandler;
import org.eclipse.mylyn.tasks.core.RepositoryAttachment;
import org.eclipse.mylyn.tasks.core.RepositoryOperation;
+import org.eclipse.mylyn.tasks.core.RepositoryStatus;
import org.eclipse.mylyn.tasks.core.RepositoryTaskAttribute;
import org.eclipse.mylyn.tasks.core.RepositoryTaskData;
import org.eclipse.mylyn.tasks.core.TaskComment;
@@ -42,6 +46,10 @@ import org.eclipse.mylyn.tasks.core.TaskRepository;
*/
public class TracTaskDataHandler extends AbstractTaskDataHandler {
+ public static final String ATTRIBUTE_BLOCKED_BY = "blockedby";
+
+ public static final String ATTRIBUTE_BLOCKING = "blocking";
+
private static final String CC_DELIMETER = ", ";
private AbstractAttributeFactory attributeFactory = new TracAttributeFactory();
@@ -359,9 +367,37 @@ public class TracTaskDataHandler extends AbstractTaskDataHandler {
}
@Override
+ public boolean initializeSubTaskData(TaskRepository repository, RepositoryTaskData taskData,
+ RepositoryTaskData parentTaskData, IProgressMonitor monitor) throws CoreException {
+ initializeTaskData(repository, taskData, monitor);
+ RepositoryTaskAttribute attribute = taskData.getAttribute(ATTRIBUTE_BLOCKING);
+ if (attribute == null) {
+ throw new CoreException(new RepositoryStatus(repository, IStatus.ERROR, TracCorePlugin.PLUGIN_ID, RepositoryStatus.ERROR_REPOSITORY, "The repository does not support subtasks"));
+ }
+ cloneTaskData(parentTaskData, taskData);
+ taskData.setDescription("");
+ taskData.setSummary("");
+ attribute.setValue(parentTaskData.getId());
+ return true;
+ }
+
+ @Override
public Set<String> getSubTaskIds(RepositoryTaskData taskData) {
- // TODO Auto-generated method stub
+ RepositoryTaskAttribute attribute = taskData.getAttribute(ATTRIBUTE_BLOCKED_BY);
+ if (attribute != null) {
+ return new HashSet<String>(Arrays.asList(attribute.getValue().split("\\s")));
+ }
return Collections.emptySet();
}
+ @Override
+ public boolean canInitializeSubTaskData(AbstractTask task, RepositoryTaskData parentTaskData) {
+ if (parentTaskData != null) {
+ return parentTaskData.getAttribute(ATTRIBUTE_BLOCKED_BY) != null;
+ } else if (task instanceof TracTask) {
+ return ((TracTask)task).getSupportsSubtasks();
+ }
+ return false;
+ }
+
}

Back to the top