HorseDao.java 2.59 KB
Newer Older
1 2 3 4
package at.ac.tuwien.sepm.assignment.individual.persistence;

import at.ac.tuwien.sepm.assignment.individual.entity.Horse;
import at.ac.tuwien.sepm.assignment.individual.exception.NotFoundException;
5
import at.ac.tuwien.sepm.assignment.individual.exception.PersistenceException;
6

7
import java.io.IOException;
8 9
import java.util.List;
import java.util.Map;
10

11 12 13 14 15
public interface HorseDao {

    /**
     * @param id of the horse to find.
     * @return the horse with the specified id.
16
     * @throws PersistenceException will be thrown if something goes wrong during the database access.
17 18
     * @throws NotFoundException   will be thrown if the horse could not be found in the database.
     */
19
    Horse findOneById(Long id) throws NotFoundException, PersistenceException;
20

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

    /**
     * @param filters to use for filtering the horses
     * @return a list of all horses that fill the criteria
     * @throws NotFoundException wil be thrown if no horses fill the criteria
32
     * @throws PersistenceException will be thrown if something goes wrong during the database access.
33
     */
34
    List<Horse> getFiltered(Map<String, String> filters) throws NotFoundException, PersistenceException;
35

36 37 38
    /**
     * @param horse that specifies the horse to add
     * @return the newly created horse
39
     * @throws PersistenceException will be thrown if something goes wrong during the database access.
40
     */
41
    Horse addHorse(Horse horse) throws PersistenceException;
42 43 44 45

    /**
     * @param horse that specifies the new horse values alongside with the id of the horse to update
     * @return the updated horse
46 47
     * @throws PersistenceException will be thrown if something goes wrong during the database access.
     * @throws IOException          will be thrown if the old horse image could not be deleted
48
     */
49
    Horse updateHorse(Horse horse) throws PersistenceException, IOException;
50 51 52

    /**
     * @param id of the horse to delete
53 54 55
     * @throws PersistenceException will be thrown if something goes wrong during the database access.
     * @throws NotFoundException    will be thrown if the horse could not be found in the database.
     * @throws IOException          will be thrown if the horse image could not be deleted
56
     */
57
    void deleteHorse(Long id) throws PersistenceException, NotFoundException, IOException;
58
}