It's all about the answers!

Ask a question

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


Gou Peng (191) | asked Oct 05, 12:25 a.m.

Hi

I can use the IComponent  get the InitialBaseline ,how can i get all the baseline names of the component use RTC-SDK-Server-6.0.6.1 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.3k7) | answered Oct 05, 10:21 a.m.
FORUM MODERATOR / JAZZ DEVELOPER

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

Gou Peng selected this answer as the correct answer

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

sorry, we can not use the internal api .

com.ibm.team.scm.common.internal.IScmQueryService; 
Do you have any other way?


David Lafreniere commented Oct 05, 12:07 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
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, 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, 1:19 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
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.