/*
 * Copyright 2012-2013 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package cz.muni.fi.pa165.methanolmanager.dal;

import cz.muni.fi.pa165.methanolmanager.dal.domain.Bottle;
import cz.muni.fi.pa165.methanolmanager.dal.domain.Make;
import cz.muni.fi.pa165.methanolmanager.dal.domain.Producer;
import cz.muni.fi.pa165.methanolmanager.dal.domain.Store;
import cz.muni.fi.pa165.methanolmanager.dal.repository.BottleRepository;
import cz.muni.fi.pa165.methanolmanager.dal.repository.MakeRepository;
import cz.muni.fi.pa165.methanolmanager.dal.repository.ProducerRepository;
import cz.muni.fi.pa165.methanolmanager.dal.repository.StoreRepository;
import java.util.Date;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.orm.jpa.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

@Configuration
@EnableAutoConfiguration
@EnableJpaRepositories
@EntityScan(basePackages = "cz.muni.fi.pa165.methanolmanager.dal.domain")
@ComponentScan
public class DalConfig {
    @Bean
    InitializingBean seedData(final StoreRepository storeRepository,
            final ProducerRepository producerRepository,
            final MakeRepository makeRepository,
            final BottleRepository bottleRepository) {
        return new InitializingBean() {
            @Override
            public void afterPropertiesSet() throws Exception {
                Store s1 = new Store("Brnenka", "Lidicka 234");
                Store s2 = new Store("Tesco", "Kr. Pole");
                Store s3 = new Store("NonStop", "Arabska 15");

                storeRepository.save(s1);
                storeRepository.save(s2);
                storeRepository.save(s3);

                Producer p1 = new Producer("Bozkov Producer");
                Producer p2 = new Producer("Finlandia Producer");
                Producer p3 = new Producer("Bechcer Producer");

                producerRepository.save(p1);
                producerRepository.save(p2);
                producerRepository.save(p3);

                Make m1 = new Make("Bozkov", p1);
                Make m2 = new Make("Finlandia", p2);
                Make m3 = new Make("Bechcer", p3);

                makeRepository.save(m1);
                makeRepository.save(m2);
                makeRepository.save(m3);

                bottleRepository.save(new Bottle("Tuzemak", new Date(), new Date(), false, m1, s1));
                bottleRepository.save(new Bottle("Vodka", new Date(), new Date(), false, m2, s2));
                bottleRepository.save(new Bottle("Becherovka", new Date(), new Date(), false, m3, s3));
                bottleRepository.save(new Bottle("Tuzemak", new Date(), new Date(), false, m1, s1));
                bottleRepository.save(new Bottle("Vodka", new Date(), new Date(), false, m2, s2));
                bottleRepository.save(new Bottle("Becherovka", new Date(), new Date(), false, m3, s3));
                bottleRepository.save(new Bottle("Tuzemak", new Date(), new Date(), false, m1, s1));
                bottleRepository.save(new Bottle("Vodka", new Date(), new Date(), false, m2, s2));
                bottleRepository.save(new Bottle("Becherovka", new Date(), new Date(), false, m3, s3));
                bottleRepository.save(new Bottle("Tuzemak", new Date(), new Date(), false, m1, s1));
                bottleRepository.save(new Bottle("Vodka", new Date(), new Date(), false, m2, s2));
                bottleRepository.save(new Bottle("Becherovka", new Date(), new Date(), false, m3, s3));
            }
        };
    }
}

@@ -1826,2542 +1826,6 @@
 g %7B%0A
-    @Bean%0A    InitializingBean seedData(final StoreRepository storeRepository,%0A            final ProducerRepository producerRepository,%0A            final MakeRepository makeRepository,%0A            final BottleRepository bottleRepository) %7B%0A        return new InitializingBean() %7B%0A            @Override%0A            public void afterPropertiesSet() throws Exception %7B%0A                Store s1 = new Store(%22Brnenka%22, %22Lidicka 234%22);%0A                Store s2 = new Store(%22Tesco%22, %22Kr. Pole%22);%0A                Store s3 = new Store(%22NonStop%22, %22Arabska 15%22);%0A%0A                storeRepository.save(s1);%0A                storeRepository.save(s2);%0A                storeRepository.save(s3);%0A%0A                Producer p1 = new Producer(%22Bozkov Producer%22);%0A                Producer p2 = new Producer(%22Finlandia Producer%22);%0A                Producer p3 = new Producer(%22Bechcer Producer%22);%0A%0A                producerRepository.save(p1);%0A                producerRepository.save(p2);%0A                producerRepository.save(p3);%0A%0A                Make m1 = new Make(%22Bozkov%22, p1);%0A                Make m2 = new Make(%22Finlandia%22, p2);%0A                Make m3 = new Make(%22Bechcer%22, p3);%0A%0A                makeRepository.save(m1);%0A                makeRepository.save(m2);%0A                makeRepository.save(m3);%0A%0A                bottleRepository.save(new Bottle(%22Tuzemak%22, new Date(), new Date(), false, m1, s1));%0A                bottleRepository.save(new Bottle(%22Vodka%22, new Date(), new Date(), false, m2, s2));%0A                bottleRepository.save(new Bottle(%22Becherovka%22, new Date(), new Date(), false, m3, s3));%0A                bottleRepository.save(new Bottle(%22Tuzemak%22, new Date(), new Date(), false, m1, s1));%0A                bottleRepository.save(new Bottle(%22Vodka%22, new Date(), new Date(), false, m2, s2));%0A                bottleRepository.save(new Bottle(%22Becherovka%22, new Date(), new Date(), false, m3, s3));%0A                bottleRepository.save(new Bottle(%22Tuzemak%22, new Date(), new Date(), false, m1, s1));%0A                bottleRepository.save(new Bottle(%22Vodka%22, new Date(), new Date(), false, m2, s2));%0A                bottleRepository.save(new Bottle(%22Becherovka%22, new Date(), new Date(), false, m3, s3));%0A                bottleRepository.save(new Bottle(%22Tuzemak%22, new Date(), new Date(), false, m1, s1));%0A                bottleRepository.save(new Bottle(%22Vodka%22, new Date(), new Date(), false, m2, s2));%0A                bottleRepository.save(new Bottle(%22Becherovka%22, new Date(), new Date(), false, m3, s3));%0A            %7D%0A        %7D;%0A    %7D%0A
 %7D%0A

Remove temporary test seed data