Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2007-02-09 23:06:01 -0500
committermkersten2007-02-09 23:06:01 -0500
commit3ee272a24ffae8d7f061a43228926c30551af8ff (patch)
treecaeb9ad6f1896660f772ae4496832143bc36fef9 /org.eclipse.mylyn.tasks.core
parentbd1f40843527e1fd3132384836706208e43ee143 (diff)
downloadorg.eclipse.mylyn.tasks-3ee272a24ffae8d7f061a43228926c30551af8ff.tar.gz
org.eclipse.mylyn.tasks-3ee272a24ffae8d7f061a43228926c30551af8ff.tar.xz
org.eclipse.mylyn.tasks-3ee272a24ffae8d7f061a43228926c30551af8ff.zip
NEW - bug 149624: [api] AbstractRepositoryTask repositoryUrl and task id should not be derived from handleIdentifier
https://bugs.eclipse.org/bugs/show_bug.cgi?id=149624
Diffstat (limited to 'org.eclipse.mylyn.tasks.core')
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/RepositoryTaskHandleUtil.java55
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskDataManager.java76
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/WebTask.java26
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/.AbstractRepositoryTask.java146
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractQueryHit.java3
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryTask.java146
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/DateRangeActivityDelegate.java14
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/DelegatingTaskExternalizer.java8
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITask.java4
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITaskListElement.java2
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/Task.java22
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskList.java41
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepositoryManager.java3
13 files changed, 300 insertions, 246 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/RepositoryTaskHandleUtil.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/RepositoryTaskHandleUtil.java
new file mode 100644
index 000000000..61cfad9a4
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/RepositoryTaskHandleUtil.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2004 - 2006 University Of British Columbia 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:
+ * University Of British Columbia - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylar.internal.tasks.core;
+
+
+
+/**
+ * @author Mik Kersten
+ */
+public class RepositoryTaskHandleUtil {
+
+ public static final String HANDLE_DELIM = "-";
+
+ private static final String MISSING_REPOSITORY = "norepository";
+
+ public static String getHandle(String repositoryUrl, String taskId) {
+ if (repositoryUrl == null) {
+ return MISSING_REPOSITORY + HANDLE_DELIM + taskId;
+ } else if (taskId.contains(HANDLE_DELIM)) {
+ throw new RuntimeException("invalid handle for task, can not contain: " + HANDLE_DELIM + ", was: "
+ + taskId);
+ } else {
+ return repositoryUrl + HANDLE_DELIM + taskId;
+ }
+ }
+
+ public static String getRepositoryUrl(String taskHandle) {
+ int index = taskHandle.lastIndexOf(RepositoryTaskHandleUtil.HANDLE_DELIM);
+ String url = null;
+ if (index != -1) {
+ url = taskHandle.substring(0, index);
+ }
+ return url;
+ }
+
+ // @Deprecated
+ public static String getTaskId(String taskHandle) {
+ int index = taskHandle.lastIndexOf(HANDLE_DELIM);
+ if (index != -1) {
+ String id = taskHandle.substring(index + 1);
+ return id;
+ }
+ return null;
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskDataManager.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskDataManager.java
index 40297b59b..cb3885c2f 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskDataManager.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/TaskDataManager.java
@@ -27,7 +27,6 @@ import java.util.Set;
import org.eclipse.mylar.core.MylarStatusHandler;
import org.eclipse.mylar.tasks.core.AbstractAttributeFactory;
import org.eclipse.mylar.tasks.core.AbstractRepositoryConnector;
-import org.eclipse.mylar.tasks.core.AbstractRepositoryTask;
import org.eclipse.mylar.tasks.core.RepositoryTaskAttribute;
import org.eclipse.mylar.tasks.core.RepositoryTaskData;
import org.eclipse.mylar.tasks.core.TaskRepositoryManager;
@@ -100,16 +99,16 @@ public class TaskDataManager {
* Add a RepositoryTaskData to the offline reports file. Previously stored
* taskData is held and can be retrieved via getOldTaskData()
*/
- public void push(RepositoryTaskData newEntry) {
- String handle = AbstractRepositoryTask.getHandle(newEntry.getRepositoryUrl(), newEntry.getId());
- RepositoryTaskData moveToOld = getNewDataMap().get(handle);
+ public void push(String taskHandle, RepositoryTaskData newEntry) {
+// String handle = AbstractRepositoryTask.getHandle(newEntry.getRepositoryUrl(), newEntry.getId());
+ RepositoryTaskData moveToOld = getNewDataMap().get(taskHandle);
synchronized (file) {
if (moveToOld != null) {
- getOldDataMap().put(handle, moveToOld);
+ getOldDataMap().put(taskHandle, moveToOld);
} else {
- getOldDataMap().put(handle, newEntry);
+ getOldDataMap().put(taskHandle, newEntry);
}
- getNewDataMap().put(handle, newEntry);
+ getNewDataMap().put(taskHandle, newEntry);
}
}
@@ -118,8 +117,8 @@ public class TaskDataManager {
*
* @param newData
*/
- public void replace(RepositoryTaskData newData) {
- String handle = AbstractRepositoryTask.getHandle(newData.getRepositoryUrl(), newData.getId());
+ public void replace(String handle, RepositoryTaskData newData) {
+// String handle = AbstractRepositoryTask.getHandle(newData.getRepositoryUrl(), newData.getId());
synchronized (file) {
getNewDataMap().put(handle, newData);
}
@@ -128,8 +127,8 @@ public class TaskDataManager {
/**
* Add an unsubmitted RepositoryTaskData to the offline reports file.
*/
- public void putUnsubmitted(RepositoryTaskData newEntry) {
- String handle = AbstractRepositoryTask.getHandle(newEntry.getRepositoryUrl(), newEntry.getId());
+ public void putUnsubmitted(String handle, RepositoryTaskData newEntry) {
+// String handle = AbstractRepositoryTask.getHandle(newEntry.getRepositoryUrl(), newEntry.getId());
synchronized (file) {
getUnsubmittedTaskData().put(handle, newEntry);
}
@@ -212,13 +211,13 @@ public class TaskDataManager {
}
- /**
- * @return editable copy of task data with any edits applied
- */
- public RepositoryTaskData getEditableCopy(String repositoryUrl, String taskId) {
- String handle = AbstractRepositoryTask.getHandle(repositoryUrl, taskId);
- return getEditableCopy(handle);
- }
+// /**
+// * @return editable copy of task data with any edits applied
+// */
+// public RepositoryTaskData getEditableCopy(String handle) {
+// String handle = AbstractRepositoryTask.getHandle(repositoryUrl, taskId);
+// return getEditableCopy(handle);
+// }
public void saveEdits(String handle, Set<RepositoryTaskAttribute> attributes) {
synchronized (file) {
@@ -263,15 +262,15 @@ public class TaskDataManager {
return data;
}
- /**
- * Returns the most recent copy of the task data.
- *
- * @return offline task data, null if no data found
- */
- public RepositoryTaskData getRepsitoryTaskData(String repositoryUrl, String taskId) {
- String handle = AbstractRepositoryTask.getHandle(repositoryUrl, taskId);
- return getRepositoryTaskData(handle);
- }
+// /**
+// * Returns the most recent copy of the task data.
+// *
+// * @return offline task data, null if no data found
+// */
+// public RepositoryTaskData getRepsitoryTaskData(String repositoryUrl, String taskId) {
+// String handle = AbstractRepositoryTask.getHandle(repositoryUrl, taskId);
+// return getRepositoryTaskData(handle);
+// }
/**
* Returns the old copy if exists, null otherwise.
@@ -280,13 +279,13 @@ public class TaskDataManager {
return getOldDataMap().get(handle);
}
- /**
- * Returns the old copy if exists, null otherwise.
- */
- public RepositoryTaskData getOldRepositoryTaskData(String repositoryUrl, String taskId) {
- String handle = AbstractRepositoryTask.getHandle(repositoryUrl, taskId);
- return getOldRepositoryTaskData(handle);
- }
+// /**
+// * Returns the old copy if exists, null otherwise.
+// */
+// public RepositoryTaskData getOldRepositoryTaskData(String repositoryUrl, String taskId) {
+// String handle = AbstractRepositoryTask.getHandle(repositoryUrl, taskId);
+// return getOldRepositoryTaskData(handle);
+// }
/**
* Remove some bugs from the offline reports list
@@ -294,17 +293,16 @@ public class TaskDataManager {
* @param indicesToRemove
* An array of the indicies of the bugs to be removed
*/
- public void remove(List<RepositoryTaskData> dataToRemove) {
+ public void remove(List<String> handlesToRemove) {
synchronized (file) {
- for (RepositoryTaskData repositoryTaskData : dataToRemove) {
- remove(repositoryTaskData);
+ for (String handle: handlesToRemove) {
+ remove(handle);
}
}
}
- public void remove(RepositoryTaskData taskData) {
+ public void remove(String handle) {
synchronized (file) {
- String handle = AbstractRepositoryTask.getHandle(taskData.getRepositoryUrl(), taskData.getId());
getNewDataMap().remove(handle);
getOldDataMap().remove(handle);
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/WebTask.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/WebTask.java
index b5657d1af..72906b47d 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/WebTask.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/WebTask.java
@@ -25,26 +25,26 @@ public class WebTask extends AbstractRepositoryTask {
private static final String UNKNOWN_OWNER = "<unknown>";
- private final String id;
+// private final String id;
private final String taskPrefix;
- private final String repositoryUrl;
+// private final String repositoryUrl;
private final String repsitoryType;
public WebTask(String id, String label, String taskPrefix, String repositoryUrl, String repsitoryType) {
- super(taskPrefix + id, label, false);
- this.id = id;
+ super(repositoryUrl, id, label, false);
+// this.id = id;
this.taskPrefix = taskPrefix;
this.repositoryUrl = repositoryUrl;
this.repsitoryType = repsitoryType;
- setUrl(taskPrefix + id);
+ setTaskUrl(taskPrefix + id);
}
- public String getId() {
- return this.id;
- }
+// public String getId() {
+// return this.id;
+// }
public String getTaskPrefix() {
return this.taskPrefix;
@@ -55,13 +55,13 @@ public class WebTask extends AbstractRepositoryTask {
return repsitoryType;
}
- @Override
- public String getRepositoryUrl() {
- return repositoryUrl;
- }
+// @Override
+// public String getRepositoryUrl() {
+// return repositoryUrl;
+// }
@Override
- public String getIdLabel() {
+ public String getIdentifyingLabel() {
return null;
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/.AbstractRepositoryTask.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/.AbstractRepositoryTask.java
index ede3bdf5b..e13b1598b 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/.AbstractRepositoryTask.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/.AbstractRepositoryTask.java
@@ -11,10 +11,9 @@
package org.eclipse.mylar.tasks.core;
-import java.util.Date;
-
import org.eclipse.core.runtime.IStatus;
import org.eclipse.mylar.core.net.HtmlStreamTokenizer;
+import org.eclipse.mylar.internal.tasks.core.RepositoryTaskHandleUtil;
/**
* Virtual proxy for a repository task.
@@ -24,13 +23,13 @@ import org.eclipse.mylar.core.net.HtmlStreamTokenizer;
*/
public abstract class AbstractRepositoryTask extends Task {
- private static final String CONTEXT_HANDLE_DELIM = "-";
-
- private static final String MISSING_REPOSITORY_HANDLE = "norepository" + CONTEXT_HANDLE_DELIM;
-
/** The last time this task's bug report was in a synchronized (read?) state. */
protected String lastSynchronizedDateStamp;
+ protected String repositoryUrl;
+
+ protected String taskId;
+
protected transient RepositoryTaskData taskData;
protected boolean currentlySynchronizing;
@@ -49,14 +48,21 @@ public abstract class AbstractRepositoryTask extends Task {
protected RepositoryTaskSyncState syncState = RepositoryTaskSyncState.SYNCHRONIZED;
- public static final String HANDLE_DELIM = "-";
-
protected IStatus status = null;
-
- public AbstractRepositoryTask(String handle, String label, boolean newTask) {
- super(handle, label, newTask);
+
+ public AbstractRepositoryTask(String repositoryUrl, String taskId, String label, boolean newTask) {
+// super(getHandle(repositoryUrl, taskId), label, newTask);
+ super(null, label, newTask);
+ this.repositoryUrl = repositoryUrl;
+ this.taskId = taskId;
+ }
+
+ @Override
+ public final String getHandleIdentifier() {
+ return RepositoryTaskHandleUtil.getHandle(repositoryUrl, taskId);
}
+
@Override
public abstract String getRepositoryKind();
@@ -80,22 +86,21 @@ public abstract class AbstractRepositoryTask extends Task {
return syncState;
}
- public String getRepositoryUrl() {
- return AbstractRepositoryTask.getRepositoryUrl(getHandleIdentifier());
- }
-
+ /**
+ * TODO: remove
+ */
@Override
- public boolean isLocal() {
+ public final boolean isLocal() {
return false;
}
- public static long getLastRefreshTimeInMinutes(Date lastRefresh) {
- Date timeNow = new Date();
- if (lastRefresh == null)
- lastRefresh = new Date();
- long timeDifference = (timeNow.getTime() - lastRefresh.getTime()) / 60000;
- return timeDifference;
- }
+// public static long getLastRefreshTimeInMinutes(Date lastRefresh) {
+// Date timeNow = new Date();
+// if (lastRefresh == null)
+// lastRefresh = new Date();
+// long timeDifference = (timeNow.getTime() - lastRefresh.getTime()) / 60000;
+// return timeDifference;
+// }
public boolean isSynchronizing() {
return currentlySynchronizing;
@@ -106,44 +111,12 @@ public abstract class AbstractRepositoryTask extends Task {
}
/**
- * Human readable identifier for this task. Override if different than ID, can return
- * null if no such label exists.
+ * Human readable identifier for this task. Override if different than ID,
+ * can return null if no such label exists.
*/
- public String getIdLabel() {
- return getTaskId(handleIdentifier);
- }
-
- public static String getTaskId(String taskHandle) {
- int index = taskHandle.lastIndexOf(AbstractRepositoryTask.HANDLE_DELIM);
- if (index != -1) {
- String id = taskHandle.substring(index + 1);
- return id;
- }
- return null;
- }
-
- public static String getRepositoryUrl(String taskHandle) {
- int index = taskHandle.lastIndexOf(AbstractRepositoryTask.HANDLE_DELIM);
- String url = null;
- if (index != -1) {
- url = taskHandle.substring(0, index);
- }
- return url;
- }
-
- public static String getHandle(String repositoryUrl, String taskId) {
- if (repositoryUrl == null) {
- return MISSING_REPOSITORY_HANDLE + taskId;
- } else if (taskId.contains(CONTEXT_HANDLE_DELIM)) {
- throw new RuntimeException("invalid handle for task, can not contain: " + CONTEXT_HANDLE_DELIM + ", was: "
- + taskId);
- } else {
- return repositoryUrl + CONTEXT_HANDLE_DELIM + taskId;
- }
- }
-
- public static String getHandle(String repositoryUrl, int taskId) {
- return AbstractRepositoryTask.getHandle(repositoryUrl, "" + taskId);
+ public String getIdentifyingLabel() {
+ return taskId;
+// return RepositoryTaskHandleUtil.getTaskId(handleIdentifier);
}
public boolean isDirty() {
@@ -181,31 +154,46 @@ public abstract class AbstractRepositoryTask extends Task {
return "<unknown>";
}
}
-
+
public IStatus getStatus() {
return status;
}
-
+
public void setStatus(IStatus status) {
this.status = status;
}
+
+// /**
+// * Need to update URL since it is derived from handle identifier.
+// */
+// @Override
+// public void setHandleIdentifier(String newHandleIdentifier) {
+// String oldHandleIdentifier = getHandleIdentifier();
+// String url = getUrl();
+// if (oldHandleIdentifier != null && url != null) {
+// String oldRepositoryUrl = AbstractRepositoryTask.getRepositoryUrl(oldHandleIdentifier);
+// String newRepositoryUrl = AbstractRepositoryTask.getRepositoryUrl(newHandleIdentifier);
+//
+// if (url.startsWith(oldRepositoryUrl)) {
+// setUrl(newRepositoryUrl + url.substring(oldRepositoryUrl.length()));
+// }
+// }
+// super.setHandleIdentifier(newHandleIdentifier);
+// }
+
- /**
- * Need to update URL since it is derived from handle identifier.
- */
- @Override
- public void setHandleIdentifier(String newHandleIdentifier) {
- String oldHandleIdentifier = getHandleIdentifier();
- String url = getUrl();
- if (oldHandleIdentifier != null && url != null) {
- String oldRepositoryUrl = AbstractRepositoryTask.getRepositoryUrl(oldHandleIdentifier);
- String newRepositoryUrl = AbstractRepositoryTask.getRepositoryUrl(newHandleIdentifier);
-
- if (url.startsWith(oldRepositoryUrl)) {
- setUrl(newRepositoryUrl + url.substring(oldRepositoryUrl.length()));
- }
- }
- super.setHandleIdentifier(newHandleIdentifier);
+ public final String getTaskId() {
+ return taskId;
}
-
+
+ public final String getRepositoryUrl() {
+ // return
+ // AbstractRepositoryTask.getRepositoryUrl(getHandleIdentifier());
+ return repositoryUrl;
+ }
+
+ public final void setRepositoryUrl(String repositoryUrl) {
+ this.repositoryUrl = repositoryUrl;
+ }
+
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractQueryHit.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractQueryHit.java
index 63398eb6a..d4c93d5f1 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractQueryHit.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractQueryHit.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.mylar.tasks.core;
+import org.eclipse.mylar.internal.tasks.core.RepositoryTaskHandleUtil;
import org.eclipse.mylar.tasks.core.Task.PriorityLevel;
@@ -112,7 +113,7 @@ public abstract class AbstractQueryHit implements ITaskListElement {
if (task != null) {
return task.getHandleIdentifier();
}
- return AbstractRepositoryTask.getHandle(repositoryUrl, id);
+ return RepositoryTaskHandleUtil.getHandle(repositoryUrl, id);
}
/**
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryTask.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryTask.java
index ede3bdf5b..e13b1598b 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryTask.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryTask.java
@@ -11,10 +11,9 @@
package org.eclipse.mylar.tasks.core;
-import java.util.Date;
-
import org.eclipse.core.runtime.IStatus;
import org.eclipse.mylar.core.net.HtmlStreamTokenizer;
+import org.eclipse.mylar.internal.tasks.core.RepositoryTaskHandleUtil;
/**
* Virtual proxy for a repository task.
@@ -24,13 +23,13 @@ import org.eclipse.mylar.core.net.HtmlStreamTokenizer;
*/
public abstract class AbstractRepositoryTask extends Task {
- private static final String CONTEXT_HANDLE_DELIM = "-";
-
- private static final String MISSING_REPOSITORY_HANDLE = "norepository" + CONTEXT_HANDLE_DELIM;
-
/** The last time this task's bug report was in a synchronized (read?) state. */
protected String lastSynchronizedDateStamp;
+ protected String repositoryUrl;
+
+ protected String taskId;
+
protected transient RepositoryTaskData taskData;
protected boolean currentlySynchronizing;
@@ -49,14 +48,21 @@ public abstract class AbstractRepositoryTask extends Task {
protected RepositoryTaskSyncState syncState = RepositoryTaskSyncState.SYNCHRONIZED;
- public static final String HANDLE_DELIM = "-";
-
protected IStatus status = null;
-
- public AbstractRepositoryTask(String handle, String label, boolean newTask) {
- super(handle, label, newTask);
+
+ public AbstractRepositoryTask(String repositoryUrl, String taskId, String label, boolean newTask) {
+// super(getHandle(repositoryUrl, taskId), label, newTask);
+ super(null, label, newTask);
+ this.repositoryUrl = repositoryUrl;
+ this.taskId = taskId;
+ }
+
+ @Override
+ public final String getHandleIdentifier() {
+ return RepositoryTaskHandleUtil.getHandle(repositoryUrl, taskId);
}
+
@Override
public abstract String getRepositoryKind();
@@ -80,22 +86,21 @@ public abstract class AbstractRepositoryTask extends Task {
return syncState;
}
- public String getRepositoryUrl() {
- return AbstractRepositoryTask.getRepositoryUrl(getHandleIdentifier());
- }
-
+ /**
+ * TODO: remove
+ */
@Override
- public boolean isLocal() {
+ public final boolean isLocal() {
return false;
}
- public static long getLastRefreshTimeInMinutes(Date lastRefresh) {
- Date timeNow = new Date();
- if (lastRefresh == null)
- lastRefresh = new Date();
- long timeDifference = (timeNow.getTime() - lastRefresh.getTime()) / 60000;
- return timeDifference;
- }
+// public static long getLastRefreshTimeInMinutes(Date lastRefresh) {
+// Date timeNow = new Date();
+// if (lastRefresh == null)
+// lastRefresh = new Date();
+// long timeDifference = (timeNow.getTime() - lastRefresh.getTime()) / 60000;
+// return timeDifference;
+// }
public boolean isSynchronizing() {
return currentlySynchronizing;
@@ -106,44 +111,12 @@ public abstract class AbstractRepositoryTask extends Task {
}
/**
- * Human readable identifier for this task. Override if different than ID, can return
- * null if no such label exists.
+ * Human readable identifier for this task. Override if different than ID,
+ * can return null if no such label exists.
*/
- public String getIdLabel() {
- return getTaskId(handleIdentifier);
- }
-
- public static String getTaskId(String taskHandle) {
- int index = taskHandle.lastIndexOf(AbstractRepositoryTask.HANDLE_DELIM);
- if (index != -1) {
- String id = taskHandle.substring(index + 1);
- return id;
- }
- return null;
- }
-
- public static String getRepositoryUrl(String taskHandle) {
- int index = taskHandle.lastIndexOf(AbstractRepositoryTask.HANDLE_DELIM);
- String url = null;
- if (index != -1) {
- url = taskHandle.substring(0, index);
- }
- return url;
- }
-
- public static String getHandle(String repositoryUrl, String taskId) {
- if (repositoryUrl == null) {
- return MISSING_REPOSITORY_HANDLE + taskId;
- } else if (taskId.contains(CONTEXT_HANDLE_DELIM)) {
- throw new RuntimeException("invalid handle for task, can not contain: " + CONTEXT_HANDLE_DELIM + ", was: "
- + taskId);
- } else {
- return repositoryUrl + CONTEXT_HANDLE_DELIM + taskId;
- }
- }
-
- public static String getHandle(String repositoryUrl, int taskId) {
- return AbstractRepositoryTask.getHandle(repositoryUrl, "" + taskId);
+ public String getIdentifyingLabel() {
+ return taskId;
+// return RepositoryTaskHandleUtil.getTaskId(handleIdentifier);
}
public boolean isDirty() {
@@ -181,31 +154,46 @@ public abstract class AbstractRepositoryTask extends Task {
return "<unknown>";
}
}
-
+
public IStatus getStatus() {
return status;
}
-
+
public void setStatus(IStatus status) {
this.status = status;
}
+
+// /**
+// * Need to update URL since it is derived from handle identifier.
+// */
+// @Override
+// public void setHandleIdentifier(String newHandleIdentifier) {
+// String oldHandleIdentifier = getHandleIdentifier();
+// String url = getUrl();
+// if (oldHandleIdentifier != null && url != null) {
+// String oldRepositoryUrl = AbstractRepositoryTask.getRepositoryUrl(oldHandleIdentifier);
+// String newRepositoryUrl = AbstractRepositoryTask.getRepositoryUrl(newHandleIdentifier);
+//
+// if (url.startsWith(oldRepositoryUrl)) {
+// setUrl(newRepositoryUrl + url.substring(oldRepositoryUrl.length()));
+// }
+// }
+// super.setHandleIdentifier(newHandleIdentifier);
+// }
+
- /**
- * Need to update URL since it is derived from handle identifier.
- */
- @Override
- public void setHandleIdentifier(String newHandleIdentifier) {
- String oldHandleIdentifier = getHandleIdentifier();
- String url = getUrl();
- if (oldHandleIdentifier != null && url != null) {
- String oldRepositoryUrl = AbstractRepositoryTask.getRepositoryUrl(oldHandleIdentifier);
- String newRepositoryUrl = AbstractRepositoryTask.getRepositoryUrl(newHandleIdentifier);
-
- if (url.startsWith(oldRepositoryUrl)) {
- setUrl(newRepositoryUrl + url.substring(oldRepositoryUrl.length()));
- }
- }
- super.setHandleIdentifier(newHandleIdentifier);
+ public final String getTaskId() {
+ return taskId;
}
-
+
+ public final String getRepositoryUrl() {
+ // return
+ // AbstractRepositoryTask.getRepositoryUrl(getHandleIdentifier());
+ return repositoryUrl;
+ }
+
+ public final void setRepositoryUrl(String repositoryUrl) {
+ this.repositoryUrl = repositoryUrl;
+ }
+
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/DateRangeActivityDelegate.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/DateRangeActivityDelegate.java
index 57658336c..6297dac0a 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/DateRangeActivityDelegate.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/DateRangeActivityDelegate.java
@@ -161,8 +161,8 @@ public class DateRangeActivityDelegate implements ITask {
return task.getScheduledForDate();
}
- public String getUrl() {
- return task.getUrl();
+ public String getTaskUrl() {
+ return task.getTaskUrl();
}
public boolean hasBeenReminded() {
@@ -213,9 +213,9 @@ public class DateRangeActivityDelegate implements ITask {
task.setEstimatedTimeHours(estimated);
}
- public void setHandleIdentifier(String id) {
- task.setHandleIdentifier(id);
- }
+// public void setHandleIdentifier(String id) {
+// task.setHandleIdentifier(id);
+// }
public void setKind(String kind) {
task.setKind(kind);
@@ -241,8 +241,8 @@ public class DateRangeActivityDelegate implements ITask {
task.setScheduledForDate(date);
}
- public void setUrl(String url) {
- task.setUrl(url);
+ public void setTaskUrl(String url) {
+ task.setTaskUrl(url);
}
public int compareTo(ITaskListElement taskListElement) {
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/DelegatingTaskExternalizer.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/DelegatingTaskExternalizer.java
index c71a9d8fe..12711a508 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/DelegatingTaskExternalizer.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/DelegatingTaskExternalizer.java
@@ -188,8 +188,8 @@ public class DelegatingTaskExternalizer implements ITaskListExternalizer {
node.setAttribute(KEY_ACTIVE, VAL_FALSE);
}
- if (task.getUrl() != null) {
- node.setAttribute(KEY_ISSUEURL, task.getUrl());
+ if (task.getTaskUrl() != null) {
+ node.setAttribute(KEY_ISSUEURL, task.getTaskUrl());
}
node.setAttribute(KEY_NOTES, task.getNotes());
node.setAttribute(KEY_TIME_ESTIMATED, "" + task.getEstimateTimeHours());
@@ -357,9 +357,9 @@ public class DelegatingTaskExternalizer implements ITaskListExternalizer {
task.setActive(false);
}
if (element.hasAttribute(KEY_ISSUEURL)) {
- task.setUrl(element.getAttribute(KEY_ISSUEURL));
+ task.setTaskUrl(element.getAttribute(KEY_ISSUEURL));
} else {
- task.setUrl("");
+ task.setTaskUrl("");
}
if (element.hasAttribute(KEY_NOTES)) {
task.setNotes(element.getAttribute(KEY_NOTES));
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 35199623e..b2c9fc776 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
@@ -41,9 +41,9 @@ public interface ITask extends ITaskListElement {
public abstract boolean hasValidUrl();
- public abstract void setUrl(String url);
+ public abstract void setTaskUrl(String url);
- public abstract String getUrl();
+ public abstract String getTaskUrl();
public abstract String getNotes();
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITaskListElement.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITaskListElement.java
index 4b19ec2e5..48576efe8 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITaskListElement.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITaskListElement.java
@@ -22,7 +22,7 @@ public interface ITaskListElement extends Comparable<ITaskListElement> {
public abstract String getHandleIdentifier();
- public abstract void setHandleIdentifier(String id);
+// public abstract void setHandleIdentifier(String id);
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/Task.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/Task.java
index 78ca2e846..5d3aff81f 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/Task.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/Task.java
@@ -99,10 +99,10 @@ public class Task implements ITask {
}
}
+ private String handleIdentifier = "-1";
+
private boolean active = false;
- protected String handleIdentifier = "-1";
-
private boolean category = false;
private boolean hasReminded = false;
@@ -117,7 +117,7 @@ public class Task implements ITask {
private boolean completed;
- private String url = "";
+ private String taskUrl = "";
private AbstractTaskContainer parentCategory = null;
@@ -155,9 +155,9 @@ public class Task implements ITask {
return handleIdentifier;
}
- public void setHandleIdentifier(String id) {
- this.handleIdentifier = id;
- }
+// public void setHandleIdentifier(String id) {
+// this.handleIdentifier = id;
+// }
public ITask getParent() {
return parent;
@@ -221,12 +221,12 @@ public class Task implements ITask {
this.priority = priority;
}
- public void setUrl(String url) {
- this.url = url;
+ public void setTaskUrl(String url) {
+ this.taskUrl = url;
}
- public String getUrl() {
- return url;
+ public String getTaskUrl() {
+ return taskUrl;
}
public String getNotes() {
@@ -341,7 +341,7 @@ public class Task implements ITask {
}
public boolean hasValidUrl() {
- String taskUrl = getUrl();
+ String taskUrl = getTaskUrl();
if (taskUrl != null && !taskUrl.equals("") && !taskUrl.equals("http://") && !taskUrl.equals("https://")) {
try {
new URL(taskUrl);
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskList.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskList.java
index eb48efe56..5399cc749 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskList.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskList.java
@@ -23,6 +23,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CopyOnWriteArraySet;
import org.eclipse.mylar.core.MylarStatusHandler;
+import org.eclipse.mylar.internal.tasks.core.RepositoryTaskHandleUtil;
/**
* TODO: some asymetry left between query containers and other task containers
@@ -91,26 +92,33 @@ public class TaskList {
}
}
- public void refactorRepositoryUrl(Object oldUrl, String newUrl) {
+ public void refactorRepositoryUrl(String oldRepositoryUrl, String newRepositoryUrl) {
+ // TODO: update mappings in offline task data, will currently lose them
for (ITask task : tasks.values()) {
if (task instanceof AbstractRepositoryTask) {
AbstractRepositoryTask repositoryTask = (AbstractRepositoryTask) task;
- if (oldUrl.equals(AbstractRepositoryTask.getRepositoryUrl(repositoryTask.getHandleIdentifier()))) {
+ if (oldRepositoryUrl.equals(RepositoryTaskHandleUtil.getRepositoryUrl(repositoryTask.getHandleIdentifier()))) {
tasks.remove(repositoryTask.getHandleIdentifier());
- String id = AbstractRepositoryTask.getTaskId(repositoryTask.getHandleIdentifier());
- String newHandle = AbstractRepositoryTask.getHandle(newUrl, id);
- repositoryTask.setHandleIdentifier(newHandle);
- tasks.put(newHandle, repositoryTask);
+// String id = AbstractRepositoryTask.getTaskId(repositoryTask.getHandleIdentifier());
+// String newHandle = AbstractRepositoryTask.getHandle(newUrl, id);
+// repositoryTask.setHandleIdentifier(newHandle);
+ repositoryTask.setRepositoryUrl(newRepositoryUrl);
+ tasks.put(repositoryTask.getHandleIdentifier(), repositoryTask);
+
+ String taskUrl = repositoryTask.getTaskUrl();
+ if (taskUrl.startsWith(oldRepositoryUrl)) {
+ repositoryTask.setTaskUrl(newRepositoryUrl + taskUrl.substring(oldRepositoryUrl.length()));
+ }
}
}
}
for (AbstractRepositoryQuery query : queries.values()) {
- if (query.getRepositoryUrl().equals(oldUrl)) {
- query.setRepositoryUrl(newUrl);
+ if (query.getRepositoryUrl().equals(oldRepositoryUrl)) {
+ query.setRepositoryUrl(newRepositoryUrl);
for (AbstractQueryHit hit : query.getHits()) {
queryHits.remove(hit.getHandleIdentifier());
- hit.setRepositoryUrl(newUrl);
+ hit.setRepositoryUrl(newRepositoryUrl);
queryHits.put(hit.getHandleIdentifier(), hit);
}
for (ITaskListChangeListener listener : changeListeners) {
@@ -374,6 +382,8 @@ public class TaskList {
}
/**
+ * TODO: consider removing, if everything becomes a repository task
+ *
* @return null if no such task.
*/
public ITask getTask(String handleIdentifier) {
@@ -384,6 +394,19 @@ public class TaskList {
}
}
+ /**
+ * @since 2.0
+ */
+ public AbstractRepositoryTask getTask(String repositoryUrl, String taskId) {
+ String handle = RepositoryTaskHandleUtil.getHandle(repositoryUrl, taskId);
+ ITask task = getTask(handle);
+ if (task instanceof AbstractRepositoryTask) {
+ return (AbstractRepositoryTask)task;
+ } else {
+ return null;
+ }
+ }
+
public AbstractTaskContainer getContainerForHandle(String categoryHandle) {
for (AbstractTaskContainer cat : categories.values()) {
if (cat instanceof AbstractTaskContainer) {
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepositoryManager.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepositoryManager.java
index 5a5ff151e..033b93c52 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepositoryManager.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskRepositoryManager.java
@@ -27,6 +27,7 @@ import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.mylar.core.MylarStatusHandler;
+import org.eclipse.mylar.internal.tasks.core.RepositoryTaskHandleUtil;
import org.eclipse.mylar.internal.tasks.core.TaskRepositoriesExternalizer;
/**
@@ -175,7 +176,7 @@ public class TaskRepositoryManager {
if (activeTasks.size() == 1) {
ITask activeTask = activeTasks.get(0);
if (activeTask instanceof AbstractRepositoryTask) {
- String repositoryUrl = AbstractRepositoryTask.getRepositoryUrl(activeTask.getHandleIdentifier());
+ String repositoryUrl = RepositoryTaskHandleUtil.getRepositoryUrl(activeTask.getHandleIdentifier());
for (TaskRepository repository : getRepositories(repositoryKind)) {
if (repository.getUrl().equals(repositoryUrl)) {
return repository;

Back to the top