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

Save Work Item precondition - get Parent workitem

I have a 'Save Work Item (server)' Precondition. I have a requirement to 'inspect' the workitem's Parent (if it exists) in this precondition as part of a validation rule. The problem I have is that when the user invokes 'Add -> Set Parent...', then 'saves' the workitem, the Precondition does not recognize that the parent relationship exists. Only after the 'save' is successful, if I 'save' the workitem again, does the Precondition recognize the Parent relationship.

Is there a technique that I can use to find the Parent workitem in the Precondition on that first 'save' (when the parent relationship is first established)?

Thanks in advance,

Dave

0 votes


Accepted answer

Permanent link
I found the solution... posting it for the benefit of others.



public IWorkItemHandle findParent(AdvisableOperation operation) throws TeamRepositoryException
{
Object data = operation.getOperationData();

if (data instanceof ISaveParameter) // from Workitem -> save operation
{
ISaveParameter saveParameter = (ISaveParameter) data;
IWorkItemReferences ref = saveParameter.getNewReferences();
List<IEndPointDescriptor> types = ref.getTypes();
for (IEndPointDescriptor desc : types)
{
if (desc.getId().equalsIgnoreCase("parent")) // "parent" is an RTC/Jazz string ID
{
List<IReference> refList = ref.getReferences(desc);

if (refList.size() > 0)
{
IReference iRef = refList.get(0); // Only one parent
Object obj = iRef.resolve();
if (obj instanceof IWorkItemHandle) // Only looking for Workitems.
{
return (IWorkItemHandle) obj;
}
else
return null;
}
else
return null;
}
}
}
return null;
}
Ralph Schoon selected this answer as the correct answer

1 vote


6 other answers

Permanent link
Hi Canberk,

I took the opportunity to blog what I found about work item links in my blog: https://rsjazz.wordpress.com/2012/09/19/the-rtc-workitem-link-apilinking-workitems-to-other-elements/

It is client side only today. The restriction really is that I couldn't find a quick way to access the references of work items on the server (except in plug ins, where I have a save parameter). I found that and work on more. Currently I am struggling with finding the code to create a link on the server.

0 votes


Permanent link

Hi Ralph,

I only check if there's a reference to the workitem by implemented by link and it seems to work. I haven't checked the content but as I debug I see that whenever I add a requirement to the workitem, the size of the LinkTypeReference increases. I added my comment to the workitem.

0 votes


Permanent link
Canberk,

I found out recently that CLM link changes don't trigger advisors or participants and filed https://jazz.net/jazz/web/projects/Rational%20Team%20Concert#action=com.ibm.team.workitem.viewWorkItem&id=228421 . This might be a situation that is similar. I am not sure. You might want to file a work item or support my work item.

On the the hand, I am wondering if you plugin looks at the right references in the saveParameter.

0 votes


Permanent link

My plugins purpose is to check if my task contains a link to a requirement or not. If not, you can't save workitem, if there's a link you can save it. I finished the plugin and deployed to server. I tested on both RTC and RRC sides.

When you create a workitem through RTC web client or thick client, the plugin works. It warns user in case of a missing link. But if I try to add a workitem to a requirement with a "implemented by" link throug RRC web client, we cant save the workitem. The plugin warns me about "not having a requirement linked to the workitem". I guess linking operation bahaves differently.

0 votes

Comments

there are TWO sets of data, old and proposed new..

I but you are checking OldState.. (which doesn't have the link yet) chaneg to checking NewState

That is something to check, sa mentioned in my other answer. However, there are really links that don't trigger a participants. I am not sure if these are of the class. The inconsistent behavior in RTC and the external tools are disturbing.


Permanent link
The WorkItemEndPoints are only a subset. Try the WorkItemLinkTypes and the ILinkRegistry. There are Link types for requirements.

ILinkTypeRegistry.INSTANCE.getLinkType(WorkItemLinkTypes.IMPLEMENTS_REQUIREMENT).getTargetEndPointDescriptor()


1 vote

Comments

You're simply great :) That was what ı was looking for. Finally I finished my plugin :)


Permanent link

Is it ppossible to check if workitem is linked to a requirement?

ı couldn't find any WorkItemEndPoints properties that might show the requirement.

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,930

Question asked: Jan 12 '09, 3:20 p.m.

Question was seen: 8,055 times

Last updated: Sep 20 '12, 11:54 a.m.

Confirmation Cancel Confirm