Skip to content

Commit

Permalink
RSWW-134 update generating transport courses ids
Browse files Browse the repository at this point in the history
  • Loading branch information
Danzigerrr committed Jun 3, 2024
1 parent 7d313c4 commit 98563f7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private void createPlaneConnections(List<TransportCourse> planeCourses, Map<Inte
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());
UUID planeConnectionArriveId = UUID.nameUUIDFromBytes((departureLocation.getId().toString() + hotelLocation.getId().toString() + TransportType.PLANE + String.valueOf(100)).getBytes());
planeCourses.add(TransportCourse.builder()
.id(planeConnectionArriveId)
.departureFrom(departureLocation)
Expand All @@ -122,7 +122,7 @@ private void createPlaneConnections(List<TransportCourse> planeCourses, Map<Inte
.build());

// Add return plane connection
UUID planeConnectionReturnId = UUID.nameUUIDFromBytes((departureLocation.toString() + hotelLocation.toString() + TransportType.PLANE + String.valueOf(200)).getBytes());
UUID planeConnectionReturnId = UUID.nameUUIDFromBytes((departureLocation.getId().toString() + hotelLocation.getId().toString() + TransportType.PLANE + String.valueOf(200)).getBytes());
planeCourses.add(TransportCourse.builder()
.id(planeConnectionReturnId)
.departureFrom(hotelLocation)
Expand All @@ -148,29 +148,29 @@ private void createBusConnections(List<TransportCourse> busCourses, Map<Integer,
Location hotelLocation = hotelLocationMap.get(hotelId);

for (String departureCity : departureCities) {
for (Location depLocation : departureLocations) {
String connectionKey = depLocation.getRegion() + "-" + hotelLocation.getRegion();
for (Location departureLocation : departureLocations) {
String connectionKey = departureLocation.getRegion() + "-" + hotelLocation.getRegion();

// Check if the connection already exists
if (!busConnections.contains(connectionKey) && depLocation.getRegion().equals(departureCity)) {
if (!busConnections.contains(connectionKey) && departureLocation.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());
UUID busConnectionArriveId = UUID.nameUUIDFromBytes((departureLocation.getId().toString() + hotelLocation.getId().toString() + TransportType.BUS + String.valueOf(100)).getBytes());
busCourses.add(TransportCourse.builder()
.id(busConnectionArriveId)
.departureFrom(depLocation)
.departureFrom(departureLocation)
.arrivalAt(hotelLocation)
.type(TransportType.BUS)
.build());

// Add return bus connection
UUID bussConnectionReturnId = UUID.nameUUIDFromBytes((depLocation.toString() + hotelLocation.toString() + TransportType.BUS + String.valueOf(200)).getBytes());
UUID bussConnectionReturnId = UUID.nameUUIDFromBytes((departureLocation.getId().toString() + hotelLocation.getId().toString() + TransportType.BUS + String.valueOf(200)).getBytes());
busCourses.add(TransportCourse.builder()
.id(bussConnectionReturnId)
.departureFrom(hotelLocation)
.arrivalAt(depLocation)
.arrivalAt(departureLocation)
.type(TransportType.BUS)
.build());

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package org.microarchitecturovisco.transport.bootstrap.util;

import org.microarchitecturovisco.transport.model.domain.TransportType;
import org.microarchitecturovisco.transport.model.dto.LocationDto;
import org.microarchitecturovisco.transport.model.dto.TransportCourseDto;
import org.microarchitecturovisco.transport.model.domain.TransportType;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Component;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
Expand Down Expand Up @@ -113,7 +112,7 @@ private void createPlaneConnections(List<TransportCourseDto> planeCourses, Map<I
// Check if the connection already exists - do not allow duplicates
if (!planeConnections.contains(connectionKey)) {
// Add plane connection
UUID planeConnectionArriveId = UUID.nameUUIDFromBytes((departureLocation.toString() + hotelLocation.toString() + TransportType.PLANE + String.valueOf(100)).getBytes());
UUID planeConnectionArriveId = UUID.nameUUIDFromBytes((departureLocation.getIdLocation().toString() + hotelLocation.getIdLocation().toString() + TransportType.PLANE + String.valueOf(100)).getBytes());
planeCourses.add(TransportCourseDto.builder()
.idTransportCourse(planeConnectionArriveId)
.departureFromLocation(departureLocation)
Expand All @@ -122,7 +121,7 @@ private void createPlaneConnections(List<TransportCourseDto> planeCourses, Map<I
.build());

// Add return plane connection
UUID planeConnectionReturnId = UUID.nameUUIDFromBytes((departureLocation.toString() + hotelLocation.toString() + TransportType.PLANE + String.valueOf(200)).getBytes());
UUID planeConnectionReturnId = UUID.nameUUIDFromBytes((departureLocation.getIdLocation().toString() + hotelLocation.getIdLocation().toString() + TransportType.PLANE + String.valueOf(200)).getBytes());
planeCourses.add(TransportCourseDto.builder()
.idTransportCourse(planeConnectionReturnId)
.departureFromLocation(hotelLocation)
Expand All @@ -148,29 +147,29 @@ private void createBusConnections(List<TransportCourseDto> busCourses, Map<Integ
LocationDto hotelLocation = hotelLocationMap.get(hotelId);

for (String departureCity : departureCities) {
for (LocationDto depLocation : departureLocations) {
String connectionKey = depLocation.getRegion() + "-" + hotelLocation.getRegion();
for (LocationDto departureLocation : departureLocations) {
String connectionKey = departureLocation.getRegion() + "-" + hotelLocation.getRegion();

// Check if the connection already exists
if (!busConnections.contains(connectionKey) && depLocation.getRegion().equals(departureCity)) {
if (!busConnections.contains(connectionKey) && departureLocation.getRegion().equals(departureCity)) {
// Check if the destination location is among the bus arrival locations
for (LocationDto 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());
UUID busConnectionArriveId = UUID.nameUUIDFromBytes((departureLocation.getIdLocation().toString() + hotelLocation.getIdLocation().toString() + TransportType.BUS + String.valueOf(100)).getBytes());
busCourses.add(TransportCourseDto.builder()
.idTransportCourse(busConnectionArriveId)
.departureFromLocation(depLocation)
.departureFromLocation(departureLocation)
.arrivalAtLocation(hotelLocation)
.type(TransportType.BUS)
.build());

// Add return bus connection
UUID bussConnectionReturnId = UUID.nameUUIDFromBytes((depLocation.toString() + hotelLocation.toString() + TransportType.BUS + String.valueOf(200)).getBytes());
UUID bussConnectionReturnId = UUID.nameUUIDFromBytes((departureLocation.getIdLocation().toString() + hotelLocation.getIdLocation().toString() + TransportType.BUS + String.valueOf(200)).getBytes());
busCourses.add(TransportCourseDto.builder()
.idTransportCourse(bussConnectionReturnId)
.departureFromLocation(hotelLocation)
.arrivalAtLocation(depLocation)
.arrivalAtLocation(departureLocation)
.type(TransportType.BUS)
.build());

Expand Down

0 comments on commit 98563f7

Please sign in to comment.