creating a Project Association programmatically does not create link back
Accepted answer
Comments
thanks for showing how you would address this.
Internal classes.. You will need them for most of the advanced things we want to do, so don't listen to the noise..
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.
How did you get the 4 strings (used in your snippet) needed to create the project area associations?
strLinkType
strTargetConsumerRegistryUrl
strTargetServicesUrl
strTargetUrl
3 other answers
@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
String strRTCUUID = prj.getItemId().getUuidValue();
prjRQM = (IProjectArea) repoRQM.itemManager().fetchCompleteItem(prjRQM, IItemManager.REFRESH, null);
prjRQM = (IProjectArea) prjRQM.getWorkingCopy();
IWorkItemCommon workItemCommon = (IWorkItemCommon)repoRQM.getClientLibrary(IWorkItemCommon.class);
IProjectLink prjLink = (IProjectLink) workItemCommon.getAuditableCommon().createAuditable(IProjectLink.ITEM_TYPE);
prjLink = (IProjectLink) prjLink.getWorkingCopy();
prjLink.setProjectArea(prjRQM);
prjLink.setLinkType(strInternalLinkTypeBackLink);
prjLink.setLabel(prj.getName());
prjLink.setTargetConsumerRegistryUrl(repo.getRepositoryURI() + "process/project-areas/" + strRTCUUID + "/links");
prjLink.setTargetServicesUrl(repo.getRepositoryURI() + "oslc/contexts/" + strRTCUUID + "/workitems/services.xml");
prjLink.setTargetUrl(repo.getRepositoryURI() + "process/project-areas/" + strRTCUUID);
prjRQM.addProjectLink(prjLink);
//Save RQM
IProcessItemService processItemService = (IProcessItemService) repoRQM.getClientLibrary(IProcessItemService.class);
processItemService.save(new IProcessItem[] { prjRQM, prjLink }, null);
//Create the link RTC -> RQM
String strRQMUUID = prjRQM.getItemId().getUuidValue();
prj = (IProjectArea) prj.getWorkingCopy();
workItemCommon = (IWorkItemCommon)repo.getClientLibrary(IWorkItemCommon.class);
prjLink = (IProjectLink) workItemCommon.getAuditableCommon().createAuditable(IProjectLink.ITEM_TYPE);
prjLink = (IProjectLink) prjLink.getWorkingCopy();
prjLink.setProjectArea(prj);
prjLink.setLinkType(strInternalLinkType);
prjLink.setLabel(strArtifactContainer);
prjLink.setTargetConsumerRegistryUrl(repoRQM.getRepositoryURI() + "process/project-areas/" + strRQMUUID + "/links");
prjLink.setTargetServicesUrl(repoRQM.getRepositoryURI() + "oslc_qm/contexts/" + strRQMUUID + "/services.xml");
prjLink.setTargetUrl(repoRQM.getRepositoryURI() + "process/project-areas/" + strRQMUUID);
prj.addProjectLink(prjLink);
//Save RTC
processItemService = (IProcessItemService) repo.getClientLibrary(IProcessItemService.class);
processItemService.save(new IProcessItem[] { prj, prjLink }, null);
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.
http://sleroyblog.wordpress.com/2013/04/09/querying-rqm-40-through-oslc-and-rest-api/
Comments
Thank you all for your responses,
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.
I would try to first analyze the data and find out how the link data looks like and then start from there. Please be aware that not all source code ships with the SDK. There s code with intellectual capital that does not ship. Some classes thus don't show code. However I very rarely run into those classes. The main API's come with code.
I would first look into the unit tests that ship with the SDK.
1 vote
Comments
sam detweiler
Dec 24 '16, 5:07 p.m.>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.