Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 204751

Summary: [api] improve API for non-local tasks with locally controlled attributes, e.g. completion, ownership
Product: z_Archived Reporter: Eugene Kuleshov <ekuleshov>
Component: MylynAssignee: Steffen Pingel <steffen.pingel>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: mik.kersten, shawn.minto, steffen.pingel
Version: unspecified   
Target Milestone: 3.0   
Hardware: PC   
OS: All   
Whiteboard:
Attachments:
Description Flags
mylyn/context/zip
none
mylyn/context/zip none

Description Eugene Kuleshov CLA 2007-09-26 20:42:25 EDT
TaskRepositoryManager.isOwnedByUser() has a check if task.isLocal() == true, but WebTask says that it is a local task. In result, any web task completed today (i.e. all tasks from the new query) appear as green because they all considered owned by the local user.

We can't change web task to non-local, because we do need control on marking tasks as read and completed. But it 2.0 release, any local changes are being overwritten (i.e. completed status will be lost on the next sync).
Comment 1 Mik Kersten CLA 2007-10-11 20:36:16 EDT
What's the desired for what TaskRepositoryManager.isOwnedByUser() should return for web tasks?  There is no way to know if they are owned by the user, so I assume that it should be false?
Comment 2 Eugene Kuleshov CLA 2007-10-11 20:41:20 EDT
(In reply to comment #1)
> What's the desired for what TaskRepositoryManager.isOwnedByUser() should return
> for web tasks?  There is no way to know if they are owned by the user, so I
> assume that it should be false?

The web repository connector does map task owner if query configuration provide corresponding mapping. See connector user guide.

Anyways, since there is a connector for local tasks it is rather strange to have task.isLocal() check in TaskRepositoryManager.isOwnedByUser().
Comment 3 Steffen Pingel CLA 2008-04-28 19:02:45 EDT
From bug 222089:

The AbstractTask.isLocal() is used to enable various actions for a task and change the behavor of action, e.g. it determines if a task can be completed in the task list or if it is moved to the Uncategorized folder when deleted from a category etc. There is an unclear overlap with checking if a task extends LocalTask.

Also WebTask class currently returns true for isLocal(). Eugene points out:

"If I remember correctly, isLocal() been set that way to allow to manually change task completion status and other properties not available from the server, as well as execute actions specific to local tasks (read/unread, etc)."

While this makes sense this has undesired side effects in other places where WebTasks should be regarded as remote repository tasks.
Comment 4 Steffen Pingel CLA 2008-04-28 19:03:00 EDT
*** Bug 222089 has been marked as a duplicate of this bug. ***
Comment 5 Mik Kersten CLA 2008-04-29 04:19:48 EDT
Steffen: Removing parent since this is now marked as a duplicate.
Comment 6 Steffen Pingel CLA 2008-05-12 16:48:29 EDT
I have removed the isLocal() method from ITask and changed TaskRepositoryManager.isOwnedByUser()  to do an instanceof check for LocalTask. The synchronization state in the task list does not depend on getLastReadTimeStamp() anymore so there should not be a need for connectors to overwrite isLocal(). Connectors should use menu contributions to add complete/incomplete actions to the context menu.
Comment 7 Mik Kersten CLA 2008-05-12 20:29:05 EDT
Sounds great.
Comment 8 Eugene Kuleshov CLA 2008-05-12 20:35:09 EDT
(In reply to comment #7)
> Sounds great.

What about separately controlling completion, ownership and other attributes for local tasks?
Comment 9 Steffen Pingel CLA 2008-05-12 22:09:28 EDT
Keeping separate local and repository state for certain attributes, e.g. due dates has been proposed on bug 229487 but I am not sure if that is still on the table for 3.0. I have opened bug 231704 for further discussion.

I have moved the "Mark as" menu into a menu extension with the id "org.eclipse.mylyn.tasks.ui.menu.task.mark". An example how to contribute items to the menu can be found in the plugin.xml of tasks.ui.
Comment 10 Steffen Pingel CLA 2008-05-12 22:09:31 EDT
Created attachment 99862 [details]
mylyn/context/zip
Comment 11 Steffen Pingel CLA 2008-05-26 16:49:11 EDT
The current solution for contributing common menu actions, e.g. for marking tasks complete seems slightly cumbersome and potentially duplicates a lot of the XML configuration. There is a risk of ending up with an inconsistent UI if connectors contribute commands in different ways, e.g. with different icons or in different menu locations.
Comment 12 Steffen Pingel CLA 2008-05-26 18:11:19 EDT
Added a method to AbstractRepositoryConnector:

    public boolean hasCapability(Capability capability, TaskRepository taskRepository, ITask task,
			ICapabilityContext context);
			
Supported capabilities:

   public enum Capability { LOCAL_COMPLETION_STATE, REPOSITORY_DUE_DATE };
   
The ICapabilityContext parameter is similar to ISynchronizationContext and allows access to the task data manager in case connectors need to load task data to determine a capability.
Comment 13 Steffen Pingel CLA 2008-05-26 18:11:23 EDT
Created attachment 102066 [details]
mylyn/context/zip
Comment 14 Steffen Pingel CLA 2008-05-30 02:37:55 EDT
After further review and discussion the capability enum has been replaced by a new method:

AbstractRepositoryConnector{

	public boolean hasLocalCompletionState(TaskRepository taskRepository, ITask task);
	
}