Skip to content

Commit

Permalink
Merge pull request #98 from TTBMP/release/v1.0
Browse files Browse the repository at this point in the history
Release/v1.0
  • Loading branch information
buracchi authored Jul 4, 2021
2 parents 89a7457 + 58e3e9a commit 647781c
Show file tree
Hide file tree
Showing 63 changed files with 372 additions and 451 deletions.
67 changes: 67 additions & 0 deletions app/src/main/java/com/ttbmp/cinehub/app/dto/ShiftDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.ttbmp.cinehub.app.dto;

import com.ttbmp.cinehub.domain.shift.ProjectionistShift;
import com.ttbmp.cinehub.domain.shift.Shift;
import com.ttbmp.cinehub.domain.shift.UsherShift;
import lombok.AccessLevel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import lombok.experimental.FieldDefaults;

import java.time.LocalDate;
import java.time.LocalTime;

/**
* @author Fabio Buracchi, Massimo Mazzetti
*/

@Getter
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
@ToString
@EqualsAndHashCode
public class ShiftDto {

int id;
String employeeId;
LocalDate date;
LocalTime start;
LocalTime end;
ShiftType type;
HallDto hall;

public ShiftDto(Shift shift) {
this.id = shift.getId();
this.employeeId = shift.getEmployee().getId();
this.date = LocalDate.parse(shift.getDate());
this.start = LocalTime.parse(shift.getStart());
this.end = LocalTime.parse(shift.getEnd());
if(shift instanceof ProjectionistShift){
this.type=ShiftType.PROJECTIONIST_SHIFT;
this.hall = new HallDto (((ProjectionistShift) shift).getHall());
}else if(shift instanceof UsherShift){
this.type=ShiftType.USHER_SHIFT;
this.hall = null;
}else{
throw new IllegalStateException("Unexpected value: " + shift);
}
}

public enum ShiftType {
PROJECTIONIST_SHIFT("ProjectionistShift"),
USHER_SHIFT("UsherShift");

private final String type;

ShiftType(final String type) {
this.type = type;
}

@Override
public String toString() {
return type;
}

}

}
37 changes: 0 additions & 37 deletions app/src/main/java/com/ttbmp/cinehub/app/dto/shift/ShiftDto.java

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public class CustomerProxy extends Customer {
private final TicketRepository ticketRepository;
private final UserRepository userRepository;

private boolean isNameLoaded = false;
private boolean isSurnameLoaded = false;
private boolean isEmailLoaded = false;
private boolean isRoleListLoaded = false;
private boolean isTicketListLoaded = false;
private boolean isCustomerNameLoaded = false;
private boolean isCustomerSurnameLoaded = false;
private boolean isCustomerEmailLoaded = false;
private boolean isCustomerRoleListLoaded = false;
private boolean isCustomerTicketListLoaded = false;

public CustomerProxy(ServiceLocator serviceLocator, String id) {
super(id, null, null, null, null, null);
Expand All @@ -34,7 +34,7 @@ public CustomerProxy(ServiceLocator serviceLocator, String id) {

@Override
public String getName() {
if (!isNameLoaded) {
if (!isCustomerNameLoaded) {
try {
setName(userRepository.getUser(getId()).getName());
} catch (RepositoryException e) {
Expand All @@ -46,13 +46,13 @@ public String getName() {

@Override
public void setName(String name) {
isNameLoaded = true;
isCustomerNameLoaded = true;
super.setName(name);
}

@Override
public String getSurname() {
if (!isSurnameLoaded) {
if (!isCustomerSurnameLoaded) {
try {
setSurname(userRepository.getUser(getId()).getSurname());
} catch (RepositoryException e) {
Expand All @@ -64,13 +64,13 @@ public String getSurname() {

@Override
public void setSurname(String surname) {
isSurnameLoaded = true;
isCustomerSurnameLoaded = true;
super.setSurname(surname);
}

@Override
public String getEmail() {
if (!isEmailLoaded) {
if (!isCustomerEmailLoaded) {
try {
setEmail(userRepository.getUser(getId()).getEmail());
} catch (RepositoryException e) {
Expand All @@ -82,13 +82,13 @@ public String getEmail() {

@Override
public void setEmail(String email) {
isEmailLoaded = true;
isCustomerEmailLoaded = true;
super.setEmail(email);
}

@Override
public List<Role> getRoleList() {
if (!isRoleListLoaded) {
if (!isCustomerRoleListLoaded) {
try {
setRoleList(userRepository.getUser(getId()).getRoleList());
} catch (RepositoryException e) {
Expand All @@ -100,13 +100,13 @@ public List<Role> getRoleList() {

@Override
public void setRoleList(List<Role> roleList) {
isRoleListLoaded = true;
isCustomerRoleListLoaded = true;
super.setRoleList(roleList);
}

@Override
public boolean hasPermission(Permission requiredPermission) {
if (!isRoleListLoaded) {
if (!isCustomerRoleListLoaded) {
try {
setRoleList(userRepository.getUser(getId()).getRoleList());
} catch (RepositoryException e) {
Expand All @@ -118,7 +118,7 @@ public boolean hasPermission(Permission requiredPermission) {

@Override
public List<Ticket> getOwnedTicketList() {
if (!isTicketListLoaded) {
if (!isCustomerTicketListLoaded) {
try {
setOwnedTicketList(ticketRepository.getTicketList(this));
} catch (RepositoryException e) {
Expand All @@ -130,7 +130,7 @@ public List<Ticket> getOwnedTicketList() {

@Override
public void setOwnedTicketList(List<Ticket> ownedTicketList) {
isTicketListLoaded = true;
isCustomerTicketListLoaded = true;
super.setOwnedTicketList(ownedTicketList);
}

Expand Down
Loading

0 comments on commit 647781c

Please sign in to comment.