package at.procon.eventhub.tachograph.service;

import at.procon.eventhub.dto.EventFamily;
import at.procon.eventhub.importing.extraction.ExtractionDefinition;
import at.procon.eventhub.importing.extraction.ExtractionDefinitionRegistry;
import at.procon.eventhub.tachograph.dto.TachographImportRequest;
import java.util.List;
import org.springframework.stereotype.Component;

@Component
public class TachographExtractionDefinitionRegistry extends ExtractionDefinitionRegistry<TachographImportRequest> {

    public TachographExtractionDefinitionRegistry(
            CardActivityRowMapper cardActivityRowMapper,
            VuActivityRowMapper vuActivityRowMapper,
            IwCycleCardEventRowMapper iwCycleCardEventRowMapper,
            CardVehiclesUsedCardEventRowMapper cardVehiclesUsedCardEventRowMapper,
            VuBorderCrossingRowMapper vuBorderCrossingRowMapper,
            CardBorderCrossingRowMapper cardBorderCrossingRowMapper,
            VuLoadUnloadRowMapper vuLoadUnloadRowMapper,
            CardLoadUnloadRowMapper cardLoadUnloadRowMapper,
            VuSpecificConditionRowMapper vuSpecificConditionRowMapper,
            CardSpecificConditionRowMapper cardSpecificConditionRowMapper,
            VuPositionRowMapper vuPositionRowMapper,
            CardPositionRowMapper cardPositionRowMapper,
            VuPlaceRowMapper vuPlaceRowMapper,
            CardPlaceRowMapper cardPlaceRowMapper,
            SpeedingEventRowMapper speedingEventRowMapper
    ) {
        super(List.of(
                new ExtractionDefinition<>(
                        "CARD_ACTIVITY",
                        EventFamily.DRIVER_ACTIVITY,
                        "DRIVER_CARD",
                        "DRIVER",
                        "classpath:sql/tachograph/card-activity.sql",
                        cardActivityRowMapper
                ),
                new ExtractionDefinition<>(
                        "VU_ACTIVITY",
                        EventFamily.DRIVER_ACTIVITY,
                        "VEHICLE_UNIT",
                        "VEHICLE",
                        "classpath:sql/tachograph/vu-activity.sql",
                        vuActivityRowMapper
                ),
                new ExtractionDefinition<>(
                        "IW_CYCLE",
                        EventFamily.DRIVER_CARD,
                        "VEHICLE_UNIT",
                        "BOTH",
                        "classpath:sql/tachograph/iw-cycle.sql",
                        iwCycleCardEventRowMapper
                ),
                new ExtractionDefinition<>(
                        "CARD_VEHICLES_USED",
                        EventFamily.DRIVER_CARD,
                        "DRIVER_CARD",
                        "DRIVER",
                        "classpath:sql/tachograph/card-vehicles-used.sql",
                        cardVehiclesUsedCardEventRowMapper
                ),
                new ExtractionDefinition<>(
                        "VU_BORDER_CROSSING",
                        EventFamily.BORDER_CROSSING,
                        "VEHICLE_UNIT",
                        "VEHICLE",
                        "classpath:sql/tachograph/vu-border-crossing.sql",
                        vuBorderCrossingRowMapper
                ),
                new ExtractionDefinition<>(
                        "CARD_BORDER_CROSSING",
                        EventFamily.BORDER_CROSSING,
                        "DRIVER_CARD",
                        "DRIVER",
                        "classpath:sql/tachograph/card-border-crossing.sql",
                        cardBorderCrossingRowMapper
                ),
                new ExtractionDefinition<>(
                        "VU_LOAD_UNLOAD",
                        EventFamily.LOAD_UNLOAD,
                        "VEHICLE_UNIT",
                        "VEHICLE",
                        "classpath:sql/tachograph/vu-load-unload.sql",
                        vuLoadUnloadRowMapper
                ),
                new ExtractionDefinition<>(
                        "CARD_LOAD_UNLOAD",
                        EventFamily.LOAD_UNLOAD,
                        "DRIVER_CARD",
                        "DRIVER",
                        "classpath:sql/tachograph/card-load-unload.sql",
                        cardLoadUnloadRowMapper
                ),
                new ExtractionDefinition<>(
                        "VU_SPECIFIC_CONDITION",
                        EventFamily.SPECIFIC_CONDITION,
                        "VEHICLE_UNIT",
                        "VEHICLE",
                        "classpath:sql/tachograph/vu-specific-condition.sql",
                        vuSpecificConditionRowMapper
                ),
                new ExtractionDefinition<>(
                        "CARD_SPECIFIC_CONDITION",
                        EventFamily.SPECIFIC_CONDITION,
                        "DRIVER_CARD",
                        "DRIVER",
                        "classpath:sql/tachograph/card-specific-condition.sql",
                        cardSpecificConditionRowMapper
                ),
                new ExtractionDefinition<>(
                        "VU_POSITION",
                        EventFamily.POSITION,
                        "VEHICLE_UNIT",
                        "VEHICLE",
                        "classpath:sql/tachograph/vu-position.sql",
                        vuPositionRowMapper
                ),
                new ExtractionDefinition<>(
                        "CARD_POSITION",
                        EventFamily.POSITION,
                        "DRIVER_CARD",
                        "DRIVER",
                        "classpath:sql/tachograph/card-position.sql",
                        cardPositionRowMapper
                ),
                new ExtractionDefinition<>(
                        "VU_PLACE",
                        EventFamily.PLACE,
                        "VEHICLE_UNIT",
                        "VEHICLE",
                        "classpath:sql/tachograph/vu-place.sql",
                        vuPlaceRowMapper
                ),
                new ExtractionDefinition<>(
                        "CARD_PLACE",
                        EventFamily.PLACE,
                        "DRIVER_CARD",
                        "DRIVER",
                        "classpath:sql/tachograph/card-place.sql",
                        cardPlaceRowMapper
                ),
                new ExtractionDefinition<>(
                        "SPEEDING_EVENTS",
                        EventFamily.SPEEDING,
                        "VEHICLE_UNIT",
                        "VEHICLE",
                        "classpath:sql/tachograph/speeding-events.sql",
                        speedingEventRowMapper
                )
        ));
    }
}
