It's all about the answers!

Ask a question

Save Work Item precondition - get Parent workitem


David Weber (761810) | asked Jan 12 '09, 3:20 p.m.
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

Accepted answer


permanent link
David Weber (761810) | answered Jan 15 '09, 3:26 p.m.
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

6 other answers



permanent link
Ralph Schoon (63.0k33645) | answered Sep 18 '12, 10:06 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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()



Comments
Canberk Akduygu commented Sep 18 '12, 4:22 p.m. | edited Sep 18 '12, 4:23 p.m.

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


permanent link
Canberk Akduygu (99237371) | answered Sep 18 '12, 7:03 a.m.

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

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


permanent link
Canberk Akduygu (99237371) | answered Sep 19 '12, 2:07 a.m.

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.


Comments
sam detweiler commented Sep 20 '12, 8:19 a.m.

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


Ralph Schoon commented Sep 20 '12, 11:54 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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
Ralph Schoon (63.0k33645) | answered Sep 19 '12, 11:16 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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.

permanent link
Canberk Akduygu (99237371) | answered Sep 20 '12, 4:08 a.m.

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.


permanent link
Ralph Schoon (63.0k33645) | answered Sep 20 '12, 7:52 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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.

Your answer


Register or to post your answer.