creating a Project Association programmatically does not create link back
In RTC, when creating Project Associations programmatically using the Java client API, it does not create the link back.
The Association is successfully created in RTC, but the correspondent Association is not created in the other system. In this case, RQM. The funny thing is, deleting the project association in RTC will display a error: 'Failure to delete back links'
If we create the association manually, the link back is created. And no error will be displayed when deleting it.
My thoughts:
- I expected the same behaviour in the API than in the RTC client. To a strict observer, it may look like we can corrupt RTC by using the API.
- I guess we need to create the corresponding link back in RQM to set up the association successfully. I was wondering if somebody can point me to an example or a section in the RQM OSLC API.
Thank you.
|
Accepted answer
Your comments gave me some ideas, and I managed to get it working.
The solution uses internal classes, and it still has a tweak I need investigate, but in case it can be useful for anybody,
The following code creates the link successfully in RTC, but it does not create the backlink:
IProjectLink prjLink;
prj = (IProjectArea) prj.getWorkingCopy();
IWorkItemCommon workItemCommon = (IWorkItemCommon)repo.getClientLibrary(IWorkItemCommon.class);
prjLink = (IProjectLink) workItemCommon.getAuditableCommon().createAuditable(IProjectLink.ITEM_TYPE);
prjLink = (IProjectLink) prjLink.getWorkingCopy();
prjLink.setProjectArea(prj);
prjLink.setLinkType(strLinkType);
prjLink.setLabel(strRQMProjectAreaName);
prjLink.setTargetConsumerRegistryUrl(strTargetConsumerRegistryUrl);
prjLink.setTargetServicesUrl(strTargetServicesUrl);
prjLink.setTargetUrl(strTargetUrl);
IProcessItemService processItemService = (IProcessItemService) repo.getClientLibrary(IProcessItemService.class);
prj.addProjectLink(prjLink);
processItemService.save(new IProcessItem[] { prj, prjLink }, null);
If we replace the last three lines with the following ones, it will prompt for the RQM credentials and will create the backlink:
IProcessItemService service =(IProcessItemService) repo.getClientLibrary(IProcessItemService.class);
service.getWorkingCopyManager().connect(prj);
ProjectAreaWorkingCopy prjWC = (ProjectAreaWorkingCopy) service.getWorkingCopyManager().getWorkingCopy(prj);
prjWC.getLinks().addLinks(new IProjectLinkHandle[] {prjLink});
prjWC.save(null);
This solution is meant to be run from the Eclipse client.
I guess any Jazz developer will recommend not to mess with internal classes,
but the level of automation required by my organization worths the risk.
Ralph Schoon selected this answer as the correct answer
Comments
sam detweiler
commented Dec 10 '14, 2:07 p.m.
thanks for showing how you would address this.
As I am a fan of automation, all I can suggest is to express your demand for these internal API's to be made externally available by submitting enhancement requests.
Daniel Chirillo
commented Dec 16 '16, 1:51 p.m.
How did you get the 4 strings (used in your snippet) needed to create the project area associations?
|
3 other answers
I don't have experience in using Java API but OSLC API to add a link won't create a back link automatically and you will need to create a back link manually or using OSLC API as well. There are some good reference in this blog for RQM API:
http://sleroyblog.wordpress.com/2013/04/09/querying-rqm-40-through-oslc-and-rest-api/ Comments Thank you all for your responses,
but Ralph, Don, I'm afraid that is not what I was asking about.
We are not trying to automate the creation of links between artifacts, but to automate the creation of the Project Associations themselves (Project Area setup).
I have been looking for this in the RQM OSLC and REST APIs without luck.
I guess the only option is, as Sam says, to read the source code. But I guess that can be a daunting task.
In any case, thank you all for your help. I understand this was a tricky question.
1
Ralph Schoon
commented Dec 02 '14, 5:51 a.m.
| edited Dec 02 '14, 5:52 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
My naive assumption is that the same restrictions apply to creation of these references. Especially because I have seen the same issue with deleting links in the past and it happened to be a link that was created the wrong way (with the wrong location information) which resulted in a URL that was equivalent to the other in the UI, but apparently not for the application.
|
Ralph Schoon (63.4k●3●36●46)
| answered Dec 02 '14, 4:05 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Please also refer to this post: https://rsjazz.wordpress.com/2013/11/06/creating-clm-links-with-back-link/ this is about work item CLM links.
If you use the RTC Java API, you need to understand that there are also various ways how to create the links e.g. for work items. Different link types require different information to allow linking. If the links are of a wrong format you will experience problems with links not showing up on one end or with errors when trying to delete the links. It is important to figure out which format the links on both ends have and to recreate that format when creating them with the API. |
@danchirillo, please have a look at below code. Feels like ages since I did this. In the end, I created the backlink using also the RTC Java API to avoid using dodgy internal code. See below:
//Create the backlink RQM -> RTC
//Create the link RTC -> RQM
|
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.
Comments
>I expected the same behaviour in the API than in the RTC client.
but you don't know what the RTC client actually did when you requested this action. it might have called 50 apis.
you could find and read the source code to know exactly. all the source is in the SDK download for each release.