(Java API) How Can I Access the Links of the OLD State?
I am trying to create an Operation Participant that will keep track of whether or not work items are blocked by children. If the user modifies a work item, the script should check against the links on that work item for 2 things:
1) Did the user remove the last remaining link that was blocking this work item?
I've got this working against the current state of the work item, but in order to tell whether or not a link was previously present and has now been removed, I need to be able to compare the current links against the previous ones. I've seen posts indicating that I can do this by accessing the operation's "old state". I believe it should look something like this:
Object data = operation.getOperationData();
I found a blog posting by Ralph where he provided some code that is supposed to be able to provide all of the "old references" for a work item when given that work item's ISaveParameter. His code looks like this:
private IWorkItemReferences accessLinksInOldState(ISaveParameter saveParameter, IProgressMonitor monitor) throws TeamRepositoryException
I tried solving this my own way but when that didn't work I tried the code that Ralph posted. Nothing seems to be working. My code has a print statement where I basically iterate through the old references and print them out and then subsequently iterate through the new references and print those out as well. In all cases, the "before" links match the "after" links. For example, if I have remove an existing link, I would expect to see:
Before: <nothing>
That's not happening. Anyone have any insight into this? Note that I read another posting that indicated that when you resolve an old work item by using "resolveAuditable", you always get the current links. I thought maybe this would be occurring in my print routine where I iterate over the references to print out the work item IDs associated with those references, but that doesn't seem to be the problem (or at least, not the only problem). I also iterate through the references lists to compare their sizes. One list should be empty and the other should have a size of 1. Both lists are the same size in all instances. |
One answer
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.
Comments
I posted a comment on this, but I don't see it so I'll try again.
I did a quick test and verified that I am not seeing the Old data at all irrespective of the references. I tried capturing the "old" description and the "new" description and then printing them out. When I change the value, the participant displays only the new data. Attempting to access the old data returns the new data instead.
I think I tried it exactly your way and I think I was able to find references that way. I tried to detect changes to the references. Unfortunately in my case the participant would not have been triggered, because I was looking for tracks links that don't trigger the participant. I am not sure how far I got, but I think I was able to get the references and actually compare them. Is the list of references empty? What happens while debugging on Jetty?
Unfortunately, I never did get Jetty set up. The instructions seemed a little confusing. I'm sure that would make all of this vastly easier.
Using the technique described above, I can definitely get references. The references are just the same as the new references there is no "old" data to be had (of any kind, reference or otherwise). It seems like I am just getting the current/new data (post-save).
Perhaps I'll see if I can get Jetty set up and switch gears a bit.
You should set up Jetty. Try the new version of the Extensions Workshop. If you can't get that up, you can't really approach extending RTC. I was about to do an advisor anyway and will try to have a look at this as well.