Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 146396 - Refactor TaskRepository to be extensible
Summary: Refactor TaskRepository to be extensible
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: unspecified   Edit
Hardware: PC All
: P3 blocker (vote)
Target Milestone: ---   Edit
Assignee: Eugene Kuleshov CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 145123
  Show dependency tree
 
Reported: 2006-06-10 19:51 EDT by Eugene Kuleshov CLA
Modified: 2006-10-22 12:44 EDT (History)
1 user (show)

See Also:


Attachments
Proposed changes (22.69 KB, patch)
2006-06-10 20:14 EDT, Eugene Kuleshov CLA
no flags Details | Diff
mylar/context/zip (4.58 KB, application/octet-stream)
2006-06-10 20:16 EDT, Eugene Kuleshov CLA
no flags Details
Changes for TaskRepository persistence and custom attributes (17.83 KB, patch)
2006-06-14 18:06 EDT, Eugene Kuleshov CLA
no flags Details | Diff
Changes for TaskRepository persistence and custom attributes with test (19.61 KB, patch)
2006-06-14 21:34 EDT, Eugene Kuleshov CLA
no flags Details | Diff
/org.eclipse.mylar.sandbox/icons/obj16/web_repository.gif (587 bytes, image/gif)
2006-06-15 19:50 EDT, Eugene Kuleshov CLA
no flags Details
Changes for TaskRepository persistence and custom attributes with test (22.05 KB, patch)
2006-06-15 20:06 EDT, Eugene Kuleshov CLA
no flags Details | Diff
EditRepositoryWizard fix for editing existing repositories (1.95 KB, patch)
2006-06-16 19:17 EDT, Eugene Kuleshov CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eugene Kuleshov CLA 2006-06-10 19:51:14 EDT
It looks like TaskRepository can't be extended or have some additional settings.
Perhaps concrete implementation of the AbstractRepositorySettingsPage should return instance of the TaskRepository (or its subclass)
Comment 1 Eugene Kuleshov CLA 2006-06-10 20:14:45 EDT
Created attachment 44076 [details]
Proposed changes

Here is the proposed changes
Comment 2 Eugene Kuleshov CLA 2006-06-10 20:16:19 EDT
Created attachment 44077 [details]
mylar/context/zip

Task context for proposed refactorings
Comment 3 Mik Kersten CLA 2006-06-12 11:38:13 EDT
Will look at this after 0.5.3 goes out (scheduled for today).
Comment 4 Eugene Kuleshov CLA 2006-06-14 12:33:49 EDT
Mik, do you have time to adress this any time soon? Thanks
Comment 5 Mik Kersten CLA 2006-06-14 15:00:28 EDT
Changes look good and patch applied.  However, once this is further along we'll need to figure out if we want to promote inheritance for TaskRepository (e.g. making AbstractTaskRepository with an IssueTrackerRepository subtype), or have a final, customizable, and probably immutable class for TaskRepository.

