use of org.sonar.db.ce.CeTaskQuery in project sonarqube by SonarSource.
the class ActivityAction method buildQuery.
private CeTaskQuery buildQuery(DbSession dbSession, ActivityWsRequest request) {
CeTaskQuery query = new CeTaskQuery();
query.setType(request.getType());
query.setOnlyCurrents(request.getOnlyCurrents());
Date minSubmittedAt = parseStartingDateOrDateTime(request.getMinSubmittedAt());
query.setMinSubmittedAt(minSubmittedAt == null ? null : minSubmittedAt.getTime());
Date maxExecutedAt = parseEndingDateOrDateTime(request.getMaxExecutedAt());
query.setMaxExecutedAt(maxExecutedAt == null ? null : maxExecutedAt.getTime());
List<String> statuses = request.getStatus();
if (statuses != null && !statuses.isEmpty()) {
query.setStatuses(request.getStatus());
}
query.setComponentUuids(loadComponentUuids(dbSession, request));
return query;
}
use of org.sonar.db.ce.CeTaskQuery in project sonarqube by SonarSource.
the class ActivityAction method doHandle.
private ActivityResponse doHandle(ActivityWsRequest request) {
checkPermission(request);
try (DbSession dbSession = dbClient.openSession(false)) {
// if a task searched by uuid is found all other parameters are ignored
Optional<WsCe.Task> taskSearchedById = searchTaskByUuid(dbSession, request);
if (taskSearchedById.isPresent()) {
return buildResponse(singletonList(taskSearchedById.get()), Collections.emptyList(), request.getPageSize());
}
CeTaskQuery query = buildQuery(dbSession, request);
Iterable<WsCe.Task> queuedTasks = loadQueuedTasks(dbSession, request, query);
Iterable<WsCe.Task> pastTasks = loadPastTasks(dbSession, request, query);
return buildResponse(queuedTasks, pastTasks, request.getPageSize());
}
}
use of org.sonar.db.ce.CeTaskQuery in project sonarqube by SonarSource.
the class ComponentAction method handle.
@Override
public void handle(Request wsRequest, Response wsResponse) throws Exception {
try (DbSession dbSession = dbClient.openSession(false)) {
ComponentDto component = componentFinder.getByUuidOrKey(dbSession, wsRequest.param(PARAM_COMPONENT_ID), wsRequest.param(PARAM_COMPONENT_KEY), COMPONENT_ID_AND_KEY);
userSession.checkComponentPermission(UserRole.USER, component);
List<CeQueueDto> queueDtos = dbClient.ceQueueDao().selectByComponentUuid(dbSession, component.uuid());
CeTaskQuery activityQuery = new CeTaskQuery().setComponentUuid(component.uuid()).setOnlyCurrents(true);
List<CeActivityDto> activityDtos = dbClient.ceActivityDao().selectByQuery(dbSession, activityQuery, 0, 1);
ProjectResponse.Builder wsResponseBuilder = ProjectResponse.newBuilder();
wsResponseBuilder.addAllQueue(formatter.formatQueue(dbSession, queueDtos));
if (activityDtos.size() == 1) {
wsResponseBuilder.setCurrent(formatter.formatActivity(dbSession, activityDtos.get(0)));
}
writeProtobuf(wsResponseBuilder.build(), wsRequest, wsResponse);
}
}
Aggregations