use of com.thoughtworks.go.server.presentation.models.PipelineHistoryJsonPresentationModel in project gocd by gocd.
the class PipelineHistoryController method list.
@RequestMapping(value = "/**/pipelineHistory.json", method = RequestMethod.GET)
public ModelAndView list(@RequestParam("pipelineName") String pipelineName, @RequestParam(value = "perPage", required = false) Integer perPageParam, @RequestParam(value = "start", required = false) Integer startParam, @RequestParam(value = "labelFilter", required = false) String labelFilter, HttpServletResponse response, HttpServletRequest request) throws NamingException {
PipelineConfig pipelineConfig = goConfigService.pipelineConfigNamed(new CaseInsensitiveString(pipelineName));
String username = CaseInsensitiveString.str(UserHelper.getUserName().getUsername());
Pagination pagination;
try {
pagination = Pagination.pageStartingAt(startParam, pipelineHistoryService.totalCount(pipelineName), perPageParam);
} catch (Exception e) {
Map<String, Object> json = new LinkedHashMap<>();
addDeveloperErrorMessage(json, e);
return jsonNotAcceptable(json).respond(response);
}
PipelinePauseInfo pauseInfo = pipelinePauseService.pipelinePauseInfo(pipelineName);
boolean hasBuildCauseInBuffer = pipelineScheduleQueue.hasBuildCause(CaseInsensitiveString.str(pipelineConfig.name()));
PipelineInstanceModels pipelineHistory = StringUtil.isBlank(labelFilter) ? pipelineHistoryService.load(pipelineName, pagination, username, true) : pipelineHistoryService.findMatchingPipelineInstances(pipelineName, labelFilter, perPageParam, UserHelper.getUserName(), new HttpLocalizedOperationResult());
boolean hasForcedBuildCause = pipelineScheduleQueue.hasForcedBuildCause(pipelineName);
PipelineHistoryJsonPresentationModel historyJsonPresenter = new PipelineHistoryJsonPresentationModel(pauseInfo, pipelineHistory, pipelineConfig, pagination, canForce(pipelineConfig, username), hasForcedBuildCause, hasBuildCauseInBuffer, canPause(pipelineConfig, username));
return jsonFound(historyJsonPresenter.toJson()).respond(response);
}
Aggregations