fixed resource-scoped @PathParam

This commit is contained in:
2023-07-05 10:42:10 -04:00
parent 59d40ecba9
commit 9627dba941
15 changed files with 137 additions and 170 deletions

View File

@@ -21,11 +21,17 @@ 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 interface CourseApi {
public abstract class CourseApi {
@Parameter(description = "A unique identifier for a golf course")
@NotNull
@Positive
@PathParam("courseId")
void setCourseId(@NotNull @Positive int courseId);
private int courseId;
protected int getCourseId() {
return this.courseId;
}
@GET
@Produces(Constants.V1_JSON)
@@ -33,7 +39,7 @@ public interface CourseApi {
summary = "Retrieves meta-data about a course.",
description = "Retreives name, location, and other direct meta-data about the specified course."
)
Course get();
public abstract Course get();
@GET
@Path("/nine/byName/{name}")
@@ -42,7 +48,7 @@ public interface CourseApi {
summary = "Retrieves meta-data about a course nine.",
description = "Retreives name, location, and other direct meta-data about the specified course."
)
CourseNine getNine(@PathParam("name") String name);
public abstract CourseNine getNine(@PathParam("name") String name);
@GET
@Path("/nine/{nineId:[0-9]+}")
@@ -51,6 +57,6 @@ public interface CourseApi {
summary = "Retrieves limited meta-data about a course nine.",
description = "Retreives name, location, and other direct meta-data about the specified course."
)
CourseNine getNine(@PathParam("nineId") long courseNineId);
public abstract CourseNine getNine(@PathParam("nineId") long courseNineId);
}

View File

@@ -20,10 +20,16 @@ import jakarta.ws.rs.Produces;
*/
@Path("/golf/event/{eventId}")
@Tag(name = "Event API")
public interface EventApi {
public abstract class EventApi {
@NotNull
@Positive
@PathParam("eventId")
void setEventId(@NotNull @Positive long eventId);
private long eventId;
protected long getEventId() {
return this.eventId;
}
@GET
@Produces(Constants.V1_JSON)
@@ -35,7 +41,7 @@ public interface EventApi {
@ApiResponse(responseCode = "200", description = "Success"),
@ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found")
})
Event get();
public abstract Event get();
@GET
@Path("/detail")
@@ -48,7 +54,7 @@ public interface EventApi {
@ApiResponse(responseCode = "200", description = "Success"),
@ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found")
})
Event getDetail();
public abstract Event getDetail();
@POST
@Path("/document/{documentId}/send")
@@ -68,7 +74,7 @@ public interface EventApi {
description = "An event or document with the specified ID could not be found"
)
})
void sendDocument(@PathParam("documentId") long documentId);
public abstract void sendDocument(@PathParam("documentId") long documentId);
@POST
@Path("/document/{documentId}/sendTest/{personId}")
@@ -88,6 +94,7 @@ public interface EventApi {
description = "An event, document, or person with the specified ID could not be found"
)
})
void sendTestDocument(@PathParam("documentId") long documentId, @PathParam("personId") long personId);
public abstract void sendTestDocument(@PathParam("documentId") long documentId,
@PathParam("personId") long personId);
}

View File

