package at.procon.eventhub.tachograph.service;

import at.procon.eventhub.importing.ImportPlanItemDto;
import at.procon.eventhub.importing.ImportTimeChunkDto;
import at.procon.eventhub.importing.extraction.AbstractNoopExtractionBatchExecutor;
import at.procon.eventhub.tachograph.dto.TachographExtractionBatchResultDto;
import at.procon.eventhub.tachograph.dto.TachographImportRequest;
import java.util.UUID;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.stereotype.Service;

/**
 * Default executor used by the generated skeleton. It marks the route contract
 * and scheduling/execution lifecycle but intentionally does not read the real
 * tachograph DB. Replace this bean with an implementation that executes the
 * SQL for each extractionCode and sends mapped EventHubEventDto records to
 * direct:eventhub-normalized-input.
 */
@Service
@ConditionalOnMissingBean(TachographExtractionBatchExecutor.class)
@ConditionalOnExpression("!T(org.springframework.util.StringUtils).hasText('${eventhub.tachograph.datasource.jdbc-url:}')")
public class NoopTachographExtractionBatchExecutor
        extends AbstractNoopExtractionBatchExecutor<TachographImportRequest, TachographExtractionBatchResultDto>
        implements TachographExtractionBatchExecutor {

    @Override
    protected TachographExtractionBatchResultDto emptyResult(
            UUID packageId,
            ImportPlanItemDto planItem,
            ImportTimeChunkDto chunk
    ) {
        return new TachographExtractionBatchResultDto(
                packageId,
                planItem.extractionCode(),
                planItem.sourceKind(),
                0,
                0,
                0,
                0,
                false,
                null,
                null,
                null,
                null,
                java.util.Map.of()
        );
    }

    @Override
    protected String providerName() {
        return "tachograph";
    }
}
