public void visitRentals(RentalVisitor visitor) { for (RentalDTO r : rentalService.getAllRentals()) { UserDTO user = userService.getUserById(r.getUserId()); MovieDTO movie = movieService.getMovieById(r.getMovieId()); visitor.visit( r.getId(), r.getRentalDays(), r.getRentalDate(), user.getLastName(), user.getFirstName(), movie.getTitle(), r.getRemainingDays(), r.getRentalFee()); } }
public void visitRentalsOfUser(Long userId, RentalVisitor visitor) { UserDTO user = userService.getUserById(userId); for (Long id : user.getRentalIds()) { RentalDTO r = rentalService.getRentalById(id); MovieDTO movie = movieService.getMovieById(r.getMovieId()); visitor.visit( r.getId(), r.getRentalDays(), r.getRentalDate(), user.getLastName(), user.getFirstName(), movie.getTitle(), r.getRemainingDays(), r.getRentalFee()); } }
private UserDTO getUser(Long id) { if (user == null || !user.getId().equals(id)) { user = userService.getUserById(id); } return user; }