@@ -16,16 +16,20 @@ import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.SecurityContext;
import jakarta.ws.rs.core.StreamingOutput;
@Path("/golf/event/{eventId}/finance")
@Tag(name = "Event Finance API")
public interface EventFinanceApi {
public abstract class EventFinanceApi {
@NotNull
@Positive
@PathParam("eventId")
void setEventId(@NotNull @Positive long eventId);
private long eventId;
protected long getEventId() {
return this.eventId;
}
@GET
@Path("/balance/persons")
@@ -42,8 +46,8 @@ public interface EventFinanceApi {
@ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"),
@ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found")
})
List<Map<String, Object>> getBalanceByPersonsAsJson(@Context SecurityContext securityContext,
@QueryParam("minBalance") Float minBalance, @QueryParam("maxBalance") Float maxBalance);
public abstract List<Map<String, Object>> getBalanceByPersonsAsJson(@QueryParam("minBalance") Float minBalance,
@QueryParam("maxBalance") Float maxBalance);
@GET
@Path("/balance/persons/csv")
@@ -60,7 +64,7 @@ public interface EventFinanceApi {
@ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"),
@ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found")
})
StreamingOutput getBalanceByPersonsAsCsv(@Context SecurityContext securityContext);
public abstract StreamingOutput getBalanceByPersonsAsCsv();
@GET
@Path("/balance/person/{personId}")
@@ -80,8 +84,7 @@ public interface EventFinanceApi {
description = "An event or person with the specified IDs could not be found"
)
})
Map<String, Object> getBalanceByPersonsAsJson(@Context SecurityContext securityContext,
@PathParam("personId") long personId);
public abstract Map<String, Object> getBalanceByPersonsAsJson(@PathParam("personId") long personId);
@GET
@Path("/series/balance/persons")
@@ -98,6 +101,6 @@ public interface EventFinanceApi {
@ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"),
@ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found")
})
List<Map<String, Object>> getSeriesBalanceByPersonsAsJson(@Context SecurityContext securityContext);
public abstract List<Map<String, Object>> getSeriesBalanceByPersonsAsJson();
}

View File

@@ -21,10 +21,16 @@ import jakarta.ws.rs.core.StreamingOutput;
@Path("/golf/event/{eventId}")
@Tag(name = "Event Participant API")
public interface EventPersonApi {
public abstract class EventPersonApi {
@NotNull
@Positive
@PathParam("eventId")
void setEventId(@NotNull @Positive long eventId);
private long eventId;
protected long getEventId() {
return this.eventId;
}
@GET
@Path("/people")
@@ -41,7 +47,7 @@ public interface EventPersonApi {
@ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"),
@ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found")
})
List<? extends EventPerson> get();
public abstract List<? extends EventPerson> get();
@GET
@Path("/people/detail")
@@ -58,7 +64,7 @@ public interface EventPersonApi {
@ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"),
@ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found")
})
List<? extends EventPerson> getDetail();
public abstract List<? extends EventPerson> getDetail();
@GET
@Path("/people/csv")
@@ -75,7 +81,7 @@ public interface EventPersonApi {
@ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"),
@ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found")
})
StreamingOutput getAsCsv();
public abstract StreamingOutput getAsCsv();
@GET
@Path("/participants")
@@ -85,7 +91,7 @@ public interface EventPersonApi {
@ApiResponse(responseCode = "200", description = "Success"),
@ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found")
})
List<? extends EventPerson> getParticipants();
public abstract List<? extends EventPerson> getParticipants();
@GET
@Path("/participants/csv")
@@ -102,7 +108,7 @@ public interface EventPersonApi {
@ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"),
@ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found")
})
StreamingOutput getParticipantsAsCsv();
public abstract StreamingOutput getParticipantsAsCsv();
@GET
@Path("/series/participants")
@@ -119,6 +125,6 @@ public interface EventPersonApi {
@ApiResponse(responseCode = "403", description = "Authenticated, but not permitted"),
@ApiResponse(responseCode = "404", description = "An event with the specified ID could not be found")
})
Set<Long> getSeriesParticipants();
public abstract Set<Long> getSeriesParticipants();
}

View File

