create links programmatically
Hi,
I'm having trouble creating links programmatically. I created this method, by copying and pasting from various code snippets from the Jazz code.
public static void createBlocks(IWorkItem blocked, int idBlocks, IWorkItemServer workItemService,
IRepositoryItemService repoService) throws TeamRepositoryException {
// add references
IWorkItem newWI = workItemService.findWorkItemById(idBlocks, IWorkItem.FULL_PROFILE, null);
IReference newRef = WorkItemLinkTypes.createWorkItemReference(newWI);
IWorkItemReferences refs =workItemService.resolveWorkItemReferences(blocked, null);
ILinkType unDirectedType = ILinkTypeRegistry.INSTANCE.getLinkType(WorkItemLinkTypes.BLOCKS_WORK_ITEM);
IEndPointDescriptor blocks = unDirectedType.getTargetEndPointDescriptor();
refs.add(blocks, newRef);
// save the workitem
workItemService.saveWorkItem2(blocked, workItemService.resolveWorkItemReferences(blocked, null), null);
}
However, my method doesn't create any links. Am I on the right track? Does anybody have an idea what I did wrong? Thanks!
Annie
I'm having trouble creating links programmatically. I created this method, by copying and pasting from various code snippets from the Jazz code.
public static void createBlocks(IWorkItem blocked, int idBlocks, IWorkItemServer workItemService,
IRepositoryItemService repoService) throws TeamRepositoryException {
// add references
IWorkItem newWI = workItemService.findWorkItemById(idBlocks, IWorkItem.FULL_PROFILE, null);
IReference newRef = WorkItemLinkTypes.createWorkItemReference(newWI);
IWorkItemReferences refs =workItemService.resolveWorkItemReferences(blocked, null);
ILinkType unDirectedType = ILinkTypeRegistry.INSTANCE.getLinkType(WorkItemLinkTypes.BLOCKS_WORK_ITEM);
IEndPointDescriptor blocks = unDirectedType.getTargetEndPointDescriptor();
refs.add(blocks, newRef);
// save the workitem
workItemService.saveWorkItem2(blocked, workItemService.resolveWorkItemReferences(blocked, null), null);
}
However, my method doesn't create any links. Am I on the right track? Does anybody have an idea what I did wrong? Thanks!
Annie