package at.procon.eventhub.importing.extraction;

import at.procon.eventhub.importing.ExtractionBatchResult;
import at.procon.eventhub.importing.ImportPlanItemDto;
import at.procon.eventhub.importing.ImportRunRequest;
import at.procon.eventhub.importing.ImportTimeChunkDto;
import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public abstract class AbstractNoopExtractionBatchExecutor<R extends ImportRunRequest, B extends ExtractionBatchResult>
        implements ExtractionBatchExecutor<R, B> {

    private final Logger log = LoggerFactory.getLogger(getClass());

    @Override
    public B execute(
            UUID importRunId,
            UUID packageId,
            int eventSourceId,
            R request,
            ImportPlanItemDto planItem,
            ImportTimeChunkDto chunk
    ) {
        log.warn("No concrete {} SQL extractor configured. importRunId={} packageId={} extractionCode={} sourceKind={} chunk={}",
                providerName(), importRunId, packageId, planItem.extractionCode(), planItem.sourceKind(), chunk.sequence());
        return emptyResult(packageId, planItem, chunk);
    }

    protected abstract B emptyResult(UUID packageId, ImportPlanItemDto planItem, ImportTimeChunkDto chunk);

    protected String providerName() {
        return "provider";
    }
}
