another fixes for @PathParam

This commit is contained in:
2023-07-05 12:30:58 -04:00
parent 9627dba941
commit b571db1f4e
10 changed files with 103 additions and 139 deletions

View File

@@ -21,17 +21,7 @@ import jakarta.ws.rs.Produces;
@Tag(name = "Course API") @Tag(name = "Course API")
@ApiResponse(responseCode = "200", description = "Success") @ApiResponse(responseCode = "200", description = "Success")
@ApiResponse(responseCode = "404", description = "A golf course with the specified ID could not be found") @ApiResponse(responseCode = "404", description = "A golf course with the specified ID could not be found")
public abstract class CourseApi { public interface CourseApi {
@Parameter(description = "A unique identifier for a golf course")
@NotNull
@Positive
@PathParam("courseId")
private int courseId;
protected int getCourseId() {
return this.courseId;
}
@GET @GET
@Produces(Constants.V1_JSON) @Produces(Constants.V1_JSON)
@@ -39,7 +29,8 @@ public abstract class CourseApi {
summary = "Retrieves meta-data about a course.", summary = "Retrieves meta-data about a course.",
description = "Retreives name, location, and other direct meta-data about the specified 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 @GET
@Path("/nine/byName/{name}") @Path("/nine/byName/{name}")
@@ -48,7 +39,9 @@ public abstract class CourseApi {
summary = "Retrieves meta-data about a course nine.", summary = "Retrieves meta-data about a course nine.",
description = "Retreives name, location, and other direct meta-data about the specified course." 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 @GET
@Path("/nine/{nineId:[0-9]+}") @Path("/nine/{nineId:[0-9]+}")
@@ -57,6 +50,8 @@ public abstract class CourseApi {
summary = "Retrieves limited meta-data about a course nine.", summary = "Retrieves limited meta-data about a course nine.",
description = "Retreives name, location, and other direct meta-data about the specified course." 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);
} }

View File

@@ -3,6 +3,7 @@ package com.poststats.golf.api;
import com.poststats.golf.api.model.Event; import com.poststats.golf.api.model.Event;
import io.swagger.v3.oas.annotations.Operation; 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.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
@@ -20,16 +21,7 @@ import jakarta.ws.rs.Produces;
*/ */
@Path("/golf/event/{eventId}") @Path("/golf/event/{eventId}")
@Tag(name = "Event API") @Tag(name = "Event API")
public abstract class EventApi { public interface EventApi {
@NotNull
@Positive
@PathParam("eventId")
private long eventId;
protected long getEventId() {
return this.eventId;
}
@GET @GET
@Produces(Constants.V1_JSON) @Produces(Constants.V1_JSON)
@@ -41,7 +33,7 @@ public abstract class EventApi {
@ApiResponse(responseCode = "200", description = "Success"), @ApiResponse(responseCode = "200", description = "Success"),
@ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found") @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 @GET
@Path("/detail") @Path("/detail")
@@ -54,7 +46,7 @@ public abstract class EventApi {
@ApiResponse(responseCode = "200", description = "Success"), @ApiResponse(responseCode = "200", description = "Success"),
@ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found") @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 @POST
@Path("/document/{documentId}/send") @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" 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 @POST
@Path("/document/{documentId}/sendTest/{personId}") @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" description = "An event, document, or person with the specified ID could not be found"
) )
}) })
public abstract void sendTestDocument(@PathParam("documentId") long documentId, void sendTestDocument(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId,
@PathParam("personId") long personId); @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);
} }

View File

@@ -4,6 +4,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import io.swagger.v3.oas.annotations.Operation; 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.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
@@ -20,16 +21,7 @@ import jakarta.ws.rs.core.StreamingOutput;
@Path("/golf/event/{eventId}/finance") @Path("/golf/event/{eventId}/finance")
@Tag(name = "Event Finance API") @Tag(name = "Event Finance API")
public abstract class EventFinanceApi { public interface EventFinanceApi {
@NotNull
@Positive
@PathParam("eventId")
private long eventId;
protected long getEventId() {
return this.eventId;
}
@GET @GET
@Path("/balance/persons") @Path("/balance/persons")
@@ -46,7 +38,8 @@ public abstract class EventFinanceApi {
@ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"), @ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"),
@ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found") @ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found")
}) })
public abstract List<Map<String, Object>> getBalanceByPersonsAsJson(@QueryParam("minBalance") Float minBalance, List<Map<String, Object>> getBalanceByPersonsAsJson(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId,
@QueryParam("minBalance") Float minBalance,
@QueryParam("maxBalance") Float maxBalance); @QueryParam("maxBalance") Float maxBalance);
@GET @GET
@@ -64,7 +57,7 @@ public abstract class EventFinanceApi {
@ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"), @ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"),
@ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found") @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 @GET
@Path("/balance/person/{personId}") @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" description = "An event or person with the specified IDs could not be found"
) )
}) })
public abstract Map<String, Object> getBalanceByPersonsAsJson(@PathParam("personId") long personId); Map<String, Object> 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 @GET
@Path("/series/balance/persons") @Path("/series/balance/persons")
@@ -101,6 +95,6 @@ public abstract class EventFinanceApi {
@ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"), @ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"),
@ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found") @ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found")
}) })
public abstract List<Map<String, Object>> getSeriesBalanceByPersonsAsJson(); List<Map<String, Object>> getSeriesBalanceByPersonsAsJson(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId);
} }

