package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service; import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidOperationException; import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation; import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation.Status; import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; import java.util.EnumSet; import java.util.Set; import java.util.SortedSet; public interface OperationService { /** * Add given operation to the store. * * @param operation that should be added to the store * @return the id that was assigned * @throws InvalidOperationException if the operation is invalid * @throws ServiceException if the operation could not be persisted */ long add(Operation operation) throws InvalidOperationException, ServiceException; /** * Request new vehicles to the given operation. * * @param operationId id of the operation that the vehicles should be send to * @param vehicleIds the ids of the vehicles that should be send to the given operation * @throws InvalidOperationException if the operationId is invalid or does not exist * @throws InvalidVehicleException if one of the vehicle ids is invalid or does not exist * @throws ServiceException if the vehicles could not be loaded or the operation could not be * persisted */ void requestVehicles(long operationId, Set vehicleIds) throws InvalidOperationException, InvalidVehicleException, ServiceException; /** * Completes the given operation with the specified status. * * @param operationId id of the operation that should be completed * @param status of the completed operation, either {@link Status#COMPLETED} or {@link * Status#CANCELLED} * @throws InvalidOperationException if the operationId is invalid or does not exist * @throws ServiceException if the operation could not be persisted */ void complete(long operationId, Status status) throws InvalidOperationException, ServiceException; /** * Get all available vehicles, sorted by how well they fit to the given opCode, starting with * the best fitting. * * @param opCode the operation code that is used to determine the ranking * @return a sorted list containing all available vehicles * @throws InvalidOperationException if the opCode is invalid * @throws ServiceException if loading the stored vehicles failed */ SortedSet rankVehicles(String opCode) throws InvalidOperationException, ServiceException; /** * Get all stored operations with matching status. * * @param statuses set containing all statuses that should be matched * @return list containing all matched operations * @throws ServiceException if loading the stored operations failed */ Set list(EnumSet statuses) throws ServiceException; }