Search in sources :

Example 1 with SortOrder

use of com.thoughtworks.go.server.ui.SortOrder in project gocd by gocd.

the class AgentJobHistoryControllerV1 method index.

public String index(Request request, Response response) throws IOException {
    String uuid = request.params(":uuid");
    Integer offset = getOffset(request);
    Integer pageSize = getPageSize(request);
    JobInstanceService.JobHistoryColumns column = getSortColumn(request);
    SortOrder sortOrder = getSortOrder(request);
    Integer total = jobInstanceService.totalCompletedJobsCountOn(uuid);
    Pagination pagination = Pagination.pageStartingAt(offset, total, pageSize);
    AgentInstance agent = agentService.findAgent(uuid);
    if (agent.isNullAgent()) {
        throw new RecordNotFoundException(EntityType.Agent, uuid);
    }
    JobInstancesModel jobInstances = jobInstanceService.completedJobsOnAgent(uuid, column, sortOrder, pagination);
    return writerForTopLevelObject(request, response, outputWriter -> AgentJobHistoryRepresenter.toJSON(outputWriter, uuid, jobInstances));
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) JobInstanceService(com.thoughtworks.go.server.service.JobInstanceService) Pagination(com.thoughtworks.go.server.util.Pagination) RecordNotFoundException(com.thoughtworks.go.config.exceptions.RecordNotFoundException) SortOrder(com.thoughtworks.go.server.ui.SortOrder) JobInstancesModel(com.thoughtworks.go.server.ui.JobInstancesModel)

Aggregations

RecordNotFoundException (com.thoughtworks.go.config.exceptions.RecordNotFoundException)1 AgentInstance (com.thoughtworks.go.domain.AgentInstance)1 JobInstanceService (com.thoughtworks.go.server.service.JobInstanceService)1 JobInstancesModel (com.thoughtworks.go.server.ui.JobInstancesModel)1 SortOrder (com.thoughtworks.go.server.ui.SortOrder)1 Pagination (com.thoughtworks.go.server.util.Pagination)1