Search in sources :

Example 26 with DbSession

use of org.sonar.db.DbSession in project sonarqube by SonarSource.

the class PersistCrossProjectDuplicationIndexStep method execute.

@Override
public void execute() {
    if (!crossProjectDuplicationStatusHolder.isEnabled()) {
        return;
    }
    try (DbSession dbSession = dbClient.openSession(true)) {
        Component project = treeRootHolder.getRoot();
        new DepthTraversalTypeAwareCrawler(new DuplicationVisitor(dbSession, analysisMetadataHolder.getUuid())).visit(project);
        dbSession.commit();
    }
}
Also used : DbSession(org.sonar.db.DbSession) DepthTraversalTypeAwareCrawler(org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler) Component(org.sonar.server.computation.task.projectanalysis.component.Component)

Example 27 with DbSession

use of org.sonar.db.DbSession in project sonarqube by SonarSource.

the class PersistProjectLinksStep method execute.

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

Example 28 with DbSession

use of org.sonar.db.DbSession in project sonarqube by SonarSource.

the class PersistTestsStep method execute.

@Override
public void execute() {
    try (DbSession dbSession = dbClient.openSession(true)) {
        TestDepthTraversalTypeAwareVisitor visitor = new TestDepthTraversalTypeAwareVisitor(dbSession);
        new DepthTraversalTypeAwareCrawler(visitor).visit(treeRootHolder.getRoot());
        dbSession.commit();
        if (visitor.hasUnprocessedCoverageDetails) {
            LOG.warn("Some coverage tests are not taken into account during analysis of project '{}'", visitor.getProjectKey());
        }
    }
}
Also used : DbSession(org.sonar.db.DbSession) DepthTraversalTypeAwareCrawler(org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler)

Example 29 with DbSession

use of org.sonar.db.DbSession in project sonarqube by SonarSource.

the class PurgeDatastoresStep method execute.

private void execute(Component root) {
    try (DbSession dbSession = dbClient.openSession(true)) {
        IdUuidPair idUuidPair = new IdUuidPair(dbIdsRepository.getComponentId(root), root.getUuid());
        projectCleaner.purge(dbSession, idUuidPair, settingsRepository.getSettings(root), disabledComponentsHolder.getUuids());
        dbSession.commit();
    }
}
Also used : DbSession(org.sonar.db.DbSession) IdUuidPair(org.sonar.db.purge.IdUuidPair)

Example 30 with DbSession

use of org.sonar.db.DbSession in project sonarqube by SonarSource.

the class UpdateQualityProfilesLastUsedDateStep method execute.

@Override
public void execute() {
    try (DbSession dbSession = dbClient.openSession(true)) {
        Component root = treeRootHolder.getRoot();
        Metric metric = metricRepository.getByKey(QUALITY_PROFILES_KEY);
        Set<QualityProfile> qualityProfiles = parseQualityProfiles(measureRepository.getRawMeasure(root, metric));
        if (qualityProfiles.isEmpty()) {
            return;
        }
        List<QualityProfileDto> dtos = dbClient.qualityProfileDao().selectByKeys(dbSession, qualityProfiles.stream().map(QualityProfile::getQpKey).collect(Collectors.toList()));
        dtos.addAll(getAncestors(dbSession, dtos));
        long analysisDate = analysisMetadataHolder.getAnalysisDate();
        dtos.forEach(dto -> {
            dto.setLastUsed(analysisDate);
            dbClient.qualityProfileDao().update(dbSession, dto);
        });
        dbSession.commit();
    }
}
Also used : DbSession(org.sonar.db.DbSession) Metric(org.sonar.server.computation.task.projectanalysis.metric.Metric) QualityProfile(org.sonar.server.qualityprofile.QualityProfile) Component(org.sonar.server.computation.task.projectanalysis.component.Component) QualityProfileDto(org.sonar.db.qualityprofile.QualityProfileDto)

Aggregations

DbSession (org.sonar.db.DbSession)254 ComponentDto (org.sonar.db.component.ComponentDto)63 OrganizationDto (org.sonar.db.organization.OrganizationDto)30 JsonWriter (org.sonar.api.utils.text.JsonWriter)24 UserDto (org.sonar.db.user.UserDto)20 PermissionTemplateDto (org.sonar.db.permission.template.PermissionTemplateDto)16 Test (org.junit.Test)13 MetricDto (org.sonar.db.metric.MetricDto)13 Paging (org.sonar.api.utils.Paging)12 QualityProfileDto (org.sonar.db.qualityprofile.QualityProfileDto)10 CeQueueDto (org.sonar.db.ce.CeQueueDto)8 DepthTraversalTypeAwareCrawler (org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler)8 SearchOptions (org.sonar.server.es.SearchOptions)8 NotFoundException (org.sonar.server.exceptions.NotFoundException)8 List (java.util.List)7 SnapshotDto (org.sonar.db.component.SnapshotDto)7 GroupDto (org.sonar.db.user.GroupDto)7 DbClient (org.sonar.db.DbClient)6 ProjectId (org.sonar.server.permission.ProjectId)6 RuleKey (org.sonar.api.rule.RuleKey)5