package de.thpeetz.kontor

import de.thpeetz.kontor.comics.*
import org.springframework.boot.ApplicationRunner
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
class KontorConfiguration {
    @Bean
    fun databaseInitializer(artistRepository: ArtistRepository,
                            publisherRepository: PublisherRepository,
                            comicRepository: ComicRepository,
                            issueRepository: IssueRepository
    ) = ApplicationRunner {

        artistRepository.save(Artist("Turner, Michael"))
        artistRepository.save(Artist("Bendis, Brian Michael"))
        artistRepository.save(Artist("Land, Greg"))
        artistRepository.save(Artist("Whedon, Joss"))
        val marvel = publisherRepository.save(Publisher("Marvel"))
        val aspen = publisherRepository.save(Publisher("Aspen"))
        publisherRepository.save(Publisher("DC"))
        val de = publisherRepository.save(Publisher("Dynamite Entertainment"))
        val wildstorm = publisherRepository.save(Publisher("WildStorm"))
        val bongo = publisherRepository.save(Publisher("Bongo"))
        val image = publisherRepository.save(Publisher("Image"))
        val darkHorse = publisherRepository.save(Publisher("Dark Horse Comics"))
        val cliffhanger = publisherRepository.save(Publisher("Cliffhanger"))
        comicRepository.save(Comic(title = "X-Men", publisher = marvel, currentOrder = false, completed = false))
        val redSonja = comicRepository.save(Comic(title = "Red Sonja", publisher = de, currentOrder = false, completed = false))
        val x23 = comicRepository.save(Comic(title = "X-23", publisher = marvel, currentOrder = false, completed = false))
        comicRepository.save(Comic(title = "Simpsons Comics", publisher = bongo, currentOrder = false, completed = false))
        comicRepository.save(Comic(title = "Futurama Comics", publisher = bongo, currentOrder = false, completed = false))
        comicRepository.save(Comic(title = "Bomb Queen III: The Good, The Bad and The Lovely", publisher = image, currentOrder = false, completed = false))
        comicRepository.save(Comic(title = "Bomb Queen IV: Suicide Bomber", publisher = image, currentOrder = false, completed = false))
        comicRepository.save(Comic(title = "Gen13", publisher = wildstorm, currentOrder = false, completed = false))
        val bombqueen = comicRepository.save(Comic(title = "Bomb Queen II: Queen of Hearts", publisher = image, currentOrder = false, completed = false))
        comicRepository.save(Comic(title = "Iron & The Maiden",publisher = aspen,currentOrder = false,completed = false))
        comicRepository.save(Comic(title = "Fathom",publisher = aspen,currentOrder = false,completed = false))
        comicRepository.save(Comic(title = "Soulfire",publisher = aspen,currentOrder = false,completed = false))
        comicRepository.save(Comic(title = "Star Wars: Rebellion",publisher = darkHorse,currentOrder = false,completed = false))
        comicRepository.save(Comic(title = "Star Wars: Rebellion",publisher = darkHorse,currentOrder = false,completed = false))
        comicRepository.save(Comic(title = "Star Wars: Knights of the Old Republic",publisher = darkHorse,currentOrder = false,completed = false))
        comicRepository.save(Comic(title = "Star Wars: Legacy",publisher = darkHorse,currentOrder = false,completed = false))
        comicRepository.save(Comic(title = "Star Wars: Dark Times", publisher = darkHorse, currentOrder = false, completed = false))
        comicRepository.save(Comic(title = "Samurai: Heaven and Earth", publisher = darkHorse, currentOrder = false, completed = false))
        val battlpope = comicRepository.save(Comic(title = "Battle Pope", publisher = image,currentOrder = false, completed = false))
        comicRepository.save(Comic(title = "Danger Girl", publisher = cliffhanger, currentOrder = false, completed = false))
        val marville = comicRepository.save(Comic(title = "Marville", publisher = marvel, currentOrder = false, completed = false))
        issueRepository.save(Issue(number = "0", comic = redSonja, gelesen = true))
        issueRepository.save(Issue(number = "1", comic = redSonja, gelesen = true))
        issueRepository.save(Issue(number = "2", comic = redSonja, gelesen = true))
        issueRepository.save(Issue(number = "1", comic = x23, gelesen = false))
        issueRepository.save(Issue(number = "1", comic = bombqueen, gelesen = false))
        issueRepository.save(Issue(number = "2", comic = bombqueen, gelesen = false))
        issueRepository.save(Issue(number = "3", comic = bombqueen, gelesen = false))
        issueRepository.save(Issue(number = "4", comic = bombqueen, gelesen = false))
        issueRepository.save(Issue(number = "1", comic = battlpope, gelesen = false))
        issueRepository.save(Issue(number = "2", comic = battlpope, gelesen = false))
        issueRepository.save(Issue(number = "3", comic = battlpope, gelesen = false))
        issueRepository.save(Issue(number = "4", comic = battlpope, gelesen = false))
        issueRepository.save(Issue(number = "5", comic = battlpope, gelesen = false))
        issueRepository.save(Issue(number = "6", comic = battlpope, gelesen = false))
        issueRepository.save(Issue(number = "7", comic = battlpope, gelesen = false))
        issueRepository.save(Issue(number = "8", comic = battlpope, gelesen = false))
        issueRepository.save(Issue(number = "9", comic = battlpope, gelesen = false))
        issueRepository.save(Issue(number = "10", comic = battlpope, gelesen = false))
        issueRepository.save(Issue(number = "11", comic = battlpope, gelesen = false))
        issueRepository.save(Issue(number = "12", comic = battlpope, gelesen = false))
        issueRepository.save(Issue(number = "1", comic = marville, gelesen = false))
        issueRepository.save(Issue(number = "2", comic = marville, gelesen = false))
        issueRepository.save(Issue(number = "3", comic = marville, gelesen = false))
        issueRepository.save(Issue(number = "4", comic = marville, gelesen = false))
        issueRepository.save(Issue(number = "5", comic = marville, gelesen = false))
        issueRepository.save(Issue(number = "6", comic = marville, gelesen = false))
        issueRepository.save(Issue(number = "7", comic = marville, gelesen = false))
    }
}
