creating a Project Association programmatically does not create link back
Accepted answer
Comments
3 other answers
http://sleroyblog.wordpress.com/2013/04/09/querying-rqm-40-through-oslc-and-rest-api/
Comments
1 vote
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
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);
Comments
sam detweiler
Dec 24 '16, 5:07 p.m.