use of org.sonar.db.component.FilePathWithHashDto in project sonarqube by SonarSource.
the class ProjectDataLoader method addFileData.
private static void addFileData(ProjectRepositories data, List<ComponentDto> moduleChildren, List<FilePathWithHashDto> files) {
Map<String, String> moduleKeysByUuid = newHashMap();
for (ComponentDto module : moduleChildren) {
moduleKeysByUuid.put(module.uuid(), module.key());
}
for (FilePathWithHashDto file : files) {
FileData fileData = new FileData(file.getSrcHash(), file.getRevision());
data.addFileData(moduleKeysByUuid.get(file.getModuleUuid()), file.getPath(), fileData);
}
}
use of org.sonar.db.component.FilePathWithHashDto in project sonarqube by SonarSource.
the class ProjectDataLoader method load.
public ProjectRepositories load(ProjectDataQuery query) {
try (DbSession session = dbClient.openSession(false)) {
ProjectRepositories data = new ProjectRepositories();
ComponentDto module = checkFoundWithOptional(dbClient.componentDao().selectByKey(session, query.getModuleKey()), "Project or module with key '%s' is not found", query.getModuleKey());
checkRequest(isProjectOrModule(module), "Key '%s' belongs to a component which is not a Project", query.getModuleKey());
boolean hasScanPerm = userSession.hasComponentPermission(SCAN_EXECUTION, module) || userSession.hasPermission(OrganizationPermission.SCAN, module.getOrganizationUuid());
boolean hasBrowsePerm = userSession.hasComponentPermission(USER, module);
checkPermission(query.isIssuesMode(), hasScanPerm, hasBrowsePerm);
ComponentDto project = getProject(module, session);
if (!project.key().equals(module.key())) {
addSettings(data, module.getKey(), getSettingsFromParents(module, hasScanPerm, session));
}
List<ComponentDto> modulesTree = dbClient.componentDao().selectEnabledDescendantModules(session, module.uuid());
Map<String, String> moduleUuidsByKey = moduleUuidsByKey(modulesTree);
Map<String, Long> moduleIdsByKey = moduleIdsByKey(modulesTree);
List<PropertyDto> modulesTreeSettings = dbClient.propertiesDao().selectEnabledDescendantModuleProperties(module.uuid(), session);
TreeModuleSettings treeModuleSettings = new TreeModuleSettings(moduleUuidsByKey, moduleIdsByKey, modulesTree, modulesTreeSettings);
addSettingsToChildrenModules(data, query.getModuleKey(), Maps.<String, String>newHashMap(), treeModuleSettings, hasScanPerm);
List<FilePathWithHashDto> files = searchFilesWithHashAndRevision(session, module);
addFileData(data, modulesTree, files);
// FIXME need real value but actually only used to know if there is a previous analysis in local issue tracking mode so any value is
// ok
data.setLastAnalysisDate(new Date());
return data;
}
}
Aggregations