use of org.sonar.db.component.ComponentDto 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.ComponentDto 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;
}
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class ProjectDataLoader method getSettingsFromParents.
private Map<String, String> getSettingsFromParents(ComponentDto module, boolean hasScanPerm, DbSession session) {
List<ComponentDto> parents = newArrayList();
aggregateParentModules(module, parents, session);
Collections.reverse(parents);
Map<String, String> parentProperties = newHashMap();
for (ComponentDto parent : parents) {
parentProperties.putAll(getPropertiesMap(dbClient.propertiesDao().selectProjectProperties(session, parent.key()), hasScanPerm));
}
return parentProperties;
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class ProjectDataLoader method addSettingsToChildrenModules.
private static void addSettingsToChildrenModules(ProjectRepositories ref, String moduleKey, Map<String, String> parentProperties, TreeModuleSettings treeModuleSettings, boolean hasScanPerm) {
Map<String, String> currentParentProperties = newHashMap();
currentParentProperties.putAll(parentProperties);
currentParentProperties.putAll(getPropertiesMap(treeModuleSettings.findModuleSettings(moduleKey), hasScanPerm));
addSettings(ref, moduleKey, currentParentProperties);
for (ComponentDto childModule : treeModuleSettings.findChildrenModule(moduleKey)) {
addSettings(ref, childModule.getKey(), currentParentProperties);
addSettingsToChildrenModules(ref, childModule.getKey(), currentParentProperties, treeModuleSettings, hasScanPerm);
}
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class ProjectDataLoader method aggregateParentModules.
private void aggregateParentModules(ComponentDto component, List<ComponentDto> parents, DbSession session) {
String moduleUuid = component.moduleUuid();
if (moduleUuid != null) {
ComponentDto parent = dbClient.componentDao().selectOrFailByUuid(session, moduleUuid);
if (parent != null) {
parents.add(parent);
aggregateParentModules(parent, parents, session);
}
}
}
Aggregations