Search in sources :

Example 1 with ComponentRootBuilder

use of org.sonar.server.computation.task.projectanalysis.component.ComponentRootBuilder in project sonarqube by SonarSource.

the class BuildComponentTreeStep method execute.

@Override
public void execute() {
    String branch = analysisMetadataHolder.getBranch();
    ScannerReport.Component reportProject = reportReader.readComponent(analysisMetadataHolder.getRootComponentRef());
    String projectKey = createKey(reportProject.getKey(), branch);
    UuidFactory uuidFactory = new UuidFactory(dbClient, projectKey);
    try (DbSession dbSession = dbClient.openSession(false)) {
        BaseAnalysisSupplier baseAnalysisSupplier = new BaseAnalysisSupplier(dbClient, dbSession);
        ComponentRootBuilder rootBuilder = new ComponentRootBuilder(branch, uuidFactory::getOrCreateForKey, reportReader::readComponent, () -> dbClient.componentDao().selectByKey(dbSession, projectKey), baseAnalysisSupplier);
        Component project = rootBuilder.build(reportProject, projectKey);
        treeRootHolder.setRoot(project);
        analysisMetadataHolder.setBaseAnalysis(toAnalysis(baseAnalysisSupplier.apply(project.getUuid())));
    }
}
Also used : DbSession(org.sonar.db.DbSession) UuidFactory(org.sonar.server.computation.task.projectanalysis.component.UuidFactory) ScannerReport(org.sonar.scanner.protocol.output.ScannerReport) ComponentRootBuilder(org.sonar.server.computation.task.projectanalysis.component.ComponentRootBuilder) Component(org.sonar.server.computation.task.projectanalysis.component.Component)

Aggregations

DbSession (org.sonar.db.DbSession)1 ScannerReport (org.sonar.scanner.protocol.output.ScannerReport)1 Component (org.sonar.server.computation.task.projectanalysis.component.Component)1 ComponentRootBuilder (org.sonar.server.computation.task.projectanalysis.component.ComponentRootBuilder)1 UuidFactory (org.sonar.server.computation.task.projectanalysis.component.UuidFactory)1