How to fetch change set data from links
I am using the below code :
for(Object wI : links){
ILink link = (ILink) wI;
Object source = link.getTargetRef().resolve();
IItemHandle changeSetHandle = (IItemHandle) link.getTargetRef().resolve();
if (source instanceof IChangeSetHandle) {
changeSet = (IChangeSet) repo.itemManager().fetchCompleteItem(changeSetHandle,
IItemManager.DEFAULT, monitor);
System.out.println("changeset---1"+changeSet);
}
}
But there is some exception like : com.ibm.team.repository.common.ItemNotFoundException: CRJAZ0215E The following record was not found in the database: com.ibm.team.scm.common.internal.impl.ChangeSetHandleImpl |
2 answers
Ralph Schoon (63.6k●3●36●46)
| answered Mar 27 '18, 5:48 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER The source code is totally messy; source and changeSetHandle seem to be the same thing and why would you test the instance for one and then use the other item to resolve?
|
Ralph Schoon (63.6k●3●36●46)
| answered Mar 27 '18, 5:52 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER This is code that worked for me
IWorkItemReferences wiReferences = workItemCommon .resolveWorkItemReferences(workItem, monitor); List<ichangesethandle> changeSetHandles = new ArrayList<ichangesethandle>(); List<ireference> references = wiReferences .getReferences(ILinkTypeRegistry.INSTANCE.getLinkType( WorkItemLinkTypes.CHANGE_SET) .getSourceEndPointDescriptor()); for (IReference reference : references) { if (reference.isItemReference()) { IItemHandle refItem = (IItemHandle) reference.resolve(); if (refItem instanceof IChangeSetHandle) { changeSetHandles.add((IChangeSetHandle) refItem); } } } Comments
Rinkal Garg
commented Mar 28 '18, 3:00 a.m.
@Ralph I have some change sets which have link type id : com.ibm.team.workitem.linktype.scm.tracksChanges
Rinkal Garg
commented Mar 28 '18, 3:08 a.m.
Surely there is some issue in this line :
List changeSets = repo.itemManager().fetchCompleteItems(changeSetHandles,
IItemManager.DEFAULT, monitor);
I have URIReference of change sets. Is there any other way to fetch URI references?
Ralph Schoon
commented Mar 28 '18, 5:01 a.m.
| edited Mar 28 '18, 5:03 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
The code I shared works for me. I don't get null pointers and I am passing an array of the IChangeSetHandles to the call you surely say to be wrong and NOT the references.
Rinkal Garg
commented Mar 28 '18, 5:15 a.m.
I have reference.isURIReference() type, shall I use the same code to fetch complete change set? |
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.