1 package org.sourceforge.vlibrary.user.dao;
2
3 import java.util.ArrayList;
4
5 import org.sourceforge.vlibrary.exceptions.LibraryException;
6 import org.sourceforge.vlibrary.user.domain.Author;
7
8
9 /**
10 *
11 * Author data access interface.
12 *
13 * @version $Revision$ $Date$
14 *
15 */
16
17 public interface AuthorDAO {
18
19 /**
20 * <p>Inserts the given author into the database. Has the side effect of
21 * setting the <code>id</code> field of <code>author</code> to the
22 * sequentially generated ID of the new record.
23 * </p>
24 * <p>First checks to see if an author with the same
25 * <code>firstName</code> and <code>lastName</code> as <code>author</code>
26 * exists. If so, no insert is performed; but <code>author.id</code> is
27 * updated to the id of the previously existing record.
28 * </p>
29 *
30 * @throws LibraryException if a data access error occurs
31 */
32 void insert (Author author) throws LibraryException;
33
34 /**
35 * Walks input ArrayList, looking up and setting ID properties for
36 * each Author in the list. Lookup is based on first name + last name.
37 * If an Author is not found, a new entry is inserted into the database
38 * and the ID of the newly created record is assigned to the instance.
39 *
40 * @param authors = ArrayList of Authors
41 * @exception LibraryException
42 */
43 void setAuthorIds(ArrayList authors) throws LibraryException;
44
45 /**
46 * Finds the id of the given <code>Author</code> object in the database,
47 * using the <code>firstName</code> and <code>lastName</code> properties
48 * to lookup the record.
49 *
50 * @param author Author to lookup by name
51 * @return Long id of the Author
52 * @throws LibraryException
53 */
54 Long findAuthorByFirstLastName(Author author) throws LibraryException;
55
56
57 }