Question: In the previous week you were tasked to create the model layer, an abstract level of the Data layer and a concrete UserArrayListDAO. This week

In the previous week you were tasked to create the model layer, an abstract level of the Data layer and a concrete UserArrayListDAO. This week we will add a service layer to the BookStore project which will have associations with the abstract Data layer types. 2 Task 3 Change your DAO layer to look like the below diagram Convert the Removeable, Persistable and Searchable interface to be of Generic types 3 Task 4 Start implementing the classes provided in the class diagram below The services have an association with the repositories in the DAO layer You will have to implement the service methods to provide the required functionality as described below Strictly follow the naming conventions provided in the Class diagrams Service Classes: Model Classes should be in package: com.fdmgroup.bookstore.service 1. Implement AuthenticationService: a. authenticate(..): The authenticate method will first validate the user with the UserRepository validate(..) method, then if the credentials are valid, it will ask for the user from the UserRepository by calling the findByUsername(username) method passing it the username. If the user is authenticated it will return the User object to the calling class otherwise it will throw a UserNotFoundException. b. findById(..): method finds a User by ID using the UserRepository findById method. It should throw a UserNotFoundException if the ID does not belong to a user in the DB. 2. Implement BookService: a. getAllBooks(): will return the list of books it gets from the BookRepositorys findAll() method. b. getBooksOfGenre(BookGenre bookGenre): This will return a list of all books belonging to the bookGenre. c. searchBooksByTitle(String title): Returns a list of all books with a tile that matches the title passed in. d. searchBooksByAuthorName(String bookAuthorNameToSearch): Returns a list of all books where the author contains the bookAuthorNameToSearch. That means that if the bookAuthorNameToSearch is isaac it should match books where the author is Isaac Asimov, Jane Isaacson, and any book that has an author with the string isaac in the name, case insensitive. You may want to use regular expressions for this. e. findById(..): find a book by itemId using the BookRepository findById method. Should throw an ItemNotFoundException if the book id does not exist in the database. 3. Implement OrderingService: a. placeOrder(Book Book, User customer): First validates that the Book and User exist by using the BookService and AuthenticationService findById methods. If either of those are not found then it should catch the ItemNotFoundException or the UserNotFoundException that those methods throw. If both are valid, meaning neither of the findById methods throw a NotFoundException, then creates an Order object adding in the current system date-time, then persists the order using the OrderRepository and returns the created Order. Note that the orderId should be automatically created. b. placeOrders(..): should build a list of orders in a similar way as what is described above for the placeOrder(..) method, if the customer or any of the books is not valid then the method does not handle the exception and instead declares that it might throw it. Once the list of orders is built it and we know all are valid (cause no exceptions where thrown) then use the OrderRepository to persist the orders. c. getOrdersForUser(User user): Finds the list of orders for the provided user. d. getOrdersForBook(Book Book): Finds all orders for the passed in book. 4. Strictly follow the naming conventions provided in the Class diagrams 5. Add a test class for each of the Services and fully test each method. Note: The Service layer should have a 100% test coverage and only the abstract DAO Layer is to be used. You cannot use the UserArrayListRepository created in the last phase.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!