It's all about the answers!

Ask a question

Getting a change set handle from a change set id


Doug Effler (131) | asked Mar 23 '16, 6:32 p.m.

I'm working on some configuration management tools to interface with RTC using the Plain Java Libraries. I have a change set id -- like "_ZYdu...pakQ" -- that was saved off when we added change sets to RTC. I want to later use that change set ID to get the IChangeSetHandle to link our tools back to RTC. I think I have the first and last bits figured out:

String changeSetId = "something"

IWorkspaceManager wm = SCMPlatform.getWorkspaceManager(REPO);

IChangeSetSearchCriteria criteria = IChangeSetSearchCriteria.FACTORY.newInstance();

???????????????

List<IChangeSetHandle> results = wm.findChangeSets(changeSetCriteria, IWorkspaceManager.MAX_QUERY_SIZE, MONITOR);

IChangeSetHandle handle = results.get(0); //Should only be one match with that ID

...but I can't figure out the middle part to define the criteria. I tried:

criteria.setSourceId(UUID.valueOf(changeSetId));

...but that didn't work. What am I missing?

Accepted answer


permanent link
Michele Pegoraro (1.8k12114101) | answered Mar 24 '16, 6:29 a.m.
Generally the way to get an object from its UUID is the following:

ObjectInterface.ITEM_TYPE.createItemHandle(UUID.valueOf(uuidValue), null);

In your case it will be

IChangeSetHandle handle = (IChangeSetHandle) IChangeSet.ITEM_TYPE.createItemHandle(UUID.valueOf("_ZYdu...pakQ"), null);

Michele.
Doug Effler selected this answer as the correct answer

Comments
Doug Effler commented Mar 24 '16, 10:20 a.m.

That worked for me. Thank you very much. :-D

Your answer


Register or to post your answer.