It's all about the answers!

Ask a question

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

Gagandeep Singh (122) | asked Sep 25 '13, 1:33 a.m.
retagged Dec 03 '13, 5:00 p.m. by David Lafreniere (4.8k7)
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();
            SimpleDateFormat format= new SimpleDateFormat("yyyyMMdd-hhmm");;
            changeSetSearchCriteria.setModifiedAfter(new Timestamp(format.parse("20130901").getTime()));
            List<IChangeSetHandle> changeSetHandles;
                changeSetHandles = SCMPlatform.getWorkspaceManager(repository).findChangeSets(changeSetSearchCriteria, 1024,monitor);
            }catch ( TeamRepositoryException  e){
                throw new RuntimeException(e);

Also now how to read from changeSetHandlers ?

2 answers

permanent link
praveen patidar (8613144) | answered Oct 24 '13, 11:58 p.m.
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,

IItemReference linkTarget = IReferenceFactory.INSTANCE
// 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
IChangeSet changeset = (IChangeSet) itemManager
                                    IItemManager.DEFAULT, null);

permanent link
Ralph Schoon (63.0k33645) | answered Sep 25 '13, 3:15 a.m.
Please have a look at and and and

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

Your answer

Register or to post your answer.