package at.procon.dip.domain.time.startup;

import at.procon.dip.domain.time.service.LeitstandTimeImportService;
import at.procon.dip.runtime.condition.ConditionalOnRuntimeMode;
import at.procon.dip.runtime.config.RuntimeMode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

@Component
@ConditionalOnRuntimeMode(RuntimeMode.NEW)
@ConditionalOnProperty(prefix = "dip.time.leitstand", name = {"enabled", "startup-sync-enabled"}, havingValue = "true")
@RequiredArgsConstructor
@Slf4j
public class LeitstandTimeImportStartupRunner implements ApplicationRunner {
    private final LeitstandTimeImportService importService;
    @Override
    public void run(ApplicationArguments args) {
        log.info("Starting Leitstand TIME import (T2)");
        importService.runSync();
    }
}
