Skip to content

Commit

Permalink
changes in Read.me and DTO sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
wydra98 committed Jun 29, 2020
1 parent 14c4630 commit af54633
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 135 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
38 changes: 23 additions & 15 deletions diagrams/dtos/dtos.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 5 additions & 7 deletions diagrams/dtos/dtos.plantuml → diagrams/dtos/dtos.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@startuml dtos
@startuml
class TripDto {
+ tickets: Array<TicketDto>
+ departureDate: Date
+ arrivalDate: Date
+ totalPrice: Price
+ totalPrice: number
}

class TicketDto {
Expand All @@ -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
Expand All @@ -47,7 +45,7 @@ class PassengerDto {
+ dateOfBirth: Date
+ phoneNumber: String
+ email: String
+ idOrPesel: String
+ pesel: String
}

TripDto *-- TicketDto
Expand All @@ -57,4 +55,4 @@ FlightDto *-- AirlineDto

BookingRequestDto *-- TripDto
BookingRequestDto *-- PassengerDto
@enduml
@enduml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import javax.transaction.Transactional;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Optional;

Expand Down Expand Up @@ -95,17 +96,16 @@ public void run(String... args) throws Exception {
.build();
connectionRepository.save(connection3);

Optional<Airline> airline4 = airlineRepository.findById(2L);
//Optional<Airline> airline4 = airlineRepository.findById(2L);
Optional<Airport> srcAirport4 = airportRepository.findById(1L);
Optional<Airport> 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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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));
}
}
9 changes: 3 additions & 6 deletions src/main/java/pl/edu/pk/siwz/backend/models/Times.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import lombok.*;

import javax.persistence.Embeddable;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.LocalDateTime;

@Embeddable
@Builder
Expand All @@ -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;
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
);


This file was deleted.

0 comments on commit af54633

Please sign in to comment.