It's all about the answers!

Ask a question

How to list the component baselines in a snapshot using Java API?

Ratheesh P (3536) | asked May 28 '14, 9:49 a.m.
edited Jul 26 '16, 10:34 a.m. by David Lafreniere (4.4k7)
How can I list the component baselines in a stream snapshot using plain java API's?
We could use the command line "lscm list components <snapshot alias/name/uuid> --snapshot" but how is same possible using java API?

Accepted answer

permanent link
Tim Mok (6.6k38) | answered May 28 '14, 4:28 p.m.
With your IBaselineSet that represents the snapshot, you can call #getBaselines().
David Lafreniere selected this answer as the correct answer

One other answer

permanent link
Pietro Bottino (3513) | answered Jul 26 '16, 9:44 a.m.
Good morning.

Incrementing the Tim's answer, try it this:

IComponentHandle componentHandle = changeSet.getComponent();
IComponent component = (IComponent) itemService.fetchItem(componentHandle, IRepositoryItemService.COMPLETE);
ServiceHistoryProvider targetHistory = ServiceHistoryProvider.FACTORY.create(workspace, changeSet.getComponent());
BaselinesInHistoryResult baselinesInHistory = scmService.getBaselinesInHistory(targetHistory, Integer.MAX_VALUE, null, null);
List<IBaselineHandle> baselines = baselinesInHistory.getBaselines();
for (IBaselineHandle baselineHandle : baselines) {   
    IBaseline baseline = (IBaseline) itemService.fetchItem(baselineHandle,IRepositoryItemService.COMPLETE);

David Lafreniere commented Jul 26 '16, 10:41 a.m.

Just to make it clear for readers: This code shows how, on the server, one would fetch the baselines in the history of some workspace or stream. The question is asking how to get the baselines of a given snapshot, which would be IBaselineSet.getBaselines().

Your answer

Register or to post your answer.