@Override
protected List<DefaultIssue> loadIssues() {
List<DefaultIssue> result = new ArrayList<>();
try (DbSession dbSession = dbClient.openSession(false)) {
Set<String> dirOrModulesUuidsWithIssues = dbClient.issueDao().selectModuleAndDirComponentUuidsOfOpenIssuesForProjectUuid(dbSession, component.getUuid());
if (!dirOrModulesUuidsWithIssues.isEmpty()) {
Map<String, String> pathByModuleKey = reportModulesPath.get();
Map<String, ComponentDto> modulesByUuid = dbClient.componentDao().selectProjectAndModulesFromProjectKey(dbSession, component.getDbKey(), true)
.stream().collect(Collectors.toMap(ComponentDto::uuid, Function.identity()));
List<ComponentDto> dirOrModulesWithIssues = dbClient.componentDao().selectByUuids(dbSession, dirOrModulesUuidsWithIssues);
dirOrModulesWithIssues.forEach(c -> {
List<DefaultIssue> issuesOnModuleOrDir = issuesLoader.loadOpenIssues(c.uuid());
String moduleOrDirProjectRelativePath = c.qualifier().equals(Qualifiers.MODULE) ? buildModuleProjectRelativePath(pathByModuleKey, c)
: buildDirectoryProjectRelativePath(pathByModuleKey, c, modulesByUuid.get(c.moduleUuid()));
result.addAll(migrateIssuesToTheRoot(issuesOnModuleOrDir, moduleOrDirProjectRelativePath));
componentsWithUnprocessedIssues.remove(c.uuid());
});
}
result.addAll(issuesLoader.loadOpenIssues(effectiveUuid));
return result;
}
}