Search in sources :

Example 96 with ComponentDto

use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.

the class ProjectStatusAction method getProjectThenSnapshot.

private ProjectAndSnapshot getProjectThenSnapshot(DbSession dbSession, ProjectStatusWsRequest request) {
    ComponentDto projectDto = componentFinder.getByUuidOrKey(dbSession, request.getProjectId(), request.getProjectKey(), ParamNames.PROJECT_ID_AND_KEY);
    java.util.Optional<SnapshotDto> snapshot = dbClient.snapshotDao().selectLastAnalysisByRootComponentUuid(dbSession, projectDto.projectUuid());
    return new ProjectAndSnapshot(projectDto, snapshot.orElse(null));
}
Also used : SnapshotDto(org.sonar.db.component.SnapshotDto) ComponentDto(org.sonar.db.component.ComponentDto)

Example 97 with ComponentDto

use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.

the class RemoveProjectAction method handle.

@Override
public void handle(Request request, Response response) throws Exception {
    RemoveProjectRequest removeProjectRequest = toWsRequest(request);
    try (DbSession dbSession = dbClient.openSession(false)) {
        String profileKey = projectAssociationFinder.getProfileKey(removeProjectRequest.getLanguage(), removeProjectRequest.getProfileName(), removeProjectRequest.getProfileKey());
        ComponentDto project = projectAssociationFinder.getProject(dbSession, removeProjectRequest.getProjectKey(), removeProjectRequest.getProjectUuid());
        profileProjectOperations.removeProject(dbSession, profileKey, project);
    }
    response.noContent();
}
Also used : DbSession(org.sonar.db.DbSession) RemoveProjectRequest(org.sonarqube.ws.client.qualityprofile.RemoveProjectRequest) ComponentDto(org.sonar.db.component.ComponentDto)

Example 98 with ComponentDto

use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.

the class SearchDataLoader method lookupByModuleKey.

private Set<String> lookupByModuleKey(DbSession dbSession, Map<String, QProfile> qualityProfiles, Set<String> languageKeys, @Nullable String moduleKey) {
    if (languageKeys.isEmpty() || moduleKey == null) {
        return languageKeys;
    }
    ComponentDto project = getProject(moduleKey, dbSession);
    addAllFromDto(qualityProfiles, profileFactory.getByProjectAndLanguages(dbSession, project.getKey(), languageKeys));
    return difference(languageKeys, qualityProfiles.keySet());
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto)

Example 99 with ComponentDto

use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.

the class ServerUserSession method componentUuidToProjectUuid.

@Override
protected Optional<String> componentUuidToProjectUuid(String componentUuid) {
    String projectUuid = projectUuidByComponentUuid.get(componentUuid);
    if (projectUuid != null) {
        return Optional.of(projectUuid);
    }
    try (DbSession dbSession = dbClient.openSession(false)) {
        com.google.common.base.Optional<ComponentDto> component = dbClient.componentDao().selectByUuid(dbSession, componentUuid);
        if (!component.isPresent()) {
            return Optional.empty();
        }
        projectUuid = component.get().projectUuid();
        projectUuidByComponentUuid.put(componentUuid, projectUuid);
        return Optional.of(projectUuid);
    }
}
Also used : DbSession(org.sonar.db.DbSession) ComponentDto(org.sonar.db.component.ComponentDto)

Example 100 with ComponentDto

use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.

the class ResetAction method handle.

@Override
public void handle(Request request, Response response) throws Exception {
    try (DbSession dbSession = dbClient.openSession(false)) {
        ResetRequest resetRequest = toWsRequest(request);
        Optional<ComponentDto> component = getComponent(dbSession, resetRequest);
        checkPermissions(component);
        resetRequest.getKeys().forEach(key -> {
            SettingData data = new SettingData(key, emptyList(), component.orElse(null));
            ImmutableList.of(validations.scope(), validations.qualifier()).forEach(validation -> validation.accept(data));
        });
        List<String> keys = getKeys(resetRequest);
        if (component.isPresent()) {
            settingsUpdater.deleteComponentSettings(dbSession, component.get(), keys);
        } else {
            settingsUpdater.deleteGlobalSettings(dbSession, keys);
        }
        dbSession.commit();
        response.noContent();
    }
}
Also used : DbSession(org.sonar.db.DbSession) SettingData(org.sonar.server.setting.ws.SettingValidations.SettingData) ComponentDto(org.sonar.db.component.ComponentDto) ResetRequest(org.sonarqube.ws.client.setting.ResetRequest)

Aggregations

ComponentDto (org.sonar.db.component.ComponentDto)836 Test (org.junit.Test)661 OrganizationDto (org.sonar.db.organization.OrganizationDto)151 SnapshotDto (org.sonar.db.component.SnapshotDto)94 DbSession (org.sonar.db.DbSession)70 SearchOptions (org.sonar.server.es.SearchOptions)62 MetricDto (org.sonar.db.metric.MetricDto)49 IssueDto (org.sonar.db.issue.IssueDto)48 RuleDto (org.sonar.db.rule.RuleDto)47 GroupDto (org.sonar.db.user.GroupDto)39 UserDto (org.sonar.db.user.UserDto)38 WsTester (org.sonar.server.ws.WsTester)33 MetricTesting.newMetricDto (org.sonar.db.metric.MetricTesting.newMetricDto)25 PropertyDto (org.sonar.db.property.PropertyDto)23 IssueIndexer (org.sonar.server.issue.index.IssueIndexer)21 ProjectRepositories (org.sonar.scanner.protocol.input.ProjectRepositories)18 Date (java.util.Date)16 ComponentLinkDto (org.sonar.db.component.ComponentLinkDto)14 RuleTesting.newRuleDto (org.sonar.db.rule.RuleTesting.newRuleDto)14 ComponentTreeWsResponse (org.sonarqube.ws.WsMeasures.ComponentTreeWsResponse)13