package at.procon.eventhub.processing.service;

import at.procon.eventhub.processing.dto.UnifiedRuntimeDriverWorkingTimeScopeResultDto;
import at.procon.eventhub.processing.dto.UnifiedRuntimeProcessingApiRequest;
import at.procon.eventhub.processing.dto.UnifiedRuntimeTachographEsperScopeResultDto;

/**
 * @deprecated Compatibility adapter. Use {@link RuntimeDriverWorkingTimeScopeProcessingService};
 * tachograph files/databases are only one possible source for the common driver working-time runtime plan.
 */
@Deprecated(forRemoval = false)
public class UnifiedRuntimeTachographEsperScopeProcessingService {

    private final RuntimeDriverWorkingTimeScopeProcessingService delegate;

    public UnifiedRuntimeTachographEsperScopeProcessingService(
            RuntimeDriverWorkingTimeScopeProcessingService delegate
    ) {
        this.delegate = delegate;
    }

    public UnifiedRuntimeTachographEsperScopeResultDto processScope(UnifiedRuntimeProcessingApiRequest apiRequest) {
        return toLegacy(delegate.processScope(apiRequest));
    }

    public UnifiedRuntimeTachographEsperScopeResultDto processScope(
            UnifiedRuntimeProcessingApiRequest apiRequest,
            boolean includePartitionDebug
    ) {
        return toLegacy(delegate.processScope(apiRequest, includePartitionDebug));
    }

    private UnifiedRuntimeTachographEsperScopeResultDto toLegacy(
            UnifiedRuntimeDriverWorkingTimeScopeResultDto result
    ) {
        return new UnifiedRuntimeTachographEsperScopeResultDto(
                result.request(),
                result.inputEventCount(),
                result.selectedDriverCount(),
                result.discoveredVehicleCount(),
                result.discoveredVehicles(),
                result.driverResults(),
                result.partitionDebugByDriver(),
                result.notes(),
                result.warnings()
        );
    }
}
