From 5a4d0a745d9aff8af10e2148d0efcb3aa9e6cead Mon Sep 17 00:00:00 2001
From: Riegel <alexander.riegel@hft-stuttgart.de>
Date: Tue, 13 Aug 2024 16:03:06 +0200
Subject: [PATCH] Extracted method. Ref #69

---
 .../reporting/pdf/PdfStreamReporter.java      | 34 +++++++++++--------
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/reporting/pdf/PdfStreamReporter.java b/CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/reporting/pdf/PdfStreamReporter.java
index 65c137a..f1f5374 100644
--- a/CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/reporting/pdf/PdfStreamReporter.java
+++ b/CityDoctorParent/CityDoctorValidation/src/main/java/de/hft/stuttgart/citydoctor2/reporting/pdf/PdfStreamReporter.java
@@ -393,21 +393,7 @@ public class PdfStreamReporter implements StreamReporter {
 	@Override
 	public void finishReport() throws CheckReportWriteException {
 		if (buildings != null) {
-			for (Section s : buildings.getSubSections()) {
-				if (!s.hasErrors()) {
-					numOkBuildings++;
-					// building has no errors, no table
-					continue;
-				}
-				numErrorBuildings++;
-				Table t = new Table(2);
-				t.setTableColumnWidth(75, 25);
-				t.setTitle("Error", "Count");
-				for (Entry<String, AtomicInteger> e : s.getStats().getErrorCounts().entrySet()) {
-					t.addRow(e.getKey(), e.getValue().toString());
-				}
-				s.addTable(1, t);
-			}
+			countFinishedReportBuildings();
 		}
 		int numBuildings = numErrorBuildings + numOkBuildings;
 		if (numBuildings > 0) {
@@ -446,6 +432,24 @@ public class PdfStreamReporter implements StreamReporter {
 		report.save(outFile);
 	}
 
+	private void countFinishedReportBuildings() {
+		for (Section s : buildings.getSubSections()) {
+			if (!s.hasErrors()) {
+				numOkBuildings++;
+				// building has no errors, no table
+				continue;
+			}
+			numErrorBuildings++;
+			Table t = new Table(2);
+			t.setTableColumnWidth(75, 25);
+			t.setTitle("Error", "Count");
+			for (Entry<String, AtomicInteger> e : s.getStats().getErrorCounts().entrySet()) {
+				t.addRow(e.getKey(), e.getValue().toString());
+			}
+			s.addTable(1, t);
+		}
+	}
+
 	@Override
 	public void reportGlobalError(CheckError err) {
 		AtomicInteger errorCount = errorStatistics.computeIfAbsent(err.getErrorId(), k -> new AtomicInteger(0));
-- 
GitLab