程序代写代做代考 Java javascript JDBC case study database chain Hotel Booking System Case Study Overview of the Application

Hotel Booking System Case Study Overview of the Application
You are the technical team leader working with SCS (Singapore Computer Systems). You are an expert in building web solutions based on various technical stacks. Recently, you have done a couple of successful projects using the Spring framework on full stack apps performing, end-to-end layering, microservice design and implementation.
Hence the SCS project manager approaches you to help her with a hotel booking solution for a client in Malaysia. The client is Oriental chain of hotels that has pan Asia presence. For more than 10 years Oriental have been in hotel business in more than a dozen busy Asian cities offering affordable stay services and function hosting services. They decided to launch an online application to increase hotel booking efficiency via a low cost system implementation in public cloud. They have approached you to help them in this project. As a tech lead, you decided to code the application using Spring Boot as a reactive web application. You also want to apply the agile practices that you have been trained at ISS.
You plan to create a simple booking application that will allow hotel staff as well users (i.e., customers) to self-register themselves as well as book rooms. The application is referred to as HBS in short. For starters, you focused on building a Minimal Viable Prototype using MVC. Within the coming two sprints you plan to release a better version of the prototype that will be used by the stakeholders to understand how process automation will happen.
As of now, Information stored regarding a hotel includes identifier, room number and floor. The total number of rooms per floor and number of floors in the hotel are preset via the Hotel Setup screen. Room reservation includes room identifier and the guest information. From the many requirements listed by stakeholders, you decide to focus on better profiling of hotel and room for the MVP design.
Technical Requirements
This HBS web application will use an embedded database for persistence, Spring Data JPA for a model, Spring Thymeleaf for a view, Spring Web MVC for controllers and Spring Reactive for Asynchronous communication.
Tools and Frameworks
In order to implement the HBS web application using Spring Boot, the following build tools need to be downloaded and installed:
• Java Development Kit.
• Maven Tool for Automated Build and Test.
• Spring Boot and STS IDE for development and testing support.
• Spring Web Framework including MVC and Data
• Spring WebSocket Framework including Mono and Flux.

You have identified the following framework to be used while developing this HBS application.
• Using Spring Data JPA for persistence.
• Using Thymeleaf for view.
• Using Spring Web MVC with support for servlet as the controller.
• Using Spring Web Sockets and mono to support asynchronous communication.
The Use Case diagram
The requirements, design, and implementation details will be discussed in brief using use case diagram and class diagram. The following use case diagram shows the requirement for the hotel booking system (HBS):
The actor is the admin of the car rental system. He/she is responsible for all operations in the system. The following use cases are marked for release in the first two sprints:
• Browse Available Rooms: This is required to view rooms that are available for booking today.
• Make a Booking: This is where both customer and staff can make a booking using minimal information such as room number and customer name.
• View Unoccupied Rooms: View all the unoccupied room for today.

• View Occupancy List: View the various rooms and the respective occupancy details for today.
All actions need authentication and authorization to identify users and relate the rental requests they make. All booking records need to be saved based on the booking dates and should be retrievable based on the current date (today) also.
Class Diagram
A well-built domain model can easily support multiple business logic and can run an application on limited resources efficiently. A simplified class diagram for this HBS web application is discussed for the prototype.
There are two main models namely, Car and User. Some additional information is provided below as follows:
• Customer/Staff: This is the main domain model, which will represent the two key actors in the system.
• HotelRooms: This is the inventory of all rooms in the hotel with detailed description, location and floor.
• RoomBooking: This is the second transactional class, which will store the HotelRoom id, occupying customer id, booking date range, and other relevant details.

UI Screens
The UI will consist of main menu screen. HBS system will have separate registration screens for customer and staff. Also there is an extension screen for customer that allows them book a room and view that booking only. The UI has an additional requirement where it needs to refresh every 30 seconds to see updated content from others. This UI will be implemented in a responsive way so that it can be used in desktop devices as well as mobile devices. Thymeleaf framework will be used to implement the aforementioned UI design with standard HTML 5, CSS3, and a bit of JavaScript. After running, the HBS application the current sample screens are as shown below:
Main Screen
Add Booking Screen

Show Occupied Rooms
Show Available Rooms
Show All Rooms

Code Fragments
Configuration
The following configuration properties in theapplication.propertiesfile is set to configure DataSource:
Domain Model
Partial codes for unmapped classes from the model package are shown below:
HotelRooms.java
spring.jpa.hibernate.ddl-auto=create spring.jpa.properties.hibernate.format_sql=true spring.jpa.properties.hibernate.show_sql=true
spring.datasource.driver-class-name=org.h2.Driver spring.datasource.url=jdbc:h2:~/carrental spring.datasource.username=sa spring.datasource.password=
public class HotelRooms {
private Long id;
private int room;
private int floor;
private String description; private RoomState roomState;
.. . }
RoomState.java
RoomBooking.java
package com.hbs.model;
public enum RoomState {
AVAILABLE, OCCUPIED, MAINTENANCE, CLEANING }
public class RoomBooking {
private Long id;

private int floor;
private String guestName;
private String guestSurname;
private RoomState roomState;
private Date bookingFrom;
private Date bookingTo;
private Date bookingDate;
… }
Staff.java
package com.hbs.model;
public class Staff {
private int id;
private String firstName;
private String lastName;
private String userId;
private String password; …
}
Customer.java}
package com.hbs.model;
public class Staff {
private int id;
private String firstName;
private String lastName;
private String userId;
private String password; …
}

HbsServiceImpl.java
@Service
public class HbsServiceImpl implements HbsService {
@Autowired
private HbsRepository hbsRepository;
@Override
public String addBooking(RoomBooking roomBooking) {
RoomBooking currentRoomStatus = hbsRepository.findById(roomBooking.getId()).get();
if(currentRoomStatus.getRoomState() .equals(RoomState.AVAILABLE)){
roomBooking.setRoomState(RoomState.OCCUPIED); hbsRepository.save(roomBooking);
return “index”;
} else {
return “unavailable”;
}
} . .} .
HbsController.java
package com.hbs.controller;
@Controller @RequestMapping(“/hbs”) public class HbsController {
@Autowired
private HbsService hbsService;
@RequestMapping(“/”) public String startPage(){
return “index”;
}
@RequestMapping(value = “/showBookingForm”, method = RequestMethod.GET)
public String showFormForAdd(Model model) { //Complete this method

}
. .. }
}
@RequestMapping(value = “/addBooking”, method = RequestMethod.POST)
public String addBooking(
@ModelAttribute RoomBooking roomBooking) {
//Complete this method