@@ -26,10 +26,16 @@ import jakarta.ws.rs.core.StreamingOutput;
*/
@Path("/golf/event/{eventId}")
@Tag(name = "Event Round API")
public interface EventRoundApi {
public abstract class EventRoundApi {
@NotNull
@Positive
@PathParam("eventId")
void setEventId(@NotNull @Positive long eventId);
private long eventId;
protected long getEventId() {
return this.eventId;
}
@GET
@Path("/rounds/next")
@@ -45,7 +51,7 @@ public interface EventRoundApi {
description = "An event with the specified ID or upcoming event rounds could not be found"
)
})
List<EventRound> getNext();
public abstract List<EventRound> getNext();
@GET
@Path("/round/{eroundId:[0-9]+}")
@@ -61,7 +67,7 @@ public interface EventRoundApi {
description = "An event or event round with the specified ID could not be found"
)
})
EventRound getOne(@PathParam("eroundId") long eroundId);
public abstract EventRound getOne(@PathParam("eroundId") long eroundId);
@GET
@Path("/rounds")
@@ -77,7 +83,7 @@ public interface EventRoundApi {
description = "An event with the specified ID or any event rounds could not be found"
)
})
List<EventRound> getAll();
public abstract List<EventRound> getAll();
@GET
@Path("/round/{eroundId:[0-9]+}/pairings")
@@ -90,7 +96,7 @@ public interface EventRoundApi {
description = "An event or its round with the specified ID could not be found"
)
})
List<EventRoundPairing> getPairings(@PathParam("eroundId") long eroundId);
public abstract List<EventRoundPairing> getPairings(@PathParam("eroundId") long eroundId);
@GET
@Path("/round/{eroundId:[0-9]+}/pairings/csv")
@@ -103,7 +109,7 @@ public interface EventRoundApi {
description = "An event or its round with the specified ID could not be found"
)
})
StreamingOutput getPairingsAsCsv(@PathParam("eroundId") long eroundId,
public abstract StreamingOutput getPairingsAsCsv(@PathParam("eroundId") long eroundId,
@QueryParam("orderBy") List<EventRoundPairingOrder> orderBys,
@QueryParam("lastNameFirst") boolean lastNameFirst);
@@ -118,6 +124,7 @@ public interface EventRoundApi {
description = "An event with the specified ID or upcoming event rounds could not be found"
)
})
EventRoundPairing getPairing(@PathParam("eroundId") long eroundId, @PathParam("pairingID") BigInteger pairingId);
public abstract EventRoundPairing getPairing(@PathParam("eroundId") long eroundId,
@PathParam("pairingID") BigInteger pairingId);
}

View File

@@ -19,10 +19,16 @@ import jakarta.ws.rs.Produces;
*/
@Path("/golfer/{personId}")
@Tag(name = "Golfer API")
public interface GolferApi {
public abstract class GolferApi {
@NotNull
@Positive
@PathParam("personId")
void setPersonId(@NotNull @Positive long personId);
private long personId;
protected long getPersonId() {
return this.personId;
}
@GET
@Produces(Constants.V1_JSON)
@@ -34,6 +40,6 @@ public interface GolferApi {
@ApiResponse(responseCode = "200", description = "Success"),
@ApiResponse(responseCode = "404", description = "A golfer with the specified ID could not be found")
})
Golfer get();
public abstract Golfer get();
}

View File

@@ -23,10 +23,16 @@ import jakarta.ws.rs.QueryParam;
*/
@Path("/golf/series/{seriesId}")
@Tag(name = "Event Series API")
public interface SeriesApi {
public abstract class SeriesApi {
@NotNull
@Positive
@PathParam("seriesId")
void setSeriesId(@NotNull @Positive int seriesId);
private int seriesId;
protected int getSeriesId() {
return this.seriesId;
}
@GET
@Produces(Constants.V1_JSON)
@@ -38,7 +44,7 @@ public interface SeriesApi {
@ApiResponse(responseCode = "200", description = "Success"),
@ApiResponse(responseCode = "404", description = "An event series with the specified ID could not be found")
})
Series get();
public abstract Series get();
@GET
@Path("/events")
@@ -51,6 +57,6 @@ public interface SeriesApi {
@ApiResponse(responseCode = "200", description = "Success"),
@ApiResponse(responseCode = "404", description = "An event series with the specified ID could not be found")
})
List<Event> getEvents(@QueryParam("reverse") Boolean reverse);
public abstract List<Event> getEvents(@QueryParam("reverse") Boolean reverse);
}

View File

@@ -1,22 +0,0 @@
package com.poststats.golf.api.impl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jakarta.annotation.PostConstruct;
import jakarta.enterprise.context.RequestScoped;
/**
* @author brian.long@poststats.com
*/
@RequestScoped
public class BaseApi implements com.poststats.golf.api.BaseApi {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@PostConstruct
public void init() {
this.logger.debug("BaseApi init");
}
}

