diff --git a/src/main/java/telraam/api/AbstractListableResource.java b/src/main/java/telraam/api/AbstractListableResource.java index e600a1c..b9e5030 100644 --- a/src/main/java/telraam/api/AbstractListableResource.java +++ b/src/main/java/telraam/api/AbstractListableResource.java @@ -1,6 +1,7 @@ package telraam.api; +import io.swagger.v3.oas.annotations.Operation; import telraam.database.daos.DAO; import java.util.List; @@ -11,6 +12,7 @@ protected AbstractListableResource(DAO dao) { } @Override + @Operation(summary = "Find all") public List getListOf() { return dao.getAll(); } diff --git a/src/main/java/telraam/api/AbstractResource.java b/src/main/java/telraam/api/AbstractResource.java index bcd70d0..62f9bd7 100644 --- a/src/main/java/telraam/api/AbstractResource.java +++ b/src/main/java/telraam/api/AbstractResource.java @@ -1,11 +1,13 @@ package telraam.api; +import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import jakarta.ws.rs.GET; import jakarta.ws.rs.WebApplicationException; import jakarta.ws.rs.core.Response; +import org.checkerframework.checker.units.qual.C; import telraam.database.daos.DAO; import java.util.Optional; @@ -19,12 +21,14 @@ protected AbstractResource(DAO dao) { } @Override + @Operation(summary = "Add new to the database") // TODO Validate model and return 405 for wrong input public int create(@Parameter(required = true) T t) { return dao.insert(t); } @Override + @Operation(summary = "Find by ID") @ApiResponse(responseCode = "400", description = "Invalid or no ID supplied") // TODO validate ID, return 400 on wrong ID format @ApiResponse(responseCode = "404", description = "Entity with specified ID not found") public T get(@Parameter(description = "ID of entity that needs to be fetched", required = true) Optional id) { @@ -41,6 +45,7 @@ public T get(@Parameter(description = "ID of entity that needs to be fetched", r } @Override + @Operation(summary = "Update an existing") @ApiResponse(responseCode = "400", description = "Invalid or no ID supplied") // TODO validate ID, return 400 on wrong ID format @ApiResponse(responseCode = "404", description = "Entity with specified ID not found") @ApiResponse(responseCode = "405", description = "Validation exception") // TODO validate input, 405 on wrong input @@ -60,6 +65,7 @@ public T update(@Parameter(description = "Entity object that needs to be updated } @Override + @Operation(summary = "Delete an existing") @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid or no ID supplied"), // TODO validate ID, return 400 on wrong ID format }) diff --git a/src/main/java/telraam/api/BatonResource.java b/src/main/java/telraam/api/BatonResource.java index 49bcd68..faa802b 100644 --- a/src/main/java/telraam/api/BatonResource.java +++ b/src/main/java/telraam/api/BatonResource.java @@ -1,52 +1,18 @@ package telraam.api; -import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.MediaType; -import telraam.database.daos.BatonDAO; +import telraam.database.daos.DAO; import telraam.database.models.Baton; -import java.util.List; -import java.util.Optional; - @Path("/baton") // dropwizard @Tag(name = "Baton") @Produces(MediaType.APPLICATION_JSON) public class BatonResource extends AbstractListableResource { - public BatonResource(BatonDAO dao) { + public BatonResource(DAO dao) { super(dao); } - - @Override - @Operation(summary = "Find all batons") - public List getListOf() { - return super.getListOf(); - } - - @Override - @Operation(summary = "Add a new baton to the database") - public int create(Baton baton) { - return super.create(baton); - } - - @Override - @Operation(summary = "Find baton by ID") - public Baton get(Optional id) { - return super.get(id); - } - - @Override - @Operation(summary = "Update an existing baton") - public Baton update(Baton baton, Optional id) { - return super.update(baton, id); - } - - @Override - @Operation(summary = "Delete an existing baton") - public boolean delete(Optional id) { - return super.delete(id); - } } diff --git a/src/main/java/telraam/api/BatonSwitchoverResource.java b/src/main/java/telraam/api/BatonSwitchoverResource.java index 72a0b85..9b1a173 100644 --- a/src/main/java/telraam/api/BatonSwitchoverResource.java +++ b/src/main/java/telraam/api/BatonSwitchoverResource.java @@ -1,6 +1,5 @@ package telraam.api; -import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; @@ -8,33 +7,12 @@ import telraam.database.daos.BatonSwitchoverDAO; import telraam.database.models.BatonSwitchover; -import java.util.List; -import java.util.Optional; - @Path("/batonswitchover") // dropwizard -@Tag(name="Baton Switchover") +@Tag(name = "Baton Switchover") @Produces(MediaType.APPLICATION_JSON) public class BatonSwitchoverResource extends AbstractListableResource { public BatonSwitchoverResource(BatonSwitchoverDAO dao) { super(dao); } - - @Override - @Operation(summary = "Find all baton switchovers") - public List getListOf() { - return super.getListOf(); - } - - @Override - @Operation(summary = "Find baton switchover by ID") - public BatonSwitchover get(Optional id) { - return super.get(id); - } - - @Override - @Operation(summary = "Add a new baton switchover to the database") - public int create(BatonSwitchover batonSwitchover) { - return super.create(batonSwitchover); - } } diff --git a/src/main/java/telraam/api/DetectionResource.java b/src/main/java/telraam/api/DetectionResource.java index c41a514..b7566cc 100644 --- a/src/main/java/telraam/api/DetectionResource.java +++ b/src/main/java/telraam/api/DetectionResource.java @@ -22,36 +22,6 @@ public DetectionResource(DetectionDAO dao) { detectionDAO = dao; } - @Override - @Operation(summary = "Find all detections") - public List getListOf() { - return super.getListOf(); - } - - @Override - @Operation(summary = "Add a new detection to the database") - public int create(Detection detection) { - return super.create(detection); - } - - @Override - @Operation(summary = "Find detection by ID") - public Detection get(Optional id) { - return super.get(id); - } - - @Override - @Operation(summary = "Update an existing detection") - public Detection update(Detection detection, Optional id) { - return super.update(detection, id); - } - - @Override - @Operation(summary = "Delete an existing detection") - public boolean delete(Optional id) { - return super.delete(id); - } - @GET @Path("/since/{id}") @Operation(summary = "Get detections with ID larger than given ID") diff --git a/src/main/java/telraam/api/LapResource.java b/src/main/java/telraam/api/LapResource.java index 25da4b9..a0ef3db 100644 --- a/src/main/java/telraam/api/LapResource.java +++ b/src/main/java/telraam/api/LapResource.java @@ -30,28 +30,4 @@ public List getListOf(@QueryParam("source") final Integer source) { return lapDAO.getAllBySource(source); } } - - @Override - @Operation(summary = "Add a new lap to the database") - public int create(Lap lap) { - return super.create(lap); - } - - @Override - @Operation(summary = "Find lap by ID") - public Lap get(Optional id) { - return super.get(id); - } - - @Override - @Operation(summary = "Update an existing lap") - public Lap update(Lap lap, Optional id) { - return super.update(lap, id); - } - - @Override - @Operation(summary = "Delete an existing lap") - public boolean delete(Optional id) { - return super.delete(id); - } } diff --git a/src/main/java/telraam/api/LapSourceResource.java b/src/main/java/telraam/api/LapSourceResource.java index bed07ac..630e6db 100644 --- a/src/main/java/telraam/api/LapSourceResource.java +++ b/src/main/java/telraam/api/LapSourceResource.java @@ -1,15 +1,12 @@ package telraam.api; -import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.ws.rs.*; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.MediaType; import telraam.database.daos.DAO; import telraam.database.models.LapSource; -import java.util.List; -import java.util.Optional; - @Path("/lap-source") @Tag(name = "Lap Source") @Produces(MediaType.APPLICATION_JSON) @@ -17,34 +14,4 @@ public class LapSourceResource extends AbstractListableResource { public LapSourceResource(DAO dao) { super(dao); } - - @Override - @Operation(summary = "Find all lap sources") - public List getListOf() { - return super.getListOf(); - } - - @Override - @Operation(summary = "Add a new lap source to the database") - public int create(LapSource lapSource) { - return super.create(lapSource); - } - - @Override - @Operation(summary = "Find lap source by ID") - public LapSource get(Optional id) { - return super.get(id); - } - - @Override - @Operation(summary = "Update an existing lap source") - public LapSource update(LapSource lapSource, Optional id) { - return super.update(lapSource, id); - } - - @Override - @Operation(summary = "Delete an existing lap source") - public boolean delete(Optional id) { - return super.delete(id); - } } diff --git a/src/main/java/telraam/api/LapSourceSwitchoverResource.java b/src/main/java/telraam/api/LapSourceSwitchoverResource.java index 9ad4d1f..598cdf0 100644 --- a/src/main/java/telraam/api/LapSourceSwitchoverResource.java +++ b/src/main/java/telraam/api/LapSourceSwitchoverResource.java @@ -1,39 +1,18 @@ package telraam.api; -import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.ws.rs.*; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.MediaType; import telraam.database.daos.LapSourceSwitchoverDAO; import telraam.database.models.LapSourceSwitchover; -import java.util.List; -import java.util.Optional; - @Path("/lapsourceswitchover") // dropwizard -@Tag(name="Lap Source Switchover") +@Tag(name = "Lap Source Switchover") @Produces(MediaType.APPLICATION_JSON) public class LapSourceSwitchoverResource extends AbstractListableResource { public LapSourceSwitchoverResource(LapSourceSwitchoverDAO dao) { super(dao); } - - @Override - @Operation(summary = "Find all lap source switchovers") - public List getListOf() { - return super.getListOf(); - } - - @Override - @Operation(summary = "Find lap source switchover by ID") - public LapSourceSwitchover get(Optional id) { - return super.get(id); - } - - @Override - @Operation(summary = "Add a new lap source switchover to the database") - public int create(LapSourceSwitchover lapSourceSwitchover) { - return super.create(lapSourceSwitchover); - } } diff --git a/src/main/java/telraam/api/StationResource.java b/src/main/java/telraam/api/StationResource.java index df61deb..106131c 100644 --- a/src/main/java/telraam/api/StationResource.java +++ b/src/main/java/telraam/api/StationResource.java @@ -1,51 +1,17 @@ package telraam.api; -import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; import telraam.database.daos.DAO; import telraam.database.models.Station; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.core.MediaType; -import java.util.List; -import java.util.Optional; - @Path("/station") -@Tag(name="Station") +@Tag(name = "Station") @Produces(MediaType.APPLICATION_JSON) public class StationResource extends AbstractListableResource { public StationResource(DAO dao) { super(dao); } - - @Override - @Operation(summary = "Find all stations") - public List getListOf() { - return super.getListOf(); - } - - @Override - @Operation(summary = "Add a new station to the database") - public int create(Station station) { - return super.create(station); - } - - @Override - @Operation(summary = "Find station by ID") - public Station get(Optional id) { - return super.get(id); - } - - @Override - @Operation(summary = "Update an existing station") - public Station update(Station station, Optional id) { - return super.update(station, id); - } - - @Override - @Operation(summary = "Delete an existing station") - public boolean delete(Optional id) { - return super.delete(id); - } } diff --git a/src/main/java/telraam/api/TeamResource.java b/src/main/java/telraam/api/TeamResource.java index 56975c9..5983eff 100644 --- a/src/main/java/telraam/api/TeamResource.java +++ b/src/main/java/telraam/api/TeamResource.java @@ -28,12 +28,6 @@ public TeamResource(TeamDAO teamDAO, BatonSwitchoverDAO batonSwitchoverDAO) { this.batonSwitchoverDAO = batonSwitchoverDAO; } - @Override - @Operation(summary = "Find all teams") - public List getListOf() { - return super.getListOf(); - } - @Override @Operation(summary = "Add a new team to the database") public int create(Team team) { @@ -51,12 +45,6 @@ public int create(Team team) { return ret; } - @Override - @Operation(summary = "Find team by ID") - public Team get(Optional id) { - return super.get(id); - } - @Override @Operation(summary = "Update an existing team") public Team update(Team team, Optional id) { @@ -77,10 +65,4 @@ public Team update(Team team, Optional id) { return ret; } - - @Override - @Operation(summary = "Delete an existing team") - public boolean delete(Optional id) { - return super.delete(id); - } } diff --git a/src/main/java/telraam/api/TimeResource.java b/src/main/java/telraam/api/TimeResource.java index ebdae5f..f49e0c3 100644 --- a/src/main/java/telraam/api/TimeResource.java +++ b/src/main/java/telraam/api/TimeResource.java @@ -11,7 +11,7 @@ @Tag(name = "Time") @Produces(MediaType.APPLICATION_JSON) public class TimeResource { - static class TimeResponse { + public static class TimeResponse { public long timestamp; public TimeResponse() {