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 ?
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 ?
2 answers
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
You can,for example use the IItemManager
IChangeSet contribution = (IChangeSet) repo.itemManager().fetchCompleteItem(tempCs, IItemManager.DEFAULT, null);
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);
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);