Search in sources :

Example 6 with DepthTraversalTypeAwareCrawler

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

the class FileMoveDetectionStep method getReportFilesByKey.

private static Map<String, Component> getReportFilesByKey(Component root) {
    final ImmutableMap.Builder<String, Component> builder = ImmutableMap.builder();
    new DepthTraversalTypeAwareCrawler(new TypeAwareVisitorAdapter(CrawlerDepthLimit.FILE, POST_ORDER) {

        @Override
        public void visitFile(Component file) {
            builder.put(file.getKey(), file);
        }
    }).visit(root);
    return builder.build();
}
Also used : DepthTraversalTypeAwareCrawler(org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler) TypeAwareVisitorAdapter(org.sonar.server.computation.task.projectanalysis.component.TypeAwareVisitorAdapter) Component(org.sonar.server.computation.task.projectanalysis.component.Component) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 7 with DepthTraversalTypeAwareCrawler

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

the class PersistEventsStep method execute.

@Override
public void execute() {
    try (DbSession dbSession = dbClient.openSession(false)) {
        long analysisDate = analysisMetadataHolder.getAnalysisDate();
        new DepthTraversalTypeAwareCrawler(new PersistEventComponentVisitor(dbSession, analysisDate)).visit(treeRootHolder.getRoot());
        dbSession.commit();
    }
}
Also used : DbSession(org.sonar.db.DbSession) DepthTraversalTypeAwareCrawler(org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler)

Example 8 with DepthTraversalTypeAwareCrawler

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

the class PersistMeasuresStep method execute.

@Override
public void execute() {
    DbSession dbSession = dbClient.openSession(true);
    try {
        new DepthTraversalTypeAwareCrawler(new MeasureVisitor(dbSession)).visit(treeRootHolder.getRoot());
        dbSession.commit();
    } finally {
        dbSession.close();
    }
}
Also used : DbSession(org.sonar.db.DbSession) DepthTraversalTypeAwareCrawler(org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler)

Example 9 with DepthTraversalTypeAwareCrawler

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

the class LoadDuplicationsFromReportStep method execute.

@Override
public void execute() {
    new DepthTraversalTypeAwareCrawler(new TypeAwareVisitorAdapter(CrawlerDepthLimit.FILE, POST_ORDER) {

        @Override
        public void visitFile(Component file) {
            CloseableIterator<ScannerReport.Duplication> duplications = batchReportReader.readComponentDuplications(file.getReportAttributes().getRef());
            try {
                int idGenerator = 1;
                while (duplications.hasNext()) {
                    loadDuplications(file, duplications.next(), idGenerator);
                    idGenerator++;
                }
            } finally {
                duplications.close();
            }
        }
    }).visit(treeRootHolder.getRoot());
}
Also used : Duplication(org.sonar.server.computation.task.projectanalysis.duplication.Duplication) DepthTraversalTypeAwareCrawler(org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler) TypeAwareVisitorAdapter(org.sonar.server.computation.task.projectanalysis.component.TypeAwareVisitorAdapter) Component(org.sonar.server.computation.task.projectanalysis.component.Component)

Example 10 with DepthTraversalTypeAwareCrawler

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

the class PersistAnalysisStep method execute.

@Override
public void execute() {
    try (DbSession dbSession = dbClient.openSession(false)) {
        new DepthTraversalTypeAwareCrawler(new PersistSnapshotsPathAwareVisitor(dbSession, analysisMetadataHolder.getAnalysisDate())).visit(treeRootHolder.getRoot());
        dbSession.commit();
    }
}
Also used : DbSession(org.sonar.db.DbSession) DepthTraversalTypeAwareCrawler(org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler)

Aggregations

DepthTraversalTypeAwareCrawler (org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler)10 DbSession (org.sonar.db.DbSession)8 Component (org.sonar.server.computation.task.projectanalysis.component.Component)4 TypeAwareVisitorAdapter (org.sonar.server.computation.task.projectanalysis.component.TypeAwareVisitorAdapter)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 ComponentDto (org.sonar.db.component.ComponentDto)1 Duplication (org.sonar.server.computation.task.projectanalysis.duplication.Duplication)1 Metric (org.sonar.server.computation.task.projectanalysis.metric.Metric)1