package de.thpeetz.kontor.tysc;

import de.thpeetz.kontor.tysc.data.Card;
import de.thpeetz.kontor.tysc.data.CardSet;
import de.thpeetz.kontor.tysc.data.Player;
import de.thpeetz.kontor.tysc.data.Rooster;
import de.thpeetz.kontor.tysc.data.Sport;
import de.thpeetz.kontor.tysc.data.Team;
import de.thpeetz.kontor.tysc.data.Vendor;
import de.thpeetz.kontor.tysc.repository.CardRepository;
import de.thpeetz.kontor.tysc.repository.CardSetRepository;
import de.thpeetz.kontor.tysc.repository.FieldPositionRepository;
import de.thpeetz.kontor.tysc.repository.PlayerRepository;
import de.thpeetz.kontor.tysc.repository.RoosterRepository;
import de.thpeetz.kontor.tysc.repository.SportRepository;
import de.thpeetz.kontor.tysc.repository.TeamRepository;
import de.thpeetz.kontor.tysc.repository.VendorRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

import de.thpeetz.kontor.tysc.data.FieldPosition;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Component
public class SetupModuleTysc implements ApplicationListener<ContextRefreshedEvent> {

    boolean alreadySetup = false;

    @Autowired
    private SportRepository sportRepository;

    @Autowired
    private TeamRepository teamRepository;

    @Autowired
    private VendorRepository vendorRepository;

    @Autowired
    private FieldPositionRepository fieldPositionRepository;

    @Autowired
    private PlayerRepository playerRepository;

    @Autowired
    private CardSetRepository cardSetRepository;

    @Autowired
    private RoosterRepository roosterRepository;

    @Autowired
    private CardRepository cardRepository;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        if (alreadySetup) {
            log.info("SetupDataLoader(TYSC) already executed, skipping");
            return;
        }
        log.info("Setp up TYSC data");
        alreadySetup = true;
    }
}