View File

@@ -13,8 +13,6 @@ import com.poststats.transformer.impl.DaoConverter;
import jakarta.annotation.PostConstruct;
import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Inject;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.Response.Status;
@@ -22,9 +20,7 @@ import jakarta.ws.rs.core.Response.Status;
* @author brian.long@poststats.com
*/
@RequestScoped
public class CourseApi implements com.poststats.golf.api.CourseApi {
private int courseId;
public class CourseApi extends com.poststats.golf.api.CourseApi {
@Inject
private Logger logger;
@@ -43,20 +39,15 @@ public class CourseApi implements com.poststats.golf.api.CourseApi {
@PostConstruct
public void init() {
this.logger.debug("CourseApi init: {}", this.courseId);
}
@Override
public void setCourseId(@NotNull @Positive int courseId) {
this.courseId = courseId;
this.logger.debug("CourseApi init: {}", this.getCourseId());
}
@Override
public Course get() {
FlexMap row = this.courseService.get(this.courseId);
FlexMap row = this.courseService.get(this.getCourseId());
if (row == null)
throw new WebApplicationException("Course not found", Status.NOT_FOUND);
this.logger.trace("found: {}", this.courseId);
this.logger.trace("found: {}", this.getCourseId());
this.facilityService.inject("facilityID", row, "facility");
return this.converter.convertValue(row, Course.class);
@@ -64,10 +55,10 @@ public class CourseApi implements com.poststats.golf.api.CourseApi {
@Override
public CourseNine getNine(String name) {
FlexMap row = this.courseNineService.getNine(this.courseId, name);
FlexMap row = this.courseNineService.getNine(this.getCourseId(), name);
if (row == null)
throw new WebApplicationException("Course nine not found", Status.NOT_FOUND);
this.logger.trace("found: {}", this.courseId);
this.logger.trace("found: {}", this.getCourseId());
this.courseService.injectDeep("courseID", row, "course");
return this.converter.convertValue(row, CourseNine.class);
@@ -78,7 +69,7 @@ public class CourseApi implements com.poststats.golf.api.CourseApi {
FlexMap row = this.courseNineService.getNine(courseNineId);
if (row == null)
throw new WebApplicationException("Course nine not found", Status.NOT_FOUND);
if (this.courseId != row.getInteger("courseID"))
if (this.getCourseId() != row.getInteger("courseID"))
throw new WebApplicationException("Course nine not found", Status.NOT_FOUND);
this.logger.trace("found: {}", courseNineId);

View File

@@ -7,7 +7,6 @@ import java.util.Collections;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.brianlong.cache.CacheRetrievalException;
import com.brianlong.util.FlexMap;
@@ -30,11 +29,10 @@ import jakarta.ws.rs.core.Response.Status;
* @author brian.long@poststats.com
*/
@RequestScoped
public class EventApi implements com.poststats.golf.api.EventApi {
public class EventApi extends com.poststats.golf.api.EventApi {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private long eventId;
@Inject
private Logger logger;
@Inject
private EventService eventService;
@@ -56,16 +54,12 @@ public class EventApi implements com.poststats.golf.api.EventApi {
@PostConstruct
public void init() {
this.logger.debug("EventApi init: {}", this.eventId);
}
public void setEventId(long eventId) {
this.eventId = eventId;
this.logger.debug("EventApi init: {}", this.getEventId());
}
@Override
public Event get() {
FlexMap row = this.eventService.get(this.eventId);
FlexMap row = this.eventService.get(this.getEventId());
if (row == null)
throw new WebApplicationException("Event not found", Status.NOT_FOUND);
@@ -75,7 +69,7 @@ public class EventApi implements com.poststats.golf.api.EventApi {
@Override
public Event getDetail() {
FlexMap row = this.eventService.get(this.eventId);
FlexMap row = this.eventService.get(this.getEventId());
if (row == null)
throw new WebApplicationException("Event not found", Status.NOT_FOUND);
@@ -85,7 +79,7 @@ public class EventApi implements com.poststats.golf.api.EventApi {
@Override
public void sendDocument(long documentId) {
FlexMap document = this.eventDocumentService.get(this.eventId, documentId);
FlexMap document = this.eventDocumentService.get(this.getEventId(), documentId);
if (document == null)
throw new WebApplicationException("Document not found", Status.NOT_FOUND);
@@ -104,11 +98,11 @@ public class EventApi implements com.poststats.golf.api.EventApi {
@Override
public void sendTestDocument(long documentId, long personId) {
FlexMap document = this.eventDocumentService.get(this.eventId, documentId);
FlexMap document = this.eventDocumentService.get(this.getEventId(), documentId);
if (document == null)
throw new WebApplicationException("Document not found", Status.NOT_FOUND);
FlexMap eperson = this.eventPersonService.get(this.eventId, personId);
FlexMap eperson = this.eventPersonService.get(this.getEventId(), personId);
if (eperson == null)
throw new WebApplicationException("Person not found", Status.NOT_FOUND);

View File

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

View File

@@ -22,9 +22,7 @@ import jakarta.inject.Inject;
import jakarta.ws.rs.core.StreamingOutput;
@RequestScoped
public class EventPersonApi implements com.poststats.golf.api.EventPersonApi {
private long eventId;
public class EventPersonApi extends com.poststats.golf.api.EventPersonApi {
@Inject
private EventService eventService;
@@ -38,45 +36,40 @@ public class EventPersonApi implements com.poststats.golf.api.EventPersonApi {
@Inject
private DaoConverter converter;
@Override
public void setEventId(long eventId) {
this.eventId = eventId;
}
@Override
public List<? extends EventPerson> get() {
return this.converter.convertValue(this.eventPersonService.getPeople(this.eventId), EventPerson.class);
return this.converter.convertValue(this.eventPersonService.getPeople(this.getEventId()), EventPerson.class);
}
@Override
public List<? extends EventPerson> getDetail() {
List<? extends FlexMap> persons = this.eventPersonService.getPeople(this.eventId);
List<? extends FlexMap> persons = this.eventPersonService.getPeople(this.getEventId());
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.eventId);
List<? extends FlexMap> persons = this.eventPersonService.getPeople(this.getEventId());
return this.toCsv(persons);
}
@Override
public List<? extends EventPerson> getParticipants() {
List<? extends FlexMap> participants = this.eventPersonService.getParticipants(this.eventId);
List<? extends FlexMap> participants = this.eventPersonService.getParticipants(this.getEventId());
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.eventId);
List<? extends FlexMap> persons = this.eventPersonService.getParticipants(this.getEventId());
return this.toCsv(persons);
}
@Override
public Set<Long> getSeriesParticipants() {
int seriesId = this.eventService.getSeriesId(this.eventId);
int seriesId = this.eventService.getSeriesId(this.getEventId());
Set<Long> eventIds = this.eventService.getIdsBySeriesId(seriesId);
Set<Long> personIds = new HashSet<>();

View File

@@ -16,7 +16,6 @@ import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.brianlong.util.FlexMap;
import com.poststats.formatter.PersonFormatter;
@@ -42,11 +41,10 @@ import jakarta.ws.rs.core.StreamingOutput;
* @author brian.long@poststats.com
*/
@RequestScoped
public class EventRoundApi implements com.poststats.golf.api.EventRoundApi {
public class EventRoundApi extends com.poststats.golf.api.EventRoundApi {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private long eventId;
@Inject
private Logger logger;
@Inject
private PersonService golferService;
@@ -65,17 +63,12 @@ public class EventRoundApi implements com.poststats.golf.api.EventRoundApi {
@PostConstruct
public void init() {
this.logger.debug("EventRoundApi init: {}", this.eventId);
}
@Override
public void setEventId(long eventId) {
this.eventId = eventId;
this.logger.debug("EventRoundApi init: {}", this.getEventId());
}
@Override
public List<EventRound> getNext() {
List<? extends FlexMap> rows = this.roundService.getUpcoming(this.eventId);
List<? extends FlexMap> rows = this.roundService.getUpcoming(this.getEventId());
if (rows == null || rows.isEmpty())
throw new WebApplicationException("No event round was found", Status.NOT_FOUND);
@@ -88,9 +81,9 @@ public class EventRoundApi implements com.poststats.golf.api.EventRoundApi {
FlexMap row = this.roundService.get(eroundId);
if (row == null)
throw new WebApplicationException("Event round not found", Status.NOT_FOUND);
if (this.eventId != row.getLong("eventID")) {
if (this.getEventId() != row.getLong("eventID")) {
this.logger.warn("The event round {} was requested without the appropriate event ID {}", eroundId,
this.eventId);
this.getEventId());
throw new WebApplicationException("Event round not found", Status.NOT_FOUND);
}
@@ -100,7 +93,7 @@ public class EventRoundApi implements com.poststats.golf.api.EventRoundApi {
@Override
public List<EventRound> getAll() {
Map<Long, ? extends FlexMap> rows = this.roundService.getByEventId(this.eventId);
Map<Long, ? extends FlexMap> rows = this.roundService.getByEventId(this.getEventId());
if (rows.isEmpty())
throw new WebApplicationException("No event rounds found", Status.NOT_FOUND);

View File

@@ -1,7 +1,6 @@
package com.poststats.golf.api.impl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.brianlong.util.FlexMap;
import com.poststats.golf.api.model.Golfer;
@@ -18,11 +17,10 @@ import jakarta.ws.rs.core.Response.Status;
* @author brian.long@poststats.com
*/
@RequestScoped
public class GolferApi implements com.poststats.golf.api.GolferApi {
public class GolferApi extends com.poststats.golf.api.GolferApi {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private long personId;
@Inject
private Logger logger;
@Inject
private PersonService personService;
@@ -35,17 +33,12 @@ public class GolferApi implements com.poststats.golf.api.GolferApi {
@PostConstruct
public void init() {
this.logger.debug("GolferApi init: {}", this.personId);
}
@Override
public void setPersonId(long personId) {
this.personId = personId;
this.logger.debug("GolferApi init: {}", this.getPersonId());
}
@Override
public Golfer get() {
FlexMap row = this.personService.get(this.personId);
FlexMap row = this.personService.get(this.getPersonId());
if (row == null)
throw new WebApplicationException("Event not found", Status.NOT_FOUND);

View File

@@ -5,7 +5,6 @@ import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.brianlong.util.FlexMap;
import com.poststats.golf.api.model.Event;
@@ -24,11 +23,10 @@ import jakarta.ws.rs.core.Response.Status;
* @author brian.long@poststats.com
*/
@RequestScoped
public class SeriesApi implements com.poststats.golf.api.SeriesApi {
public class SeriesApi extends com.poststats.golf.api.SeriesApi {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private int seriesId;
@Inject
private Logger logger;
@Inject
private SeriesService seriesService;
@@ -41,17 +39,12 @@ public class SeriesApi implements com.poststats.golf.api.SeriesApi {
@PostConstruct
public void init() {
this.logger.debug("SeriesApi init: {}", this.seriesId);
}
@Override
public void setSeriesId(int seriesId) {
this.seriesId = seriesId;
this.logger.debug("SeriesApi init: {}", this.getSeriesId());
}
@Override
public Series get() {
FlexMap row = this.seriesService.get(this.seriesId);
FlexMap row = this.seriesService.get(this.getSeriesId());
if (row == null)
throw new WebApplicationException("Series not found", Status.NOT_FOUND);
@@ -60,7 +53,7 @@ public class SeriesApi implements com.poststats.golf.api.SeriesApi {
@Override
public List<Event> getEvents(Boolean reverse) {
Map<Long, ? extends FlexMap> rows = this.eventService.getBySeriesId(this.seriesId);
Map<Long, ? extends FlexMap> rows = this.eventService.getBySeriesId(this.getSeriesId());
if (rows.isEmpty())
throw new WebApplicationException("Series or events not found", Status.NOT_FOUND);