Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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)?

0 votes


Accepted answer

Permanent link
  1. 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.
  2. I am not sure what ILinkManager does, but it does not save links on a work item.  
  3. 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);
        }
    }


    


Todd Mueller selected this answer as the correct answer

0 votes

Comments

Please also note, that the operation behavior is only triggered for work item links (like parent/child) but not for CLM links that work across servers e.g. Tracks/Contributes to. 

Thank you Ralph. I am using the WorkItemOperation way of updating the work item.  It was inside the execute() method here where I had the code to update a work item attribute value, AND used the ILinkManager to remove/add the link.  I believe you're right in that this does not directly do things through the work item itself.  I'll play with trying to modify the links on a work item through the work item references as you suggest.

You have to remove references like this:

workingCopy.getReferences().remove(iReference)

You might also have to add: 


workingCopy.getAdditionalSaveParameters().add(IAdditionalSaveParameters.UPDATE_BACKLINKS); 

Thank you Ralph.  You were correct in my scenario that I needed to use the work item's references (workingCopy.getReferences()) for removing and adding the parent link instead of using ILinkManager.  This solution causes a perceived change on the work item itself, which then kicks off all my preconditions and followup actions, which is the behavior I wanted. Got it working now.

1 vote

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 12,023

Question asked: Aug 10 '22, 5:58 p.m.

Question was seen: 809 times

Last updated: Aug 16 '22, 1:27 a.m.

Confirmation Cancel Confirm