HTML and CSS Reference
In-Depth Information
@Override
public void approveBookRequest(Integer bookRequestNumber) throws BookRequestNotFound {
BookRequest updatableBookRequest = em.find(BookRequest.class, bookRequestNumber);
if (updatableBookRequest == null) {
throw new BookRequestNotFound();
}
updatableBookRequest.setStatus(Constants.APPROVED_REQUEST); //approved status
updatableBookRequest.setResponseTime(System.currentTimeMillis());
em.merge(updatableBookRequest);
em.flush();
}
@Override
public void rejectBookRequest(Integer bookRequestNumber) throws BookRequestNotFound {
BookRequest updatableBookRequest = em.find(BookRequest.class, bookRequestNumber);
if (updatableBookRequest == null) {
throw new BookRequestNotFound();
}
updatableBookRequest.setStatus(Constants.REJECTED_REQUEST); //rejected status
updatableBookRequest.setResponseTime(System.currentTimeMillis());
em.merge(updatableBookRequest);
em.flush();
}
//...
}
The first methods of
BookRequestManager
EJB are as follows:
•
sendBookRequest
: Creates a book request in the
BOOK_REQUEST
table setting its status to
1
(which refers to pending) and the request time to the current system time. It throws
BookRequestAlreadyExists
exception if the user has already sent a request for the
target book.
•
approveBookRequest
: Sets the topic request status to
3
(which refers to approved) and the
response time to the current system time. It throws
BookRequestNotFound
exception if the
target book request is not found.
rejectBookRequest
: Sets the topic request status to
2
(which refers to rejected) and the
response time to the current system time. It throws
BookRequestNotFound
exception if the
target book request is not found.
Listing 13-13 shows the second part of
BookRequestManager
EJB class.
•