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

RTC - IOperationParticipant - operation.workItemSave - Resolve IVersionable path

Hello,

I'm trying to read the full path from the files associated via changeset to a workitem. In this case it will trigger as a participant on an operation.workItemSave operation. After getting the path it will do some modifications on the work item attributes.

Right now I can get the list changesets and its changes. But I don't know how to resolve the path.

The code I have:

run(){
IWorkItem workitem = (IWorkItem) ((ISaveParameter) data).getNewState();<-OK
List<IChange> changes = getIChangeSets(workitem);<-OK
List<IVersionable> versionables = getIVersionables();<-OK
resolvePath();<-?
};

I managed to get the iversionable, but don't know how to resolve IFolderHandle

private String resolvePath(IVersionable versionable){    
    IFolderHandle folderHandle = versionable.getParent();
    //How do i resolve ifolderHandle? 
}

After getting the IFolder i would climb the tree and build the path.

From the examples I found in the forum.
There is a "IScmService.configurationResolvePath" method to resolve the path, but it needs a ServiceConfigurationProvider which in turn is provided by a IWorkspace.

If this was a DeliverOperationData I could get the configuration, but this "data" is a IWorkItem.

Is it possible to get the full path of a file associated to a workitem?

Any help is welcome. Thanks!

0 votes



2 answers

Permanent link
The IVersionableItemHandle could be either a IFolderHandle or a IFileItemHandle so you can just cast it after an "if instanceof" check.

0 votes


Permanent link
The only way to compute a pathname from an IVersionableHandle is to provide  a Workspace (or Stream or Snapshot/Baseline) context, because the pathname for a file depends on what folder versions are selected for the parent folders (a file version only knows the UUID of its immediate parent folder, and it's name relative to that parent folder ... the additional folders and relative names for the rest of the pathname can only be determined if you know what version to use of those parent folders.

So if all you have is a work item (and not a workspace, stream, or snapshot/baseline), you cannot compute a pathname.

0 votes

Comments

Hello Geoffrey and thank you for providing feedback.
I was thinking about this, provide a stream. Server side -  is there any way to search for a stream based on name? (one of the attributes of the workitem is the exact name of the stream)
Client side I would use:
IWorkspaceSearchCriteria searchCriteria;
searchCriteria.setKind(IWorkspaceSearchCriteria.STREAMS);
List<IWorkspaceHandle> results = IWorkspaceManager.findWorkspaces(searchCriteria);
Iterate the result and find the match.

But I can't find how to do this server-side.
Thank you

I know there must be a way to find a stream by name on the server, but we'll need one of the API experts to provide a pointer.   Note that stream names are not guaranteed to be unique, so it might return multiple streams.

but remember, streams are not located anywhere in the file system, so the path i useless there too.

you 'might' be able to get the path from the root of the workspace(aka stream).
but you will probably have to go thru the component to get it.

you will have to find the ScmService on the server side, like ScmPlatform on the client side. not all the apis are symetrical

getService(IScmService.class)
note that you will need to reference this in your plugin.xml

@gmclemm
We know the correct way should be searching by UUID but one of the conditions when creating streams is the name must be unique.

@sdetweil
We use IScmService to fetch the IVersionables (IScmService.fetchState(handle)) but none of the methods provided by IScmService is able to search for IWorkspace. We are using RTC 4.0.6, probably a newer API can provide this.

Thank you all for helping, I'll leave the question open in case someone knows a "workaround".



Streams (and workspace) could be searched using IScmQueryService.findWorkspaces method. You need a IWorkspaceSearchCriteria that you can get using its factory. In this object you can set which type of workspace (stream or not) you are searching and the name of the searched object.
In order to search for the complete path (relative to the workspace) I suggest you to use  scmService.configurationDetermineAncestorsInHistory method that gives you a more reliable INameItemPair list. Every object of this list is a node of the path from the component root. You have to get the name of the element and using concatenation to obtain a full path.

@mikyjpeg
Thank you, IScmQueryService can provide me the workspace (stream), now I can resolve the path.








showing 5 of 6 show 1 more comments

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
× 10,937

Question asked: Jan 21 '16, 12:15 p.m.

Question was seen: 2,406 times

Last updated: Jan 25 '16, 6:12 a.m.

Confirmation Cancel Confirm