HorseService.java 2.93 KB
Newer Older
1 2 3 4
package at.ac.tuwien.sepm.assignment.individual.service;

import at.ac.tuwien.sepm.assignment.individual.entity.Horse;
import at.ac.tuwien.sepm.assignment.individual.exception.NotFoundException;
5 6
import at.ac.tuwien.sepm.assignment.individual.util.ValidationException;
import org.springframework.dao.DataAccessException;
7 8 9
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
10 11
import java.util.List;
import java.util.Map;
12 13 14 15 16 17 18 19 20 21

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

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

36 37
    /**
     * @param horse to add.
38
     * @return the new horse.
39
     * @throws ValidationException will be thrown if something goes wrong during verification.
40
     * @throws DataAccessException will be thrown if the horse could not be saved in the database.
41 42
     */
    Horse addHorse(Horse horse);
43

44 45 46
    /**
     * @param horse that specifies the new horse values alongside with the id of the horse to update
     * @return the updated horse
47
     * @throws ValidationException will be thrown if something goes wrong during verification.
48
     * @throws DataAccessException will be thrown if the horse could not be saved in the database.
49
     * @throws IOException         will be thrown if the old horse image could not be deleted
50
     */
51 52 53 54 55 56 57 58 59
    Horse updateHorse(Horse horse) throws ValidationException, DataAccessException, IOException;

    /**
     * @param id of the horse to delete
     * @throws NotFoundException   will be thrown if the horse could not be found in the system
     * @throws DataAccessException will be thrown if the horse could not be deleted from the database
     * @throws IOException         will be thrown if the horse image could not be deleted
     */
    void deleteHorse(Long id) throws NotFoundException, DataAccessException, IOException;
60

61 62
    /**
     * @param img image to upload
63
     * @throws IOException         will be thrown if something goes wrong with saving the file
64
     * @throws ValidationException will be thrown if the file is in the incorrect format
65
     */
66
    void saveImage(MultipartFile img) throws IOException, ValidationException;
67
}