summaryrefslogtreecommitdiff
path: root/plugins/tasks/tasks-core/src/com/intellij/tasks/bugzilla/BugzillaTask.java
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/tasks/tasks-core/src/com/intellij/tasks/bugzilla/BugzillaTask.java')
-rw-r--r--plugins/tasks/tasks-core/src/com/intellij/tasks/bugzilla/BugzillaTask.java102
1 files changed, 102 insertions, 0 deletions
diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/bugzilla/BugzillaTask.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/bugzilla/BugzillaTask.java
new file mode 100644
index 000000000000..5c94ad2edf0a
--- /dev/null
+++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/bugzilla/BugzillaTask.java
@@ -0,0 +1,102 @@
+package com.intellij.tasks.bugzilla;
+
+import com.intellij.tasks.Comment;
+import com.intellij.tasks.Task;
+import com.intellij.tasks.TaskRepository;
+import com.intellij.tasks.TaskType;
+import icons.TasksIcons;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import java.util.Date;
+import java.util.Hashtable;
+
+/**
+ * @author Mikhail Golubev
+ */
+@SuppressWarnings("UseOfObsoleteCollectionType")
+public class BugzillaTask extends Task {
+ private final Hashtable<String, Object> myResponse;
+ private final BugzillaRepository myRepository;
+
+ public BugzillaTask(@NotNull Hashtable<String, Object> xmlRpcResponse, @NotNull BugzillaRepository repository) {
+ myResponse = xmlRpcResponse;
+ myRepository = repository;
+ }
+
+ @NotNull
+ @Override
+ public String getId() {
+ return String.valueOf(myResponse.get("id"));
+ }
+
+ @NotNull
+ @Override
+ public String getSummary() {
+ return (String)myResponse.get("summary");
+ }
+
+ @Nullable
+ @Override
+ public String getDescription() {
+ return null;
+ }
+
+ @NotNull
+ @Override
+ public Comment[] getComments() {
+ return Comment.EMPTY_ARRAY;
+ }
+
+ @NotNull
+ @Override
+ public Icon getIcon() {
+ return TasksIcons.Bugzilla;
+ }
+
+ @NotNull
+ @Override
+ public TaskType getType() {
+ String severity = (String)myResponse.get("severity");
+ return severity.equalsIgnoreCase("enhancement")? TaskType.FEATURE : TaskType.BUG;
+ }
+
+ @Nullable
+ @Override
+ public Date getUpdated() {
+ return (Date)myResponse.get("last_change_time");
+ }
+
+ @Nullable
+ @Override
+ public Date getCreated() {
+ return (Date)myResponse.get("creation_time");
+ }
+
+ @Override
+ public boolean isClosed() {
+ return !(Boolean)myResponse.get("is_open");
+ }
+
+ @Override
+ public boolean isIssue() {
+ return true;
+ }
+
+ @Nullable
+ @Override
+ public String getIssueUrl() {
+ String repositoryUrl = myRepository.getUrl();
+ if (repositoryUrl.endsWith("xmlrpc.cgi")) {
+ repositoryUrl = repositoryUrl.substring(0, repositoryUrl.length() - "xmlrpc.cgi".length());
+ }
+ return repositoryUrl + "/show_bug.cgi?id=" + getId();
+ }
+
+ @Nullable
+ @Override
+ public TaskRepository getRepository() {
+ return myRepository;
+ }
+}