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

Strange behaviour on link location. Bug?

Hi, I've find out a strange behaviour of ILinkServiceLibrary.findLinks method.
This is the scenario: I've developed a precondition plugin on save work item operation. This pre-condition fails if you are trying to reopen a work-item if it has a parent work-item in a defined workflow state. Everything seems to be ok if I do all things one at time, but if I try in the same "save" operation to change link (changing the parent work-item in an other one in the correct workflow state), when I run the findLinks method on a IReference instance obtained from a workitem which I've retrieve using ISaveParameter.getNewState() I got the old parent link instead of the new one.

Am I missing something or is it a bug?

0 votes



2 answers

Permanent link
Hi, I've find out a strange behaviour of ILinkServiceLibrary.findLinks
method.
This is the scenario: I've developed a precondition plugin on save
work item operation. This pre-condition fails if you are trying to
reopen a work-item if it has a parent work-item in a defined workflow
state. Everything seems to be ok if I do all things one at time, but
if I try in the same "save" operation to change link
(changing the parent work-item in an other one in the correct
workflow state), when I run the findLinks method on a IReference
instance obtained from a workitem which I've retrieve using
ISaveParameter.getNewState() I got the old parent link instead of the
new one.

Am I missing something or is it a bug?

The LinkServiceLibrary queries the repository, but the new parent is not
saved yet (you are in the precondition). That's why you still get the old
parent.

I would suggest you use this code:

private IWorkItem getParentWorkItem(ISaveParameter param,
IAuditableCommon auditableCommon) throws TeamRepositoryException {
List<IReference> parentRefs= null;
IWorkItemReferences refs= param.getNewReferences();
if (refs.hasReferences(WorkItemEndPoints.PARENT_WORK_ITEM)) {
parentRefs= refs.getReferences(WorkItemEndPoints.PARENT_WORK_ITEM);
}
if (parentRefs != null && !parentRefs.isEmpty()) {
IReference parent= parentRefs.get(0);
if (parent.isItemReference()) {
IItemHandle refItem= ((IItemReference)parent).getReferencedItem();
if (refItem instanceof IWorkItemHandle) {
return (IWorkItem)
auditableCommon.resolveAuditable((IWorkItemHandle) refItem,
IWorkItem.DEFAULT_PROFILE, null);
}
}
}
return null;
}



--
Regards,
Patrick
Jazz Work Item Team

0 votes


Permanent link
Thank you for the answer, I was supposing that referring to the "newState" object I would had the entire new object. So I was wrong, as I can see from your snippet, informations related to links are still stored in ISaveParameter but in another location.

I'm going to try your code. Thanks.

0 votes

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
× 10,948

Question asked: Aug 26 '09, 12:20 p.m.

Question was seen: 5,733 times

Last updated: Aug 26 '09, 12:20 p.m.

Confirmation Cancel Confirm