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")
@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);
}

View File

@@ -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);
}

View File

@@ -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<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);
@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<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
@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<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 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,16 +22,7 @@ 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")
@@ -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<? extends EventPerson> get();
List<? extends EventPerson> 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<? extends EventPerson> getDetail();
List<? extends EventPerson> 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<? extends EventPerson> getParticipants();
List<? extends EventPerson> 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<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 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<EventRound> getNext();
List<EventRound> 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<EventRound> getAll();
List<EventRound> 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<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
@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<EventRoundPairingOrder> 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);
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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<Map<String, Object>> getBalanceByPersonsAsJson(Float minBalance, Float maxBalance) {
Map<Long, DataSet> personsBalances = this.eventFinanceService.getPersonsBalances(this.getEventId(), minBalance,
public List<Map<String, Object>> getBalanceByPersonsAsJson(long eventId, Float minBalance, Float maxBalance) {
Map<Long, DataSet> personsBalances = this.eventFinanceService.getPersonsBalances(eventId, minBalance,
maxBalance);
List<Map<String, Object>> personsBalancesJson = new ArrayList<>(personsBalances.size());
@@ -44,8 +44,8 @@ public class EventFinanceApi extends com.poststats.golf.api.EventFinanceApi {
}
@Override
public StreamingOutput getBalanceByPersonsAsCsv() {
Map<Long, DataSet> personsBalances = this.eventFinanceService.getPersonsBalances(this.getEventId());
public StreamingOutput getBalanceByPersonsAsCsv(long eventId) {
Map<Long, DataSet> 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<String, Object> getBalanceByPersonsAsJson(long personId) {
DataSet personBalance = this.eventFinanceService.getPersonBalance(this.getEventId(), personId);
public Map<String, Object> getBalanceByPersonsAsJson(long eventId, long personId) {
DataSet personBalance = this.eventFinanceService.getPersonBalance(eventId, personId);
Map<String, Object> 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<Map<String, Object>> getSeriesBalanceByPersonsAsJson() {
public List<Map<String, Object>> getSeriesBalanceByPersonsAsJson(long eventId) {
Map<Long, DataSet> personsBalances = this.eventFinanceService
.getSeriesPersonsPreviousBalances(this.getEventId());
.getSeriesPersonsPreviousBalances(eventId);
List<Map<String, Object>> personsBalancesJson = new ArrayList<>(personsBalances.size());
for (DataSet personBalance : personsBalances.values()) {

View File

@@ -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<? extends EventPerson> get() {
return this.converter.convertValue(this.eventPersonService.getPeople(this.getEventId()), EventPerson.class);
public List<? extends EventPerson> get(long eventId) {
return this.converter.convertValue(this.eventPersonService.getPeople(eventId), EventPerson.class);
}
@Override
public List<? extends EventPerson> getDetail() {
List<? extends FlexMap> persons = this.eventPersonService.getPeople(this.getEventId());
public List<? extends EventPerson> getDetail(long eventId) {
List<? extends FlexMap> persons = this.eventPersonService.getPeople(eventId);
this.golferService.injectDeep("personID", persons, "golfer");
return this.converter.convertValue(persons, EventPerson.class);
}
@Override
public StreamingOutput getAsCsv() {
List<? extends FlexMap> persons = this.eventPersonService.getPeople(this.getEventId());
public StreamingOutput getAsCsv(long eventId) {
List<? extends FlexMap> persons = this.eventPersonService.getPeople(eventId);
return this.toCsv(persons);
}
@Override
public List<? extends EventPerson> getParticipants() {
List<? extends FlexMap> participants = this.eventPersonService.getParticipants(this.getEventId());
public List<? extends EventPerson> getParticipants(long eventId) {
List<? extends FlexMap> participants = this.eventPersonService.getParticipants(eventId);
this.golferService.injectDeep("personID", participants, "golfer");
return this.converter.convertValue(participants, EventPerson.class);
}
@Override
public StreamingOutput getParticipantsAsCsv() {
List<? extends FlexMap> persons = this.eventPersonService.getParticipants(this.getEventId());
public StreamingOutput getParticipantsAsCsv(long eventId) {
List<? extends FlexMap> persons = this.eventPersonService.getParticipants(eventId);
return this.toCsv(persons);
}
@Override
public Set<Long> getSeriesParticipants() {
int seriesId = this.eventService.getSeriesId(this.getEventId());
public Set<Long> getSeriesParticipants(long eventId) {
int seriesId = this.eventService.getSeriesId(eventId);
Set<Long> eventIds = this.eventService.getIdsBySeriesId(seriesId);
Set<Long> personIds = new HashSet<>();
for (long eventId : eventIds) {
List<? extends FlexMap> tmpPersons = this.eventPersonService.getParticipants(eventId);
for (long otherEventId : eventIds) {
List<? extends FlexMap> tmpPersons = this.eventPersonService.getParticipants(otherEventId);
for (FlexMap person : tmpPersons)
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
*/
@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<EventRound> getNext() {
List<? extends FlexMap> rows = this.roundService.getUpcoming(this.getEventId());
public List<EventRound> getNext(long eventId) {
List<? extends FlexMap> 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<EventRound> getAll() {
Map<Long, ? extends FlexMap> rows = this.roundService.getByEventId(this.getEventId());
public List<EventRound> getAll(long eventId) {
Map<Long, ? extends FlexMap> 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<EventRoundPairing> getPairings(long eroundId) {
public List<EventRoundPairing> getPairings(long eventId, long eroundId) {
List<? extends FlexMap> 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<EventRoundPairingOrder> orderBys,
public StreamingOutput getPairingsAsCsv(long eventId, long eroundId, List<EventRoundPairingOrder> 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);