View File

@@ -6,6 +6,7 @@ import java.util.Set;
import com.poststats.golf.api.model.EventPerson; import com.poststats.golf.api.model.EventPerson;
import io.swagger.v3.oas.annotations.Operation; 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.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
@@ -21,17 +22,8 @@ import jakarta.ws.rs.core.StreamingOutput;
@Path("/golf/event/{eventId}") @Path("/golf/event/{eventId}")
@Tag(name = "Event Participant API") @Tag(name = "Event Participant API")
public abstract class EventPersonApi { public interface EventPersonApi {
@NotNull
@Positive
@PathParam("eventId")
private long eventId;
protected long getEventId() {
return this.eventId;
}
@GET @GET
@Path("/people") @Path("/people")
@RolesAllowed( @RolesAllowed(
@@ -47,7 +39,7 @@ public abstract class EventPersonApi {
@ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"), @ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"),
@ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found") @ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found")
}) })
public abstract List<? extends EventPerson> get(); List<? extends EventPerson> get(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId);
@GET @GET
@Path("/people/detail") @Path("/people/detail")
@@ -64,7 +56,7 @@ public abstract class EventPersonApi {
@ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"), @ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"),
@ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found") @ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found")
}) })
public abstract List<? extends EventPerson> getDetail(); List<? extends EventPerson> getDetail(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId);
@GET @GET
@Path("/people/csv") @Path("/people/csv")
@@ -81,7 +73,7 @@ public abstract class EventPersonApi {
@ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"), @ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"),
@ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found") @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 @GET
@Path("/participants") @Path("/participants")
@@ -91,7 +83,7 @@ public abstract class EventPersonApi {
@ApiResponse(responseCode = "200", description = "Success"), @ApiResponse(responseCode = "200", description = "Success"),
@ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found") @ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found")
}) })
public abstract List<? extends EventPerson> getParticipants(); List<? extends EventPerson> getParticipants(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId);
@GET @GET
@Path("/participants/csv") @Path("/participants/csv")
@@ -108,7 +100,7 @@ public abstract class EventPersonApi {
@ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"), @ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"),
@ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found") @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 @GET
@Path("/series/participants") @Path("/series/participants")
@@ -125,6 +117,6 @@ public abstract class EventPersonApi {
@ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"), @ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"),
@ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found") @ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found")
}) })
public abstract Set<Long> getSeriesParticipants(); Set<Long> getSeriesParticipants(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId);
} }

View File

@@ -9,6 +9,7 @@ import com.poststats.golf.api.model.EventRoundPairing;
import com.poststats.golf.api.model.EventRoundPairingOrder; import com.poststats.golf.api.model.EventRoundPairingOrder;
import io.swagger.v3.oas.annotations.Operation; 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.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
@@ -26,16 +27,7 @@ import jakarta.ws.rs.core.StreamingOutput;
*/ */
@Path("/golf/event/{eventId}") @Path("/golf/event/{eventId}")
@Tag(name = "Event Round API") @Tag(name = "Event Round API")
public abstract class EventRoundApi { public interface EventRoundApi {
@NotNull
@Positive
@PathParam("eventId")
private long eventId;
protected long getEventId() {
return this.eventId;
}
@GET @GET
@Path("/rounds/next") @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" description = "An event with the specified ID or upcoming event rounds could not be found"
) )
}) })
public abstract List<EventRound> getNext(); List<EventRound> getNext(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId);
@GET @GET
@Path("/round/{eroundId:[0-9]+}") @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" 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 @GET
@Path("/rounds") @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" description = "An event with the specified ID or any event rounds could not be found"
) )
}) })
public abstract List<EventRound> getAll(); List<EventRound> getAll(@Parameter(description = "A unique identifier for an event") @NotNull @Positive @PathParam("eventId") long eventId);
@GET @GET
@Path("/round/{eroundId:[0-9]+}/pairings") @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" description = "An event or its round with the specified ID could not be found"
) )
}) })
public abstract List<EventRoundPairing> getPairings(@PathParam("eroundId") long eroundId); List<EventRoundPairing> 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 @GET
@Path("/round/{eroundId:[0-9]+}/pairings/csv") @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" 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<EventRoundPairingOrder> orderBys, @QueryParam("orderBy") List<EventRoundPairingOrder> orderBys,
@QueryParam("lastNameFirst") boolean lastNameFirst); @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" 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); @PathParam("pairingID") BigInteger pairingId);
} }

