diff --git a/src/main/java/at/procon/eventhub/config/EventHubProperties.java b/src/main/java/at/procon/eventhub/config/EventHubProperties.java index 821cdf6..21fb336 100644 --- a/src/main/java/at/procon/eventhub/config/EventHubProperties.java +++ b/src/main/java/at/procon/eventhub/config/EventHubProperties.java @@ -30,7 +30,8 @@ public class EventHubProperties { private final Batch batch = new Batch(); private final Tachograph tachograph = new Tachograph(); - private final TachographFileSession tachographFileSession = new TachographFileSession(); + private final RuntimeProcessing runtimeProcessing = new RuntimeProcessing(); + private final TachographFileSession tachographFileSession = new TachographFileSession(runtimeProcessing); private final EsperPoc esperPoc = new EsperPoc(); private final YellowFox yellowFox = new YellowFox(); @@ -46,6 +47,10 @@ public class EventHubProperties { return tachographFileSession; } + public RuntimeProcessing getRuntimeProcessing() { + return runtimeProcessing; + } + public EsperPoc getEsperPoc() { return esperPoc; } @@ -318,7 +323,15 @@ public class EventHubProperties { private int maxSessions = 100; private long maxFileSizeBytes = 20L * 1024L * 1024L; private final LegalRequirements legalRequirements = new LegalRequirements(); - private final Processing processing = new Processing(); + private final Processing processing; + + public TachographFileSession() { + this(new Processing()); + } + + public TachographFileSession(Processing processing) { + this.processing = processing == null ? new Processing() : processing; + } public Duration getTtl() { return ttl; @@ -355,6 +368,9 @@ public class EventHubProperties { } } + public static class RuntimeProcessing extends Processing { + } + public static class Processing { private TimelineInputMode timelineInputMode = TimelineInputMode.INTERVALS; private DrivingDerivedProjectionInputMode drivingDerivedProjectionInputMode = DrivingDerivedProjectionInputMode.INTERVALS; diff --git a/src/main/java/at/procon/eventhub/processing/api/UnifiedRuntimeProcessingController.java b/src/main/java/at/procon/eventhub/processing/api/UnifiedRuntimeProcessingController.java index e8ac603..6b38250 100644 --- a/src/main/java/at/procon/eventhub/processing/api/UnifiedRuntimeProcessingController.java +++ b/src/main/java/at/procon/eventhub/processing/api/UnifiedRuntimeProcessingController.java @@ -14,15 +14,15 @@ import at.procon.eventhub.processing.eventprocessing.plan.RuntimeProcessingPlanD import at.procon.eventhub.processing.eventprocessing.validation.RuntimeMixedSourceEvidenceValidationApiRequest; import at.procon.eventhub.processing.eventprocessing.validation.RuntimeMixedSourceEvidenceValidationResultDto; import at.procon.eventhub.processing.eventprocessing.validation.RuntimeMixedSourceEvidenceValidationService; -import at.procon.eventhub.processing.eventprocessing.validation.RuntimeTachographParityValidationApiRequest; -import at.procon.eventhub.processing.eventprocessing.validation.RuntimeTachographParityValidationResultDto; -import at.procon.eventhub.processing.eventprocessing.validation.RuntimeTachographParityValidationService; import at.procon.eventhub.processing.model.RuntimeDriverTimeline; import at.procon.eventhub.processing.model.UnifiedRuntimeEventBundle; import at.procon.eventhub.processing.service.UnifiedRuntimeDerivedProjectionService; import at.procon.eventhub.processing.service.UnifiedRuntimeDriverTimelineService; import at.procon.eventhub.processing.service.UnifiedRuntimeEventAssemblyService; import at.procon.eventhub.processing.service.RuntimeDriverWorkingTimeScopeProcessingService; +import at.procon.eventhub.tachographfilesession.processing.validation.RuntimeTachographParityValidationApiRequest; +import at.procon.eventhub.tachographfilesession.processing.validation.RuntimeTachographParityValidationResultDto; +import at.procon.eventhub.tachographfilesession.processing.validation.RuntimeTachographParityValidationService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; diff --git a/src/main/java/at/procon/eventhub/processing/driverworkingtime/service/DriverWorkingTimeReusableProjectionBuilder.java b/src/main/java/at/procon/eventhub/processing/driverworkingtime/service/DriverWorkingTimeReusableProjectionBuilder.java index 2154669..d71cac0 100644 --- a/src/main/java/at/procon/eventhub/processing/driverworkingtime/service/DriverWorkingTimeReusableProjectionBuilder.java +++ b/src/main/java/at/procon/eventhub/processing/driverworkingtime/service/DriverWorkingTimeReusableProjectionBuilder.java @@ -247,7 +247,7 @@ public class DriverWorkingTimeReusableProjectionBuilder { try { Configuration configuration = new Configuration(); configurationSetup.accept(configuration); - String runtimeUri = "eventhub-tachograph-reusable-projection-" + RUNTIME_COUNTER.incrementAndGet(); + String runtimeUri = "eventhub-driver-working-time-reusable-projection-" + RUNTIME_COUNTER.incrementAndGet(); runtime = EPRuntimeProvider.getRuntime(runtimeUri, configuration); CompilerArguments arguments = new CompilerArguments(configuration); @@ -261,7 +261,7 @@ public class DriverWorkingTimeReusableProjectionBuilder { sender.accept(runtime); } catch (EPCompileException | EPDeployException e) { - throw new IllegalStateException("Cannot compile/deploy reusable tachograph projection EPL bundle", e); + throw new IllegalStateException("Cannot compile/deploy reusable driver working-time projection EPL bundle", e); } finally { if (runtime != null) { runtime.destroy(); @@ -728,21 +728,21 @@ public class DriverWorkingTimeReusableProjectionBuilder { ) .replace( "${REST_GEO_LOOKBACK_SECONDS}", - Long.toString(Math.max(1, properties.getTachographFileSession().getProcessing().getRestCandidateGeoLookbackMinutes()) * 60L) + Long.toString(Math.max(1, properties.getRuntimeProcessing().getRestCandidateGeoLookbackMinutes()) * 60L) ) .replace( "${REST_GEO_LOOKAHEAD_SECONDS}", - Long.toString(Math.max(1, properties.getTachographFileSession().getProcessing().getRestCandidateGeoLookaheadMinutes()) * 60L) + Long.toString(Math.max(1, properties.getRuntimeProcessing().getRestCandidateGeoLookaheadMinutes()) * 60L) ) .replace( "${REST_GEO_STATIONARY_MAX_METERS}", - Integer.toString(Math.max(0, properties.getTachographFileSession().getProcessing().getRestCandidateGeoStationaryMaxMeters())) + Integer.toString(Math.max(0, properties.getRuntimeProcessing().getRestCandidateGeoStationaryMaxMeters())) ) .replace( "${REST_GEO_MINOR_MOVEMENT_MAX_METERS}", Integer.toString(Math.max( - properties.getTachographFileSession().getProcessing().getRestCandidateGeoStationaryMaxMeters(), - properties.getTachographFileSession().getProcessing().getRestCandidateGeoMinorMovementMaxMeters() + properties.getRuntimeProcessing().getRestCandidateGeoStationaryMaxMeters(), + properties.getRuntimeProcessing().getRestCandidateGeoMinorMovementMaxMeters() )) ); } diff --git a/src/main/java/at/procon/eventhub/processing/eventprocessing/module/SupportEvidenceNormalizationModule.java b/src/main/java/at/procon/eventhub/processing/eventprocessing/module/SupportEvidenceNormalizationModule.java index 249b595..96c92a3 100644 --- a/src/main/java/at/procon/eventhub/processing/eventprocessing/module/SupportEvidenceNormalizationModule.java +++ b/src/main/java/at/procon/eventhub/processing/eventprocessing/module/SupportEvidenceNormalizationModule.java @@ -85,7 +85,7 @@ public class SupportEvidenceNormalizationModule implements RuntimeProcessingModu .toList(); RuntimeSupportEvidenceNormalizationResult normalizationResult = - supportEvidenceNormalizer.normalizeForTachographDriver(driverKey, partition.mergedEvents()); + supportEvidenceNormalizer.normalizeForDriverWorkingTime(driverKey, partition.mergedEvents()); List supportEvidenceEvents = normalizationResult.normalizedEvents().stream() .map(event -> supportEvidenceNormalizer.toSupportEvidenceEvent(driverKey, event)) .filter(Objects::nonNull) @@ -121,10 +121,10 @@ public class SupportEvidenceNormalizationModule implements RuntimeProcessingModu scopeRequest.occurredFrom(), scopeRequest.occurredTo(), scopeRequest.significantDrivingMinutes() == null - ? properties.getTachographFileSession().getProcessing().getSignificantDrivingMinutes() + ? properties.getRuntimeProcessing().getSignificantDrivingMinutes() : scopeRequest.significantDrivingMinutes(), scopeRequest.minimumRestPeriodMinutes() == null - ? properties.getTachographFileSession().getProcessing().getMinimumRestPeriodMinutes() + ? properties.getRuntimeProcessing().getMinimumRestPeriodMinutes() : scopeRequest.minimumRestPeriodMinutes(), driverActivityIntervals, normalizedPartition.vehicleUsageIntervals(), diff --git a/src/main/java/at/procon/eventhub/processing/eventprocessing/support/RuntimeSupportEvidenceNormalizer.java b/src/main/java/at/procon/eventhub/processing/eventprocessing/support/RuntimeSupportEvidenceNormalizer.java index 3f04b4a..5b12156 100644 --- a/src/main/java/at/procon/eventhub/processing/eventprocessing/support/RuntimeSupportEvidenceNormalizer.java +++ b/src/main/java/at/procon/eventhub/processing/eventprocessing/support/RuntimeSupportEvidenceNormalizer.java @@ -23,7 +23,8 @@ import org.springframework.stereotype.Service; @Service public class RuntimeSupportEvidenceNormalizer { - private static final LinkedHashSet DIRECT_TACHOGRAPH_SUPPORT_DOMAINS = new LinkedHashSet<>(List.of( + private static final String DRIVER_WORKING_TIME_PROFILE_KEY = "driver-working-time-v1"; + private static final LinkedHashSet DIRECT_DRIVER_WORKING_TIME_SUPPORT_DOMAINS = new LinkedHashSet<>(List.of( EventDomain.POSITION, EventDomain.PLACE, EventDomain.BORDER_CROSSING, @@ -36,7 +37,7 @@ public class RuntimeSupportEvidenceNormalizer { this.objectMapper = objectMapper; } - public RuntimeSupportEvidenceNormalizationResult normalizeForTachographDriver( + public RuntimeSupportEvidenceNormalizationResult normalizeForDriverWorkingTime( String driverKey, List events ) { @@ -45,7 +46,7 @@ public class RuntimeSupportEvidenceNormalizer { int normalizedSupportEvidence = 0; int unchanged = 0; for (EventHubEventDto event : safeEvents) { - EventHubEventDto normalized = normalizeOneForTachographDriver(driverKey, event); + EventHubEventDto normalized = normalizeOneForDriverWorkingTime(driverKey, event); normalizedEvents.add(normalized); if (normalized != event) { normalizedSupportEvidence++; @@ -56,7 +57,7 @@ public class RuntimeSupportEvidenceNormalizer { List notes = new ArrayList<>(); notes.add("Runtime support evidence normalization inspected " + safeEvents.size() + " event(s)."); notes.add("Runtime support evidence normalization adapted " + normalizedSupportEvidence - + " support/vehicle event(s) for the tachograph Esper profile."); + + " support/vehicle event(s) for the shared driver working-time pipeline."); return new RuntimeSupportEvidenceNormalizationResult( normalizedEvents, safeEvents.size(), @@ -66,6 +67,17 @@ public class RuntimeSupportEvidenceNormalizer { ); } + /** + * @deprecated Use {@link #normalizeForDriverWorkingTime(String, List)}. + */ + @Deprecated(forRemoval = false) + public RuntimeSupportEvidenceNormalizationResult normalizeForTachographDriver( + String driverKey, + List events + ) { + return normalizeForDriverWorkingTime(driverKey, events); + } + public RuntimeSupportEvidenceEvent toSupportEvidenceEvent(String fallbackDriverKey, EventHubEventDto event) { if (event == null || isDriverActivityOrCardUsage(event)) { return null; @@ -101,7 +113,7 @@ public class RuntimeSupportEvidenceNormalizer { ); } - private EventHubEventDto normalizeOneForTachographDriver(String fallbackDriverKey, EventHubEventDto event) { + private EventHubEventDto normalizeOneForDriverWorkingTime(String fallbackDriverKey, EventHubEventDto event) { if (event == null || isDriverActivityOrCardUsage(event)) { return event; } @@ -166,7 +178,7 @@ public class RuntimeSupportEvidenceNormalizer { } private EventDomain normalizedDomain(EventHubEventDto event) { - if (event.eventDomain() != null && DIRECT_TACHOGRAPH_SUPPORT_DOMAINS.contains(event.eventDomain())) { + if (event.eventDomain() != null && DIRECT_DRIVER_WORKING_TIME_SUPPORT_DOMAINS.contains(event.eventDomain())) { return event.eventDomain(); } return EventDomain.POSITION; @@ -202,7 +214,7 @@ public class RuntimeSupportEvidenceNormalizer { ) { Map attributes = new LinkedHashMap<>(); put(attributes, "normalizedSupportEvidence", true); - put(attributes, "normalizedForProfile", "tachograph-driver-esper-v1"); + put(attributes, "normalizedForProfile", DRIVER_WORKING_TIME_PROFILE_KEY); put(attributes, "originalEventDomain", support.eventDomain()); put(attributes, "originalEventType", support.eventType()); put(attributes, "originalLifecycle", support.lifecycle()); @@ -233,7 +245,7 @@ public class RuntimeSupportEvidenceNormalizer { originalRaw.fields().forEachRemaining(entry -> raw.set(entry.getKey(), entry.getValue())); } put(raw, "normalizedSupportEvidence", true); - put(raw, "normalizedForProfile", "tachograph-driver-esper-v1"); + put(raw, "normalizedForProfile", DRIVER_WORKING_TIME_PROFILE_KEY); put(raw, "supportEventId", support.eventId()); put(raw, "supportEventDomain", support.eventDomain()); put(raw, "supportEventType", support.eventType()); diff --git a/src/main/java/at/procon/eventhub/processing/service/RuntimeIntervalEventWindowSelector.java b/src/main/java/at/procon/eventhub/processing/service/RuntimeIntervalEventWindowSelector.java index 0f1fb08..557633c 100644 --- a/src/main/java/at/procon/eventhub/processing/service/RuntimeIntervalEventWindowSelector.java +++ b/src/main/java/at/procon/eventhub/processing/service/RuntimeIntervalEventWindowSelector.java @@ -10,12 +10,12 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; -final class RuntimeIntervalEventWindowSelector { +public final class RuntimeIntervalEventWindowSelector { private RuntimeIntervalEventWindowSelector() { } - static RuntimeTimelineEventBundle filterBundle( + public static RuntimeTimelineEventBundle filterBundle( RuntimeTimelineEventBundle bundle, OffsetDateTime occurredFrom, OffsetDateTime occurredTo, @@ -31,7 +31,7 @@ final class RuntimeIntervalEventWindowSelector { ); } - static List filterIntervalEvents( + public static List filterIntervalEvents( List events, OffsetDateTime occurredFrom, OffsetDateTime occurredTo, @@ -58,7 +58,7 @@ final class RuntimeIntervalEventWindowSelector { return List.copyOf(result); } - static List filterPointEvents( + public static List filterPointEvents( List events, OffsetDateTime occurredFrom, OffsetDateTime occurredTo diff --git a/src/main/java/at/procon/eventhub/processing/service/UnifiedRuntimeDerivedProjectionService.java b/src/main/java/at/procon/eventhub/processing/service/UnifiedRuntimeDerivedProjectionService.java index 9aecec3..ddd78af 100644 --- a/src/main/java/at/procon/eventhub/processing/service/UnifiedRuntimeDerivedProjectionService.java +++ b/src/main/java/at/procon/eventhub/processing/service/UnifiedRuntimeDerivedProjectionService.java @@ -1,41 +1,25 @@ package at.procon.eventhub.processing.service; import at.procon.eventhub.config.EventHubProperties; -import at.procon.eventhub.dto.DriverRefDto; import at.procon.eventhub.dto.EventHubEventDto; -import at.procon.eventhub.processing.dto.UnifiedRuntimeDerivedProjectionResultDto; import at.procon.eventhub.processing.dto.RuntimeSupportEvidenceNormalizationDebugDto; import at.procon.eventhub.processing.dto.UnifiedRuntimeProcessingApiRequest; -import at.procon.eventhub.processing.driverworkingtime.model.DriverWorkingTimeActivityInterval; import at.procon.eventhub.processing.driverworkingtime.model.DriverWorkingTimeProcessingInput; -import at.procon.eventhub.processing.driverworkingtime.model.DriverWorkingTimeVehicleUsageInterval; +import at.procon.eventhub.processing.dto.UnifiedRuntimeDerivedProjectionResultDto; import at.procon.eventhub.processing.driverworkingtime.service.DriverWorkingTimeDerivedProjectionEngine; import at.procon.eventhub.processing.driverworkingtime.service.DriverWorkingTimeProcessingCore; import at.procon.eventhub.processing.driverworkingtime.service.DriverWorkingTimeReusableProjectionBuilder; import at.procon.eventhub.processing.eventprocessing.support.RuntimeSupportEvidenceNormalizationResult; import at.procon.eventhub.processing.eventprocessing.support.RuntimeSupportEvidenceNormalizer; import at.procon.eventhub.processing.model.RuntimeDriverTimeline; -import at.procon.eventhub.processing.model.RuntimeSupportEvent; import at.procon.eventhub.processing.model.UnifiedRuntimeEventBundle; import at.procon.eventhub.processing.model.UnifiedRuntimeProcessingRequest; import at.procon.eventhub.processing.driverworkingtime.dto.DriverWorkingTimeProcessingResultDto; import at.procon.eventhub.processing.support.RuntimeDriverWorkingTimeAdapter; -import at.procon.eventhub.tachographfilesession.model.TachographEsperActivityIntervalEvent; -import at.procon.eventhub.tachographfilesession.model.TachographEsperDailyWeeklyRestCandidateCoverageIntervalEvent; -import at.procon.eventhub.tachographfilesession.model.TachographEsperDrivingDerivedProjectionBundle; -import at.procon.eventhub.tachographfilesession.model.TachographEsperDrivingInterruptionIntervalEvent; -import at.procon.eventhub.tachographfilesession.model.TachographEsperPotentialHomeOvernightStayIntervalEvent; -import at.procon.eventhub.tachographfilesession.model.TachographEsperPotentialInVehicleOvernightStayIntervalEvent; -import at.procon.eventhub.tachographfilesession.model.TachographEsperPotentialInVehicleTripIntervalEvent; -import at.procon.eventhub.tachographfilesession.model.TachographEsperSupportGeoEvent; -import at.procon.eventhub.tachographfilesession.model.TachographEsperVehicleUsageIntervalEvent; -import at.procon.eventhub.tachographfilesession.model.TachographEsperVuCardAbsentIntervalEvent; import at.procon.eventhub.processing.support.RuntimeEntityReferenceResolver; -import java.time.Duration; import java.time.OffsetDateTime; import java.time.ZoneOffset; import java.util.ArrayList; -import java.util.Comparator; import java.util.List; import java.util.Objects; import java.util.UUID; @@ -101,7 +85,7 @@ public class UnifiedRuntimeDerivedProjectionService { String driverKey = explicitDriverKey == null ? resolveDriverKey(request, eventBundle.mergedEvents()) : explicitDriverKey; - RuntimeSupportEvidenceNormalizationResult normalizationResult = supportEvidenceNormalizer.normalizeForTachographDriver( + RuntimeSupportEvidenceNormalizationResult normalizationResult = supportEvidenceNormalizer.normalizeForDriverWorkingTime( driverKey, eventBundle.mergedEvents() ); @@ -193,8 +177,8 @@ public class UnifiedRuntimeDerivedProjectionService { ); } - private EventHubProperties.Processing processingProperties() { - return properties.getTachographFileSession().getProcessing(); + private EventHubProperties.RuntimeProcessing processingProperties() { + return properties.getRuntimeProcessing(); } private UUID runtimeSessionId(UnifiedRuntimeProcessingRequest request) { @@ -213,288 +197,7 @@ public class UnifiedRuntimeDerivedProjectionService { return RuntimeEntityReferenceResolver.requestDriverKey(request, events); } - - private List mergeVehicleUsageIntervals( - List intervals - ) { - if (intervals == null || intervals.isEmpty()) { - return List.of(); - } - List sorted = intervals.stream() - .sorted(Comparator.comparing(TachographEsperVehicleUsageIntervalEvent::startedAt) - .thenComparing(TachographEsperVehicleUsageIntervalEvent::endedAt, Comparator.nullsLast(Comparator.naturalOrder())) - .thenComparing(TachographEsperVehicleUsageIntervalEvent::intervalId, Comparator.nullsLast(String::compareTo))) - .toList(); - List merged = new ArrayList<>(); - for (TachographEsperVehicleUsageIntervalEvent next : sorted) { - if (merged.isEmpty()) { - merged.add(next); - continue; - } - TachographEsperVehicleUsageIntervalEvent current = merged.get(merged.size() - 1); - if (canMergeVehicleUsage(current, next)) { - merged.set(merged.size() - 1, mergeVehicleUsage(current, next)); - } else { - merged.add(next); - } - } - return List.copyOf(merged); - } - - private boolean canMergeVehicleUsage( - TachographEsperVehicleUsageIntervalEvent left, - TachographEsperVehicleUsageIntervalEvent right - ) { - if (left == null || right == null || left.endedAt() == null || right.startedAt() == null) { - return false; - } - return Objects.equals(left.driverKey(), right.driverKey()) - && Objects.equals(left.registrationKey(), right.registrationKey()) - && Objects.equals(left.vehicleKey(), right.vehicleKey()) - && !right.startedAt().isAfter(left.endedAt().plusSeconds(1)); - } - - private TachographEsperVehicleUsageIntervalEvent mergeVehicleUsage( - TachographEsperVehicleUsageIntervalEvent left, - TachographEsperVehicleUsageIntervalEvent right - ) { - List sourceIntervalIds = new ArrayList<>(); - if (left.sourceIntervalIds() != null) { - sourceIntervalIds.addAll(left.sourceIntervalIds()); - } - if (right.sourceIntervalIds() != null) { - for (String sourceIntervalId : right.sourceIntervalIds()) { - if (!sourceIntervalIds.contains(sourceIntervalId)) { - sourceIntervalIds.add(sourceIntervalId); - } - } - } - OffsetDateTime end = right.endedAt() == null || right.endedAt().isBefore(left.endedAt()) - ? left.endedAt() - : right.endedAt(); - return new TachographEsperVehicleUsageIntervalEvent( - left.sessionId(), - left.driverKey(), - left.intervalId(), - left.startedAt(), - end, - Duration.between(left.startedAt(), end).getSeconds(), - left.odometerBeginKm(), - right.odometerEndKm() == null ? left.odometerEndKm() : right.odometerEndKm(), - left.registrationKey(), - left.vehicleKey(), - left.sourceKind(), - sourceIntervalIds - ); - } - - private List clipActivityIntervals( - List intervals, - OffsetDateTime requestedFrom, - OffsetDateTime requestedTo - ) { - if (requestedFrom == null || requestedTo == null) { - return intervals == null ? List.of() : List.copyOf(intervals); - } - return (intervals == null ? List.of() : intervals).stream() - .map(interval -> { - if (!intersects(interval.startedAt(), interval.endedAt(), requestedFrom, requestedTo)) { - return null; - } - OffsetDateTime start = max(interval.startedAt(), requestedFrom); - OffsetDateTime end = min(interval.endedAt(), requestedTo); - if (start == null || end == null || !end.isAfter(start)) { - return null; - } - boolean clipped = interval.clippedToRequestedPeriod() - || !Objects.equals(start, interval.startedAt()) - || !Objects.equals(end, interval.endedAt()); - return new TachographEsperActivityIntervalEvent( - interval.sessionId(), - interval.driverKey(), - interval.intervalId(), - interval.activityType(), - interval.cardSlot(), - interval.cardStatus(), - interval.drivingStatus(), - interval.registrationKey(), - interval.vehicleKey(), - interval.sourceKind(), - start, - end, - Duration.between(start, end).getSeconds(), - interval.sourceIntervalIds(), - interval.synthetic(), - clipped, - interval.level() - ); - }) - .filter(Objects::nonNull) - .sorted(Comparator.comparing(TachographEsperActivityIntervalEvent::startedAt) - .thenComparing(TachographEsperActivityIntervalEvent::endedAt)) - .toList(); - } - - private List clipVehicleUsageIntervals( - List intervals, - OffsetDateTime requestedFrom, - OffsetDateTime requestedTo - ) { - if (requestedFrom == null || requestedTo == null) { - return intervals == null ? List.of() : List.copyOf(intervals); - } - return (intervals == null ? List.of() : intervals).stream() - .map(interval -> { - if (!intersects(interval.startedAt(), interval.endedAt(), requestedFrom, requestedTo)) { - return null; - } - OffsetDateTime start = max(interval.startedAt(), requestedFrom); - OffsetDateTime end = min(interval.endedAt(), requestedTo); - if (start == null || end == null || !end.isAfter(start)) { - return null; - } - boolean startClipped = !Objects.equals(start, interval.startedAt()); - boolean endClipped = !Objects.equals(end, interval.endedAt()); - return new TachographEsperVehicleUsageIntervalEvent( - interval.sessionId(), - interval.driverKey(), - interval.intervalId(), - start, - end, - Duration.between(start, end).getSeconds(), - startClipped ? null : interval.odometerBeginKm(), - endClipped ? null : interval.odometerEndKm(), - interval.registrationKey(), - interval.vehicleKey(), - interval.sourceKind(), - interval.sourceIntervalIds() - ); - }) - .filter(Objects::nonNull) - .sorted(Comparator.comparing(TachographEsperVehicleUsageIntervalEvent::startedAt) - .thenComparing(TachographEsperVehicleUsageIntervalEvent::endedAt)) - .toList(); - } - - private List clipDrivingIntervals( - List intervals, - OffsetDateTime requestedFrom, - OffsetDateTime requestedTo - ) { - return filterIntersecting( - intervals, - requestedFrom, - requestedTo, - TachographEsperDrivingInterruptionIntervalEvent::startedAt, - TachographEsperDrivingInterruptionIntervalEvent::endedAt - ); - } - - private List clipVuCardAbsentIntervals( - List intervals, - OffsetDateTime requestedFrom, - OffsetDateTime requestedTo - ) { - return filterIntersecting( - intervals, - requestedFrom, - requestedTo, - TachographEsperVuCardAbsentIntervalEvent::startedAt, - TachographEsperVuCardAbsentIntervalEvent::endedAt - ); - } - - private List clipSupportGeoEvents( - List supportEvents, - String driverKey, - OffsetDateTime requestedFrom, - OffsetDateTime requestedTo - ) { - return (supportEvents == null ? List.of() : supportEvents).stream() - .filter(event -> event.occurredAt() != null) - .filter(event -> driverKey == null || event.driverKey() == null || Objects.equals(driverKey, event.driverKey())) - .filter(event -> requestedFrom == null || !event.occurredAt().isBefore(requestedFrom)) - .filter(event -> requestedTo == null || !event.occurredAt().isAfter(requestedTo)) - .map(event -> new TachographEsperSupportGeoEvent( - event.eventId(), - event.driverKey(), - event.occurredAt(), - event.eventDomain(), - event.eventType(), - event.eventLifecycle(), - event.registrationKey(), - event.vehicleKey(), - event.country(), - event.region(), - event.countryFrom(), - event.countryTo(), - event.operation(), - event.latitude(), - event.longitude(), - event.odometerKm(), - event.rawRecordPath() - )) - .sorted(Comparator.comparing(TachographEsperSupportGeoEvent::occurredAt) - .thenComparing(TachographEsperSupportGeoEvent::eventId, Comparator.nullsLast(String::compareTo))) - .toList(); - } - - private List filterIntersecting( - List intervals, - OffsetDateTime requestedFrom, - OffsetDateTime requestedTo, - TimeAccessor startAccessor, - TimeAccessor endAccessor - ) { - if (intervals == null || intervals.isEmpty()) { - return List.of(); - } - if (requestedFrom == null || requestedTo == null) { - return List.copyOf(intervals); - } - return intervals.stream() - .filter(interval -> intersects(startAccessor.get(interval), endAccessor.get(interval), requestedFrom, requestedTo)) - .toList(); - } - - private boolean intersects( - OffsetDateTime intervalStart, - OffsetDateTime intervalEnd, - OffsetDateTime requestedFrom, - OffsetDateTime requestedTo - ) { - if (intervalStart == null || intervalEnd == null || requestedFrom == null || requestedTo == null) { - return false; - } - return intervalEnd.isAfter(requestedFrom) && intervalStart.isBefore(requestedTo); - } - - private OffsetDateTime min(OffsetDateTime left, OffsetDateTime right) { - if (left == null) { - return right; - } - if (right == null) { - return left; - } - return left.isBefore(right) ? left : right; - } - - private OffsetDateTime max(OffsetDateTime left, OffsetDateTime right) { - if (left == null) { - return right; - } - if (right == null) { - return left; - } - return left.isAfter(right) ? left : right; - } - private OffsetDateTime utc(OffsetDateTime value) { return value == null ? null : value.withOffsetSameInstant(ZoneOffset.UTC); } - - @FunctionalInterface - private interface TimeAccessor { - OffsetDateTime get(T value); - } } diff --git a/src/main/java/at/procon/eventhub/processing/eventprocessing/plan/TachographDriverWorkingTimeRuntimeProcessingPlan.java b/src/main/java/at/procon/eventhub/tachographfilesession/processing/plan/TachographDriverWorkingTimeRuntimeProcessingPlan.java similarity index 77% rename from src/main/java/at/procon/eventhub/processing/eventprocessing/plan/TachographDriverWorkingTimeRuntimeProcessingPlan.java rename to src/main/java/at/procon/eventhub/tachographfilesession/processing/plan/TachographDriverWorkingTimeRuntimeProcessingPlan.java index 3f96e95..24bb5d8 100644 --- a/src/main/java/at/procon/eventhub/processing/eventprocessing/plan/TachographDriverWorkingTimeRuntimeProcessingPlan.java +++ b/src/main/java/at/procon/eventhub/tachographfilesession/processing/plan/TachographDriverWorkingTimeRuntimeProcessingPlan.java @@ -1,5 +1,6 @@ -package at.procon.eventhub.processing.eventprocessing.plan; +package at.procon.eventhub.tachographfilesession.processing.plan; +import at.procon.eventhub.processing.eventprocessing.plan.DriverWorkingTimeRuntimeProcessingPlan; import at.procon.eventhub.processing.service.RuntimeDriverWorkingTimeScopeProcessingService; /** diff --git a/src/main/java/at/procon/eventhub/processing/eventprocessing/profile/TachographDriverEsperRuntimeEventProcessingProfile.java b/src/main/java/at/procon/eventhub/tachographfilesession/processing/profile/TachographDriverEsperRuntimeEventProcessingProfile.java similarity index 95% rename from src/main/java/at/procon/eventhub/processing/eventprocessing/profile/TachographDriverEsperRuntimeEventProcessingProfile.java rename to src/main/java/at/procon/eventhub/tachographfilesession/processing/profile/TachographDriverEsperRuntimeEventProcessingProfile.java index 0d923d9..e4ebfd8 100644 --- a/src/main/java/at/procon/eventhub/processing/eventprocessing/profile/TachographDriverEsperRuntimeEventProcessingProfile.java +++ b/src/main/java/at/procon/eventhub/tachographfilesession/processing/profile/TachographDriverEsperRuntimeEventProcessingProfile.java @@ -1,4 +1,4 @@ -package at.procon.eventhub.processing.eventprocessing.profile; +package at.procon.eventhub.tachographfilesession.processing.profile; import at.procon.eventhub.processing.eventprocessing.dto.RuntimeEventProcessingApiRequest; import at.procon.eventhub.processing.eventprocessing.dto.RuntimeEventProcessingResultDto; @@ -6,6 +6,7 @@ import at.procon.eventhub.processing.eventprocessing.partition.RuntimeEventParti import at.procon.eventhub.processing.eventprocessing.plan.RuntimeProcessingExecutionApiRequest; import at.procon.eventhub.processing.eventprocessing.plan.RuntimeProcessingExecutionResultDto; import at.procon.eventhub.processing.eventprocessing.plan.DriverWorkingTimeRuntimeProcessingPlan; +import at.procon.eventhub.processing.eventprocessing.profile.RuntimeEventProcessingProfile; import at.procon.eventhub.processing.service.RuntimeDriverWorkingTimeScopeProcessingService; import java.util.List; import java.util.Set; diff --git a/src/main/java/at/procon/eventhub/processing/service/TachographDbRuntimeEventLoader.java b/src/main/java/at/procon/eventhub/tachographfilesession/processing/service/TachographDbRuntimeEventLoader.java similarity index 98% rename from src/main/java/at/procon/eventhub/processing/service/TachographDbRuntimeEventLoader.java rename to src/main/java/at/procon/eventhub/tachographfilesession/processing/service/TachographDbRuntimeEventLoader.java index a30c7af..80b500c 100644 --- a/src/main/java/at/procon/eventhub/processing/service/TachographDbRuntimeEventLoader.java +++ b/src/main/java/at/procon/eventhub/tachographfilesession/processing/service/TachographDbRuntimeEventLoader.java @@ -1,4 +1,4 @@ -package at.procon.eventhub.processing.service; +package at.procon.eventhub.tachographfilesession.processing.service; import at.procon.eventhub.dto.AcquisitionStrategy; import at.procon.eventhub.dto.EventFamily; @@ -15,6 +15,8 @@ import at.procon.eventhub.processing.model.UnifiedDiscoveredVehicleRef; import at.procon.eventhub.processing.model.UnifiedEventSourceFamily; import at.procon.eventhub.processing.model.UnifiedRuntimeEventBackend; import at.procon.eventhub.processing.model.UnifiedRuntimeProcessingRequest; +import at.procon.eventhub.processing.service.RuntimeDriverEventLoader; +import at.procon.eventhub.processing.service.RuntimeVehicleEventLoader; import at.procon.eventhub.reference.TachographNationRegistry; import at.procon.eventhub.tachograph.dto.TachographImportRequest; import at.procon.eventhub.tachograph.service.TachographExtractionDefinitionRegistry; diff --git a/src/main/java/at/procon/eventhub/processing/service/TachographDbUnifiedDriverEventSource.java b/src/main/java/at/procon/eventhub/tachographfilesession/processing/service/TachographDbUnifiedDriverEventSource.java similarity index 89% rename from src/main/java/at/procon/eventhub/processing/service/TachographDbUnifiedDriverEventSource.java rename to src/main/java/at/procon/eventhub/tachographfilesession/processing/service/TachographDbUnifiedDriverEventSource.java index 3f6c53f..9a3a852 100644 --- a/src/main/java/at/procon/eventhub/processing/service/TachographDbUnifiedDriverEventSource.java +++ b/src/main/java/at/procon/eventhub/tachographfilesession/processing/service/TachographDbUnifiedDriverEventSource.java @@ -1,9 +1,10 @@ -package at.procon.eventhub.processing.service; +package at.procon.eventhub.tachographfilesession.processing.service; import at.procon.eventhub.dto.EventHubEventDto; import at.procon.eventhub.persistence.EventHubEventReadRepository; import at.procon.eventhub.processing.model.UnifiedDriverEventsRequest; import at.procon.eventhub.processing.model.UnifiedEventSourceFamily; +import at.procon.eventhub.processing.service.UnifiedDriverEventSource; import java.util.List; import org.springframework.stereotype.Component; diff --git a/src/main/java/at/procon/eventhub/processing/service/TachographDbUnifiedVehicleEventSource.java b/src/main/java/at/procon/eventhub/tachographfilesession/processing/service/TachographDbUnifiedVehicleEventSource.java similarity index 89% rename from src/main/java/at/procon/eventhub/processing/service/TachographDbUnifiedVehicleEventSource.java rename to src/main/java/at/procon/eventhub/tachographfilesession/processing/service/TachographDbUnifiedVehicleEventSource.java index 845a2d8..1165845 100644 --- a/src/main/java/at/procon/eventhub/processing/service/TachographDbUnifiedVehicleEventSource.java +++ b/src/main/java/at/procon/eventhub/tachographfilesession/processing/service/TachographDbUnifiedVehicleEventSource.java @@ -1,9 +1,10 @@ -package at.procon.eventhub.processing.service; +package at.procon.eventhub.tachographfilesession.processing.service; import at.procon.eventhub.dto.EventHubEventDto; import at.procon.eventhub.persistence.EventHubEventReadRepository; import at.procon.eventhub.processing.model.UnifiedVehicleEventsRequest; import at.procon.eventhub.processing.model.UnifiedEventSourceFamily; +import at.procon.eventhub.processing.service.UnifiedVehicleEventSource; import java.util.List; import org.springframework.stereotype.Component; diff --git a/src/main/java/at/procon/eventhub/processing/service/TachographFileSessionRuntimeEventLoader.java b/src/main/java/at/procon/eventhub/tachographfilesession/processing/service/TachographFileSessionRuntimeEventLoader.java similarity index 93% rename from src/main/java/at/procon/eventhub/processing/service/TachographFileSessionRuntimeEventLoader.java rename to src/main/java/at/procon/eventhub/tachographfilesession/processing/service/TachographFileSessionRuntimeEventLoader.java index 70539a1..ea7db06 100644 --- a/src/main/java/at/procon/eventhub/processing/service/TachographFileSessionRuntimeEventLoader.java +++ b/src/main/java/at/procon/eventhub/tachographfilesession/processing/service/TachographFileSessionRuntimeEventLoader.java @@ -1,4 +1,4 @@ -package at.procon.eventhub.processing.service; +package at.procon.eventhub.tachographfilesession.processing.service; import at.procon.eventhub.dto.EventHubEventDto; import at.procon.eventhub.processing.model.UnifiedDiscoveredVehicleRef; @@ -7,6 +7,10 @@ import at.procon.eventhub.processing.model.UnifiedEventSourceFamily; import at.procon.eventhub.processing.model.UnifiedRuntimeEventBackend; import at.procon.eventhub.processing.model.UnifiedRuntimeProcessingRequest; import at.procon.eventhub.processing.model.UnifiedVehicleEventsRequest; +import at.procon.eventhub.processing.service.RuntimeDriverEventLoader; +import at.procon.eventhub.processing.service.RuntimeVehicleEventLoader; +import at.procon.eventhub.processing.service.UnifiedDriverEventSourceService; +import at.procon.eventhub.processing.service.UnifiedVehicleEventSourceService; import at.procon.eventhub.service.EventAcquisitionRecordKeyService; import at.procon.eventhub.service.EventHubEventSorter; import at.procon.eventhub.tachographfilesession.service.TachographCompositeSessionNotFoundException; diff --git a/src/main/java/at/procon/eventhub/processing/service/TachographFileSessionUnifiedDriverEventSource.java b/src/main/java/at/procon/eventhub/tachographfilesession/processing/service/TachographFileSessionUnifiedDriverEventSource.java similarity index 93% rename from src/main/java/at/procon/eventhub/processing/service/TachographFileSessionUnifiedDriverEventSource.java rename to src/main/java/at/procon/eventhub/tachographfilesession/processing/service/TachographFileSessionUnifiedDriverEventSource.java index 9bcc91b..3c278ff 100644 --- a/src/main/java/at/procon/eventhub/processing/service/TachographFileSessionUnifiedDriverEventSource.java +++ b/src/main/java/at/procon/eventhub/tachographfilesession/processing/service/TachographFileSessionUnifiedDriverEventSource.java @@ -1,8 +1,10 @@ -package at.procon.eventhub.processing.service; +package at.procon.eventhub.tachographfilesession.processing.service; import at.procon.eventhub.dto.EventHubEventDto; import at.procon.eventhub.processing.model.UnifiedDriverEventsRequest; import at.procon.eventhub.processing.model.UnifiedEventSourceFamily; +import at.procon.eventhub.processing.service.RuntimeIntervalEventWindowSelector; +import at.procon.eventhub.processing.service.UnifiedDriverEventSource; import at.procon.eventhub.tachographfilesession.model.DriverExtractionSession; import at.procon.eventhub.tachographfilesession.model.TachographFileSession; import at.procon.eventhub.tachographfilesession.model.TachographTimelineEventBundle; diff --git a/src/main/java/at/procon/eventhub/processing/service/TachographFileSessionUnifiedDriverTimelineSource.java b/src/main/java/at/procon/eventhub/tachographfilesession/processing/service/TachographFileSessionUnifiedDriverTimelineSource.java similarity index 94% rename from src/main/java/at/procon/eventhub/processing/service/TachographFileSessionUnifiedDriverTimelineSource.java rename to src/main/java/at/procon/eventhub/tachographfilesession/processing/service/TachographFileSessionUnifiedDriverTimelineSource.java index 96792d0..b1c0489 100644 --- a/src/main/java/at/procon/eventhub/processing/service/TachographFileSessionUnifiedDriverTimelineSource.java +++ b/src/main/java/at/procon/eventhub/tachographfilesession/processing/service/TachographFileSessionUnifiedDriverTimelineSource.java @@ -1,8 +1,9 @@ -package at.procon.eventhub.processing.service; +package at.procon.eventhub.tachographfilesession.processing.service; import at.procon.eventhub.processing.model.RuntimeDriverTimeline; import at.procon.eventhub.processing.model.UnifiedDriverTimelineRequest; import at.procon.eventhub.processing.model.UnifiedEventSourceFamily; +import at.procon.eventhub.processing.service.UnifiedDriverTimelineSource; import at.procon.eventhub.tachographfilesession.support.RuntimeTimelineCompatibilityAdapter; import at.procon.eventhub.tachographfilesession.model.DriverExtractionSession; import at.procon.eventhub.tachographfilesession.model.TachographFileSession; diff --git a/src/main/java/at/procon/eventhub/processing/service/TachographFileSessionUnifiedVehicleEventSource.java b/src/main/java/at/procon/eventhub/tachographfilesession/processing/service/TachographFileSessionUnifiedVehicleEventSource.java similarity index 95% rename from src/main/java/at/procon/eventhub/processing/service/TachographFileSessionUnifiedVehicleEventSource.java rename to src/main/java/at/procon/eventhub/tachographfilesession/processing/service/TachographFileSessionUnifiedVehicleEventSource.java index ca7be33..db7a0ef 100644 --- a/src/main/java/at/procon/eventhub/processing/service/TachographFileSessionUnifiedVehicleEventSource.java +++ b/src/main/java/at/procon/eventhub/tachographfilesession/processing/service/TachographFileSessionUnifiedVehicleEventSource.java @@ -1,9 +1,11 @@ -package at.procon.eventhub.processing.service; +package at.procon.eventhub.tachographfilesession.processing.service; import at.procon.eventhub.dto.EventHubEventDto; import at.procon.eventhub.dto.VehicleRefDto; import at.procon.eventhub.processing.model.UnifiedEventSourceFamily; import at.procon.eventhub.processing.model.UnifiedVehicleEventsRequest; +import at.procon.eventhub.processing.service.RuntimeIntervalEventWindowSelector; +import at.procon.eventhub.processing.service.UnifiedVehicleEventSource; import at.procon.eventhub.reference.TachographNationRegistry; import at.procon.eventhub.tachographfilesession.model.DriverExtractionSession; import at.procon.eventhub.tachographfilesession.model.TachographFileSession; diff --git a/src/main/java/at/procon/eventhub/processing/service/UnifiedRuntimeTachographEsperScopeProcessingService.java b/src/main/java/at/procon/eventhub/tachographfilesession/processing/service/UnifiedRuntimeTachographEsperScopeProcessingService.java similarity index 92% rename from src/main/java/at/procon/eventhub/processing/service/UnifiedRuntimeTachographEsperScopeProcessingService.java rename to src/main/java/at/procon/eventhub/tachographfilesession/processing/service/UnifiedRuntimeTachographEsperScopeProcessingService.java index da39cd3..2e858fb 100644 --- a/src/main/java/at/procon/eventhub/processing/service/UnifiedRuntimeTachographEsperScopeProcessingService.java +++ b/src/main/java/at/procon/eventhub/tachographfilesession/processing/service/UnifiedRuntimeTachographEsperScopeProcessingService.java @@ -1,8 +1,9 @@ -package at.procon.eventhub.processing.service; +package at.procon.eventhub.tachographfilesession.processing.service; import at.procon.eventhub.processing.dto.UnifiedRuntimeDriverWorkingTimeScopeResultDto; import at.procon.eventhub.processing.dto.UnifiedRuntimeProcessingApiRequest; import at.procon.eventhub.processing.dto.UnifiedRuntimeTachographEsperScopeResultDto; +import at.procon.eventhub.processing.service.RuntimeDriverWorkingTimeScopeProcessingService; /** * @deprecated Compatibility adapter. Use {@link RuntimeDriverWorkingTimeScopeProcessingService}; diff --git a/src/main/java/at/procon/eventhub/processing/eventprocessing/validation/RuntimeTachographDriverParityResultDto.java b/src/main/java/at/procon/eventhub/tachographfilesession/processing/validation/RuntimeTachographDriverParityResultDto.java similarity index 89% rename from src/main/java/at/procon/eventhub/processing/eventprocessing/validation/RuntimeTachographDriverParityResultDto.java rename to src/main/java/at/procon/eventhub/tachographfilesession/processing/validation/RuntimeTachographDriverParityResultDto.java index 80859d9..228befe 100644 --- a/src/main/java/at/procon/eventhub/processing/eventprocessing/validation/RuntimeTachographDriverParityResultDto.java +++ b/src/main/java/at/procon/eventhub/tachographfilesession/processing/validation/RuntimeTachographDriverParityResultDto.java @@ -1,4 +1,4 @@ -package at.procon.eventhub.processing.eventprocessing.validation; +package at.procon.eventhub.tachographfilesession.processing.validation; import java.util.List; diff --git a/src/main/java/at/procon/eventhub/processing/eventprocessing/validation/RuntimeTachographParityCategoryComparisonDto.java b/src/main/java/at/procon/eventhub/tachographfilesession/processing/validation/RuntimeTachographParityCategoryComparisonDto.java similarity index 70% rename from src/main/java/at/procon/eventhub/processing/eventprocessing/validation/RuntimeTachographParityCategoryComparisonDto.java rename to src/main/java/at/procon/eventhub/tachographfilesession/processing/validation/RuntimeTachographParityCategoryComparisonDto.java index 89dd808..ef7a3b6 100644 --- a/src/main/java/at/procon/eventhub/processing/eventprocessing/validation/RuntimeTachographParityCategoryComparisonDto.java +++ b/src/main/java/at/procon/eventhub/tachographfilesession/processing/validation/RuntimeTachographParityCategoryComparisonDto.java @@ -1,4 +1,4 @@ -package at.procon.eventhub.processing.eventprocessing.validation; +package at.procon.eventhub.tachographfilesession.processing.validation; public record RuntimeTachographParityCategoryComparisonDto( String category, diff --git a/src/main/java/at/procon/eventhub/processing/eventprocessing/validation/RuntimeTachographParityValidationApiRequest.java b/src/main/java/at/procon/eventhub/tachographfilesession/processing/validation/RuntimeTachographParityValidationApiRequest.java similarity index 96% rename from src/main/java/at/procon/eventhub/processing/eventprocessing/validation/RuntimeTachographParityValidationApiRequest.java rename to src/main/java/at/procon/eventhub/tachographfilesession/processing/validation/RuntimeTachographParityValidationApiRequest.java index e3eda2c..70d4dfa 100644 --- a/src/main/java/at/procon/eventhub/processing/eventprocessing/validation/RuntimeTachographParityValidationApiRequest.java +++ b/src/main/java/at/procon/eventhub/tachographfilesession/processing/validation/RuntimeTachographParityValidationApiRequest.java @@ -1,4 +1,4 @@ -package at.procon.eventhub.processing.eventprocessing.validation; +package at.procon.eventhub.tachographfilesession.processing.validation; import java.time.OffsetDateTime; import java.util.LinkedHashSet; diff --git a/src/main/java/at/procon/eventhub/processing/eventprocessing/validation/RuntimeTachographParityValidationResultDto.java b/src/main/java/at/procon/eventhub/tachographfilesession/processing/validation/RuntimeTachographParityValidationResultDto.java similarity index 91% rename from src/main/java/at/procon/eventhub/processing/eventprocessing/validation/RuntimeTachographParityValidationResultDto.java rename to src/main/java/at/procon/eventhub/tachographfilesession/processing/validation/RuntimeTachographParityValidationResultDto.java index 57d4e88..4783299 100644 --- a/src/main/java/at/procon/eventhub/processing/eventprocessing/validation/RuntimeTachographParityValidationResultDto.java +++ b/src/main/java/at/procon/eventhub/tachographfilesession/processing/validation/RuntimeTachographParityValidationResultDto.java @@ -1,4 +1,4 @@ -package at.procon.eventhub.processing.eventprocessing.validation; +package at.procon.eventhub.tachographfilesession.processing.validation; import java.util.LinkedHashMap; import java.util.List; diff --git a/src/main/java/at/procon/eventhub/processing/eventprocessing/validation/RuntimeTachographParityValidationService.java b/src/main/java/at/procon/eventhub/tachographfilesession/processing/validation/RuntimeTachographParityValidationService.java similarity index 99% rename from src/main/java/at/procon/eventhub/processing/eventprocessing/validation/RuntimeTachographParityValidationService.java rename to src/main/java/at/procon/eventhub/tachographfilesession/processing/validation/RuntimeTachographParityValidationService.java index 290ba67..a4498a8 100644 --- a/src/main/java/at/procon/eventhub/processing/eventprocessing/validation/RuntimeTachographParityValidationService.java +++ b/src/main/java/at/procon/eventhub/tachographfilesession/processing/validation/RuntimeTachographParityValidationService.java @@ -1,4 +1,4 @@ -package at.procon.eventhub.processing.eventprocessing.validation; +package at.procon.eventhub.tachographfilesession.processing.validation; import at.procon.eventhub.processing.dto.UnifiedRuntimeDerivedProjectionResultDto; import at.procon.eventhub.processing.driverworkingtime.dto.DriverWorkingTimeProcessingResultDto; @@ -9,7 +9,7 @@ import at.procon.eventhub.processing.eventprocessing.dto.RuntimeEventProcessingA import at.procon.eventhub.processing.eventprocessing.dto.RuntimeEventProcessingPartitionResultDto; import at.procon.eventhub.processing.eventprocessing.dto.RuntimeEventProcessingResultDto; import at.procon.eventhub.processing.eventprocessing.partition.RuntimeEventPartitioningStrategy; -import at.procon.eventhub.processing.eventprocessing.profile.TachographDriverEsperRuntimeEventProcessingProfile; +import at.procon.eventhub.tachographfilesession.processing.profile.TachographDriverEsperRuntimeEventProcessingProfile; import at.procon.eventhub.processing.model.UnifiedEventSourceFamily; import at.procon.eventhub.processing.model.UnifiedRuntimeEventBackend; import at.procon.eventhub.tachographfilesession.dto.TachographEsperDriverProcessingResultDto; diff --git a/src/test/java/at/procon/eventhub/config/EventHubPropertiesTest.java b/src/test/java/at/procon/eventhub/config/EventHubPropertiesTest.java index 43b2249..200ad7b 100644 --- a/src/test/java/at/procon/eventhub/config/EventHubPropertiesTest.java +++ b/src/test/java/at/procon/eventhub/config/EventHubPropertiesTest.java @@ -2,6 +2,7 @@ package at.procon.eventhub.config; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertSame; import org.junit.jupiter.api.Test; @@ -31,4 +32,14 @@ class EventHubPropertiesTest { assertFalse(legalRequirements.isResetSessionAfterUse()); } + + @Test + void runtimeProcessingAndLegacyTachographProcessingShareTheSameSettingsInstance() { + EventHubProperties properties = new EventHubProperties(); + + properties.getRuntimeProcessing().setSignificantDrivingMinutes(9); + + assertSame(properties.getRuntimeProcessing(), properties.getTachographFileSession().getProcessing()); + assertEquals(9, properties.getTachographFileSession().getProcessing().getSignificantDrivingMinutes()); + } } diff --git a/src/test/java/at/procon/eventhub/processing/eventprocessing/profile/TachographDriverEsperRuntimeEventProcessingProfileTest.java b/src/test/java/at/procon/eventhub/processing/eventprocessing/profile/TachographDriverEsperRuntimeEventProcessingProfileTest.java index 94e78b1..c8c317a 100644 --- a/src/test/java/at/procon/eventhub/processing/eventprocessing/profile/TachographDriverEsperRuntimeEventProcessingProfileTest.java +++ b/src/test/java/at/procon/eventhub/processing/eventprocessing/profile/TachographDriverEsperRuntimeEventProcessingProfileTest.java @@ -15,6 +15,7 @@ import at.procon.eventhub.processing.eventprocessing.partition.RuntimeEventParti import at.procon.eventhub.processing.model.UnifiedEventSourceFamily; import at.procon.eventhub.processing.model.UnifiedRuntimeProcessingRequest; import at.procon.eventhub.processing.service.RuntimeDriverWorkingTimeScopeProcessingService; +import at.procon.eventhub.tachographfilesession.processing.profile.TachographDriverEsperRuntimeEventProcessingProfile; import java.time.OffsetDateTime; import java.util.List; import java.util.Map; diff --git a/src/test/java/at/procon/eventhub/processing/eventprocessing/support/RuntimeSupportEvidenceNormalizerTest.java b/src/test/java/at/procon/eventhub/processing/eventprocessing/support/RuntimeSupportEvidenceNormalizerTest.java index 79eee4e..b0ccec0 100644 --- a/src/test/java/at/procon/eventhub/processing/eventprocessing/support/RuntimeSupportEvidenceNormalizerTest.java +++ b/src/test/java/at/procon/eventhub/processing/eventprocessing/support/RuntimeSupportEvidenceNormalizerTest.java @@ -24,7 +24,7 @@ class RuntimeSupportEvidenceNormalizerTest { private final RuntimeSupportEvidenceNormalizer normalizer = new RuntimeSupportEvidenceNormalizer(objectMapper); @Test - void normalizesVehicleOnlyIgnitionWithPositionAsTachographPositionSupportEvidence() { + void normalizesVehicleOnlyIgnitionWithPositionAsDriverWorkingTimeSupportEvidence() { EventHubEventDto ignition = vehicleOnlyEvent( "ignition-on-1", EventDomain.IGNITION, @@ -36,7 +36,7 @@ class RuntimeSupportEvidenceNormalizerTest { new GeoPointDto(new BigDecimal("48.2082"), new BigDecimal("16.3738")) ); - RuntimeSupportEvidenceNormalizationResult result = normalizer.normalizeForTachographDriver( + RuntimeSupportEvidenceNormalizationResult result = normalizer.normalizeForDriverWorkingTime( "DRIVER-1", List.of(ignition) ); @@ -53,7 +53,7 @@ class RuntimeSupportEvidenceNormalizerTest { } @Test - void keepsTachographSupportDomainButAddsDriverAndNormalizedRawMetadata() { + void keepsDirectSupportDomainButAddsDriverAndNormalizedRawMetadata() { EventHubEventDto border = vehicleOnlyEvent( "border-1", EventDomain.BORDER_CROSSING, @@ -65,7 +65,7 @@ class RuntimeSupportEvidenceNormalizerTest { new GeoPointDto(new BigDecimal("48.5"), new BigDecimal("16.5")) ); - EventHubEventDto normalized = normalizer.normalizeForTachographDriver("DRIVER-1", List.of(border)) + EventHubEventDto normalized = normalizer.normalizeForDriverWorkingTime("DRIVER-1", List.of(border)) .normalizedEvents() .getFirst(); @@ -97,7 +97,7 @@ class RuntimeSupportEvidenceNormalizerTest { null ); - RuntimeSupportEvidenceNormalizationResult result = normalizer.normalizeForTachographDriver( + RuntimeSupportEvidenceNormalizationResult result = normalizer.normalizeForDriverWorkingTime( "DRIVER-1", List.of(cardUsage) ); diff --git a/src/test/java/at/procon/eventhub/processing/eventprocessing/validation/RuntimeMixedSourceEvidenceValidationServiceTest.java b/src/test/java/at/procon/eventhub/processing/eventprocessing/validation/RuntimeMixedSourceEvidenceValidationServiceTest.java index b955e43..b5b2293 100644 --- a/src/test/java/at/procon/eventhub/processing/eventprocessing/validation/RuntimeMixedSourceEvidenceValidationServiceTest.java +++ b/src/test/java/at/procon/eventhub/processing/eventprocessing/validation/RuntimeMixedSourceEvidenceValidationServiceTest.java @@ -14,7 +14,7 @@ import at.procon.eventhub.processing.eventprocessing.dto.RuntimeEventProcessingA import at.procon.eventhub.processing.eventprocessing.dto.RuntimeEventProcessingPartitionResultDto; import at.procon.eventhub.processing.eventprocessing.dto.RuntimeEventProcessingResultDto; import at.procon.eventhub.processing.eventprocessing.partition.RuntimeEventPartitioningStrategy; -import at.procon.eventhub.processing.eventprocessing.profile.TachographDriverEsperRuntimeEventProcessingProfile; +import at.procon.eventhub.tachographfilesession.processing.profile.TachographDriverEsperRuntimeEventProcessingProfile; import at.procon.eventhub.processing.model.UnifiedEventSourceFamily; import at.procon.eventhub.processing.model.UnifiedRuntimeEventBackend; import at.procon.eventhub.processing.dto.UnifiedRuntimeProcessingApiRequest; diff --git a/src/test/java/at/procon/eventhub/processing/eventprocessing/validation/RuntimeTachographParityValidationServiceTest.java b/src/test/java/at/procon/eventhub/processing/eventprocessing/validation/RuntimeTachographParityValidationServiceTest.java index 73c011f..84118e3 100644 --- a/src/test/java/at/procon/eventhub/processing/eventprocessing/validation/RuntimeTachographParityValidationServiceTest.java +++ b/src/test/java/at/procon/eventhub/processing/eventprocessing/validation/RuntimeTachographParityValidationServiceTest.java @@ -10,7 +10,10 @@ import at.procon.eventhub.processing.eventprocessing.RuntimeEventProcessingServi import at.procon.eventhub.processing.eventprocessing.dto.RuntimeEventProcessingPartitionResultDto; import at.procon.eventhub.processing.eventprocessing.dto.RuntimeEventProcessingResultDto; import at.procon.eventhub.processing.eventprocessing.partition.RuntimeEventPartitioningStrategy; -import at.procon.eventhub.processing.eventprocessing.profile.TachographDriverEsperRuntimeEventProcessingProfile; +import at.procon.eventhub.tachographfilesession.processing.profile.TachographDriverEsperRuntimeEventProcessingProfile; +import at.procon.eventhub.tachographfilesession.processing.validation.RuntimeTachographParityValidationApiRequest; +import at.procon.eventhub.tachographfilesession.processing.validation.RuntimeTachographParityValidationResultDto; +import at.procon.eventhub.tachographfilesession.processing.validation.RuntimeTachographParityValidationService; import at.procon.eventhub.processing.model.UnifiedRuntimeProcessingRequest; import at.procon.eventhub.tachographfilesession.dto.TachographEsperDriverProcessingResultDto; import at.procon.eventhub.tachographfilesession.model.DriverExtractionSession; diff --git a/src/test/java/at/procon/eventhub/processing/service/TachographFileSessionRuntimeEventLoaderTest.java b/src/test/java/at/procon/eventhub/processing/service/TachographFileSessionRuntimeEventLoaderTest.java index 6fa1547..2ede05a 100644 --- a/src/test/java/at/procon/eventhub/processing/service/TachographFileSessionRuntimeEventLoaderTest.java +++ b/src/test/java/at/procon/eventhub/processing/service/TachographFileSessionRuntimeEventLoaderTest.java @@ -19,6 +19,9 @@ import at.procon.eventhub.tachographfilesession.model.ExtractedVehicleRegistrati import at.procon.eventhub.tachographfilesession.model.ExtractionStats; import at.procon.eventhub.tachographfilesession.model.TachographFileSession; import at.procon.eventhub.tachographfilesession.model.TachographFileSessionMetadata; +import at.procon.eventhub.tachographfilesession.processing.service.TachographFileSessionRuntimeEventLoader; +import at.procon.eventhub.tachographfilesession.processing.service.TachographFileSessionUnifiedDriverEventSource; +import at.procon.eventhub.tachographfilesession.processing.service.TachographFileSessionUnifiedVehicleEventSource; import at.procon.eventhub.tachographfilesession.service.DriverKeyFactory; import at.procon.eventhub.tachographfilesession.service.DriverTimelineBuilder; import at.procon.eventhub.tachographfilesession.model.TachographCompositeSession; diff --git a/src/test/java/at/procon/eventhub/processing/service/UnifiedDriverEventSourceServiceTest.java b/src/test/java/at/procon/eventhub/processing/service/UnifiedDriverEventSourceServiceTest.java index 81969c6..e023b11 100644 --- a/src/test/java/at/procon/eventhub/processing/service/UnifiedDriverEventSourceServiceTest.java +++ b/src/test/java/at/procon/eventhub/processing/service/UnifiedDriverEventSourceServiceTest.java @@ -18,6 +18,7 @@ import at.procon.eventhub.tachographfilesession.model.ExtractedVehicleRegistrati import at.procon.eventhub.tachographfilesession.model.ExtractionStats; import at.procon.eventhub.tachographfilesession.model.TachographFileSession; import at.procon.eventhub.tachographfilesession.model.TachographFileSessionMetadata; +import at.procon.eventhub.tachographfilesession.processing.service.TachographFileSessionUnifiedDriverEventSource; import at.procon.eventhub.tachographfilesession.service.DriverKeyFactory; import at.procon.eventhub.tachographfilesession.service.DriverTimelineBuilder; import at.procon.eventhub.tachographfilesession.service.InMemoryTachographFileSessionRepository; diff --git a/src/test/java/at/procon/eventhub/processing/service/UnifiedDriverTimelineServiceTest.java b/src/test/java/at/procon/eventhub/processing/service/UnifiedDriverTimelineServiceTest.java index de007c0..5a142c3 100644 --- a/src/test/java/at/procon/eventhub/processing/service/UnifiedDriverTimelineServiceTest.java +++ b/src/test/java/at/procon/eventhub/processing/service/UnifiedDriverTimelineServiceTest.java @@ -17,6 +17,7 @@ import at.procon.eventhub.tachographfilesession.model.ExtractedVehicleRegistrati import at.procon.eventhub.tachographfilesession.model.ExtractionStats; import at.procon.eventhub.tachographfilesession.model.TachographFileSession; import at.procon.eventhub.tachographfilesession.model.TachographFileSessionMetadata; +import at.procon.eventhub.tachographfilesession.processing.service.TachographFileSessionUnifiedDriverTimelineSource; import at.procon.eventhub.tachographfilesession.service.DriverKeyFactory; import at.procon.eventhub.tachographfilesession.service.EventBackedDriverTimelineBuilder; import at.procon.eventhub.tachographfilesession.service.InMemoryTachographFileSessionRepository; diff --git a/src/test/java/at/procon/eventhub/processing/service/UnifiedVehicleEventSourceServiceTest.java b/src/test/java/at/procon/eventhub/processing/service/UnifiedVehicleEventSourceServiceTest.java index 7cce143..91015f4 100644 --- a/src/test/java/at/procon/eventhub/processing/service/UnifiedVehicleEventSourceServiceTest.java +++ b/src/test/java/at/procon/eventhub/processing/service/UnifiedVehicleEventSourceServiceTest.java @@ -18,6 +18,7 @@ import at.procon.eventhub.tachographfilesession.model.ExtractedVehicleRegistrati import at.procon.eventhub.tachographfilesession.model.ExtractionStats; import at.procon.eventhub.tachographfilesession.model.TachographFileSession; import at.procon.eventhub.tachographfilesession.model.TachographFileSessionMetadata; +import at.procon.eventhub.tachographfilesession.processing.service.TachographFileSessionUnifiedVehicleEventSource; import at.procon.eventhub.tachographfilesession.service.DriverKeyFactory; import at.procon.eventhub.tachographfilesession.service.DriverTimelineBuilder; import at.procon.eventhub.tachographfilesession.service.InMemoryTachographFileSessionRepository;