Changeset 07f4e8b for src/main/java
- Timestamp:
- 01/24/24 17:42:28 (10 months ago)
- Branches:
- master
- Children:
- 0f5aa27
- Parents:
- 5528b99
- Location:
- src/main/java/com/tourMate
- Files:
-
- 3 added
- 1 deleted
- 47 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/tourMate/config/SecurityConfig.java
r5528b99 r07f4e8b 5 5 import org.springframework.context.annotation.Bean; 6 6 import org.springframework.context.annotation.Configuration; 7 import org.springframework.http.HttpHeaders;8 7 import org.springframework.http.HttpMethod; 8 import org.springframework.http.HttpStatus; 9 9 import org.springframework.security.config.annotation.web.builders.HttpSecurity; 10 10 import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; … … 13 13 import org.springframework.security.crypto.password.PasswordEncoder; 14 14 import org.springframework.security.web.SecurityFilterChain; 15 import org.springframework.security.web.authentication. UsernamePasswordAuthenticationFilter;15 import org.springframework.security.web.authentication.logout.HttpStatusReturningLogoutSuccessHandler; 16 16 import org.springframework.security.web.util.matcher.AntPathRequestMatcher; 17 17 import org.springframework.web.cors.CorsConfiguration; … … 21 21 import java.util.Arrays; 22 22 23 import static org.springframework.security.config.Customizer.withDefaults;24 25 23 @Configuration 26 24 @EnableWebSecurity 27 25 public class SecurityConfig { 26 27 private final UserSecurity userSecurity; 28 29 public SecurityConfig(UserSecurity userSecurity) { 30 this.userSecurity = userSecurity; 31 } 28 32 29 33 @Bean … … 64 68 try { 65 69 authz 66 .requestMatchers(new AntPathRequestMatcher("/ 1/hasBusiness")).permitAll()67 .requestMatchers(new AntPathRequestMatcher("/business/ 1/unapproved")).permitAll()70 .requestMatchers(new AntPathRequestMatcher("/{userId}/hasBusiness")).access(userSecurity) 71 .requestMatchers(new AntPathRequestMatcher("/business/*/unapproved")).permitAll() 68 72 .requestMatchers(new AntPathRequestMatcher("/register")).permitAll() 69 73 .requestMatchers(new AntPathRequestMatcher("/hotel/search")).permitAll() … … 71 75 .requestMatchers(new AntPathRequestMatcher("/restaurant/search")).permitAll() 72 76 .requestMatchers(new AntPathRequestMatcher("/upload")).permitAll() 73 .requestMatchers(new AntPathRequestMatcher("/business/*")).hasAnyAuthority("SUPERADMIN") 74 .anyRequest().authenticated() 77 .requestMatchers(new AntPathRequestMatcher("/business/approve/*")).hasAnyAuthority("SUPERADMIN") 78 .requestMatchers(new AntPathRequestMatcher("/business/add/*")).authenticated() 79 .requestMatchers(new AntPathRequestMatcher("/*/user/{userId}")).access(userSecurity) 80 .anyRequest().permitAll() 81 // .anyRequest().authenticated() 75 82 .and() 76 .formLogin() .loginPage("http://localhost:3000/login")83 .formLogin() 77 84 .loginProcessingUrl("/api/login").usernameParameter("username").passwordParameter("password") 78 85 .successHandler((request, response, authentication) -> { 79 86 response.setStatus(HttpServletResponse.SC_OK); 87 response.setCharacterEncoding("UTF-8"); 80 88 response.setContentType("application/json"); 81 89 response.getWriter().print("{\"message\": \"Login successful\","); … … 85 93 .failureHandler((request, response, exception) -> { 86 94 response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); 87 response.getWriter().print("Pukla veza\n" + exception.getMessage()); 95 response.sendRedirect("/login"); 96 response.getWriter().print("Neuspesna najava\n" + exception.getMessage()); 88 97 response.getWriter().flush(); 89 98 }) … … 93 102 .sessionCreationPolicy(SessionCreationPolicy.ALWAYS) 94 103 .and() 95 .logout() 104 .logout().logoutSuccessHandler((new HttpStatusReturningLogoutSuccessHandler(HttpStatus.OK))) 96 105 .permitAll(); 97 106 -
src/main/java/com/tourMate/controllers/HotelController.java
r5528b99 r07f4e8b 2 2 3 3 import com.tourMate.dto.HotelDto; 4 import com.tourMate.dto.HotelReservationDto; 5 import com.tourMate.dto.HotelReservationUserDto; 4 6 import com.tourMate.entities.*; 5 7 import com.tourMate.services.HotelManager; … … 50 52 } 51 53 52 @GetMapping(path = "/hotel/ list/{id}")54 @GetMapping(path = "/hotel/{id}/list") 53 55 public ResponseEntity<Hotels> getHotelById (@PathVariable(name = "id") long hotelId) 54 56 { … … 104 106 //HOTEL ROOM CRUD 105 107 @PostMapping(path = "/hotel/rooms/add") 106 public void addRoom(@RequestBody HotelRoom room, @RequestParam(name = "hotelId") long hotelId) { 108 public void addRoom(@RequestBody HotelRoom room, 109 @RequestParam(name = "hotelId") long hotelId) { 107 110 Hotels h = hotelManager.findHotelByID(hotelId); 108 hotelManager.createRoom(h, room.getHotelRoomDescription(), room.getHotelRoomName(), room.getKitchenAvailable(), room.getAirConditioning(), room.getBalcony(), room.getPrice() );111 hotelManager.createRoom(h, room.getHotelRoomDescription(), room.getHotelRoomName(), room.getKitchenAvailable(), room.getAirConditioning(), room.getBalcony(), room.getPrice(), room.getNumOfBeds()); 109 112 } 110 113 … … 149 152 //HOTEL AVAILABILITY CRUD 150 153 @PostMapping(path = "/hotel/rooms/available/{id}/add") 151 public void addRoomAvailible(@RequestBody HotelRoomAvailable hotelRoomAvailable, @PathVariable long id) 154 public void addRoomAvailible(@RequestBody HotelRoomAvailable hotelRoomAvailable, 155 @PathVariable long id) 152 156 { 153 157 HotelRoom hotelRoom = hotelManager.findRoomById(id); … … 178 182 public List<HotelRoomAvailable> getRoomAvailability(@PathVariable Long id) 179 183 { 180 return hotelManager.getRoomsAvail ibility();184 return hotelManager.getRoomsAvailableById(id); 181 185 } 182 186 183 187 @GetMapping(path = "/hotel/search") 184 public List<HotelDto> searchAvailibleRooms(@RequestParam(name = "hotelLocation") String hotelLocation, @RequestParam(name = "dateFrom") @DateTimeFormat(pattern = "yyyy-MM-dd") Date dateFrom, 185 @RequestParam(name = "dateTo") @DateTimeFormat(pattern = "yyyy-MM-dd") Date dateTo, @RequestParam(name = "numBeds") int numBeds) 186 { 187 System.out.println(hotelLocation); 188 public List<HotelDto> searchAvailibleRooms(@RequestParam(name = "hotelLocation") String hotelLocation, 189 @RequestParam(name = "dateFrom") @DateTimeFormat(pattern = "yyyy-MM-dd") Date dateFrom, 190 @RequestParam(name = "dateTo") @DateTimeFormat(pattern = "yyyy-MM-dd") Date dateTo, 191 @RequestParam(name = "numBeds") int numBeds, 192 @RequestParam(name = "flexible") Boolean flexible) 193 { 194 System.out.println(flexible); 188 195 System.out.println(dateFrom + " " + dateTo); 189 return hotelManager.getRoomsAvailibilityByDateAndLocation(hotelLocation, dateFrom, dateTo, numBeds );196 return hotelManager.getRoomsAvailibilityByDateAndLocation(hotelLocation, dateFrom, dateTo, numBeds, flexible); 190 197 } 191 198 … … 203 210 } 204 211 205 <<<<<<< HEAD206 212 @GetMapping(path = "/hotel/{id}/reservations/active") 207 213 public List<HotelReservationDto> getActiveReservationsForHotel(@PathVariable Long id) … … 233 239 return hotelManager.getRoomImages(id); 234 240 } 235 ======= 236 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl) 241 242 @PostMapping("/hotel/{id}/cancel") 243 public void cancelHotelReservation(@PathVariable Long id){ 244 hotelManager.deleteReservation(id); 245 } 246 237 247 } -
src/main/java/com/tourMate/controllers/RestaurantController.java
r5528b99 r07f4e8b 1 1 package com.tourMate.controllers; 2 2 3 import com.tourMate.dto.HotelReservationDto; 3 4 import com.tourMate.dto.RestaurantDto; 5 import com.tourMate.dto.RestaurantReservationDto; 4 6 import com.tourMate.dto.RestaurantReservationUserDto; 5 7 import com.tourMate.entities.*; … … 34 36 } 35 37 38 @PostMapping("/restaurant/{id}/cancel") 39 public void removeRestaurant(@PathVariable Long id){ 40 restaurantManager.deleteReservation(id); 41 } 42 36 43 @GetMapping(path = "/restaurant") 37 44 public List<Restaurant> showRestaurants() { … … 42 49 public List<Restaurant> showRestaurantsForUser(@PathVariable(name = "id") long userId) { 43 50 44 return restaurantManager.getRestaurants ();51 return restaurantManager.getRestaurantsByUser(userId); 45 52 } 46 53 … … 133 140 @PathVariable Long id) { 134 141 System.out.println(restaurantsAvailible.getHourFrom() + " " + restaurantsAvailible.getHourTo()); 135 restaurantManager.createTableAvailable(id, restaurantsAvailible.getHourFrom(), restaurantsAvailible.getHourTo() );142 restaurantManager.createTableAvailable(id, restaurantsAvailible.getHourFrom(), restaurantsAvailible.getHourTo(), restaurantsAvailible.getNumTables()); 136 143 } 137 144 … … 170 177 return restaurantManager.getRestaurantImages(id); 171 178 } 179 180 @GetMapping(path = "/menu/{id}/images") 181 public List<MenuImages> getImagesForMenu(@PathVariable Long id) 182 { 183 return restaurantManager.getMenuImages(id); 184 } 185 186 @GetMapping(path = "/restaurant/{id}/reservations/active") 187 public List<RestaurantReservationDto> getActiveReservationsForHotel(@PathVariable Long id) 188 { 189 return restaurantManager.findReservationByRestaurant(id); 190 } 172 191 } 173 192 -
src/main/java/com/tourMate/controllers/ReviewController.java
r5528b99 r07f4e8b 20 20 @RequestParam(name = "hotelId", required = false) Long hotelId, 21 21 @RequestParam(name = "restaurantId", required = false) Long restaurantId, 22 @RequestParam(name = "transportId", required = false) Long transportId ) { 23 reviewManager.createReview(title, numStars, description, hotelId, restaurantId, transportId); 22 @RequestParam(name = "transportId", required = false) Long transportId, 23 @RequestParam(name = "reservationId") Long reservationId) { 24 reviewManager.createReview(title, numStars, description, hotelId, restaurantId, transportId, reservationId); 24 25 } 25 26 -
src/main/java/com/tourMate/controllers/TransportController.java
r5528b99 r07f4e8b 20 20 21 21 // TRANSPORT CRUD // 22 @PostMapping(path = "/transport/add") 23 public void add(@RequestBody Transport transport) { 24 transportManager.createTransport(transport.getTransportName(), transport.getCarBrand(), transport.getCarType(), transport.getCarManufacturedYear(), transport.getNoPassengers(), transport.getNoBags(), transport.getEMBG(), new User(), transport.getCarPlate()); 22 @PostMapping(path = "/transport/add/{userId}") 23 public void add(@RequestBody Transport transport, 24 @PathVariable Long userId) { 25 transportManager.createTransport(transport.getTransportName(), transport.getCarBrand(), transport.getCarType(), transport.getCarManufacturedYear(), transport.getNoPassengers(), transport.getNoBags(), transport.getEMBG(), userId, transport.getCarPlate()); 25 26 26 27 } … … 45 46 public TransportDto getTransport(@PathVariable(name = "id") long transportId) 46 47 { 47 System.out.println("TUKA SUUUUUM");48 48 return transportManager.findTransportById(transportId); 49 49 } … … 84 84 @PostMapping(path = "/transport/available/add") 85 85 public void add(@RequestBody TransportAvailible transportAvailable, @RequestParam(name = "transportId") long transportId) { 86 System.out.println("OREEEEEL");87 System.out.println("DVA ORLA");88 86 Transport t = transportManager.getTransportById(transportId); 89 87 List<TransportRoute> routes = transportAvailable.getRoutes().stream().toList(); … … 127 125 128 126 @GetMapping(path = "/transport/search") 129 public List<TransportListingDto> searchAvailableTransport(@RequestParam(name = "from") String from, @RequestParam(name = "to") String to, 130 @RequestParam(name = "date") @DateTimeFormat(pattern = "yyyy-MM-dd") Date date){ 131 return transportManager.getTransportsAvailableByFilters(from, to, date); 127 public List<TransportListingDto> searchAvailableTransport(@RequestParam(name = "from") String from, 128 @RequestParam(name = "to") String to, 129 @RequestParam(name = "date") @DateTimeFormat(pattern = "yyyy-MM-dd") Date date, 130 @RequestParam(name = "numPassengers") int numPassengers){ 131 return transportManager.getTransportsAvailableByFilters(from, to, date, numPassengers); 132 132 } 133 133 … … 151 151 return transportManager.findPastTransportReservationsByUser(id); 152 152 } 153 154 @GetMapping(path = "/transport/{id}/reservations/active") 155 public List<TransportReservation> showTransportReservationsByTransport(@PathVariable Long id) { 156 return transportManager.findTransportReservationByTransportId(id); 157 } 153 158 } -
src/main/java/com/tourMate/controllers/UsersController.java
r5528b99 r07f4e8b 11 11 import org.springframework.web.bind.annotation.*; 12 12 13 import java.util.ArrayList;14 13 import java.util.List; 15 14 … … 39 38 { 40 39 return businessManager.getUnapprovedBusinessesOfUser(userId); 40 } 41 42 @GetMapping(path = "/business/unapproved") 43 public List<Business> getAllUnapprovedBusinesses() 44 { 45 return businessManager.getUnapprovedBusinesses(); 46 } 47 48 @GetMapping(path = "/users/unapproved") 49 public List<User> getAllUnapprovedUsers() 50 { 51 return usersManager.getUnapprovedUsers(); 52 } 53 54 @GetMapping(path = "/users/approve/{userId}") 55 public ResponseEntity<?> approveUserProfile(@PathVariable Long userId) 56 { 57 usersManager.approveUserProfile(userId); 58 return new ResponseEntity<>(HttpStatus.OK); 59 60 61 } 62 63 @GetMapping(path = "/business/approve/{businessId}") 64 public ResponseEntity<?> approveBusiness(@PathVariable Long businessId) 65 { 66 businessManager.approveBusiness(businessId); 67 return new ResponseEntity<>(HttpStatus.OK); 41 68 } 42 69 … … 85 112 } 86 113 } 114 115 @GetMapping("/users/unlock/{id}") 116 public ResponseEntity unlock(@PathVariable Long id) 117 { 118 usersManager.unlock(id); 119 return new ResponseEntity(HttpStatus.OK); 120 } 87 121 } 88 122 -
src/main/java/com/tourMate/dao/BusinessDao.java
r5528b99 r07f4e8b 9 9 public interface BusinessDao { 10 10 11 @Transactional 12 void createBusiness(Business business, long userId); 13 public List<Business> getUnapprovedBusinessesOfUser(long userId); 14 public void deleteBusiness(long businessId); 15 public List<Business> getCreatedBusinesses(); 16 public Business findBusinessById (long businessId); 11 List<Business> getCreatedBusinesses(); 12 13 Business findBusinessById(long businessId); 17 14 18 15 @Transactional 19 void editBusiness(long businessId, String name, String phone, String address, String edbs, User user, boolean approved); 20 public boolean hasBusiness(long userId); 16 void createBusiness(Business business); 21 17 18 List<Business> getUnapprovedBusinessesOfUser(User u); 19 20 @Transactional 21 void deleteBusiness(Business business); 22 23 boolean hasBusiness(User u); 24 25 List<Business> getUnapprovedBusinesses(); 26 27 void approveBusiness(Business business); 28 29 @Transactional 30 void editBusiness(Business business); 22 31 } -
src/main/java/com/tourMate/dao/HotelDao.java
r5528b99 r07f4e8b 9 9 10 10 public interface HotelDao { 11 public void createHotel(Hotels hotel, long userId); 12 public void editHotel(long hotelId, String hotelName, String hotelDescripiton, String hotelLocation, String hotelEDBS, Boolean parking, Boolean petFriendly, Boolean internetAvailable); 13 public void deleteHotel(long hotelId); 14 public Hotels findHotelByID (long hotelId); 15 public List<Hotels> getHotels(); 16 public List<Hotels> getHotelsForUser(long userId); 17 public List<Hotels> getHotelsByLocation(String hotelLocation); 11 @Transactional 12 void createHotel(Hotels hotel); 18 13 19 public void deleteHotelImage(long hotelImageId); 20 public HotelsImages findHotelImageById(long hotelImageId); 21 public List<HotelsImages> getHotelImages(Hotels hotels); 22 public List<HotelRoomImages> getRoomImages(HotelRoom hotelRoom); 14 List<Hotels> getHotels(); 23 15 24 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price); 25 public void editRoom(long hotelRoomId, Hotels hotel, String hotelRoomDescription, String HotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price); 26 public void deleteRoom(long hotelRoomId); 27 public HotelRoom findRoomById (long hotelRoomId); 28 public List<HotelRoom> getRoomsOfHotel (long hotelId); 29 public List<HotelRoomAvailable> getRoomsAvailable(Long id); 16 List<Hotels> getHotelsForUser(User u); 17 18 List<Hotels> getHotelsByLocation(String hotelLocation); 30 19 31 20 @Transactional 32 public void createRoomAvailible(HotelRoom hotelRoom, Date dateFrom, Date dateTo, int numberOfBeds); 33 public void editRoomAvailible(long hotelRoomAvailableId, HotelRoom hotelRoom, Date dateFrom, Date dateTo, int numberOfBeds); 34 public void deleteRoomAvailible(long hotelRoomAvailableId); 35 public HotelRoomAvailable findAvailibleRoomById(long hotelRoomAvailableId); 36 public List<HotelRoomAvailable> getRoomsAvailibility(); 37 public List<HotelRoomAvailable> getRoomsAvailibilityByHotel(Hotels hotel); 38 public List<HotelRoomAvailable> getRoomsAvailibilityByDateAndLocation(String hotelLocation, Date dateFrom, Date dateTo, int numberOfBeds); 21 void editHotel(Hotels hotel); 39 22 40 public void createReservation(User user, HotelRoom hotelRoom, Date dateFrom, Date dateTo, Integer numberOfBeds); 41 public void editReservation(long hotelRoomReservedId, User user, HotelRoom hotelRoom, Date dateFrom, Date dateTo, Integer numberOfBeds); 42 public void deleteReservation(long hotelRoomReservedId); 43 public HotelRoomReservations findReservationById(long hotelRoomReservedId); 44 public List<HotelRoomReservations> findReservationByUser(User user); 45 public List<HotelRoomReservations> findReservationByHotel(Hotels hotel); 46 public List<HotelRoomReservations> getReservations(); 23 @Transactional 24 void deleteHotel(Hotels hotel); 25 26 Hotels findHotelByID(long hotelId); 27 28 List<HotelsImages> getHotelImages(Hotels hotel); 29 30 @Transactional 31 void addHotelImage(HotelsImages image); 32 33 @Transactional 34 void addRoomImage(HotelRoomImages x); 35 36 @Transactional 37 void saveReservation(HotelRoomReservations hotelRoomReservations); 38 39 @Transactional 40 HotelsImages findHotelImageById(long hotelImageId); 41 42 @Transactional 43 void deleteHotelImage(HotelsImages hotelsImages); 44 45 List<HotelRoom> getRoomsOfHotel(Hotels hotel); 46 47 List<HotelRoomAvailable> getRoomsAvailable(Long id); 48 49 HotelRoom findRoomById(long hotelRoomId); 50 51 List<HotelRoomImages> getRoomImages(HotelRoom hotelRoom); 52 53 @Transactional 54 void createRoom(HotelRoom hotelRoom); 55 56 @Transactional 57 void editRoom(HotelRoom hr); 58 59 @Transactional 60 void deleteRoom(HotelRoom hr); 61 62 @Transactional 63 void createRoomAvailible(HotelRoomAvailable hra); 64 65 @Transactional 66 void editRoomAvailible(HotelRoomAvailable hr); 67 68 @Transactional 69 void deleteRoomAvailible(HotelRoomAvailable hra); 70 71 HotelRoomAvailable findAvailibleRoomById(long hotelRoomAvailableId); 72 73 List<HotelRoomAvailable> getRoomsAvailibility(); 74 75 List<HotelRoomAvailable> getRoomsAvailibilityByHotel(Hotels hotel); 76 77 List<HotelRoomAvailable> getRoomsAvailibilityByDateAndLocation(String hotelLocation, Date dateFrom, Date dateTo, int numberOfBeds, Boolean flexible); 78 79 @Transactional 80 void createReservation(HotelRoomReservations r); 81 82 @Transactional 83 void editReservation(HotelRoomReservations hr); 84 85 @Transactional 86 void deleteReservation(HotelRoomReservations hr); 87 88 HotelRoomReservations findReservationById(long hotelRoomReservedId); 89 90 List<HotelRoomReservations> findReservationByUser(User user); 91 92 List<HotelRoomReservations> findReservationByHotel(Hotels hotel); 93 94 List<HotelRoomReservations> getReservations(); 47 95 48 96 List<Reviews> findReviewsByHotel(Hotels hotel); 49 97 50 98 List<HotelRoomReservations> findPastReservationByUser(User u); 51 52 void addHotelImage(HotelsImages x); 53 54 void addRoomImage(HotelRoomImages x); 99 // public void createHotel(Hotels hotel, long userId); 100 // public void editHotel(long hotelId, String hotelName, String hotelDescripiton, String hotelLocation, String hotelEDBS, Boolean parking, Boolean petFriendly, Boolean internetAvailable); 101 // public void deleteHotel(long hotelId); 102 // public Hotels findHotelByID (long hotelId); 103 // public List<Hotels> getHotels(); 104 // public List<Hotels> getHotelsForUser(long userId); 105 // public List<Hotels> getHotelsByLocation(String hotelLocation); 106 // 107 // public void deleteHotelImage(long hotelImageId); 108 // public HotelsImages findHotelImageById(long hotelImageId); 109 // public List<HotelsImages> getHotelImages(Hotels hotels); 110 // public List<HotelRoomImages> getRoomImages(HotelRoom hotelRoom); 111 // 112 // public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price, int numOfBeds); 113 // public void editRoom(long hotelRoomId, Hotels hotel, String hotelRoomDescription, String HotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price); 114 // public void deleteRoom(long hotelRoomId); 115 // public HotelRoom findRoomById (long hotelRoomId); 116 // public List<HotelRoom> getRoomsOfHotel (long hotelId); 117 // public List<HotelRoomAvailable> getRoomsAvailable(Long id); 118 // 119 // @Transactional 120 // public void createRoomAvailible(HotelRoom hotelRoom, Date dateFrom, Date dateTo, int numberOfBeds); 121 // public void editRoomAvailible(long hotelRoomAvailableId, HotelRoom hotelRoom, Date dateFrom, Date dateTo, int numberOfBeds); 122 // public void deleteRoomAvailible(long hotelRoomAvailableId); 123 // public HotelRoomAvailable findAvailibleRoomById(long hotelRoomAvailableId); 124 // public List<HotelRoomAvailable> getRoomsAvailibility(); 125 // public List<HotelRoomAvailable> getRoomsAvailibilityByHotel(Hotels hotel); 126 // public List<HotelRoomAvailable> getRoomsAvailibilityByDateAndLocation(String hotelLocation, Date dateFrom, Date dateTo, int numberOfBeds, Boolean flexible); 127 // 128 // public void createReservation(User user, HotelRoom hotelRoom, Date dateFrom, Date dateTo, Integer numberOfBeds); 129 // public void editReservation(long hotelRoomReservedId, User user, HotelRoom hotelRoom, Date dateFrom, Date dateTo, Integer numberOfBeds); 130 // public void deleteReservation(long hotelRoomReservedId); 131 // public HotelRoomReservations findReservationById(long hotelRoomReservedId); 132 // public List<HotelRoomReservations> findReservationByUser(User user); 133 // public List<HotelRoomReservations> findReservationByHotel(Hotels hotel); 134 // public List<HotelRoomReservations> getReservations(); 135 // 136 // List<Reviews> findReviewsByHotel(Hotels hotel); 137 // 138 // List<HotelRoomReservations> findPastReservationByUser(User u); 139 // 140 // void addHotelImage(HotelsImages x); 141 // 142 // void addRoomImage(HotelRoomImages x); 143 // void saveReservation(HotelRoomReservations hotelRoomReservations); 55 144 } -
src/main/java/com/tourMate/dao/MenuDao.java
r5528b99 r07f4e8b 2 2 3 3 import com.tourMate.entities.Menu; 4 import jakarta.transaction.Transactional; 4 5 5 6 import java.util.List; 6 7 7 8 public interface MenuDao { 8 public void createMenu(String name, String ingredients, double price); 9 public void deleteMenu(long menuId); 10 public List<Menu> getCreatedMenus(); 11 public Menu findMenuById(long menuId); 12 public void editMenu(long menuId, String name, String ingredients, double price); 9 @Transactional 10 void createMenu(Menu menu); 11 12 @Transactional 13 void deleteMenu(Menu menu); 14 15 List<Menu> getCreatedMenus(); 16 17 Menu findMenuById(long menuId); 18 19 @Transactional 20 void editMenu(Menu menu); 21 // public void createMenu(String name, String ingredients, double price); 22 // 23 // @Transactional 24 // void createMenu(Menu menu); 25 // 26 // public void deleteMenu(long menuId); 27 // 28 // @Transactional 29 // void deleteMenu(Menu menu); 30 // 31 // public List<Menu> getCreatedMenus(); 32 // public Menu findMenuById(long menuId); 33 // public void editMenu(long menuId, String name, String ingredients, double price); 13 34 } -
src/main/java/com/tourMate/dao/RestaurantDao.java
r5528b99 r07f4e8b 8 8 9 9 public interface RestaurantDao { 10 public void createRestaurant(Restaurant restaurant, long userId);11 public void deleteRestaurant(long restaurantID);12 10 @Transactional 13 public void editRestaurant(long restaurantID, String restaurantName, String restaurantLocation, String cousineType, String restaurantDescription, String restaurantEdbs, User restaurantOwner); 14 public Restaurant findRestaurantByID (long restaurantID); 15 public List<Restaurant> searchByRestaurantName(String restaurantName); 16 public List<Restaurant> searchByRestaurantLocation(String restaurantLocation); 17 public List<Restaurant> getRestaurants(); 11 void createRestaurant(Restaurant restaurant); 12 List<RestaurantsAvailible> getTablesByDateAndLocation(String restaurantLocation, Date hourFrom, Date hourTo, int noSeats); 18 13 @Transactional 19 public void addMenuToRestaurant(long restaurantId, Menu menu); 14 void addRestaurantImage(RestaurantImages restaurantImages); 15 @Transactional 16 void removeRestaurantImage(RestaurantImages image); 17 @Transactional 18 void saveTable(RestaurantsTable resTable); 19 @Transactional 20 RestaurantImages findRestaurantImageById(long restaurantImageId); 21 void deleteRestaurant(Restaurant r); 22 List<Restaurant> getRestaurants(); 23 @Transactional 24 void addMenuToRestaurant(Menu menu); 25 Restaurant findRestaurantByID(long restaurantID); 26 List<RestaurantImages> getRestaurantImages(long restaurantID); 27 List<RestaurantsTable> getRestaurantTables(long restaurantID); 28 RestaurantsTable findTableById(long tableId); 29 @Transactional 30 void deleteTable(RestaurantsTable rt); 31 List<Restaurant> getRestaurantsByUser(User u); 32 List<RestaurantsAvailible> getTablesAvailabilityById(Long id); 33 @Transactional 34 void saveTableAvailable(RestaurantsAvailible ra); 35 @Transactional 36 void deleteTableAvailable(RestaurantsAvailible ra); 20 37 21 public List<RestaurantsAvailible> getTablesByDateAndLocation(String restaurantLocation, Date hourFrom, Date hourTo, int noSeats);38 List<RestaurantsAvailible> getTablesAvailability(); 22 39 23 public void createTable(Restaurant restaurant, int noSeats); 24 public void editTable(Restaurant restaurant, long tableId, int noSeats); 25 public void deleteTable(long tableId); 26 public List<Restaurant> getRestaurantsByUser(long userId); 27 public RestaurantsTable findTableById(long tableId); 28 public List<RestaurantsTable> searchByNoSeats(int noSeats); 29 public List<RestaurantsTable> getRestaurantTables(long restaurantID); 40 // List<RestaurantsAvailible> getTablesAvailability(); 41 @Transactional 42 void createReservation(RestaurantReservations reservations); 43 @Transactional 44 void deleteReservation(RestaurantReservations r); 45 RestaurantReservations findReservationByID(long tableId); 46 RestaurantsAvailible findAvailableReservationByID(long availibleId); 47 List<RestaurantReservations> findReservationByUser(User user); 48 List<RestaurantReservations> findReservationByRestaurant(Restaurant restaurant); 49 List<RestaurantReservations> getReservations(); 50 List<Restaurant> searchByRestaurantName(String restaurantName); 30 51 31 public void addRestaurantImage(RestaurantImages restaurantImages); 32 public void removeRestaurantImage(long restaurantImageId); 33 public RestaurantImages findRestaurantImageById(long restaurantImageId); 34 public List<RestaurantImages> getRestaurantImages(long restaurantID); 52 List<Restaurant> searchByRestaurantLocation(String restaurantLocation); 35 53 36 public void createTableAvailable(RestaurantsTable restaurantsTable, Date hourFrom, Date hourTo, int noSeats); 37 @Transactional 38 abstract void createTableAvailable(RestaurantsTable restaurantsTable, Date hourFrom, Date hourTo); 39 public List<RestaurantsAvailible> getTablesAvailabilityById(Long id); 40 public void editTableAvailable(long tableId, Restaurant restaurant, int noSeats); 41 public void deleteTableAvailable(long tableId); 42 public RestaurantsAvailible findAvailableReservationByID(long availibleId); 43 44 public List<RestaurantsAvailible> getTablesAvailability(); 45 public void createReservation(RestaurantReservations reservations); 46 public void editReservation(long restaurantsTableId, RestaurantsTable rt, Date hourFrom, Date hourTo, int noSeats, User user); 47 public void deleteReservation(long restaurantsTableId); 48 public RestaurantReservations findReservationByID(long tableId); 49 public List<RestaurantReservations> findReservationByUser(User user); 50 public List<RestaurantReservations> findReservationByRestaurant(Restaurant restaurant); 51 public List<RestaurantReservations> getReservations(); 54 List<RestaurantsTable> searchByNoSeats(int noSeats); 52 55 53 56 List<Reviews> findReviewsByRestaurant(Restaurant restaurant); 54 57 55 List<RestaurantReservations> findPastReservationsByUser(User u); 58 List<RestaurantReservations> findPastReservationsByUser(User user); 59 60 List<MenuImages> getMenuImages(long menuId); 61 62 List<MenuImages> getMenuImagesByRestaurant(Restaurant restaurant); 63 64 @Transactional 65 void addMenuImage(MenuImages menuImages); 66 67 Menu findMenuId(Long menuId); 68 69 void saveReservation(RestaurantReservations r); 70 71 // public void createRestaurant(Restaurant restaurant, long userId); 72 // public void deleteRestaurant(long restaurantID); 73 // @Transactional 74 // public void editRestaurant(long restaurantID, String restaurantName, String restaurantLocation, String cousineType, String restaurantDescription, String restaurantEdbs, User restaurantOwner); 75 // public Restaurant findRestaurantByID (long restaurantID); 76 // public List<Restaurant> searchByRestaurantName(String restaurantName); 77 // public List<Restaurant> searchByRestaurantLocation(String restaurantLocation); 78 // public List<Restaurant> getRestaurants(); 79 // @Transactional 80 // public void addMenuToRestaurant(long restaurantId, Menu menu); 81 // 82 // public List<RestaurantsAvailible> getTablesByDateAndLocation(String restaurantLocation, Date hourFrom, Date hourTo, int noSeats); 83 // 84 // public void createTable(Restaurant restaurant, int noSeats); 85 // public void editTable(Restaurant restaurant, long tableId, int noSeats); 86 // public void deleteTable(long tableId); 87 // public List<Restaurant> getRestaurantsByUser(long userId); 88 // public RestaurantsTable findTableById(long tableId); 89 // public List<RestaurantsTable> searchByNoSeats(int noSeats); 90 // public List<RestaurantsTable> getRestaurantTables(long restaurantID); 91 // 92 // public void addRestaurantImage(RestaurantImages restaurantImages); 93 // public void removeRestaurantImage(long restaurantImageId); 94 // public RestaurantImages findRestaurantImageById(long restaurantImageId); 95 // public List<RestaurantImages> getRestaurantImages(long restaurantID); 96 // 97 // public void createTableAvailable(RestaurantsTable restaurantsTable, Date hourFrom, Date hourTo, int noSeats); 98 // @Transactional 99 // abstract void createTableAvailable(RestaurantsTable restaurantsTable, Date hourFrom, Date hourTo); 100 // public List<RestaurantsAvailible> getTablesAvailabilityById(Long id); 101 // public void editTableAvailable(long tableId, Restaurant restaurant, int noSeats); 102 // public void deleteTableAvailable(long tableId); 103 // public RestaurantsAvailible findAvailableReservationByID(long availibleId); 104 // 105 // public List<RestaurantsAvailible> getTablesAvailability(); 106 // public void createReservation(RestaurantReservations reservations); 107 // public void editReservation(long restaurantsTableId, RestaurantsTable rt, Date hourFrom, Date hourTo, int noSeats, User user); 108 // public void deleteReservation(long restaurantsTableId); 109 // public RestaurantReservations findReservationByID(long tableId); 110 // public List<RestaurantReservations> findReservationByUser(User user); 111 // public List<RestaurantReservations> findReservationByRestaurant(Restaurant restaurant); 112 // public List<RestaurantReservations> getReservations(); 113 // 114 // List<Reviews> findReviewsByRestaurant(Restaurant restaurant); 115 // 116 // List<RestaurantReservations> findPastReservationsByUser(User u); 117 // List<MenuImages> getMenuImages(long menuId); 118 // public void addMenuImage(MenuImages menuImages); 119 // 120 // Menu findMenuId(Long menuId); 121 // 122 // void saveReservation(RestaurantReservations restaurantReservations); 56 123 } -
src/main/java/com/tourMate/dao/ReviewDao.java
r5528b99 r07f4e8b 10 10 11 11 public interface ReviewDao { 12 13 12 @Transactional 14 13 void createReview(Reviews review); 15 14 16 public void deleteReview(long id); 17 public void editReview(long id, String title, String description, int numStar, Hotels hotel, Restaurant restaurant, Transport transport); 18 public Reviews findReviewById(long id); 19 public List<Reviews> getAllReviews(); 20 public List<Reviews> getHotelReviews(); 21 public List<Reviews> getTransportReviews(); 22 public List<Reviews> getRestaurantReviews(); 23 public List<Reviews> getHotelReviews(Hotels hotel); 24 public List<Reviews> getRestaurantReviews(Restaurant restaurant); 25 public List<Reviews> getTransportReviews(Transport transport); 15 void deleteReview(Reviews review); 16 17 Reviews findReviewById(long id); 18 19 void editReview(Reviews review); 20 21 List<Reviews> getAllReviews(); 22 23 List<Reviews> getHotelReviews(); 24 25 List<Reviews> getTransportReviews(); 26 27 List<Reviews> getRestaurantReviews(); 28 29 List<Reviews> getHotelReviews(Hotels hotel); 30 31 List<Reviews> getRestaurantReviews(Restaurant restaurant); 32 33 List<Reviews> getTransportReviews(Transport transport); 34 // @Transactional 35 // void createReview(Reviews review); 36 // 37 // public void deleteReview(long id); 38 // public void editReview(long id, String title, String description, int numStar, Hotels hotel, Restaurant restaurant, Transport transport); 39 // public Reviews findReviewById(long id); 40 // public List<Reviews> getAllReviews(); 41 // public List<Reviews> getHotelReviews(); 42 // public List<Reviews> getTransportReviews(); 43 // public List<Reviews> getRestaurantReviews(); 44 // public List<Reviews> getHotelReviews(Hotels hotel); 45 // public List<Reviews> getRestaurantReviews(Restaurant restaurant); 46 // public List<Reviews> getTransportReviews(Transport transport); 26 47 27 48 } -
src/main/java/com/tourMate/dao/TransportDao.java
r5528b99 r07f4e8b 4 4 import com.tourMate.dto.TransportDto; 5 5 import com.tourMate.entities.*; 6 import jakarta.transaction.Transactional; 6 7 7 8 8 import java.util.Collection;9 9 import java.util.Date; 10 10 import java.util.List; 11 11 12 12 public interface TransportDao { 13 @Transactional 14 void createTransport(Transport t); 13 15 14 public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate); 16 @Transactional 17 void deleteTransport(Transport t); 15 18 16 public void deleteTransport(long transportId);19 List<Transport> getTransports(); 17 20 18 public void editTransport(long transportID, String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate);21 List<TransportDto> getTransportsByUser(User u); 19 22 20 public List<Transport> getTransports(); 21 public List<TransportDto> getTransportsByUser(long userId); 23 List<RouteListingDto> getRoutesForTransport(Transport t); 22 24 23 public List<RouteListingDto> getRoutesForTransport(long transportId); 24 public Transport getTransportById(long transportId); 25 public TransportDto findTransportById (long transportId); 25 TransportDto findTransportById(long transportId); 26 26 27 public void createTransportReservation(TransportReservation transportReservation);27 Transport getTransportById(long transportId); 28 28 29 public void editTransportReservation(Transport transport, long reservationID, String departureLocation, String arrivalLocation, Date date, Integer noSeats, User user, Date departureHour); 29 @Transactional 30 void editTransport(Transport t); 30 31 31 public void deleteTransportReservation(long reservationID); 32 @Transactional 33 void createTransportReservation(TransportReservation transportReservation); 32 34 33 publicTransportReservation findTransportReservationByID(long reservationID);35 TransportReservation findTransportReservationByID(long reservationID); 34 36 35 publicList<TransportReservation> getTransportReservations();37 List<TransportReservation> getTransportReservations(); 36 38 37 public List<TransportReservation> getTransportsReservationsByUserID(long userID);39 TransportAvailible findTransportAvailableByID(long reservationID); 38 40 39 public void createTransportAvailable(Transport transport, String departureLocation, String arrivalLocation, Date date, Integer noSeats, Date departureHour, Collection<TransportRoute> routes);41 List<TransportRoute> getTransportsAvailableByFilters(String fromL, String toL, Date date, int numPassengers); 40 42 41 public void editTransportAvailable(Transport transport, long availableID, String departureLocation, String arrivalLocation, Date date, Integer noSeats, Date departureHour);43 List<TransportReservation> getTransportsReservationsByUserID(long userID); 42 44 43 public void deleteTransportAvailable(long availableID);45 List<TransportAvailible> getTransportsAvailable(); 44 46 45 public TransportAvailible findTransportAvailableByID (long reservationID); 47 @Transactional 48 void createTransportAvailable(TransportAvailible ta); 46 49 47 public List<TransportAvailible> getTransportsAvailable();50 void editTransportAvailable(TransportAvailible ta); 48 51 49 public List<TransportRoute> getTransportsAvailableByFilters (String from,String to,Date date); 50 51 public void createTransportRoute(TransportAvailible parentRoute, String from, String to, double price, Date departure, Date arrival, int freeSpace, int order); 52 53 public void deleteTransportRoute(long transportRouteId); 54 55 public void editTransportRoute(long transportRouteId, TransportAvailible parentRoute, String from, String to, double price, Date departure, Date arrival, int freeSpace, int order); 56 57 public TransportRoute findTransportRouteById(long transportRouteId); 52 TransportRoute findTransportRouteById(long transportRouteId); 58 53 59 54 List<Reviews> getReviewsForTransport(Transport transport); 60 55 61 List<TransportReservation> find ReservationByUser(User u);56 List<TransportReservation> findPastReservationByUser(User user); 62 57 63 List<TransportReservation> findPastReservationByUser(User user); 58 @Transactional 59 void saveReservation(TransportReservation transportReservation); 60 61 List<TransportReservation> findReservationByUser(User user); 62 63 @Transactional 64 void deleteTransportReservation(TransportReservation tr); 65 66 @Transactional 67 void deleteTransportAvailable(TransportAvailible ta); 68 69 void createTransportRoute(TransportRoute tr); 70 71 void deleteTransportRoute(TransportRoute tr); 72 73 void editTransportRoute(TransportRoute tr); 74 75 List<TransportReservation> findTransportReservationByTransportId(Transport t); 76 77 // public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, Long userId, String carPlate); 78 // 79 // public void deleteTransport(long transportId); 80 // 81 // public void editTransport(long transportID, String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate); 82 // 83 // public List<Transport> getTransports(); 84 // public List<TransportDto> getTransportsByUser(long userId); 85 // 86 // public List<RouteListingDto> getRoutesForTransport(long transportId); 87 // public Transport getTransportById(long transportId); 88 // public TransportDto findTransportById (long transportId); 89 // 90 // public void createTransportReservation(TransportReservation transportReservation); 91 // 92 // public void editTransportReservation(Transport transport, long reservationID, String departureLocation, String arrivalLocation, Date date, Integer noSeats, User user, Date departureHour); 93 // 94 // public void deleteTransportReservation(long reservationID); 95 // 96 // public TransportReservation findTransportReservationByID(long reservationID); 97 // 98 // public List<TransportReservation> getTransportReservations(); 99 // 100 // public List<TransportReservation> getTransportsReservationsByUserID(long userID); 101 // 102 // public void createTransportAvailable(Transport transport, String departureLocation, String arrivalLocation, Date date, Integer noSeats, Date departureHour, Collection<TransportRoute> routes); 103 // 104 // public void editTransportAvailable(Transport transport, long availableID, String departureLocation, String arrivalLocation, Date date, Integer noSeats, Date departureHour); 105 // 106 // public void deleteTransportAvailable(long availableID); 107 // 108 // public TransportAvailible findTransportAvailableByID (long reservationID); 109 // 110 // public List<TransportAvailible> getTransportsAvailable(); 111 // 112 // public List<TransportRoute> getTransportsAvailableByFilters (String from, String to, Date date, int numPassengers); 113 // 114 // public void createTransportRoute(TransportAvailible parentRoute, String from, String to, double price, Date departure, Date arrival, int freeSpace, int order); 115 // 116 // public void deleteTransportRoute(long transportRouteId); 117 // 118 // public void editTransportRoute(long transportRouteId, TransportAvailible parentRoute, String from, String to, double price, Date departure, Date arrival, int freeSpace, int order); 119 // 120 // public TransportRoute findTransportRouteById(long transportRouteId); 121 // 122 // List<Reviews> getReviewsForTransport(Transport transport); 123 // 124 // List<TransportReservation> findReservationByUser(User u); 125 // 126 // List<TransportReservation> findPastReservationByUser(User user); 127 // 128 // void saveReservation(TransportReservation transportReservation); 64 129 } -
src/main/java/com/tourMate/dao/UsersDao.java
r5528b99 r07f4e8b 23 23 24 24 UserDetails findUserByUsername(String username); 25 26 List<User> getUnapprovedUsers(); 27 28 void approveUserProfile(User u); 29 30 Role findById(Long id); 31 void updateUser(User s); 25 32 } -
src/main/java/com/tourMate/dao/impl/BusinessDaoImpl.java
r5528b99 r07f4e8b 19 19 @Transactional 20 20 @Override 21 public void createBusiness(Business business, long userId) { 22 User u = em.find(User.class, userId); 23 business.setUser(u); 21 public void createBusiness(Business business) { 24 22 em.persist(business); 25 23 } 26 24 27 25 @Override 28 public List<Business> getUnapprovedBusinessesOfUser(long userId) { 29 User u = em.find(User.class, userId); 26 public List<Business> getUnapprovedBusinessesOfUser(User u) { 30 27 return em.createQuery("SELECT b FROM Business b WHERE b.user = :user").setParameter("user", u).getResultList(); 31 28 } … … 33 30 @Transactional 34 31 @Override 35 public void deleteBusiness(long businessId) { 36 Business business = findBusinessById(businessId); 32 public void deleteBusiness(Business business) { 37 33 em.remove(business); 38 39 34 } 40 35 41 36 @Override 42 public boolean hasBusiness( long userId)37 public boolean hasBusiness(User u) 43 38 { 44 User u = em.find(User.class, userId);45 39 return Integer.parseInt(em.createQuery("SELECT COUNT(b) FROM Business b WHERE b.user = :user").setParameter("user", u).getSingleResult().toString()) > 0; 40 } 41 42 @Override 43 public List<Business> getUnapprovedBusinesses() { 44 return em.createQuery("select b from Business b where not b.approved").getResultList(); 45 } 46 47 @Override 48 @Transactional 49 public void approveBusiness(Business b) { 50 em.persist(b); 46 51 } 47 52 … … 57 62 } 58 63 64 59 65 @Transactional 60 66 @Override 61 public void editBusiness(long businessId, String name, String phone, String address, String edbs, User user, boolean approved) { 62 Business business = findBusinessById(businessId); 63 business.setName(name); 64 business.setPhone(phone); 65 business.setAddress(address); 66 business.setEdbs(edbs); 67 business.setUser(user); 68 business.setApproved(approved); 67 public void editBusiness(Business business) { 69 68 em.persist(business); 70 69 } -
src/main/java/com/tourMate/dao/impl/HotelDaoImpl.java
r5528b99 r07f4e8b 8 8 import org.springframework.stereotype.Service; 9 9 10 import java.util.Calendar; 10 11 import java.util.Date; 11 12 import java.util.List; … … 19 20 @Override 20 21 @Transactional 21 public void createHotel(Hotels hotel, long userId) { 22 User u = em.find(User.class, userId); 23 Hotels h = new Hotels(hotel.getHotelName(), hotel.getHotelDescripiton(), hotel.getHotelLocation(), hotel.getHotelEDBS(), hotel.getParking(), hotel.getPetFriendly(), hotel.getInternetAvailable(), u); 24 em.persist(h); 22 public void createHotel(Hotels hotel) { 23 em.persist(hotel); 25 24 } 26 25 27 26 @Override 28 27 public List<Hotels> getHotels() { 29 List<Hotels> hoteli = em.createQuery("select h from Hotels h order by h.hotelId").getResultList(); 30 System.out.println("OREEEEEEL"); 31 return hoteli; 32 //return em.createQuery("select h from Hotels h order by h.hotelId").getResultList(); 33 } 34 35 @Override 36 public List<Hotels> getHotelsForUser(long userId) { 37 User u = em.find(User.class, userId); 28 return em.createQuery("select h from Hotels h order by h.hotelId").getResultList(); 29 } 30 31 @Override 32 public List<Hotels> getHotelsForUser(User u) { 38 33 return em.createQuery("select h from Hotels h where h.owner = :u").setParameter("u", u).getResultList(); 39 34 } … … 46 41 @Transactional 47 42 @Override 48 public void editHotel(long hotelId, String hotelName, String hotelDescripiton, String hotelLocation, String hotelEDBS, Boolean parking, Boolean petFriendly, Boolean internetAvailable) { 49 Hotels hotel = findHotelByID(hotelId); 50 hotel.setHotelName(hotelName); 51 hotel.setHotelDescripiton(hotelDescripiton); 52 hotel.setHotelLocation(hotelLocation); 53 hotel.setHotelEDBS(hotelEDBS); 54 hotel.setParking(parking); 55 hotel.setPetFriendly(petFriendly); 56 hotel.setInternetAvailable(internetAvailable); 43 public void editHotel(Hotels hotel) { 57 44 em.persist(hotel); 58 45 } … … 60 47 @Transactional 61 48 @Override 62 public void deleteHotel(long hotelId) { 63 Hotels h = findHotelByID(hotelId); 64 em.remove(h); 49 public void deleteHotel(Hotels hotel) { 50 em.remove(hotel); 65 51 } 66 52 … … 89 75 @Override 90 76 @Transactional 77 public void saveReservation(HotelRoomReservations hotelRoomReservations) { 78 em.persist(hotelRoomReservations); 79 } 80 81 @Override 82 @Transactional 91 83 public HotelsImages findHotelImageById(long hotelImageId) { 92 84 return em.find(HotelsImages.class, hotelImageId); … … 95 87 @Override 96 88 @Transactional 97 public void deleteHotelImage(long hotelImageId) { 98 HotelsImages hotelsImages = findHotelImageById(hotelImageId); 89 public void deleteHotelImage(HotelsImages hotelsImages) { 99 90 em.remove(hotelsImages); 100 91 } 101 92 102 93 @Override 103 public List<HotelRoom> getRoomsOfHotel(long hotelId) { 104 Hotels h = findHotelByID(hotelId); 105 return em.createQuery("SELECT hr from HotelRoom hr where hr.hotel = :hotel").setParameter("hotel", h).getResultList(); 94 public List<HotelRoom> getRoomsOfHotel(Hotels hotel) { 95 return em.createQuery("SELECT hr from HotelRoom hr where hr.hotel = :hotel").setParameter("hotel", hotel).getResultList(); 106 96 } 107 97 … … 123 113 @Transactional 124 114 @Override 125 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price) { 126 HotelRoom hotelRoom = new HotelRoom(hotel, hotelRoomDescription, hotelRoomName, kitchenAvailable, airConditioning, balcony, price); 115 public void createRoom(HotelRoom hotelRoom) { 127 116 em.persist(hotelRoom); 128 117 } … … 130 119 @Transactional 131 120 @Override 132 public void editRoom(long hotelRoomId, Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price) { 133 HotelRoom hr = findRoomById(hotelRoomId); 134 hr.setHotel(hotel); 135 hr.setHotelRoomDescription(hotelRoomDescription); 136 hr.setHotelRoomName(hotelRoomName); 137 hr.setKitchenAvailable(kitchenAvailable); 138 hr.setAirConditioning(airConditioning); 139 hr.setBalcony(balcony); 140 hr.setPrice(price); 121 public void editRoom(HotelRoom hr) { 141 122 em.persist(hr); 142 123 } … … 144 125 @Transactional 145 126 @Override 146 public void deleteRoom(long hotelRoomId) { 147 HotelRoom hr = findRoomById(hotelRoomId); 127 public void deleteRoom(HotelRoom hr) { 148 128 em.remove(hr); 149 129 } … … 151 131 @Transactional 152 132 @Override 153 public void createRoomAvailible(HotelRoom hotelRoom, Date dateFrom, Date dateTo, int numberOfBeds) { 154 HotelRoomAvailable hra = new HotelRoomAvailable(hotelRoom, dateFrom, dateTo, numberOfBeds); 133 public void createRoomAvailible(HotelRoomAvailable hra) { 155 134 em.persist(hra); 156 135 } … … 158 137 @Transactional 159 138 @Override 160 public void editRoomAvailible(long hotelRoomAvailableId, HotelRoom hotelRoom, Date dateFrom, Date dateTo, int numberOfBeds) { 161 HotelRoomAvailable hr = findAvailibleRoomById(hotelRoomAvailableId); 162 hr.setHotelRoom(hotelRoom); 163 hr.setDateFrom(dateFrom); 164 hr.setDateTo(dateTo); 165 hr.setNumberOfBeds(numberOfBeds); 139 public void editRoomAvailible(HotelRoomAvailable hr) { 166 140 em.persist(hr); 167 141 } … … 169 143 @Transactional 170 144 @Override 171 public void deleteRoomAvailible(long hotelRoomAvailableId) { 172 HotelRoomAvailable hra = findAvailibleRoomById(hotelRoomAvailableId); 145 public void deleteRoomAvailible(HotelRoomAvailable hra) { 173 146 em.remove(hra); 174 147 } … … 190 163 191 164 @Override 192 public List<HotelRoomAvailable> getRoomsAvailibilityByDateAndLocation(String hotelLocation, Date dateFrom, Date dateTo, int numberOfBeds) { 193 return em.createQuery("select hr from HotelRoomAvailable hr where hr.dateFrom <= :dateFrom and hr.dateTo >= :dateTo " + 194 <<<<<<< HEAD 195 "and hr.hotelRoom.hotel.hotelLocation LIKE :hotelLocation and hr.hotelRoom.numOfBeds >= :numBeds") 196 ======= 197 "and hr.hotelRoom.hotel.hotelLocation LIKE :hotelLocation and hr.numberOfBeds >= :numBeds") 198 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl) 199 .setParameter("hotelLocation", hotelLocation) 200 .setParameter("dateFrom", dateFrom) 201 .setParameter("dateTo", dateTo) 202 .setParameter("numBeds", numberOfBeds) 203 .getResultList(); 204 } 205 206 @Override 207 @Transactional 208 public void createReservation(User user, HotelRoom hotelRoom, Date dateFrom, Date dateTo, Integer numberOfBeds) { 209 HotelRoomReservations r = new HotelRoomReservations(user, hotelRoom, dateFrom, dateTo, numberOfBeds); 165 public List<HotelRoomAvailable> getRoomsAvailibilityByDateAndLocation(String hotelLocation, Date dateFrom, Date dateTo, int numberOfBeds, Boolean flexible) { 166 if(flexible) 167 { 168 Calendar calendar = Calendar.getInstance(); 169 Calendar calendar1 = Calendar.getInstance(); 170 calendar.setTime(dateTo); 171 calendar1.setTime(dateFrom); 172 return em.createQuery("SELECT hr FROM HotelRoomAvailable hr WHERE " + 173 "((hr.dateFrom <= :dateTo AND hr.dateTo >= :dateFrom) OR " + 174 "(hr.dateFrom <= :dateToMinus1 AND hr.dateTo >= :dateFromMinus1) OR " + 175 "(hr.dateFrom <= :dateToMinus2 AND hr.dateTo >= :dateFromMinus2) OR " + 176 "(hr.dateFrom <= :dateToMinus3 AND hr.dateTo >= :dateFromMinus3) OR " + 177 "(hr.dateFrom <= :dateToPlus1 AND hr.dateTo >= :dateFromPlus1) OR " + 178 "(hr.dateFrom <= :dateToPlus2 AND hr.dateTo >= :dateFromPlus2) OR " + 179 "(hr.dateFrom <= :dateToPlus3 AND hr.dateTo >= :dateFromPlus3)) " + 180 "AND hr.hotelRoom.hotel.hotelLocation LIKE :hotelLocation " + 181 "AND hr.hotelRoom.numOfBeds >= :numBeds") 182 .setParameter("hotelLocation", hotelLocation) 183 .setParameter("dateFrom", dateFrom) 184 .setParameter("dateTo", dateTo) 185 .setParameter("dateToMinus1", subtractDays(calendar, 1)) 186 .setParameter("dateToMinus2", subtractDays(calendar, 2)) 187 .setParameter("dateToMinus3", subtractDays(calendar, 3)) 188 .setParameter("dateToPlus1", addDays(calendar, 1)) 189 .setParameter("dateToPlus2", addDays(calendar, 2)) 190 .setParameter("dateToPlus3", addDays(calendar, 3)) 191 .setParameter("dateFromMinus1", subtractDays(calendar1, 1)) 192 .setParameter("dateFromMinus2", subtractDays(calendar1, 2)) 193 .setParameter("dateFromMinus3", subtractDays(calendar1, 3)) 194 .setParameter("dateFromPlus1", addDays(calendar1, 1)) 195 .setParameter("dateFromPlus2", addDays(calendar1, 2)) 196 .setParameter("dateFromPlus3", addDays(calendar1, 3)) 197 .setParameter("numBeds", numberOfBeds) 198 .getResultList(); 199 } 200 else 201 { 202 return em.createQuery("SELECT hr FROM HotelRoomAvailable hr WHERE " + 203 "((hr.dateFrom <= :dateTo AND hr.dateTo >= :dateFrom)) " + 204 "AND hr.hotelRoom.hotel.hotelLocation LIKE :hotelLocation " + 205 "AND hr.hotelRoom.numOfBeds >= :numBeds") 206 .setParameter("hotelLocation", hotelLocation) 207 .setParameter("dateFrom", dateFrom) 208 .setParameter("dateTo", dateTo) 209 .setParameter("numBeds", numberOfBeds) 210 .getResultList(); 211 } 212 213 214 215 216 } 217 218 private Date addDays(Calendar calendar, int days) { 219 Calendar newCalendar = (Calendar) calendar.clone(); 220 newCalendar.add(Calendar.DAY_OF_MONTH, days); 221 return newCalendar.getTime(); 222 } 223 224 private Date subtractDays(Calendar calendar, int days) { 225 Calendar newCalendar = (Calendar) calendar.clone(); 226 newCalendar.add(Calendar.DAY_OF_MONTH, -days); 227 return newCalendar.getTime(); 228 } 229 230 @Override 231 @Transactional 232 public void createReservation(HotelRoomReservations r) { 210 233 em.persist(r); 211 234 } … … 213 236 @Override 214 237 @Transactional 215 public void editReservation(long hotelRoomReservedId, User user, HotelRoom hotelRoom, Date dateFrom, Date dateTo, Integer numberOfBeds) { 216 HotelRoomReservations hr = findReservationById(hotelRoomReservedId); 217 hr.setUser(user); 218 hr.setHotelRoom(hotelRoom); 219 hr.setDateFrom(dateFrom); 220 hr.setDateTo(dateTo); 221 hr.setNumberOfBeds(numberOfBeds); 238 public void editReservation(HotelRoomReservations hr) { 222 239 em.persist(hr); 223 224 } 225 226 @Transactional 227 @Override 228 public void deleteReservation(long hotelRoomReservedId) { 229 HotelRoomReservations r = findReservationById(hotelRoomReservedId); 230 em.remove(hotelRoomReservedId); 240 } 241 242 @Transactional 243 @Override 244 public void deleteReservation(HotelRoomReservations hr) { 245 246 em.remove(hr); 231 247 } 232 248 … … 244 260 @Override 245 261 public List<HotelRoomReservations> findReservationByHotel(Hotels hotel) { 246 List<HotelRoom> hotelRooms = getRoomsOfHotel(hotel .getHotelId());247 return em.createQuery("select hr from HotelRoomReservations hr where hr.hotelRoom in :hotelRooms").setParameter("hotelRooms", hotelRooms).getResultList();262 List<HotelRoom> hotelRooms = getRoomsOfHotel(hotel); 263 return em.createQuery("select hr from HotelRoomReservations hr where hr.hotelRoom.hotel = :hotel").setParameter("hotel", hotel).getResultList(); 248 264 } 249 265 -
src/main/java/com/tourMate/dao/impl/MenuDaoImpl.java
r5528b99 r07f4e8b 18 18 @Transactional 19 19 @Override 20 public void createMenu(String name, String ingredients, double price) { 21 Menu menu = new Menu(name, ingredients, price); 20 public void createMenu(Menu menu) { 22 21 em.persist(menu); 23 22 } … … 25 24 @Transactional 26 25 @Override 27 public void deleteMenu(long menuId) { 28 Menu menu = findMenuById(menuId); 26 public void deleteMenu(Menu menu) { 29 27 em.remove(menu); 30 28 } … … 42 40 @Transactional 43 41 @Override 44 public void editMenu(long menuId, String name, String ingredients, double price) { 45 Menu menu = findMenuById(menuId); 46 menu.setName(name); 47 menu.setIngredients(ingredients); 48 menu.setPrice(price); 42 public void editMenu(Menu menu) { 43 49 44 em.persist(menu); 50 45 } -
src/main/java/com/tourMate/dao/impl/RestaurantDaoImpl.java
r5528b99 r07f4e8b 18 18 @Override 19 19 @Transactional 20 public void createRestaurant(Restaurant restaurant, long userId) { 21 User u = em.find(User.class, userId); 22 Restaurant r = new Restaurant(restaurant.getRestaurantName(), restaurant.getRestaurantLocation(), restaurant.getCousineType(), restaurant.getRestaurantDescription(), restaurant.getRestaurantEdbs(), u); 23 em.persist(r); 20 public void createRestaurant(Restaurant restaurant) { 21 em.persist(restaurant); 24 22 } 25 23 … … 43 41 @Transactional 44 42 @Override 45 public void removeRestaurantImage(long restaurantImageId){ 46 RestaurantImages restaurantImage = findRestaurantImageById(restaurantImageId); 47 em.remove(restaurantImage); 43 public void removeRestaurantImage(RestaurantImages image){ 44 em.remove(image); 48 45 } 49 46 … … 55 52 56 53 @Override 57 public void deleteRestaurant(long restaurantID) { 58 Restaurant r = findRestaurantByID(restaurantID); 54 public void deleteRestaurant(Restaurant r) { 59 55 em.remove(r); 60 56 } … … 67 63 @Override 68 64 @Transactional 69 public void addMenuToRestaurant(long restaurantId, Menu menu) { 70 Restaurant r = findRestaurantByID(restaurantId); 71 menu.setRestaurant(r); 65 public void addMenuToRestaurant(Menu menu) { 72 66 em.persist(menu); 73 67 } … … 84 78 85 79 @Override 86 @Transactional87 public void editRestaurant(long restaurantID, String restaurantName, String restaurantLocation, String cousineType, String restaurantDescription, String restaurantEdbs, User restaurantOwner) {88 Restaurant res = findRestaurantByID(restaurantID);89 res.setRestaurantName(restaurantName);90 res.setRestaurantLocation(restaurantLocation);91 res.setRestaurantEdbs(restaurantEdbs);92 res.setRestaurantDescription(restaurantDescription);93 res.setRestaurantOwner(restaurantOwner);94 res.setCousineType(cousineType);95 em.persist(res);96 }97 98 @Override99 80 public List<RestaurantsTable> getRestaurantTables(long restaurantID) { 100 List<RestaurantsTable> restaurantsTables = getRestaurantTables(restaurantID); 101 return restaurantsTables; 81 return em.createQuery("select rt from RestaurantsTable rt where rt.restaurant.restaurantID = :restaurantId").setParameter("restaurantId", restaurantID).getResultList(); 102 82 } 103 83 … … 109 89 @Override 110 90 @Transactional 111 public void createTable(Restaurant restaurant, int noSeats) { 112 RestaurantsTable resTable = new RestaurantsTable(restaurant, noSeats); 91 public void saveTable(RestaurantsTable resTable) { 113 92 em.persist(resTable); 114 93 } 115 94 116 @Override 117 @Transactional 118 public void editTable(Restaurant restaurant, long tableId, int noSeats) { 119 RestaurantsTable resTable = findTableById(tableId); 120 resTable.setRestaurant(restaurant); 121 resTable.setNoSeats(noSeats); 122 em.persist(resTable); 123 } 124 125 @Override 126 @Transactional 127 public void deleteTable(long tableId) { 128 RestaurantsTable rt = findTableById(tableId); 95 96 @Override 97 @Transactional 98 public void deleteTable(RestaurantsTable rt) { 129 99 em.persist(rt); 130 100 } 131 101 132 102 @Override 133 public List<Restaurant> getRestaurantsByUser(long userId) { 134 User u = em.find(User.class, userId); 103 public List<Restaurant> getRestaurantsByUser(User u) { 135 104 return em.createQuery("select r from Restaurant r where r.restaurantOwner = :u").setParameter("u", u).getResultList(); 136 }137 138 @Override139 @Transactional140 public void createTableAvailable(RestaurantsTable restaurantsTable, Date hourFrom, Date hourTo, int noSeats) {141 RestaurantsAvailible ra = new RestaurantsAvailible(restaurantsTable, hourFrom, hourTo, noSeats);142 em.persist(ra);143 105 } 144 106 … … 151 113 @Override 152 114 @Transactional 153 public void createTableAvailable(RestaurantsTable restaurantsTable, Date hourFrom, Date hourTo){ 154 RestaurantsAvailible rta = new RestaurantsAvailible(restaurantsTable, hourFrom, hourTo); 155 em.persist(rta); 156 } 157 158 @Override 159 @Transactional 160 public void editTableAvailable(long tableId, Restaurant restaurant, int noSeats) { 161 RestaurantsTable rt = findTableById(tableId); 162 rt.setRestaurant(restaurant); 163 rt.setNoSeats(noSeats); 164 em.persist(rt); 165 } 166 167 @Override 168 @Transactional 169 public void deleteTableAvailable(long tableId) { 170 RestaurantsAvailible ra = findAvailableReservationByID(tableId); 115 public void saveTableAvailable(RestaurantsAvailible ra){ 116 em.persist(ra); 117 } 118 119 @Override 120 @Transactional 121 public void deleteTableAvailable(RestaurantsAvailible ra) { 171 122 em.remove(ra); 172 123 } … … 183 134 } 184 135 185 @Override 186 @Transactional 187 public void editReservation(long restaurantsTableId, RestaurantsTable rt, Date hourFrom, Date hourTo, int noSeats, User user) { 188 RestaurantReservations r = findReservationByID(restaurantsTableId); 189 r.setTable(rt); 190 r.setTimeFrom(hourFrom); 191 r.setTimeTo(hourTo); 192 r.setNoSeats(noSeats); 193 r.setUser(user); 194 em.persist(r); 195 } 196 197 @Override 198 @Transactional 199 public void deleteReservation(long restaurantsTableId) { 200 RestaurantReservations r = findReservationByID(restaurantsTableId); 136 137 @Override 138 @Transactional 139 public void deleteReservation(RestaurantReservations r) { 201 140 em.remove(r); 202 141 } … … 259 198 260 199 } 200 201 @Override 202 public List<MenuImages> getMenuImages(long menuId) { 203 return em.createQuery("select ri from MenuImages ri where ri.menu.id = :menuId").setParameter("menuId", menuId).getResultList(); 204 } 205 206 @Override 207 public List<MenuImages> getMenuImagesByRestaurant(Restaurant resta) { 208 return em.createQuery("select mi from MenuImages mi where mi.menu.restaurant = :restaurant") 209 .setParameter("restaurant", resta) 210 .getResultList(); 211 } 212 213 @Transactional 214 @Override 215 public void addMenuImage(MenuImages menuImages) { 216 em.persist(menuImages); 217 } 218 219 @Override 220 public Menu findMenuId(Long menuId) { 221 return em.find(Menu.class, menuId); 222 } 223 224 @Override 225 @Transactional 226 public void saveReservation(RestaurantReservations restaurantReservations) { 227 em.persist(restaurantReservations); 228 } 261 229 } -
src/main/java/com/tourMate/dao/impl/ReviewDaoImpl.java
r5528b99 r07f4e8b 25 25 26 26 @Override 27 public void deleteReview(long id) { 28 Reviews review = findReviewById(id); 27 public void deleteReview(Reviews review) { 29 28 em.remove(review); 30 29 } … … 36 35 37 36 @Override 38 public void editReview(long id, String title, String description, int numStar, Hotels hotel, Restaurant restaurant, Transport transport) { 39 Reviews review = findReviewById(id); 40 review.setDescription(description); 41 review.setHotel(hotel); 42 review.setRestaurant(restaurant); 43 review.setTitle(title); 44 review.setNumStar(numStar); 45 review.setTransport(transport); 37 public void editReview(Reviews review) { 46 38 em.persist(review); 47 39 } -
src/main/java/com/tourMate/dao/impl/TransportDaoImpl.java
r5528b99 r07f4e8b 10 10 import org.springframework.stereotype.Service; 11 11 12 import java.util.Collection;13 12 import java.util.Date; 14 13 import java.util.List; … … 22 21 @Override 23 22 @Transactional 24 public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate) { 25 User u = em.find(User.class, 1); 26 Transport t=new Transport(transportName,carBrand,carType,carManufacturedYear,noPassengers,noBags,EMBG,u,carPlate); 23 public void createTransport(Transport t) { 27 24 em.persist(t); 28 25 } … … 30 27 @Override 31 28 @Transactional 32 public void deleteTransport(long transportId) { 33 Transport t=getTransportById(transportId); 29 public void deleteTransport(Transport t) { 34 30 em.remove(t); 35 31 } … … 41 37 42 38 @Override 43 public List<TransportDto> getTransportsByUser(long userId) { 44 User u = em.find(User.class, userId); 39 public List<TransportDto> getTransportsByUser(User u) { 45 40 List<Transport> transports = em.createQuery("select t from Transport t where t.owner = :u").setParameter("u", u).getResultList(); 46 41 return transports.stream().map(x -> new TransportDto( … … 62 57 y.getFreeSpace(), 63 58 y.getTime(), 64 y.getRoutes() 65 )).toList() 59 y.getRoutes(), 60 y.getRoutes().stream() 61 .mapToDouble(TransportRoute::getPrice) 62 .max().orElse(0) 63 )).toList(), 64 x.getAvailableRoutes().stream() 65 .flatMapToDouble(y -> y.getRoutes() 66 .stream() 67 .mapToDouble(TransportRoute::getPrice)).max().orElseGet(() -> 0) 66 68 )).toList(); 67 69 } 68 70 69 71 @Override 70 public List<RouteListingDto> getRoutesForTransport(long transportId) { 71 Transport t = em.find(Transport.class, transportId); 72 public List<RouteListingDto> getRoutesForTransport(Transport t) { 72 73 List<TransportAvailible> transportsAvailible = em.createQuery("select ta from TransportAvailible ta where ta.transport = :transport").setParameter("transport", t).getResultList(); 73 74 return transportsAvailible.stream().map(x -> new RouteListingDto( … … 78 79 x.getFreeSpace(), 79 80 x.getTime(), 80 x.getRoutes() 81 x.getRoutes(), 82 x.getRoutes().stream() 83 .mapToDouble(TransportRoute::getPrice) 84 .max().orElse(0) 81 85 )).toList(); 82 86 } … … 103 107 y.getFreeSpace(), 104 108 y.getTime(), 105 y.getRoutes() 106 )).toList()); 107 } 108 109 y.getRoutes(), 110 y.getRoutes().stream() 111 .mapToDouble(TransportRoute::getPrice) 112 .max().orElse(0) 113 )).toList(), 114 x.getAvailableRoutes().stream() 115 .flatMapToDouble(y -> y.getRoutes() 116 .stream() 117 .mapToDouble(TransportRoute::getPrice)).max().orElseGet(() -> 0)); 118 } 119 120 @Override 109 121 public Transport getTransportById(long transportId) 110 122 { … … 114 126 @Override 115 127 @Transactional 116 public void editTransport(long transportID, String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate) { 117 Transport t=getTransportById(transportID); 118 t.setTransportName(transportName); 119 t.setCarBrand(carBrand); 120 t.setCarType(carType); 121 t.setCarManufacturedYear(carManufacturedYear); 122 t.setNoPassengers(noPassengers); 123 t.setNoBags(noBags); 124 t.setEMBG(EMBG); 125 t.setOwner(owner); 126 t.setCarPlate(carPlate); 128 public void editTransport(Transport t) { 127 129 em.persist(t); 128 130 } … … 150 152 151 153 @Override 152 public List<TransportRoute> getTransportsAvailableByFilters(String fromL, String toL, Date date ) {154 public List<TransportRoute> getTransportsAvailableByFilters(String fromL, String toL, Date date, int numPassengers) { 153 155 System.out.println(fromL + " " + toL); 154 return em.createQuery("select h from TransportRoute h where h.from = :froml and h.to = :tol").setParameter("froml", fromL). 155 setParameter("tol", toL).getResultList(); 156 return em.createQuery("select h from TransportRoute h where h.from = :froml and h.to = :tol and h.freeSpace >= :nump") 157 .setParameter("froml", fromL) 158 .setParameter("tol", toL) 159 .setParameter("nump", numPassengers) 160 .getResultList(); 156 161 } 157 162 … … 168 173 @Override 169 174 @Transactional 170 public void createTransportAvailable(Transport transport, String departureLocation, String arrivalLocation, Date date, Integer noSeats, Date departureHour, Collection<TransportRoute> routes) { 171 TransportAvailible ta=new TransportAvailible(transport,departureLocation,arrivalLocation,date,noSeats,departureHour); 175 public void createTransportAvailable(TransportAvailible ta) { 172 176 em.persist(ta); 173 List<TransportRoute> routes1 = routes.stream().toList(); 174 routes.forEach(x -> { 175 createTransportRoute(ta, x.getFrom(), x.getTo(), x.getPrice(), x.getDeparture(), x.getArrival(), x.getFreeSpace(), x.getOrder()); 176 }); 177 } 178 179 @Override 180 @Transactional 181 public void editTransportReservation(Transport transport, long reservationID, String departureLocation, String arrivalLocation, Date date, Integer noSeats, User user, Date departureHour) 182 { 183 // TransportReservation tr=findTransportReservationByID(reservationID); 184 // tr.setTransport(transport); 185 // tr.setDepartureLocation(departureLocation); 186 // tr.setArrivalLocation(arrivalLocation); 187 // tr.setDate(date); 188 // tr.setNoSeats(noSeats); 189 // tr.setUser(user); 190 // tr.setDepartureHour(departureHour); 191 // em.persist(tr); 192 } 193 194 @Override 195 public void editTransportAvailable(Transport transport, long availableID, String departureLocation, String arrivalLocation, Date date, Integer noSeats, Date departureHour) { 196 TransportAvailible ta=findTransportAvailableByID(availableID); 197 ta.setTransport(transport); 198 ta.setFrom(departureLocation); 199 ta.setTo(arrivalLocation); 200 ta.setDate(date); 201 ta.setFreeSpace(noSeats); 202 ta.setTime(departureHour); 177 178 } 179 180 @Override 181 public void editTransportAvailable(TransportAvailible ta) { 203 182 em.persist(ta); 204 183 } … … 224 203 } 225 204 205 @Transactional 206 @Override 207 public void saveReservation(TransportReservation transportReservation) { 208 em.persist(transportReservation); 209 } 210 226 211 @Override 227 212 public List<TransportReservation> findReservationByUser(User user) { … … 235 220 @Override 236 221 @Transactional 237 public void deleteTransportReservation(long reservationID) { 238 TransportReservation tr=findTransportReservationByID(reservationID); 222 public void deleteTransportReservation(TransportReservation tr) { 239 223 em.remove(tr); 240 224 } … … 242 226 @Override 243 227 @Transactional 244 public void deleteTransportAvailable(long availableID) { 245 TransportAvailible ta=findTransportAvailableByID(availableID); 228 public void deleteTransportAvailable(TransportAvailible ta) { 246 229 em.remove(ta); 247 230 } 248 231 249 232 @Override 250 public void createTransportRoute(TransportAvailible parentRoute, String from, String to, double price, Date departure, Date arrival, int freeSpace, int order) {251 TransportRoute tr = new TransportRoute(parentRoute, from, to, price, departure, arrival, freeSpace, order);233 @Transactional 234 public void createTransportRoute(TransportRoute tr) { 252 235 em.persist(tr); 253 236 } 254 237 255 238 @Override 256 public void deleteTransportRoute(long transportRouteId) { 257 TransportRoute tr = findTransportRouteById(transportRouteId); 239 public void deleteTransportRoute(TransportRoute tr) { 258 240 em.remove(tr); 259 241 } 260 242 261 243 @Override 262 public void editTransportRoute(long transportRouteId, TransportAvailible parentRoute, String from, String to, double price, Date departure, Date arrival, int freeSpace, int order) { 263 TransportRoute tr = findTransportRouteById(transportRouteId); 264 tr.setParentRoute(parentRoute); 265 tr.setFrom(from); 266 tr.setTo(to); 267 tr.setPrice(price); 268 tr.setDeparture(departure); 269 tr.setArrival(arrival); 270 tr.setFreeSpace(freeSpace); 271 tr.setOrder(order); 244 public void editTransportRoute(TransportRoute tr) { 272 245 em.persist(tr); 273 246 274 247 } 275 248 249 @Override 250 public List<TransportReservation> findTransportReservationByTransportId(Transport t) { 251 return em.createQuery("SELECT tr from TransportReservation tr where tr.transportRoute.parentRoute.transport= :transport") 252 .setParameter("transport", t) 253 .getResultList(); 254 } 255 276 256 277 257 } -
src/main/java/com/tourMate/dao/impl/UsersDaoImpl.java
r5528b99 r07f4e8b 28 28 @Override 29 29 public void createUser(String name, String surname, String email, Date birthDate, String address, String contact) { 30 Role r = em.find(Role.class, 1);30 Role r = em.find(Role.class, 2); 31 31 User user = new User(name, surname, email, passwordEncoder.encode("password"), birthDate, address, contact, r); 32 32 em.persist(user); … … 74 74 } 75 75 76 @Override 77 public List<User> getUnapprovedUsers() { 78 return em.createQuery("select u from User u where not u.enabled").getResultList(); 79 } 80 81 @Override 82 @Transactional 83 public void approveUserProfile(User u) { 84 u.setEnabled(true); 85 em.persist(u); 86 } 87 88 @Override 89 public Role findById(Long id) { 90 return em.find(Role.class, id); 91 } 92 93 @Override 94 @Transactional 95 public void updateUser(User s) { 96 em.persist(s); 97 } 76 98 77 99 -
src/main/java/com/tourMate/dto/HotelReservationUserDto.java
r5528b99 r07f4e8b 7 7 8 8 public class HotelReservationUserDto { 9 private Long reservationId; 9 10 private User user; 10 11 private HotelRoom hotelRoom; … … 20 21 private Boolean reviewed; 21 22 22 public HotelReservationUserDto(User user, HotelRoom hotelRoom, Date dateFrom, Date dateTo, Integer numBeds, String hotelName, String hotelLocation, String hotelAddress, Long hotelId, Boolean reviewed) { 23 public HotelReservationUserDto(Long reservationId, User user, HotelRoom hotelRoom, Date dateFrom, Date dateTo, Integer numBeds, String hotelName, String hotelLocation, String hotelAddress, Long hotelId, Boolean reviewed) { 24 this.reservationId = reservationId; 23 25 this.user = user; 24 26 this.hotelRoom = hotelRoom; … … 31 33 this.hotelId = hotelId; 32 34 this.reviewed = reviewed; 35 } 36 37 public Long getReservationId() { 38 return reservationId; 33 39 } 34 40 -
src/main/java/com/tourMate/dto/RestaurantDto.java
r5528b99 r07f4e8b 5 5 import java.util.ArrayList; 6 6 import java.util.Collection; 7 import java.util.List; 7 8 8 9 public class RestaurantDto { … … 14 15 private String restaurantEdbs; 15 16 private Collection<Menu> menus = new ArrayList<Menu>(); 17 private Collection<MenuImages> menuImages; 16 18 private Collection<RestaurantsAvailible> tables; 17 19 private Collection<Reviews> reviews; 18 20 private double averageScore; 19 21 private Collection<RestaurantImages> images; 20 public RestaurantDto(long restaurantID, String restaurantName, String restaurantLocation, String cousineType, String restaurantDescription, String restaurantEdbs, Collection<Menu> menus, Collection<RestaurantsAvailible> tables, Collection<Reviews> reviews, double averageScore, Collection<RestaurantImages> images) { 22 23 public RestaurantDto(long restaurantID, String restaurantName, String restaurantLocation, String cousineType, String restaurantDescription, String restaurantEdbs, Collection<Menu> menus, Collection<RestaurantsAvailible> tables, Collection<Reviews> reviews, double averageScore, Collection<RestaurantImages> images, Collection<MenuImages> menuImages) { 21 24 this.restaurantID = restaurantID; 22 25 this.restaurantName = restaurantName; … … 30 33 this.averageScore = averageScore; 31 34 this.images = images; 35 this.menuImages = menuImages; 36 } 37 public Collection<MenuImages> getMenuImages() { 38 return menuImages; 32 39 } 33 40 … … 119 126 this.images = images; 120 127 } 128 121 129 } -
src/main/java/com/tourMate/dto/RestaurantReservationUserDto.java
r5528b99 r07f4e8b 8 8 9 9 public class RestaurantReservationUserDto { 10 private Long reservationId; 10 11 private User user; 11 12 private RestaurantsTable restaurantsTable; … … 21 22 private Boolean reviewed; 22 23 23 public RestaurantReservationUserDto(User user, RestaurantsTable restaurantsTable, Date dateFrom, Date dateTo, Integer numPeople, String restaurantName, String restaurantLocation, String restaurantAddress, Long restaurantId, Boolean reviewed) { 24 public RestaurantReservationUserDto(Long reservationId, User user, RestaurantsTable restaurantsTable, Date dateFrom, Date dateTo, Integer numPeople, String restaurantName, String restaurantLocation, String restaurantAddress, Long restaurantId, Boolean reviewed) { 25 this.reservationId = reservationId; 24 26 this.user = user; 25 27 this.restaurantsTable = restaurantsTable; … … 32 34 this.restaurantId = restaurantId; 33 35 this.reviewed = reviewed; 36 } 37 38 public Long getReservationId() { 39 return reservationId; 34 40 } 35 41 -
src/main/java/com/tourMate/dto/RouteListingDto.java
r5528b99 r07f4e8b 18 18 private Date time; 19 19 private Collection<String> routes; 20 private Double maxPrice; 20 21 21 public RouteListingDto(long transportAvailibleId, String from, String to, Date date, int freeSpace, Date time, Collection<TransportRoute> routes ) {22 public RouteListingDto(long transportAvailibleId, String from, String to, Date date, int freeSpace, Date time, Collection<TransportRoute> routes, Double maxPrice) { 22 23 this.transportAvailibleId = transportAvailibleId; 23 24 this.from = from; … … 27 28 this.time = time; 28 29 this.routes = routes.stream().map(x -> x.getFrom()).distinct().skip(1).toList(); 30 this.maxPrice = maxPrice; 29 31 } 30 32 … … 84 86 this.routes = routes; 85 87 } 88 89 public Double getMaxPrice() { 90 return maxPrice; 91 } 86 92 } -
src/main/java/com/tourMate/dto/TransportDto.java
r5528b99 r07f4e8b 16 16 private User owner; 17 17 private String carPlate; 18 private Double maxPrice; 18 19 private Collection<RouteListingDto> availableRoutes; 19 20 20 public TransportDto(long transportID, String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate, Collection<RouteListingDto> availableRoutes ) {21 public TransportDto(long transportID, String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate, Collection<RouteListingDto> availableRoutes, Double maxPrice) { 21 22 this.transportID = transportID; 22 23 this.transportName = transportName; … … 30 31 this.carPlate = carPlate; 31 32 this.availableRoutes = availableRoutes; 33 this.maxPrice = maxPrice; 32 34 } 33 35 -
src/main/java/com/tourMate/dto/TransportReservationUserDto.java
r5528b99 r07f4e8b 10 10 11 11 public class TransportReservationUserDto { 12 private Long reservationId; 12 13 private User user; 13 14 private TransportRoute transportRoute; … … 19 20 private Boolean reviewed; 20 21 21 public TransportReservationUserDto(User user, TransportRoute transportRoute, Long transportId, Integer numPeople, String carBrand, String carType, User owner, Boolean reviewed) { 22 public TransportReservationUserDto(Long reservationId, User user, TransportRoute transportRoute, Long transportId, Integer numPeople, String carBrand, String carType, User owner, Boolean reviewed) { 23 this.reservationId = reservationId; 22 24 this.user = user; 23 25 this.transportRoute = transportRoute; … … 28 30 this.owner = owner; 29 31 this.reviewed = reviewed; 32 } 33 public Long getReservationId() { 34 return reservationId; 30 35 } 31 36 -
src/main/java/com/tourMate/entities/Business.java
r5528b99 r07f4e8b 88 88 } 89 89 90 @OneToOne(fetch = FetchType. LAZY)90 @OneToOne(fetch = FetchType.EAGER) 91 91 @JoinColumn(name = "owner_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_biznis_kon_korisnik")) 92 92 public User getUser() { … … 107 107 this.approved = approved; 108 108 } 109 109 110 } -
src/main/java/com/tourMate/entities/HotelRoom.java
r5528b99 r07f4e8b 1 <<<<<<< HEAD2 1 package com.tourMate.entities; 3 2 … … 160 159 } 161 160 } 162 =======163 package com.tourMate.entities;164 165 import jakarta.persistence.*;166 import com.fasterxml.jackson.annotation.JsonIgnore;167 168 import javax.validation.constraints.NotNull;169 170 @Entity171 @Table(name="hotel_rooms", schema = "public")172 public class HotelRoom {173 private long hotelRoomId;174 @JsonIgnore175 private Hotels hotel;176 private String hotelRoomDescription;177 @Enumerated(EnumType.STRING)178 private String hotelRoomName;179 private double price;180 private Boolean kitchenAvailable;181 private Boolean airConditioning;182 private Boolean balcony;183 184 public HotelRoom(long hotelRoomId, Hotels hotel, String hotelRoomDescription, String hotelRoomName, double price, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony) {185 this.hotelRoomId = hotelRoomId;186 this.hotel = hotel;187 this.hotelRoomDescription = hotelRoomDescription;188 this.hotelRoomName = hotelRoomName;189 this.price = price;190 this.kitchenAvailable = kitchenAvailable;191 this.airConditioning = airConditioning;192 this.balcony = balcony;193 }194 195 public HotelRoom(Hotels hotel, String hotelRoomDescription, String type,196 Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price) {197 this.hotel = hotel;198 this.hotelRoomDescription = hotelRoomDescription;199 this.hotelRoomName = type;200 this.kitchenAvailable = kitchenAvailable;201 this.airConditioning = airConditioning;202 this.balcony = balcony;203 this.price = price;204 }205 206 public HotelRoom(String hotelRoomDescription, String type,207 Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price) {208 this.hotel = hotel;209 this.hotelRoomDescription = hotelRoomDescription;210 this.hotelRoomName = type;211 this.kitchenAvailable = kitchenAvailable;212 this.airConditioning = airConditioning;213 this.balcony = balcony;214 this.price = price;215 }216 217 public HotelRoom() {218 219 }220 221 @Id222 @GeneratedValue(strategy = GenerationType.IDENTITY)223 @Column(name = "room_id",unique = true,nullable = false)224 public long getHotelRoomId() {225 return hotelRoomId;226 }227 228 public void setHotelRoomId(long hotelRoomId) {229 this.hotelRoomId = hotelRoomId;230 }231 232 @ManyToOne(fetch = FetchType.LAZY)233 @JoinColumn(name = "hotel_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_room_kon_hotel"))234 public Hotels getHotel() {235 return hotel;236 }237 238 public void setHotel(Hotels hotelId) {239 this.hotel = hotelId;240 }241 242 @Column(name="hotel_room_description",unique = false,nullable = false)243 @NotNull244 public String getHotelRoomDescription() {245 return hotelRoomDescription;246 }247 248 public void setHotelRoomDescription(String hotelRoomDescription) {249 this.hotelRoomDescription = hotelRoomDescription;250 }251 252 @Column(name="hotel_room_price",unique = false,nullable = false)253 @NotNull254 public double getPrice() {255 return price;256 }257 258 @Column(name="hotel_room_name",unique = false,nullable = false)259 @NotNull260 public String getHotelRoomName() {261 return hotelRoomName;262 }263 264 265 public void setHotelRoomName(String name) {266 this.hotelRoomName = name;267 }268 public void setPrice(double type) {269 this.price = type;270 }271 @Column(name="hotel_room_kitchen",unique = false,nullable = false)272 @NotNull273 public Boolean getKitchenAvailable() {274 return kitchenAvailable;275 }276 277 public void setKitchenAvailable(Boolean kitchenAvailable) {278 this.kitchenAvailable = kitchenAvailable;279 }280 @Column(name="hotel_room_ac",unique = false,nullable = false)281 @NotNull282 public Boolean getAirConditioning() {283 return airConditioning;284 }285 286 public void setAirConditioning(Boolean airConditioning) {287 this.airConditioning = airConditioning;288 }289 @Column(name="hotel_room_balcony",unique = false,nullable = false)290 @NotNull291 public Boolean getBalcony() {292 return balcony;293 }294 295 public void setBalcony(Boolean balcony) {296 this.balcony = balcony;297 }298 }299 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl) -
src/main/java/com/tourMate/entities/HotelRoomReservations.java
r5528b99 r07f4e8b 43 43 } 44 44 45 @ManyToOne(fetch = FetchType. LAZY)45 @ManyToOne(fetch = FetchType.EAGER) 46 46 @JoinColumn(name = "room_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_roomres_kon_room")) 47 47 public HotelRoom getHotelRoom() { … … 59 59 } 60 60 61 @OneToOne(fetch = FetchType. LAZY)61 @OneToOne(fetch = FetchType.EAGER) 62 62 @JoinColumn(name = "user_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_roomres_kon_user")) 63 63 public User getUser() { -
src/main/java/com/tourMate/entities/RestaurantImages.java
r5528b99 r07f4e8b 31 31 } 32 32 33 @ManyToOne(fetch = FetchType. LAZY)33 @ManyToOne(fetch = FetchType.EAGER) 34 34 @JoinColumn(name="restaurant_id",unique = false,nullable = false,foreignKey = @ForeignKey(name = "fk_ref_od_restimg_kon_restoran")) 35 35 public Restaurant getRestaurant() { -
src/main/java/com/tourMate/entities/RestaurantReservations.java
r5528b99 r07f4e8b 82 82 } 83 83 84 @ManyToOne(fetch = FetchType. LAZY)84 @ManyToOne(fetch = FetchType.EAGER) 85 85 @JoinColumn(name = "user_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_rezervacija_restoran_kon_korisnik")) 86 86 public User getUser() { -
src/main/java/com/tourMate/entities/Reviews.java
r5528b99 r07f4e8b 75 75 76 76 @ManyToOne(fetch = FetchType.LAZY) 77 @JoinColumn(name = "hotel_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_hotel"))77 @JoinColumn(name = "hotel_id", unique = false, nullable = true, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_hotel")) 78 78 public Hotels getHotel () { 79 79 return hotel; … … 85 85 86 86 @ManyToOne(fetch = FetchType.LAZY) 87 @JoinColumn(name = "restaurant_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_restorani"))87 @JoinColumn(name = "restaurant_id", unique = false, nullable = true, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_restorani")) 88 88 public Restaurant getRestaurant () { 89 89 return restaurant; … … 95 95 96 96 @ManyToOne(fetch = FetchType.LAZY) 97 @JoinColumn(name = "transport_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_transport"))97 @JoinColumn(name = "transport_id", unique = false, nullable = true, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_transport")) 98 98 public Transport getTransport () { 99 99 return transport; -
src/main/java/com/tourMate/entities/User.java
r5528b99 r07f4e8b 52 52 private Role role; 53 53 @Column(name = "locked", unique = false, nullable = false) 54 boolean locked ;54 boolean locked = false; 55 55 56 56 @Column(name = "enabled", unique = false, nullable = false) … … 96 96 } 97 97 98 public boolean isLocked() { 99 return locked; 100 } 98 101 99 102 public long getUserID() { … … 162 165 @Override 163 166 public boolean isAccountNonLocked() { 164 return true;167 return locked; 165 168 } 166 169 -
src/main/java/com/tourMate/services/BusinessManager.java
r5528b99 r07f4e8b 8 8 public void createBusiness(Business business, long userId); 9 9 public List<Business> getUnapprovedBusinessesOfUser(long userId); 10 public void deleteBusiness(long businessId); 11 public List<Business> getCreatedBusinesses(); 10 11 void deleteBusiness(long businessId); 12 13 public List<Business> getUnapprovedBusinesses(); 14 public void approveBusiness(Long businessId); 12 15 public Business findBusinessById (long businessId); 13 public void editBusiness(long businessId, String name, String phone, String address, String edbs, User user, boolean approved);14 16 public boolean hasBusiness(long userId); 17 18 void editBusiness(long businessId, String name, String phone, String address, String edbs, User user, boolean approved); 15 19 } -
src/main/java/com/tourMate/services/HotelManager.java
r5528b99 r07f4e8b 2 2 3 3 import com.tourMate.dto.HotelDto; 4 import com.tourMate.dto.HotelReservationDto; 5 import com.tourMate.dto.HotelReservationUserDto; 4 6 import com.tourMate.entities.*; 5 import org.springframework.web.multipart.MultipartFile;6 7 7 8 import java.util.Date; 8 9 import java.util.List; 9 import java.util.Map;10 10 11 11 public interface HotelManager { … … 24 24 public List<HotelRoom> getRoomsOfHotel (long hotelId); 25 25 public HotelRoom findRoomById (long hotelRoomId); 26 <<<<<<< HEAD27 26 public List<HotelRoomImages> getRoomImages(Long hotelRoom); 28 27 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price, int numOfBeds); 29 =======30 public List<HotelRoomImages> getRoomImages(HotelRoom hotelRoom);31 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price);32 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl)33 28 public void editRoom(long hotelRoomId, Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price); 34 29 public void deleteRoom(long hotelRoomId); 35 public List<HotelRoomAvailable> getRoomsAvailable(Long id);36 30 public void createRoomAvailible(HotelRoom hotelRoom, Date dateFrom, Date dateTo, int numberOfBeds); 37 31 public void editRoomAvailible(long hotelRoomAvailableId, HotelRoom hotelRoom, Date dateFrom, Date dateTo, int numberOfBeds); … … 40 34 public HotelRoomAvailable findAvailibleRoomById(long hotelRoomAvailableId); 41 35 public List<HotelRoomAvailable> getRoomsAvailibility(); 36 public List<HotelRoomAvailable> getRoomsAvailableById(Long id); 42 37 public List<HotelRoomAvailable> getRoomsAvailibilityByHotel(Hotels hotel); 43 public List<HotelDto> getRoomsAvailibilityByDateAndLocation(String hotelLocation, Date dateFrom, Date dateTo, int numberOfBeds );38 public List<HotelDto> getRoomsAvailibilityByDateAndLocation(String hotelLocation, Date dateFrom, Date dateTo, int numberOfBeds, Boolean flexible); 44 39 public void createReservation(Long userId, Long hotelRoomId, Long hotelRoomAvailableId, Date dateFrom, Date dateTo, Integer numberOfBeds); 45 40 public void editReservation(long hotelRoomReservedId, User user, HotelRoom hotelRoom, Date dateFrom, Date dateTo, Integer numberOfBeds); 46 41 public void deleteReservation(long hotelRoomReservedId); 42 public List<HotelReservationDto> findVaidReseravtionsByHotel(Long hotelId); 43 public List<HotelReservationUserDto> findValidHotelReservationsByUser(Long userId); 47 44 public HotelRoomReservations findReservationById(long hotelRoomReservedId); 48 45 public List<HotelRoomReservations> findReservationByUser(User user); … … 54 51 55 52 void addRoomImage(Long id, List<String> filesToAdd); 53 void setReservationReviewed(Long reservationId); 56 54 } -
src/main/java/com/tourMate/services/RestaurantManager.java
r5528b99 r07f4e8b 2 2 3 3 import com.tourMate.dto.RestaurantDto; 4 import com.tourMate.dto.RestaurantReservationDto; 4 5 import com.tourMate.dto.RestaurantReservationUserDto; 5 6 import com.tourMate.entities.*; … … 10 11 public interface RestaurantManager { 11 12 public void createRestaurant(Restaurant restaurant, long userId); 12 public void deleteRestaurant(long restaurantID); 13 13 14 public void addMenuToRestaurant(long restaurantId, Menu menu); 15 14 16 public List<Restaurant> getRestaurantsByUser(long userId); 15 void deleteHotel(long restaurantID); 17 public void deleteRestaurant(Long restaurantID); 18 19 void deleteRestaurant(long restaurantID); 16 20 17 21 public List<Restaurant> getRestaurants(); 18 public Restaurant findRestaurantByID (long restaurantID); 22 23 public Restaurant findRestaurantByID(long restaurantID); 24 19 25 public void addRestaurantImage(Long restaurant, List<String> url); 26 20 27 public void removeRestaurantImage(long restaurantImageId); 28 21 29 public RestaurantImages findRestaurantImageById(long restaurantImageId); 22 30 23 31 public List<RestaurantImages> getRestaurantImages(long restaurantID); 32 24 33 public void editRestaurant(long restaurantID, String restaurantName, String restaurantLocation, String cousineType, String restaurantDescription, String restaurantEdbs, User restaurantOwner); 34 35 void editReservation(long restaurantsTableId, RestaurantsTable rt, Date hourFrom, Date hourTo, int noSeats, User user); 36 25 37 public List<RestaurantsTable> getRestaurantTables(long restaurantID); 26 public List<RestaurantDto> getTablesByDateAndLocation(String restaurantLocation, Date hourFrom, Date hourTo, int noSeats ); 38 39 public List<RestaurantDto> getTablesByDateAndLocation(String restaurantLocation, Date hourFrom, Date hourTo, int noSeats); 40 27 41 public RestaurantsTable findTableById(long tableId); 42 28 43 public void createTable(Long restaurantId, int noSeats); 44 29 45 public void editTable(Restaurant restaurant, long tableId, int noSeats); 46 30 47 public void deleteTable(long tableId); 31 48 32 public void createTableAvailable(Long rt, Date hourFrom, Date hourTo );49 public void createTableAvailable(Long rt, Date hourFrom, Date hourTo, int numTables); 33 50 34 51 public void editTableAvailable(long tableId, Restaurant restaurant, int noSeats); 52 35 53 public void deleteTableAvailable(long tableId); 36 public List<RestaurantsTable> getTablesAvailability(); 54 37 55 public List<RestaurantsAvailible> getTablesAvailabilityById(Long id); 38 public void createReservation(Restaurant restaurant, int noSeats); 56 57 RestaurantsAvailible findAvailableReservationByID(long tableId); 39 58 40 59 void createReservation(RestaurantsTable rt, Date dateFrom, Date dateTo, User user); 41 60 42 public void editReservation(long tableId, Restaurant restaurant, int noSeats);43 61 public void deleteReservation(long tableId); 62 44 63 public RestaurantReservations findReservationByID(long tableId); 45 public List<RestaurantReservations> findAvailableReservationByID();46 64 47 List<RestaurantReservations> findAvailableReservationByID(long reservationId);65 // List<RestaurantReservations> findAvailableReservationByID(long reservationId); 48 66 49 67 public List<RestaurantReservations> findReservationByUser(User user); 50 public List<RestaurantReservations> findReservationByRestaurant(Restaurant restaurant); 68 69 public List<RestaurantReservationDto> findReservationByRestaurant(Long restaurant); 70 51 71 public List<RestaurantReservations> getReservations(); 72 52 73 public List<Restaurant> searchByRestaurantName(String restaurantName); 74 53 75 public List<Restaurant> searchByRestaurantLocation(String restaurantLocation); 76 54 77 public List<RestaurantsTable> searchByNoSeats(int noSeats); 55 78 … … 61 84 62 85 List<RestaurantReservationUserDto> findPastRestaurantReservationsByUser(Long userId); 86 87 List<MenuImages> getMenuImages(Long id); 88 89 void addMenuImage(Long restaurant, List<String> url); 90 91 Menu findMenuById(Long menuId); 92 93 void setReservationReviewed(Long reservationId); 94 95 List<MenuImages> getMenuImagesByRestaurant(long restaurantId); 63 96 } -
src/main/java/com/tourMate/services/ReviewManager.java
r5528b99 r07f4e8b 9 9 public interface ReviewManager{ 10 10 11 public void createReview(String title, int numStar, String description, Long hotel, Long restaurant, Long transport );11 public void createReview(String title, int numStar, String description, Long hotel, Long restaurant, Long transport, Long reservationId); 12 12 public void deleteReview(long id); 13 13 public Reviews findReviewById(long id); -
src/main/java/com/tourMate/services/TransportManager.java
r5528b99 r07f4e8b 13 13 public interface TransportManager { 14 14 15 public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate);15 public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, Long userId, String carPlate); 16 16 17 17 public void deleteTransport(long transportId); … … 30 30 public TransportReservation findTransportReservationByID(long reservationID); 31 31 32 List<TransportReservation> findTransportReservationByTransportId(long reservationID); 33 32 34 public List<TransportReservation> getTransportReservations(); 33 35 … … 35 37 public Transport getTransportById(long transportId); 36 38 37 <<<<<<< HEAD38 39 List<Reviews> getReviewsForTransport(long transportId); 39 40 40 41 public List<TransportListingDto> getTransportsAvailableByFilters (String from, String to, Date date, int numPassengers); 41 =======42 public List<TransportListingDto> getTransportsAvailableByFilters (String from, String to, Date date);43 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl)44 42 45 43 public List<TransportReservation> getTransportsReservationsByUserID(long userID); … … 48 46 49 47 public void createTransportAvailable(Transport transport, String departureLocation, String arrivalLocation, Date date, Integer noSeats, Date departureHour, Collection<TransportRoute> routes); 50 51 public void editTransportReservation(Transport transport, long reservationID, String departureLocation, String arrivalLocation, Date date, Integer noSeats, User user, Date departureHour);52 53 48 public void editTransportAvailable(Transport transport, long availableID, String departureLocation, String arrivalLocation, Date date, Integer noSeats, Date departureHour); 54 49 … … 67 62 68 63 List<TransportReservationUserDto> findPastTransportReservationsByUser(Long userId); 64 65 void setReservationReviewed(Long reservationId); 69 66 } 70 67 -
src/main/java/com/tourMate/services/UsersManager.java
r5528b99 r07f4e8b 16 16 17 17 public void editUser(long userID, String name, String surname, String email, Date birthDate, String address, String contact); 18 public List<User> getUnapprovedUsers(); 19 public void approveUserProfile(long userId); 20 21 void unlock(Long id); 18 22 } -
src/main/java/com/tourMate/services/impl/BusinessManagerImpl.java
r5528b99 r07f4e8b 2 2 3 3 import com.tourMate.dao.BusinessDao; 4 import com.tourMate.dao.UsersDao; 4 5 import com.tourMate.entities.Business; 6 import com.tourMate.entities.Role; 5 7 import com.tourMate.entities.User; 6 8 import com.tourMate.services.BusinessManager; 9 import com.tourMate.services.UsersManager; 7 10 import org.springframework.beans.factory.annotation.Autowired; 8 11 import org.springframework.stereotype.Service; … … 16 19 @Autowired 17 20 BusinessDao businessDao; 21 @Autowired 22 UsersDao usersDao; 23 @Autowired 24 UsersManager usersManager; 18 25 19 26 @Override 20 27 public void createBusiness(Business business, long userId) { 21 businessDao.createBusiness(business, userId); 28 User u = usersManager.findUserByID(userId); 29 business.setUser(u); 30 businessDao.createBusiness(business); 22 31 } 23 32 24 33 @Override 25 34 public List<Business> getUnapprovedBusinessesOfUser(long userId) { 26 return businessDao.getUnapprovedBusinessesOfUser(userId); 35 User u = usersManager.findUserByID(userId); 36 return businessDao.getUnapprovedBusinessesOfUser(u); 27 37 } 28 38 29 39 @Override 30 40 public void deleteBusiness(long businessId) { 31 businessDao.deleteBusiness(businessId); 41 Business business = businessDao.findBusinessById(businessId); 42 businessDao.deleteBusiness(business); 32 43 33 44 } 34 45 35 46 @Override 36 public boolean hasBusiness(long userId){37 return businessDao. hasBusiness(userId);47 public List<Business> getUnapprovedBusinesses() { 48 return businessDao.getUnapprovedBusinesses(); 38 49 } 39 50 40 51 @Override 41 public List<Business> getCreatedBusinesses() { 42 return businessDao.getCreatedBusinesses(); 52 public void approveBusiness(Long businessId) { 53 Business b = findBusinessById(businessId); 54 b.setApproved(true); 55 businessDao.approveBusiness(b); 56 changeUserRoleBusiness(b.getUser().getUserID()); 57 } 58 59 private void changeUserRoleBusiness(Long userId) 60 { 61 User u = usersDao.findUserByID(userId); 62 Role r = usersDao.findById(3L); 63 u.setRole(r); 64 usersDao.updateUser(u); 65 } 66 67 @Override 68 public boolean hasBusiness(long userId){ 69 User u = usersManager.findUserByID(userId); 70 return businessDao.hasBusiness(u); 43 71 } 44 72 … … 50 78 @Override 51 79 public void editBusiness(long businessId, String name, String phone, String address, String edbs, User user, boolean approved) { 52 businessDao.editBusiness(businessId, name, phone, address, edbs, user, approved); 80 Business business = findBusinessById(businessId); 81 business.setName(name); 82 business.setPhone(phone); 83 business.setAddress(address); 84 business.setEdbs(edbs); 85 business.setUser(user); 86 business.setApproved(approved); 87 businessDao.editBusiness(business); 53 88 } 54 89 -
src/main/java/com/tourMate/services/impl/HotelManagerImpl.java
r5528b99 r07f4e8b 4 4 import com.tourMate.dao.UsersDao; 5 5 import com.tourMate.dto.HotelDto; 6 import com.tourMate.dto.HotelReservationDto; 7 import com.tourMate.dto.HotelReservationUserDto; 6 8 import com.tourMate.entities.*; 7 9 import com.tourMate.services.HotelManager; 10 import com.tourMate.services.UsersManager; 8 11 import org.springframework.beans.factory.annotation.Autowired; 9 12 import org.springframework.stereotype.Service; 10 import org.springframework.web.multipart.MultipartFile;11 13 12 14 import java.time.Duration; 13 import java.util.Collection;14 15 import java.util.Date; 15 16 import java.util.List; … … 24 25 @Autowired 25 26 UsersDao usersDao; 26 27 @Autowired 28 UsersManager usersManager; 27 29 28 30 @Override … … 33 35 @Override 34 36 public void createHotel(Hotels hotels, long userId) { 35 hotelDao.createHotel(hotels, userId); 37 User u = usersManager.findUserByID(userId); 38 hotels.setOwner(u); 39 hotelDao.createHotel(hotels); 36 40 } 37 41 … … 39 43 @Override 40 44 public List<Hotels> getHotels() { 41 List<Hotels> hoteli = hotelDao.getHotels();42 45 return hotelDao.getHotels(); 43 46 } … … 45 48 @Override 46 49 public List<Hotels> getHotelsForUser(long userId) { 47 return hotelDao.getHotelsForUser(userId); 50 User u = usersManager.findUserByID(userId); 51 return hotelDao.getHotelsForUser(u); 48 52 } 49 53 … … 55 59 @Override 56 60 public void editHotel(long hotelId, String hotelName, String hotelDescripiton, String hotelLocation, String hotelEDBS, Boolean parking, Boolean petFriendly, Boolean internetAvailable) { 57 hotelDao.editHotel(hotelId, hotelName, hotelDescripiton, hotelLocation, hotelEDBS, parking, petFriendly, internetAvailable); 61 Hotels hotel = hotelDao.findHotelByID(hotelId); 62 hotel.setHotelName(hotelName); 63 hotel.setHotelDescripiton(hotelDescripiton); 64 hotel.setHotelLocation(hotelLocation); 65 hotel.setHotelEDBS(hotelEDBS); 66 hotel.setParking(parking); 67 hotel.setPetFriendly(petFriendly); 68 hotel.setInternetAvailable(internetAvailable); 69 hotelDao.editHotel(hotel); 58 70 } 59 71 60 72 @Override 61 73 public void deleteHotel(long hotelId) { 62 hotelDao.deleteHotel(hotelId); 74 Hotels h = findHotelByID(hotelId); 75 hotelDao.deleteHotel(h); 63 76 } 64 77 … … 76 89 @Override 77 90 public List<HotelRoom> getRoomsOfHotel(long hotelId) { 78 return hotelDao.getRoomsOfHotel(hotelId); 91 Hotels h = findHotelByID(hotelId); 92 return hotelDao.getRoomsOfHotel(h); 79 93 } 80 94 … … 99 113 @Override 100 114 public void deleteHotelImage(long hotelImageId){ 101 hotelDao.deleteHotelImage(hotelImageId); 115 HotelsImages hotelsImages = findHotelImageById(hotelImageId); 116 hotelDao.deleteHotelImage(hotelsImages); 102 117 } 103 118 … … 108 123 109 124 @Override 110 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price) { 111 hotelDao.createRoom(hotel, hotelRoomDescription, hotelRoomName, kitchenAvailable, airConditioning, balcony, price); 125 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price, int numOfBeds) { 126 HotelRoom hotelRoom = new HotelRoom(hotel, hotelRoomDescription, hotelRoomName, kitchenAvailable, airConditioning, balcony, price, numOfBeds); 127 hotelDao.createRoom(hotelRoom); 112 128 } 113 129 114 130 @Override 115 131 public void editRoom(long hotelRoomId, Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price) { 116 hotelDao.editRoom(hotelRoomId, hotel, hotelRoomDescription, hotelRoomName, kitchenAvailable, airConditioning, balcony, price); 132 HotelRoom hr = findRoomById(hotelRoomId); 133 hr.setHotel(hotel); 134 hr.setHotelRoomDescription(hotelRoomDescription); 135 hr.setHotelRoomName(hotelRoomName); 136 hr.setKitchenAvailable(kitchenAvailable); 137 hr.setAirConditioning(airConditioning); 138 hr.setBalcony(balcony); 139 hr.setPrice(price); 140 hotelDao.editRoom(hr); 117 141 } 118 142 119 143 @Override 120 144 public void deleteRoom(long hotelRoomId) { 121 hotelDao.deleteRoom(hotelRoomId); 122 } 123 124 @Override 125 public List<HotelRoomAvailable> getRoomsAvailable(Long id) { 145 HotelRoom hr = findRoomById(hotelRoomId); 146 hotelDao.deleteRoom(hr); 147 } 148 149 150 @Override 151 public List<HotelRoomAvailable> getRoomsAvailableById(Long id) { 126 152 return hotelDao.getRoomsAvailable(id); 127 153 } … … 129 155 @Override 130 156 public void createRoomAvailible(HotelRoom hotelRoom, Date dateFrom, Date dateTo, int numberOfBeds) { 131 hotelDao.createRoomAvailible(hotelRoom, dateFrom, dateTo, numberOfBeds); 157 HotelRoomAvailable hra = new HotelRoomAvailable(hotelRoom, dateFrom, dateTo, numberOfBeds); 158 hotelDao.createRoomAvailible(hra); 132 159 } 133 160 134 161 @Override 135 162 public void editRoomAvailible(long hotelRoomAvailableId, HotelRoom hotelRoom, Date dateFrom, Date dateTo, int numberOfBeds) { 136 hotelDao.editRoomAvailible(hotelRoomAvailableId, hotelRoom, dateFrom, dateTo, numberOfBeds); 163 HotelRoomAvailable hr = findAvailibleRoomById(hotelRoomAvailableId); 164 hr.setHotelRoom(hotelRoom); 165 hr.setDateFrom(dateFrom); 166 hr.setDateTo(dateTo); 167 hr.setNumberOfBeds(numberOfBeds); 168 hotelDao.editRoomAvailible(hr); 137 169 } 138 170 … … 142 174 roomAvailable.setNumberOfBeds(numberOfBeds-1); 143 175 HotelRoom room = hotelDao.findRoomById(hotelRoomId); 144 hotelDao.createRoomAvailible(room, roomAvailable.getDateFrom(), from, 1); 145 hotelDao.createRoomAvailible(room, to, roomAvailable.getDateTo(), 1); 176 HotelRoomAvailable hra = new HotelRoomAvailable(room,roomAvailable.getDateFrom(),from,1); 177 hotelDao.createRoomAvailible(hra); 178 HotelRoomAvailable hra1 = new HotelRoomAvailable(room,to,roomAvailable.getDateTo(),1); 179 hotelDao.createRoomAvailible(hra1); 146 180 } 147 181 148 182 @Override 149 183 public void deleteRoomAvailible(long hotelRoomAvailableId) { 150 hotelDao.deleteRoomAvailible(hotelRoomAvailableId); 184 HotelRoomAvailable hra = findAvailibleRoomById(hotelRoomAvailableId); 185 hotelDao.deleteRoomAvailible(hra); 151 186 } 152 187 … … 167 202 168 203 @Override 169 public List<HotelDto> getRoomsAvailibilityByDateAndLocation(String hotelLocation, Date dateFrom, Date dateTo, int numberOfBeds ) {204 public List<HotelDto> getRoomsAvailibilityByDateAndLocation(String hotelLocation, Date dateFrom, Date dateTo, int numberOfBeds, Boolean flexible) { 170 205 long numberOfNights = Duration.between(dateFrom.toInstant(), dateTo.toInstant()).toDays(); 171 List<HotelRoomAvailable> roomsAvailible = hotelDao.getRoomsAvailibilityByDateAndLocation(hotelLocation, dateFrom, dateTo, numberOfBeds );206 List<HotelRoomAvailable> roomsAvailible = hotelDao.getRoomsAvailibilityByDateAndLocation(hotelLocation, dateFrom, dateTo, numberOfBeds, flexible); 172 207 Map<Hotels, List<HotelRoomAvailable>> roomsByHotels = roomsAvailible.stream().collect(Collectors.groupingBy(x -> x.getHotelRoom().getHotel())); 173 208 List<HotelDto> hotelsList = roomsByHotels.keySet().stream() … … 195 230 HotelRoom room = hotelDao.findRoomById(hotelRoomId); 196 231 User user = usersDao.findUserByID(userId); 197 hotelDao.createReservation(user, room, dateFrom, dateTo, numberOfBeds);232 HotelRoomReservations r = new HotelRoomReservations(user, room, dateFrom, dateTo, numberOfBeds); 198 233 editRoomAvailibleReservation(hotelRoomAvailableId, hotelRoomId, dateFrom, dateTo, numberOfBeds); 234 hotelDao.createReservation(r); 235 199 236 } 200 237 201 238 @Override 202 239 public void editReservation(long hotelRoomReservedId, User user, HotelRoom hotelRoom, Date dateFrom, Date dateTo, Integer numberOfBeds) { 203 hotelDao.editReservation(hotelRoomReservedId, user, hotelRoom, dateFrom, dateTo, numberOfBeds); 240 HotelRoomReservations hr = findReservationById(hotelRoomReservedId); 241 hr.setUser(user); 242 hr.setHotelRoom(hotelRoom); 243 hr.setDateFrom(dateFrom); 244 hr.setDateTo(dateTo); 245 hr.setNumberOfBeds(numberOfBeds); 246 hotelDao.editReservation(hr); 204 247 } 205 248 206 249 @Override 207 250 public void deleteReservation(long hotelRoomReservedId) { 208 hotelDao.deleteReservation(hotelRoomReservedId); 209 } 210 211 @Override 212 <<<<<<< HEAD 251 HotelRoomReservations r = findReservationById(hotelRoomReservedId); 252 HotelRoomAvailable hra = new HotelRoomAvailable(r.getHotelRoom(), r.getDateFrom(), r.getDateTo(), r.getNumberOfBeds()); 253 hotelDao.createRoomAvailible(hra); 254 hotelDao.deleteReservation(r); 255 } 256 257 @Override 213 258 public List<HotelReservationDto> findVaidReseravtionsByHotel(Long hotelId) { 214 259 Hotels hotel = findHotelByID(hotelId); … … 230 275 List<HotelRoomReservations> reservations = hotelDao.findReservationByUser(u); 231 276 return reservations.stream().map(x -> new HotelReservationUserDto( 277 x.getHotelRoomReservedId(), 232 278 x.getUser(), 233 279 x.getHotelRoom(), … … 244 290 245 291 @Override 246 =======247 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl)248 292 public HotelRoomReservations findReservationById(long hotelRoomReservedId) { 249 293 return hotelDao.findReservationById(hotelRoomReservedId); … … 276 320 List<HotelRoomReservations> reservations = hotelDao.findPastReservationByUser(u); 277 321 return reservations.stream().map(x -> new HotelReservationUserDto( 322 x.getHotelRoomReservedId(), 278 323 x.getUser(), 279 324 x.getHotelRoom(), … … 294 339 filesToAdd.stream().map(file -> new HotelRoomImages(hr, file)).forEach(x -> hotelDao.addRoomImage(x)); 295 340 } 341 342 @Override 343 public void setReservationReviewed(Long reservationId) { 344 HotelRoomReservations hotelRoomReservations = findReservationById(reservationId); 345 hotelRoomReservations.setReviewed(true); 346 hotelDao.saveReservation(hotelRoomReservations); 347 } 296 348 } -
src/main/java/com/tourMate/services/impl/ImageManagerImpl.java
r5528b99 r07f4e8b 56 56 hotelManager.addRoomImage(id, filesToAdd); 57 57 } 58 else if(type.equals("menu")) 59 { 60 restaurantManager.addMenuImage(id, filesToAdd); 61 } 58 62 59 63 return filesToAdd; -
src/main/java/com/tourMate/services/impl/MenuManagerImpl.java
r5528b99 r07f4e8b 17 17 @Override 18 18 public void createMenu(String name, String ingredients, double price) { 19 menuDao.createMenu(n ame, ingredients, price);19 menuDao.createMenu(new Menu(name, ingredients, price)); 20 20 } 21 21 22 22 @Override 23 23 public void deleteMenu(long menuId) { 24 menuDao.deleteMenu(menuId); 24 Menu menu = findMenuById(menuId); 25 menuDao.deleteMenu(menu); 25 26 } 26 27 … … 37 38 @Override 38 39 public void editMenu(long menuId, String name, String ingredients, double price) { 39 menuDao.editMenu(menuId, name, ingredients, price); 40 Menu menu = findMenuById(menuId); 41 menu.setName(name); 42 menu.setIngredients(ingredients); 43 menu.setPrice(price); 44 menuDao.editMenu(menu); 40 45 } 41 46 } -
src/main/java/com/tourMate/services/impl/RestaurantManagerImpl.java
r5528b99 r07f4e8b 3 3 import com.tourMate.dao.RestaurantDao; 4 4 import com.tourMate.dto.RestaurantDto; 5 import com.tourMate.dto.RestaurantReservationDto; 5 6 import com.tourMate.dto.RestaurantReservationUserDto; 6 7 import com.tourMate.services.RestaurantManager; … … 22 23 @Autowired 23 24 UsersManager usersManager; 25 24 26 @Override 25 27 public void createRestaurant(Restaurant restaurant, long userId) { 26 restaurantDao.createRestaurant(restaurant, userId); 27 } 28 29 28 User u = usersManager.findUserByID(userId); 29 Restaurant r = new Restaurant(restaurant.getRestaurantName(), restaurant.getRestaurantLocation(), restaurant.getCousineType(), restaurant.getRestaurantDescription(), restaurant.getRestaurantEdbs(), u); 30 restaurantDao.createRestaurant(r); 31 } 32 33 @Override 34 public void deleteRestaurant(Long restaurantID) { 35 Restaurant r = findRestaurantByID(restaurantID); 36 restaurantDao.deleteRestaurant(r); 37 } 38 39 @Override 40 public void addMenuToRestaurant(long restaurantId, Menu menu) { 41 Restaurant r = findRestaurantByID(restaurantId); 42 menu.setRestaurant(r); 43 restaurantDao.addMenuToRestaurant(menu); 44 } 45 46 @Override 47 public List<Restaurant> getRestaurantsByUser(long userId) { 48 User u = usersManager.findUserByID(userId); 49 return restaurantDao.getRestaurantsByUser(u); 50 } 30 51 31 52 @Override 32 53 public void deleteRestaurant(long restaurantID) { 33 restaurantDao.deleteRestaurant(restaurantID); 34 } 35 36 @Override 37 public void addMenuToRestaurant(long restaurantId, Menu menu) { 38 restaurantDao.addMenuToRestaurant(restaurantId, menu); 39 } 40 41 @Override 42 public List<Restaurant> getRestaurantsByUser(long userId) { 43 return restaurantDao.getRestaurantsByUser(userId); 44 } 45 46 @Override 47 public void deleteHotel(long restaurantID) { 48 restaurantDao.deleteRestaurant(restaurantID); 54 Restaurant r = findRestaurantByID(restaurantID); 55 restaurantDao.deleteRestaurant(r); 49 56 } 50 57 … … 67 74 @Override 68 75 public void removeRestaurantImage(long restaurantImageId) { 69 restaurantDao.removeRestaurantImage(restaurantImageId); 76 RestaurantImages restaurantImage = findRestaurantImageById(restaurantImageId); 77 restaurantDao.removeRestaurantImage(restaurantImage); 70 78 } 71 79 … … 81 89 82 90 @Override 83 public List<RestaurantDto> getTablesByDateAndLocation(String restaurantLocation, Date hourFrom, Date hourTo, int noSeats) {91 public List<RestaurantDto> getTablesByDateAndLocation(String restaurantLocation, Date hourFrom, Date hourTo, int noSeats) { 84 92 List<RestaurantsAvailible> restaurantsAvailibles = restaurantDao.getTablesByDateAndLocation(restaurantLocation, hourFrom, hourTo, noSeats); 85 93 Map<Restaurant, List<RestaurantsAvailible>> tablesByRestaurants = restaurantsAvailibles.stream().collect(Collectors.groupingBy(x -> x.getRestaurantTable().getRestaurant())); … … 96 104 getReviewsForRestaurant(x.getRestaurantID()), 97 105 getReviewsForRestaurant(x.getRestaurantID()).stream().mapToDouble(Reviews::getNumStar).average().orElse(0), 98 getRestaurantImages(x.getRestaurantID()) 106 getRestaurantImages(x.getRestaurantID()), 107 getMenuImagesByRestaurant(x.getRestaurantID()) 99 108 )).toList(); 100 109 return restaurantsList; … … 103 112 @Override 104 113 public void editRestaurant(long restaurantID, String restaurantName, String restaurantLocation, String cousineType, String restaurantDescription, String restaurantEdbs, User restaurantOwner) { 105 restaurantDao.editRestaurant(restaurantID, restaurantName, restaurantLocation, cousineType, restaurantDescription, restaurantEdbs, restaurantOwner); 114 Restaurant res = findRestaurantByID(restaurantID); 115 res.setRestaurantName(restaurantName); 116 res.setRestaurantLocation(restaurantLocation); 117 res.setRestaurantEdbs(restaurantEdbs); 118 res.setRestaurantDescription(restaurantDescription); 119 res.setRestaurantOwner(restaurantOwner); 120 res.setCousineType(cousineType); 121 restaurantDao.createRestaurant(res); 122 } 123 124 @Override 125 public void editReservation(long restaurantsTableId, RestaurantsTable rt, Date hourFrom, Date hourTo, int noSeats, User user){ 126 RestaurantReservations r = findReservationByID(restaurantsTableId); 127 r.setTable(rt); 128 r.setTimeFrom(hourFrom); 129 r.setTimeTo(hourTo); 130 r.setNoSeats(noSeats); 131 r.setUser(user); 132 restaurantDao.saveReservation(r); 106 133 } 107 134 … … 119 146 public void createTable(Long restaurantId, int noSeats) { 120 147 Restaurant r = restaurantDao.findRestaurantByID(restaurantId); 121 restaurantDao.createTable(r, noSeats); 148 RestaurantsTable restaurantsTable = new RestaurantsTable(r, noSeats); 149 restaurantDao.saveTable(restaurantsTable); 122 150 } 123 151 124 152 @Override 125 153 public void editTable(Restaurant restaurant, long tableId, int noSeats) { 126 restaurantDao.editTable(restaurant, tableId, noSeats); 154 RestaurantsTable resTable = findTableById(tableId); 155 resTable.setRestaurant(restaurant); 156 resTable.setNoSeats(noSeats); 157 restaurantDao.saveTable(resTable); 127 158 } 128 159 129 160 @Override 130 161 public void deleteTable(long tableId) { 131 restaurantDao.deleteTable(tableId); 132 } 133 134 @Override 135 public void createTableAvailable(Long rt, Date hourFrom, Date hourTo) { 162 RestaurantsTable rt = findTableById(tableId); 163 restaurantDao.deleteTable(rt); 164 } 165 166 @Override 167 public void createTableAvailable(Long rt, Date hourFrom, Date hourTo, int numTables) { 136 168 RestaurantsTable rtabl = findTableById(rt); 137 restaurantDao.createTableAvailable(rtabl, hourFrom, hourTo);138 }139 140 @Override 141 public List<RestaurantsAvailible> getTablesAvailabilityById(Long id)142 {169 RestaurantsAvailible ra = new RestaurantsAvailible(rtabl, hourFrom, hourTo, numTables); 170 restaurantDao.saveTableAvailable(ra); 171 } 172 173 @Override 174 public List<RestaurantsAvailible> getTablesAvailabilityById(Long id) { 143 175 return restaurantDao.getTablesAvailabilityById(id); 144 176 } … … 146 178 @Override 147 179 public void editTableAvailable(long tableId, Restaurant restaurant, int noSeats) { 148 restaurantDao.editTableAvailable(tableId, restaurant, noSeats); 180 RestaurantsTable rt = findTableById(tableId); 181 rt.setRestaurant(restaurant); 182 rt.setNoSeats(noSeats); 183 restaurantDao.saveTable(rt); 149 184 } 150 185 151 186 @Override 152 187 public void deleteTableAvailable(long tableId) { 153 restaurantDao.deleteTableAvailable(tableId); 154 } 155 156 @Override 157 public List<RestaurantsTable> getTablesAvailability() { 158 return null; 159 } 160 161 @Override 162 public void createReservation(Restaurant restaurant, int noSeats) { 163 188 RestaurantsAvailible ra = findAvailableReservationByID(tableId); 189 restaurantDao.deleteTableAvailable(ra); 190 } 191 192 @Override 193 public RestaurantsAvailible findAvailableReservationByID(long tableId){ 194 return restaurantDao.findAvailableReservationByID(tableId); 164 195 } 165 196 … … 170 201 } 171 202 172 @Override173 public void editReservation(long tableId, Restaurant restaurant, int noSeats) {174 //restaurantDao.editReservation(tableId, restaurant, noSeats);175 }176 203 177 204 @Override 178 205 public void deleteReservation(long tableId) { 179 restaurantDao.deleteReservation(tableId); 206 RestaurantReservations r = findReservationByID(tableId); 207 RestaurantsAvailible ra = new RestaurantsAvailible(r.getTable(), r.getTimeFrom(), r.getTimeTo(), r.getNoSeats()); 208 restaurantDao.saveTableAvailable(ra); 209 restaurantDao.deleteReservation(r); 180 210 } 181 211 182 212 @Override 183 213 public RestaurantReservations findReservationByID(long tableId) { 184 //return restaurantDao.findReservationByID(tableId); 185 return null; 186 } 187 188 @Override 189 public List<RestaurantReservations> findAvailableReservationByID() { 190 return null; 191 } 192 193 @Override 194 public List<RestaurantReservations> findAvailableReservationByID(long reservationId) { 195 return null; 196 // return restaurantDao.findAvailableReservationByID(reservationId); 214 return restaurantDao.findReservationByID(tableId); 215 //return null; 197 216 } 198 217 … … 203 222 204 223 @Override 205 public List<RestaurantReservations> findReservationByRestaurant(Restaurant restaurant) { 206 return restaurantDao.findReservationByRestaurant(restaurant); 224 public List<RestaurantReservationDto> findReservationByRestaurant(Long restaurant) { 225 Restaurant r = findRestaurantByID(restaurant); 226 List<RestaurantReservations> res = restaurantDao.findReservationByRestaurant(r); 227 return res.stream().map(x -> new RestaurantReservationDto( 228 x.getUser(), 229 x.getTable(), 230 x.getTimeFrom(), 231 x.getTimeTo() 232 )).collect(Collectors.toList()); 207 233 } 208 234 … … 251 277 } 252 278 253 public void editTableAvailability(RestaurantsAvailible restaurantsAvailible, RestaurantsTable table, Date dateFrom, Date dateTo) 254 { 279 public void editTableAvailability(RestaurantsAvailible restaurantsAvailible, RestaurantsTable table, Date dateFrom, Date dateTo) { 255 280 restaurantsAvailible.setNumTables(restaurantsAvailible.getNumTables() - 1); 256 restaurantDao.createTableAvailable(table, restaurantsAvailible.getHourFrom(), dateFrom, 1); 257 restaurantDao.createTableAvailable(table, dateTo, restaurantsAvailible.getHourTo(), 1); 281 RestaurantsAvailible ra1 = new RestaurantsAvailible(table, restaurantsAvailible.getHourFrom(), dateFrom, 1); 282 RestaurantsAvailible ra2 = new RestaurantsAvailible(table, dateTo, restaurantsAvailible.getHourTo(), 1); 283 284 restaurantDao.saveTableAvailable(ra1); 285 restaurantDao.saveTableAvailable(ra2); 258 286 } 259 287 … … 263 291 List<RestaurantReservations> reservations = restaurantDao.findReservationByUser(u); 264 292 return reservations.stream().map(x -> new RestaurantReservationUserDto( 293 x.getReservationId(), 265 294 x.getUser(), 266 295 x.getTable(), … … 281 310 List<RestaurantReservations> reservations = restaurantDao.findPastReservationsByUser(u); 282 311 return reservations.stream().map(x -> new RestaurantReservationUserDto( 312 x.getReservationId(), 283 313 x.getUser(), 284 314 x.getTable(), … … 293 323 )).toList(); 294 324 } 325 326 @Override 327 public List<MenuImages> getMenuImages(Long id) { 328 return restaurantDao.getMenuImages(id); 329 } 330 331 @Override 332 public void addMenuImage(Long menuId, List<String> url) { 333 Menu r = restaurantDao.findMenuId(menuId); 334 url.stream().map(file -> new MenuImages(r, file)).forEach(x -> restaurantDao.addMenuImage(x)); 335 } 336 337 @Override 338 public Menu findMenuById(Long menuId) { 339 return restaurantDao.findMenuId(menuId); 340 } 341 342 @Override 343 public void setReservationReviewed(Long reservationId) { 344 RestaurantReservations restaurantReservations = findReservationByID(reservationId); 345 restaurantReservations.setReviewed(true); 346 restaurantDao.saveReservation(restaurantReservations); 347 } 348 349 @Override 350 public List<MenuImages> getMenuImagesByRestaurant(long restaurantId) { 351 Restaurant r = findRestaurantByID(restaurantId); 352 return restaurantDao.getMenuImagesByRestaurant(r); 353 } 295 354 } -
src/main/java/com/tourMate/services/impl/ReviewManagerImpl.java
r5528b99 r07f4e8b 3 3 import com.tourMate.dao.ReviewDao; 4 4 import com.tourMate.dao.ReviewManager; 5 import com.tourMate.entities.Hotels; 6 import com.tourMate.entities.Restaurant; 7 import com.tourMate.entities.Reviews; 8 import com.tourMate.entities.Transport; 5 import com.tourMate.entities.*; 9 6 import com.tourMate.services.HotelManager; 10 7 import com.tourMate.services.RestaurantManager; … … 29 26 30 27 @Override 31 public void createReview(String title, int numStar, String description, Long hotel, Long restaurant, Long transport ) {28 public void createReview(String title, int numStar, String description, Long hotel, Long restaurant, Long transport, Long reservationId) { 32 29 Hotels h = null; 33 30 Restaurant r = null; … … 36 33 { 37 34 h = hotelManager.findHotelByID(hotel); 35 hotelManager.setReservationReviewed(reservationId); 38 36 } 39 37 if(restaurant != null) 40 38 { 41 39 r = restaurantManager.findRestaurantByID(restaurant); 40 restaurantManager.setReservationReviewed(reservationId); 42 41 } 43 42 if(transport != null) 44 43 { 45 44 t = transportManager.getTransportById(transport); 45 transportManager.setReservationReviewed(reservationId); 46 46 } 47 47 Reviews review = new Reviews (title, numStar, description, h, r, t); … … 51 51 @Override 52 52 public void deleteReview(long id) { 53 reviewDao.deleteReview(id); 53 Reviews review = findReviewById(id); 54 reviewDao.deleteReview(review); 54 55 } 55 56 … … 61 62 @Override 62 63 public void editReview(long id, String title, String description, int numStar, Hotels hotel, Restaurant restaurant, Transport transport) { 63 reviewDao.editReview(id, title, description, numStar, hotel, restaurant, transport); 64 Reviews review = findReviewById(id); 65 review.setDescription(description); 66 review.setHotel(hotel); 67 review.setRestaurant(restaurant); 68 review.setTitle(title); 69 review.setNumStar(numStar); 70 review.setTransport(transport); 71 reviewDao.editReview(review); 64 72 } 65 73 -
src/main/java/com/tourMate/services/impl/TransportManagerImpl.java
r5528b99 r07f4e8b 24 24 UsersManager usersManager; 25 25 26 @Override 27 public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate) { 28 transportDao.createTransport(transportName, carBrand, carType, carManufacturedYear, noPassengers, noBags, EMBG, owner, carPlate); 26 27 @Override 28 public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, Long userId, String carPlate) { 29 User u = usersManager.findUserByID(userId); 30 Transport t=new Transport(transportName,carBrand,carType,carManufacturedYear,noPassengers,noBags,EMBG,u,carPlate); 31 transportDao.createTransport(t); 29 32 } 30 33 31 34 @Override 32 35 public void deleteTransport(long transportId) { 33 transportDao.deleteTransport(transportId); 36 Transport t=getTransportById(transportId); 37 transportDao.deleteTransport(t); 34 38 } 35 39 … … 41 45 @Override 42 46 public List<TransportDto> getTransportsByUser(long userId) { 43 return transportDao.getTransportsByUser(userId); 47 User u = usersManager.findUserByID(userId); 48 return transportDao.getTransportsByUser(u); 44 49 } 45 50 46 51 @Override 47 52 public List<RouteListingDto> getRoutesForTransport(long transportId) { 48 return transportDao.getRoutesForTransport(transportId); 53 Transport t = getTransportById(transportId); 54 return transportDao.getRoutesForTransport(t); 49 55 } 50 56 … … 61 67 @Override 62 68 public void editTransport(long transportID, String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate) { 63 transportDao.editTransport(transportID, transportName, carBrand, carType, carManufacturedYear, noPassengers, noBags, EMBG, owner, carPlate); 69 Transport t=getTransportById(transportID); 70 t.setTransportName(transportName); 71 t.setCarBrand(carBrand); 72 t.setCarType(carType); 73 t.setCarManufacturedYear(carManufacturedYear); 74 t.setNoPassengers(noPassengers); 75 t.setNoBags(noBags); 76 t.setEMBG(EMBG); 77 t.setOwner(owner); 78 t.setCarPlate(carPlate); 79 transportDao.editTransport(t); 64 80 } 65 81 … … 78 94 79 95 @Override 96 public List<TransportReservation> findTransportReservationByTransportId(long reservationID) { 97 Transport t = getTransportById(reservationID); 98 return transportDao.findTransportReservationByTransportId(t); 99 } 100 101 @Override 80 102 public List<TransportReservation> getTransportReservations() { 81 103 return transportDao.getTransportReservations(); … … 93 115 94 116 @Override 95 <<<<<<< HEAD96 117 public List<Reviews> getReviewsForTransport(long transportId) { 97 118 Transport transport = getTransportById(transportId); … … 102 123 public List<TransportListingDto> getTransportsAvailableByFilters(String from, String to, Date date, int numPassengers) { 103 124 List<TransportRoute> transportAvailable = transportDao.getTransportsAvailableByFilters(from, to, date, numPassengers); 104 =======105 public List<TransportListingDto> getTransportsAvailableByFilters(String from, String to, Date date) {106 List<TransportRoute> transportAvailable = transportDao.getTransportsAvailableByFilters(from, to, date);107 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl)108 125 Map<TransportAvailible, List<TransportRoute>> transportsByTransporter = transportAvailable.stream().collect(Collectors.groupingBy(x -> x.getParentRoute())); 109 126 List<TransportListingDto> transportList = transportsByTransporter.keySet().stream().toList().stream() … … 136 153 @Override 137 154 public void createTransportAvailable(Transport transport, String departureLocation, String arrivalLocation, Date date, Integer noSeats, Date departureHour, Collection<TransportRoute> routes) { 138 transportDao.createTransportAvailable(transport, departureLocation, arrivalLocation, date, noSeats, departureHour, routes);139 }140 141 @Override142 public void editTransportReservation(Transport transport, long reservationID, String departureLocation, String arrivalLocation, Date date, Integer noSeats, User user, Date departureHour) {143 transportDao.editTransportReservation(transport, reservationID, departureLocation, arrivalLocation, date, noSeats, user, departureHour);155 TransportAvailible ta=new TransportAvailible(transport,departureLocation,arrivalLocation,date,noSeats,departureHour); 156 transportDao.createTransportAvailable(ta); 157 routes.forEach(x -> { 158 TransportRoute tr = new TransportRoute(ta, x.getFrom(), x.getTo(), x.getPrice(), x.getDeparture(), x.getArrival(), x.getFreeSpace(), x.getOrder()); 159 transportDao.createTransportRoute(tr); 160 }); 144 161 } 145 162 146 163 @Override 147 164 public void editTransportAvailable(Transport transport, long availableID, String departureLocation, String arrivalLocation, Date date, Integer noSeats, Date departureHour) { 148 transportDao.editTransportAvailable(transport, availableID, departureLocation, arrivalLocation, date, noSeats, departureHour); 165 TransportAvailible ta=findTransportAvailableByID(availableID); 166 ta.setTransport(transport); 167 ta.setFrom(departureLocation); 168 ta.setTo(arrivalLocation); 169 ta.setDate(date); 170 ta.setFreeSpace(noSeats); 171 ta.setTime(departureHour); 172 transportDao.editTransportAvailable(ta); 149 173 } 150 174 151 175 @Override 152 176 public void deleteTransportReservation(long reservationID) { 153 transportDao.deleteTransportReservation(reservationID); 177 TransportReservation tr=findTransportReservationByID(reservationID); 178 transportDao.deleteTransportReservation(tr); 154 179 } 155 180 156 181 @Override 157 182 public void deleteTransportAvailable(long availableID) { 158 transportDao.deleteTransportAvailable(availableID); 183 TransportAvailible ta=findTransportAvailableByID(availableID); 184 transportDao.deleteTransportAvailable(ta); 159 185 } 160 186 161 187 @Override 162 188 public void createTransportRoute(TransportAvailible parentRoute, String from, String to, double price, Date departure, Date arrival, int freeSpace, int order) { 163 transportDao.createTransportRoute(parentRoute, from, to, price, departure, arrival, freeSpace, order); 189 TransportRoute tr = new TransportRoute(parentRoute, from, to, price, departure, arrival, freeSpace, order); 190 191 transportDao.createTransportRoute(tr); 164 192 } 165 193 166 194 @Override 167 195 public void deleteTransportRoute(long transportRouteId) { 168 transportDao.deleteTransportRoute(transportRouteId); 196 TransportRoute tr = transportDao.findTransportRouteById(transportRouteId); 197 transportDao.deleteTransportRoute(tr); 169 198 } 170 199 171 200 @Override 172 201 public void editTransportRoute(long transportRouteId, TransportAvailible parentRoute, String from, String to, double price, Date departure, Date arrival, int freeSpace, int order) { 173 transportDao.editTransportRoute(transportRouteId, parentRoute, from, to, price, departure, arrival, freeSpace, order); 202 TransportRoute tr = transportDao.findTransportRouteById(transportRouteId); 203 tr.setParentRoute(parentRoute); 204 tr.setFrom(from); 205 tr.setTo(to); 206 tr.setPrice(price); 207 tr.setDeparture(departure); 208 tr.setArrival(arrival); 209 tr.setFreeSpace(freeSpace); 210 tr.setOrder(order); 211 transportDao.editTransportRoute(tr); 174 212 } 175 213 … … 179 217 List<TransportReservation> reservations = transportDao.findReservationByUser(u); 180 218 return reservations.stream().map(x -> new TransportReservationUserDto( 219 x.getReservationID(), 181 220 x.getUser(), 182 221 x.getTransportRoute(), … … 195 234 List<TransportReservation> reservations = transportDao.findPastReservationByUser(u); 196 235 return reservations.stream().map(x -> new TransportReservationUserDto( 236 x.getReservationID(), 197 237 x.getUser(), 198 238 x.getTransportRoute(), … … 206 246 } 207 247 248 @Override 249 public void setReservationReviewed(Long reservationId) { 250 TransportReservation transportReservation = findTransportReservationByID(reservationId); 251 transportReservation.setReviewed(true); 252 transportDao.saveReservation(transportReservation); 253 } 254 208 255 } 209 256 -
src/main/java/com/tourMate/services/impl/UsersManagerImpl.java
r5528b99 r07f4e8b 45 45 46 46 @Override 47 public List<User> getUnapprovedUsers() { 48 return usersDao.getUnapprovedUsers(); 49 } 50 51 @Override 52 public void approveUserProfile(long userId) { 53 User u = findUserByID(userId); 54 usersDao.approveUserProfile(u); 55 } 56 57 @Override 58 public void unlock(Long id) { 59 User u = findUserByID(id); 60 u.setLocked(!u.isLocked()); 61 u.setEnabled(true); 62 usersDao.updateUser(u); 63 } 64 65 @Override 47 66 public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { 48 67 return usersDao.findUserByUsername(username);
Note:
See TracChangeset
for help on using the changeset viewer.