package com.plannaplan; import java.io.InputStream; import java.sql.Date; import com.plannaplan.models.ConfigData; import com.plannaplan.models.TourData; import com.plannaplan.entities.User; import com.plannaplan.services.UserService; import com.plannaplan.types.UserRoles; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.context.event.EventListener; import com.plannaplan.services.ConfiguratorService; @SpringBootApplication public class App { public final static String API_VERSION = "v1"; @Autowired private ConfiguratorService contrl; @Autowired UserService userService; @Value("${plannaplan.dev}") private boolean isDev; public static void main(String[] args) { Logo logo = new Logo("beta"); System.out.println(logo.getLogo()); System.out.println( "|=============================================================================================|"); SpringApplication.run(App.class, args); } /** * method to import mocked data to testing app after startz. It is called only * in dev profile */ @EventListener(ApplicationReadyEvent.class) public void importData() { System.out.println(Logo.getInitInfo(isDev)); if (this.isDev) { InputStream inputStream = getClass().getClassLoader().getResourceAsStream("Zajecia.xlsx"); ConfigData data = new ConfigData( new TourData(new Date(System.currentTimeMillis()), new Date(System.currentTimeMillis() + 86400000)), new TourData(new Date(System.currentTimeMillis() + 86400000), new Date(System.currentTimeMillis() + 2 * 86400000)), inputStream); this.contrl.config(data); User newuser = new User(); newuser.setEmail("tommy@st.amu.edu.pl"); newuser.setName("Tomek"); newuser.setSurname("Atomek"); newuser.setRole(UserRoles.STUDENT); this.userService.save(newuser); newuser = new User(); newuser.setEmail("robercik@st.amu.edu.pl"); newuser.setName("Robert"); newuser.setSurname("GÅ‚owacki"); newuser.setRole(UserRoles.STUDENT); this.userService.save(newuser); newuser = new User(); newuser.setEmail("mewa@st.amu.edu.pl"); newuser.setName("Poznanska"); newuser.setSurname("Mewa"); newuser.setRole(UserRoles.STUDENT); this.userService.save(newuser); newuser = new User(); newuser.setEmail("tkul2@st.amu.edu.pl"); newuser.setName("Tomasz"); newuser.setSurname("Kula"); newuser.setRole(UserRoles.STUDENT); this.userService.save(newuser); newuser = new User(); newuser.setEmail("annana@st.amu.edu.pl"); newuser.setName("Anna"); newuser.setSurname("Na"); newuser.setRole(UserRoles.STUDENT); this.userService.save(newuser); newuser = new User(); newuser.setEmail("mnart@st.amu.edu.pl"); newuser.setName("Marta"); newuser.setSurname("Narta"); newuser.setRole(UserRoles.STUDENT); this.userService.save(newuser); newuser = new User(); newuser.setEmail("zmineniane@st.amu.edu.pl"); newuser.setName("Tutaj"); newuser.setSurname("Koncza"); newuser.setRole(UserRoles.STUDENT); this.userService.save(newuser); newuser = new User(); newuser.setEmail("mi@st.amu.edu.pl"); newuser.setName("Mi"); newuser.setSurname("Sie"); newuser.setRole(UserRoles.STUDENT); this.userService.save(newuser); newuser = new User(); newuser.setEmail("pms@st.amu.edu.pl"); newuser.setName("Pomysly"); newuser.setSurname("Sad"); newuser.setRole(UserRoles.STUDENT); this.userService.save(newuser); } System.out.println(Logo.getStartedInfo(isDev)); } }