Daniel Ferber
Daniel Ferber

Reputation: 311

Jazz RTC Java API: How to list Components owned by a Project Area

I am working an automation for IBM Rational Team Concert (IBM aka Jazz RTC).

How may one a list all components owned by a specific project area? Which are the required API calls?

I could not find any getters in the IProjectArea instance, nor service or client instances with such methods. And I could not figure out how to use IComponentSearchCriteria for this purpose.

Upvotes: 1

Views: 533

Answers (1)

Daniel Ferber
Daniel Ferber

Reputation: 311

The components owned by a project area may be queried using IComponentSearchCriteria. However, the API is not quite clear how to specify the owning project area.

  1. Get the IWorkspaceManager from the ITeamRepository, which contains the findComponents method.
  2. Get the IProjectAreaHandle for your project area. I you have only the project area name, check this question to learn how to get the IProjectAreaHandle for the project area name.
  3. Create a IComponentSearchCriteria and set the filterByOwnerOptional to your IProjectAreaHandle instance.
  4. Call IWorkspaceManager.findComponents(...) to get a list of IComponentHandles. The first parameter is the search criteria. Se second parameter is the maximum number of results (which I set to IWorkspaceManager.MAX_QUERY_SIZE, which is 512. The third parameter is the progress monitor, which may be null.
  5. If you need to get component name, description or other attributes, then you need to call IItemManager.fetchCompleteItems(...) fetch the full IComponent instances.

Here is an example in Groovy:

List<IComponentHandle> listComponents(String projectAreaName) {
    final manager = repositoty.getClientLibrary(IWorkspaceManager) as IWorkspaceManager;
    final criteria = IComponentSearchCriteria.FACTORY.newInstance();
    final IProjectArea projectArea = findProjectAreaByName(projectAreaName)
    criteria.filterByOwnerOptional.add(projectArea)
    final List<IComponentHandle> handles =  manager.findComponents(criteria, IWorkspaceManager.MAX_QUERY_SIZE, null)
    final itemManager = repositoty.itemManager()
    return itemManager.fetchCompleteItems(handles, IItemManager.DEFAULT, null) as List<IComponent>
}

Upvotes: 2

Related Questions