View File

@@ -10,7 +10,6 @@ import com.poststats.golf.service.CourseService;
import com.poststats.service.FacilityService; import com.poststats.service.FacilityService;
import com.poststats.transformer.impl.DaoConverter; import com.poststats.transformer.impl.DaoConverter;
import jakarta.annotation.PostConstruct;
import jakarta.enterprise.context.RequestScoped; import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.ws.rs.WebApplicationException; import jakarta.ws.rs.WebApplicationException;
@@ -20,7 +19,7 @@ import jakarta.ws.rs.core.Response.Status;
* @author brian.long@poststats.com * @author brian.long@poststats.com
*/ */
@RequestScoped @RequestScoped
public class CourseApi extends com.poststats.golf.api.CourseApi { public class CourseApi implements com.poststats.golf.api.CourseApi {
@Inject @Inject
private Logger logger; private Logger logger;
@@ -37,39 +36,34 @@ public class CourseApi extends com.poststats.golf.api.CourseApi {
@Inject @Inject
private DaoConverter converter; private DaoConverter converter;
@PostConstruct
public void init() {
this.logger.debug("CourseApi init: {}", this.getCourseId());
}
@Override @Override
public Course get() { public Course get(int courseId) {
FlexMap row = this.courseService.get(this.getCourseId()); FlexMap row = this.courseService.get(courseId);
if (row == null) if (row == null)
throw new WebApplicationException("Course not found", Status.NOT_FOUND); 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"); this.facilityService.inject("facilityID", row, "facility");
return this.converter.convertValue(row, Course.class); return this.converter.convertValue(row, Course.class);
} }
@Override @Override
public CourseNine getNine(String name) { public CourseNine getNine(int courseId, String name) {
FlexMap row = this.courseNineService.getNine(this.getCourseId(), name); FlexMap row = this.courseNineService.getNine(courseId, name);
if (row == null) if (row == null)
throw new WebApplicationException("Course nine not found", Status.NOT_FOUND); 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"); this.courseService.injectDeep("courseID", row, "course");
return this.converter.convertValue(row, CourseNine.class); return this.converter.convertValue(row, CourseNine.class);
} }
@Override @Override
public CourseNine getNine(long courseNineId) { public CourseNine getNine(int courseId, long courseNineId) {
FlexMap row = this.courseNineService.getNine(courseNineId); FlexMap row = this.courseNineService.getNine(courseNineId);
if (row == null) if (row == null)
throw new WebApplicationException("Course nine not found", Status.NOT_FOUND); 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); throw new WebApplicationException("Course nine not found", Status.NOT_FOUND);
this.logger.trace("found: {}", courseNineId); this.logger.trace("found: {}", courseNineId);

View File

@@ -29,7 +29,7 @@ import jakarta.ws.rs.core.Response.Status;
* @author brian.long@poststats.com * @author brian.long@poststats.com
*/ */
@RequestScoped @RequestScoped
public class EventApi extends com.poststats.golf.api.EventApi { public class EventApi implements com.poststats.golf.api.EventApi {
@Inject @Inject
private Logger logger; private Logger logger;
@@ -54,12 +54,12 @@ public class EventApi extends com.poststats.golf.api.EventApi {
@PostConstruct @PostConstruct
public void init() { public void init() {
this.logger.debug("EventApi init: {}", this.getEventId()); this.logger.debug("EventApi init");
} }
@Override @Override
public Event get() { public Event get(long eventId) {
FlexMap row = this.eventService.get(this.getEventId()); FlexMap row = this.eventService.get(eventId);
if (row == null) if (row == null)
throw new WebApplicationException("Event not found", Status.NOT_FOUND); throw new WebApplicationException("Event not found", Status.NOT_FOUND);
@@ -68,8 +68,8 @@ public class EventApi extends com.poststats.golf.api.EventApi {
} }
@Override @Override
public Event getDetail() { public Event getDetail(long eventId) {
FlexMap row = this.eventService.get(this.getEventId()); FlexMap row = this.eventService.get(eventId);
if (row == null) if (row == null)
throw new WebApplicationException("Event not found", Status.NOT_FOUND); throw new WebApplicationException("Event not found", Status.NOT_FOUND);
@@ -78,8 +78,8 @@ public class EventApi extends com.poststats.golf.api.EventApi {
} }
@Override @Override
public void sendDocument(long documentId) { public void sendDocument(long eventId, long documentId) {
FlexMap document = this.eventDocumentService.get(this.getEventId(), documentId); FlexMap document = this.eventDocumentService.get(eventId, documentId);
if (document == null) if (document == null)
throw new WebApplicationException("Document not found", Status.NOT_FOUND); throw new WebApplicationException("Document not found", Status.NOT_FOUND);
@@ -97,12 +97,12 @@ public class EventApi extends com.poststats.golf.api.EventApi {
} }
@Override @Override
public void sendTestDocument(long documentId, long personId) { public void sendTestDocument(long eventId, long documentId, long personId) {
FlexMap document = this.eventDocumentService.get(this.getEventId(), documentId); FlexMap document = this.eventDocumentService.get(eventId, documentId);
if (document == null) if (document == null)
throw new WebApplicationException("Document not found", Status.NOT_FOUND); 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) if (eperson == null)
throw new WebApplicationException("Person not found", Status.NOT_FOUND); throw new WebApplicationException("Person not found", Status.NOT_FOUND);

View File

@@ -20,14 +20,14 @@ import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.StreamingOutput; import jakarta.ws.rs.core.StreamingOutput;
@RequestScoped @RequestScoped
public class EventFinanceApi extends com.poststats.golf.api.EventFinanceApi { public class EventFinanceApi implements com.poststats.golf.api.EventFinanceApi {
@Inject @Inject
private EventFinanceService eventFinanceService; private EventFinanceService eventFinanceService;
@Override @Override
public List<Map<String, Object>> getBalanceByPersonsAsJson(Float minBalance, Float maxBalance) { public List<Map<String, Object>> getBalanceByPersonsAsJson(long eventId, Float minBalance, Float maxBalance) {
Map<Long, DataSet> personsBalances = this.eventFinanceService.getPersonsBalances(this.getEventId(), minBalance, Map<Long, DataSet> personsBalances = this.eventFinanceService.getPersonsBalances(eventId, minBalance,
maxBalance); maxBalance);
List<Map<String, Object>> personsBalancesJson = new ArrayList<>(personsBalances.size()); List<Map<String, Object>> personsBalancesJson = new ArrayList<>(personsBalances.size());
@@ -44,8 +44,8 @@ public class EventFinanceApi extends com.poststats.golf.api.EventFinanceApi {
} }
@Override @Override
public StreamingOutput getBalanceByPersonsAsCsv() { public StreamingOutput getBalanceByPersonsAsCsv(long eventId) {
Map<Long, DataSet> personsBalances = this.eventFinanceService.getPersonsBalances(this.getEventId()); Map<Long, DataSet> personsBalances = this.eventFinanceService.getPersonsBalances(eventId);
return new StreamingOutput() { return new StreamingOutput() {
@Override @Override
@@ -72,8 +72,8 @@ public class EventFinanceApi extends com.poststats.golf.api.EventFinanceApi {
} }
@Override @Override
public Map<String, Object> getBalanceByPersonsAsJson(long personId) { public Map<String, Object> getBalanceByPersonsAsJson(long eventId, long personId) {
DataSet personBalance = this.eventFinanceService.getPersonBalance(this.getEventId(), personId); DataSet personBalance = this.eventFinanceService.getPersonBalance(eventId, personId);
Map<String, Object> personBalanceJson = new HashMap<>(5); Map<String, Object> personBalanceJson = new HashMap<>(5);
personBalanceJson.put("personId", personBalance.getLong("personID")); personBalanceJson.put("personId", personBalance.getLong("personID"));
@@ -85,9 +85,9 @@ public class EventFinanceApi extends com.poststats.golf.api.EventFinanceApi {
} }
@Override @Override
public List<Map<String, Object>> getSeriesBalanceByPersonsAsJson() { public List<Map<String, Object>> getSeriesBalanceByPersonsAsJson(long eventId) {
Map<Long, DataSet> personsBalances = this.eventFinanceService Map<Long, DataSet> personsBalances = this.eventFinanceService
.getSeriesPersonsPreviousBalances(this.getEventId()); .getSeriesPersonsPreviousBalances(eventId);
List<Map<String, Object>> personsBalancesJson = new ArrayList<>(personsBalances.size()); List<Map<String, Object>> personsBalancesJson = new ArrayList<>(personsBalances.size());
for (DataSet personBalance : personsBalances.values()) { for (DataSet personBalance : personsBalances.values()) {

View File

@@ -22,7 +22,7 @@ import jakarta.inject.Inject;
import jakarta.ws.rs.core.StreamingOutput; import jakarta.ws.rs.core.StreamingOutput;
@RequestScoped @RequestScoped
public class EventPersonApi extends com.poststats.golf.api.EventPersonApi { public class EventPersonApi implements com.poststats.golf.api.EventPersonApi {
@Inject @Inject
private EventService eventService; private EventService eventService;
@@ -37,44 +37,44 @@ public class EventPersonApi extends com.poststats.golf.api.EventPersonApi {
private DaoConverter converter; private DaoConverter converter;
@Override @Override
public List<? extends EventPerson> get() { public List<? extends EventPerson> get(long eventId) {
return this.converter.convertValue(this.eventPersonService.getPeople(this.getEventId()), EventPerson.class); return this.converter.convertValue(this.eventPersonService.getPeople(eventId), EventPerson.class);
} }
@Override @Override
public List<? extends EventPerson> getDetail() { public List<? extends EventPerson> getDetail(long eventId) {
List<? extends FlexMap> persons = this.eventPersonService.getPeople(this.getEventId()); List<? extends FlexMap> persons = this.eventPersonService.getPeople(eventId);
this.golferService.injectDeep("personID", persons, "golfer"); this.golferService.injectDeep("personID", persons, "golfer");
return this.converter.convertValue(persons, EventPerson.class); return this.converter.convertValue(persons, EventPerson.class);
} }
@Override @Override
public StreamingOutput getAsCsv() { public StreamingOutput getAsCsv(long eventId) {
List<? extends FlexMap> persons = this.eventPersonService.getPeople(this.getEventId()); List<? extends FlexMap> persons = this.eventPersonService.getPeople(eventId);
return this.toCsv(persons); return this.toCsv(persons);
} }
@Override @Override
public List<? extends EventPerson> getParticipants() { public List<? extends EventPerson> getParticipants(long eventId) {
List<? extends FlexMap> participants = this.eventPersonService.getParticipants(this.getEventId()); List<? extends FlexMap> participants = this.eventPersonService.getParticipants(eventId);
this.golferService.injectDeep("personID", participants, "golfer"); this.golferService.injectDeep("personID", participants, "golfer");
return this.converter.convertValue(participants, EventPerson.class); return this.converter.convertValue(participants, EventPerson.class);
} }
@Override @Override
public StreamingOutput getParticipantsAsCsv() { public StreamingOutput getParticipantsAsCsv(long eventId) {
List<? extends FlexMap> persons = this.eventPersonService.getParticipants(this.getEventId()); List<? extends FlexMap> persons = this.eventPersonService.getParticipants(eventId);
return this.toCsv(persons); return this.toCsv(persons);
} }
@Override @Override
public Set<Long> getSeriesParticipants() { public Set<Long> getSeriesParticipants(long eventId) {
int seriesId = this.eventService.getSeriesId(this.getEventId()); int seriesId = this.eventService.getSeriesId(eventId);
Set<Long> eventIds = this.eventService.getIdsBySeriesId(seriesId); Set<Long> eventIds = this.eventService.getIdsBySeriesId(seriesId);
Set<Long> personIds = new HashSet<>(); Set<Long> personIds = new HashSet<>();
for (long eventId : eventIds) { for (long otherEventId : eventIds) {
List<? extends FlexMap> tmpPersons = this.eventPersonService.getParticipants(eventId); List<? extends FlexMap> tmpPersons = this.eventPersonService.getParticipants(otherEventId);
for (FlexMap person : tmpPersons) for (FlexMap person : tmpPersons)
personIds.add(person.getLong(com.poststats.sql.Constants.PERSON_ID)); personIds.add(person.getLong(com.poststats.sql.Constants.PERSON_ID));
} }

View File

@@ -41,7 +41,7 @@ import jakarta.ws.rs.core.StreamingOutput;
* @author brian.long@poststats.com * @author brian.long@poststats.com
*/ */
@RequestScoped @RequestScoped
public class EventRoundApi extends com.poststats.golf.api.EventRoundApi { public class EventRoundApi implements com.poststats.golf.api.EventRoundApi {
@Inject @Inject
private Logger logger; private Logger logger;
@@ -63,12 +63,12 @@ public class EventRoundApi extends com.poststats.golf.api.EventRoundApi {
@PostConstruct @PostConstruct
public void init() { public void init() {
this.logger.debug("EventRoundApi init: {}", this.getEventId()); this.logger.debug("EventRoundApi init");
} }
@Override @Override
public List<EventRound> getNext() { public List<EventRound> getNext(long eventId) {
List<? extends FlexMap> rows = this.roundService.getUpcoming(this.getEventId()); List<? extends FlexMap> rows = this.roundService.getUpcoming(eventId);
if (rows == null || rows.isEmpty()) if (rows == null || rows.isEmpty())
throw new WebApplicationException("No event round was found", Status.NOT_FOUND); 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 @Override
public EventRound getOne(long eroundId) { public EventRound getOne(long eventId, long eroundId) {
FlexMap row = this.roundService.get(eroundId); FlexMap row = this.roundService.get(eroundId);
if (row == null) if (row == null)
throw new WebApplicationException("Event round not found", Status.NOT_FOUND); throw new WebApplicationException("Event round not found", Status.NOT_FOUND);
if (this.getEventId() != row.getLong("eventID")) { if (eventId != row.getLong("eventID")) {
this.logger.warn("The event round {} was requested without the appropriate event ID {}", eroundId, this.logger.warn("The event round {} was requested without the appropriate event ID {}", eroundId, eventId);
this.getEventId());
throw new WebApplicationException("Event round not found", Status.NOT_FOUND); throw new WebApplicationException("Event round not found", Status.NOT_FOUND);
} }
@@ -92,8 +91,8 @@ public class EventRoundApi extends com.poststats.golf.api.EventRoundApi {
} }
@Override @Override
public List<EventRound> getAll() { public List<EventRound> getAll(long eventId) {
Map<Long, ? extends FlexMap> rows = this.roundService.getByEventId(this.getEventId()); Map<Long, ? extends FlexMap> rows = this.roundService.getByEventId(eventId);
if (rows.isEmpty()) if (rows.isEmpty())
throw new WebApplicationException("No event rounds found", Status.NOT_FOUND); throw new WebApplicationException("No event rounds found", Status.NOT_FOUND);
@@ -101,7 +100,7 @@ public class EventRoundApi extends com.poststats.golf.api.EventRoundApi {
} }
@Override @Override
public List<EventRoundPairing> getPairings(long eroundId) { public List<EventRoundPairing> getPairings(long eventId, long eroundId) {
List<? extends FlexMap> rows = this.pairingService.getByRoundId(eroundId); List<? extends FlexMap> rows = this.pairingService.getByRoundId(eroundId);
if (rows == null || rows.isEmpty()) if (rows == null || rows.isEmpty())
throw new WebApplicationException("No pairings found", Status.NOT_FOUND); throw new WebApplicationException("No pairings found", Status.NOT_FOUND);
@@ -111,7 +110,7 @@ public class EventRoundApi extends com.poststats.golf.api.EventRoundApi {
} }
@Override @Override
public StreamingOutput getPairingsAsCsv(long eroundId, List<EventRoundPairingOrder> orderBys, public StreamingOutput getPairingsAsCsv(long eventId, long eroundId, List<EventRoundPairingOrder> orderBys,
boolean lastNameFirst) { boolean lastNameFirst) {
this.logger.debug("getPairingsAsCsv({}, {})", eroundId, lastNameFirst); this.logger.debug("getPairingsAsCsv({}, {})", eroundId, lastNameFirst);
@@ -144,7 +143,7 @@ public class EventRoundApi extends com.poststats.golf.api.EventRoundApi {
} }
@Override @Override
public EventRoundPairing getPairing(long eroundId, BigInteger pairingId) { public EventRoundPairing getPairing(long eventId, long eroundId, BigInteger pairingId) {
FlexMap row = this.pairingService.get(pairingId); FlexMap row = this.pairingService.get(pairingId);
if (row == null) if (row == null)
throw new WebApplicationException("No pairing was found", Status.NOT_FOUND); throw new WebApplicationException("No pairing was found", Status.NOT_FOUND);