JPA+Tutorial+3+-+The+Problem

We want to implement a simple system to track books and eventually other resources for a library. This page covers the requirements for Version 1. The problem as stated is bigger than what this tutorial implements. Parts are left as exercises that are scheduled into a course or advanced exercises for students who finish their work early.

Checking out a Book
A Patron checks out one or more books, all of which are due 14 days later.
 * Description**


 * Basic Course of Events**
 * 1) This use case begins when a Patron identifies him or herself by entering their Patron ID.
 * 2) The system verifies that the Patron exists and is in good standing.
 * 3) The system asks the Patron to enter the first resource.
 * 4) The patron provides the book identifier (each book has a unique identifier because the ISBN is not enough, we need to know WHICH version of Catcher int the Rye the Patron is checking out)
 * 5) The system records the book, calculates the due date and records the book as on loan to the Patron.
 * 6) The use case ends.


 * Alternatives**
 * Num**||**Step**||**Description**||
 * 1||2||The Patron is not in good standing, they have overdue books. Do not allow them to check out any other books until they return all overdue books||
 * 2||2||The Patron is not in good standing, they have fines from overdue books they now paid. Do not allow them to check out any books until they pay their fines.||
 * 3||2||The Patron is not found (maybe their account was removed due to inactivity). Do not allow the to check out any books||
 * 4||5||The Book is not found, log the book and tell the Patron to ask for assistance with the particular book.||
 * 5||5||The Book is a reserve book and cannot be checked out. Inform the Patron.||
 * 6||5||The due date falls on a day when the Library is not open, move the return date to the next date the library is open.||

Returning a Book
A Patron returns a book. The library computes any fines and removes the recording of the loan of the book.
 * Description**


 * Basic Course of Events**
 * 1) This use case begins when a Patron returns a book. The Patron identifies the book by providing the book identifier.
 * 2) The system retrieves the loan information for the book.
 * 3) The system updates the book as being returned and indicates success to the Patron.
 * 4) The patron indicates they are finished returning books.
 * 5) The system reports the total of any fines for the books returned as well as any pending fines.
 * 6) The system asks the user if they would like to pay their fines.
 * 7) The user indicates the do: **Initiate: Paying Fines**
 * 8) The use case ends.


 * Alternatives**
 * Num**||**Step**||**Description**||
 * 1||2||The book is not on loan, inform the user.||
 * 2||3||The book is late, calculate a fine and inform the user of a fine.||
 * 3||5||The user owes no fines, the use case ends.||
 * 4||6||The user indicates they do not want to pay fines right now. The system informs them they will not be able to checkout books until all fines are paid and the use case ends.||

Adding a Book
A Librarian wishes to add a new book into the system.
 * Description**


 * Basic Course of Events**
 * 1) The Librarian indicates they want to add a new Book.
 * 2) The system asks the Librarian to provide book information (Book Title, Authors, ISBN, replacement cost)
 * 3) The Librarian provides the book information.
 * 4) The system validates the information.
 * 5) The system creates a new book and assigns the book a unique identifier.
 * 6) The system indicates the unique identifier for the book (and prints a book label)
 * 7) The use case ends.

No alternatives listed for this use case.
 * Alternatives**

Removing a Book
The Librarian wishes to take a book out of the system and make it no longer available for checkout.
 * Description**


 * Basic Course of Events**
 * 1) The Librarian indicates they want to remove a book.
 * 2) The system asks the librarian for the book identifier.
 * 3) The Librarian provides the book identifier.
 * 4) The system validates the book identifier and book.
 * 5) The system removes the book from the system and indicates success.


 * Alternatives**
 * Num**||**Step**||**Description**||
 * 1||3||The book identifier is not found. Indicate the error. The use case ends.||
 * 2||4||The book is on loan. Remove the loan (ignoring any fines). Indicate the error to the user but complete the use case normally.||
 * 3||4||This is the last book with the that particular ISBN. Ask the user to confirm the removal. If confirmed, complete the use case normally. If not confirmed, do not remove the book. Either way, the use case ends.||

Adding a Patron
A Librarian adds a new Patron into the system.
 * Description**


 * Basic Course of Events**
 * 1) The Librarian indicates they wish to add a new Patron to the system.
 * 2) The system asks the Librarian to provide the Name (first, mi, last), Address (street 1, street 2, city, state, zip), and Phone number(area code + 7 digits).
 * 3) The system verifies the minimal information is provided.
 * 4) The system creates a new Patron and assigned a Patron ID.
 * 5) The system provides the new Patron ID back to the Librarian (and prints a card).
 * 6) The use case ends.


 * Alternatives**
 * Num**||**Step**||**Description**||
 * 1||3||Some required information is missing. Indicate the required information and ask the Librarian to perform it. Continue back at step 2.||

Removing a Patron
The Librarian wants to remove a Patron.
 * Description**


 * Basic Course of Events**
 * 1) The Librarian indicates they want to remove a Patron.
 * 2) The system asks for the Patron's id.
 * 3) The Librarian provides the id.
 * 4) The system validates the id.
 * 5) The system removes the Patron from the system.


 * Alternatives**
 * Num**||**Step**||**Description**||
 * 1||3||The id is not found. Indicate the error to the user and continue at step 2||
 * 2||3||The Patron has outstanding fines. Indicate this to the Librarian and ask to confirm the removal. If confirmed, remove and complete the use case normally. If not confirmed, end the use case without removing the Patron.||
 * 3||3||The Patron has outstanding loans. Indicate this to the Librarian and do not allow removal.||

Paying Fines
A Patron wishes to pay fines. Note that this use case can be invoked by itself or called from other use cases.
 * Description**


 * Basic Course of Events**
 * 1) A Patron is identified and their fines calculated.
 * 2) The system asks for the amount tendered.
 * 3) The system determines the difference and indicates the difference to the user.
 * 4) The use case ends.


 * Alternatives**
 * Num**||**Step**||**Description**||
 * 1||1||The identified Patron has no fines. Indicate this to the user and the use case ends.||
 * 2||4||If there is still a balance, the system asks if it should ask for additional reimbursements. If yes, they go back to step 2, otherwise the use case ends.||

Record a Book as Unrecoverable
A book is not going to be returned/recovered. Add a fine if the book is on loan.
 * Description**


 * Basic Course of Events**
 * 1) This use case begins when a book is going to indicated as not returnable.
 * 2) The system asks the user to provide the book id and a reason.
 * 3) The user provides the id and reason.
 * 4) The system retrieves the book.
 * 5) The system calculates the replacement cost assigns it to the Patron who has it checked out.
 * 6) The book is removed from the system.


 * Alternatives**
 * Num**||**Step**||**Description**||
 * 1||3||The book id is not known. Retrieve a list of books checked out to a Patron, select from the list and continue to step 3.||
 * 2||3||The book id is not known. Provide the isbn. Select the user who has the book checked out and select the book by id. Continue at step 3.||
 * 3||3||The book id is not known. Provide the title. Select the user who has the book checked out and select the book by id. Continue at step 3.||
 * 4||5||The book is not checked out, do not calculate any fines.||

Reviewing all Checkouts for a Patron
Report all of the books currently checked out by a Patron. Provide the title, isbn and due date. Sort by due date, with the book due the soonest at the beginning. If the user has an outstanding balance, indicate that as well.
 * Description**

Reviewing all Fines for all Patrons
Present a list of all the patrons with fines. Sort by the last name followed by the first name. Provide the name of the user, their phone number and their total balance.