use of com.epam.ta.reportportal.core.analyzer.auto.strategy.search.SearchLogsMode in project service-api by reportportal.
the class SearchLogServiceImpl method composeRequest.
private Optional<SearchRq> composeRequest(SearchLogRq request, Project project, TestItem item, Launch launch) {
SearchLogsMode searchMode = SearchLogsMode.fromString(request.getSearchMode()).orElseThrow(() -> new ReportPortalException(ErrorType.BAD_REQUEST_ERROR, request.getSearchMode()));
SearchRq searchRq = new SearchRq();
searchRq.setFilteredLaunchIds(searchCollectorFactory.getCollector(searchMode).collect(request.getFilterId(), launch));
// TODO fix query - select messages from `Nested Step` descendants too
List<String> logMessages = logRepository.findMessagesByLaunchIdAndItemIdAndPathAndLevelGte(launch.getId(), item.getItemId(), item.getPath(), LogLevel.ERROR_INT);
if (CollectionUtils.isEmpty(logMessages)) {
return Optional.empty();
}
searchRq.setLogMessages(logMessages);
final AnalyzerConfig analyzerConfig = AnalyzerUtils.getAnalyzerConfig(project);
searchRq.setAnalyzerConfig(analyzerConfig);
searchRq.setLogLines(analyzerConfig.getNumberOfLogLines());
searchRq.setItemId(item.getItemId());
searchRq.setLaunchId(launch.getId());
searchRq.setLaunchName(launch.getName());
searchRq.setProjectId(project.getId());
return Optional.of(searchRq);
}
Aggregations