It's all about the answers!

Ask a question

how can i get all the baseline names of the component use RTC-SDK-Server- api

Gou Peng (216) | asked Oct 05 '19, 12:25 a.m.


I can use the IComponent  get the InitialBaseline ,how can i get all the baseline names of the component use RTC-SDK-Server- api

IRepositoryItemService itemService=getService(IRepositoryItemService.class);
IComponent this_component = (IComponent)item; 
IBaselineHandle this_baselineHandle = this_component.getInitialBaseline();
IBaseline  this_baseline = (IBaseline) itemService.fetchItem(this_baseline, IRepositoryItemService.COMPLETE);

Accepted answer

permanent link
David Lafreniere (4.8k7) | answered Oct 05 '19, 10:21 a.m.

Try IScmQueryService.findBaselines(), and in the IBaselineSearchCriteria just fill in the .setComponentRequired()

Gou Peng selected this answer as the correct answer

Gou Peng commented Oct 05 '19, 11:42 a.m.

sorry, we can not use the internal api .; 
Do you have any other way?

David Lafreniere commented Oct 05 '19, 12:07 p.m.
Not that it's helpful for your specific question, but just to add more related information on this post: If you were client side, you would use this official API: IWorkspaceManager.findBaselines().

Unfortunately I'm not familiar with writing raw queries on the server to return what you need (hopefully someone else sees this and posts an example), I also would recommend scanning other questions on the forum to see if there are examples.

Note: Generally speaking, we treat IScmQueryService as though it were API for the most part (even though as you pointed out, it's in an internal package). Most of the API has been around for years, and you'll notice if enhancements are needed, we deprecate the API (preserving behavior) and write new API.

Gou Peng commented Oct 09 '19, 11:44 a.m.
thanks for your reply.
1.I have try the way you recommend. but the IProgressMonitor monitor can not be cast to (IRepositoryProgressMonitorHandle) monitor. The code is as follows 
2.Is there a way to directly query current project components and component baselines? I need to get the Baselineid (_vmPE0OcgEem5aNhmIyAYBQ)

public class DownloadURLAdvistor extends AbstractService implements
IOperationAdvisor {
public void run(AdvisableOperation operation,
IProcessConfigurationElement advisorConfiguration,
IAdvisorInfoCollector collector, IProgressMonitor monitor)
IWorkItem newWorkItem = (IWorkItem) auditable;
 IScmQueryService scm = getService(IScmQueryService.class);
 IComponentSearchCriteria criteria = IComponentSearchCriteria.FACTORY.newInstance();
 scm.findComponents(criteria, 1000,  (IRepositoryProgressMonitorHandle) monitor);

David Lafreniere commented Oct 09 '19, 1:19 p.m.
1. Yes, IProgressMonitor and IRepositoryProgressMonitor are different.

You can create one using:
    private IRepositoryProgressMonitor getRepoMonitor(IProgressMonitor monitor) {
        return IRepositoryProgressMonitor.ITEM_FACTORY.createItem(monitor == null ? new NullProgressMonitor() : monitor);

2. IComponentSearchCriteria.getFilterByOwnerOptional().. you add to that collection the IProjectAreaHandles or ITeamAreaHandles. This will return all components owned by those process areas.

Then use as suggested, IBaselineSearchCriteria.setComponentRequired() to return all baselines in that component. It will return handles (so you'll have only the itemID), you then simply fetch the full IBaseline from the handles, and IBaseline.getName() has the name.

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.