public class BookDAO extends Object
Constructor and Description |
---|
BookDAO()
Create a BookDAO.
|
Modifier and Type | Method and Description |
---|---|
void |
addAuthor(Book book,
Author author)
Adds
author to the authors of book . |
void |
addSubject(Book book,
Subject subject)
Adds
subject to the subjects associated with
book . |
ArrayList<Book> |
authorSearch(String authorLastName)
Returns a list of
Book instances whose author lists contain
an author with the given last name. |
boolean |
bookExists(long book)
Determines whether or not the ID provided corresponds to a book in the
library.
|
int |
countCopies(String isbn)
Counts the number of copies of the book, checked in or out, any location.
|
ArrayList |
dump()
Returns a list of all books in the library.
|
ArrayList<Author> |
getAuthors(Book book)
Returns an ArrayList consisting of the authors of the given book.
|
String |
getIsbn(long bookID)
Gets the ISBN of the book with the given ID if there is such a book,
null otherwise.
|
ArrayList<Subject> |
getSubjects(Book book)
Returns an ArrayList consisting of the subject classifications
associated with the the given book.
|
Book |
insert(Book book)
Inserts a book into the database and returns the result of retrieving
the inserted book.
|
ArrayList |
ownerSearch(long owner)
Returns a list of books owned by the reader with the given ID.
|
Book |
retrieve(long bookID)
Retrieves the book with the given ID, if there is such a book;
otherwise Null.
|
Book |
retrieve(String bookID)
Retrieves the book having the ID represented by the input string, if
there is such a book; otherwise Null.
|
Book |
retrieveByGenericCriteria(String sqlString,
Object[] criteria)
Retrieve Book by unique criteria from the database.
|
Book |
retrieveByIsbn(String isbn)
Retrieves the book having the given ISBN,
there is such a book; otherwise Null.
|
void |
setAuthorDAO(AuthorDAO authorDAO)
Used for Spring Dependency Injection
|
void |
setAuthors(Book book,
ArrayList<Author> authors)
Sets the list of authors associated with the given book.
|
void |
setCountCopiesSQL(String countCopiesSQL)
Used for Spring Dependency Injection
|
void |
setInsertBookAuthorSQL(String insertBookAuthorSQL)
Used for Spring Dependency Injection
|
void |
setInsertBookSQL(String insertBookSQL)
Used for Spring Dependency Injection
|
void |
setInsertSubjectBookSQL(String insertSubjectBookSQL)
Used for Spring Dependency Injection
|
void |
setJdbcTemplate(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate)
Used for Spring Dependency Injection
|
void |
setResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource resourceBundleMessageSource)
Used for Spring Dependency Injection
|
void |
setSelectAllBooksSQL(String selectAllBooksSQL)
Used for Spring Dependency Injection
|
void |
setSelectAuthorsByBookIdSQL(String selectAuthorsByBookIdSQL)
Used for Spring Dependency Injection
|
void |
setSelectBookAuthorByBookIdAuthoridSQL(String selectBookAuthorByBookIdAuthoridSQL)
Used for Spring Dependency Injection
|
void |
setSelectBookByAuthorSQL(String selectBookByAuthorSQL)
Used for Spring Dependency Injection
|
void |
setSelectBookByIdSQL(String selectBookByIdSQL)
Used for Spring Dependency Injection
|
void |
setSelectBookByISBNSQL(String selectBookByISBNSQL)
Used for Spring Dependency Injection
|
void |
setSelectBookByOwnerSQL(String selectBookByOwnerSQL)
Used for Spring Dependency Injection
|
void |
setSelectBookByTitleSQL(String selectBookByTitleSQL)
Used for Spring Dependency Injection
|
void |
setSelectSubjectAndSearchOrderBySQL(String selectSubjectAndSearchOrderBySQL)
Used for Spring Dependency Injection
|
void |
setSelectSubjectAndSearchSelectSQL(String selectSubjectAndSearchSelectSQL)
Used for Spring Dependency Injection
|
void |
setSelectSubjectAndSearchWhereSQL(String selectSubjectAndSearchWhereSQL)
Used for Spring Dependency Injection
|
void |
setSelectSubjectBySubjectIdBookIdSQL(String selectSubjectBySubjectIdBookIdSQL)
Used for Spring Dependency Injection
|
void |
setSelectSubjectOrSearchMainSQL(String selectSubjectOrSearchMainSQL)
Used for Spring Dependency Injection
|
void |
setSelectSubjectOrSearchOrderBySQL(String selectSubjectOrSearchOrderBySQL)
Used for Spring Dependency Injection
|
void |
setSelectSubjectsByBookIdSQL(String selectSubjectsByBookIdSQL)
Used for Spring Dependency Injection
|
void |
setSubjectDAO(SubjectDAO subjectDAO)
Used for Spring Dependency Injection
|
void |
setSubjects(Book book,
ArrayList<Subject> subjects)
Sets the list of subjects associated with the given book.
|
void |
setUpdateBookSQL(String updateBookSQL)
Used for Spring Dependency Injection
|
ArrayList<Book> |
subjectAndSearch(ArrayList subjects)
Returns a list of
Book instances association with all of
the subjects in the input subjects array. |
ArrayList<Book> |
subjectOrSearch(ArrayList<Subject> subjects)
Returns a list of
Book instances association with all of
the subjects in the input subjects array. |
ArrayList |
titleSearch(String title)
Returns a list of books with the given title.
|
void |
update(Book book)
Updates
book in the database. |
public void setJdbcTemplate(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate)
jdbcTemplate
- The jdbcTemplate to set.public void setResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource resourceBundleMessageSource)
public void setSelectSubjectAndSearchSelectSQL(String selectSubjectAndSearchSelectSQL)
public void setSelectSubjectAndSearchWhereSQL(String selectSubjectAndSearchWhereSQL)
public void setSelectSubjectAndSearchOrderBySQL(String selectSubjectAndSearchOrderBySQL)
public void setInsertBookSQL(String insertBookSQL)
public void setSelectSubjectOrSearchMainSQL(String selectSubjectOrSearchMainSQL)
public void setSelectSubjectOrSearchOrderBySQL(String selectSubjectOrSearchOrderBySQL)
public void setSelectBookByISBNSQL(String selectBookByISBNSQL)
public void setCountCopiesSQL(String countCopiesSQL)
public void setSelectBookByIdSQL(String selectBookByIdSQL)
public void setUpdateBookSQL(String updateBookSQL)
public void setSelectBookAuthorByBookIdAuthoridSQL(String selectBookAuthorByBookIdAuthoridSQL)
public void setInsertBookAuthorSQL(String insertBookAuthorSQL)
public void setSelectAuthorsByBookIdSQL(String selectAuthorsByBookIdSQL)
public void setSelectSubjectBySubjectIdBookIdSQL(String selectSubjectBySubjectIdBookIdSQL)
public void setInsertSubjectBookSQL(String insertSubjectBookSQL)
public void setSelectSubjectsByBookIdSQL(String selectSubjectsByBookIdSQL)
public void setSelectAllBooksSQL(String selectAllBooksSQL)
public void setSelectBookByTitleSQL(String selectBookByTitleSQL)
public void setSelectBookByOwnerSQL(String selectBookByOwnerSQL)
public void setSelectBookByAuthorSQL(String selectBookByAuthorSQL)
public void setAuthorDAO(AuthorDAO authorDAO)
public void setSubjectDAO(SubjectDAO subjectDAO)
public Book insert(Book book) throws LibraryException
Inserts a book into the database and returns the result of retrieving the inserted book. The returned book instance therefore has the ID of the newly generated record in the database. The ID field in the book passed in as actual parameter is ignored.
The supplied book must have minimally a title and isbn, otherwise a LibraryException is thrown.
NB: this method does NOT set subjects or authors
LibraryException
- if an error occurspublic void update(Book book) throws LibraryException
Updates book
in the database. Assumes that all required
fields are set, including id
, which is used to locate the
record to update.
NB: this method does NOT set subjects or authors.
LibraryException
public Book retrieveByGenericCriteria(String sqlString, Object[] criteria) throws LibraryException
sqlString
- SQL String to be used for the specific criteria Objectcriteria
- Unique criteria to search the reader from, such as id,
isbnLibraryException
public String getIsbn(long bookID) throws LibraryException
bookID
- ID of bookLibraryException
- if an error occurs searching for the bookpublic Book retrieve(long bookID) throws LibraryException
bookID
- ID to lookupLibraryException
public Book retrieve(String bookID) throws LibraryException
bookID
- string IDLibraryException
public Book retrieveByIsbn(String isbn) throws LibraryException
bookID
- string IDLibraryException
public int countCopies(String isbn) throws LibraryException
isbn
- ISBN of the bookLibraryException
public void addAuthor(Book book, Author author) throws LibraryException
author
to the authors of book
.
Will create a record for author
if no author with
the given name exists yet. Requires that book
exist
already in the database and that the book ID is set.author
- Author to addbook
- book to associate author withLibraryException
public ArrayList<Author> getAuthors(Book book) throws LibraryException
LibraryException
public void addSubject(Book book, Subject subject) throws LibraryException
subject
to the subjects associated with
book
. Will create a record for subject
if no
subject with the given description exists yet. Requires that
book
exist already in the database and that the book ID
is set.subject
- Subject to addbook
- book to associate subject withLibraryException
public ArrayList<Subject> getSubjects(Book book) throws LibraryException
LibraryException
public void setAuthors(Book book, ArrayList<Author> authors) throws LibraryException
addAuthor(Book, Author)
for each Author instance in the
authors
list.authors
- Author instances to associate with the bookbook
- book to set authors forLibraryException
public void setSubjects(Book book, ArrayList<Subject> subjects) throws LibraryException
addSubject(Book, Subject)
for each Subject instance in the
subjects
list.subjects
- Subject instances to associate with the bookbook
- book to set subjects forLibraryException
public ArrayList dump() throws LibraryException
LibraryException
public ArrayList titleSearch(String title) throws LibraryException
title
- title to searchLibraryException
public ArrayList ownerSearch(long owner) throws LibraryException
owner
- ID of ownerLibraryException
public ArrayList<Book> subjectAndSearch(ArrayList subjects) throws LibraryException
Book
instances association with all of
the subjects in the input subjects
array. The list returned
is the intersection of the books associated with each of the individual
subjects. A book must be associated with every subject in the
list to be included in the returned list.subjects
- list of subjects to seach onLibraryException
public ArrayList<Book> subjectOrSearch(ArrayList<Subject> subjects) throws LibraryException
Book
instances association with all of
the subjects in the input subjects
array. The list returned
is the intersection of the books associated with each of the individual
subjects. A book must be associated with every subject in the
list to be included in the returned list.subjects
- list of subjects to seach onLibraryException
public ArrayList<Book> authorSearch(String authorLastName) throws LibraryException
Book
instances whose author lists contain
an author with the given last name. Returns an empty list if there are
no such books.authorLastName
- last name of author to searchLibraryException
public boolean bookExists(long book) throws LibraryException
book
- ID to validateLibraryException
Copyright © 2003-2017 The Virtual Library Team. All Rights Reserved.