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

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

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?

0 votes


Accepted answer

Permanent link
With your IBaselineSet that represents the snapshot, you can call #getBaselines().
David Lafreniere selected this answer as the correct answer

0 votes

Comments

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);
    <continue...>
}







-1 votes

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().


One other answer

Permanent link

  Hello Guys,


I am able to fetch the list of snapshots from a given stream programmatically but I am unable to fetch the list of components within a snapshot. I need to copy some files from one component in the snapshot to a component outside the snapshot(in another stream)...

Please help...

0 votes

Comments

When you have a snapshot (IBaselineSet) you will need to fetch the full IBaseline objects (from the handles of IBaselineSet.getBaselines()). From there, you can get the component using IBaseline.getComponent().

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,934
× 1,202
× 74

Question asked: May 28 '14, 9:49 a.m.

Question was seen: 6,240 times

Last updated: Feb 01 '21, 3:15 p.m.

Confirmation Cancel Confirm