How to query for projects that contain empty components
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
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();
wsSearchCriteria.setKind(IWorkspaceSearchCriteria.ALL);
wsSearchCriteria.setPartialOwnerNameIgnoreCase(projectArea.getName());
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);
changesetCriteria.setComponent(component);
List<IChangeSetHandle> changeSetList = SCMPlatform.getWorkspaceManager(repository).findChangeSets(changesetCriteria, IWorkspaceManager.MAX_QUERY_SIZE, null);
numberOfChangesets = numberOfChangesets + changeSetList.size();
}
}
return numberOfChangesets;
}
|
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.