It's all about the answers!

Ask a question

How to access change set file information


Adrian Ronayne (2336) | asked Oct 25 '12, 9:56 a.m.
 How can I access the files created/modified by a change set using the java API's ? I cannot find any documentation on how to accomplish this.

Here is the closest doc I have found : https://jazz.net/forum/questions/38090/get-files-referred-in-a-change-set-via-rest-apis but it falls short in actually showing how to implement getVersionable.

2 answers



permanent link
DJ Houghton (2663) | answered Oct 25 '12, 10:25 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
What object types do you have? The API on IScmService might be useful. Check out #getHistoryForVersionable. From there you can get the ChangeHistoryEntry, which gives you the ChangeSetHandle, which you can do a fetch on to get the IChangeSet, and then you can get the list of IChanges, which gets you the handles to the before and after state. 
  

Comments
Adrian Ronayne commented Oct 25 '12, 11:06 a.m.

What do you mean by 'object types' ? All I want to display is a listing of files delivered for a given stream along with the author of that delivered file. Where can I find the IScmService API ? 


permanent link
DJ Houghton (2663) | answered Oct 25 '12, 4:29 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
Sorry, I was confused on which APIs you were using, the ones I referred to probably not available to you. Here is a (warning: completely untested) snippet of code which might help you if you're using the plain Java APIs. 

    public static void main(ITeamRepository repo) throws Exception {

        IWorkspaceManager wsmgr = SCMPlatform.getWorkspaceManager(repo);

        IItemManager imgr = (IItemManager) repo.getClientLibrary(IItemManager.class);

        IVersionableManager vmgr = (IVersionableManager) repo.getClientLibrary(IVersionableManager.class);


        IChangeSetSearchCriteria criteria = IChangeSetSearchCriteria.FACTORY.newInstance();

        // TODO set the cs search criteria

        

        List<IChangeSetHandle> list = wsmgr.findChangeSets(criteria, 100, null);

        for (IChangeSetHandle handle : list) {

            IChangeSet cs = (IChangeSet) imgr.fetchCompleteState(handle, null);

            IContributorHandle authorHandle = cs.getAuthor();

            IContributor author = (IContributor) imgr.fetchCompleteState(authorHandle, null);

            // TODO do something with the author


            List<IChange> changes = cs.changes();

            for (IChange change : changes) {

                IVersionableHandle beforeHandle = change.beforeState();

                IVersionable before = vmgr.fetchCompleteState(beforeHandle, null);

                // TODO do something with the before state


                IVersionableHandle afterHandle = change.afterState();

                IVersionable after = vmgr.fetchCompleteState(afterHandle, null);

                // TODO do something with the after state

            }

        }

    }


Your answer


Register or 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.