use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class SearchAction method doHandle.
private SearchWsResponse doHandle(SearchWsRequest request) {
try (DbSession dbSession = dbClient.openSession(false)) {
ComponentQuery query = buildQuery(request);
OrganizationDto organization = getOrganization(dbSession, request);
Paging paging = buildPaging(dbSession, request, organization, query);
List<ComponentDto> components = searchComponents(dbSession, organization, query, paging);
return buildResponse(components, organization, paging);
}
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class SearchProjectsAction method searchData.
private SearchResults searchData(DbSession dbSession, SearchProjectsRequest request, @Nullable OrganizationDto organization) {
Set<String> favoriteProjectUuids = loadFavoriteProjectUuids(dbSession);
List<Criterion> criteria = FilterParser.parse(firstNonNull(request.getFilter(), ""));
ProjectMeasuresQuery query = newProjectMeasuresQuery(criteria, hasFavoriteFilter(criteria) ? favoriteProjectUuids : null).setSort(request.getSort()).setAsc(request.getAsc());
Optional.ofNullable(organization).map(OrganizationDto::getUuid).ifPresent(query::setOrganizationUuid);
queryValidator.validate(dbSession, query);
SearchIdResult<String> esResults = index.search(query, new SearchOptions().addFacets(request.getFacets()).setPage(request.getPage(), request.getPageSize()));
List<String> projectUuids = esResults.getIds();
Ordering<ComponentDto> ordering = Ordering.explicit(projectUuids).onResultOf(ComponentDto::uuid);
List<ComponentDto> projects = ordering.immutableSortedCopy(dbClient.componentDao().selectByUuids(dbSession, projectUuids));
Map<String, SnapshotDto> analysisByProjectUuid = getSnapshots(dbSession, request, projectUuids);
return new SearchResults(projects, favoriteProjectUuids, esResults, analysisByProjectUuid, query);
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class LoadPeriodsStep method buildPeriod.
@CheckForNull
private Period buildPeriod(Component projectOrView, DbSession session) {
Optional<ComponentDto> projectDto = dbClient.componentDao().selectByKey(session, projectOrView.getKey());
// No project on first analysis, no period
if (!projectDto.isPresent()) {
return null;
}
boolean isReportType = projectOrView.getType().isReportType();
PeriodResolver periodResolver = new PeriodResolver(dbClient, session, projectDto.get().uuid(), analysisMetadataHolder.getAnalysisDate(), isReportType ? projectOrView.getReportAttributes().getVersion() : null);
Settings settings = settingsRepository.getSettings(projectOrView);
Period period = periodResolver.resolve(settings);
// SONAR-4700 Add a past snapshot only if it exists
if (period != null) {
return period;
}
return null;
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class PersistComponentsStep method createForSubView.
private ComponentDto createForSubView(Component subView, PathAwareVisitor.Path<ComponentDtoHolder> path) {
ComponentDto res = createBase(subView);
res.setScope(Scopes.PROJECT);
res.setQualifier(Qualifiers.SUBVIEW);
res.setName(subView.getName());
res.setDescription(subView.getDescription());
res.setLongName(res.name());
res.setCopyComponentUuid(subView.getSubViewAttributes().getOriginalViewUuid());
setRootAndParentModule(res, path);
return res;
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class PersistComponentsStep method createBase.
private ComponentDto createBase(Component component) {
String componentKey = component.getKey();
String componentUuid = component.getUuid();
ComponentDto componentDto = new ComponentDto();
componentDto.setOrganizationUuid(analysisMetadataHolder.getOrganization().getUuid());
componentDto.setUuid(componentUuid);
componentDto.setKey(componentKey);
componentDto.setDeprecatedKey(componentKey);
componentDto.setEnabled(true);
componentDto.setCreatedAt(new Date(system2.now()));
return componentDto;
}
Aggregations