OwnerDao.java 2.69 KB
Newer Older
1 2
package at.ac.tuwien.sepm.assignment.individual.persistence;

3
import at.ac.tuwien.sepm.assignment.individual.entity.Horse;
4 5 6 7
import at.ac.tuwien.sepm.assignment.individual.entity.Owner;
import at.ac.tuwien.sepm.assignment.individual.exception.NotFoundException;
import org.springframework.dao.DataAccessException;

8 9
import java.util.List;
import java.util.Map;
10

11 12 13 14 15 16 17 18 19 20
public interface OwnerDao {

    /**
     * @param id of the owner to find.
     * @return the owner with the specified id.
     * @throws DataAccessException will be thrown if something goes wrong during the database access.
     * @throws NotFoundException   will be thrown if the owner could not be found in the database.
     */
    Owner findOneById(Long id);

21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
    /**
     * @return a list of all owners in the system
     * @throws NotFoundException   will be thrown if no owners are present in the database
     * @throws DataAccessException will be thrown if something goes wrong during the database access
     */
    List<Owner> getAll() throws NotFoundException;

    /**
     * @param filters to use for filtering the owners
     * @return a list of all owners that fill the criteria
     * @throws NotFoundException wil be thrown if no owners fill the criteria
     * @throws DataAccessException will be thrown if something goes wrong during the database access
     */
    List<Owner> getFiltered(Map<String, String> filters) throws NotFoundException;

36 37 38 39 40 41 42 43
    /**
     * @param id of the owner whose horses the database should obtain
     * @return a list of all horses that the specified owner owns
     * @throws NotFoundException will be thrown if the owner owns no horses or if the owner could not be found
     * @throws DataAccessException will be thrown if something goes wrong during the database access
     */
    List<Horse> getOwnedHorses(Long id) throws NotFoundException;

44 45
    /**
     * @param owner that specifies the owner to add
46
     * @return the newly created owner
47 48 49 50
     * @throws DataAccessException will be thrown if something goes wrong during the database access.
     */
    Owner addOwner(Owner owner);

51 52 53 54 55 56
    /**
     * @param owner that specifies the new owner values alongside with the id of the owner to update
     * @return the updated owner
     * @throws DataAccessException will be thrown if something goes wrong during the database access.
     */
    Owner updateOwner(Owner owner) throws DataAccessException;
57 58 59 60 61 62 63

    /**
     * @param id of the owner to delete
     * @throws DataAccessException will be thrown if something goes wrong during the database access.
     * @throws NotFoundException   will be thrown if the owner could not be found in the database.
     */
    void deleteOwner(Long id) throws DataAccessException, NotFoundException;
64
}