我使用下面的代码来获取工作项的父项和子项,我得到了链接引用,现在我想从对象中获取工作项Id。请帮忙
IReference reference = linkManager.referenceFactory().createReferenceToItem(workItem
.getItemHandle());
ILinkQueryPage page;
ILinkQueryPage page1;
page = linkManager.findLinksByTarget("com.ibm.team.workitem.linktype.parentworkitem", reference, monitor);
ILinkCollection linkCollection = page.getLinks();
Collection childWI = linkCollection.getLinksById("com.ibm.team.workitem.linktype.parentworkitem");
System.out.println(childWI);
答案 0 :(得分:0)
ILinkCollection linkCollection = page.getLinks();
Collection childWI = linkCollection.getLinksById(...)
这意味着你有一组ILink。
作为seen here,可以轻松解析指向WorkItem的链接:
for (ILink l : links) {
IItemHandle linkHandle = (IItemHandle) l.getTargetRef().resolve();
if (linkHandle instanceof IWorkItemHandle) {
IWorkItem aWorkItem = (IWorkItem) teamRepository.itemManager().fetchCompleteItem(linkHandle, IItemManager.DEFAULT, monitor);
}
}
每个WorkItem
都有一个getId()
方法来访问其ID。