use of com.mercedesbenz.sechub.domain.scan.report.ReportProductResultTransformer in project sechub by mercedes-benz.
the class SecHubReportProductTransformerService method createResult.
ReportTransformationResult createResult(UUID secHubJobUUID) throws SecHubExecutionException {
notNull(secHubJobUUID, "secHubJobUUID may not be null!");
List<ProductResult> reportProductResults = productResultRepository.findAllProductResults(secHubJobUUID, SERECO);
if (reportProductResults.isEmpty()) {
throw new SecHubExecutionException("No report result found for:" + secHubJobUUID);
}
int reportProductResultAmount = reportProductResults.size();
if (reportProductResultAmount > 1) {
LOG.warn("Found {} report product results, should normally be only one!", reportProductResultAmount);
}
ReportTransformationResult transformResult = null;
for (ProductResult reportProductResult : reportProductResults) {
for (ReportProductResultTransformer transformer : transformers) {
if (transformer.canTransform(reportProductResult.getProductIdentifier())) {
LOG.debug("Transformer {} is used to transform result", transformer.getClass().getSimpleName());
ReportTransformationResult transformedResult = transformer.transform(reportProductResult);
transformResult = resultMerger.merge(transformResult, transformedResult);
}
}
}
if (transformResult == null) {
throw new SecHubExecutionException("No transformable report result format found for:" + secHubJobUUID);
}
return transformResult;
}
Aggregations