From af54633b3f49215e77fa125783afa8257d735b6a Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 29 Jun 2020 07:37:59 +0200 Subject: [PATCH] changes in Read.me and DTO sequence --- README.md | 3 -- diagrams/dtos/dtos.svg | 38 +++++++++++-------- diagrams/dtos/{dtos.plantuml => dtos.txt} | 12 +++--- .../ConnectionController/ConnectionDto.java | 26 ------------- .../backend/loaders/ConnectionLoader.java | 8 ++-- .../backend/models/Connection/Connection.java | 35 ++++------------- .../pl/edu/pk/siwz/backend/models/Times.java | 9 ++--- .../backend/service/ConnectionService.java | 1 - .../V1__init_Airline_and_Airport_table.sql | 14 +++---- .../V2__init_Connection_Flight_table.sql | 27 +++++++++++++ ...ection_Route_and_ConnectionRoute_table.sql | 38 ------------------- 11 files changed, 76 insertions(+), 135 deletions(-) rename diagrams/dtos/{dtos.plantuml => dtos.txt} (87%) delete mode 100644 src/main/java/pl/edu/pk/siwz/backend/controllers/ConnectionController/ConnectionDto.java create mode 100644 src/main/resources/db/migration/V2__init_Connection_Flight_table.sql delete mode 100644 src/main/resources/db/migration/V2__init_Connection_Route_and_ConnectionRoute_table.sql diff --git a/README.md b/README.md index 452906f..e9b87e6 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,6 @@ Modify ```spring.datasource.url=YOUR_PATH_TO_DB``` with proper url to your db so After running project enter following url: ```http://localhost:8080/console``` -### Booking sequence diagram -![UML](./diagrams/booking-sequence/sequence.svg) - ### Data Transfer Objects ![UML](./diagrams/dtos/dtos.svg) diff --git a/diagrams/dtos/dtos.svg b/diagrams/dtos/dtos.svg index 3c7fa84..8fed85a 100644 --- a/diagrams/dtos/dtos.svg +++ b/diagrams/dtos/dtos.svg @@ -1,10 +1,23 @@ -TripDtotickets: Array<TicketDto>departureDate: DatearrivalDate: DatetotalPrice: PriceTicketDtoflight: FlightDtodepartureDate: DatearrivalDate: DatetotalPrice: numberFlightDtoflightId: intairline: AirlineDtosrcAirport: AirportDtodstAirport: AirportDtoAirlineDtocode: Stringname: StringAirportDtoid: intiata: Stringicao: StringairportName: Stringcity: Stringcountry: Stringtimezone: intattributesBookingRequestDtochosenTrip: TripDtopassengers: Array<PassengerDto>PassengerDtofirstname: Stringsurname: StringdateOfBirth: DatephoneNumber: Stringemail: StringidOrPesel: StringTripDtotickets: Array<TicketDto>departureDate: DatearrivalDate: DatetotalPrice: numberTicketDtoflight: FlightDtodepartureDate: DatearrivalDate: DatetotalPrice: numberFlightDtoflightId: intairline: AirlineDtosrcAirport: AirportDtodstAirport: AirportDtoAirlineDtocode: Stringname: StringAirportDtoid: intname: Stringcity: Stringcountry: Stringtimezone: intattributesBookingRequestDtochosenTrip: TripDtopassengers: Array<PassengerDto>PassengerDtofirstname: Stringsurname: StringdateOfBirth: DatephoneNumber: Stringemail: Stringpesel: String \ No newline at end of file diff --git a/diagrams/dtos/dtos.plantuml b/diagrams/dtos/dtos.txt similarity index 87% rename from diagrams/dtos/dtos.plantuml rename to diagrams/dtos/dtos.txt index 92e510d..8dc7deb 100644 --- a/diagrams/dtos/dtos.plantuml +++ b/diagrams/dtos/dtos.txt @@ -1,9 +1,9 @@ -@startuml dtos +@startuml class TripDto { + tickets: Array + departureDate: Date + arrivalDate: Date - + totalPrice: Price + + totalPrice: number } class TicketDto { @@ -28,9 +28,7 @@ class AirlineDto { class AirportDto { __ attributes __ + id: int - + iata: String - + icao: String - + airportName: String + + name: String + city: String + country: String + timezone: int @@ -47,7 +45,7 @@ class PassengerDto { + dateOfBirth: Date + phoneNumber: String + email: String - + idOrPesel: String + + pesel: String } TripDto *-- TicketDto @@ -57,4 +55,4 @@ FlightDto *-- AirlineDto BookingRequestDto *-- TripDto BookingRequestDto *-- PassengerDto -@enduml +@enduml \ No newline at end of file diff --git a/src/main/java/pl/edu/pk/siwz/backend/controllers/ConnectionController/ConnectionDto.java b/src/main/java/pl/edu/pk/siwz/backend/controllers/ConnectionController/ConnectionDto.java deleted file mode 100644 index 0b669be..0000000 --- a/src/main/java/pl/edu/pk/siwz/backend/controllers/ConnectionController/ConnectionDto.java +++ /dev/null @@ -1,26 +0,0 @@ -package pl.edu.pk.siwz.backend.controllers.ConnectionController; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.Setter; -import pl.edu.pk.siwz.backend.controllers.AirlineController.AirlineDto; -import pl.edu.pk.siwz.backend.controllers.AirportController.AirportDto; - - -@Getter -@Setter -@Builder -@AllArgsConstructor -public class ConnectionDto { - private Long id; - private AirportDto srcAirportDto; - private AirportDto dstAirportDto; - private AirlineDto airlineDto; - private int numberSeats; - private String departureDate; - private String arrivalDate; - private String departureTime; - private String arrivalTime; - private double price; -} diff --git a/src/main/java/pl/edu/pk/siwz/backend/loaders/ConnectionLoader.java b/src/main/java/pl/edu/pk/siwz/backend/loaders/ConnectionLoader.java index 50e2508..56dab4c 100644 --- a/src/main/java/pl/edu/pk/siwz/backend/loaders/ConnectionLoader.java +++ b/src/main/java/pl/edu/pk/siwz/backend/loaders/ConnectionLoader.java @@ -13,6 +13,7 @@ import javax.transaction.Transactional; import java.time.LocalDate; +import java.time.LocalDateTime; import java.time.LocalTime; import java.util.Optional; @@ -95,17 +96,16 @@ public void run(String... args) throws Exception { .build(); connectionRepository.save(connection3); - Optional airline4 = airlineRepository.findById(2L); + //Optional airline4 = airlineRepository.findById(2L); Optional srcAirport4 = airportRepository.findById(1L); Optional dstAirport4 = airportRepository.findById(3L); Connection connection4 = Connection.builder() .srcAirport(srcAirport4.get()) .dstAirport(dstAirport4.get()) - .airline(airline4.get()) .times(Times. builder() - .departureDate(LocalDate.parse("2020-03-25")) - .arrivalDate(LocalDate.parse("2020-07-29")) + .departureDate(LocalDateTime.parse("2020-03-25")) + .arrivalDate(LocalDateTime.parse("2020-07-29")) .arrivalTime(LocalTime.parse("10:40:00")) .departureTime(LocalTime.parse("10:40:00")) .build()) diff --git a/src/main/java/pl/edu/pk/siwz/backend/models/Connection/Connection.java b/src/main/java/pl/edu/pk/siwz/backend/models/Connection/Connection.java index e0cfd68..173f6bc 100644 --- a/src/main/java/pl/edu/pk/siwz/backend/models/Connection/Connection.java +++ b/src/main/java/pl/edu/pk/siwz/backend/models/Connection/Connection.java @@ -4,17 +4,11 @@ import lombok.*; import org.hibernate.annotations.GenericGenerator; -import org.springframework.beans.factory.annotation.Autowired; -import pl.edu.pk.siwz.backend.controllers.AirlineController.AirlineMapper; -import pl.edu.pk.siwz.backend.controllers.AirportController.AirportMapper; -import pl.edu.pk.siwz.backend.controllers.ConnectionController.ConnectionDto; import pl.edu.pk.siwz.backend.models.Airline.Airline; import pl.edu.pk.siwz.backend.models.Airport.Airport; import pl.edu.pk.siwz.backend.models.Times; -import pl.edu.pk.siwz.backend.service.ConnectionService; -import java.time.LocalDate; -import java.time.LocalTime; +import java.time.LocalDateTime; @Entity @Builder @@ -28,44 +22,29 @@ public class Connection { @Id @GeneratedValue(generator = "inc") @GenericGenerator(name = "inc", strategy = "increment") - @Column(name = "connection_id") private Long id; @OneToOne - @JoinColumn(name = "airport_src_id") + @JoinColumn(name = "src_airport_id") private Airport srcAirport; @OneToOne - @JoinColumn(name = "airport_dst_id") + @JoinColumn(name = "dst_airport_dst") private Airport dstAirport; @OneToOne @JoinColumn(name = "airline_id") private Airline airline; - private int numberSeats; @Embedded private Times times; - private double price; public void updateForm(Long id, Airport srcAirport, Airport dstAirport, - Airline airline, - int numberSeats, String arrivalDate, - String arrivalTime, - String departureDate, - String departureTime, - double price - ) { - + String departureDate + ) { this.id = id; this.srcAirport = srcAirport; this.dstAirport = dstAirport; - this.airline = airline; - this.numberSeats = numberSeats; - this.getTimes().setDepartureDate(LocalDate.parse(departureDate)); - this.getTimes().setArrivalDate(LocalDate.parse(arrivalDate)); - this.getTimes().setDepartureTime(LocalTime.parse(departureTime)); - this.getTimes().setArrivalTime(LocalTime.parse(arrivalTime)); - this.price = price; - + this.getTimes().setDepartureDate(LocalDateTime.parse(departureDate)); + this.getTimes().setArrivalDate(LocalDateTime.parse(arrivalDate)); } } diff --git a/src/main/java/pl/edu/pk/siwz/backend/models/Times.java b/src/main/java/pl/edu/pk/siwz/backend/models/Times.java index b531a7d..f1e0ff4 100644 --- a/src/main/java/pl/edu/pk/siwz/backend/models/Times.java +++ b/src/main/java/pl/edu/pk/siwz/backend/models/Times.java @@ -3,8 +3,7 @@ import lombok.*; import javax.persistence.Embeddable; -import java.time.LocalDate; -import java.time.LocalTime; +import java.time.LocalDateTime; @Embeddable @Builder @@ -13,8 +12,6 @@ @Getter @Setter public class Times { - private LocalDate departureDate; - private LocalDate arrivalDate; - private LocalTime departureTime; - private LocalTime arrivalTime; + private LocalDateTime departureDate; + private LocalDateTime arrivalDate; } diff --git a/src/main/java/pl/edu/pk/siwz/backend/service/ConnectionService.java b/src/main/java/pl/edu/pk/siwz/backend/service/ConnectionService.java index cc4dc79..0b8d7d5 100644 --- a/src/main/java/pl/edu/pk/siwz/backend/service/ConnectionService.java +++ b/src/main/java/pl/edu/pk/siwz/backend/service/ConnectionService.java @@ -1,7 +1,6 @@ package pl.edu.pk.siwz.backend.service; import org.springframework.stereotype.Service; -import pl.edu.pk.siwz.backend.controllers.ConnectionController.ConnectionDto; import pl.edu.pk.siwz.backend.models.Airline.Airline; import pl.edu.pk.siwz.backend.models.Airline.AirlineRepository; import pl.edu.pk.siwz.backend.models.Airport.Airport; diff --git a/src/main/resources/db/migration/V1__init_Airline_and_Airport_table.sql b/src/main/resources/db/migration/V1__init_Airline_and_Airport_table.sql index 2c46090..c81dd10 100644 --- a/src/main/resources/db/migration/V1__init_Airline_and_Airport_table.sql +++ b/src/main/resources/db/migration/V1__init_Airline_and_Airport_table.sql @@ -2,16 +2,16 @@ drop table if exists airlines cascade; drop table if exists airports cascade; create table airlines( - airline_id bigint auto_increment primary key , - name varchar(100) not null, - country varchar(100) not null + id bigint auto_increment primary key , + name varchar(50) not null, + country varchar(50) not null ); create table airports( - airport_id bigint auto_increment primary key , - name varchar(100) not null, - city varchar(100) not null, - country varchar(100) not null, + id bigint auto_increment primary key , + name varchar(50) not null, + city varchar(50) not null, + country varchar(50) not null, longitude float not null, latitude float not null, timezone int diff --git a/src/main/resources/db/migration/V2__init_Connection_Flight_table.sql b/src/main/resources/db/migration/V2__init_Connection_Flight_table.sql new file mode 100644 index 0000000..69daabf --- /dev/null +++ b/src/main/resources/db/migration/V2__init_Connection_Flight_table.sql @@ -0,0 +1,27 @@ +drop table if exists connections cascade; +drop table if exists flights cascade; + + +create table connections( + id bigint auto_increment primary key auto_increment, + src_airport_id bigint not null, + dst_airport_id bigint not null, + departure_date varchar(50) not null, + arrival_date varchar(50) not null, + + foreign key (src_airport_id) references airports(id), + foreign key (src_airport_id) references airports(id) +); + +create table flights( + id bigint auto_increment primary key auto_increment, + connection_id bigint not null, + airline_id bigint not null, + number_seats int not null, + price double not null, + + foreign key (connection_id) references connections(id), + foreign key (airline_id) references airlines(id) +); + + diff --git a/src/main/resources/db/migration/V2__init_Connection_Route_and_ConnectionRoute_table.sql b/src/main/resources/db/migration/V2__init_Connection_Route_and_ConnectionRoute_table.sql deleted file mode 100644 index bae8a3e..0000000 --- a/src/main/resources/db/migration/V2__init_Connection_Route_and_ConnectionRoute_table.sql +++ /dev/null @@ -1,38 +0,0 @@ -drop table if exists connections cascade; -/*drop table if exists routes cascade; -drop table if exists routeconnections cascade;*/ - -create table connections( - connection_id bigint auto_increment , - airport_src_id bigint not null, - airport_dst_id bigint not null, - number_seats int not null, - departure_date date not null, - arrival_date date not null, - departure_time time not null, - arrival_time time not null, - price double not null, - - foreign key (airport_src_id) references airports(airport_id), - foreign key (airport_dst_id) references airports(airport_id), - foreign key (airline_id) references airlines(airline_id) -); -/* -create table routes( - route_id bigint primary key auto_increment, - airline_id bigint not null, - airport_src_id bigint not null, - airport_dst_id bigint not null, - foreign key (airline_id ) references airlines(airline_id), - foreign key (airport_src_id) references airports(airport_id), - foreign key (airport_dst_id) references airports(airport_id) -); - -create table routeconnections( - routeconnection_id bigint primary key auto_increment, - connection_id bigint not null, - route_id bigint not null, - foreign key (connection_id) references connections(connection_id), - foreign key (route_id) references routes(route_id) -); -*/