Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 209402 - [api] add cloneTaskData() method to TaskDataHandler
Summary: [api] add cloneTaskData() method to TaskDataHandler
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 2.2   Edit
Assignee: Frank Becker CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 169426
  Show dependency tree
 
Reported: 2007-11-09 20:19 EST by Steffen Pingel CLA
Modified: 2007-11-15 16:10 EST (History)
2 users (show)

See Also:


Attachments
implementation of cloneTaskData (2.12 KB, patch)
2007-11-11 16:13 EST, Frank Becker CLA
no flags Details | Diff
mylyn/context/zip (2.54 KB, application/octet-stream)
2007-11-11 16:13 EST, Frank Becker CLA
no flags Details
test implementation (19.94 KB, patch)
2007-11-12 18:04 EST, Frank Becker CLA
no flags Details | Diff
mylyn/context/zip (16.55 KB, application/octet-stream)
2007-11-12 18:04 EST, Frank Becker CLA
no flags Details
Patch with jUnit Test (11.74 KB, patch)
2007-11-14 17:34 EST, Frank Becker CLA
no flags Details | Diff
mylyn/context/zip (17.92 KB, application/octet-stream)
2007-11-14 17:34 EST, Frank Becker CLA
no flags Details
mylyn/context/zip (46.16 KB, application/octet-stream)
2007-11-14 21:01 EST, Steffen Pingel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Steffen Pingel CLA 2007-11-09 20:19:38 EST
From bug 169426 comment 25:

