package de.thpeetz.kontor.bookshelf;

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.bookshelf.data.ArticleAuthorRepository;
import de.thpeetz.kontor.bookshelf.data.AuthorRepository;
import de.thpeetz.kontor.bookshelf.data.BookAuthorRepository;
import de.thpeetz.kontor.bookshelf.data.BookRepository;
import de.thpeetz.kontor.bookshelf.data.BookshelfPublisherRepository;
import lombok.extern.slf4j.Slf4j;

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

    boolean alreadySetup = false;

    @Autowired
    private BookshelfPublisherRepository publisherRepository;

    @Autowired
    private AuthorRepository authorRepository;

    @Autowired
    private ArticleAuthorRepository articleAuthorRepository;

    @Autowired
    private BookRepository bookRepository;

    @Autowired
    private BookAuthorRepository bookAuthorRepository;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        if (alreadySetup) {
            log.info("SetupModuleBookshelf already executed, skipping");
            return;
        }
        log.info("Set up Bookshelf data");
    }
}
