Copying comments from one work item to a new one
I'm trying to make a copy of a work item and part of that is making an exact
copy of the associated comments (preserving owner/dates/etc). I'm using the following code: // Add existing comments to new work item IComments comments = wi.getComments(); if (comments.getContents().length > 0) { for (IComment comment: comments.getContents()) { IContributorHandle creator = comment.getCreator(); IComment newComment = workItem.getComments().createComment(creator, comment.getHTMLContent()); ((Comment) newComment).setCreationDate(comment.getCreationDate()); workItem.getComments().append(newComment); } } The problem I run into is with setting the creator (IContributorHandle). When I use the above code, it all compiles and runs fine but when I try to view the new work item in RTC, it just hangs trying to display it. If I replace the "creator" variable in createComment(creator, comment.getHTMLContent()) with createComment(repoNew.loggedInContributor(), comment.getHTMLContent()) (which returns an IContributor object instead of the handle), then it all works fine, except it isn't the actual user who created the original comment. So the ultimate question is, given an IContributorHandle, how do I get the full object (IContributor) that the handle represents? I was looking at some of the fetch/resolve methods but couldn't find one off hand that looked right. Thanks! -- Dave Draeger IBM WebSphere Serviceability Development |
4 answers
Are you copying between different repositories? This would be unsupported because the editor has no hint that the comment creator on the new work item would have to be resolved in a different repository than the work item. Otherwise the code should work as expected and it would be interesting to know why the UI hangs when you try to open it. (You could resolve the contributor using ITeamRepository.itemManager().fetchCompleteItem(handle, IItemManager.DEFAULT, monitor).)
Christof Jazz Work Item team Dave Draeger wrote: I'm trying to make a copy of a work item and part of that is making an exact |
I am attempting to follow the directions for resolving an IContributorHandle to an IContributor as specified in the oiriginal post:
So the ultimate question is, given an IContributorHandle, how do I get the full object (IContributor) that the handle represents? I tried the method suggested: You could resolve the contributor using ITeamRepository.itemManager().fetchCompleteItem(handle, IItemManager.DEFAULT, monitor). However, this returns an IItem rather than an IContributor. I need to obtain IContributor because I am attempting to extract the raw data from my repository, and as far as I can tell, IContributor is the only object that has the necessary methods to do this -- I would like to obtain the name of the user as a simple String using getName(). Thanks in advance for any help! Aaron |
|
Have you tried using the fetch Contributor by user id call? This returns an IContributor. There is also the contributorManager.fetchAllContributors in which you could search for the user you are looking for.
I am attempting to follow the directions for resolving an IContributorHandle to an IContributor as specified in the oiriginal post: So the ultimate question is, given an IContributorHandle, how do I get the full object (IContributor) that the handle represents? I tried the method suggested: You could resolve the contributor using ITeamRepository.itemManager().fetchCompleteItem(handle, IItemManager.DEFAULT, monitor). However, this returns an IItem rather than an IContributor. I need to obtain IContributor because I am attempting to extract the raw data from my repository, and as far as I can tell, IContributor is the only object that has the necessary methods to do this -- I would like to obtain the name of the user as a simple String using getName(). Thanks in advance for any help! Aaron |
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.