On another note, I worry that the single-sanbox plug-in will be too restrictive for you and others.  I'm thinking of making an org.eclipse.mylar/sandbox folder in CVS that will contain seperate sandbox projects, can have an update site project, etc. 
Comment 6 Eugene Kuleshov CLA 2006-06-14 15:28:01 EDT
(In reply to comment #5)
> Changes look good and patch applied.  However, once this is further along we'll
> need to figure out if we want to promote inheritance for TaskRepository (e.g.
> making AbstractTaskRepository with an IssueTrackerRepository subtype), or have
> a final, customizable, and probably immutable class for TaskRepository.

Iither one is fine with me. Though it could be easier to handle persistence with generic customizable one (e.g. use something like map of properties)

> On another note, I worry that the single-sanbox plug-in will be too restrictive
> for you and others.  I'm thinking of making an org.eclipse.mylar/sandbox folder
> in CVS that will contain seperate sandbox projects, can have an update site
> project, etc. 

Ops. It looks like I've included sanbox stuff into this patch. But it is probably good thing...

Comment 7 Eugene Kuleshov CLA 2006-06-14 16:34:48 EDT
It appears that TaskRepositoryManager.saveRepositories() and readRepositories() can't handle any additional repository properties besides those hardcoded in TaskRepository.
Comment 8 Eugene Kuleshov CLA 2006-06-14 16:37:38 EDT
I wonder if AbstractRepositoryConnector should provide String[] getRepositoryProperties() method that will return names of supported repository properties. Then TaskRepository will have map of those properties and allow RepositoryManager to deal with any custom attributes.
Comment 9 Eugene Kuleshov CLA 2006-06-14 18:06:16 EDT
Created attachment 44464 [details]
Changes for TaskRepository persistence and custom attributes

I've also included changes for sandbox web provider.
Comment 10 Mik Kersten CLA 2006-06-14 20:58:40 EDT
Looks good and I do like this approach more than the subtype.  But before I apply could you please add a unit test for a custom property to TaskRepositoryManagerTest?
Comment 11 Eugene Kuleshov CLA 2006-06-14 21:34:51 EDT
Created attachment 44474 [details]
Changes for TaskRepository persistence and custom attributes with test

I've added a test case, however there are two existing tests are failing.

org.eclipse.mylar.tasklist.tests.TaskRepositoryManagerTest
testRepositoryPersistance(org.eclipse.mylar.tasklist.tests.TaskRepositoryManagerTest)
junit.framework.AssertionFailedError: expected:<1> but was:<2>
	at junit.framework.Assert.fail(Assert.java:47)
	at junit.framework.Assert.failNotEquals(Assert.java:282)
	at junit.framework.Assert.assertEquals(Assert.java:64)
	at junit.framework.Assert.assertEquals(Assert.java:201)
	at junit.framework.Assert.assertEquals(Assert.java:207)
	at org.eclipse.mylar.tasklist.tests.TaskRepositoryManagerTest.testRepositoryPersistance(TaskRepositoryManagerTest.java:103)

testRepositorySyncTimePersistance2(org.eclipse.mylar.tasklist.tests.TaskRepositoryManagerTest)
junit.framework.AssertionFailedError: expected:<Wed Dec 31 19:00:00 EST 1969> but was:<Wed Jun 14 21:30:38 EDT 2006>
	at junit.framework.Assert.fail(Assert.java:47)
	at junit.framework.Assert.failNotEquals(Assert.java:282)
	at junit.framework.Assert.assertEquals(Assert.java:64)
	at junit.framework.Assert.assertEquals(Assert.java:71)
	at org.eclipse.mylar.tasklist.tests.TaskRepositoryManagerTest.testRepositorySyncTimePersistance2(TaskRepositoryManagerTest.java:195)
Comment 12 Mik Kersten CLA 2006-06-15 19:31:02 EDT
I tried to apply the patch, and if I run the suite without the patch all tests pass, with the patch those two tests fail.  I launched a test workspace and this resulted in a fatal error causing previous tasks not to be associated with repositories (message is "Mylar: No repository associated with task").  So there is a bug with the patch.

Btw, icons need to come as attachments since they won't apply as a patch.
Comment 13 Eugene Kuleshov CLA 2006-06-15 19:50:21 EDT
Created attachment 44605 [details]
/org.eclipse.mylar.sandbox/icons/obj16/web_repository.gif
Comment 14 Eugene Kuleshov CLA 2006-06-15 20:06:24 EDT
Created attachment 44607 [details]
Changes for TaskRepository persistence and custom attributes with test

That should fix it.
Comment 15 Mik Kersten CLA 2006-06-16 14:29:49 EDT
Great.  Patch applied.

I'm going to request to move the sandbox into the org.eclipse.mylar/sandbox directory.  I won't know exactly when it happens, but when it does you may need to take any additional patches that haven't been applied, save them locally, and then re-apply them to the new project.  Will keep you posted.
Comment 16 Eugene Kuleshov CLA 2006-06-16 15:07:12 EDT
Thanks Mik.

By the way, I wonder if createTaskFromExistingKey() should be actually in AbstractAddExistingTaskWizard class, so it will at least stay close to its usage...
Comment 17 Mik Kersten CLA 2006-06-16 17:13:32 EDT
I have had this struggle .  The bad thing about it is that it puts functionality that's not UI into the UI.  The good thing about it is that it is where you expect it to be.  Let's keep this in mind if we start doing another refactoring of the connectors.
Comment 18 Eugene Kuleshov CLA 2006-06-16 19:17:06 EDT
Created attachment 44706 [details]
EditRepositoryWizard fix for editing existing repositories

This fix would allow to edit existing repositories. Otherwise custom properties are lost. This probably makes "edit" wizard the same as "new repository" wizard.
Comment 19 Eugene Kuleshov CLA 2006-06-16 19:18:16 EDT
It is hard to let it go. Had to reopen again since saving custom properties didn't work with EditRepositoryWizard (purely an UI issue). Fix attached.
Comment 20 Mik Kersten CLA 2006-06-16 19:30:11 EDT
Yup, they're almost the same, but note that the edit one needs to refactor the task handles in performFinish().  

  MylarTaskListPlugin.getTaskListManager().refactorRepositoryUrl(oldUrl, newUrl);

We could make the single wizard polymorphic to this... btw, this is one of the reasons I prefer to not put too much functionality into the wizards--sometimes it's perfectly fine to have duplication with UI things like wizards, and plugin.xml often forces this.  But it's rarely OK to have that with the core functionality that we end up pushing into the managers and connectors.

Patch applied.
Comment 21 Mik Kersten CLA 2006-07-05 22:39:12 EDT
Anything left to do here?
Comment 22 Eugene Kuleshov CLA 2006-07-06 11:20:49 EDT
Not sure if it belong to this report. Here is the list of possible refactorings:

-- AbstractRepositoryConnector.openEditQueryDialog() method should be replaced with getEditQueryWizard()
-- WebTaskNewPage and WebTaskWizard should be made generic and reused by Jira plugin
-- review WebTask, WebQuery, WebQueryHit and WebTaskExternalizer to see what can be generalized
-- review WebQueryEditWizard, WebQueryWizard, WebQueryWizardPage, WebTaskNewPage, WebTaskWizard to see what can be generalized
Comment 23 Steffen Pingel CLA 2006-07-06 18:48:53 EDT
(In reply to comment #22)
> -- AbstractRepositoryConnector.openEditQueryDialog() method should be replaced
> with getEditQueryWizard()

I have opened bug 149921 to discuss changes to the query wizard api.
Comment 24 Eugene Kuleshov CLA 2006-10-22 12:43:04 EDT
Mik, I guess we can close this now.
Comment 25 Eugene Kuleshov CLA 2006-10-22 12:44:01 EDT
Closing as fixed, since there is no work left on this.