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

Want to Read all ChangeSet's associated with a Work Item

Say in my  Project Area's "SSFS On Premise" and "WMS" , i want to get all changeSets associated to a single Work Item say "344521".

Following is the code...kindly help

IWorkspaceManager iworkspaceManager = (IWorkspaceManager) repository.getClientLibrary(IWorkspaceManager.class);
            IWorkspaceSearchCriteria criteria1 = IWorkspaceSearchCriteria.FACTORY.newInstance();
            criteria1.setKind( IWorkspaceSearchCriteria.WORKSPACES );
            criteria1.setExactName( "SSFS On Premise" );
//                criteria1.setExactOwnerName("SSFS On Premise");
            List<IWorkspaceHandle> workspaceHandles = iworkspaceManager.findWorkspaces(criteria1, Integer.MAX_VALUE, monitor);    
            IWorkspaceHandle wh = workspaceHandles.get( 0 );
            IWorkspaceConnection workspaceConnection = iworkspaceManager.getWorkspaceConnection(wh, monitor);    
           
//           
            IChangeSetSearchCriteria changeSetSearchCriteria =     IChangeSetSearchCriteria.FACTORY.newInstance();
            IContextHandle workspaceContexthandle = workspaceConnection.getContextHandle();
           
            changeSetSearchCriteria.setContext(workspaceContexthandle);
           
            SimpleDateFormat format= new SimpleDateFormat("yyyyMMdd-hhmm");;
           
            changeSetSearchCriteria.setModifiedAfter(new Timestamp(format.parse("20130901").getTime()));
           
            List<IChangeSetHandle> changeSetHandles;
           
            try{
                changeSetHandles = SCMPlatform.getWorkspaceManager(repository).findChangeSets(changeSetSearchCriteria, 1024,monitor);
            }catch ( TeamRepositoryException  e){
                throw new RuntimeException(e);
            }

Also now how to read from changeSetHandlers ?

0 votes



2 answers

Permanent link
Please have a look at http://thescmlounge.blogspot.de/2013/08/getting-your-stuff-using-rtc-sdk-to-zip.html and https://jazz.net/forum/questions/31044/how-to-get-workitemhandle-from-changesethandle and https://jazz.net/forum/questions/93392/change-set-how-to-retrive-the-information-of-changeset-programatically and https://jazz.net/forum/questions/3392/fetching-change-set-for-work-item

You can,for example use the IItemManager
IChangeSet contribution = (IChangeSet) repo.itemManager().fetchCompleteItem(tempCs, IItemManager.DEFAULT, null); 

1 vote


Permanent link
HI,
Why you are traveling through the workspace and then get the change set. as question suggested you need to get change sets only from work item. then probably you can first search work item and then change sets associated with it.
Search the work item by
IWorkItem task = workItemClient.findWorkItemById(
                    Integer.parseInt("12345"), IWorkItem.FULL_PROFILE,
                    null);



IItemReference linkTarget = IReferenceFactory.INSTANCE
                .createReferenceToItem(task);
// Get alist of all change sets
ILinkQueryPage changeSets = linkManager.findLinksByTarget(
                WorkItemLinkTypes.CHANGE_SET, linkTarget,
                new NullProgressMonitor());
        ILinkCollection linkCollection = changeSets.getLinks();
           for (ILink iLink : linkCollection) {
            IChangeSetHandle changeSetHandle = (IChangeSetHandle) iLink
                    .getSourceRef().resolve();
IChangeSet changeset = (IChangeSet) itemManager
                             .fetchCompleteItem(changeSetHandle,
                                    IItemManager.DEFAULT, null);

0 votes

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
× 1,204
× 169
× 149

Question asked: Sep 25 '13, 1:33 a.m.

Question was seen: 6,766 times

Last updated: Dec 03 '13, 5:00 p.m.

Confirmation Cancel Confirm