Skip to content

Commit

Permalink
Merge pull request #84 from TTBMP/release/v0.11
Browse files Browse the repository at this point in the history
Release/v0.11
  • Loading branch information
buracchi authored May 24, 2021
2 parents 87ffb50 + 3dbf424 commit f6ed320
Show file tree
Hide file tree
Showing 259 changed files with 5,209 additions and 4,115 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ plugins {
}

dependencies {
api(project(":domain"))
implementation(project(":service:authentication"))
implementation(project(":domain"))
implementation(project(":service:security"))
implementation(project(":service:email"))
implementation(project(":service:movie-api"))
implementation(project(":service:payment"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,8 @@ public static CinemaDto mapToDto(Cinema cinema) {
);
}

public static Cinema mapToEntity(CinemaDto cinemaDto) {
return new Cinema(
cinemaDto.getId(),
cinemaDto.getName(),
cinemaDto.getCity(), cinemaDto.getAddress(),
HallDataMapper.mapToEntityList(cinemaDto.getHalList())
);
}

public static List<CinemaDto> mapToDtoList(List<Cinema> cinemaList) {
return DataMapperHelper.mapList(cinemaList, CinemaDataMapper::mapToDto);
}

public static List<Cinema> mapToEntityList(List<CinemaDto> cinemaListDto) {
return DataMapperHelper.mapList(cinemaListDto, CinemaDataMapper::mapToEntity);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.ttbmp.cinehub.app.datamapper;

import com.ttbmp.cinehub.app.dto.CustomerDto;
import com.ttbmp.cinehub.app.utilities.DataMapperHelper;
import com.ttbmp.cinehub.domain.Customer;

import java.util.List;

public class CustomerDataMapper {

private CustomerDataMapper() {
}

public static CustomerDto mapToDto(Customer customer) {
return new CustomerDto(customer.getId(), customer.getName(), customer.getSurname(), customer.getEmail());
}

public static List<CustomerDto> mapToDtoList(List<Customer> customerList) {
return DataMapperHelper.mapList(customerList, CustomerDataMapper::mapToDto);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.ttbmp.cinehub.app.dto.UsherDto;
import com.ttbmp.cinehub.app.utilities.DataMapperHelper;
import com.ttbmp.cinehub.domain.employee.Employee;
import com.ttbmp.cinehub.domain.employee.Projectionist;
import com.ttbmp.cinehub.domain.employee.Usher;

import java.util.List;
Expand Down Expand Up @@ -36,33 +35,8 @@ public static EmployeeDto mapToDto(Employee employee) {
}
}

public static Employee matToEntity(EmployeeDto employeeDto) {
if (employeeDto instanceof UsherDto) {
return new Usher(
employeeDto.getId(),
employeeDto.getName(),
employeeDto.getSurname(),
null,
CinemaDataMapper.mapToEntity(employeeDto.getCinema())
);
} else {
return new Projectionist(
employeeDto.getId(),
employeeDto.getName(),
employeeDto.getSurname(),
null,
CinemaDataMapper.mapToEntity(employeeDto.getCinema())
);
}

}

public static List<EmployeeDto> mapToDtoList(List<Employee> employeeList) {
return DataMapperHelper.mapList(employeeList, EmployeeDataMapper::mapToDto);
}

public static List<Employee> mapToEntityList(List<EmployeeDto> employeeListDto) {
return DataMapperHelper.mapList(employeeListDto, EmployeeDataMapper::matToEntity);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,11 @@ private HallDataMapper() {
}

public static HallDto mapToDto(Hall hall) {
return new HallDto(hall.getId(), SeatDataMapper.mapToDtoList(hall.getSeatList()), hall.getName());
}

public static Hall mapToEntity(HallDto hallDto) {
if (hallDto != null) {
return new Hall(hallDto.getId(), SeatDataMapper.mapToEntityList(hallDto.getSeatList()), hallDto.getName());
}
return null;
return new HallDto(hall.getId(), SeatDataMapper.mapToDtoList(hall.getSeatList(), s -> false), hall.getName());
}

public static List<HallDto> mapToDtoList(List<Hall> hallList) {
return DataMapperHelper.mapList(hallList, HallDataMapper::mapToDto);
}

public static List<Hall> mapToEntityList(List<HallDto> hallListDto) {
return DataMapperHelper.mapList(hallListDto, HallDataMapper::mapToEntity);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,8 @@ public static MovieDto mapToDto(Movie movie) {
);
}

public static Movie mapToEntity(MovieDto movieDto) {
return new Movie(
movieDto.getId(),
movieDto.getName(),
movieDto.getOverview(),
Integer.parseInt(movieDto.getDuration()),
movieDto.getMovieUrl(),
movieDto.getVote(),
movieDto.getReleases()
);
}

public static List<MovieDto> mapToDtoList(List<Movie> movieList) {
return DataMapperHelper.mapList(movieList, MovieDataMapper::mapToDto);
}

public static List<Movie> mapToEntityList(List<MovieDto> movieList) {
return DataMapperHelper.mapList(movieList, MovieDataMapper::mapToEntity);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,8 @@ public static ProjectionDto mapToDto(Projection projection) {
);
}

public static Projection mapToEntity(ProjectionDto projectionDto) {
return new Projection(
projectionDto.getId(),
projectionDto.getDate(),
projectionDto.getStartTime(),
MovieDataMapper.mapToEntity(projectionDto.getMovieDto()),
HallDataMapper.mapToEntity(projectionDto.getHallDto()),
projectionDto.getProjectionist(),
TicketDataMapper.mapToEntityList(projectionDto.getListTicket()),
projectionDto.getBasePrice()
);
}

public static List<ProjectionDto> mapToDtoList(List<Projection> projectionList) {
return DataMapperHelper.mapList(projectionList, ProjectionDataMapper::mapToDto);
}

public static List<Projection> mapToEntityList(List<ProjectionDto> projectionDtoList) {
return DataMapperHelper.mapList(projectionDtoList, ProjectionDataMapper::mapToEntity);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.ttbmp.cinehub.domain.Seat;

import java.util.List;
import java.util.function.Predicate;

/**
* @author Ivan Palmieri
Expand All @@ -13,20 +14,18 @@ public class SeatDataMapper {
private SeatDataMapper() {
}

public static SeatDto mapToDto(Seat seat) {
return new SeatDto(seat.getId(), seat.getPosition());
public static SeatDto mapToDto(Seat seat, boolean isBooked) {
return new SeatDto(seat.getId(), seat.getPosition(), isBooked);
}

public static Seat mapToEntity(SeatDto seatDto) {
return new Seat(seatDto.getId(), seatDto.getPosition());
public static List<SeatDto> mapToDtoList(List<Seat> seatList, Predicate<Seat> isBooked) {
return DataMapperHelper.mapList(
seatList,
seat -> new SeatDto(
seat.getId(),
seat.getPosition(),
isBooked.test(seat)
));
}

public static List<SeatDto> mapToDtoList(List<Seat> seatList) {
return DataMapperHelper.mapList(seatList, SeatDataMapper::mapToDto);
}

public static List<Seat> mapToEntityList(List<SeatDto> ticketDtoList) {
return DataMapperHelper.mapList(ticketDtoList, SeatDataMapper::mapToEntity);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
import com.ttbmp.cinehub.app.dto.ShiftDto;
import com.ttbmp.cinehub.app.dto.ShiftProjectionistDto;
import com.ttbmp.cinehub.app.dto.ShiftUsherDto;
import com.ttbmp.cinehub.app.dto.UsherDto;
import com.ttbmp.cinehub.app.utilities.DataMapperHelper;
import com.ttbmp.cinehub.domain.employee.Usher;
import com.ttbmp.cinehub.domain.shift.ProjectionistShift;
import com.ttbmp.cinehub.domain.shift.Shift;
import com.ttbmp.cinehub.domain.shift.UsherShift;

import java.time.LocalDate;
import java.time.LocalTime;
Expand Down Expand Up @@ -47,36 +45,9 @@ public static ShiftDto mapToDto(Shift shift) {
}
}

public static Shift mapToEntity(ShiftDto shiftDto) {
Objects.requireNonNull(shiftDto);
if (shiftDto.getEmployee() instanceof UsherDto)
return new UsherShift(
shiftDto.getId(),
EmployeeDataMapper.matToEntity(shiftDto.getEmployee()),
shiftDto.getDate().toString(),
shiftDto.getStart().toString(),
shiftDto.getEnd().toString()
);
else
return new ProjectionistShift(
shiftDto.getId(),
EmployeeDataMapper.matToEntity(shiftDto.getEmployee()),
shiftDto.getDate().toString(),
shiftDto.getStart().toString(),
shiftDto.getEnd().toString(),
HallDataMapper.mapToEntity(((ShiftProjectionistDto) shiftDto).getHallDto()),
null
);
}

public static List<ShiftDto> mapToDtoList(List<Shift> shiftList) {
Objects.requireNonNull(shiftList);
return DataMapperHelper.mapList(shiftList, ShiftDataMapper::mapToDto);
}

public static List<Shift> mapToEntityList(List<ShiftDto> shiftDtoList) {
Objects.requireNonNull(shiftDtoList);
return DataMapperHelper.mapList(shiftDtoList, ShiftDataMapper::mapToEntity);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,16 @@ private TicketDataMapper() {
}

public static TicketDto mapToDto(Ticket ticket) {
return new TicketDto(ticket.getId(), ticket.getPrice(), UserDataMapper.mapToDto(ticket.getOwner()), SeatDataMapper.mapToDto(ticket.getSeat()));
}

public static Ticket mapToEntity(TicketDto ticketDto) {
return new Ticket(ticketDto.getId(), ticketDto.getPrice(), UserDataMapper.mapToEntity(ticketDto.getOwner()), SeatDataMapper.mapToEntity(ticketDto.getSeatDto()));
return new TicketDto(
ticket.getId(),
ticket.getPrice(),
CustomerDataMapper.mapToDto(ticket.getOwner()),
SeatDataMapper.mapToDto(ticket.getSeat(), true)
);
}

public static List<TicketDto> mapToDtoList(List<Ticket> ticketList) {
return DataMapperHelper.mapList(ticketList, TicketDataMapper::mapToDto);
}

public static List<Ticket> mapToEntityList(List<TicketDto> ticketDto) {
return DataMapperHelper.mapList(ticketDto, TicketDataMapper::mapToEntity);
}

}

This file was deleted.

11 changes: 7 additions & 4 deletions app/src/main/java/com/ttbmp/cinehub/app/di/ServiceLocator.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.ttbmp.cinehub.app.repository.cinema.CinemaRepository;
import com.ttbmp.cinehub.app.repository.cinema.JdbcCinemaRepository;
import com.ttbmp.cinehub.app.repository.customer.CustomerRepository;
import com.ttbmp.cinehub.app.repository.customer.JdbcCustomerRepository;
import com.ttbmp.cinehub.app.repository.employee.EmployeeRepository;
import com.ttbmp.cinehub.app.repository.employee.JdbcEmployeeRepository;
import com.ttbmp.cinehub.app.repository.employee.projectionist.JdbcProjectionistRepository;
Expand All @@ -26,14 +28,14 @@
import com.ttbmp.cinehub.app.repository.ticket.TicketRepository;
import com.ttbmp.cinehub.app.repository.user.JdbcUserRepository;
import com.ttbmp.cinehub.app.repository.user.UserRepository;
import com.ttbmp.cinehub.app.service.authentication.AuthenticationService;
import com.ttbmp.cinehub.app.service.authentication.MockAuthenticationService;
import com.ttbmp.cinehub.app.service.email.EmailService;
import com.ttbmp.cinehub.app.service.email.MockEmailService;
import com.ttbmp.cinehub.app.service.movieapi.MovieApiService;
import com.ttbmp.cinehub.app.service.movieapi.TheMovieDbApiServiceAdapter;
import com.ttbmp.cinehub.app.service.payment.PaymentService;
import com.ttbmp.cinehub.app.service.payment.StripeServiceAdapter;
import com.ttbmp.cinehub.app.service.security.FirebaseAuthSecurityServiceAdapter;
import com.ttbmp.cinehub.app.service.security.SecurityService;
import com.ttbmp.cinehub.app.utilities.FactoryMap;

/**
Expand All @@ -48,18 +50,19 @@ public ServiceLocator() {
}

protected void addServicesFactory() {
serviceFactoryMap.put(AuthenticationService.class, MockAuthenticationService::new);
serviceFactoryMap.put(EmailService.class, MockEmailService::new);
serviceFactoryMap.put(MovieApiService.class, TheMovieDbApiServiceAdapter::new);
serviceFactoryMap.put(PaymentService.class, StripeServiceAdapter::new);
serviceFactoryMap.put(SecurityService.class, () -> new FirebaseAuthSecurityServiceAdapter(this));
serviceFactoryMap.put(CinemaRepository.class, () -> new JdbcCinemaRepository(this));
serviceFactoryMap.put(CustomerRepository.class, () -> new JdbcCustomerRepository(this));
serviceFactoryMap.put(EmployeeRepository.class, () -> new JdbcEmployeeRepository(this));
serviceFactoryMap.put(ProjectionistRepository.class, () -> new JdbcProjectionistRepository(this));
serviceFactoryMap.put(UsherRepository.class, () -> new JdbcUsherRepository(this));
serviceFactoryMap.put(HallRepository.class, () -> new JdbcHallRepository(this));
serviceFactoryMap.put(MovieRepository.class, () -> new JdbcMovieRepository(this));
serviceFactoryMap.put(ProjectionRepository.class, () -> new JdbcProjectionRepository(this));
serviceFactoryMap.put(SeatRepository.class, JdbcSeatRepository::new);
serviceFactoryMap.put(SeatRepository.class, () -> new JdbcSeatRepository(this));
serviceFactoryMap.put(ShiftRepository.class, () -> new JdbcShiftRepository(this));
serviceFactoryMap.put(ProjectionistShiftRepository.class, () -> new JdbcProjectionistShiftRepository(this));
serviceFactoryMap.put(UsherShiftRepository.class, () -> new JdbcUsherShiftRepository(this));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import java.util.List;

public class UserDto {
public class CustomerDto {

private String id;
private String name;
private String surname;
private String email;
private List<TicketDto> ownedTicketDtoList;

public UserDto(String id, String name, String surname, String email) {
public CustomerDto(String id, String name, String surname, String email) {
this.id = id;
this.name = name;
this.surname = surname;
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/ttbmp/cinehub/app/dto/MovieDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* @author Ivan Palmieri
*/
public class MovieDto {

private int id;
private String name;
private String overview;
Expand Down
Loading

0 comments on commit f6ed320

Please sign in to comment.