It's all about the answers!

Ask a question

How to fetch Iversionable/IfileItem of a file by passing itemid and stateid of the file


akshay p (15119) | asked Feb 11 '19, 4:36 a.m.
edited Feb 11 '19, 6:40 p.m. by Fariz Saracevic (919613)

Is there any way i can get the IFileItem or Iversionable just by knowing ITEM id and state id ?

Accepted answer


permanent link
David Lafreniere (4.8k7) | answered Feb 12 '19, 2:10 p.m.
FORUM MODERATOR / JAZZ DEVELOPER

UUID itemId = getFileItemId();
UUID stateId = getFileState();
IComponentHandle componentHandle = getComponentHandle();
IWorkspaceConnection workspaceConnection = getWorkspaceConnection();


IFileItemHandle fileItemHandle = (IFileItemHandle) IFileItem.ITEM_TYPE.createItemHandle(itemId, stateId);
IFileItem file = (IFileItem) workspaceConnection.configuration(componentHandle).fetchCompleteItem(fileItemHandle, monitor);

Ralph Schoon selected this answer as the correct answer

Comments
akshay p commented Feb 13 '19, 3:09 a.m.
Currently i am taking State id and item id of a file from different location and these two parameters are of String type. How i can convert them into UUID type.

and one more thing is that, i have various baselines of same component and snapshots of streams. SO i don't want to pass/specify any specific component or stream as a input parameter.

I want to retrieve the file irrespective of streams, snapshots, baselines and JUST WANT TO USE UUID of ITEM ID AND STATE ID

Ralph Schoon commented Feb 13 '19, 3:32 a.m. | edited Feb 13 '19, 3:32 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

David Lafreniere commented Feb 13 '19, 4:57 p.m. | edited Feb 21 '19, 12:26 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
The server API is: IScmService.fetchState(...)

Or from the client API you can call:
IVersionableManager vmgr = SCMPlatform.getWorkspaceManager(repo).versionableManager();
IVersionable versionable = vmgr.fetchCompleteState(versionableHandle, monitor);

akshay p commented Feb 21 '19, 12:21 a.m.

how i can get relative path of the file?


David Lafreniere commented Feb 21 '19, 12:25 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
You can use:

IScmService.configurationLocateAncestors(...)

or

IScmService.configurationDetermineAncestorsInHistory(...)  (this will give you the path of a file even if it was recently deleted in the stream - it goes through the change set history to try to find the path 'where the file used to be).

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.