It's all about the answers!

Ask a question

How to query for projects that contain empty components

michael entler (171227) | asked Sep 24 '15, 5:47 p.m.

I'm currently on RTC 3, but this is a question for 5, which we will upgrade to soon.

I'm looking for a way to search across all our projects(or just all of RTC repository) for Empty Components, to see which projects are not effectively checking in code, or components that just aren't in use.

Is there way to do this simply?

One answer

permanent link
Kohji Ohsawa (5951310) | answered Sep 24 '15, 8:06 p.m.
Hi Michael,

I am not aware a simple way on RTC except writing a simple code with SDK. With using SDK, you can count the number of change sets in a component. If it is zero that means there is no changesets in a component. I hope it might help you.

private static int countChangesets(IProjectArea projectArea) throws TeamRepositoryException {
IProgressMonitor monitor = new NullProgressMonitor();
ITeamRepository repository = (ITeamRepository)projectArea.getOrigin(); 
IWorkspaceManager workspaceManager = SCMPlatform.getWorkspaceManager(repository);
IWorkspaceSearchCriteria wsSearchCriteria = WorkspaceSearchCriteria.FACTORY.newInstance();
IChangeSetSearchCriteria changesetCriteria = IChangeSetSearchCriteria.FACTORY.newInstance(); 
int numberOfChangesets = 0;
List <IWorkspaceHandle> workspaceHandles = workspaceManager.findWorkspaces(wsSearchCriteria, Integer.MAX_VALUE, monitor);
for (IWorkspaceHandle workspaceHandle: workspaceHandles) {
IWorkspaceConnection workspaceConnection = workspaceManager.getWorkspaceConnection(workspaceHandle, null);
List componentList = workspaceConnection.getComponents();
for (Object obj : componentList) {
IComponentHandle componentHandle = (IComponentHandle)obj;
IComponent component = (IComponent)repository.itemManager().fetchCompleteItem(componentHandle, IItemManager.DEFAULT, monitor);
List<IChangeSetHandle> changeSetList = SCMPlatform.getWorkspaceManager(repository).findChangeSets(changesetCriteria, IWorkspaceManager.MAX_QUERY_SIZE, null); 
numberOfChangesets = numberOfChangesets + changeSetList.size();
return numberOfChangesets;

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.