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));
}
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();
}
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());
}
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);
}
}
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();
}
}
Aggregations