use of org.sonar.db.component.ComponentQuery in project sonarqube by SonarSource.
the class ActivityAction method loadComponentUuids.
@CheckForNull
private List<String> loadComponentUuids(DbSession dbSession, ActivityWsRequest request) {
String componentUuid = request.getComponentId();
String componentQuery = request.getQuery();
if (componentUuid != null) {
return singletonList(componentUuid);
}
if (componentQuery != null) {
ComponentQuery componentDtoQuery = ComponentQuery.builder().setNameOrKeyQuery(componentQuery).setQualifiers(POSSIBLE_QUALIFIERS.toArray(new String[0])).build();
List<ComponentDto> componentDtos = dbClient.componentDao().selectByQuery(dbSession, componentDtoQuery, 0, CeTaskQuery.MAX_COMPONENT_UUIDS);
return Lists.transform(componentDtos, ComponentDto::uuid);
}
return null;
}
use of org.sonar.db.component.ComponentQuery 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.ComponentQuery in project sonarqube by SonarSource.
the class BulkApplyTemplateAction method doHandle.
private void doHandle(BulkApplyTemplateWsRequest request) {
try (DbSession dbSession = dbClient.openSession(false)) {
PermissionTemplateDto template = wsSupport.findTemplate(dbSession, newTemplateRef(request.getTemplateId(), request.getOrganization(), request.getTemplateName()));
checkGlobalAdmin(userSession, template.getOrganizationUuid());
ComponentQuery componentQuery = ComponentQuery.builder().setNameOrKeyQuery(request.getQuery()).setQualifiers(qualifiers(request.getQualifier())).build();
List<ComponentDto> projects = dbClient.componentDao().selectByQuery(dbSession, template.getOrganizationUuid(), componentQuery, 0, Integer.MAX_VALUE);
permissionTemplateService.apply(dbSession, template, projects);
}
}
use of org.sonar.db.component.ComponentQuery in project sonarqube by SonarSource.
the class SearchAction method doHandle.
private SearchWsResponse doHandle(SearchWsRequest request) {
try (DbSession dbSession = dbClient.openSession(false)) {
OrganizationDto organization = support.getOrganization(dbSession, ofNullable(request.getOrganization()).orElseGet(defaultOrganizationProvider.get()::getKey));
userSession.checkPermission(OrganizationPermission.ADMINISTER, organization);
ComponentQuery query = buildQuery(request);
Paging paging = buildPaging(dbSession, request, organization, query);
List<ComponentDto> components = dbClient.componentDao().selectByQuery(dbSession, organization.getUuid(), query, paging.offset(), paging.pageSize());
return buildResponse(components, organization, paging);
}
}
use of org.sonar.db.component.ComponentQuery in project sonarqube by SonarSource.
the class SearchMyProjectsDataLoader method searchProjects.
@VisibleForTesting
ProjectsResult searchProjects(DbSession dbSession, SearchMyProjectsRequest request) {
int userId = requireNonNull(userSession.getUserId(), "Current user must be authenticated");
List<Long> componentIds = dbClient.roleDao().selectComponentIdsByPermissionAndUserId(dbSession, UserRole.ADMIN, userId);
ComponentQuery dbQuery = ComponentQuery.builder().setQualifiers(Qualifiers.PROJECT).setComponentIds(ImmutableSet.copyOf(componentIds)).build();
return new ProjectsResult(dbClient.componentDao().selectByQuery(dbSession, dbQuery, offset(request.getPage(), request.getPageSize()), request.getPageSize()), dbClient.componentDao().countByQuery(dbSession, dbQuery));
}
Aggregations