Changeset 5528b99 for src/main/java/com


Ignore:
Timestamp:
01/16/24 16:34:03 (10 months ago)
Author:
darsov2 <62809499+darsov2@…>
Branches:
master
Children:
07f4e8b
Parents:
e6c2521
Message:

revert

Location:
src/main/java/com/tourMate
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/tourMate/config/SecurityConfig.java

    re6c2521 r5528b99  
    77import org.springframework.http.HttpHeaders;
    88import org.springframework.http.HttpMethod;
    9 import org.springframework.http.HttpStatus;
    109import org.springframework.security.config.annotation.web.builders.HttpSecurity;
    1110import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
     
    1514import org.springframework.security.web.SecurityFilterChain;
    1615import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
    17 import org.springframework.security.web.authentication.logout.HttpStatusReturningLogoutSuccessHandler;
    1816import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
    1917import org.springframework.web.cors.CorsConfiguration;
     
    7674                                        .anyRequest().authenticated()
    7775                                        .and()
    78                                         .formLogin()
     76                                        .formLogin().loginPage("http://localhost:3000/login")
    7977                                        .loginProcessingUrl("/api/login").usernameParameter("username").passwordParameter("password")
    8078                                        .successHandler((request, response, authentication) -> {
    8179                                            response.setStatus(HttpServletResponse.SC_OK);
    82                                             response.setCharacterEncoding("UTF-8");
    8380                                            response.setContentType("application/json");
    8481                                            response.getWriter().print("{\"message\": \"Login successful\",");
     
    8885                                        .failureHandler((request, response, exception) -> {
    8986                                            response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    90                                             response.sendRedirect("/login");
    91                                             response.getWriter().print("Neuspesna najava\n" + exception.getMessage());
     87                                            response.getWriter().print("Pukla veza\n" + exception.getMessage());
    9288                                            response.getWriter().flush();
    9389                                        })
     
    9793                                        .sessionCreationPolicy(SessionCreationPolicy.ALWAYS)
    9894                                        .and()
    99                                         .logout().logoutSuccessHandler((new HttpStatusReturningLogoutSuccessHandler(HttpStatus.OK)))
     95                                        .logout()
    10096                                        .permitAll();
    10197
  • src/main/java/com/tourMate/controllers/HotelController.java

    re6c2521 r5528b99  
    22
    33import com.tourMate.dto.HotelDto;
    4 import com.tourMate.dto.HotelReservationDto;
    5 import com.tourMate.dto.HotelReservationUserDto;
    64import com.tourMate.entities.*;
    75import com.tourMate.services.HotelManager;
     
    106104    //HOTEL ROOM CRUD
    107105    @PostMapping(path = "/hotel/rooms/add")
    108     public void addRoom(@RequestBody HotelRoom room,
    109                         @RequestParam(name = "hotelId") long hotelId) {
     106    public void addRoom(@RequestBody HotelRoom room, @RequestParam(name = "hotelId") long hotelId) {
    110107        Hotels h = hotelManager.findHotelByID(hotelId);
    111         hotelManager.createRoom(h, room.getHotelRoomDescription(), room.getHotelRoomName(), room.getKitchenAvailable(), room.getAirConditioning(), room.getBalcony(), room.getPrice(), room.getNumOfBeds());
     108        hotelManager.createRoom(h, room.getHotelRoomDescription(), room.getHotelRoomName(), room.getKitchenAvailable(), room.getAirConditioning(), room.getBalcony(), room.getPrice());
    112109    }
    113110
     
    152149        //HOTEL AVAILABILITY CRUD
    153150    @PostMapping(path = "/hotel/rooms/available/{id}/add")
    154     public void addRoomAvailible(@RequestBody HotelRoomAvailable hotelRoomAvailable,
    155                                  @PathVariable long id)
     151    public void addRoomAvailible(@RequestBody HotelRoomAvailable hotelRoomAvailable, @PathVariable long id)
    156152    {
    157153        HotelRoom hotelRoom = hotelManager.findRoomById(id);
     
    182178    public List<HotelRoomAvailable> getRoomAvailability(@PathVariable Long id)
    183179    {
    184         return hotelManager.getRoomsAvailableById(id);
     180        return hotelManager.getRoomsAvailibility();
    185181    }
    186182
    187183    @GetMapping(path = "/hotel/search")
    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)
     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)
    192186    {
    193187        System.out.println(hotelLocation);
     
    209203    }
    210204
     205<<<<<<< HEAD
    211206    @GetMapping(path = "/hotel/{id}/reservations/active")
    212207    public List<HotelReservationDto> getActiveReservationsForHotel(@PathVariable Long id)
     
    238233        return hotelManager.getRoomImages(id);
    239234    }
     235=======
     236>>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl)
    240237}
  • src/main/java/com/tourMate/controllers/TransportController.java

    re6c2521 r5528b99  
    2020
    2121    // TRANSPORT CRUD //
    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());
     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());
    2625
    2726    }
     
    4645    public TransportDto getTransport(@PathVariable(name = "id") long transportId)
    4746    {
     47        System.out.println("TUKA SUUUUUM");
    4848        return transportManager.findTransportById(transportId);
    4949    }
     
    8484    @PostMapping(path = "/transport/available/add")
    8585    public void add(@RequestBody TransportAvailible transportAvailable, @RequestParam(name = "transportId") long transportId) {
     86        System.out.println("OREEEEEL");
     87        System.out.println("DVA ORLA");
    8688        Transport t = transportManager.getTransportById(transportId);
    8789        List<TransportRoute> routes = transportAvailable.getRoutes().stream().toList();
     
    125127
    126128    @GetMapping(path = "/transport/search")
    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);
     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);
    132132    }
    133133
  • src/main/java/com/tourMate/controllers/UsersController.java

    re6c2521 r5528b99  
    1111import org.springframework.web.bind.annotation.*;
    1212
     13import java.util.ArrayList;
    1314import java.util.List;
    1415
     
    3839    {
    3940        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);
    6841    }
    6942
  • src/main/java/com/tourMate/dao/BusinessDao.java

    re6c2521 r5528b99  
    1111    @Transactional
    1212    void createBusiness(Business business, long userId);
    13     List<Business> getUnapprovedBusinessesOfUser(long userId);
    14     void deleteBusiness(long businessId);
    15     List<Business> getCreatedBusinesses();
    16     Business findBusinessById (long businessId);
     13    public List<Business> getUnapprovedBusinessesOfUser(long userId);
     14    public void deleteBusiness(long businessId);
     15    public List<Business> getCreatedBusinesses();
     16    public Business findBusinessById (long businessId);
    1717
    1818    @Transactional
    1919    void editBusiness(long businessId, String name, String phone, String address, String edbs, User user, boolean approved);
    20     boolean hasBusiness(long userId);
     20    public boolean hasBusiness(long userId);
    2121
    22     List<Business> getUnapprovedBusinesses();
    23 
    24     void approveBusiness(Business business);
    2522}
  • src/main/java/com/tourMate/dao/HotelDao.java

    re6c2521 r5528b99  
    2222    public List<HotelRoomImages> getRoomImages(HotelRoom hotelRoom);
    2323
    24     public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price, int numOfBeds);
     24    public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price);
    2525    public void editRoom(long hotelRoomId, Hotels hotel, String hotelRoomDescription, String HotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price);
    2626    public void deleteRoom(long hotelRoomId);
  • src/main/java/com/tourMate/dao/TransportDao.java

    re6c2521 r5528b99  
    1212public interface TransportDao {
    1313
    14     public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, Long userId, String carPlate);
     14    public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate);
    1515
    1616    public void deleteTransport(long transportId);
     
    4747    public List<TransportAvailible> getTransportsAvailable();
    4848
    49     public List<TransportRoute> getTransportsAvailableByFilters (String from, String to, Date date, int numPassengers);
     49    public List<TransportRoute> getTransportsAvailableByFilters (String from,String to,Date date);
    5050
    5151    public void createTransportRoute(TransportAvailible parentRoute, String from, String to, double price, Date departure, Date arrival, int freeSpace, int order);
  • src/main/java/com/tourMate/dao/UsersDao.java

    re6c2521 r5528b99  
    2323
    2424    UserDetails findUserByUsername(String username);
    25 
    26     List<User> getUnapprovedUsers();
    27 
    28     void approveUserProfile(User u);
    2925}
  • src/main/java/com/tourMate/dao/impl/BusinessDaoImpl.java

    re6c2521 r5528b99  
    4646    }
    4747
    48     @Override
    49     public List<Business> getUnapprovedBusinesses() {
    50         return em.createQuery("select b from Business b where not b.approved").getResultList();
    51     }
    52 
    53     @Override
    54     @Transactional
    55     public void approveBusiness(Business b) {
    56         b.setApproved(true);
    57         em.persist(b);
    58     }
    59 
    6048
    6149    @Override
  • src/main/java/com/tourMate/dao/impl/HotelDaoImpl.java

    re6c2521 r5528b99  
    2828    public List<Hotels> getHotels() {
    2929        List<Hotels> hoteli = em.createQuery("select h from Hotels h order by h.hotelId").getResultList();
     30        System.out.println("OREEEEEEL");
    3031        return hoteli;
    3132        //return em.createQuery("select h from Hotels h order by h.hotelId").getResultList();
     
    122123    @Transactional
    123124    @Override
    124     public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price, int numOfBeds) {
    125         HotelRoom hotelRoom = new HotelRoom(hotel, hotelRoomDescription, hotelRoomName, kitchenAvailable, airConditioning, balcony, price, numOfBeds);
     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);
    126127        em.persist(hotelRoom);
    127128    }
     
    191192    public List<HotelRoomAvailable> getRoomsAvailibilityByDateAndLocation(String hotelLocation, Date dateFrom, Date dateTo, int numberOfBeds) {
    192193        return em.createQuery("select hr from HotelRoomAvailable hr where hr.dateFrom <= :dateFrom and hr.dateTo >= :dateTo " +
     194<<<<<<< HEAD
    193195                        "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)
    194199                .setParameter("hotelLocation", hotelLocation)
    195200                .setParameter("dateFrom", dateFrom)
     
    240245    public List<HotelRoomReservations> findReservationByHotel(Hotels hotel) {
    241246        List<HotelRoom> hotelRooms = getRoomsOfHotel(hotel.getHotelId());
    242         return em.createQuery("select hr from HotelRoomReservations hr where hr.hotelRoom.hotel = :hotel").setParameter("hotel", hotel).getResultList();
     247        return em.createQuery("select hr from HotelRoomReservations hr where hr.hotelRoom in :hotelRooms").setParameter("hotelRooms", hotelRooms).getResultList();
    243248    }
    244249
  • src/main/java/com/tourMate/dao/impl/TransportDaoImpl.java

    re6c2521 r5528b99  
    2222    @Override
    2323    @Transactional
    24     public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, Long userId, String carPlate) {
    25         User u = em.find(User.class, userId);
     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);
    2626        Transport t=new Transport(transportName,carBrand,carType,carManufacturedYear,noPassengers,noBags,EMBG,u,carPlate);
    2727        em.persist(t);
     
    6262                        y.getFreeSpace(),
    6363                        y.getTime(),
    64                         y.getRoutes(),
    65                         y.getRoutes().stream()
    66                                 .mapToDouble(TransportRoute::getPrice)
    67                                 .max().orElse(0)
    68                 )).toList(),
    69                 x.getAvailableRoutes().stream()
    70                         .flatMapToDouble(y -> y.getRoutes()
    71                                 .stream()
    72                                 .mapToDouble(TransportRoute::getPrice)).max().orElseGet(() -> 0)
     64                        y.getRoutes()
     65                )).toList()
    7366        )).toList();
    7467    }
     
    8578                x.getFreeSpace(),
    8679                x.getTime(),
    87                 x.getRoutes(),
    88                 x.getRoutes().stream()
    89                         .mapToDouble(TransportRoute::getPrice)
    90                         .max().orElse(0)
     80                x.getRoutes()
    9181        )).toList();
    9282    }
     
    113103                        y.getFreeSpace(),
    114104                        y.getTime(),
    115                         y.getRoutes(),
    116                         y.getRoutes().stream()
    117                                 .mapToDouble(TransportRoute::getPrice)
    118                                 .max().orElse(0)
    119                 )).toList(),
    120                 x.getAvailableRoutes().stream()
    121                         .flatMapToDouble(y -> y.getRoutes()
    122                                                         .stream()
    123                                                         .mapToDouble(TransportRoute::getPrice)).max().orElseGet(() -> 0));
     105                        y.getRoutes()
     106                )).toList());
    124107    }
    125108
     
    167150
    168151    @Override
    169     public List<TransportRoute> getTransportsAvailableByFilters(String fromL, String toL, Date date, int numPassengers) {
     152    public List<TransportRoute> getTransportsAvailableByFilters(String fromL, String toL, Date date) {
    170153        System.out.println(fromL + " " + toL);
    171         return em.createQuery("select h from TransportRoute h where h.from = :froml and h.to = :tol and h.freeSpace >= :nump")
    172                 .setParameter("froml", fromL)
    173                 .setParameter("tol", toL)
    174                 .setParameter("nump", numPassengers)
    175                 .getResultList();
     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();
    176156    }
    177157
  • src/main/java/com/tourMate/dao/impl/UsersDaoImpl.java

    re6c2521 r5528b99  
    7474    }
    7575
    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     }
    8776
    8877
  • src/main/java/com/tourMate/dto/RouteListingDto.java

    re6c2521 r5528b99  
    1818    private Date time;
    1919    private Collection<String> routes;
    20     private Double maxPrice;
    2120
    22     public RouteListingDto(long transportAvailibleId, String from, String to, Date date, int freeSpace, Date time, Collection<TransportRoute> routes, Double maxPrice) {
     21    public RouteListingDto(long transportAvailibleId, String from, String to, Date date, int freeSpace, Date time, Collection<TransportRoute> routes) {
    2322        this.transportAvailibleId = transportAvailibleId;
    2423        this.from = from;
     
    2827        this.time = time;
    2928        this.routes = routes.stream().map(x -> x.getFrom()).distinct().skip(1).toList();
    30         this.maxPrice = maxPrice;
    3129    }
    3230
     
    8684        this.routes = routes;
    8785    }
    88 
    89     public Double getMaxPrice() {
    90         return maxPrice;
    91     }
    9286}
  • src/main/java/com/tourMate/dto/TransportDto.java

    re6c2521 r5528b99  
    1616    private User owner;
    1717    private String carPlate;
    18     private Double maxPrice;
    1918    private Collection<RouteListingDto> availableRoutes;
    2019
    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) {
     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) {
    2221        this.transportID = transportID;
    2322        this.transportName = transportName;
     
    3130        this.carPlate = carPlate;
    3231        this.availableRoutes = availableRoutes;
    33         this.maxPrice = maxPrice;
    3432    }
    3533
  • src/main/java/com/tourMate/entities/Business.java

    re6c2521 r5528b99  
    8888    }
    8989
    90     @OneToOne(fetch = FetchType.EAGER)
     90    @OneToOne(fetch = FetchType.LAZY)
    9191    @JoinColumn(name = "owner_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_biznis_kon_korisnik"))
    9292    public User getUser() {
     
    107107        this.approved = approved;
    108108    }
    109 
    110109}
  • src/main/java/com/tourMate/entities/HotelRoom.java

    re6c2521 r5528b99  
     1<<<<<<< HEAD
    12package com.tourMate.entities;
    23
     
    159160    }
    160161}
     162=======
     163package com.tourMate.entities;
     164
     165import jakarta.persistence.*;
     166import com.fasterxml.jackson.annotation.JsonIgnore;
     167
     168import javax.validation.constraints.NotNull;
     169
     170@Entity
     171@Table(name="hotel_rooms", schema = "public")
     172public class HotelRoom {
     173    private long hotelRoomId;
     174    @JsonIgnore
     175    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    @Id
     222    @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    @NotNull
     244    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    @NotNull
     254    public double getPrice() {
     255        return price;
     256    }
     257
     258    @Column(name="hotel_room_name",unique = false,nullable = false)
     259    @NotNull
     260    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    @NotNull
     273    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    @NotNull
     282    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    @NotNull
     291    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

    re6c2521 r5528b99  
    4343    }
    4444
    45     @ManyToOne(fetch = FetchType.EAGER)
     45    @ManyToOne(fetch = FetchType.LAZY)
    4646    @JoinColumn(name = "room_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_roomres_kon_room"))
    4747    public HotelRoom getHotelRoom() {
     
    5959    }
    6060
    61     @OneToOne(fetch = FetchType.EAGER)
     61    @OneToOne(fetch = FetchType.LAZY)
    6262    @JoinColumn(name = "user_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_roomres_kon_user"))
    6363    public User getUser() {
  • src/main/java/com/tourMate/entities/Reviews.java

    re6c2521 r5528b99  
    7575
    7676    @ManyToOne(fetch = FetchType.LAZY)
    77     @JoinColumn(name = "hotel_id", unique = false, nullable = true, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_hotel"))
     77    @JoinColumn(name = "hotel_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_hotel"))
    7878    public Hotels getHotel () {
    7979        return hotel;
     
    8585
    8686    @ManyToOne(fetch = FetchType.LAZY)
    87     @JoinColumn(name = "restaurant_id", unique = false, nullable = true, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_restorani"))
     87    @JoinColumn(name = "restaurant_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_restorani"))
    8888    public Restaurant getRestaurant () {
    8989        return restaurant;
     
    9595
    9696    @ManyToOne(fetch = FetchType.LAZY)
    97     @JoinColumn(name = "transport_id", unique = false, nullable = true, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_transport"))
     97    @JoinColumn(name = "transport_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_transport"))
    9898    public Transport getTransport () {
    9999        return transport;
  • src/main/java/com/tourMate/entities/User.java

    re6c2521 r5528b99  
    5252    private Role role;
    5353    @Column(name = "locked", unique = false, nullable = false)
    54     boolean locked = false;
     54    boolean locked;
    5555
    5656    @Column(name = "enabled", unique = false, nullable = false)
     
    162162    @Override
    163163    public boolean isAccountNonLocked() {
    164         return locked;
     164        return true;
    165165    }
    166166
  • src/main/java/com/tourMate/services/BusinessManager.java

    re6c2521 r5528b99  
    99    public List<Business> getUnapprovedBusinessesOfUser(long userId);
    1010    public void deleteBusiness(long businessId);
    11     public List<Business> getUnapprovedBusinesses();
    12     public void approveBusiness(Long businessId);
     11    public List<Business> getCreatedBusinesses();
    1312    public Business findBusinessById (long businessId);
    1413    public void editBusiness(long businessId, String name, String phone, String address, String edbs, User user, boolean approved);
  • src/main/java/com/tourMate/services/HotelManager.java

    re6c2521 r5528b99  
    22
    33import com.tourMate.dto.HotelDto;
    4 import com.tourMate.dto.HotelReservationDto;
    5 import com.tourMate.dto.HotelReservationUserDto;
    64import com.tourMate.entities.*;
    75import org.springframework.web.multipart.MultipartFile;
     
    2624    public List<HotelRoom> getRoomsOfHotel (long hotelId);
    2725    public HotelRoom findRoomById (long hotelRoomId);
     26<<<<<<< HEAD
    2827    public List<HotelRoomImages> getRoomImages(Long hotelRoom);
    2928    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)
    3033    public void editRoom(long hotelRoomId, Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price);
    3134    public void deleteRoom(long hotelRoomId);
     35    public List<HotelRoomAvailable> getRoomsAvailable(Long id);
    3236    public void createRoomAvailible(HotelRoom hotelRoom, Date dateFrom, Date dateTo, int numberOfBeds);
    3337    public void editRoomAvailible(long hotelRoomAvailableId, HotelRoom hotelRoom, Date dateFrom, Date dateTo, int numberOfBeds);
     
    3640    public HotelRoomAvailable findAvailibleRoomById(long hotelRoomAvailableId);
    3741    public List<HotelRoomAvailable> getRoomsAvailibility();
    38     public List<HotelRoomAvailable> getRoomsAvailableById(Long id);
    3942    public List<HotelRoomAvailable> getRoomsAvailibilityByHotel(Hotels hotel);
    4043    public List<HotelDto> getRoomsAvailibilityByDateAndLocation(String hotelLocation, Date dateFrom, Date dateTo, int numberOfBeds);
     
    4245    public void editReservation(long hotelRoomReservedId, User user, HotelRoom hotelRoom, Date dateFrom, Date dateTo, Integer numberOfBeds);
    4346    public void deleteReservation(long hotelRoomReservedId);
    44     public List<HotelReservationDto> findVaidReseravtionsByHotel(Long hotelId);
    45     public List<HotelReservationUserDto> findValidHotelReservationsByUser(Long userId);
    4647    public HotelRoomReservations findReservationById(long hotelRoomReservedId);
    4748    public List<HotelRoomReservations> findReservationByUser(User user);
  • src/main/java/com/tourMate/services/TransportManager.java

    re6c2521 r5528b99  
    1313public interface TransportManager {
    1414
    15     public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, Long userId, String carPlate);
     15    public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate);
    1616
    1717    public void deleteTransport(long transportId);
     
    3535    public Transport getTransportById(long transportId);
    3636
     37<<<<<<< HEAD
    3738    List<Reviews> getReviewsForTransport(long transportId);
    3839
    3940    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)
    4044
    4145    public List<TransportReservation> getTransportsReservationsByUserID(long userID);
  • src/main/java/com/tourMate/services/UsersManager.java

    re6c2521 r5528b99  
    1616
    1717    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);
    2018}
  • src/main/java/com/tourMate/services/impl/BusinessManagerImpl.java

    re6c2521 r5528b99  
    3434
    3535    @Override
    36     public List<Business> getUnapprovedBusinesses() {
    37         return businessDao.getUnapprovedBusinesses();
     36    public boolean hasBusiness(long userId){
     37        return businessDao.hasBusiness(userId);
    3838    }
    3939
    4040    @Override
    41     public void approveBusiness(Long businessId) {
    42         Business b = findBusinessById(businessId);
    43         businessDao.approveBusiness(b);
    44     }
    45 
    46     @Override
    47     public boolean hasBusiness(long userId){
    48         return businessDao.hasBusiness(userId);
     41    public List<Business> getCreatedBusinesses() {
     42        return businessDao.getCreatedBusinesses();
    4943    }
    5044
  • src/main/java/com/tourMate/services/impl/HotelManagerImpl.java

    re6c2521 r5528b99  
    44import com.tourMate.dao.UsersDao;
    55import com.tourMate.dto.HotelDto;
    6 import com.tourMate.dto.HotelReservationDto;
    7 import com.tourMate.dto.HotelReservationUserDto;
    86import com.tourMate.entities.*;
    97import com.tourMate.services.HotelManager;
     
    1311
    1412import java.time.Duration;
     13import java.util.Collection;
    1514import java.util.Date;
    1615import java.util.List;
     
    109108
    110109    @Override
    111     public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price, int numOfBeds) {
    112         hotelDao.createRoom(hotel, hotelRoomDescription, hotelRoomName, kitchenAvailable, airConditioning, balcony, price, numOfBeds);
     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);
    113112    }
    114113
     
    123122    }
    124123
    125 
    126     @Override
    127     public List<HotelRoomAvailable> getRoomsAvailableById(Long id) {
     124    @Override
     125    public List<HotelRoomAvailable> getRoomsAvailable(Long id) {
    128126        return hotelDao.getRoomsAvailable(id);
    129127    }
     
    212210
    213211    @Override
     212<<<<<<< HEAD
    214213    public List<HotelReservationDto> findVaidReseravtionsByHotel(Long hotelId) {
    215214        Hotels hotel = findHotelByID(hotelId);
     
    245244
    246245    @Override
     246=======
     247>>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl)
    247248    public HotelRoomReservations findReservationById(long hotelRoomReservedId) {
    248249        return hotelDao.findReservationById(hotelRoomReservedId);
  • src/main/java/com/tourMate/services/impl/TransportManagerImpl.java

    re6c2521 r5528b99  
    2525
    2626    @Override
    27     public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, Long userId, String carPlate) {
    28         transportDao.createTransport(transportName, carBrand, carType, carManufacturedYear, noPassengers, noBags, EMBG, userId, carPlate);
     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);
    2929    }
    3030
     
    9393
    9494    @Override
     95<<<<<<< HEAD
    9596    public List<Reviews> getReviewsForTransport(long transportId) {
    9697        Transport transport = getTransportById(transportId);
     
    101102    public List<TransportListingDto> getTransportsAvailableByFilters(String from, String to, Date date, int numPassengers) {
    102103        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)
    103108        Map<TransportAvailible, List<TransportRoute>> transportsByTransporter = transportAvailable.stream().collect(Collectors.groupingBy(x -> x.getParentRoute()));
    104109        List<TransportListingDto> transportList = transportsByTransporter.keySet().stream().toList().stream()
  • src/main/java/com/tourMate/services/impl/UsersManagerImpl.java

    re6c2521 r5528b99  
    4545
    4646    @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
    5847    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
    5948        return usersDao.findUserByUsername(username);
Note: See TracChangeset for help on using the changeset viewer.