How to force a Save operation when only changing links in a work item using java plain client?
I am writing a java plain client utility that attempts to force modify a work item, specifically by removing an existing parent link, and then re-adding it. I'm doing this because I also have a couple of server preconditions/followup actions that will run on a Save Operation that is specifically looking for a change in work item links. However, my utility program is "working" in that it removes and re-adds the parent link, but this does NOT kick off the server-side preconditions/followup actions. It appears this only works on a java plain client program if it actually updates a work item attribute value. I know, links are a separate entity inside EWM's database. Side note, using the web UI or the rich client, the act of (e.g.) removing a parent link and clicking Save DOES kick off the server preconditions/followup actions where it does detect the change in links (via ISaveParameter.getNewReferences()).
In the utility, I'm using ILinkManager to deleteLink() and saveLink(). However, this does not trigger a Save Operation on the work item. Therefore, is there another API I can call to simulate a Save Operation (that also detects the link changes)?
Accepted answer
- This here describes how you operate with work item: https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation . The best way to update a work item is to use a work item operation as in the examples.
- I am not sure what ILinkManager does, but it does not save links on a work item.
- The code below is used to add a new link to the work items references the implementation uses a work item operation. If you use other methods make sure to use the work item save method that also saves the references. A working copy only has saver(monitor) the Server API has other save2 and save 3 and only the latter saves the references.
// Linking Blocking
private static class LinkBlockingWorkItemOperation extends
WorkItemOperation {
private IWorkItemHandle fOpposite;
public LinkBlockingWorkItemOperation(IWorkItemHandle opposite) {
super("Linking Blocking Work Item", IWorkItem.FULL_PROFILE);
fOpposite = opposite;
}
@Override
protected void execute(WorkItemWorkingCopy workingCopy,
IProgressMonitor monitor) throws TeamRepositoryException {
IItemReference reference = IReferenceFactory.INSTANCE
.createReferenceToItem(fOpposite);
workingCopy.getReferences().add(WorkItemEndPoints.BLOCKS_WORK_ITEM,
reference);
}
}
Comments
1 vote