Search in sources :

Example 1 with CeTaskQuery

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;
}
Also used : CeTaskQuery(org.sonar.db.ce.CeTaskQuery) StringUtils.defaultString(org.apache.commons.lang.StringUtils.defaultString) Date(java.util.Date)

Example 2 with CeTaskQuery

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());
    }
}
Also used : DbSession(org.sonar.db.DbSession) CeTaskQuery(org.sonar.db.ce.CeTaskQuery)

Example 3 with CeTaskQuery

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);
    }
}
Also used : DbSession(org.sonar.db.DbSession) ProjectResponse(org.sonarqube.ws.WsCe.ProjectResponse) CeActivityDto(org.sonar.db.ce.CeActivityDto) ComponentDto(org.sonar.db.component.ComponentDto) CeQueueDto(org.sonar.db.ce.CeQueueDto) CeTaskQuery(org.sonar.db.ce.CeTaskQuery)

Aggregations

CeTaskQuery (org.sonar.db.ce.CeTaskQuery)3 DbSession (org.sonar.db.DbSession)2 Date (java.util.Date)1 StringUtils.defaultString (org.apache.commons.lang.StringUtils.defaultString)1 CeActivityDto (org.sonar.db.ce.CeActivityDto)1 CeQueueDto (org.sonar.db.ce.CeQueueDto)1 ComponentDto (org.sonar.db.component.ComponentDto)1 ProjectResponse (org.sonarqube.ws.WsCe.ProjectResponse)1