From 049aa361db0404456f37793b52996835069ec57a Mon Sep 17 00:00:00 2001 From: Marcus van Elst Date: Fri, 3 Apr 2026 10:56:22 +0200 Subject: [PATCH] M4 AP-006 AP-007-Scope im Bootstrap trennen --- .../umbenenner/bootstrap/BootstrapRunner.java | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/pdf-umbenenner-bootstrap/src/main/java/de/gecheckt/pdf/umbenenner/bootstrap/BootstrapRunner.java b/pdf-umbenenner-bootstrap/src/main/java/de/gecheckt/pdf/umbenenner/bootstrap/BootstrapRunner.java index d885fc5..4b0effe 100644 --- a/pdf-umbenenner-bootstrap/src/main/java/de/gecheckt/pdf/umbenenner/bootstrap/BootstrapRunner.java +++ b/pdf-umbenenner-bootstrap/src/main/java/de/gecheckt/pdf/umbenenner/bootstrap/BootstrapRunner.java @@ -16,7 +16,6 @@ import de.gecheckt.pdf.umbenenner.adapter.out.pdfextraction.PdfTextExtractionPor import de.gecheckt.pdf.umbenenner.adapter.out.sourcedocument.SourceDocumentCandidatesPortAdapter; import de.gecheckt.pdf.umbenenner.adapter.out.sqlite.SqliteDocumentRecordRepositoryAdapter; import de.gecheckt.pdf.umbenenner.adapter.out.sqlite.SqliteProcessingAttemptRepositoryAdapter; -import de.gecheckt.pdf.umbenenner.adapter.out.sqlite.SqliteSchemaInitializationAdapter; import de.gecheckt.pdf.umbenenner.adapter.out.sqlite.SqliteUnitOfWorkAdapter; import de.gecheckt.pdf.umbenenner.application.config.InvalidStartConfigurationException; import de.gecheckt.pdf.umbenenner.application.config.StartConfiguration; @@ -27,7 +26,6 @@ import de.gecheckt.pdf.umbenenner.application.port.out.ConfigurationPort; import de.gecheckt.pdf.umbenenner.application.port.out.DocumentPersistenceException; import de.gecheckt.pdf.umbenenner.application.port.out.DocumentRecordRepository; import de.gecheckt.pdf.umbenenner.application.port.out.FingerprintPort; -import de.gecheckt.pdf.umbenenner.application.port.out.PersistenceSchemaInitializationPort; import de.gecheckt.pdf.umbenenner.application.port.out.ProcessingAttemptRepository; import de.gecheckt.pdf.umbenenner.application.port.out.RunLockPort; import de.gecheckt.pdf.umbenenner.application.port.out.UnitOfWorkPort; @@ -58,16 +56,17 @@ import de.gecheckt.pdf.umbenenner.domain.model.RunId; * during the run. * * - *

M4 wiring

+ *

M4 wiring (AP-006)

*

* The production constructor wires the following M4 adapters via the UseCaseFactory: *

+ *

+ * Schema initialisation is AP-007 responsibility, not performed in AP-006. * * @since M2 (extended in M4-AP-006) */ @@ -128,7 +127,7 @@ public class BootstrapRunner { /** * Creates the BootstrapRunner with default factories for production use. *

- * Wires the full M4 processing pipeline: + * Wires the M4 processing pipeline: *

*

- * Schema initialisation is performed by the UseCaseFactory when the use case is created, - * using {@link SqliteSchemaInitializationAdapter}. (AP-007 responsibility) + * Schema initialisation is AP-007 responsibility and is NOT performed here. */ public BootstrapRunner() { this.configPortFactory = PropertiesConfigurationPortAdapter::new; @@ -149,11 +147,6 @@ public class BootstrapRunner { this.validatorFactory = StartConfigurationValidator::new; this.useCaseFactory = (config, lock) -> { String jdbcUrl = buildJdbcUrl(config); - // AP-007: Initialize schema when the use case is created - if (config.sqliteFile() != null) { - PersistenceSchemaInitializationPort schemaPort = new SqliteSchemaInitializationAdapter(jdbcUrl); - schemaPort.initializeSchema(); - } FingerprintPort fingerprintPort = new Sha256FingerprintAdapter(); DocumentRecordRepository documentRecordRepository = new SqliteDocumentRecordRepositoryAdapter(jdbcUrl); @@ -201,8 +194,7 @@ public class BootstrapRunner { * M4 additions: *

* * @return exit code: 0 for success, 1 for invalid configuration or unexpected bootstrap failure @@ -237,7 +229,7 @@ public class BootstrapRunner { // Step 6: Create the use case with the validated config and run lock. // Config is passed directly; the use case does not re-read the properties file. // Adapters (source document port, PDF extraction port, M4 ports) are wired by the factory. - // Schema initialization happens within the UseCaseFactory. (AP-007 responsibility) + // Schema initialization is AP-007 responsibility, not performed in AP-006. BatchRunProcessingUseCase useCase = useCaseFactory.create(config, runLockPort); // Step 7: Create the CLI command adapter with the use case @@ -269,9 +261,8 @@ public class BootstrapRunner { LOG.error("Configuration loading failed: {}", e.getMessage()); return 1; } catch (DocumentPersistenceException e) { - // Persistence operation during startup failed – hard start error - // (e.g., schema initialisation in UseCaseFactory) - LOG.error("Persistence operation during startup failed: {}", e.getMessage(), e); + // Persistence operation failed – hard error + LOG.error("Persistence operation failed: {}", e.getMessage(), e); return 1; } catch (Exception e) { LOG.error("Bootstrap failure during startup.", e);