OwnerDao.java 2.47 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
import at.ac.tuwien.sepm.assignment.individual.entity.Owner;
import at.ac.tuwien.sepm.assignment.individual.exception.NotFoundException;
6
import at.ac.tuwien.sepm.assignment.individual.exception.PersistenceException;
7

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

11 12 13 14 15
public interface OwnerDao {

    /**
     * @param id of the owner to find.
     * @return the owner with the specified id.
16
     * @throws NotFoundException will be thrown if the owner could not be found in the database.
17
     */
18
    Owner findOneById(Long id) throws NotFoundException;
19

20 21 22 23 24 25 26 27 28 29 30 31 32
    /**
     * @return a list of all owners in the system
     * @throws NotFoundException   will be thrown if no owners are present in the database
     */
    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
     */
    List<Owner> getFiltered(Map<String, String> filters) throws NotFoundException;

33 34 35 36 37 38 39
    /**
     * @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
     */
    List<Horse> getOwnedHorses(Long id) throws NotFoundException;

40 41
    /**
     * @param owner that specifies the owner to add
42
     * @return the newly created owner
43
     * @throws PersistenceException will be thrown if something goes wrong during the database access.
44
     */
45
    Owner addOwner(Owner owner) throws PersistenceException;
46

47 48 49
    /**
     * @param owner that specifies the new owner values alongside with the id of the owner to update
     * @return the updated owner
50 51
     * @throws PersistenceException will be thrown if something goes wrong during the database access.
     * @throws NotFoundException wil be thrown if no owners fill the criteria
52
     */
53
    Owner updateOwner(Owner owner) throws PersistenceException, NotFoundException;
54 55 56

    /**
     * @param id of the owner to delete
57 58
     * @throws PersistenceException 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.
59
     */
60
    void deleteOwner(Long id) throws PersistenceException, NotFoundException;
61
}