From 7d313c409f53b773d5b46d5a9122bc71e65d2bdc Mon Sep 17 00:00:00 2001 From: Krzysztof Nazar Date: Mon, 3 Jun 2024 19:51:54 +0200 Subject: [PATCH] RSWW-134 set up basic transports import transport courses and transport id are not working correctly --- .../{Bootstrap.java => HotelBootstrap.java} | 4 +- .../hotels/bootstrap/util/RoomParser.java | 2 +- .../bootstrap/TransportBootstrap.java | 110 ++++++++++ .../bootstrap/util/LocationParser.java | 102 +++++++++ .../util/TransportCoursesParser.java | 187 ++++++++++++++++ .../transports/domain/Location.java | 49 +++++ .../transports/domain/Transport.java | 36 ++++ .../transports/domain/TransportCourse.java | 30 +++ .../transports/domain/TransportType.java | 6 + .../repositories/LocationRepository.java | 11 + .../TransportCourseRepository.java | 9 + .../repositories/TransportRepository.java | 13 ++ .../initData/hotel_departure_options.csv | 201 ++++++++++++++++++ 13 files changed, 757 insertions(+), 3 deletions(-) rename data-generator/src/main/java/cloud/project/datagenerator/hotels/bootstrap/{Bootstrap.java => HotelBootstrap.java} (93%) create mode 100644 data-generator/src/main/java/cloud/project/datagenerator/transports/bootstrap/TransportBootstrap.java create mode 100644 data-generator/src/main/java/cloud/project/datagenerator/transports/bootstrap/util/LocationParser.java create mode 100644 data-generator/src/main/java/cloud/project/datagenerator/transports/bootstrap/util/TransportCoursesParser.java create mode 100644 data-generator/src/main/java/cloud/project/datagenerator/transports/domain/Location.java create mode 100644 data-generator/src/main/java/cloud/project/datagenerator/transports/domain/Transport.java create mode 100644 data-generator/src/main/java/cloud/project/datagenerator/transports/domain/TransportCourse.java create mode 100644 data-generator/src/main/java/cloud/project/datagenerator/transports/domain/TransportType.java create mode 100644 data-generator/src/main/java/cloud/project/datagenerator/transports/repositories/LocationRepository.java create mode 100644 data-generator/src/main/java/cloud/project/datagenerator/transports/repositories/TransportCourseRepository.java create mode 100644 data-generator/src/main/java/cloud/project/datagenerator/transports/repositories/TransportRepository.java create mode 100644 data-generator/src/main/resources/initData/hotel_departure_options.csv diff --git a/data-generator/src/main/java/cloud/project/datagenerator/hotels/bootstrap/Bootstrap.java b/data-generator/src/main/java/cloud/project/datagenerator/hotels/bootstrap/HotelBootstrap.java similarity index 93% rename from data-generator/src/main/java/cloud/project/datagenerator/hotels/bootstrap/Bootstrap.java rename to data-generator/src/main/java/cloud/project/datagenerator/hotels/bootstrap/HotelBootstrap.java index fccc7556..b5be7f45 100644 --- a/data-generator/src/main/java/cloud/project/datagenerator/hotels/bootstrap/Bootstrap.java +++ b/data-generator/src/main/java/cloud/project/datagenerator/hotels/bootstrap/HotelBootstrap.java @@ -17,7 +17,7 @@ @Component @RequiredArgsConstructor -public class Bootstrap implements CommandLineRunner { +public class HotelBootstrap implements CommandLineRunner { private final HotelParser hotelParser; private final RoomParser roomParser; private final ResourceLoader resourceLoader; @@ -26,7 +26,7 @@ public class Bootstrap implements CommandLineRunner { @Override public void run(String... args) throws IOException { - Logger logger = Logger.getLogger("Bootstrap"); + Logger logger = Logger.getLogger("TransportBootstrap"); Resource hotelCsvFile = resourceLoader.getResource("classpath:initData/hotels.csv"); Resource hotelRoomsCsvFile = resourceLoader.getResource("classpath:initData/hotel_rooms.csv"); diff --git a/data-generator/src/main/java/cloud/project/datagenerator/hotels/bootstrap/util/RoomParser.java b/data-generator/src/main/java/cloud/project/datagenerator/hotels/bootstrap/util/RoomParser.java index c3a8728e..157e9b22 100644 --- a/data-generator/src/main/java/cloud/project/datagenerator/hotels/bootstrap/util/RoomParser.java +++ b/data-generator/src/main/java/cloud/project/datagenerator/hotels/bootstrap/util/RoomParser.java @@ -24,7 +24,7 @@ public class RoomParser { private final HotelCsvReader hotelCsvReader; public void importRooms(Resource resource, List hotels) { - Logger logger = Logger.getLogger("Bootstrap | Rooms"); + Logger logger = Logger.getLogger("TransportBootstrap | Rooms"); RoomCapacityCalculator capacityCalculator = new RoomCapacityCalculator(); try (BufferedReader br = new BufferedReader(new InputStreamReader(resource.getInputStream()))) { String line; diff --git a/data-generator/src/main/java/cloud/project/datagenerator/transports/bootstrap/TransportBootstrap.java b/data-generator/src/main/java/cloud/project/datagenerator/transports/bootstrap/TransportBootstrap.java new file mode 100644 index 00000000..987bc0f9 --- /dev/null +++ b/data-generator/src/main/java/cloud/project/datagenerator/transports/bootstrap/TransportBootstrap.java @@ -0,0 +1,110 @@ +package cloud.project.datagenerator.transports.bootstrap; + +import cloud.project.datagenerator.transports.bootstrap.util.LocationParser; +import cloud.project.datagenerator.transports.bootstrap.util.TransportCoursesParser; +import cloud.project.datagenerator.transports.domain.Location; +import cloud.project.datagenerator.transports.domain.Transport; +import cloud.project.datagenerator.transports.domain.TransportCourse; +import cloud.project.datagenerator.transports.repositories.LocationRepository; +import cloud.project.datagenerator.transports.repositories.TransportCourseRepository; +import cloud.project.datagenerator.transports.repositories.TransportRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.boot.CommandLineRunner; +import org.springframework.core.io.Resource; +import org.springframework.core.io.ResourceLoader; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; +import java.time.Month; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.UUID; +import java.util.logging.Logger; + +@Component +@RequiredArgsConstructor +public class TransportBootstrap implements CommandLineRunner { + private final LocationParser locationParser; + private final TransportCoursesParser transportCoursesParser; + private final ResourceLoader resourceLoader; + private final TransportRepository transportRepository; + private final TransportCourseRepository transportCourseRepository; + private final LocationRepository locationRepository; + + @Override + public void run(String... args) { + Logger logger = Logger.getLogger("TransportBootstrap | Transports"); + + Resource hotelCsvResource = resourceLoader.getResource("classpath:initData/hotels.csv"); + Resource hotelDepartureOptionsResource = resourceLoader.getResource("classpath:initData/hotel_departure_options.csv"); + + List planeArrivalLocations = locationParser.importLocationsAbroad(hotelCsvResource, "PLANE"); + List busArrivalLocations = locationParser.importLocationsAbroad(hotelCsvResource, "BUS"); + List departureLocations = locationParser.importLocationsPoland(hotelDepartureOptionsResource); + + Map> transportCoursesMap = transportCoursesParser.createTransportCourses(hotelCsvResource, hotelDepartureOptionsResource, busArrivalLocations, planeArrivalLocations, departureLocations); + + List planeCourses = transportCoursesMap.get("PLANE"); + List busCourses = transportCoursesMap.get("BUS"); + + LocalDateTime bootstrapBeginDay = LocalDateTime.of(2024, Month.MAY, 1, 12, 0, 0); + + int randomSeed = 12345678; + Random random = new Random(randomSeed); + + int numberOfDays = 60; + + // generate transport for each course and every day of two months + for (int day = 0; day < numberOfDays; day++) { + for (TransportCourse planeCourse : planeCourses) { + int capacity = random.nextInt(8, 15); + + LocalDateTime departureDate = bootstrapBeginDay.plusDays(day); + + UUID transportId = UUID.nameUUIDFromBytes(( + departureDate + + planeCourse.toString() + + capacity + + day).getBytes()); + + Transport transport = Transport.builder() + .id(transportId) + .departureDate(departureDate) + .course(planeCourse) + .capacity(capacity) + .pricePerAdult(random.nextFloat(100, 500)) + .build(); + + locationRepository.saveAll(List.of(planeCourse.getDepartureFrom(), planeCourse.getArrivalAt())); + transportCourseRepository.save(planeCourse); + transportRepository.save(transport); + } + + for (TransportCourse busCourse : busCourses) { + int capacity = random.nextInt(8, 15); + LocalDateTime departureDate = bootstrapBeginDay.plusDays(day); + + UUID transportId = UUID.nameUUIDFromBytes(( + departureDate + + busCourse.toString() + + capacity + + day).getBytes()); + + Transport transport = Transport.builder() + .id(transportId) + .course(busCourse) + .departureDate(departureDate) + .capacity(capacity) + .pricePerAdult(random.nextFloat(50, 200)) + .build(); + + locationRepository.saveAll(List.of(busCourse.getDepartureFrom(), busCourse.getArrivalAt())); + transportCourseRepository.save(busCourse); + transportRepository.save(transport); + } + logger.info("TransportBootstrap imported day " + (day + 1) + " out of " + numberOfDays + " days"); + } + logger.info("TransportBootstrap finished importing data"); + } +} diff --git a/data-generator/src/main/java/cloud/project/datagenerator/transports/bootstrap/util/LocationParser.java b/data-generator/src/main/java/cloud/project/datagenerator/transports/bootstrap/util/LocationParser.java new file mode 100644 index 00000000..50963ef2 --- /dev/null +++ b/data-generator/src/main/java/cloud/project/datagenerator/transports/bootstrap/util/LocationParser.java @@ -0,0 +1,102 @@ +package cloud.project.datagenerator.transports.bootstrap.util; + +import cloud.project.datagenerator.transports.domain.Location; +import org.springframework.core.io.Resource; +import org.springframework.stereotype.Component; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.UUID; + +@Component +public class LocationParser { + + private final List locationsAvailableByBus = new ArrayList<>(); + + public LocationParser() { + locationsAvailableByBus.add(new Location("Albania", "Durres")); + locationsAvailableByBus.add(new Location("Turcja", "Kayseri")); + locationsAvailableByBus.add(new Location("Włochy", "Apulia")); + locationsAvailableByBus.add(new Location("Włochy", "Sycylia")); + locationsAvailableByBus.add(new Location("Włochy", "Kalabria")); + } + + public List importLocationsAbroad(Resource resource, String transportType) { + List locations = new ArrayList<>(); + + try (BufferedReader br = new BufferedReader(new InputStreamReader(resource.getInputStream()))) { + String line; + br.readLine(); // Skip header line + + while ((line = br.readLine()) != null) { + String[] data = line.split("\t"); + String country = data[4]; + String region = data[5]; + Location locationDto = createNewLocation(locations, country, region, transportType); + if (locationDto != null) { + locations.add(locationDto); + } + } + } catch (IOException e) { + e.printStackTrace(); + } + + return locations; + } + + public List importLocationsPoland(Resource resource) { + List locations = new ArrayList<>(); + + try (BufferedReader br = new BufferedReader(new InputStreamReader(resource.getInputStream()))) { + String line; + br.readLine(); // Skip header line + + while ((line = br.readLine()) != null) { + String[] data = line.split("\t"); + String region = data[1]; + if (!Objects.equals(region, "Dojazd własny")) { + Location locationDto = createNewLocation(locations, "Polska", region, null); + if (locationDto != null) { + locations.add(locationDto); + } + } + } + } catch (IOException e) { + e.printStackTrace(); + } + + return locations; + } + + private Location createNewLocation(List locations, String country, String region, String transportType) { + if (transportType != null && transportType.equals("BUS")) { + if (!locationAvailableByBus(country, region)) { + return null; + } + } + + if (locationExists(locations, country, region)) { + return null; + } + + return Location.builder() + .id(UUID.nameUUIDFromBytes((country+region).getBytes())) + .country(country) + .region(region) + .build(); + } + + private boolean locationExists(List locations, String country, String region) { + return locations.stream() + .anyMatch(locationDto -> locationDto.getCountry().equals(country) && locationDto.getRegion().equals(region)); + } + + private boolean locationAvailableByBus(String country, String region) { + return locationsAvailableByBus.stream() + .anyMatch(location -> location.getCountry().equals(country) && location.getRegion().equals(region)); + } +} diff --git a/data-generator/src/main/java/cloud/project/datagenerator/transports/bootstrap/util/TransportCoursesParser.java b/data-generator/src/main/java/cloud/project/datagenerator/transports/bootstrap/util/TransportCoursesParser.java new file mode 100644 index 00000000..e0aaddf7 --- /dev/null +++ b/data-generator/src/main/java/cloud/project/datagenerator/transports/bootstrap/util/TransportCoursesParser.java @@ -0,0 +1,187 @@ +package cloud.project.datagenerator.transports.bootstrap.util; + +import cloud.project.datagenerator.transports.domain.Location; +import cloud.project.datagenerator.transports.domain.TransportCourse; +import cloud.project.datagenerator.transports.domain.TransportType; +import org.springframework.core.io.Resource; +import org.springframework.stereotype.Component; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.*; + +@Component +public class TransportCoursesParser { + + public Map> createTransportCourses(Resource hotelCsvFile, Resource hotelDepartureOptionsCsvFile, List busArrivalLocations, List planeArrivalLocations, List departureLocations) { + List planeCourses = new ArrayList<>(); + List busCourses = new ArrayList<>(); + + Map> departureCitiesMap = readDepartureCities(hotelDepartureOptionsCsvFile); + Map hotelLocationMap = readHotelLocations(hotelCsvFile, planeArrivalLocations); + + Set planeConnections = new HashSet<>(); + Set busConnections = new HashSet<>(); + + createPlaneConnections(planeCourses, departureCitiesMap, hotelLocationMap, departureLocations, planeConnections); + createBusConnections(busCourses, departureCitiesMap, hotelLocationMap, busArrivalLocations, departureLocations, busConnections); + + Map> transportCoursesMap = new HashMap<>(); + transportCoursesMap.put("PLANE", planeCourses); + transportCoursesMap.put("BUS", busCourses); + + return transportCoursesMap; + } + + private Map> readDepartureCities(Resource resource) { + Map> departureCitiesMap = new HashMap<>(); + + try (Scanner scanner = new Scanner(new InputStreamReader(resource.getInputStream()))) { + scanner.nextLine(); // Skip header line + + while (scanner.hasNextLine()) { + String line = scanner.nextLine(); + String[] data = line.split("\t"); + int hotelId = Integer.parseInt(data[0]); + String departureCity = data[1]; + + // Exclude "Dojazd własny" departure city + if (!departureCity.equals("Dojazd własny")) { + List departureCities = departureCitiesMap.getOrDefault(hotelId, new ArrayList<>()); + + departureCities.add(departureCity); + + departureCitiesMap.put(hotelId, departureCities); + } + } + } catch (IOException e) { + e.printStackTrace(); + } + + return departureCitiesMap; + } + + private Map readHotelLocations(Resource resource, List planeArrivalLocations) { + Map hotelLocationMap = new HashMap<>(); + + try (BufferedReader br = new BufferedReader(new InputStreamReader(resource.getInputStream()))) { + String line; + br.readLine(); // Skip header line + + while ((line = br.readLine()) != null) { + String[] data = line.split("\t"); + int hotelId = Integer.parseInt(data[0]); + String country = data[4]; + String region = data[5]; + + // Find the matching location in the planeArrivalLocations list + Location hotelLocation = findMatchingLocation(country, region, planeArrivalLocations); + hotelLocationMap.put(hotelId, hotelLocation); + } + } catch (IOException e) { + e.printStackTrace(); + } + + return hotelLocationMap; + } + + private Location findMatchingLocation(String country, String region, List locations) { + return locations.stream() + .filter(location -> location.getCountry().equals(country) && location.getRegion().equals(region)) + .findFirst() + .orElse(null); + } + + + private void createPlaneConnections(List planeCourses, Map> departureCitiesMap, Map hotelLocationMap, List departureLocations, Set planeConnections) { + for (Map.Entry> entry : departureCitiesMap.entrySet()) { + int hotelId = entry.getKey(); + List departureCities = entry.getValue(); + + if (hotelLocationMap.containsKey(hotelId)) { + Location hotelLocation = hotelLocationMap.get(hotelId); + + for (String departureCity : departureCities) { + // Find the departure location DTO for the current departure city + Location departureLocation = findMatchingLocation("Polska", departureCity, departureLocations); + + if (departureLocation != null) { + String connectionKey = departureLocation.getRegion() + "-" + hotelLocation.getRegion(); + + // Check if the connection already exists - do not allow duplicates + if (!planeConnections.contains(connectionKey)) { + // Add plane connection + // todo change to random number using the random seed + UUID planeConnectionArriveId = UUID.nameUUIDFromBytes((departureLocation.toString() + hotelLocation.toString() + TransportType.PLANE + String.valueOf(100)).getBytes()); + planeCourses.add(TransportCourse.builder() + .id(planeConnectionArriveId) + .departureFrom(departureLocation) + .arrivalAt(hotelLocation) + .type(TransportType.PLANE) + .build()); + + // Add return plane connection + UUID planeConnectionReturnId = UUID.nameUUIDFromBytes((departureLocation.toString() + hotelLocation.toString() + TransportType.PLANE + String.valueOf(200)).getBytes()); + planeCourses.add(TransportCourse.builder() + .id(planeConnectionReturnId) + .departureFrom(hotelLocation) + .arrivalAt(departureLocation) + .type(TransportType.PLANE) + .build()); + + // Mark the connection as created + planeConnections.add(connectionKey); + } + } + } + } + } + } + + private void createBusConnections(List busCourses, Map> departureCitiesMap, Map hotelLocationMap, List busArrivalLocations, List departureLocations, Set busConnections) { + for (Map.Entry> entry : departureCitiesMap.entrySet()) { + int hotelId = entry.getKey(); + List departureCities = entry.getValue(); + + if (hotelLocationMap.containsKey(hotelId)) { + Location hotelLocation = hotelLocationMap.get(hotelId); + + for (String departureCity : departureCities) { + for (Location depLocation : departureLocations) { + String connectionKey = depLocation.getRegion() + "-" + hotelLocation.getRegion(); + + // Check if the connection already exists + if (!busConnections.contains(connectionKey) && depLocation.getRegion().equals(departureCity)) { + // Check if the destination location is among the bus arrival locations + for (Location busArrivalLocation : busArrivalLocations) { + if (busArrivalLocation.getRegion().equals(hotelLocation.getRegion())) { + // Add bus connection + UUID busConnectionArriveId = UUID.nameUUIDFromBytes((depLocation.toString() + hotelLocation.toString() + TransportType.BUS + String.valueOf(100)).getBytes()); + busCourses.add(TransportCourse.builder() + .id(busConnectionArriveId) + .departureFrom(depLocation) + .arrivalAt(hotelLocation) + .type(TransportType.BUS) + .build()); + + // Add return bus connection + UUID bussConnectionReturnId = UUID.nameUUIDFromBytes((depLocation.toString() + hotelLocation.toString() + TransportType.BUS + String.valueOf(200)).getBytes()); + busCourses.add(TransportCourse.builder() + .id(bussConnectionReturnId) + .departureFrom(hotelLocation) + .arrivalAt(depLocation) + .type(TransportType.BUS) + .build()); + + // Mark the connection as created + busConnections.add(connectionKey); + } + } + } + } + } + } + } + } +} diff --git a/data-generator/src/main/java/cloud/project/datagenerator/transports/domain/Location.java b/data-generator/src/main/java/cloud/project/datagenerator/transports/domain/Location.java new file mode 100644 index 00000000..7e65eac6 --- /dev/null +++ b/data-generator/src/main/java/cloud/project/datagenerator/transports/domain/Location.java @@ -0,0 +1,49 @@ +package cloud.project.datagenerator.transports.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; +import jakarta.validation.constraints.NotNull; +import lombok.*; + +import java.util.List; +import java.util.UUID; + +@Entity +@Table(name = "locations") +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class Location { + @Id + private UUID id; + + @NotNull + private String country; + + private String region; + + @OneToMany(mappedBy = "departureFrom") + private List transportCourseFrom; + + @OneToMany(mappedBy = "arrivalAt") + private List transportCourseAt; + + public Location(String country, String region) { + this.id = null; + this.country = country; + this.region = region; + } + + @Override + public String toString() { + return "LocationDto{" + + "idLocation=" + id + + ", country='" + country + '\'' + + ", region='" + region + '\'' + + '}'; + } +} diff --git a/data-generator/src/main/java/cloud/project/datagenerator/transports/domain/Transport.java b/data-generator/src/main/java/cloud/project/datagenerator/transports/domain/Transport.java new file mode 100644 index 00000000..4a741b39 --- /dev/null +++ b/data-generator/src/main/java/cloud/project/datagenerator/transports/domain/Transport.java @@ -0,0 +1,36 @@ +package cloud.project.datagenerator.transports.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; +import java.util.UUID; + +@Entity +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class Transport { + @Id + private UUID id; + + @ManyToOne + private TransportCourse course; + + // the day the transport takes place + @NotNull + private LocalDateTime departureDate; + + @NotNull + private int capacity; + + @NotNull + private float pricePerAdult; +} diff --git a/data-generator/src/main/java/cloud/project/datagenerator/transports/domain/TransportCourse.java b/data-generator/src/main/java/cloud/project/datagenerator/transports/domain/TransportCourse.java new file mode 100644 index 00000000..9f103917 --- /dev/null +++ b/data-generator/src/main/java/cloud/project/datagenerator/transports/domain/TransportCourse.java @@ -0,0 +1,30 @@ +package cloud.project.datagenerator.transports.domain; + +import jakarta.persistence.*; +import lombok.*; + +import java.util.UUID; + +@Entity +@Table(name = "transport_courses") +@Getter +@Setter +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TransportCourse { + @Id + private UUID id; + + @Enumerated(EnumType.STRING) + private TransportType type; + + @ManyToOne + @JoinColumn(name = "transport_course_from_location_id", nullable = false) + private Location departureFrom; + + @ManyToOne + @JoinColumn(name = "transport_course_at_location_id", nullable = false) + private Location arrivalAt; + +} \ No newline at end of file diff --git a/data-generator/src/main/java/cloud/project/datagenerator/transports/domain/TransportType.java b/data-generator/src/main/java/cloud/project/datagenerator/transports/domain/TransportType.java new file mode 100644 index 00000000..79a62611 --- /dev/null +++ b/data-generator/src/main/java/cloud/project/datagenerator/transports/domain/TransportType.java @@ -0,0 +1,6 @@ +package cloud.project.datagenerator.transports.domain; + +public enum TransportType { + PLANE, + BUS; +} diff --git a/data-generator/src/main/java/cloud/project/datagenerator/transports/repositories/LocationRepository.java b/data-generator/src/main/java/cloud/project/datagenerator/transports/repositories/LocationRepository.java new file mode 100644 index 00000000..99a8567d --- /dev/null +++ b/data-generator/src/main/java/cloud/project/datagenerator/transports/repositories/LocationRepository.java @@ -0,0 +1,11 @@ +package cloud.project.datagenerator.transports.repositories; + +import cloud.project.datagenerator.transports.domain.Location; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.UUID; + +public interface LocationRepository extends JpaRepository { + Location findFirstByRegion(String region); + Location findFirstByRegionIgnoreCase(String region); +} diff --git a/data-generator/src/main/java/cloud/project/datagenerator/transports/repositories/TransportCourseRepository.java b/data-generator/src/main/java/cloud/project/datagenerator/transports/repositories/TransportCourseRepository.java new file mode 100644 index 00000000..29c8e772 --- /dev/null +++ b/data-generator/src/main/java/cloud/project/datagenerator/transports/repositories/TransportCourseRepository.java @@ -0,0 +1,9 @@ +package cloud.project.datagenerator.transports.repositories; + +import cloud.project.datagenerator.transports.domain.TransportCourse; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.UUID; + +public interface TransportCourseRepository extends JpaRepository { +} diff --git a/data-generator/src/main/java/cloud/project/datagenerator/transports/repositories/TransportRepository.java b/data-generator/src/main/java/cloud/project/datagenerator/transports/repositories/TransportRepository.java new file mode 100644 index 00000000..135b537f --- /dev/null +++ b/data-generator/src/main/java/cloud/project/datagenerator/transports/repositories/TransportRepository.java @@ -0,0 +1,13 @@ +package cloud.project.datagenerator.transports.repositories; + +import cloud.project.datagenerator.transports.domain.Transport; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.UUID; + +public interface TransportRepository extends JpaRepository { + List findByDepartureDateGreaterThanEqualAndDepartureDateLessThanEqual( + LocalDateTime dateFrom, LocalDateTime dateTo); +} diff --git a/data-generator/src/main/resources/initData/hotel_departure_options.csv b/data-generator/src/main/resources/initData/hotel_departure_options.csv new file mode 100644 index 00000000..d8b405f8 --- /dev/null +++ b/data-generator/src/main/resources/initData/hotel_departure_options.csv @@ -0,0 +1,201 @@ +idHotel departureOption +0 Katowice +0 Poznań +0 Warszawa-Okęcie +0 Gdańsk +0 Wrocław +1 Wrocław +1 Warszawa-Okęcie +1 Katowice +1 Poznań +1 Gdańsk +2 Dojazd własny +2 Warszawa-Okęcie +2 Kraków +2 Gdańsk +2 Poznań +2 Wrocław +2 Olsztyn-Mazury +2 Katowice +3 Warszawa-Okęcie +3 Katowice +3 Wrocław +3 Poznań +4 Warszawa-Okęcie +4 Katowice +5 Katowice +5 Poznań +5 Warszawa-Okęcie +5 Wrocław +5 Gdańsk +6 Warszawa-Okęcie +6 Kraków +6 Poznań +6 Gdańsk +6 Wrocław +6 Katowice +6 Dojazd własny +6 Olsztyn-Mazury +7 Warszawa-Okęcie +8 Gdańsk +8 Katowice +8 Wrocław +8 Warszawa-Okęcie +8 Poznań +8 Olsztyn-Mazury +8 Kraków +9 Warszawa-Okęcie +9 Katowice +10 Katowice +10 Warszawa-Okęcie +10 Poznań +11 Katowice +11 Poznań +11 Warszawa-Okęcie +11 Gdańsk +11 Wrocław +12 Wrocław +13 Katowice +13 Poznań +13 Warszawa-Okęcie +13 Gdańsk +13 Wrocław +14 Katowice +14 Warszawa-Okęcie +14 Wrocław +15 Katowice +15 Warszawa-Okęcie +15 Poznań +16 Katowice +16 Warszawa-Okęcie +16 Gdańsk +16 Wrocław +16 Olsztyn-Mazury +16 Kraków +16 Poznań +17 Warszawa-Okęcie +17 Katowice +18 Katowice +19 Warszawa-Okęcie +20 Dojazd własny +20 Warszawa-Okęcie +20 Kraków +20 Gdańsk +20 Poznań +20 Wrocław +20 Katowice +20 Olsztyn-Mazury +21 Warszawa-Okęcie +22 Warszawa-Okęcie +23 Katowice +23 Warszawa-Modlin +23 Wrocław +23 Kraków +23 Poznań +23 Gdańsk +23 Warszawa-Okęcie +24 Katowice +24 Warszawa-Okęcie +24 Wrocław +24 Poznań +24 Gdańsk +24 Kraków +24 Olsztyn-Mazury +25 Warszawa-Okęcie +25 Wrocław +25 Katowice +25 Poznań +26 Warszawa-Okęcie +26 Katowice +26 Poznań +26 Wrocław +26 Gdańsk +26 Kraków +27 Warszawa-Okęcie +27 Katowice +27 Wrocław +27 Poznań +28 Poznań +28 Katowice +28 Warszawa-Okęcie +28 Gdańsk +28 Wrocław +29 Warszawa-Okęcie +30 Warszawa-Okęcie +30 Katowice +31 Dojazd własny +31 Gdańsk +31 Wrocław +32 Warszawa-Okęcie +32 Kraków +33 Katowice +33 Poznań +33 Warszawa-Okęcie +33 Wrocław +33 Gdańsk +33 Kraków +34 Warszawa-Okęcie +35 Warszawa-Okęcie +35 Katowice +35 Wrocław +36 Katowice +36 Warszawa-Okęcie +36 Wrocław +36 Poznań +36 Gdańsk +36 Kraków +36 Olsztyn-Mazury +37 Warszawa-Okęcie +38 Warszawa-Okęcie +38 Wrocław +38 Katowice +38 Poznań +39 Katowice +39 Warszawa-Okęcie +39 Gdańsk +39 Kraków +39 Wrocław +39 Poznań +40 Warszawa-Okęcie +40 Katowice +40 Wrocław +41 Katowice +42 Warszawa-Okęcie +42 Katowice +42 Wrocław +42 Poznań +43 Katowice +43 Warszawa-Okęcie +43 Poznań +43 Wrocław +44 Warszawa-Okęcie +44 Katowice +44 Wrocław +44 Kraków +44 Poznań +44 Gdańsk +45 Katowice +45 Warszawa-Okęcie +46 Dojazd własny +46 Warszawa-Okęcie +46 Kraków +46 Gdańsk +46 Poznań +46 Wrocław +46 Katowice +46 Olsztyn-Mazury +47 Wrocław +47 Katowice +47 Poznań +47 Gdańsk +47 Kraków +48 Warszawa-Okęcie +48 Wrocław +48 Katowice +48 Poznań +49 Katowice +49 Warszawa-Okęcie +49 Gdańsk +49 Poznań +49 Kraków +49 Wrocław