Fetching change set for work item
Hi all,
I am trying to fetch change sets for resolved work items. So far I have the workItem and can fetch all kind of Links to other WorkItems and URIs. But how do I get a change set. I was trying to follow the steps of the WorkItemEditor but I couldn't figure it out. Can anybody help? |
10 answers
I am trying to do the same but I am not getting results
getChangeSets(repository, workItem, null); Where repository = login(repositoryURI, userId, password); and IWorkItem workItem = resolved.getItem(); public static void getChangeSets(ITeamRepository repository, IWorkItem workItem, IProgressMonitor monitor) throws TeamRepositoryException { //Get an IReference to the work item. ILinkManager linkManager = (ILinkManager) repository.getClientLibrary(ILinkManager.class); IReferenceFactory referenceFactory = linkManager.referenceFactory(); IReference workItemReference = referenceFactory.createReferenceToItem(workItem.getItemHandle()); //Find all ILinks which attach a change set to the work item. ILinkQueryPage linkQueryPage = null; try { linkQueryPage = linkManager.findLinksByTarget("com.ibm.team.filesystem.workitems.change_set", workItemReference, monitor); } catch (TeamRepositoryException e) { // TODO Auto-generated catch block e.printStackTrace(); } ILinkCollection linkCollection = linkQueryPage.getAllLinksFromHereOn(); //Put the ILinks in a list. List<ILink> linksById = (List<ILink>)linkCollection.getLinksById("com.ibm.team.filesystem.workitems.change_set"); List<ILink> changeSetLinks = linksById; System.out.println("********************"+ linksById.size()); //ALWAYS getting size 0 List<IReference> changeSetReferences = new ArrayList<IReference>(); for (ILink link : changeSetLinks) { IChangeSetHandle changeSetHandle = (IChangeSetHandle)link.getSourceRef().resolve(); ItemId<IChangeSet> changeSetItemId = ChangeSetUtil.getChangeSet(changeSetHandle); // changeSetReferences.add(link.getSourceRef()); } Comments
S M
commented Oct 23 '12, 5:16 a.m.
Hi, have you ever found a solution for this problem?
You may want to check the posts further down that seem to have solved the problem or provide sample code that solves the problem.
|
kim wrote:
Hi all, If you have a set of ILinks in hand, then links of type "com.ibm.team.filesystem.workitems.change_set" are change-set to work item links. The source is the change-set item and the target the work item. We changed the change-set item reference after beta 2, previously it was a URI that could be resolved using the IItemManager. Now it's an item. Jean-Michel Jazz Source Control Team |
Thanks. That's exectly what I needed! Thank you
Cheers, Kim For all those people searching for direct code:
* |
Hi Jean-Michel,
I have another question closely connected to this topic. Now, I managed to extract the IFileItemHandle from the IChangeSet.
Now, I want to get the path of this IFileItem(Handle). How this and more info for the file? I really can't find any help in the source code. Thank you Kim Comments
praveen patidar
commented Nov 08 '12, 7:05 p.m.
what type of object is change ? from where it is originated ?
|
Hi Kim,
The path of a versionable state is relative to the configuration for which you wish to interpret the state in. All the IVersionable item itself knows is who its parent folder is, and what name it has with respect to that parent. The (full) paths you see in the TeamConcert UI are interpreted against workspaces or other SCM artifacts from which we can derive a configuration. JohnC SCM Server kim wrote: Hi Jean-Michel, |
Hi Kim,
Is it possible to get the change-set list out of workitem and complete them on workitem state change? Am I right that your code run from the client side? Can you write all the code? I don't know how to get the _teamRepository variable .. Thanks! |
Hi yehiel,
Well, the whole code is a bit long but you get the _teamRepository very simply: IProjectAreaHandle projectAreaHandle = ProjectAreas.getInstance().getByName(projectAreaName); Code for getting the change sets: protected void fetchChangeSets(IWorkItem workItem,IProgressMonitor _monitor, ITeamRepository teamRepository){ Where the ChangeSetUtil is import com.ibm.team.filesystem.common.internal.util.ChangeSetUtil; What do you mean by complete them on workitem state? //Kim Hi Kim, |
Why the We found only these package com.ibm.team.workitem.common.model; Or instead the Thanks in advance. |
This link type had been defined since 3.x version. For what I know it does not appear on 2.x version so it has to be set manually.
Michele.
Why the We found only these package com.ibm.team.workitem.common.model; Or instead the Thanks in advance. |
In 2.0.0.2 there is a one-off constant for this that I use:
com.ibm.team.filesystem.common.workitems.ILinkConstants.CHANGESET_WORKITEM_LINKTYPE_ID This link type had been defined since 3.x version. For what I know it does not appear on 2.x version so it has to be set manually.
Why the We found only these package com.ibm.team.workitem.common.model; Or instead the Thanks in advance. Comments
SEC Servizi
commented Oct 19 '12, 10:03 a.m.
Thanks Jason, that is the class we was looking for. |
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.