1 package org.sourceforge.vlibrary.user.dao; 2 3 4 import java.util.ArrayList; 5 6 import org.sourceforge.vlibrary.exceptions.LibraryException; 7 import org.sourceforge.vlibrary.user.domain.Subject; 8 9 10 /** 11 * @version $Revision$ $Date$ 12 */ 13 14 public interface SubjectDAO { 15 /****************************************************************************** 16 * Inserts *this* into the database. Has the side effect of 17 * setting this.id to the sequentially generated id of the new record. 18 * First checks to see if a subject with this.description exists. 19 * If so, no insert is performed, but this.id is updated to the id of 20 * the previously existing record. Delegates to insert(Connection). 21 * 22 * @throws LibraryException 23 *****************************************************************************/ 24 public Subject insert( Subject subject ) throws LibraryException; 25 26 /****************************************************************************** 27 * Walks input ArrayList pf {@link Subject} instances, looking up and 28 * setting ID properties for each Subject in the list. Lookup is based on 29 * the description property. If a Subject is not found, a new entry is 30 * inserted into the database and the ID of the newly created record is 31 * assigned to the instance. 32 * 33 * @param subjects = ArrayList of Subjects 34 * @exception LibraryException if the list contains objects that are not 35 * Subject instances or a data access error occurs 36 *****************************************************************************/ 37 public void setSubjectIds(ArrayList subjects)throws LibraryException; 38 39 /****************************************************************************** 40 * Retrieves all subjects from the database 41 * 42 * @return ArrayList of Subject object, if none found returns empty ArrayList 43 * @throws LibraryException 44 *****************************************************************************/ 45 public ArrayList getSubjects() throws LibraryException; 46 47 public Long getSubjectIdByDescription( Subject subject ) throws LibraryException; 48 49 }