How to retrieve IBaseLineSetHandle from URI (rather than UUID) ?
Jazzers,
currently I am passing to my class a String which is the UUID of a snapshot.
I am then transforming it to UUID snapId = UUID.valueOf(String)
and finding the snapshot item handle by means of:
IBaselineSetHandle snapshotHandle = (IBaselineSetHandle) IBaselineSet.ITEM_TYPE.createItemHandle(snapId, null);
This works pretty well but I really would like to pass the full URI to the snapshot object rather than the UUID for various reasons. Is there any easy out of the box way of obtaining an ItemHandle from the URI of an object? Or do I need to write a parser for the URI, keeping in mind that while the UUID starts with _ there might be plenty _ elsewhere in the URI?
If you know a call or have such a parser please share.
Best,
Arne
currently I am passing to my class a String which is the UUID of a snapshot.
I am then transforming it to UUID snapId = UUID.valueOf(String)
and finding the snapshot item handle by means of:
IBaselineSetHandle snapshotHandle = (IBaselineSetHandle) IBaselineSet.ITEM_TYPE.createItemHandle(snapId, null);
This works pretty well but I really would like to pass the full URI to the snapshot object rather than the UUID for various reasons. Is there any easy out of the box way of obtaining an ItemHandle from the URI of an object? Or do I need to write a parser for the URI, keeping in mind that while the UUID starts with _ there might be plenty _ elsewhere in the URI?
If you know a call or have such a parser please share.
Best,
Arne
Accepted answer
Thanks to Michael Valenta I was able to find an easy way to achieve this. This is the code snippet:
URI snapUri= URI.create(snapshotIdentifier.replaceAll(" ", "%20"));
Location snapLoc = Location.location(snapUri);
IBaselineSet snapshotItem = (IBaselineSet)
teamRepository.itemManager().fetchCompleteItem(snapLoc,IItemManager.DEFAULT, monitor);
The advantage of passing a snapshot URI rather than the UUID is that the URI can be easily retrieved e.g. from Snapshot Context Menu (copy URL).
- Arne
URI snapUri= URI.create(snapshotIdentifier.replaceAll(" ", "%20"));
Location snapLoc = Location.location(snapUri);
IBaselineSet snapshotItem = (IBaselineSet)
teamRepository.itemManager().fetchCompleteItem(snapLoc,IItemManager.DEFAULT, monitor);
The advantage of passing a snapshot URI rather than the UUID is that the URI can be easily retrieved e.g. from Snapshot Context Menu (copy URL).
- Arne
One other answer
how is it that u have the URI? but not the UUID?