OwnerService.java 2.9 KB
Newer Older
1 2
package at.ac.tuwien.sepm.assignment.individual.service;

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
import at.ac.tuwien.sepm.assignment.individual.util.ValidationException;
8

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

12 13 14 15 16 17 18 19 20 21 22
public interface OwnerService {


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

23 24 25 26 27 28 29 30 31 32 33 34 35 36
    /**
     * @return a list of all owners in the database
     * @throws NotFoundException will be thrown if there are no owners 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   will be thrown if no owners fill the criteria
     * @throws ValidationException will be thrown if the filter contains bad values
     */
    List<Owner> getFiltered(Map<String, String> filters) throws NotFoundException, ValidationException;

37 38 39 40
    /**
     * @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
41
     * @throws PersistenceException will be thrown if something goes wrong during the database access
42 43 44
     */
    List<Horse> getOwnedHorses(Long id) throws NotFoundException;

45 46 47 48
    /**
     * @param owner to create
     * @return the new owner
     * @throws ValidationException will be thrown if something goes wrong during verification.
49
     * @throws PersistenceException will be thrown if the owner could not be saved in the database.
50
     */
51
    Owner addOwner(Owner owner) throws ValidationException, PersistenceException;
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 ValidationException will be thrown if something goes wrong during verification.
57
     * @throws PersistenceException will be thrown if the owner could not be saved in the database.
58
     */
59
    Owner updateOwner(Owner owner) throws ValidationException, PersistenceException;
60 61 62 63

    /**
     * @param id of the owner to delete
     * @throws NotFoundException   will be thrown if the owner could not be found in the system
64
     * @throws PersistenceException will be thrown if the owner could not be deleted from the database
65
     */
66
    void deleteOwner(Long id) throws NotFoundException, PersistenceException;
67
}