added document API

This commit is contained in:
Brian Long 2024-06-14 16:36:38 -04:00
parent f853010793
commit 07e505f206
5 changed files with 330 additions and 0 deletions

View File

@ -0,0 +1,100 @@
package com.poststats.golf.rs.api;
import java.util.List;
import com.poststats.golf.rs.api.model.EventDocument;
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;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
/**
* @author brian.long@poststats.com
*/
@Path("/golf/event/{eventId}")
@Tag(name = "Event Round API")
public interface EventDocumentApi {
@GET
@Path("/document/{documentId:[0-9]+}")
@Produces(Constants.V1_JSON)
@Operation(
summary = "Retrieves limited meta-data about the specified document.",
description = "Retreives name, location, dates, and other direct meta-data about the specified document."
)
@ApiResponses({
@ApiResponse(responseCode = "200", description = "Success"),
@ApiResponse(
responseCode = "404",
description = "An event or event round with the specified ID could not be found"
)
})
EventDocument getOne(
@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);
@GET
@Path("/documents")
@Produces(Constants.V1_JSON)
@Operation(
summary = "Retrieves limited meta-data about all the documents in the specified event.",
description = "Retreives name, location, dates, and other direct meta-data about all the documents in the specified event."
)
@ApiResponses({
@ApiResponse(responseCode = "200", description = "Success"),
@ApiResponse(
responseCode = "404",
description = "An event with the specified ID or any event documents could not be found"
)
})
List<EventDocument> getAll(@Parameter(description = "A unique identifier for an event")
@NotNull @Positive @PathParam("eventId") long eventId);
@POST
@Path("/document/{documentId:[0-9]+}/sendAgenda")
@Produces(Constants.V1_JSON)
@Operation(summary = "Sends the specified agenda immediately.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "Success"),
@ApiResponse(
responseCode = "404",
description = "A document with the specified ID in the specified event could not be found"
)
})
void sendAgenda(
@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:[0-9]+}/sendAgenda/{personId:[0-9]+}")
@Produces(Constants.V1_JSON)
@Operation(summary = "Sends the specified agenda immediately.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "Success"),
@ApiResponse(
responseCode = "404",
description = "A document with the specified ID in the specified event could not be found"
)
})
void sendAgenda(
@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

@ -0,0 +1,127 @@
package com.poststats.golf.rs.api.model;
import java.time.LocalDate;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.poststats.rs.api.annotation.MapEntry;
import com.poststats.rs.api.model.BaseModel;
@JsonIgnoreProperties(ignoreUnknown = true)
public abstract class BaseEventDocument<ConcreteT extends BaseEventDocument<ConcreteT>> extends BaseModel<ConcreteT> {
@JsonProperty
@MapEntry
private String type;
@JsonProperty
@MapEntry
private LocalDate day;
@JsonProperty
@MapEntry("liveline")
private LocalDate publicationDate;
@JsonProperty
@MapEntry
private boolean sendEmailWithLink;
@JsonProperty
@MapEntry
private boolean sendEmailWithContent;
@JsonProperty
@MapEntry
private boolean sendTextWithLink;
@JsonProperty
@MapEntry
private boolean sendTextWithContent;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public LocalDate getDay() {
return day;
}
public void setDay(LocalDate day) {
this.day = day;
}
public LocalDate getPublicationDate() {
return publicationDate;
}
public void setPublicationDate(LocalDate publicationDate) {
this.publicationDate = publicationDate;
}
public boolean isSendEmailWithLink() {
return sendEmailWithLink;
}
public void setSendEmailWithLink(boolean sendEmailWithLink) {
this.sendEmailWithLink = sendEmailWithLink;
}
public boolean isSendEmailWithContent() {
return sendEmailWithContent;
}
public void setSendEmailWithContent(boolean sendEmailWithContent) {
this.sendEmailWithContent = sendEmailWithContent;
}
public boolean isSendTextWithLink() {
return sendTextWithLink;
}
public void setSendTextWithLink(boolean sendTextWithLink) {
this.sendTextWithLink = sendTextWithLink;
}
public boolean isSendTextWithContent() {
return sendTextWithContent;
}
public void setSendTextWithContent(boolean sendTextWithContent) {
this.sendTextWithContent = sendTextWithContent;
}
public ConcreteT withDay(LocalDate day) {
this.day = day;
return this.withThis();
}
public ConcreteT withPublicationDate(LocalDate publicationDate) {
this.publicationDate = publicationDate;
return this.withThis();
}
public ConcreteT withSendEmailWithLink(boolean sendEmailWithLink) {
this.sendEmailWithLink = sendEmailWithLink;
return this.withThis();
}
public ConcreteT withSendEmailWithContent(boolean sendEmailWithContent) {
this.sendEmailWithContent = sendEmailWithContent;
return this.withThis();
}
public ConcreteT withSendTextWithLink(boolean sendTextWithLink) {
this.sendTextWithLink = sendTextWithLink;
return this.withThis();
}
public ConcreteT withSendTextWithContent(boolean sendTextWithContent) {
this.sendTextWithContent = sendTextWithContent;
return this.withThis();
}
}

View File

@ -0,0 +1,66 @@
package com.poststats.golf.rs.api.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty.Access;
import com.poststats.rs.api.annotation.MapEntry;
/**
* @author brian.long@poststats.com
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class EventDocument extends BaseEventDocument<EventDocument> implements ReferenceableEventDocument {
@JsonProperty(required = true, access = Access.READ_ONLY)
@MapEntry("documentID")
private long id;
@JsonProperty
@MapEntry
private Event event;
@JsonProperty
@MapEntry("eventID")
private Long eventId;
@Override
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public Event getEvent() {
return event;
}
public void setEvent(Event event) {
this.event = event;
}
public Long getEventId() {
return eventId;
}
public void setEventId(Long eventId) {
this.eventId = eventId;
}
public EventDocument withId(long id) {
this.id = id;
return this;
}
public EventDocument withEvent(Event event) {
this.event = event;
return this;
}
public EventDocument withEventId(Long eventId) {
this.eventId = eventId;
return this;
}
}

View File

@ -0,0 +1,7 @@
package com.poststats.golf.rs.api.model;
public interface ReferenceableEventDocument {
long getId();
}

View File

@ -0,0 +1,30 @@
package com.poststats.golf.rs.api.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.poststats.rs.api.annotation.MapEntry;
/**
* @author brian.long@poststats.com
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class TransientEventDocument extends BaseEventDocument<TransientEventDocument> {
@JsonProperty
@MapEntry
private ReferenceableEvent event;
public ReferenceableEvent getEvent() {
return event;
}
public void setEvent(ReferenceableEvent event) {
this.event = event;
}
public TransientEventDocument withCourse(ReferenceableEvent event) {
this.event = event;
return this;
}
}