1
0

M3-AP-005: Batchlauf im Use-Case integriert und sauber von Bootstrap

entkoppelt
This commit is contained in:
2026-04-01 20:34:15 +02:00
parent c482b20df9
commit d60d050948
3 changed files with 413 additions and 80 deletions

View File

@@ -12,7 +12,9 @@ import de.gecheckt.pdf.umbenenner.application.config.StartConfigurationValidator
import de.gecheckt.pdf.umbenenner.application.port.in.BatchRunOutcome;
import de.gecheckt.pdf.umbenenner.application.port.in.RunBatchProcessingUseCase;
import de.gecheckt.pdf.umbenenner.application.port.out.ConfigurationPort;
import de.gecheckt.pdf.umbenenner.application.port.out.PdfTextExtractionPort;
import de.gecheckt.pdf.umbenenner.application.port.out.RunLockPort;
import de.gecheckt.pdf.umbenenner.application.port.out.SourceDocumentCandidatesPort;
import de.gecheckt.pdf.umbenenner.application.usecase.M2BatchRunProcessingUseCase;
import de.gecheckt.pdf.umbenenner.domain.model.BatchRunContext;
import de.gecheckt.pdf.umbenenner.domain.model.RunId;
@@ -69,8 +71,11 @@ public class BootstrapRunner {
/**
* Functional interface for creating a RunBatchProcessingUseCase.
* <p>
* Receives the already-loaded and validated {@link StartConfiguration} so the use case
* does not need to re-read the configuration file.
* Receives the already-loaded and validated {@link StartConfiguration} and run lock port.
* <p>
* Note: The use case signature may accept additional ports for M3+ functionality,
* but bootstrap provides No-Op implementations for now (AP-005 scope).
* Full M3 adapter wiring will be completed in AP-007 (Bootstrap expansion).
*/
@FunctionalInterface
public interface UseCaseFactory {
@@ -94,7 +99,10 @@ public class BootstrapRunner {
this.configPortFactory = PropertiesConfigurationPortAdapter::new;
this.runLockPortFactory = FilesystemRunLockPortAdapter::new;
this.validatorFactory = StartConfigurationValidator::new;
this.useCaseFactory = (config, lock) -> new M2BatchRunProcessingUseCase(config, lock);
// AP-005: Use case accepts M3 ports, but bootstrap provides No-Op implementations (M2 scope)
// AP-007 will wire real M3 adapters; for now, M2 uses No-Op ports
this.useCaseFactory = (config, lock) ->
new M2BatchRunProcessingUseCase(config, lock, new NoOpSourceCandidatesPort(), new NoOpExtractionPort());
this.commandFactory = SchedulerBatchCommand::new;
}
@@ -157,6 +165,8 @@ public class BootstrapRunner {
// Step 6: Create the use case with the validated config and run lock (application layer)
// Config is passed directly; the use case does not re-read the properties file.
// Note: The use case signature includes M3 ports, but bootstrap (M2 scope) provides No-Op implementations.
// Real M3 adapter wiring will be completed in AP-007.
RunBatchProcessingUseCase useCase = useCaseFactory.create(config, runLockPort);
// Step 7: Create the CLI command adapter with the use case
@@ -192,4 +202,36 @@ public class BootstrapRunner {
return 1;
}
}
// =========================================================================
// AP-005 (M2 scope): No-Op port implementations
// (Real M3 adapters will be wired in AP-007)
// =========================================================================
/**
* No-Op implementation of {@link SourceDocumentCandidatesPort} for M2 scope.
* <p>
* M2 batch execution does not scan the source folder, so this returns an empty list.
* AP-007 will replace this with a real filesystem adapter.
*/
private static class NoOpSourceCandidatesPort implements SourceDocumentCandidatesPort {
@Override
public java.util.List<de.gecheckt.pdf.umbenenner.domain.model.SourceDocumentCandidate> loadCandidates() {
return java.util.List.of();
}
}
/**
* No-Op implementation of {@link PdfTextExtractionPort} for M2 scope.
* <p>
* M2 batch execution does not extract PDF content, so this port is never called.
* AP-007 will replace this with a real PDFBox adapter.
*/
private static class NoOpExtractionPort implements PdfTextExtractionPort {
@Override
public de.gecheckt.pdf.umbenenner.domain.model.PdfExtractionResult extractTextAndPageCount(
de.gecheckt.pdf.umbenenner.domain.model.SourceDocumentCandidate candidate) {
throw new UnsupportedOperationException("M2 scope: No-Op port, should not be called");
}
}
}