For cloning of task data a new method should be added to AbstractTaskDataHandler. A default implementation could clone the common attributes: summary, description and possibly iterate over editable attributes of the source task data and the new task data. The latter is probably only feasible if both task data objects are associated with the same repository. Connectors can overwrite that method and provide a more specific implementation if needed.
Comment 1 Frank Becker CLA 2007-11-11 16:13:33 EST
Created attachment 82625 [details]
implementation of cloneTaskData
Comment 2 Frank Becker CLA 2007-11-11 16:13:35 EST
Created attachment 82626 [details]
mylyn/context/zip
Comment 3 Frank Becker CLA 2007-11-11 16:37:55 EST
 (In reply to comment #1)
> Created an attachment (id=82625)
> implementation of cloneTaskData

I think AbstractTaskDataHandler.cloneTaskData should be called from performFinish of the New<RepositoryTyp>TaskWizard (NewBugzillaTaskWizard, NewJiraTaskWizard, ...).

How we can get the information from the action to the New<RepositoryTyp>TaskWizard.

What do you think about this.

- Create of a class that can hold the information of the sourceTaskData. This can be used for other cases like comments, stacktrace, ...
- this class should be passed to the wizard so that we can pass it  to connectorUi.getNewTaskWizard and then to New<RepositoryTyp>TaskWizard

But this meens that AbstractRepositoryConnectorUi must be changed. This meen that all Connectors need to be modified.

What is the best way to do this.

Comment 4 Frank Becker CLA 2007-11-12 15:40:45 EST
 (In reply to comment #3)
> 
> But this meens that AbstractRepositoryConnectorUi must be changed. This meen
> that all Connectors need to be modified.
> 

Should we define an Interface which we can add to the subclasses of AbstractRepositoryConnectorUi.
Then  in NewTaskPage we can test if the new method is defined and use it so that we can reate the correct version of New<RepositoryType>TaskWizard

Should I try this way?
Comment 5 Frank Becker CLA 2007-11-12 18:04:22 EST
Created attachment 82716 [details]
test implementation

This is a test of the new way.

I create CloneTaskAction as an example to demo that this works.

Do you think this is the right way?

If so we can extend NewTaskWizardSeletion to handel the other cases.
Comment 6 Frank Becker CLA 2007-11-12 18:04:24 EST
Created attachment 82717 [details]
mylyn/context/zip
Comment 7 Steffen Pingel CLA 2007-11-14 03:25:18 EST
The patch is looking good so far. Let's focus on adding the new API to TaskDataHandler first before implementing the wizard. Most important are JUnit test cases that verify the implementation of the clone method using task data objects (see http://wiki.eclipse.org/Mylyn_Contributor_Reference#Writing_Tests). I think the signature of the clone method should look like this:

 public void cloneTaskData(RepositoryTaskData sourceTaskData, RepositoryTaskData targetTaskData);
 
A list of attributes to ignore would be connector specific and difficult to specifiy for a caller. How about making the default implemenation only clone attributes that exist on the source as well as on the target task data? In case connectors need to ignore certain attributes the default implementation should be overriden in the connector.

It would be great if you could attach a patch that contains the changes to AbstractTaskDataHandler and test cases only. Once that is merged we can iterate further on implementing the wizard. Here are a few remarks from looking through the patch:

- Please delete all comments before attaching a patch to ease the reviewing process. If there are open questions about the implementation it is better to discuss on the bug before attaching a patch.

- I like idea of having the NewTaskWizardSeletion class that encapsulates the task selection. You could rename it to TaskSelection and it should be immutable.
 
- The default implementation of  the new getNewTaskWizard() method in AbstractRepositoryConnectorUi should invoke the old method ignoring the selection and getNewTaskWizardType() is not needed. That way NewTaskWizard can always invoke the new method and the old method can be marked as deprecated and removed in the 3.0 release.

- The TaskSelection object could only be passed to NewTaskWizard and NewTaskPage for now instead of modifying SelectRepositoryPage which is used in many other places as well that don't require the selection.
Comment 8 maarten meijer CLA 2007-11-14 07:20:16 EST
What is the relation to bug 161646: [patch] Support for Clone this bug
There you can cascade a bug to another (kind of) repository with a back reference.
The copying of data can be more elaborate, is that done here? 
Comment 9 Steffen Pingel CLA 2007-11-14 16:27:01 EST
Once this bug is completed the implementation can be shared with bug 161646 and in addition the back link can be added. Let's finish this bug first and then look at refining the patch for bug 161646.
Comment 10 Frank Becker CLA 2007-11-14 17:34:48 EST
Created attachment 82920 [details]
Patch with jUnit Test

create JUnit tests for bugzilla taskData.

Not all attributes on an bug are tested.

Here the list of attributes currently not included.
			assigned_to_name,
			reporter_name,
			qa_contact,
			new_comment,
			resolution,
			everconfirmed,
			actual_time=actual_time,
			newcc=newcc,
			bug_file_loc,
			reporter_accessibl,
			cc,
			blocked,
			keywords,
			longdesclength,
			status_whiteboard,
			cclist_accessible,
			classification_id,
          		dependson
Should I include	these attributes ?

Should I do an test for the other connectors?
Comment 11 Frank Becker CLA 2007-11-14 17:34:53 EST
Created attachment 82921 [details]
mylyn/context/zip
Comment 12 Frank Becker CLA 2007-11-14 17:38:37 EST
 (In reply to comment #9)
> Once this bug is completed the implementation can be shared with bug 161646 and
> in addition the back link can be added. Let's finish this bug first and then
> look at refining the patch for bug 161646.

Same for bug 152869 and bug 169426.
Comment 13 Shawn Minto CLA 2007-11-14 18:30:32 EST
I was wondering if it would make sense that the attributes that can't be mapped are appended to the description?  I think that this is useful since it is easier to delete a chunk of text over trying to merge some information from the old task to the new one.
Comment 14 Steffen Pingel CLA 2007-11-14 18:52:12 EST
Shawn, that sounds like a great idea. There is some pending work for having a textual representation of differences between task data on bug 205861. We should be able to reuse some of that code once we are done here.
Comment 15 Steffen Pingel CLA 2007-11-14 21:00:56 EST
I have committed the patch with modifications. The default implementation clones all attributes if the source and target task data task and repository kinds match. In other cases it will only clone a selected set of attributes that have keys defined in RepositoryTaskAttribute.

Rob, please review the Bugzilla specific test case. I haven't applied it, yet.
Comment 16 Steffen Pingel CLA 2007-11-14 21:01:02 EST
Created attachment 82930 [details]
mylyn/context/zip
Comment 17 Robert Elves CLA 2007-11-14 21:14:48 EST
 (In reply to comment #15)
> Rob, please review the Bugzilla specific test case. I haven't applied it, yet.
Test portion of patch applied.