From b571db1f4ebd6ca0f94dad9899c4a965b7ee5418 Mon Sep 17 00:00:00 2001 From: "Brian M. Long" Date: Wed, 5 Jul 2023 12:30:58 -0400 Subject: [PATCH] another fixes for @PathParam --- .../com/poststats/golf/api/CourseApi.java | 23 ++++++-------- .../java/com/poststats/golf/api/EventApi.java | 24 ++++++--------- .../poststats/golf/api/EventFinanceApi.java | 22 +++++--------- .../poststats/golf/api/EventPersonApi.java | 26 ++++++---------- .../com/poststats/golf/api/EventRoundApi.java | 28 ++++++++--------- .../poststats/golf/api/impl/CourseApi.java | 24 ++++++--------- .../com/poststats/golf/api/impl/EventApi.java | 22 +++++++------- .../golf/api/impl/EventFinanceApi.java | 18 +++++------ .../golf/api/impl/EventPersonApi.java | 30 +++++++++---------- .../golf/api/impl/EventRoundApi.java | 25 ++++++++-------- 10 files changed, 103 insertions(+), 139 deletions(-) diff --git a/src/main/java/com/poststats/golf/api/CourseApi.java b/src/main/java/com/poststats/golf/api/CourseApi.java index b41fc30..4ad6689 100644 --- a/src/main/java/com/poststats/golf/api/CourseApi.java +++ b/src/main/java/com/poststats/golf/api/CourseApi.java @@ -21,17 +21,7 @@ import jakarta.ws.rs.Produces; @Tag(name = "Course API") @ApiResponse(responseCode = "200", description = "Success") @ApiResponse(responseCode = "404", description = "A golf course with the specified ID could not be found") -public abstract class CourseApi { - - @Parameter(description = "A unique identifier for a golf course") - @NotNull - @Positive - @PathParam("courseId") - private int courseId; - - protected int getCourseId() { - return this.courseId; - } +public interface CourseApi { @GET @Produces(Constants.V1_JSON) @@ -39,7 +29,8 @@ public abstract class CourseApi { summary = "Retrieves meta-data about a course.", description = "Retreives name, location, and other direct meta-data about the specified course." ) - public abstract Course get(); + public abstract Course get(@Parameter(description = "A unique identifier for a golf course") + @NotNull @Positive @PathParam("courseId") int courseId); @GET @Path("/nine/byName/{name}") @@ -48,7 +39,9 @@ public abstract class CourseApi { summary = "Retrieves meta-data about a course nine.", description = "Retreives name, location, and other direct meta-data about the specified course." ) - public abstract CourseNine getNine(@PathParam("name") String name); + public abstract CourseNine getNine(@Parameter(description = "A unique identifier for a golf course") + @NotNull @Positive @PathParam("courseId") int courseId, + @PathParam("name") String name); @GET @Path("/nine/{nineId:[0-9]+}") @@ -57,6 +50,8 @@ public abstract class CourseApi { summary = "Retrieves limited meta-data about a course nine.", description = "Retreives name, location, and other direct meta-data about the specified course." ) - public abstract CourseNine getNine(@PathParam("nineId") long courseNineId); + public abstract CourseNine getNine(@Parameter(description = "A unique identifier for a golf course") + @NotNull @Positive @PathParam("courseId") int courseId, + @PathParam("nineId") long courseNineId); } diff --git a/src/main/java/com/poststats/golf/api/EventApi.java b/src/main/java/com/poststats/golf/api/EventApi.java index af49831..61549ed 100644 --- a/src/main/java/com/poststats/golf/api/EventApi.java +++ b/src/main/java/com/poststats/golf/api/EventApi.java @@ -3,6 +3,7 @@ package com.poststats.golf.api; import com.poststats.golf.api.model.Event; 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 io.swagger.v3.oas.annotations.tags.Tag; @@ -20,16 +21,7 @@ import jakarta.ws.rs.Produces; */ @Path("/golf/event/{eventId}") @Tag(name = "Event API") -public abstract class EventApi { - - @NotNull - @Positive - @PathParam("eventId") - private long eventId; - - protected long getEventId() { - return this.eventId; - } +public interface EventApi { @GET @Produces(Constants.V1_JSON) @@ -41,7 +33,7 @@ public abstract class EventApi { @ApiResponse(responseCode = "200", description = "Success"), @ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found") }) - public abstract Event get(); + Event get(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId); @GET @Path("/detail") @@ -54,7 +46,7 @@ public abstract class EventApi { @ApiResponse(responseCode = "200", description = "Success"), @ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found") }) - public abstract Event getDetail(); + Event getDetail(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId); @POST @Path("/document/{documentId}/send") @@ -74,7 +66,8 @@ public abstract class EventApi { description = "An event or document with the specified ID could not be found" ) }) - public abstract void sendDocument(@PathParam("documentId") long documentId); + void sendDocument(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId, + @Parameter(description = "A unique identifier for an event document") @NotNull @Positive @PathParam("documentId") long documentId); @POST @Path("/document/{documentId}/sendTest/{personId}") @@ -94,7 +87,8 @@ public abstract class EventApi { description = "An event, document, or person with the specified ID could not be found" ) }) - public abstract void sendTestDocument(@PathParam("documentId") long documentId, - @PathParam("personId") long personId); + void sendTestDocument(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId, + @Parameter(description = "A unique identifier for an event document") @NotNull @Positive @PathParam("documentId") long documentId, + @Parameter(description = "A unique identifier for a person") @NotNull @Positive @PathParam("personId") long personId); } diff --git a/src/main/java/com/poststats/golf/api/EventFinanceApi.java b/src/main/java/com/poststats/golf/api/EventFinanceApi.java index f26c01b..55d11a4 100644 --- a/src/main/java/com/poststats/golf/api/EventFinanceApi.java +++ b/src/main/java/com/poststats/golf/api/EventFinanceApi.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.Map; 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 io.swagger.v3.oas.annotations.security.SecurityRequirement; @@ -20,16 +21,7 @@ import jakarta.ws.rs.core.StreamingOutput; @Path("/golf/event/{eventId}/finance") @Tag(name = "Event Finance API") -public abstract class EventFinanceApi { - - @NotNull - @Positive - @PathParam("eventId") - private long eventId; - - protected long getEventId() { - return this.eventId; - } +public interface EventFinanceApi { @GET @Path("/balance/persons") @@ -46,7 +38,8 @@ public abstract class EventFinanceApi { @ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"), @ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found") }) - public abstract List> getBalanceByPersonsAsJson(@QueryParam("minBalance") Float minBalance, + List> getBalanceByPersonsAsJson(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId, + @QueryParam("minBalance") Float minBalance, @QueryParam("maxBalance") Float maxBalance); @GET @@ -64,7 +57,7 @@ public abstract class EventFinanceApi { @ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"), @ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found") }) - public abstract StreamingOutput getBalanceByPersonsAsCsv(); + StreamingOutput getBalanceByPersonsAsCsv(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId); @GET @Path("/balance/person/{personId}") @@ -84,7 +77,8 @@ public abstract class EventFinanceApi { description = "An event or person with the specified IDs could not be found" ) }) - public abstract Map getBalanceByPersonsAsJson(@PathParam("personId") long personId); + Map getBalanceByPersonsAsJson(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId, + @Parameter(description = "A unique identifier for a person") @NotNull @Positive @PathParam("personId") long personId); @GET @Path("/series/balance/persons") @@ -101,6 +95,6 @@ public abstract class EventFinanceApi { @ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"), @ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found") }) - public abstract List> getSeriesBalanceByPersonsAsJson(); + List> getSeriesBalanceByPersonsAsJson(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId); } diff --git a/src/main/java/com/poststats/golf/api/EventPersonApi.java b/src/main/java/com/poststats/golf/api/EventPersonApi.java index b63d476..eaebf38 100644 --- a/src/main/java/com/poststats/golf/api/EventPersonApi.java +++ b/src/main/java/com/poststats/golf/api/EventPersonApi.java @@ -6,6 +6,7 @@ import java.util.Set; import com.poststats.golf.api.model.EventPerson; 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 io.swagger.v3.oas.annotations.security.SecurityRequirement; @@ -21,17 +22,8 @@ import jakarta.ws.rs.core.StreamingOutput; @Path("/golf/event/{eventId}") @Tag(name = "Event Participant API") -public abstract class EventPersonApi { - - @NotNull - @Positive - @PathParam("eventId") - private long eventId; - - protected long getEventId() { - return this.eventId; - } - +public interface EventPersonApi { + @GET @Path("/people") @RolesAllowed( @@ -47,7 +39,7 @@ public abstract class EventPersonApi { @ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"), @ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found") }) - public abstract List get(); + List get(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId); @GET @Path("/people/detail") @@ -64,7 +56,7 @@ public abstract class EventPersonApi { @ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"), @ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found") }) - public abstract List getDetail(); + List getDetail(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId); @GET @Path("/people/csv") @@ -81,7 +73,7 @@ public abstract class EventPersonApi { @ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"), @ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found") }) - public abstract StreamingOutput getAsCsv(); + StreamingOutput getAsCsv(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId); @GET @Path("/participants") @@ -91,7 +83,7 @@ public abstract class EventPersonApi { @ApiResponse(responseCode = "200", description = "Success"), @ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found") }) - public abstract List getParticipants(); + List getParticipants(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId); @GET @Path("/participants/csv") @@ -108,7 +100,7 @@ public abstract class EventPersonApi { @ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"), @ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found") }) - public abstract StreamingOutput getParticipantsAsCsv(); + StreamingOutput getParticipantsAsCsv(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId); @GET @Path("/series/participants") @@ -125,6 +117,6 @@ public abstract class EventPersonApi { @ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"), @ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found") }) - public abstract Set getSeriesParticipants(); + Set getSeriesParticipants(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId); } diff --git a/src/main/java/com/poststats/golf/api/EventRoundApi.java b/src/main/java/com/poststats/golf/api/EventRoundApi.java index 720522e..53d5041 100644 --- a/src/main/java/com/poststats/golf/api/EventRoundApi.java +++ b/src/main/java/com/poststats/golf/api/EventRoundApi.java @@ -9,6 +9,7 @@ import com.poststats.golf.api.model.EventRoundPairing; import com.poststats.golf.api.model.EventRoundPairingOrder; 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 io.swagger.v3.oas.annotations.tags.Tag; @@ -26,16 +27,7 @@ import jakarta.ws.rs.core.StreamingOutput; */ @Path("/golf/event/{eventId}") @Tag(name = "Event Round API") -public abstract class EventRoundApi { - - @NotNull - @Positive - @PathParam("eventId") - private long eventId; - - protected long getEventId() { - return this.eventId; - } +public interface EventRoundApi { @GET @Path("/rounds/next") @@ -51,7 +43,7 @@ public abstract class EventRoundApi { description = "An event with the specified ID or upcoming event rounds could not be found" ) }) - public abstract List getNext(); + List getNext(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId); @GET @Path("/round/{eroundId:[0-9]+}") @@ -67,7 +59,8 @@ public abstract class EventRoundApi { description = "An event or event round with the specified ID could not be found" ) }) - public abstract EventRound getOne(@PathParam("eroundId") long eroundId); + EventRound getOne(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId, + @Parameter(description = "A unique identifier for an event round") @NotNull @Positive @PathParam("eroundId") long eroundId); @GET @Path("/rounds") @@ -83,7 +76,7 @@ public abstract class EventRoundApi { description = "An event with the specified ID or any event rounds could not be found" ) }) - public abstract List getAll(); + List getAll(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId); @GET @Path("/round/{eroundId:[0-9]+}/pairings") @@ -96,7 +89,8 @@ public abstract class EventRoundApi { description = "An event or its round with the specified ID could not be found" ) }) - public abstract List getPairings(@PathParam("eroundId") long eroundId); + List getPairings(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId, + @Parameter(description = "A unique identifier for an event round") @NotNull @Positive @PathParam("eroundId") long eroundId); @GET @Path("/round/{eroundId:[0-9]+}/pairings/csv") @@ -109,7 +103,8 @@ public abstract class EventRoundApi { description = "An event or its round with the specified ID could not be found" ) }) - public abstract StreamingOutput getPairingsAsCsv(@PathParam("eroundId") long eroundId, + StreamingOutput getPairingsAsCsv(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId, + @Parameter(description = "A unique identifier for an event round") @NotNull @Positive @PathParam("eroundId") long eroundId, @QueryParam("orderBy") List orderBys, @QueryParam("lastNameFirst") boolean lastNameFirst); @@ -124,7 +119,8 @@ public abstract class EventRoundApi { description = "An event with the specified ID or upcoming event rounds could not be found" ) }) - public abstract EventRoundPairing getPairing(@PathParam("eroundId") long eroundId, + EventRoundPairing getPairing(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId, + @Parameter(description = "A unique identifier for an event round") @NotNull @Positive @PathParam("eroundId") long eroundId, @PathParam("pairingID") BigInteger pairingId); } diff --git a/src/main/java/com/poststats/golf/api/impl/CourseApi.java b/src/main/java/com/poststats/golf/api/impl/CourseApi.java index 23936b4..80216ba 100644 --- a/src/main/java/com/poststats/golf/api/impl/CourseApi.java +++ b/src/main/java/com/poststats/golf/api/impl/CourseApi.java @@ -10,7 +10,6 @@ import com.poststats.golf.service.CourseService; import com.poststats.service.FacilityService; import com.poststats.transformer.impl.DaoConverter; -import jakarta.annotation.PostConstruct; import jakarta.enterprise.context.RequestScoped; import jakarta.inject.Inject; import jakarta.ws.rs.WebApplicationException; @@ -20,7 +19,7 @@ import jakarta.ws.rs.core.Response.Status; * @author brian.long@poststats.com */ @RequestScoped -public class CourseApi extends com.poststats.golf.api.CourseApi { +public class CourseApi implements com.poststats.golf.api.CourseApi { @Inject private Logger logger; @@ -37,39 +36,34 @@ public class CourseApi extends com.poststats.golf.api.CourseApi { @Inject private DaoConverter converter; - @PostConstruct - public void init() { - this.logger.debug("CourseApi init: {}", this.getCourseId()); - } - @Override - public Course get() { - FlexMap row = this.courseService.get(this.getCourseId()); + public Course get(int courseId) { + FlexMap row = this.courseService.get(courseId); if (row == null) throw new WebApplicationException("Course not found", Status.NOT_FOUND); - this.logger.trace("found: {}", this.getCourseId()); + this.logger.trace("found: {}", courseId); this.facilityService.inject("facilityID", row, "facility"); return this.converter.convertValue(row, Course.class); } @Override - public CourseNine getNine(String name) { - FlexMap row = this.courseNineService.getNine(this.getCourseId(), name); + public CourseNine getNine(int courseId, String name) { + FlexMap row = this.courseNineService.getNine(courseId, name); if (row == null) throw new WebApplicationException("Course nine not found", Status.NOT_FOUND); - this.logger.trace("found: {}", this.getCourseId()); + this.logger.trace("found: {}", courseId); this.courseService.injectDeep("courseID", row, "course"); return this.converter.convertValue(row, CourseNine.class); } @Override - public CourseNine getNine(long courseNineId) { + public CourseNine getNine(int courseId, long courseNineId) { FlexMap row = this.courseNineService.getNine(courseNineId); if (row == null) throw new WebApplicationException("Course nine not found", Status.NOT_FOUND); - if (this.getCourseId() != row.getInteger("courseID")) + if (courseId != row.getInteger("courseID")) throw new WebApplicationException("Course nine not found", Status.NOT_FOUND); this.logger.trace("found: {}", courseNineId); diff --git a/src/main/java/com/poststats/golf/api/impl/EventApi.java b/src/main/java/com/poststats/golf/api/impl/EventApi.java index 7ce45aa..e03297c 100644 --- a/src/main/java/com/poststats/golf/api/impl/EventApi.java +++ b/src/main/java/com/poststats/golf/api/impl/EventApi.java @@ -29,7 +29,7 @@ import jakarta.ws.rs.core.Response.Status; * @author brian.long@poststats.com */ @RequestScoped -public class EventApi extends com.poststats.golf.api.EventApi { +public class EventApi implements com.poststats.golf.api.EventApi { @Inject private Logger logger; @@ -54,12 +54,12 @@ public class EventApi extends com.poststats.golf.api.EventApi { @PostConstruct public void init() { - this.logger.debug("EventApi init: {}", this.getEventId()); + this.logger.debug("EventApi init"); } @Override - public Event get() { - FlexMap row = this.eventService.get(this.getEventId()); + public Event get(long eventId) { + FlexMap row = this.eventService.get(eventId); if (row == null) throw new WebApplicationException("Event not found", Status.NOT_FOUND); @@ -68,8 +68,8 @@ public class EventApi extends com.poststats.golf.api.EventApi { } @Override - public Event getDetail() { - FlexMap row = this.eventService.get(this.getEventId()); + public Event getDetail(long eventId) { + FlexMap row = this.eventService.get(eventId); if (row == null) throw new WebApplicationException("Event not found", Status.NOT_FOUND); @@ -78,8 +78,8 @@ public class EventApi extends com.poststats.golf.api.EventApi { } @Override - public void sendDocument(long documentId) { - FlexMap document = this.eventDocumentService.get(this.getEventId(), documentId); + public void sendDocument(long eventId, long documentId) { + FlexMap document = this.eventDocumentService.get(eventId, documentId); if (document == null) throw new WebApplicationException("Document not found", Status.NOT_FOUND); @@ -97,12 +97,12 @@ public class EventApi extends com.poststats.golf.api.EventApi { } @Override - public void sendTestDocument(long documentId, long personId) { - FlexMap document = this.eventDocumentService.get(this.getEventId(), documentId); + public void sendTestDocument(long eventId, long documentId, long personId) { + FlexMap document = this.eventDocumentService.get(eventId, documentId); if (document == null) throw new WebApplicationException("Document not found", Status.NOT_FOUND); - FlexMap eperson = this.eventPersonService.get(this.getEventId(), personId); + FlexMap eperson = this.eventPersonService.get(eventId, personId); if (eperson == null) throw new WebApplicationException("Person not found", Status.NOT_FOUND); diff --git a/src/main/java/com/poststats/golf/api/impl/EventFinanceApi.java b/src/main/java/com/poststats/golf/api/impl/EventFinanceApi.java index fa3da0f..bb2c5b4 100644 --- a/src/main/java/com/poststats/golf/api/impl/EventFinanceApi.java +++ b/src/main/java/com/poststats/golf/api/impl/EventFinanceApi.java @@ -20,14 +20,14 @@ import jakarta.ws.rs.WebApplicationException; import jakarta.ws.rs.core.StreamingOutput; @RequestScoped -public class EventFinanceApi extends com.poststats.golf.api.EventFinanceApi { +public class EventFinanceApi implements com.poststats.golf.api.EventFinanceApi { @Inject private EventFinanceService eventFinanceService; @Override - public List> getBalanceByPersonsAsJson(Float minBalance, Float maxBalance) { - Map personsBalances = this.eventFinanceService.getPersonsBalances(this.getEventId(), minBalance, + public List> getBalanceByPersonsAsJson(long eventId, Float minBalance, Float maxBalance) { + Map personsBalances = this.eventFinanceService.getPersonsBalances(eventId, minBalance, maxBalance); List> personsBalancesJson = new ArrayList<>(personsBalances.size()); @@ -44,8 +44,8 @@ public class EventFinanceApi extends com.poststats.golf.api.EventFinanceApi { } @Override - public StreamingOutput getBalanceByPersonsAsCsv() { - Map personsBalances = this.eventFinanceService.getPersonsBalances(this.getEventId()); + public StreamingOutput getBalanceByPersonsAsCsv(long eventId) { + Map personsBalances = this.eventFinanceService.getPersonsBalances(eventId); return new StreamingOutput() { @Override @@ -72,8 +72,8 @@ public class EventFinanceApi extends com.poststats.golf.api.EventFinanceApi { } @Override - public Map getBalanceByPersonsAsJson(long personId) { - DataSet personBalance = this.eventFinanceService.getPersonBalance(this.getEventId(), personId); + public Map getBalanceByPersonsAsJson(long eventId, long personId) { + DataSet personBalance = this.eventFinanceService.getPersonBalance(eventId, personId); Map personBalanceJson = new HashMap<>(5); personBalanceJson.put("personId", personBalance.getLong("personID")); @@ -85,9 +85,9 @@ public class EventFinanceApi extends com.poststats.golf.api.EventFinanceApi { } @Override - public List> getSeriesBalanceByPersonsAsJson() { + public List> getSeriesBalanceByPersonsAsJson(long eventId) { Map personsBalances = this.eventFinanceService - .getSeriesPersonsPreviousBalances(this.getEventId()); + .getSeriesPersonsPreviousBalances(eventId); List> personsBalancesJson = new ArrayList<>(personsBalances.size()); for (DataSet personBalance : personsBalances.values()) { diff --git a/src/main/java/com/poststats/golf/api/impl/EventPersonApi.java b/src/main/java/com/poststats/golf/api/impl/EventPersonApi.java index 350ea27..82867eb 100644 --- a/src/main/java/com/poststats/golf/api/impl/EventPersonApi.java +++ b/src/main/java/com/poststats/golf/api/impl/EventPersonApi.java @@ -22,7 +22,7 @@ import jakarta.inject.Inject; import jakarta.ws.rs.core.StreamingOutput; @RequestScoped -public class EventPersonApi extends com.poststats.golf.api.EventPersonApi { +public class EventPersonApi implements com.poststats.golf.api.EventPersonApi { @Inject private EventService eventService; @@ -37,44 +37,44 @@ public class EventPersonApi extends com.poststats.golf.api.EventPersonApi { private DaoConverter converter; @Override - public List get() { - return this.converter.convertValue(this.eventPersonService.getPeople(this.getEventId()), EventPerson.class); + public List get(long eventId) { + return this.converter.convertValue(this.eventPersonService.getPeople(eventId), EventPerson.class); } @Override - public List getDetail() { - List persons = this.eventPersonService.getPeople(this.getEventId()); + public List getDetail(long eventId) { + List persons = this.eventPersonService.getPeople(eventId); this.golferService.injectDeep("personID", persons, "golfer"); return this.converter.convertValue(persons, EventPerson.class); } @Override - public StreamingOutput getAsCsv() { - List persons = this.eventPersonService.getPeople(this.getEventId()); + public StreamingOutput getAsCsv(long eventId) { + List persons = this.eventPersonService.getPeople(eventId); return this.toCsv(persons); } @Override - public List getParticipants() { - List participants = this.eventPersonService.getParticipants(this.getEventId()); + public List getParticipants(long eventId) { + List participants = this.eventPersonService.getParticipants(eventId); this.golferService.injectDeep("personID", participants, "golfer"); return this.converter.convertValue(participants, EventPerson.class); } @Override - public StreamingOutput getParticipantsAsCsv() { - List persons = this.eventPersonService.getParticipants(this.getEventId()); + public StreamingOutput getParticipantsAsCsv(long eventId) { + List persons = this.eventPersonService.getParticipants(eventId); return this.toCsv(persons); } @Override - public Set getSeriesParticipants() { - int seriesId = this.eventService.getSeriesId(this.getEventId()); + public Set getSeriesParticipants(long eventId) { + int seriesId = this.eventService.getSeriesId(eventId); Set eventIds = this.eventService.getIdsBySeriesId(seriesId); Set personIds = new HashSet<>(); - for (long eventId : eventIds) { - List tmpPersons = this.eventPersonService.getParticipants(eventId); + for (long otherEventId : eventIds) { + List tmpPersons = this.eventPersonService.getParticipants(otherEventId); for (FlexMap person : tmpPersons) personIds.add(person.getLong(com.poststats.sql.Constants.PERSON_ID)); } diff --git a/src/main/java/com/poststats/golf/api/impl/EventRoundApi.java b/src/main/java/com/poststats/golf/api/impl/EventRoundApi.java index 63c3938..16af6c7 100644 --- a/src/main/java/com/poststats/golf/api/impl/EventRoundApi.java +++ b/src/main/java/com/poststats/golf/api/impl/EventRoundApi.java @@ -41,7 +41,7 @@ import jakarta.ws.rs.core.StreamingOutput; * @author brian.long@poststats.com */ @RequestScoped -public class EventRoundApi extends com.poststats.golf.api.EventRoundApi { +public class EventRoundApi implements com.poststats.golf.api.EventRoundApi { @Inject private Logger logger; @@ -63,12 +63,12 @@ public class EventRoundApi extends com.poststats.golf.api.EventRoundApi { @PostConstruct public void init() { - this.logger.debug("EventRoundApi init: {}", this.getEventId()); + this.logger.debug("EventRoundApi init"); } @Override - public List getNext() { - List rows = this.roundService.getUpcoming(this.getEventId()); + public List getNext(long eventId) { + List rows = this.roundService.getUpcoming(eventId); if (rows == null || rows.isEmpty()) throw new WebApplicationException("No event round was found", Status.NOT_FOUND); @@ -77,13 +77,12 @@ public class EventRoundApi extends com.poststats.golf.api.EventRoundApi { } @Override - public EventRound getOne(long eroundId) { + public EventRound getOne(long eventId, long eroundId) { FlexMap row = this.roundService.get(eroundId); if (row == null) throw new WebApplicationException("Event round not found", Status.NOT_FOUND); - if (this.getEventId() != row.getLong("eventID")) { - this.logger.warn("The event round {} was requested without the appropriate event ID {}", eroundId, - this.getEventId()); + if (eventId != row.getLong("eventID")) { + this.logger.warn("The event round {} was requested without the appropriate event ID {}", eroundId, eventId); throw new WebApplicationException("Event round not found", Status.NOT_FOUND); } @@ -92,8 +91,8 @@ public class EventRoundApi extends com.poststats.golf.api.EventRoundApi { } @Override - public List getAll() { - Map rows = this.roundService.getByEventId(this.getEventId()); + public List getAll(long eventId) { + Map rows = this.roundService.getByEventId(eventId); if (rows.isEmpty()) throw new WebApplicationException("No event rounds found", Status.NOT_FOUND); @@ -101,7 +100,7 @@ public class EventRoundApi extends com.poststats.golf.api.EventRoundApi { } @Override - public List getPairings(long eroundId) { + public List getPairings(long eventId, long eroundId) { List rows = this.pairingService.getByRoundId(eroundId); if (rows == null || rows.isEmpty()) throw new WebApplicationException("No pairings found", Status.NOT_FOUND); @@ -111,7 +110,7 @@ public class EventRoundApi extends com.poststats.golf.api.EventRoundApi { } @Override - public StreamingOutput getPairingsAsCsv(long eroundId, List orderBys, + public StreamingOutput getPairingsAsCsv(long eventId, long eroundId, List orderBys, boolean lastNameFirst) { this.logger.debug("getPairingsAsCsv({}, {})", eroundId, lastNameFirst); @@ -144,7 +143,7 @@ public class EventRoundApi extends com.poststats.golf.api.EventRoundApi { } @Override - public EventRoundPairing getPairing(long eroundId, BigInteger pairingId) { + public EventRoundPairing getPairing(long eventId, long eroundId, BigInteger pairingId) { FlexMap row = this.pairingService.get(pairingId); if (row == null) throw new WebApplicationException("No pairing was found", Status.NOT_FOUND);