HorseDao.java 2.44 KB
Newer Older
1 2 3 4 5 6
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;
import org.springframework.dao.DataAccessException;

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

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

    /**
     * @param id of the horse to find.
     * @return the horse with the specified id.
     * @throws DataAccessException 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.
     */
    Horse findOneById(Long id);

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

    /**
     * @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
     * @throws DataAccessException will be thrown if something goes wrong during the database access
     */
    List<Horse> getFiltered(Map<String, String> filters) throws NotFoundException;

36 37 38 39 40 41
    /**
     * @param horse that specifies the horse to add
     * @return the newly created horse
     * @throws DataAccessException will be thrown if something goes wrong during the database access.
     */
    Horse addHorse(Horse horse);
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 48 49 50 51 52 53 54 55
     * @throws DataAccessException 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
     */
    Horse updateHorse(Horse horse) throws DataAccessException, IOException;

    /**
     * @param id of the horse to delete
     * @throws DataAccessException 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 DataAccessException, NotFoundException, IOException;
58
}