Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

0 votes



2 answers

Permanent link

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?

Cast the item you want to look up to IChangeSetHandle and use the casted interface in the lookup.

0 votes


Permanent link

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);
                }
            }
        }

    @SuppressWarnings("rawtypes")
    List changeSets = itemManager.fetchCompleteItems(changeSetHandles,
            IItemManager.DEFAULT, monitor);
    for (Object object : changeSets) {
        if (object instanceof IChangeSet) {
            IChangeSet changeSet = (IChangeSet) object;

......... </ireference></ichangesethandle></ichangesethandle>

0 votes

Comments

 @Ralph I have some change sets which have link type id : com.ibm.team.workitem.linktype.scm.tracksChanges
 and then I am using the code which you have shared but it returns null value and exception that the item is not found in the database even though the change set is there.
Any help would be appreciable.

 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?

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.

I can not remote debug.

 I have reference.isURIReference() type, shall I use the same code to fetch complete change set?

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938
× 457
× 411

Question asked: Mar 27 '18, 5:24 a.m.

Question was seen: 1,963 times

Last updated: Mar 28 '18, 5:15 a.m.

Confirmation Cancel Confirm