Skip to content

Commit

Permalink
Merge pull request #53 from TTBMP/release/v0.7
Browse files Browse the repository at this point in the history
Release/v0.7
  • Loading branch information
buracchi authored Feb 15, 2021
2 parents 8f931c5 + 8e6448c commit dceb52a
Show file tree
Hide file tree
Showing 132 changed files with 1,395 additions and 545 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.List;

/**
* @author Palmieri Ivan
* @author Ivan Palmieri
*/
public class MovieDataMapper {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@

import com.ttbmp.cinehub.app.dto.ProjectionDto;
import com.ttbmp.cinehub.app.utilities.DataMapperHelper;
import com.ttbmp.cinehub.domain.CreditCard;
import com.ttbmp.cinehub.domain.Projection;
import com.ttbmp.cinehub.domain.employee.Projectionist;

import java.util.ArrayList;
import java.util.List;

/**
* @author Palmieri Ivan
* @author Ivan Palmieri
*/
public class ProjectionDataMapper {

Expand All @@ -23,22 +20,23 @@ public static ProjectionDto mapToDto(Projection projection) {
CinemaDataMapper.mapToDto(projection.getCinema()),
HallDataMapper.mapToDto(projection.getHall()),
projection.getStartTime(),
projection.getDate()
projection.getDate(),
TicketDataMapper.mapToDtoList(projection.getTicketList()),
projection.getId(),
projection.getProjectionist()
);
}

public static Projection mapToEntity(ProjectionDto projectionDto) {
return new Projection(
0,
projectionDto.getId(),
projectionDto.getDate(),
projectionDto.getStartTime(),
MovieDataMapper.mapToEntity(projectionDto.getMovieDto()),
HallDataMapper.mapToEntity(projectionDto.getHallDto()),
CinemaDataMapper.mapToEntity(projectionDto.getCinemaDto()),
new Projectionist(
"", "", "", "", new CreditCard(0, "", 0, ""),
CinemaDataMapper.mapToEntity(projectionDto.getCinemaDto())),
new ArrayList<>()
projectionDto.getProjectionist(),
TicketDataMapper.mapToEntityList(projectionDto.getListTicket())
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
import java.util.List;

/**
* @author Palmieri Ivan
* @author Ivan Palmieri
*/
public class SeatDataMapper {
private SeatDataMapper() {
}

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

public static Seat mapToEntity(SeatDto seatDto) {
return new Seat(seatDto.getId(), seatDto.getPrice(), seatDto.getState());
return new Seat(seatDto.getId(), seatDto.getPrice(), seatDto.getState(), seatDto.getPosition());
}

public static List<SeatDto> mapToDtoList(List<Seat> seatList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,31 @@
import com.ttbmp.cinehub.app.dto.TicketDto;
import com.ttbmp.cinehub.app.utilities.DataMapperHelper;
import com.ttbmp.cinehub.domain.ticket.component.Ticket;
import com.ttbmp.cinehub.domain.ticket.component.TicketAbstract;

import java.util.List;

/**
* @author Palmieri Ivan
* @author Ivan Palmieri
*/
public class TicketDataMapper {

private TicketDataMapper() {
}

public static TicketDto mapToDto(TicketAbstract ticketAbstract) {
TicketDto ticketDto = new TicketDto(ticketAbstract.getPrice());
ticketDto.setPosition(ticketAbstract.getPosition());
return ticketDto;
public static TicketDto mapToDto(Ticket ticket) {
return new TicketDto(ticket.getId(), ticket.getPrice(), ticket.getOwner(), SeatDataMapper.mapToDto(ticket.getSeat()));
}

public static Ticket mapToEntity(TicketDto ticketDto) {
Ticket ticket = new Ticket(ticketDto.getPrice());
ticket.setPosition(ticketDto.getPosition());
return ticket;
return new Ticket(ticketDto.getId(), ticketDto.getPrice(), ticketDto.getOwner(), SeatDataMapper.mapToEntity(ticketDto.getSeatDto()));
}

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

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

}
2 changes: 1 addition & 1 deletion app/src/main/java/com/ttbmp/cinehub/app/dto/CinemaDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.List;

/**
* @author Palmieri Ivan, Fabio Buracchi
* @author Ivan Palmieri, Fabio Buracchi
*/
public class CinemaDto {

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/ttbmp/cinehub/app/dto/HallDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.List;

/**
* @author Palmieri Ivan
* @author Ivan Palmieri
*/
public class HallDto {

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/ttbmp/cinehub/app/dto/MovieDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


/**
* @author Palmieri Ivan
* @author Ivan Palmieri
*/
public class MovieDto {
private int id;
Expand Down
51 changes: 41 additions & 10 deletions app/src/main/java/com/ttbmp/cinehub/app/dto/ProjectionDto.java
Original file line number Diff line number Diff line change
@@ -1,33 +1,64 @@
package com.ttbmp.cinehub.app.dto;

import com.ttbmp.cinehub.domain.employee.Projectionist;

import java.util.List;

/**
* @author Palmieri Ivan
* @author Ivan Palmieri
*/
public class ProjectionDto {

private final String startTime;
private final HallDto hallDto;
private CinemaDto cinemaDto;
private MovieDto movieDto;
private List<TicketDto> ticketBasicList;
private int id;
private String date;

public ProjectionDto(MovieDto movie, CinemaDto cinema, HallDto hall, String startTime, String date) {
private MovieDto movieDto;
private CinemaDto cinemaDto;
private Projectionist projectionist;
private List<TicketDto> listTicket;

public ProjectionDto(MovieDto movie,
CinemaDto cinema,
HallDto hall,
String startTime,
String date,
List<TicketDto> listTicket,
int id,
Projectionist projectionist
) {
this.id = id;
this.projectionist = projectionist;
this.movieDto = movie;
this.cinemaDto = cinema;
this.hallDto = hall;
this.startTime = startTime;
this.date = date;
this.listTicket = listTicket;
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public Projectionist getProjectionist() {
return projectionist;
}

public void setProjectionist(Projectionist projectionist) {
this.projectionist = projectionist;
}

public List<TicketDto> getTicketBasicList() {
return ticketBasicList;
public List<TicketDto> getListTicket() {
return listTicket;
}

public void setTicketBasicList(List<TicketDto> ticketBasicList) {
this.ticketBasicList = ticketBasicList;
public void setListTicket(List<TicketDto> listTicket) {
this.listTicket = listTicket;
}

public String getStartTime() {
Expand Down
14 changes: 12 additions & 2 deletions app/src/main/java/com/ttbmp/cinehub/app/dto/SeatDto.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
package com.ttbmp.cinehub.app.dto;

/**
* @author Palmieri Ivan
* @author Ivan Palmieri
*/
public class SeatDto {

private int id;
private Long price;
private Boolean state;
private String position;

public SeatDto(int id, Long price, Boolean state) {
public SeatDto(int id, Long price, Boolean state, String position) {
this.id = id;
this.price = price;
this.state = state;
this.position = position;
}

public String getPosition() {
return position;
}

public void setPosition(String position) {
this.position = position;
}

public int getId() {
Expand Down
43 changes: 33 additions & 10 deletions app/src/main/java/com/ttbmp/cinehub/app/dto/TicketDto.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,47 @@
package com.ttbmp.cinehub.app.dto;

import com.ttbmp.cinehub.domain.User;

/**
* @author Palmieri Ivan
* @author Ivan Palmieri
*/
public class TicketDto {

private long price;
private String position;
private int id;
private User owner;
private SeatDto seatDto;

public TicketDto(long price) {
public TicketDto(int id, long price, User owner, SeatDto seatDto) {
this.id = id;
this.owner = owner;
this.price = price;
this.seatDto = seatDto;
}

public SeatDto getSeatDto() {
return seatDto;
}

public void setSeatDto(SeatDto seatDto) {
this.seatDto = seatDto;
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public User getOwner() {
return owner;
}

public void setOwner(User owner) {
this.owner = owner;
}

public Long getPrice() {
return price;
Expand All @@ -25,12 +55,5 @@ public void setPrice(Long price) {
this.price = price;
}

public String getPosition() {
return position;
}

public void setPosition(String position) {
this.position = position;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ public interface HallRepository {

Hall getHall(ProjectionistShift projectionistShift);

Hall getHall(int hallId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ public Hall getHall(ProjectionistShift projectionistShift) {
.get(0);
}

@Override
public Hall getHall(int hallId) {
return HALL_DATA_LIST.stream()
.filter(d -> d.id == hallId)
.map(d -> new HallProxy(d.id, serviceLocator.getService(SeatRepository.class)))
.collect(Collectors.toList())
.get(0);
}

public static class HallData {

private int id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.List;

/**
* @author Palmieri Ivan
* @author Ivan Palmieri
*/
public interface MovieRepository {

Expand Down
Loading

0 comments on commit dceb52a

Please sign in to comment.