diff options
Diffstat (limited to 'src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/OperationService.java')
-rw-r--r-- | src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/OperationService.java | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/OperationService.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/OperationService.java new file mode 100644 index 0000000..42b23bb --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/OperationService.java @@ -0,0 +1,70 @@ +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<Long> 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<Vehicle> 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<Operation> list(EnumSet<Status> statuses) throws ServiceException; +} |