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.
- Get the
IWorkspaceManager
from the ITeamRepository
, which contains the findComponents
method.
- 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.
- Create a
IComponentSearchCriteria
and set the filterByOwnerOptional
to your IProjectAreaHandle
instance.
- 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
.
- 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>
}