Search in sources :

Example 1 with FilePathWithHashDto

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);
    }
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) FilePathWithHashDto(org.sonar.db.component.FilePathWithHashDto) FileData(org.sonar.scanner.protocol.input.FileData)

Example 2 with FilePathWithHashDto

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;
    }
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) FilePathWithHashDto(org.sonar.db.component.FilePathWithHashDto) Date(java.util.Date) DbSession(org.sonar.db.DbSession) ProjectRepositories(org.sonar.scanner.protocol.input.ProjectRepositories) PropertyDto(org.sonar.db.property.PropertyDto)

Aggregations

ComponentDto (org.sonar.db.component.ComponentDto)2 FilePathWithHashDto (org.sonar.db.component.FilePathWithHashDto)2 Date (java.util.Date)1 DbSession (org.sonar.db.DbSession)1 PropertyDto (org.sonar.db.property.PropertyDto)1 FileData (org.sonar.scanner.protocol.input.FileData)1 ProjectRepositories (org.sonar.scanner.protocol.input.ProjectRepositories)1