// Path: server/src/main/java/com/changeme/service/DataInitialization.java
// @Service
// public class DataInitialization {
// 
//     private static final String[] departmentNames = {
//             "Front Office", "Reservations", "Housekeeping", "Concierge", "Guest service", "Security", "Communication"
//     };
// 
//     private static final String[] lastNames = {
//             "Dough", "Longhorn", "Smith", "Lee", "Ferguson", "March", "Dark"
//     };
// 
//     private static final String[] firstNames = {
//             "Ann", "John", "Eliot", "George", "Marian", "Julia", "Elvis"
//     };
// 
//     private static final NumberFormat numberFormat = new DecimalFormat("###.00");
// 
//     @Autowired
//     private DepartmentRepository departmentRepository;
// 
//     @Autowired
//     private AccessLevelRepository accessLevelRepository;
// 
//     @Autowired
//     private PersonRepository personRepository;
// 
//     @PostConstruct
//     public void init(){
// 
//         Locale.setDefault(Locale.US);
// 
//         List<AccessLevel> accessLevels = new ArrayList<>();
//         for(int i = 0; i < departmentNames.length; i++){
//             AccessLevel accessLevel = new AccessLevel();
//             accessLevel.setDescription("Level " + (i + 1));
//             accessLevelRepository.save(accessLevel);
//             accessLevels.add(accessLevel);
//         }
// 
//         List<Department> departments = new ArrayList<Department>();
//         for(int i = 0; i < departmentNames.length; i++){
//             Department department = new Department();
//             department.setName(departmentNames[i]);
//             department.setAccessLevel(accessLevels.get(i));
//             departmentRepository.save(department);
//             departments.add(department);
//         }
// 
//         Calendar cal = Calendar.getInstance();
//         Random rnd = new Random();
//         for(int i = 0, d = 0; i < departmentNames.length * 2; i++, d += 2){
// 
//             cal.set(1980 + rnd.nextInt(10), Calendar.MAY, 17 + rnd.nextInt(10));
// 
//             Person person = new Person();
//             try {
//                 person.setSalary(numberFormat.parse(numberFormat.format(rnd.nextDouble() * 1000)).floatValue());
//             } catch (ParseException e) {
//                 e.printStackTrace();
//             }
//             person.setBirthDate(new Date(cal.getTimeInMillis()));
//             person.setFirstName(firstNames[rnd.nextInt(firstNames.length - 1)]);
//             person.setLastName(lastNames[rnd.nextInt(lastNames.length - 1)]);
//             person.setDepartment(departments.get(rnd.nextInt(departments.size() - 1)));
//             personRepository.save(person);
//         }
// 
//     }
// 
// }


import com.changeme.service.DataInitialization;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.transaction.annotation.EnableTransactionManagement;
package com.changeme;


@SpringBootApplication
@ComponentScan("com.changeme")
@EnableTransactionManagement
public class Application {

    @Autowired
// Path: server/src/main/java/com/changeme/service/DataInitialization.java
// @Service
// public class DataInitialization {
// 
//     private static final String[] departmentNames = {
//             "Front Office", "Reservations", "Housekeeping", "Concierge", "Guest service", "Security", "Communication"
//     };
// 
//     private static final String[] lastNames = {
//             "Dough", "Longhorn", "Smith", "Lee", "Ferguson", "March", "Dark"
//     };
// 
//     private static final String[] firstNames = {
//             "Ann", "John", "Eliot", "George", "Marian", "Julia", "Elvis"
//     };
// 
//     private static final NumberFormat numberFormat = new DecimalFormat("###.00");
// 
//     @Autowired
//     private DepartmentRepository departmentRepository;
// 
//     @Autowired
//     private AccessLevelRepository accessLevelRepository;
// 
//     @Autowired
//     private PersonRepository personRepository;
// 
//     @PostConstruct
//     public void init(){
// 
//         Locale.setDefault(Locale.US);
// 
//         List<AccessLevel> accessLevels = new ArrayList<>();
//         for(int i = 0; i < departmentNames.length; i++){
//             AccessLevel accessLevel = new AccessLevel();
//             accessLevel.setDescription("Level " + (i + 1));
//             accessLevelRepository.save(accessLevel);
//             accessLevels.add(accessLevel);
//         }
// 
//         List<Department> departments = new ArrayList<Department>();
//         for(int i = 0; i < departmentNames.length; i++){
//             Department department = new Department();
//             department.setName(departmentNames[i]);
//             department.setAccessLevel(accessLevels.get(i));
//             departmentRepository.save(department);
//             departments.add(department);
//         }
// 
//         Calendar cal = Calendar.getInstance();
//         Random rnd = new Random();
//         for(int i = 0, d = 0; i < departmentNames.length * 2; i++, d += 2){
// 
//             cal.set(1980 + rnd.nextInt(10), Calendar.MAY, 17 + rnd.nextInt(10));
// 
//             Person person = new Person();
//             try {
//                 person.setSalary(numberFormat.parse(numberFormat.format(rnd.nextDouble() * 1000)).floatValue());
//             } catch (ParseException e) {
//                 e.printStackTrace();
//             }
//             person.setBirthDate(new Date(cal.getTimeInMillis()));
//             person.setFirstName(firstNames[rnd.nextInt(firstNames.length - 1)]);
//             person.setLastName(lastNames[rnd.nextInt(lastNames.length - 1)]);
//             person.setDepartment(departments.get(rnd.nextInt(departments.size() - 1)));
//             personRepository.save(person);
//         }
// 
//     }
// 
// }


// Path: server/src/main/java/com/changeme/Application.java
import com.changeme.service.DataInitialization;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.transaction.annotation.EnableTransactionManagement;

package com.changeme;


@SpringBootApplication
@ComponentScan("com.changeme")
@EnableTransactionManagement
public class Application {

    @Autowired
    private DataInitialization dataInitialization;