CurriculumsearchApplication.java 1.7 KB
Newer Older
Heti Abhishek Shah committed
1 2
package com.roshka;

Joel Florentin committed
3 4 5 6 7 8 9 10 11 12 13 14 15
import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.roshka.modelo.Postulante;
import com.roshka.modelo.PostulanteTecnologia;
import com.roshka.modelo.Tecnologia;
import com.roshka.repositorio.PostulanteRepository;
import com.roshka.repositorio.TecnologiaRepository;

import org.springframework.boot.CommandLineRunner;
Heti Abhishek Shah committed
16 17
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
willgonzz committed
18
import org.springframework.boot.autoconfigure.domain.EntityScan;
Joel Florentin committed
19
import org.springframework.context.annotation.Bean;
willgonzz committed
20
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
Heti Abhishek Shah committed
21 22

@SpringBootApplication
willgonzz committed
23 24
@EnableJpaRepositories("com.roshka.repositorio")
@EntityScan("com.roshka.modelo")
Heti Abhishek Shah committed
25 26 27 28 29 30
public class CurriculumsearchApplication {

	public static void main(String[] args) {
		SpringApplication.run(CurriculumsearchApplication.class, args);
	}

Joel Florentin committed
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
	@Bean
	CommandLineRunner runner(PostulanteRepository postRepo,TecnologiaRepository tecRepo) {
		return args -> {
			// read json and write to db
			ObjectMapper mapper = new ObjectMapper();
			TypeReference<List<Postulante>> typeReference = new TypeReference<List<Postulante>>(){};
			InputStream inputStream = TypeReference.class.getResourceAsStream("/json/postulante.json");
			try {
				List<Postulante> postulantes = mapper.readValue(inputStream,typeReference);
				postRepo.saveAll(postulantes);
				System.out.println("postulantes Saved!");
			} catch (IOException e){
				System.out.println("Unable to save tecnologias: " + e.getMessage());
			}

			
			
			
		};
	}

52
	
Heti Abhishek Shah committed
53
}