It's all about the answers!

Ask a question

create links programmatically


Annie Ying (2061103) | asked Mar 20 '08, 3:43 p.m.
JAZZ DEVELOPER
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

Be the first one to answer this question!


Register or to post your answer.