It's all about the answers!

Ask a question

Is it possible to restrict link types available between work items?


Timothy Distel (73356) | asked Jul 11 '18, 10:10 a.m.

Hi,

I am using RTC 6.0.3.

Is there a way to provide link constraints within RTC like RDNG? For example, I have one work item which resolves another work item. In the available link types, resolves and resolved by are accessible from either direction. Am I able to restrict the resolves link type so that it is not possible to put incorrect relationships in place?

Accepted answer


permanent link
Luca Martinucci (1.0k397112) | answered Jul 11 '18, 10:49 a.m.

Do you want to restrict the direction of a link type according to the work item type?

When I asked the question, it was not possible; I have not checked if newer RTC versions have this feature.
Actually, I developed a server-side Java plugin to prevent "wrong" links from being created.
Anyway, the check runs after the link has been set, and raises an error on the work item save.

Timothy Distel selected this answer as the correct answer

Comments
Timothy Distel commented Jul 11 '18, 2:13 p.m.

Would you mind sharing or pointing me in the right direction to setting up my environment to do this?


Luca Martinucci commented Jul 12 '18, 2:30 a.m.
Are you familiar with RTC plugins (extensions) development?
To learn how to setup the environment, read this article: https://jazz.net/library/article/1000

As soon as possible I will share with you the most useful code snippets of my plugin.

Basically, you must retrieve all links set on a work item, their type, their direction and the (other) linked work item.
Once you have these pieces of information, you can check whether the link is a valid one or not.


Timothy Distel commented Jul 12 '18, 8:13 a.m.

I've completed the first lab of the workshop which I believe completely sets up my own personal environment, separate from the actual environment I'll end up deploying to. I'm not sure of everything I would need to modify to connect this to my actual environment, and I don't have the most experience with java or eclipse so this is a little daunting. Would it be possible for us to establish another means of communication, other than replying to one another on the jazz forum?


Ralph Schoon commented Jul 12 '18, 9:15 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

The Lab 1 is only setting up the environment you need. You should perform the whole workshop. As I answered in my blog, all the steps you do will be needed later in your production environment.

Finally you want to create an advisor / pre condition (not a follow up action like in the workshop). However except small changes to the Interfaces the steps are very similar. You can find examples for that and for the API on my blog. Search the blog for Advisor and Link API to find the posts.


Timothy Distel commented Jul 12 '18, 9:25 a.m.

Thank you for the extra information Ralph! Will do.


Ralph Schoon commented Jul 12 '18, 9:36 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

And also the operational behavior for work item save server is not called for these link types:

Tracks <-> Contributes to
Related Change Request <-> Related Change Request
Affects Plan Item <-> Affects Plan Item
Affected by Defect <-> Affected by Defect

This is a limitation that is known for some time.

showing 5 of 6 show 1 more comments

3 other answers



permanent link
Ralph Schoon (63.6k33646) | answered Jul 11 '18, 11:57 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

You would have to create a work item save pre-condition that prevents this, You can do that for certain link types. There is no built in functionality at the moment.


permanent link
Luca Martinucci (1.0k397112) | answered Jul 12 '18, 3:20 p.m.

Timothy,
look at these code snippets I extracted from my plugin:

// retrieve the list of links ("references") set on the WI you are saving
IWorkItemReferences refs = saveParameter.getNewReferences();
List<IEndPointDescriptor> workItemReferencesTypes = refs.getTypes();
// for each link type you found, retrieve the linked items
for (IEndPointDescriptor linkDesc : workItemReferencesTypes) {
    List<IReference> listReferences = refs.getReferences(linkDesc);
    for (IReference reference : listReferences) {
    if (reference.isItemReference()) {
        referencedItem = ((IItemReference) reference).getReferencedItem();
        String itemKind = referencedItem.getItemType().getName();
        // check whether the linked item is a WI
        if (referencedItem instanceof IWorkItemHandle) {
            workLinked = (IWorkItem) repositoryItemService.fetchItem(referencedItem, IRepositoryItemService.COMPLETE);
            // retrieve the type of the linked WI     
            String linkedWorkItemType = workLinked.getWorkItemType();
            // is it a valid link?
            // ......
            // ......
        }
    }
}


If you the whole code, please provide me with your email, and I will send it to you.


Comments
Timothy Distel commented Jul 12 '18, 4:06 p.m.

Luca,

That is beyond generous, and I thank you for being so helpful. I may be far out from actually developing extensions (2-3 months) but I would love to receive the code so that when I do get to that point I have a reference not only for this particular use case but, more valuable to me, I can dissect the code to help me understand how to develop other extensions in the future. If you wouldn't mind, my email address is: timothy.distel@igimail.com


permanent link
Munjal Patel (111) | answered May 26 '22, 11:11 a.m.

@Ralph Schoon
Does operational behavior for work item save server is called for any link types?

Will it call for Parent<->Child or Resolves<->Resolved By or any other link types?

<o:p> </o:p>


Comments
Ralph Schoon commented May 30 '22, 2:08 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

No, I mentioned this in my last comment on the accepted answer. 

The link types the operational behavior for work item save server is not called for at least these link types:

Tracks <-> Contributes to
Related Change Request <-> Related Change Request
Affects Plan Item <-> Affects Plan Item
Affected by Defect <-> Affected by Defect


Your answer


Register or 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.