class HTMLScanResultReportModelBuilder {

	public Map<String, Object> build(ScanReportResult scanResult) {
		String trafficLight = scanResult.getTrafficLight();

		String styleRed = HIDE_LIGHT;
		String styleYellow = HIDE_LIGHT;
		String styleGreen = HIDE_LIGHT;

		switch (trafficLight) {
		case "RED":
			styleRed = SHOW_LIGHT;
			break;
		case "YELLOW":
			styleYellow = SHOW_LIGHT;
			break;
		case "GREEN":
			styleGreen = SHOW_LIGHT;
			break;
		default:
		}
		HtmlCodeScanDescriptionSupport codeScanSupport = new HtmlCodeScanDescriptionSupport();
		SecHubResult result = scanResult.getResult();

		Map<Integer,List<HTMLScanResultCodeScanEntry>> codeScanEntries = new HashMap<>();
		for (SecHubFinding finding: result.getFindings()) {
			codeScanEntries.put(finding.getId(), codeScanSupport.buildEntries(finding));
		}

		Map<String, Object> model = new HashMap<>();
		model.put("result", scanResult.getResult());
		model.put("redList", trafficLightCalculator.filterFindingsFor(result, TrafficLight.RED));
		model.put("yellowList", trafficLightCalculator.filterFindingsFor(result, TrafficLight.YELLOW));
		model.put("greenList", trafficLightCalculator.filterFindingsFor(result, TrafficLight.GREEN));

		model.put("trafficlight", trafficLight);

		model.put("styleRed", styleRed);
		model.put("styleYellow", styleYellow);
		model.put("styleGreen", styleGreen);
		model.put("isWebDesignMode", webDesignMode);
		model.put("embeddedCSS", getEmbeddedCSS());
		model.put("codeScanEntries", codeScanEntries);
		model.put("codeScanSupport", codeScanSupport);


		if (webDesignMode) {
			File file;
			try {
				if (cssResource==null) {
					LOG.error("CSS resource not set:{}",cssResource);
				}else {
					file = cssResource.getFile();
					String absolutePathToCSSFile = file.getAbsolutePath();
					LOG.info("Web design mode activate, using not embedded css but ref to:{}",absolutePathToCSSFile);
					model.put("includedCSSRef", absolutePathToCSSFile);
				}
			} catch (Exception e) {
				LOG.error("Was not able get file from resource:{}",cssResource,e);
			}
		}
		UUID jobUUID = scanResult.getJobUUID();
		if (jobUUID!=null) {
			model.put("jobuuid", jobUUID.toString());
		}else {
			model.put("jobuuid", "none");
		}
		model.put("info", scanResult.getInfo());

		return model;

	}

}