fixed agenda job for autolists
This commit is contained in:
@@ -6,7 +6,8 @@ public class Constants extends com.poststats.api.Constants {
|
|||||||
public static final String EVENT_ROLE = "event";
|
public static final String EVENT_ROLE = "event";
|
||||||
public static final String EVENT_SERIES_ROLE = "series";
|
public static final String EVENT_SERIES_ROLE = "series";
|
||||||
public static final String COURSE_ROLE = "course";
|
public static final String COURSE_ROLE = "course";
|
||||||
public static final String BUDDY_ROLE_PREFIX = BUDDY_ROLE + ":";
|
public static final String BUDDY_ROLE_PREFIX = BUDDY_ROLE
|
||||||
|
+ ":";
|
||||||
public static final String EVENT_ROLE_PREFIX = "event:";
|
public static final String EVENT_ROLE_PREFIX = "event:";
|
||||||
public static final String EVENT_SERIES_ROLE_PREFIX = "series:";
|
public static final String EVENT_SERIES_ROLE_PREFIX = "series:";
|
||||||
public static final String COURSE_ROLE_PREFIX = "course:";
|
public static final String COURSE_ROLE_PREFIX = "course:";
|
||||||
|
@@ -79,7 +79,8 @@ public 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 CourseNine getNine(@PathParam("name") String name) {
|
public CourseNine getNine(@PathParam("name")
|
||||||
|
String name) {
|
||||||
FlexMap row = this.courseNineService.getNine(this.courseId, name);
|
FlexMap row = this.courseNineService.getNine(this.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);
|
||||||
@@ -96,7 +97,8 @@ public 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 CourseNine getNine(@PathParam("nineId") long courseNineId) {
|
public CourseNine getNine(@PathParam("nineId")
|
||||||
|
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);
|
||||||
|
@@ -74,8 +74,10 @@ public class CoursesApi {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
@Tag(name = "Search API")
|
@Tag(name = "Search API")
|
||||||
public PagedCollection<List<Course>> searchByName(@QueryParam("name") String name,
|
public PagedCollection<List<Course>> searchByName(@QueryParam("name")
|
||||||
@BeanParam @Valid Pagination paging) {
|
String name, @BeanParam
|
||||||
|
@Valid
|
||||||
|
Pagination paging) {
|
||||||
SubList<? extends FlexMap> rows = this.courseService.findByName(name, paging.getPage(), paging.getPerPage());
|
SubList<? extends FlexMap> rows = this.courseService.findByName(name, paging.getPage(), paging.getPerPage());
|
||||||
if (rows.isEmpty())
|
if (rows.isEmpty())
|
||||||
throw new WebApplicationException("No matching courses found", Status.NOT_FOUND);
|
throw new WebApplicationException("No matching courses found", Status.NOT_FOUND);
|
||||||
@@ -98,8 +100,11 @@ public class CoursesApi {
|
|||||||
@Parameter(name = "state", description = "A State or high-level jurisdiction", example = "FL")
|
@Parameter(name = "state", description = "A State or high-level jurisdiction", example = "FL")
|
||||||
})
|
})
|
||||||
@Tag(name = "Search API")
|
@Tag(name = "Search API")
|
||||||
public PagedCollection<List<Course>> searchByJurisdiction(@PathParam("country") String country,
|
public PagedCollection<List<Course>> searchByJurisdiction(@PathParam("country")
|
||||||
@PathParam("state") String state, @BeanParam @Valid Pagination paging) {
|
String country, @PathParam("state")
|
||||||
|
String state, @BeanParam
|
||||||
|
@Valid
|
||||||
|
Pagination paging) {
|
||||||
SubList<? extends FlexMap> rows = this.courseService.findByJurisdiction(country, state, paging.getPage(),
|
SubList<? extends FlexMap> rows = this.courseService.findByJurisdiction(country, state, paging.getPage(),
|
||||||
paging.getPerPage());
|
paging.getPerPage());
|
||||||
if (rows.isEmpty())
|
if (rows.isEmpty())
|
||||||
@@ -133,10 +138,18 @@ public class CoursesApi {
|
|||||||
), @Parameter(name = "radius", description = "A search radius in miles", example = "10")
|
), @Parameter(name = "radius", description = "A search radius in miles", example = "10")
|
||||||
})
|
})
|
||||||
@Tag(name = "Search API")
|
@Tag(name = "Search API")
|
||||||
public PagedCollection<List<Course>> searchByJurisdiction(
|
public PagedCollection<List<Course>> searchByJurisdiction(@QueryParam("latitude")
|
||||||
@QueryParam("latitude") @DecimalMin("-90.0") @DecimalMax("90.0") double latitude,
|
@DecimalMin("-90.0")
|
||||||
@QueryParam("longitude") @DecimalMin("-180.0") @DecimalMax("180.0") double longitude,
|
@DecimalMax("90.0")
|
||||||
@QueryParam("radius") @Positive @Max(100) Integer radiusInMiles, @BeanParam @Valid Pagination paging) {
|
double latitude, @QueryParam("longitude")
|
||||||
|
@DecimalMin("-180.0")
|
||||||
|
@DecimalMax("180.0")
|
||||||
|
double longitude, @QueryParam("radius")
|
||||||
|
@Positive
|
||||||
|
@Max(100)
|
||||||
|
Integer radiusInMiles, @BeanParam
|
||||||
|
@Valid
|
||||||
|
Pagination paging) {
|
||||||
SubList<? extends FlexMap> rows = this.courseService.findByLocation(latitude, longitude, radiusInMiles,
|
SubList<? extends FlexMap> rows = this.courseService.findByLocation(latitude, longitude, radiusInMiles,
|
||||||
paging.getPage(), paging.getPerPage());
|
paging.getPage(), paging.getPerPage());
|
||||||
if (rows.isEmpty())
|
if (rows.isEmpty())
|
||||||
|
@@ -1,18 +1,8 @@
|
|||||||
package com.poststats.golf.api;
|
package com.poststats.golf.api;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.math.BigInteger;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.brianlong.cache.CacheRetrievalException;
|
import com.brianlong.cache.CacheRetrievalException;
|
||||||
import com.brianlong.util.FlexMap;
|
import com.brianlong.util.FlexMap;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.poststats.api.Constants;
|
|
||||||
import com.poststats.golf.api.model.Event;
|
import com.poststats.golf.api.model.Event;
|
||||||
import com.poststats.golf.job.EventAgendaJob;
|
import com.poststats.golf.job.EventAgendaJob;
|
||||||
import com.poststats.golf.service.EventDocumentService;
|
import com.poststats.golf.service.EventDocumentService;
|
||||||
@@ -20,12 +10,12 @@ import com.poststats.golf.service.EventPersonService;
|
|||||||
import com.poststats.golf.service.EventService;
|
import com.poststats.golf.service.EventService;
|
||||||
import com.poststats.golf.service.SeriesService;
|
import com.poststats.golf.service.SeriesService;
|
||||||
import com.poststats.transformer.impl.DaoConverter;
|
import com.poststats.transformer.impl.DaoConverter;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
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;
|
||||||
import jakarta.annotation.PostConstruct;
|
import jakarta.annotation.PostConstruct;
|
||||||
|
import jakarta.annotation.security.RolesAllowed;
|
||||||
import jakarta.enterprise.context.RequestScoped;
|
import jakarta.enterprise.context.RequestScoped;
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import jakarta.mail.MessagingException;
|
import jakarta.mail.MessagingException;
|
||||||
@@ -36,6 +26,13 @@ import jakarta.ws.rs.PathParam;
|
|||||||
import jakarta.ws.rs.Produces;
|
import jakarta.ws.rs.Produces;
|
||||||
import jakarta.ws.rs.WebApplicationException;
|
import jakarta.ws.rs.WebApplicationException;
|
||||||
import jakarta.ws.rs.core.Response.Status;
|
import jakarta.ws.rs.core.Response.Status;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Map;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author brian.long@poststats.com
|
* @author brian.long@poststats.com
|
||||||
@@ -53,14 +50,14 @@ public class EventApi {
|
|||||||
@Inject
|
@Inject
|
||||||
private EventService eventService;
|
private EventService eventService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private EventDocumentService eventDocumentService;
|
private EventDocumentService eventDocumentService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private EventPersonService eventPersonService;
|
private EventPersonService eventPersonService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private EventAgendaJob eventAgendaJob;
|
private EventAgendaJob eventAgendaJob;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private SeriesService seriesService;
|
private SeriesService seriesService;
|
||||||
@@ -112,57 +109,77 @@ public class EventApi {
|
|||||||
return this.converter.convertValue(row, Event.class);
|
return this.converter.convertValue(row, Event.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("/document/{documentId}/send")
|
@Path("/document/{documentId}/send")
|
||||||
@Produces(Constants.V1_JSON)
|
@RolesAllowed(
|
||||||
@Operation(
|
Constants.EVENT_ROLE_PREFIX
|
||||||
summary = "Sends the specified document.",
|
+ "communicate"
|
||||||
description = "Sends the specified document off-schedule, regardless of when it is configured to send."
|
)
|
||||||
)
|
@Produces(Constants.V1_JSON)
|
||||||
@ApiResponses({
|
@Operation(
|
||||||
@ApiResponse(responseCode = "200", description = "Success"),
|
summary = "Sends the specified document.",
|
||||||
@ApiResponse(responseCode = "404", description = "An event or document with the specified ID could not be found")
|
description = "Sends the specified document off-schedule, regardless of when it is configured to send."
|
||||||
})
|
)
|
||||||
public void sendDocument(@PathParam("documentId") long documentId) throws CacheRetrievalException, SQLException, MessagingException, IOException {
|
@ApiResponses({
|
||||||
FlexMap document = this.eventDocumentService.get(this.eventId, documentId);
|
@ApiResponse(responseCode = "200", description = "Success"),
|
||||||
if (document == null)
|
@ApiResponse(
|
||||||
throw new WebApplicationException("Document not found", Status.NOT_FOUND);
|
responseCode = "404",
|
||||||
|
description = "An event or document with the specified ID could not be found"
|
||||||
|
)
|
||||||
|
})
|
||||||
|
public void sendDocument(@PathParam("documentId")
|
||||||
|
long documentId) throws CacheRetrievalException, SQLException, MessagingException, IOException {
|
||||||
|
FlexMap document = this.eventDocumentService.get(this.eventId, documentId);
|
||||||
|
if (document == null)
|
||||||
|
throw new WebApplicationException("Document not found", Status.NOT_FOUND);
|
||||||
|
|
||||||
switch (document.getString("type")) {
|
switch (document.getString("type")) {
|
||||||
case "agenda":
|
case "agenda":
|
||||||
this.eventAgendaJob.send(document);
|
this.eventAgendaJob.send(document);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new WebApplicationException("Document is not an agenda", Status.UNSUPPORTED_MEDIA_TYPE);
|
throw new WebApplicationException("Document is not an agenda", Status.UNSUPPORTED_MEDIA_TYPE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("/document/{documentId}/sendTest/{personId}")
|
@Path("/document/{documentId}/sendTest/{personId}")
|
||||||
@Produces(Constants.V1_JSON)
|
@RolesAllowed(
|
||||||
@Operation(
|
Constants.EVENT_ROLE_PREFIX
|
||||||
summary = "Sends the specified document to the specified person.",
|
+ "communicate"
|
||||||
description = "Sends the specified document to only the specified person off-schedule."
|
)
|
||||||
)
|
@Produces(Constants.V1_JSON)
|
||||||
@ApiResponses({
|
@Operation(
|
||||||
@ApiResponse(responseCode = "200", description = "Success"),
|
summary = "Sends the specified document to the specified person.",
|
||||||
@ApiResponse(responseCode = "404", description = "An event, document, or person with the specified ID could not be found")
|
description = "Sends the specified document to only the specified person off-schedule."
|
||||||
})
|
)
|
||||||
public void sendTestDocument(@PathParam("documentId") long documentId, @PathParam("personID") long personId) throws CacheRetrievalException, SQLException, MessagingException, IOException {
|
@ApiResponses({
|
||||||
FlexMap document = this.eventDocumentService.get(this.eventId, documentId);
|
@ApiResponse(responseCode = "200", description = "Success"),
|
||||||
if (document == null)
|
@ApiResponse(
|
||||||
throw new WebApplicationException("Document not found", Status.NOT_FOUND);
|
responseCode = "404",
|
||||||
|
description = "An event, document, or person with the specified ID could not be found"
|
||||||
FlexMap eperson = this.eventPersonService.get(this.eventId, personId);
|
)
|
||||||
Map<Long, BigInteger> recipientIds = Collections.singletonMap(personId, eperson.getBigInteger("epersonID"));
|
})
|
||||||
|
public void sendTestDocument(@PathParam("documentId")
|
||||||
|
long documentId, @PathParam("personId")
|
||||||
|
long personId) throws CacheRetrievalException, SQLException, MessagingException, IOException {
|
||||||
|
FlexMap document = this.eventDocumentService.get(this.eventId, documentId);
|
||||||
|
if (document == null)
|
||||||
|
throw new WebApplicationException("Document not found", Status.NOT_FOUND);
|
||||||
|
|
||||||
switch (document.getString("type")) {
|
FlexMap eperson = this.eventPersonService.get(this.eventId, personId);
|
||||||
case "agenda":
|
if (eperson == null)
|
||||||
this.eventAgendaJob.send(document, recipientIds);
|
throw new WebApplicationException("Person not found", Status.NOT_FOUND);
|
||||||
break;
|
|
||||||
default:
|
Map<Long, BigInteger> recipientIds = Collections.singletonMap(personId, eperson.getBigInteger("epersonID"));
|
||||||
throw new WebApplicationException("Document is not an agenda", Status.UNSUPPORTED_MEDIA_TYPE);
|
|
||||||
}
|
switch (document.getString("type")) {
|
||||||
}
|
case "agenda":
|
||||||
|
this.eventAgendaJob.send(document, recipientIds);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new WebApplicationException("Document is not an agenda", Status.UNSUPPORTED_MEDIA_TYPE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -42,7 +42,10 @@ public class EventFinanceApi {
|
|||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/balance/persons")
|
@Path("/balance/persons")
|
||||||
@RolesAllowed(Constants.EVENT_ROLE_PREFIX + "member")
|
@RolesAllowed(
|
||||||
|
Constants.EVENT_ROLE_PREFIX
|
||||||
|
+ "member"
|
||||||
|
)
|
||||||
@Produces(Constants.V1_JSON)
|
@Produces(Constants.V1_JSON)
|
||||||
@SecurityRequirement(name = "basic")
|
@SecurityRequirement(name = "basic")
|
||||||
@Operation(summary = "Retrieves the balances of all participants in an event.")
|
@Operation(summary = "Retrieves the balances of all participants in an event.")
|
||||||
@@ -52,12 +55,12 @@ public 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 List<Map<String, Object>> getBalanceByPersonsAsJson(@Context SecurityContext securityContext)
|
public List<Map<String, Object>> getBalanceByPersonsAsJson(@Context
|
||||||
throws JsonProcessingException {
|
SecurityContext securityContext) throws JsonProcessingException {
|
||||||
List<DataSet> personsBalances = this.eventFinanceService.getPersonsBalances(this.eventId);
|
Map<Long, DataSet> personsBalances = this.eventFinanceService.getPersonsBalances(this.eventId);
|
||||||
|
|
||||||
List<Map<String, Object>> personsBalancesJson = new ArrayList<>(personsBalances.size());
|
List<Map<String, Object>> personsBalancesJson = new ArrayList<>(personsBalances.size());
|
||||||
for (DataSet personBalance : personsBalances) {
|
for (DataSet personBalance : personsBalances.values()) {
|
||||||
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"));
|
||||||
personBalanceJson.put("expense", personBalance.getFloat("expense"));
|
personBalanceJson.put("expense", personBalance.getFloat("expense"));
|
||||||
@@ -71,7 +74,10 @@ public class EventFinanceApi {
|
|||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/balance/persons/csv")
|
@Path("/balance/persons/csv")
|
||||||
@RolesAllowed(Constants.EVENT_ROLE_PREFIX + "finance")
|
@RolesAllowed(
|
||||||
|
Constants.EVENT_ROLE_PREFIX
|
||||||
|
+ "finance"
|
||||||
|
)
|
||||||
@Produces("text/csv")
|
@Produces("text/csv")
|
||||||
@SecurityRequirement(name = "basic")
|
@SecurityRequirement(name = "basic")
|
||||||
@Operation(summary = "Retrieves the balances of all participants in an event.")
|
@Operation(summary = "Retrieves the balances of all participants in an event.")
|
||||||
@@ -81,8 +87,9 @@ public 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 StreamingOutput getBalanceByPersonsAsCsv(@Context SecurityContext securityContext) throws IOException {
|
public StreamingOutput getBalanceByPersonsAsCsv(@Context
|
||||||
List<DataSet> personsBalances = this.eventFinanceService.getPersonsBalances(this.eventId);
|
SecurityContext securityContext) throws IOException {
|
||||||
|
Map<Long, DataSet> personsBalances = this.eventFinanceService.getPersonsBalances(this.eventId);
|
||||||
|
|
||||||
return new StreamingOutput() {
|
return new StreamingOutput() {
|
||||||
@Override
|
@Override
|
||||||
@@ -93,7 +100,7 @@ public class EventFinanceApi {
|
|||||||
personsBalancesCsvPrinter.printRecord("personID", "lname", "fname", "suffix", "expense", "paid",
|
personsBalancesCsvPrinter.printRecord("personID", "lname", "fname", "suffix", "expense", "paid",
|
||||||
"balance");
|
"balance");
|
||||||
|
|
||||||
for (DataSet personBalance : personsBalances) {
|
for (DataSet personBalance : personsBalances.values()) {
|
||||||
personsBalancesCsvPrinter.printRecord(personBalance.getLong("personID"),
|
personsBalancesCsvPrinter.printRecord(personBalance.getLong("personID"),
|
||||||
personBalance.getString("lname"), personBalance.getString("fname"),
|
personBalance.getString("lname"), personBalance.getString("fname"),
|
||||||
personBalance.getString("suffix"), personBalance.getFloat("expense"),
|
personBalance.getString("suffix"), personBalance.getFloat("expense"),
|
||||||
|
@@ -51,7 +51,10 @@ public class EventPersonApi {
|
|||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/people")
|
@Path("/people")
|
||||||
@RolesAllowed(Constants.EVENT_ROLE_PREFIX + "member")
|
@RolesAllowed(
|
||||||
|
Constants.EVENT_ROLE_PREFIX
|
||||||
|
+ "member"
|
||||||
|
)
|
||||||
@Produces(Constants.V1_JSON)
|
@Produces(Constants.V1_JSON)
|
||||||
@SecurityRequirement(name = "basic")
|
@SecurityRequirement(name = "basic")
|
||||||
@Operation(summary = "Retrieves limited meta-data about all the participants and administrators in an event.")
|
@Operation(summary = "Retrieves limited meta-data about all the participants and administrators in an event.")
|
||||||
@@ -67,7 +70,10 @@ public class EventPersonApi {
|
|||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/people/detail")
|
@Path("/people/detail")
|
||||||
@RolesAllowed(Constants.EVENT_ROLE_PREFIX + "member")
|
@RolesAllowed(
|
||||||
|
Constants.EVENT_ROLE_PREFIX
|
||||||
|
+ "member"
|
||||||
|
)
|
||||||
@Produces(Constants.V1_JSON)
|
@Produces(Constants.V1_JSON)
|
||||||
@SecurityRequirement(name = "basic")
|
@SecurityRequirement(name = "basic")
|
||||||
@Operation(summary = "Retrieves detailed meta-data about all the participants and administrators in an event.")
|
@Operation(summary = "Retrieves detailed meta-data about all the participants and administrators in an event.")
|
||||||
@@ -85,7 +91,10 @@ public class EventPersonApi {
|
|||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/people/csv")
|
@Path("/people/csv")
|
||||||
@RolesAllowed(Constants.EVENT_ROLE_PREFIX + "membership")
|
@RolesAllowed(
|
||||||
|
Constants.EVENT_ROLE_PREFIX
|
||||||
|
+ "membership"
|
||||||
|
)
|
||||||
@Produces("text/csv")
|
@Produces("text/csv")
|
||||||
@SecurityRequirement(name = "basic")
|
@SecurityRequirement(name = "basic")
|
||||||
@Operation(summary = "Retrieves address book meta-data about all the participants and administrators in an event.")
|
@Operation(summary = "Retrieves address book meta-data about all the participants and administrators in an event.")
|
||||||
@@ -116,7 +125,10 @@ public class EventPersonApi {
|
|||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/participants/csv")
|
@Path("/participants/csv")
|
||||||
@RolesAllowed(Constants.EVENT_ROLE_PREFIX + "membership")
|
@RolesAllowed(
|
||||||
|
Constants.EVENT_ROLE_PREFIX
|
||||||
|
+ "membership"
|
||||||
|
)
|
||||||
@Produces("text/csv")
|
@Produces("text/csv")
|
||||||
@SecurityRequirement(name = "basic")
|
@SecurityRequirement(name = "basic")
|
||||||
@Operation(summary = "Retrieves address book meta-data about all the participants in an event.")
|
@Operation(summary = "Retrieves address book meta-data about all the participants in an event.")
|
||||||
@@ -133,7 +145,10 @@ public class EventPersonApi {
|
|||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/series/participants")
|
@Path("/series/participants")
|
||||||
@RolesAllowed(Constants.EVENT_ROLE_PREFIX + "membership")
|
@RolesAllowed(
|
||||||
|
Constants.EVENT_ROLE_PREFIX
|
||||||
|
+ "membership"
|
||||||
|
)
|
||||||
@Produces(Constants.V1_JSON)
|
@Produces(Constants.V1_JSON)
|
||||||
@SecurityRequirement(name = "basic")
|
@SecurityRequirement(name = "basic")
|
||||||
@Operation(summary = "Retrieves limited meta-data about all the participants in an event series.")
|
@Operation(summary = "Retrieves limited meta-data about all the participants in an event series.")
|
||||||
|
@@ -94,7 +94,8 @@ public 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 EventRound getOne(@PathParam("eroundId") long eroundId) {
|
public EventRound getOne(@PathParam("eroundId")
|
||||||
|
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);
|
||||||
@@ -141,7 +142,8 @@ public 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 List<EventRoundPairing> getPairings(@PathParam("eroundId") long eroundId) {
|
public List<EventRoundPairing> getPairings(@PathParam("eroundId")
|
||||||
|
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);
|
||||||
@@ -161,8 +163,9 @@ public 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 EventRoundPairing getPairing(@PathParam("eroundId") long eroundId,
|
public EventRoundPairing getPairing(@PathParam("eroundId")
|
||||||
@PathParam("pairingID") BigInteger pairingId) {
|
long eroundId, @PathParam("pairingID")
|
||||||
|
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);
|
||||||
|
@@ -83,7 +83,8 @@ public class SeriesApi {
|
|||||||
@ApiResponse(responseCode = "200", description = "Success"),
|
@ApiResponse(responseCode = "200", description = "Success"),
|
||||||
@ApiResponse(responseCode = "404", description = "An event series with the specified ID could not be found")
|
@ApiResponse(responseCode = "404", description = "An event series with the specified ID could not be found")
|
||||||
})
|
})
|
||||||
public List<Event> getEvents(@QueryParam("reverse") Boolean reverse) {
|
public List<Event> getEvents(@QueryParam("reverse")
|
||||||
|
Boolean reverse) {
|
||||||
Map<Long, ? extends FlexMap> rows = this.eventService.getBySeriesId(this.seriesId);
|
Map<Long, ? extends FlexMap> rows = this.eventService.getBySeriesId(this.seriesId);
|
||||||
if (rows.isEmpty())
|
if (rows.isEmpty())
|
||||||
throw new WebApplicationException("Series or events not found", Status.NOT_FOUND);
|
throw new WebApplicationException("Series or events not found", Status.NOT_FOUND);
|
||||||
|
@@ -97,14 +97,16 @@ public class Event extends BaseEvent<Event> implements ReferenceableEvent {
|
|||||||
@JsonProperty
|
@JsonProperty
|
||||||
@MapEntry
|
@MapEntry
|
||||||
@MapCondition(rolesAllowed = {
|
@MapCondition(rolesAllowed = {
|
||||||
Constants.EVENT_ROLE_PREFIX + "admin"
|
Constants.EVENT_ROLE_PREFIX
|
||||||
|
+ "admin"
|
||||||
})
|
})
|
||||||
private LocalDate registrationLiveline;
|
private LocalDate registrationLiveline;
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
@MapEntry
|
@MapEntry
|
||||||
@MapCondition(rolesAllowed = {
|
@MapCondition(rolesAllowed = {
|
||||||
Constants.EVENT_ROLE_PREFIX + "admin"
|
Constants.EVENT_ROLE_PREFIX
|
||||||
|
+ "admin"
|
||||||
})
|
})
|
||||||
private LocalDate registrationHideline;
|
private LocalDate registrationHideline;
|
||||||
|
|
||||||
@@ -115,42 +117,60 @@ public class Event extends BaseEvent<Event> implements ReferenceableEvent {
|
|||||||
@JsonProperty
|
@JsonProperty
|
||||||
@MapEntry
|
@MapEntry
|
||||||
@MapCondition(rolesAllowed = {
|
@MapCondition(rolesAllowed = {
|
||||||
Constants.EVENT_ROLE_PREFIX + "admin", Constants.EVENT_ROLE_PREFIX + "finance"
|
Constants.EVENT_ROLE_PREFIX
|
||||||
|
+ "admin",
|
||||||
|
Constants.EVENT_ROLE_PREFIX
|
||||||
|
+ "finance"
|
||||||
})
|
})
|
||||||
private LocalDate financesLiveline;
|
private LocalDate financesLiveline;
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
@MapEntry
|
@MapEntry
|
||||||
@MapCondition(rolesAllowed = {
|
@MapCondition(rolesAllowed = {
|
||||||
Constants.EVENT_ROLE_PREFIX + "admin", Constants.EVENT_ROLE_PREFIX + "pairing"
|
Constants.EVENT_ROLE_PREFIX
|
||||||
|
+ "admin",
|
||||||
|
Constants.EVENT_ROLE_PREFIX
|
||||||
|
+ "pairing"
|
||||||
})
|
})
|
||||||
private LocalDate pairingsLiveline;
|
private LocalDate pairingsLiveline;
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
@MapEntry
|
@MapEntry
|
||||||
@MapCondition(rolesAllowed = {
|
@MapCondition(rolesAllowed = {
|
||||||
Constants.EVENT_ROLE_PREFIX + "admin", Constants.EVENT_ROLE_PREFIX + "pairing"
|
Constants.EVENT_ROLE_PREFIX
|
||||||
|
+ "admin",
|
||||||
|
Constants.EVENT_ROLE_PREFIX
|
||||||
|
+ "pairing"
|
||||||
})
|
})
|
||||||
private LocalDate teamsLiveline;
|
private LocalDate teamsLiveline;
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
@MapEntry
|
@MapEntry
|
||||||
@MapCondition(rolesAllowed = {
|
@MapCondition(rolesAllowed = {
|
||||||
Constants.EVENT_ROLE_PREFIX + "admin", Constants.EVENT_ROLE_PREFIX + "options"
|
Constants.EVENT_ROLE_PREFIX
|
||||||
|
+ "admin",
|
||||||
|
Constants.EVENT_ROLE_PREFIX
|
||||||
|
+ "options"
|
||||||
})
|
})
|
||||||
private LocalDate lodgingLiveline;
|
private LocalDate lodgingLiveline;
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
@MapEntry
|
@MapEntry
|
||||||
@MapCondition(rolesAllowed = {
|
@MapCondition(rolesAllowed = {
|
||||||
Constants.EVENT_ROLE_PREFIX + "admin", Constants.EVENT_ROLE_PREFIX + "pairing"
|
Constants.EVENT_ROLE_PREFIX
|
||||||
|
+ "admin",
|
||||||
|
Constants.EVENT_ROLE_PREFIX
|
||||||
|
+ "pairing"
|
||||||
})
|
})
|
||||||
private LocalDate documentsLiveline;
|
private LocalDate documentsLiveline;
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
@MapEntry
|
@MapEntry
|
||||||
@MapCondition(rolesAllowed = {
|
@MapCondition(rolesAllowed = {
|
||||||
Constants.EVENT_ROLE_PREFIX + "admin", Constants.EVENT_ROLE_PREFIX + "pairing"
|
Constants.EVENT_ROLE_PREFIX
|
||||||
|
+ "admin",
|
||||||
|
Constants.EVENT_ROLE_PREFIX
|
||||||
|
+ "pairing"
|
||||||
})
|
})
|
||||||
private LocalDate specialHolesLiveline;
|
private LocalDate specialHolesLiveline;
|
||||||
|
|
||||||
|
@@ -5,12 +5,15 @@ import com.brianlong.sql.DataSet;
|
|||||||
import com.brianlong.sql.FlexPreparedStatement;
|
import com.brianlong.sql.FlexPreparedStatement;
|
||||||
import com.brianlong.util.DateTimeFormatter;
|
import com.brianlong.util.DateTimeFormatter;
|
||||||
import com.brianlong.util.FlexMap;
|
import com.brianlong.util.FlexMap;
|
||||||
import com.poststats.golf.cache.EventCache;
|
import com.poststats.golf.formatter.EventFormatter;
|
||||||
|
import com.poststats.golf.service.EventPersonService;
|
||||||
|
import com.poststats.golf.service.EventService;
|
||||||
import com.poststats.golf.sql.EventAutolist;
|
import com.poststats.golf.sql.EventAutolist;
|
||||||
import com.poststats.provider.NonTransactionalProvider;
|
import com.poststats.provider.NonTransactionalProvider;
|
||||||
import com.poststats.provider.PostStatsProvider;
|
import com.poststats.provider.PostStatsProvider;
|
||||||
import com.poststats.provider.Statement;
|
import com.poststats.provider.Statement;
|
||||||
import com.poststats.provider.StatementProvider;
|
import com.poststats.provider.StatementProvider;
|
||||||
|
import com.poststats.service.PersonService;
|
||||||
import com.poststats.service.file.EnvironmentConfiguration;
|
import com.poststats.service.file.EnvironmentConfiguration;
|
||||||
import com.poststats.util.CompositeTexter;
|
import com.poststats.util.CompositeTexter;
|
||||||
import com.poststats.util.Contact;
|
import com.poststats.util.Contact;
|
||||||
@@ -30,7 +33,6 @@ import java.util.Collections;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.http.NameValuePair;
|
import org.apache.http.NameValuePair;
|
||||||
@@ -53,6 +55,15 @@ public class EventAgendaJob {
|
|||||||
@Inject
|
@Inject
|
||||||
private EnvironmentConfiguration envConfig;
|
private EnvironmentConfiguration envConfig;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private PersonService personService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private EventService eventService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private EventPersonService eventPersonService;
|
||||||
|
|
||||||
private String baseGolfUrl;
|
private String baseGolfUrl;
|
||||||
private CompositeTexter texter;
|
private CompositeTexter texter;
|
||||||
|
|
||||||
@@ -93,41 +104,40 @@ public class EventAgendaJob {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void send(FlexMap agenda)
|
public void send(FlexMap agenda) throws CacheRetrievalException, SQLException, MessagingException, IOException {
|
||||||
throws CacheRetrievalException, SQLException, MessagingException, IOException {
|
Long eventID = agenda.getLong("eventID");
|
||||||
Long eventID = agenda.getLong("eventID");
|
Map<Long, BigInteger> recipientIDs = EventAutolist.getInstance().getPersonIDMap("signed", eventID.longValue());
|
||||||
Map<Long, BigInteger> recipientIDs = EventAutolist.getInstance().getPersonIDMap("signed", eventID.longValue());
|
this.send(agenda, recipientIDs);
|
||||||
this.send(agenda, recipientIDs);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void send(FlexMap agenda, Map<Long, BigInteger> recipientIDs)
|
public void send(FlexMap agenda, Map<Long, BigInteger> recipientIDs)
|
||||||
throws CacheRetrievalException, SQLException, MessagingException, IOException {
|
throws CacheRetrievalException, SQLException, MessagingException, IOException {
|
||||||
boolean doEmailLink = Boolean.TRUE.equals(agenda.getBoolean("sendEmailWithLink"));
|
boolean doEmailLink = Boolean.TRUE.equals(agenda.getBoolean("sendEmailWithLink"));
|
||||||
boolean doEmail = Boolean.TRUE.equals(agenda.getBoolean("sendEmailWithContent"));
|
boolean doEmail = Boolean.TRUE.equals(agenda.getBoolean("sendEmailWithContent"));
|
||||||
boolean doText = Boolean.TRUE.equals(agenda.getBoolean("sendTextWithLink"));
|
boolean doText = Boolean.TRUE.equals(agenda.getBoolean("sendTextWithLink"));
|
||||||
if (!doText && !doEmailLink && !doEmail)
|
if (!doText && !doEmailLink && !doEmail)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Long eventID = agenda.getLong("eventID");
|
Long eventId = agenda.getLong("eventID");
|
||||||
Long documentID = agenda.getLong("documentID");
|
Long documentId = agenda.getLong("documentID");
|
||||||
LocalDate day = agenda.getDate("day");
|
LocalDate day = agenda.getDate("day");
|
||||||
|
|
||||||
this.logger.debug("Sending agenda with document ID: {}", documentID);
|
this.logger.debug("Sending agenda with document ID: {}", documentId);
|
||||||
|
|
||||||
DataSet event = EventCache.getInstance().get(eventID);
|
FlexMap event = this.eventService.get(eventId);
|
||||||
String subject = event.getString("event")
|
String subject = new EventFormatter().format(event)
|
||||||
+ " Agenda for "
|
+ " Agenda for "
|
||||||
+ this.weekdayFormatter.format(day);
|
+ this.weekdayFormatter.format(day);
|
||||||
|
|
||||||
Set<Long> textedPersonIDs = Collections.emptySet();
|
Set<Long> textedPersonIDs = Collections.emptySet();
|
||||||
if (doText)
|
if (doText)
|
||||||
textedPersonIDs = this.text(eventID, documentID, recipientIDs, subject);
|
textedPersonIDs = this.text(eventId, documentId, recipientIDs, subject);
|
||||||
|
|
||||||
if (doEmailLink)
|
if (doEmailLink)
|
||||||
this.emailLink(eventID, documentID, recipientIDs, textedPersonIDs, subject);
|
this.emailLink(eventId, documentId, recipientIDs, textedPersonIDs, subject);
|
||||||
|
|
||||||
if (doEmail) {
|
if (doEmail) {
|
||||||
this.email(eventID, documentID, recipientIDs, textedPersonIDs, subject);
|
this.email(eventId, documentId, recipientIDs, textedPersonIDs, subject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,7 +145,7 @@ public class EventAgendaJob {
|
|||||||
throws SQLException, MessagingException {
|
throws SQLException, MessagingException {
|
||||||
this.logger.debug("Sending agenda links by text with document ID: {}", documentID);
|
this.logger.debug("Sending agenda links by text with document ID: {}", documentID);
|
||||||
|
|
||||||
Map<Long, Contact> recipients = Contact.getContactMapByIds(recipientIDs.keySet(), false, true);
|
List<Contact> recipients = this.personService.getContacts(recipientIDs.keySet(), false, true);
|
||||||
|
|
||||||
String baseUrl = baseGolfUrl
|
String baseUrl = baseGolfUrl
|
||||||
+ "?n=documentAgenda&eventID="
|
+ "?n=documentAgenda&eventID="
|
||||||
@@ -146,14 +156,13 @@ public class EventAgendaJob {
|
|||||||
|
|
||||||
Set<Long> textedPersonIDs = new HashSet<Long>(recipientIDs.size());
|
Set<Long> textedPersonIDs = new HashSet<Long>(recipientIDs.size());
|
||||||
|
|
||||||
for (Entry<Long, Contact> recipient : recipients.entrySet()) {
|
for (Contact recipient : recipients) {
|
||||||
if (logger.isDebugEnabled())
|
long personId = recipient.getPersonId();
|
||||||
logger.debug("Sending agenda to: "
|
this.logger.debug("Sending agenda to: {}", personId);
|
||||||
+ recipient.getKey());
|
String message = baseUrl + recipientIDs.get(personId);
|
||||||
String message = baseUrl + recipientIDs.get(recipient.getKey());
|
this.texter.send(Arrays.asList(recipient), subject, message);
|
||||||
this.texter.send(Arrays.asList(recipient.getValue()), subject, message);
|
|
||||||
|
|
||||||
textedPersonIDs.add(recipient.getKey());
|
textedPersonIDs.add(personId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return textedPersonIDs;
|
return textedPersonIDs;
|
||||||
@@ -163,7 +172,7 @@ public class EventAgendaJob {
|
|||||||
Set<Long> excludePersonIDs, String subject) throws SQLException, MessagingException {
|
Set<Long> excludePersonIDs, String subject) throws SQLException, MessagingException {
|
||||||
this.logger.debug("Sending agenda links by email with document ID: {}", documentID);
|
this.logger.debug("Sending agenda links by email with document ID: {}", documentID);
|
||||||
|
|
||||||
Map<Long, Contact> recipients = Contact.getContactMapByIds(recipientIDs.keySet(), true, false);
|
List<Contact> recipients = this.personService.getContacts(recipientIDs.keySet(), true, false);
|
||||||
|
|
||||||
String baseUrl = this.baseGolfUrl
|
String baseUrl = this.baseGolfUrl
|
||||||
+ "?n=documentAgenda&eventID="
|
+ "?n=documentAgenda&eventID="
|
||||||
@@ -171,27 +180,27 @@ public class EventAgendaJob {
|
|||||||
+ "&documentID="
|
+ "&documentID="
|
||||||
+ documentID
|
+ documentID
|
||||||
+ "&epersonID=";
|
+ "&epersonID=";
|
||||||
for (Entry<Long, Contact> recipient : recipients.entrySet()) {
|
for (Contact recipient : recipients) {
|
||||||
if (excludePersonIDs.contains(recipient.getKey()))
|
long personId = recipient.getPersonId();
|
||||||
|
if (excludePersonIDs.contains(personId))
|
||||||
continue;
|
continue;
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
logger.debug("Sending agenda to: "
|
logger.debug("Sending agenda to: {}", personId);
|
||||||
+ recipient.getKey());
|
|
||||||
String message = "<html><body><p><a href=\""
|
String message = "<html><body><p><a href=\""
|
||||||
+ baseUrl
|
+ baseUrl
|
||||||
+ "\">"
|
+ "\">"
|
||||||
+ baseUrl
|
+ baseUrl
|
||||||
+ recipientIDs.get(recipient.getKey())
|
+ recipientIDs.get(personId)
|
||||||
+ "</a></p></body></html>";
|
+ "</a></p></body></html>";
|
||||||
Emailer.getInstance(this.envConfig).send(Arrays.asList(recipient.getValue()), subject, message);
|
Emailer.getInstance(this.envConfig).send(Arrays.asList(recipient), subject, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void email(long eventID, long documentID, Map<Long, BigInteger> recipientIDs,
|
private void email(long eventID, long documentID, Map<Long, BigInteger> recipientIDs, Set<Long> excludePersonIDs,
|
||||||
Set<Long> excludePersonIDs, String subject) throws SQLException, MessagingException, IOException {
|
String subject) throws SQLException, MessagingException, IOException {
|
||||||
this.logger.debug("Sending agenda contents with document ID: {}", documentID);
|
this.logger.debug("Sending agenda contents with document ID: {}", documentID);
|
||||||
|
|
||||||
Map<Long, Contact> recipients = Contact.getContactMapByIds(recipientIDs.keySet(), true, false);
|
List<Contact> recipients = this.personService.getContacts(recipientIDs.keySet(), true, false);
|
||||||
|
|
||||||
NameValuePair[] params = new NameValuePair[] {
|
NameValuePair[] params = new NameValuePair[] {
|
||||||
new BasicNameValuePair("n", "documentAgendaMinimal"),
|
new BasicNameValuePair("n", "documentAgendaMinimal"),
|
||||||
@@ -199,18 +208,19 @@ public class EventAgendaJob {
|
|||||||
new BasicNameValuePair("documentID", String.valueOf(documentID))
|
new BasicNameValuePair("documentID", String.valueOf(documentID))
|
||||||
};
|
};
|
||||||
|
|
||||||
for (Entry<Long, Contact> recipient : recipients.entrySet()) {
|
for (Contact recipient : recipients) {
|
||||||
this.logger.debug("Sending agenda to: {}", recipient.getKey());
|
long personId = recipient.getPersonId();
|
||||||
|
this.logger.debug("Sending agenda to: {}", personId);
|
||||||
|
|
||||||
HttpUriRequest request = RequestBuilder.get(this.baseGolfUrl).addParameters(params)
|
HttpUriRequest request = RequestBuilder.get(this.baseGolfUrl).addParameters(params)
|
||||||
.addParameter("epersonID", recipientIDs.get(recipient.getKey()).toString()).build();
|
.addParameter("epersonID", recipientIDs.get(personId).toString()).build();
|
||||||
|
|
||||||
CloseableHttpClient hclient = HttpClientBuilder.create().build();
|
CloseableHttpClient hclient = HttpClientBuilder.create().build();
|
||||||
CloseableHttpResponse response = hclient.execute(request);
|
CloseableHttpResponse response = hclient.execute(request);
|
||||||
try {
|
try {
|
||||||
if (response.getStatusLine().getStatusCode() / 100 == 2) {
|
if (response.getStatusLine().getStatusCode() / 100 == 2) {
|
||||||
String html = IOUtils.toString(response.getEntity().getContent(), "utf-8");
|
String html = IOUtils.toString(response.getEntity().getContent(), "utf-8");
|
||||||
Emailer.getInstance(this.envConfig).send(Arrays.asList(recipient.getValue()), subject, html);
|
Emailer.getInstance(this.envConfig).send(Arrays.asList(recipient), subject, html);
|
||||||
} else {
|
} else {
|
||||||
this.logger.warn("The URL could not be loaded properly: {}", request.getURI());
|
this.logger.warn("The URL could not be loaded properly: {}", request.getURI());
|
||||||
}
|
}
|
||||||
|
@@ -38,7 +38,9 @@ public class AuthenticatedPerson extends com.poststats.security.AuthenticatedPer
|
|||||||
roles.addAll(this.acSids);
|
roles.addAll(this.acSids);
|
||||||
for (Entry<Long, Set<String>> eroles : this.eventAcSids.entrySet())
|
for (Entry<Long, Set<String>> eroles : this.eventAcSids.entrySet())
|
||||||
for (String role : eroles.getValue())
|
for (String role : eroles.getValue())
|
||||||
roles.add(eroles.getKey() + ":" + role);
|
roles.add(eroles.getKey()
|
||||||
|
+ ":"
|
||||||
|
+ role);
|
||||||
return roles == null ? null : Collections.unmodifiableSet(roles);
|
return roles == null ? null : Collections.unmodifiableSet(roles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -9,7 +9,7 @@ public interface EventDocumentService extends CacheableService<Long> {
|
|||||||
* This method retrieves meta-data about the specified event document.
|
* This method retrieves meta-data about the specified event document.
|
||||||
*
|
*
|
||||||
* @param eventId A unique identifier for the event.
|
* @param eventId A unique identifier for the event.
|
||||||
* @param eventId A unique identifier for the document.
|
* @param eventId A unique identifier for the document.
|
||||||
* @return A map of meta-data specific to the event document.
|
* @return A map of meta-data specific to the event document.
|
||||||
*/
|
*/
|
||||||
FlexMap get(long eventId, long documentId);
|
FlexMap get(long eventId, long documentId);
|
||||||
|
@@ -1,10 +1,79 @@
|
|||||||
package com.poststats.golf.service;
|
package com.poststats.golf.service;
|
||||||
|
|
||||||
import com.brianlong.sql.DataSet;
|
import java.util.Map;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
import com.brianlong.sql.DataSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This service provides financial metadata about the event, series, associated
|
||||||
|
* people, or a combination of those.
|
||||||
|
*
|
||||||
|
* The balance metadata includes money `paid`, `expenses`, and `balance`. The
|
||||||
|
* balance numerically consistent with the perspective of the person, not the
|
||||||
|
* event organizers. That means it is positive when the person paid more than
|
||||||
|
* they should owe and negative if they owe money.
|
||||||
|
*
|
||||||
|
* @author brian
|
||||||
|
*/
|
||||||
public interface EventFinanceService {
|
public interface EventFinanceService {
|
||||||
|
|
||||||
List<DataSet> getPersonsBalances(long eventId);
|
/**
|
||||||
|
* Computes and retrieves the person balances for those associated with the
|
||||||
|
* specified event.
|
||||||
|
*
|
||||||
|
* @param eventId The unique identifier of an event.
|
||||||
|
* @return A map of `personId` to balance metadata.
|
||||||
|
*/
|
||||||
|
Map<Long, DataSet> getPersonsBalances(long eventId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Computes and retrieves the person balances for those associated with the
|
||||||
|
* specified event.
|
||||||
|
*
|
||||||
|
* @param eventId The unique identifier of an event.
|
||||||
|
* @param minBalance The minimum balance for returned balances; `0.01` for those that have paid more than they owe; `null` for no constraint.
|
||||||
|
* @param maxBalance The maximum balance for returned balances; `-0.01` for those that owe; `null` for no constraint.
|
||||||
|
* @return A map of `personId` to balance metadata.
|
||||||
|
*/
|
||||||
|
Map<Long, DataSet> getPersonsBalances(long eventId, Float minBalance, Float maxBalance);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Computes and retrieves the specified person's balance for the specified
|
||||||
|
* event.
|
||||||
|
*
|
||||||
|
* @param eventId The unique identifier of an event.
|
||||||
|
* @param personId The unique identifier of a person.
|
||||||
|
* @return Balance metadata.
|
||||||
|
*/
|
||||||
|
DataSet getPersonBalance(long eventId, long personId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Computes and retrieves all associated persons' cumulative balance for
|
||||||
|
* all events in the series before the specified event.
|
||||||
|
*
|
||||||
|
* @param eventId The unique identifier of an event.
|
||||||
|
* @return A map of `personId` to balance metadata.
|
||||||
|
*/
|
||||||
|
Map<Long, DataSet> getSeriesPersonsBalances(long eventId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Computes and retrieves the specified person's balances for all events in
|
||||||
|
* the specified series.
|
||||||
|
*
|
||||||
|
* @param seriesId The unique identifier of a series.
|
||||||
|
* @param personId The unique identifier of a person.
|
||||||
|
* @return A map of `eventId` to balance metadata.
|
||||||
|
*/
|
||||||
|
Map<Long, DataSet> getSeriesPersonBalances(int seriesId, long personId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Computes and retrieves the specified person's balances for all events in
|
||||||
|
* the series before the specified event.
|
||||||
|
*
|
||||||
|
* @param eventId The unique identifier of an event.
|
||||||
|
* @param personId The unique identifier of a person.
|
||||||
|
* @return A map of `eventId` to balance metadata.
|
||||||
|
*/
|
||||||
|
Map<Long, DataSet> getSeriesPersonPreviousBalances(long eventId, long personId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -2,16 +2,16 @@ package com.poststats.golf.service;
|
|||||||
|
|
||||||
import com.brianlong.util.FlexMap;
|
import com.brianlong.util.FlexMap;
|
||||||
import com.poststats.service.CacheableService;
|
import com.poststats.service.CacheableService;
|
||||||
|
import com.poststats.util.Contact;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public interface EventPersonService extends CacheableService<BigInteger> {
|
public interface EventPersonService extends CacheableService<BigInteger> {
|
||||||
|
|
||||||
FlexMap get(BigInteger epersonId);
|
FlexMap get(BigInteger epersonId);
|
||||||
|
|
||||||
FlexMap get(long eventId, long personId);
|
FlexMap get(long eventId, long personId);
|
||||||
|
|
||||||
List<? extends FlexMap> getPeople(long eventId);
|
List<? extends FlexMap> getPeople(long eventId);
|
||||||
|
|
||||||
@@ -19,4 +19,32 @@ public interface EventPersonService extends CacheableService<BigInteger> {
|
|||||||
|
|
||||||
Set<Long> getSeriesEventFellowParticipantIds(int seriesId, long personId);
|
Set<Long> getSeriesEventFellowParticipantIds(int seriesId, long personId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method retrieves contacts appropriate to the specified parameters.
|
||||||
|
*
|
||||||
|
* If both `allowEmail` and `allowText` are specified, only `allowText` will be
|
||||||
|
* used for users with email and text capability.
|
||||||
|
*
|
||||||
|
* @param eventId The unique identifier of an event.
|
||||||
|
* @param listId The unique identifier of a contact list.
|
||||||
|
* @param allowEmail `true` to allow email contact with each person.
|
||||||
|
* @param allowText `true` to allow text contact with each person.
|
||||||
|
* @return A map of meta-data specific to the person.
|
||||||
|
*/
|
||||||
|
List<Contact> getContactsByListId(long eventId, long listId, boolean allowEmail, boolean allowText);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method retrieves contacts appropriate to the specified parameters.
|
||||||
|
*
|
||||||
|
* If both `allowEmail` and `allowText` are specified, only `allowText` will be
|
||||||
|
* used for users with email and text capability.
|
||||||
|
*
|
||||||
|
* @param eventId The unique identifier of an event.
|
||||||
|
* @param autolist The unique identifier of a contact list.
|
||||||
|
* @param allowEmail `true` to allow email contact with each person.
|
||||||
|
* @param allowText `true` to allow text contact with each person.
|
||||||
|
* @return A map of meta-data specific to the person.
|
||||||
|
*/
|
||||||
|
List<Contact> getContactsByAutolist(long eventId, String autolist, boolean allowEmail, boolean allowText);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -54,8 +54,12 @@ public class CourseServiceDAO extends CacheableServiceDAO<Integer> implements Co
|
|||||||
try {
|
try {
|
||||||
FlexPreparedStatement fps = this.sqlSelectByName.buildPreparedStatement();
|
FlexPreparedStatement fps = this.sqlSelectByName.buildPreparedStatement();
|
||||||
try {
|
try {
|
||||||
fps.setVarchar(1, "%" + name + "%");
|
fps.setVarchar(1, "%"
|
||||||
fps.setVarchar(2, "%" + name + "%");
|
+ name
|
||||||
|
+ "%");
|
||||||
|
fps.setVarchar(2, "%"
|
||||||
|
+ name
|
||||||
|
+ "%");
|
||||||
fps.setSmallintU(3, (page - 1) * perPage);
|
fps.setSmallintU(3, (page - 1) * perPage);
|
||||||
fps.setSmallintU(4, perPage);
|
fps.setSmallintU(4, perPage);
|
||||||
return (SubList<? extends FlexMap>) fps.executeQuery().getAllRows(this.facilityManyToOneDef);
|
return (SubList<? extends FlexMap>) fps.executeQuery().getAllRows(this.facilityManyToOneDef);
|
||||||
|
@@ -1,9 +1,5 @@
|
|||||||
package com.poststats.golf.service.db;
|
package com.poststats.golf.service.db;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.brianlong.sql.DataSet;
|
import com.brianlong.sql.DataSet;
|
||||||
import com.brianlong.sql.FlexPreparedStatement;
|
import com.brianlong.sql.FlexPreparedStatement;
|
||||||
import com.brianlong.util.FlexMap;
|
import com.brianlong.util.FlexMap;
|
||||||
@@ -13,9 +9,11 @@ import com.poststats.provider.NonTransactionalProvider;
|
|||||||
import com.poststats.provider.Statement;
|
import com.poststats.provider.Statement;
|
||||||
import com.poststats.provider.StatementProvider;
|
import com.poststats.provider.StatementProvider;
|
||||||
import com.poststats.service.db.CacheableServiceDAO;
|
import com.poststats.service.db.CacheableServiceDAO;
|
||||||
|
|
||||||
import jakarta.enterprise.context.ApplicationScoped;
|
import jakarta.enterprise.context.ApplicationScoped;
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@ApplicationScoped
|
@ApplicationScoped
|
||||||
public class EventDocumentServiceDAO extends CacheableServiceDAO<Long> implements EventDocumentService {
|
public class EventDocumentServiceDAO extends CacheableServiceDAO<Long> implements EventDocumentService {
|
||||||
@@ -26,7 +24,7 @@ public class EventDocumentServiceDAO extends CacheableServiceDAO<Long> implement
|
|||||||
public FlexMap get(long eventId, long documentId) {
|
public FlexMap get(long eventId, long documentId) {
|
||||||
FlexMap document = this.get(documentId);
|
FlexMap document = this.get(documentId);
|
||||||
if (document != null && eventId != document.getLong("eventID"))
|
if (document != null && eventId != document.getLong("eventID"))
|
||||||
return null;
|
return null;
|
||||||
return document;
|
return document;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +37,7 @@ public class EventDocumentServiceDAO extends CacheableServiceDAO<Long> implement
|
|||||||
protected DataSet fetchOne(Long documentId) throws SQLException {
|
protected DataSet fetchOne(Long documentId) throws SQLException {
|
||||||
FlexPreparedStatement fps = this.sqlSelectEventDocument.buildPreparedStatement();
|
FlexPreparedStatement fps = this.sqlSelectEventDocument.buildPreparedStatement();
|
||||||
try {
|
try {
|
||||||
fps.setIntegerU(2, documentId);
|
fps.setIntegerU(1, documentId);
|
||||||
return fps.executeQuery().getNextRow();
|
return fps.executeQuery().getNextRow();
|
||||||
} finally {
|
} finally {
|
||||||
fps.close();
|
fps.close();
|
||||||
@@ -70,9 +68,9 @@ public class EventDocumentServiceDAO extends CacheableServiceDAO<Long> implement
|
|||||||
@NonTransactionalProvider
|
@NonTransactionalProvider
|
||||||
@GolfProvider
|
@GolfProvider
|
||||||
@Statement(
|
@Statement(
|
||||||
sql = "SELECT ED.* "
|
sql = "SELECT ED.* "
|
||||||
+ "FROM ~g~.EventDocument ED "
|
+ "FROM ~g~.EventDocument ED "
|
||||||
+ "WHERE ED.documentId IN (??) "
|
+ "WHERE ED.documentId IN (??) "
|
||||||
)
|
)
|
||||||
private StatementProvider sqlSelectEvents;
|
private StatementProvider sqlSelectEvents;
|
||||||
|
|
||||||
|
@@ -1,29 +1,44 @@
|
|||||||
package com.poststats.golf.service.db;
|
package com.poststats.golf.service.db;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.brianlong.sql.DataSet;
|
import com.brianlong.sql.DataSet;
|
||||||
import com.brianlong.sql.FlexPreparedStatement;
|
import com.brianlong.sql.FlexPreparedStatement;
|
||||||
|
import com.brianlong.util.FlexMap;
|
||||||
import com.poststats.golf.provider.GolfProvider;
|
import com.poststats.golf.provider.GolfProvider;
|
||||||
import com.poststats.golf.service.EventFinanceService;
|
import com.poststats.golf.service.EventFinanceService;
|
||||||
|
import com.poststats.golf.service.EventService;
|
||||||
import com.poststats.provider.NonTransactionalProvider;
|
import com.poststats.provider.NonTransactionalProvider;
|
||||||
import com.poststats.provider.Statement;
|
import com.poststats.provider.Statement;
|
||||||
import com.poststats.provider.StatementProvider;
|
import com.poststats.provider.StatementProvider;
|
||||||
import com.poststats.service.ServiceException;
|
import com.poststats.service.ServiceException;
|
||||||
|
|
||||||
import jakarta.enterprise.context.ApplicationScoped;
|
import jakarta.enterprise.context.ApplicationScoped;
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@ApplicationScoped
|
@ApplicationScoped
|
||||||
public class EventFinanceServiceDAO implements EventFinanceService {
|
public class EventFinanceServiceDAO implements EventFinanceService {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private EventService eventService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<Long, DataSet> getPersonsBalances(long eventId) {
|
||||||
|
return this.getPersonsBalances(eventId, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DataSet> getPersonsBalances(long eventId) {
|
public Map<Long, DataSet> getPersonsBalances(long eventId, Float minBalance, Float maxBalance) {
|
||||||
try {
|
try {
|
||||||
FlexPreparedStatement fps = this.sqlSelectBalances.buildPreparedStatement();
|
FlexPreparedStatement fps = this.sqlSelectBalances.buildPreparedStatement();
|
||||||
try {
|
try {
|
||||||
for (int i = 1; i <= 5; i++)
|
for (int i = 1; i <= 5; i++)
|
||||||
fps.setIntegerU(i, eventId);
|
fps.setIntegerU(i, eventId);
|
||||||
return fps.executeQuery().getAllRows();
|
fps.setFloat(6, minBalance == null ? Float.NEGATIVE_INFINITY : minBalance);
|
||||||
|
fps.setFloat(7, maxBalance == null ? Float.POSITIVE_INFINITY : maxBalance);
|
||||||
|
return fps.executeQuery().getAllRows("personID", Long.class);
|
||||||
} finally {
|
} finally {
|
||||||
fps.close();
|
fps.close();
|
||||||
}
|
}
|
||||||
@@ -32,29 +47,147 @@ public class EventFinanceServiceDAO implements EventFinanceService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataSet getPersonBalance(long eventId, long personId) {
|
||||||
|
try {
|
||||||
|
FlexPreparedStatement fps = this.sqlSelectPersonBalances.buildPreparedStatement();
|
||||||
|
try {
|
||||||
|
for (int i = 1; i <= 10; i += 2) {
|
||||||
|
fps.setIntegerU(i, eventId);
|
||||||
|
fps.setIntegerU(i+1, personId);
|
||||||
|
}
|
||||||
|
return fps.executeQuery().getNextRow();
|
||||||
|
} finally {
|
||||||
|
fps.close();
|
||||||
|
}
|
||||||
|
} catch (SQLException se) {
|
||||||
|
throw new ServiceException(se);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<Long, DataSet> getSeriesPersonsBalances(long eventId) {
|
||||||
|
FlexMap event = this.eventService.get(eventId);
|
||||||
|
int seriesId = event.getInteger("seriesID");
|
||||||
|
LocalDate liveline = event.getDate("liveline");
|
||||||
|
|
||||||
|
try {
|
||||||
|
FlexPreparedStatement fps = this.sqlSelectSeriesBalances.buildPreparedStatement();
|
||||||
|
try {
|
||||||
|
for (int i = 1; i <= 15; i += 3) {
|
||||||
|
fps.setSmallintU(i, seriesId);
|
||||||
|
fps.setIntegerU(i+1, eventId);
|
||||||
|
fps.setDate(i+2, liveline);
|
||||||
|
}
|
||||||
|
return fps.executeQuery().getAllRows("personID", Long.class);
|
||||||
|
} finally {
|
||||||
|
fps.close();
|
||||||
|
}
|
||||||
|
} catch (SQLException se) {
|
||||||
|
throw new ServiceException(se);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<Long, DataSet> getSeriesPersonBalances(int seriesId, long personId) {
|
||||||
|
return this.getSeriesPersonBalances(seriesId, null, null, personId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<Long, DataSet> getSeriesPersonPreviousBalances(long eventId, long personId) {
|
||||||
|
FlexMap event = this.eventService.get(eventId);
|
||||||
|
int seriesId = event.getInteger("seriesID");
|
||||||
|
LocalDate liveline = event.getDate("liveline");
|
||||||
|
return this.getSeriesPersonBalances(seriesId, eventId, liveline, personId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<Long, DataSet> getSeriesPersonBalances(int seriesId, Long eventId, LocalDate liveline, long personId) {
|
||||||
|
if (eventId == null)
|
||||||
|
eventId = -1L;
|
||||||
|
if (liveline == null)
|
||||||
|
liveline = LocalDate.now().plusYears(10L);
|
||||||
|
|
||||||
|
try {
|
||||||
|
FlexPreparedStatement fps = this.sqlSelectSeriesPersonEventBalances.buildPreparedStatement();
|
||||||
|
try {
|
||||||
|
for (int i = 1; i <= 20; i += 4) {
|
||||||
|
fps.setSmallintU(i, seriesId);
|
||||||
|
fps.setIntegerU(i+1, eventId);
|
||||||
|
fps.setDate(i+2, liveline);
|
||||||
|
fps.setIntegerU(i+3, personId);
|
||||||
|
}
|
||||||
|
return fps.executeQuery().getAllRows("personID", Long.class);
|
||||||
|
} finally {
|
||||||
|
fps.close();
|
||||||
|
}
|
||||||
|
} catch (SQLException se) {
|
||||||
|
throw new ServiceException(se);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@NonTransactionalProvider
|
||||||
|
@GolfProvider
|
||||||
|
@Statement(
|
||||||
|
sql = "SELECT TT.personID, TT.epersonID, SUM(TT.expenses) expenses, SUM(TT.paid) paid, (SUM(TT.paid)-SUM(TT.expenses)) balance "
|
||||||
|
+ "FROM ("
|
||||||
|
+ " SELECT ALL EP.personID, EP.epersonID, IF(EB.projectedValue IS NULL, 0, EB.projectedValue) expenses, 0 paid "
|
||||||
|
+ " FROM ~g~.EventPerson EP "
|
||||||
|
+ " LEFT JOIN ~g~.EventBudget EB ON (EP.eventID=EB.eventID) "
|
||||||
|
+ " WHERE EP.eventID=? "
|
||||||
|
+ " UNION ALL "
|
||||||
|
+ " SELECT ALL EP.personID, EP.epersonID, EO.amount expenses, 0 paid "
|
||||||
|
+ " FROM ~g~.EventPerson EP "
|
||||||
|
+ " INNER JOIN ~g~.EventPersonOption EPO ON (EP.epersonID=EPO.epersonID) "
|
||||||
|
+ " INNER JOIN ~g~.EventOption EO ON (EPO.optionID=EO.optionID) "
|
||||||
|
+ " WHERE EP.eventID=? AND EPO.answer='Y' AND EO.amount IS NOT NULL AND EO.waive IS FALSE "
|
||||||
|
+ " UNION ALL "
|
||||||
|
+ " SELECT ALL EP.personID, EP.epersonID, EO.amount expenses, 0 paid "
|
||||||
|
+ " FROM ~g~.EventPerson EP "
|
||||||
|
+ " INNER JOIN ~g~.EventPersonOption EPO ON (EP.epersonID=EPO.epersonID) "
|
||||||
|
+ " INNER JOIN ~g~.EventOption EO ON (EPO.optionID=EO.optionID) "
|
||||||
|
+ " WHERE EP.eventID=? AND EPO.itemID IS NOT NULL "
|
||||||
|
+ " AND (EO.multiple IS FALSE OR EO.funded='option' OR EO.static IS NOT NULL) "
|
||||||
|
+ " AND EO.amount IS NOT NULL AND EO.waive IS FALSE "
|
||||||
|
+ " UNION ALL "
|
||||||
|
+ " SELECT ALL EP.personID, EP.epersonID, EOI.amount expenses, 0 paid "
|
||||||
|
+ " FROM ~g~.EventPerson EP "
|
||||||
|
+ " INNER JOIN ~g~.EventPersonOption EPO ON (EP.epersonID=EPO.epersonID) "
|
||||||
|
+ " INNER JOIN ~g~.EventOption EO ON (EPO.optionID=EO.optionID) "
|
||||||
|
+ " INNER JOIN ~g~.EventOptionItem EOI ON (EPO.itemID=EOI.itemID) "
|
||||||
|
+ " WHERE EP.eventID=? AND EO.waive IS FALSE AND EO.funded='selection' AND EOI.amount IS NOT NULL "
|
||||||
|
+ " UNION ALL "
|
||||||
|
+ " SELECT ALL EPP.personID, EP.epersonID, 0 expenses, EPP.amount paid "
|
||||||
|
+ " FROM ~g~.EventPersonPayment EPP "
|
||||||
|
+ " LEFT JOIN ~g~.EventPerson EP ON (EPP.eventID=EP.eventID AND EPP.personID=EP.personID) "
|
||||||
|
+ " WHERE EPP.eventID=?) TT "
|
||||||
|
+ "GROUP BY TT.personID "
|
||||||
|
+ "HAVING (SUM(TT.paid)-SUM(TT.expenses))>=? AND (SUM(TT.paid)-SUM(TT.expenses))<=? "
|
||||||
|
)
|
||||||
|
private StatementProvider sqlSelectBalances;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@NonTransactionalProvider
|
@NonTransactionalProvider
|
||||||
@GolfProvider
|
@GolfProvider
|
||||||
@Statement(
|
@Statement(
|
||||||
sql = "SELECT P.personID, P.prefix, P.fname, P.lname, P.suffix, "
|
sql = "SELECT SUM(TT.expenses) expenses, SUM(TT.paid) paid, (SUM(TT.paid)-SUM(TT.expenses)) balance "
|
||||||
+ " TT.epersonID, SUM(TT.expenses) expenses, SUM(TT.paid) paid, (SUM(TT.paid)-SUM(TT.expenses)) balance "
|
|
||||||
+ "FROM ("
|
+ "FROM ("
|
||||||
+ " SELECT ALL EP.personID, EP.epersonID, IF(EB.projectedValue IS NULL, 0, EB.projectedValue) expenses, 0 paid "
|
+ " SELECT ALL EP.personID, EP.epersonID, IF(EB.projectedValue IS NULL, 0, EB.projectedValue) expenses, 0 paid "
|
||||||
+ " FROM ~g~.EventPerson EP "
|
+ " FROM ~g~.EventPerson EP "
|
||||||
+ " LEFT JOIN ~g~.EventBudget EB ON (EP.eventID=EB.eventID) "
|
+ " LEFT JOIN ~g~.EventBudget EB ON (EP.eventID=EB.eventID) "
|
||||||
+ " WHERE EP.eventID=? "
|
+ " WHERE EP.eventID=? AND EP.personID=? "
|
||||||
+ " UNION ALL "
|
+ " UNION ALL "
|
||||||
+ " SELECT ALL EP.personID, EP.epersonID, EO.amount expenses, 0 paid "
|
+ " SELECT ALL EP.personID, EP.epersonID, EO.amount expenses, 0 paid "
|
||||||
+ " FROM ~g~.EventPerson EP "
|
+ " FROM ~g~.EventPerson EP "
|
||||||
+ " INNER JOIN ~g~.EventPersonOption EPO ON (EP.epersonID=EPO.epersonID) "
|
+ " INNER JOIN ~g~.EventPersonOption EPO ON (EP.epersonID=EPO.epersonID) "
|
||||||
+ " INNER JOIN ~g~.EventOption EO ON (EPO.optionID=EO.optionID) "
|
+ " INNER JOIN ~g~.EventOption EO ON (EPO.optionID=EO.optionID) "
|
||||||
+ " WHERE EP.eventID=? AND EPO.answer='Y' AND EO.amount IS NOT NULL AND EO.waive IS FALSE "
|
+ " WHERE EP.eventID=? AND EP.personID=? AND EPO.answer='Y' AND EO.amount IS NOT NULL AND EO.waive IS FALSE "
|
||||||
+ " UNION ALL "
|
+ " UNION ALL "
|
||||||
+ " SELECT ALL EP.personID, EP.epersonID, EO.amount expenses, 0 paid "
|
+ " SELECT ALL EP.personID, EP.epersonID, EO.amount expenses, 0 paid "
|
||||||
+ " FROM ~g~.EventPerson EP "
|
+ " FROM ~g~.EventPerson EP "
|
||||||
+ " INNER JOIN ~g~.EventPersonOption EPO ON (EP.epersonID=EPO.epersonID) "
|
+ " INNER JOIN ~g~.EventPersonOption EPO ON (EP.epersonID=EPO.epersonID) "
|
||||||
+ " INNER JOIN ~g~.EventOption EO ON (EPO.optionID=EO.optionID) "
|
+ " INNER JOIN ~g~.EventOption EO ON (EPO.optionID=EO.optionID) "
|
||||||
+ " WHERE EP.eventID=? AND EPO.itemID IS NOT NULL "
|
+ " WHERE EP.eventID=? AND EP.personID=? AND EPO.itemID IS NOT NULL "
|
||||||
+ " AND (EO.multiple IS FALSE OR EO.funded='option' OR EO.static IS NOT NULL) "
|
+ " AND (EO.multiple IS FALSE OR EO.funded='option' OR EO.static IS NOT NULL) "
|
||||||
+ " AND EO.amount IS NOT NULL AND EO.waive IS FALSE "
|
+ " AND EO.amount IS NOT NULL AND EO.waive IS FALSE "
|
||||||
+ " UNION ALL "
|
+ " UNION ALL "
|
||||||
@@ -63,16 +196,105 @@ public class EventFinanceServiceDAO implements EventFinanceService {
|
|||||||
+ " INNER JOIN ~g~.EventPersonOption EPO ON (EP.epersonID=EPO.epersonID) "
|
+ " INNER JOIN ~g~.EventPersonOption EPO ON (EP.epersonID=EPO.epersonID) "
|
||||||
+ " INNER JOIN ~g~.EventOption EO ON (EPO.optionID=EO.optionID) "
|
+ " INNER JOIN ~g~.EventOption EO ON (EPO.optionID=EO.optionID) "
|
||||||
+ " INNER JOIN ~g~.EventOptionItem EOI ON (EPO.itemID=EOI.itemID) "
|
+ " INNER JOIN ~g~.EventOptionItem EOI ON (EPO.itemID=EOI.itemID) "
|
||||||
+ " WHERE EP.eventID=? AND EO.waive IS FALSE AND EO.funded='selection' AND EOI.amount IS NOT NULL "
|
+ " WHERE EP.eventID=? AND EP.personID=? AND EO.waive IS FALSE AND EO.funded='selection' AND EOI.amount IS NOT NULL "
|
||||||
+ " UNION ALL "
|
+ " UNION ALL "
|
||||||
+ " SELECT ALL EPP.personID, EP.epersonID, 0 expenses, EPP.amount paid "
|
+ " SELECT ALL EPP.personID, EP.epersonID, 0 expenses, EPP.amount paid "
|
||||||
+ " FROM ~g~.EventPersonPayment EPP "
|
+ " FROM ~g~.EventPersonPayment EPP "
|
||||||
+ " LEFT JOIN ~g~.EventPerson EP ON (EPP.eventID=EP.eventID AND EPP.personID=EP.personID) "
|
+ " LEFT JOIN ~g~.EventPerson EP ON (EPP.eventID=EP.eventID AND EPP.personID=EP.personID) "
|
||||||
+ " WHERE EPP.eventID=?) TT "
|
+ " WHERE EPP.eventID=? AND EPP.personID=?) TT "
|
||||||
+ " INNER JOIN ~p~.Person P "
|
|
||||||
+ "GROUP BY P.personID "
|
|
||||||
+ "ORDER BY P.lname, P.fname, P.suffix"
|
|
||||||
)
|
)
|
||||||
private StatementProvider sqlSelectBalances;
|
private StatementProvider sqlSelectPersonBalances;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@NonTransactionalProvider
|
||||||
|
@GolfProvider
|
||||||
|
@Statement(
|
||||||
|
sql = "SELECT TT.personID, TT.epersonID, SUM(TT.expenses) expenses, SUM(TT.paid) paid, (SUM(TT.paid)-SUM(TT.expenses)) balance "
|
||||||
|
+ "FROM ("
|
||||||
|
+ " SELECT ALL EP.personID, EP.epersonID, IF(EB.projectedValue IS NULL, 0, EB.projectedValue) expenses, 0 paid "
|
||||||
|
+ " FROM ~g~.Event E "
|
||||||
|
+ " INNER JOIN ~g~.EventPerson EP ON (E.eventID=EP.eventID) "
|
||||||
|
+ " INNER JOIN ~g~.EventBudget EB ON (EP.eventID=EB.eventID) "
|
||||||
|
+ " WHERE E.seriesID=? AND E.eventID<>? AND E.liveline<? "
|
||||||
|
+ " UNION ALL "
|
||||||
|
+ " SELECT ALL EP.personID, EP.epersonID, EO.amount expenses, 0 paid "
|
||||||
|
+ " FROM ~g~.Event E "
|
||||||
|
+ " INNER JOIN ~g~.EventPerson EP ON (E.eventID=EP.eventID) "
|
||||||
|
+ " INNER JOIN ~g~.EventPersonOption EPO ON (EP.epersonID=EPO.epersonID) "
|
||||||
|
+ " INNER JOIN ~g~.EventOption EO ON (EPO.optionID=EO.optionID) "
|
||||||
|
+ " WHERE E.seriesID=? AND E.eventID<>? AND E.liveline<? AND EPO.answer='Y' AND EO.amount IS NOT NULL AND EO.waive IS FALSE "
|
||||||
|
+ " UNION ALL "
|
||||||
|
+ " SELECT ALL EP.personID, EP.epersonID, EO.amount expenses, 0 paid "
|
||||||
|
+ " FROM ~g~.Event E "
|
||||||
|
+ " INNER JOIN ~g~.EventPerson EP ON (E.eventID=EP.eventID) "
|
||||||
|
+ " INNER JOIN ~g~.EventPersonOption EPO ON (EP.epersonID=EPO.epersonID) "
|
||||||
|
+ " INNER JOIN ~g~.EventOption EO ON (EPO.optionID=EO.optionID) "
|
||||||
|
+ " WHERE E.seriesID=? AND E.eventID<>? AND E.liveline<? AND EPO.itemID IS NOT NULL "
|
||||||
|
+ " AND (EO.multiple IS FALSE OR EO.funded='option' OR EO.static IS NOT NULL) "
|
||||||
|
+ " AND EO.amount IS NOT NULL AND EO.waive IS FALSE "
|
||||||
|
+ " UNION ALL "
|
||||||
|
+ " SELECT ALL EP.personID, EP.epersonID, EOI.amount expenses, 0 paid "
|
||||||
|
+ " FROM ~g~.Event E "
|
||||||
|
+ " INNER JOIN ~g~.EventPerson EP ON (E.eventID=EP.eventID) "
|
||||||
|
+ " INNER JOIN ~g~.EventPersonOption EPO ON (EP.epersonID=EPO.epersonID) "
|
||||||
|
+ " INNER JOIN ~g~.EventOption EO ON (EPO.optionID=EO.optionID) "
|
||||||
|
+ " INNER JOIN ~g~.EventOptionItem EOI ON (EPO.itemID=EOI.itemID) "
|
||||||
|
+ " WHERE E.seriesID=? AND E.eventID<>? AND E.liveline<? AND EO.waive IS FALSE AND EO.funded='selection' AND EOI.amount IS NOT NULL "
|
||||||
|
+ " UNION ALL "
|
||||||
|
+ " SELECT ALL EPP.personID, EP.epersonID, 0 expenses, EPP.amount paid "
|
||||||
|
+ " FROM ~g~.Event E "
|
||||||
|
+ " INNER JOIN ~g~.EventPersonPayment EPP ON (E.eventID=EPP.eventID) "
|
||||||
|
+ " LEFT JOIN ~g~.EventPerson EP ON (EPP.eventID=EP.eventID AND EPP.personID=EP.personID) "
|
||||||
|
+ " WHERE E.seriesID=? AND E.eventID<>? AND E.liveline<?) TT "
|
||||||
|
+ "GROUP BY TT.personID"
|
||||||
|
)
|
||||||
|
private StatementProvider sqlSelectSeriesBalances;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@NonTransactionalProvider
|
||||||
|
@GolfProvider
|
||||||
|
@Statement(
|
||||||
|
sql = "SELECT TT.eventID, TT.epersonID, SUM(TT.expenses) expenses, SUM(TT.paid) paid, (SUM(TT.paid)-SUM(TT.expenses)) balance "
|
||||||
|
+ "FROM ("
|
||||||
|
+ " SELECT ALL E.eventID, EP.epersonID, IF(EB.projectedValue IS NULL, 0, EB.projectedValue) expenses, 0 paid "
|
||||||
|
+ " FROM ~g~.Event E "
|
||||||
|
+ " INNER JOIN ~g~.EventPerson EP ON (E.eventID=EP.eventID) "
|
||||||
|
+ " INNER JOIN ~g~.EventBudget EB ON (EP.eventID=EB.eventID) "
|
||||||
|
+ " WHERE E.seriesID=? AND E.eventID<>? AND E.liveline<? AND EP.personID=? "
|
||||||
|
+ " UNION ALL "
|
||||||
|
+ " SELECT ALL E.eventID, EP.epersonID, EO.amount expenses, 0 paid "
|
||||||
|
+ " FROM ~g~.Event E "
|
||||||
|
+ " INNER JOIN ~g~.EventPerson EP ON (E.eventID=EP.eventID) "
|
||||||
|
+ " INNER JOIN ~g~.EventPersonOption EPO ON (EP.epersonID=EPO.epersonID) "
|
||||||
|
+ " INNER JOIN ~g~.EventOption EO ON (EPO.optionID=EO.optionID) "
|
||||||
|
+ " WHERE E.seriesID=? AND E.eventID<>? AND E.liveline<? AND EP.personID=? "
|
||||||
|
+ " AND EPO.answer='Y' AND EO.amount IS NOT NULL AND EO.waive IS FALSE "
|
||||||
|
+ " UNION ALL "
|
||||||
|
+ " SELECT ALL E.eventID, EP.epersonID, EO.amount expenses, 0 paid "
|
||||||
|
+ " FROM ~g~.Event E "
|
||||||
|
+ " INNER JOIN ~g~.EventPerson EP ON (E.eventID=EP.eventID) "
|
||||||
|
+ " INNER JOIN ~g~.EventPersonOption EPO ON (EP.epersonID=EPO.epersonID) "
|
||||||
|
+ " INNER JOIN ~g~.EventOption EO ON (EPO.optionID=EO.optionID) "
|
||||||
|
+ " WHERE E.seriesID=? AND E.eventID<>? AND E.liveline<? AND EP.personID=? AND EPO.itemID IS NOT NULL "
|
||||||
|
+ " AND (EO.multiple IS FALSE OR EO.funded='option' OR EO.static IS NOT NULL) "
|
||||||
|
+ " AND EO.amount IS NOT NULL AND EO.waive IS FALSE "
|
||||||
|
+ " UNION ALL "
|
||||||
|
+ " SELECT ALL E.eventID, EP.epersonID, EOI.amount expenses, 0 paid "
|
||||||
|
+ " FROM ~g~.Event E "
|
||||||
|
+ " INNER JOIN ~g~.EventPerson EP ON (E.eventID=EP.eventID) "
|
||||||
|
+ " INNER JOIN ~g~.EventPersonOption EPO ON (EP.epersonID=EPO.epersonID) "
|
||||||
|
+ " INNER JOIN ~g~.EventOption EO ON (EPO.optionID=EO.optionID) "
|
||||||
|
+ " INNER JOIN ~g~.EventOptionItem EOI ON (EPO.itemID=EOI.itemID) "
|
||||||
|
+ " WHERE E.seriesID=? AND E.eventID<>? AND E.liveline<? AND EP.personID=? "
|
||||||
|
+ " AND EO.waive IS FALSE AND EO.funded='selection' AND EOI.amount IS NOT NULL "
|
||||||
|
+ " UNION ALL "
|
||||||
|
+ " SELECT ALL E.eventID, EP.epersonID, 0 expenses, EPP.amount paid "
|
||||||
|
+ " FROM ~g~.Event E "
|
||||||
|
+ " INNER JOIN ~g~.EventPersonPayment EPP ON (E.eventID=EPP.eventID) "
|
||||||
|
+ " LEFT JOIN ~g~.EventPerson EP ON (EPP.eventID=EP.eventID AND EPP.personID=EP.personID) "
|
||||||
|
+ " WHERE E.seriesID=? AND E.eventID<>? AND E.liveline<? AND EPP.personID=?) TT "
|
||||||
|
+ "GROUP BY TT.eventID"
|
||||||
|
)
|
||||||
|
private StatementProvider sqlSelectSeriesPersonEventBalances;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,7 @@ package com.poststats.golf.service.db;
|
|||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -12,40 +13,46 @@ import com.brianlong.sql.DataSet;
|
|||||||
import com.brianlong.sql.FlexPreparedStatement;
|
import com.brianlong.sql.FlexPreparedStatement;
|
||||||
import com.brianlong.util.FlexMap;
|
import com.brianlong.util.FlexMap;
|
||||||
import com.poststats.golf.provider.GolfProvider;
|
import com.poststats.golf.provider.GolfProvider;
|
||||||
|
import com.poststats.golf.service.EventFinanceService;
|
||||||
import com.poststats.golf.service.EventPersonService;
|
import com.poststats.golf.service.EventPersonService;
|
||||||
import com.poststats.provider.NonTransactionalProvider;
|
import com.poststats.provider.NonTransactionalProvider;
|
||||||
import com.poststats.provider.Statement;
|
import com.poststats.provider.Statement;
|
||||||
import com.poststats.provider.StatementProvider;
|
import com.poststats.provider.StatementProvider;
|
||||||
import com.poststats.service.ServiceException;
|
import com.poststats.service.ServiceException;
|
||||||
import com.poststats.service.db.CacheableServiceDAO;
|
import com.poststats.service.db.CacheableServiceDAO;
|
||||||
|
import com.poststats.util.Contact;
|
||||||
|
|
||||||
import jakarta.enterprise.context.ApplicationScoped;
|
import jakarta.enterprise.context.ApplicationScoped;
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
|
import jakarta.mail.MessagingException;
|
||||||
|
|
||||||
@ApplicationScoped
|
@ApplicationScoped
|
||||||
public class EventPersonServiceDAO extends CacheableServiceDAO<BigInteger> implements EventPersonService {
|
public class EventPersonServiceDAO extends CacheableServiceDAO<BigInteger> implements EventPersonService {
|
||||||
|
|
||||||
@Override
|
|
||||||
public FlexMap get(long eventId, long personId) {
|
|
||||||
try {
|
|
||||||
FlexPreparedStatement fps = this.sqlSelectEventPersonByEventIdPersonId.buildPreparedStatement();
|
|
||||||
try {
|
|
||||||
fps.setIntegerU(1, eventId);
|
|
||||||
fps.setIntegerU(1, personId);
|
|
||||||
return fps.executeQuery().getNextRow();
|
|
||||||
} finally {
|
|
||||||
fps.close();
|
|
||||||
}
|
|
||||||
} catch (SQLException se) {
|
|
||||||
throw new ServiceException(se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@NonTransactionalProvider
|
private EventFinanceService eventFinanceService;
|
||||||
@GolfProvider
|
|
||||||
@Statement(sql = "SELECT * FROM ~g~.EventPerson WHERE eventID=? AND personID=?")
|
@Override
|
||||||
private StatementProvider sqlSelectEventPersonByEventIdPersonId;
|
public FlexMap get(long eventId, long personId) {
|
||||||
|
try {
|
||||||
|
FlexPreparedStatement fps = this.sqlSelectEventPersonByEventIdPersonId.buildPreparedStatement();
|
||||||
|
try {
|
||||||
|
fps.setIntegerU(1, eventId);
|
||||||
|
fps.setIntegerU(2, personId);
|
||||||
|
return fps.executeQuery().getNextRow();
|
||||||
|
} finally {
|
||||||
|
fps.close();
|
||||||
|
}
|
||||||
|
} catch (SQLException se) {
|
||||||
|
throw new ServiceException(se);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@NonTransactionalProvider
|
||||||
|
@GolfProvider
|
||||||
|
@Statement(sql = "SELECT * FROM ~g~.EventPerson WHERE eventID=? AND personID=?")
|
||||||
|
private StatementProvider sqlSelectEventPersonByEventIdPersonId;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends FlexMap> getPeople(long eventId) {
|
public List<? extends FlexMap> getPeople(long eventId) {
|
||||||
@@ -123,38 +130,260 @@ public class EventPersonServiceDAO extends CacheableServiceDAO<BigInteger> imple
|
|||||||
fps.close();
|
fps.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Contact> getContactsByListId(long eventId, long listId, boolean allowEmail, boolean allowText) {
|
||||||
|
try {
|
||||||
|
List<? extends FlexMap> persons = this.getByContactListIds(eventId, listId);
|
||||||
|
|
||||||
|
List<Contact> contacts = new ArrayList<>(persons.size());
|
||||||
|
for (FlexMap person : persons)
|
||||||
|
contacts.add(new Contact(person, allowEmail, allowText));
|
||||||
|
return contacts;
|
||||||
|
} catch (MessagingException me) {
|
||||||
|
throw new ServiceException(me);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Contact> getContactsByAutolist(long eventId, String autolist, boolean allowEmail, boolean allowText) {
|
||||||
|
try {
|
||||||
|
List<? extends FlexMap> persons = this.getByAutolist(eventId, autolist);
|
||||||
|
|
||||||
|
List<Contact> contacts = new ArrayList<>(persons.size());
|
||||||
|
for (FlexMap person : persons)
|
||||||
|
contacts.add(new Contact(person, allowEmail, allowText));
|
||||||
|
return contacts;
|
||||||
|
} catch (MessagingException me) {
|
||||||
|
throw new ServiceException(me);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<? extends FlexMap> getByContactListIds(long eventId, long listId) {
|
||||||
|
try {
|
||||||
|
FlexPreparedStatement fps = this.sqlSelectByListId.buildPreparedStatement();
|
||||||
|
try {
|
||||||
|
fps.setIntegerU(1, eventId);
|
||||||
|
fps.setIntegerU(2, listId);
|
||||||
|
return fps.executeQuery().getAllRows();
|
||||||
|
} finally {
|
||||||
|
fps.close();
|
||||||
|
}
|
||||||
|
} catch (SQLException se) {
|
||||||
|
throw new ServiceException(se);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@NonTransactionalProvider
|
||||||
|
@GolfProvider
|
||||||
|
@Statement(
|
||||||
|
sql = "SELECT P.* "
|
||||||
|
+ "FROM ~g~.EventContactList ECL "
|
||||||
|
+ " INNER JOIN ~p~.ContactListPerson CLP ON (ECL.listID=CLP.listID) "
|
||||||
|
+ " INNER JOIN ~p~.Person P ON (CLP.personID=P.personID) "
|
||||||
|
+ "WHERE ECL.eventID=? AND ECL.listID=? "
|
||||||
|
)
|
||||||
|
private StatementProvider sqlSelectByListId;
|
||||||
|
|
||||||
|
public List<? extends FlexMap> getByAutolist(long eventId, String autolist) {
|
||||||
|
switch (autolist) {
|
||||||
|
case "balance":
|
||||||
|
Map<Long, DataSet> balances = this.eventFinanceService.getPersonsBalances(eventId, null, -0.01f);
|
||||||
|
return new ArrayList<>(balances.values());
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
StatementProvider statementProvider = this.getStatementProviderByAutolist(autolist);
|
||||||
|
try {
|
||||||
|
FlexPreparedStatement fps = this.getStatementByAutolist(statementProvider, eventId, autolist);
|
||||||
|
try {
|
||||||
|
return fps.executeQuery().getAllRows();
|
||||||
|
} finally {
|
||||||
|
fps.close();
|
||||||
|
}
|
||||||
|
} catch (SQLException se) {
|
||||||
|
throw new ServiceException(se);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private StatementProvider getStatementProviderByAutolist(String autolist) {
|
||||||
|
switch (autolist) {
|
||||||
|
case "all":
|
||||||
|
return this.sqlSelectEventAllIds;
|
||||||
|
case "signed":
|
||||||
|
return this.sqlSelectEventParticipantIds;
|
||||||
|
case "unsigned":
|
||||||
|
return this.sqlSelectEventRumormillIds;
|
||||||
|
case "rookies":
|
||||||
|
return this.sqlSelectEventRookieIds;
|
||||||
|
case "rookies-refs":
|
||||||
|
return this.sqlSelectEventRookieReferralIds;
|
||||||
|
case "options":
|
||||||
|
return this.sqlSelectEventParticipantIdsWithUnansweredOptions;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
if (autolist.startsWith("previous")) {
|
||||||
|
if (autolist.length() > "previous".length()) {
|
||||||
|
return this.sqlSelectRecentSeriesParticipantIds;
|
||||||
|
} else {
|
||||||
|
return this.sqlSelectSeriesParticipantIds;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private FlexPreparedStatement getStatementByAutolist(StatementProvider statementProvider, long eventId, String autolist) throws SQLException {
|
||||||
|
int weeks = -1;
|
||||||
|
if (autolist.startsWith("previous") && autolist.length() > "previous".length())
|
||||||
|
weeks = Integer.parseInt(autolist.substring("previous".length() + 1));
|
||||||
|
|
||||||
|
FlexPreparedStatement fps = statementProvider.buildPreparedStatement();
|
||||||
|
try {
|
||||||
|
int c = 1;
|
||||||
|
fps.setIntegerU(c++, eventId);
|
||||||
|
if (weeks >= 0) {
|
||||||
|
fps.setIntegerU(c++, eventId);
|
||||||
|
fps.setSmallintU(c++, weeks);
|
||||||
|
fps.setSmallintU(c++, weeks);
|
||||||
|
}
|
||||||
|
if (autolist.equals("all") || autolist.equals("rookies-refs") || autolist.startsWith("previous")) {
|
||||||
|
fps.setIntegerU(c++, eventId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return fps;
|
||||||
|
} catch (SQLException se) {
|
||||||
|
fps.close();
|
||||||
|
throw se;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@NonTransactionalProvider
|
||||||
|
@GolfProvider
|
||||||
|
@Statement(sql = "SELECT personID, epersonID FROM ~g~.EventPerson WHERE eventID=?")
|
||||||
|
private StatementProvider sqlSelectEventParticipantIds;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@NonTransactionalProvider
|
||||||
|
@GolfProvider
|
||||||
|
@Statement(sql = "SELECT personID, NULL epersonID FROM ~g~.EventPersonContract WHERE eventID=?")
|
||||||
|
private StatementProvider sqlSelectEventRumormillIds;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@NonTransactionalProvider
|
||||||
|
@GolfProvider
|
||||||
|
@Statement(sql = "SELECT personID, epersonID FROM ~g~.EventPerson WHERE eventID=? "
|
||||||
|
+ "UNION "
|
||||||
|
+ "SELECT personID, NULL epersonID FROM ~g~.EventPersonContract WHERE eventID=? ")
|
||||||
|
private StatementProvider sqlSelectEventAllIds;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@NonTransactionalProvider
|
||||||
|
@GolfProvider
|
||||||
|
@Statement(sql = "SELECT DISTINCT EP.personID, EP.epersonID "
|
||||||
|
+ "FROM ~g~.EventPerson EP "
|
||||||
|
+ " LEFT JOIN ~g~.EventPerson EP2 ON (EP.eventID<>EP2.eventID AND EP.personID=EP2.personID) "
|
||||||
|
+ "WHERE EP.eventID=? AND EP2.epersonID IS NULL")
|
||||||
|
private StatementProvider sqlSelectEventRookieIds;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@NonTransactionalProvider
|
||||||
|
@GolfProvider
|
||||||
|
@Statement(sql = "SELECT DISTINCT EP.personID "
|
||||||
|
+ "FROM ~g~.EventPerson EP "
|
||||||
|
+ " LEFT JOIN ~g~.EventPerson EP2 ON (EP.eventID<>EP2.eventID AND EP.personID=EP2.personID) "
|
||||||
|
+ "WHERE EP.eventID=? AND EP2.epersonID IS NULL "
|
||||||
|
+ "UNION "
|
||||||
|
+ "SELECT DISTINCT P.referralPersonID "
|
||||||
|
+ "FROM ~g~.EventPerson EP "
|
||||||
|
+ " LEFT JOIN ~g~.EventPerson EP2 ON (EP.eventID<>EP2.eventID AND EP.personID=EP2.personID) "
|
||||||
|
+ " INNER JOIN ~p~.Person P ON (EP.personID=P.personID) "
|
||||||
|
+ "WHERE EP.eventID=? AND EP2.epersonID IS NULL AND P.referralPersonID IS NOT NULL")
|
||||||
|
private StatementProvider sqlSelectEventRookieReferralIds;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@NonTransactionalProvider
|
||||||
|
@GolfProvider
|
||||||
|
@Statement(sql = "SELECT EP.personID, EP.epersonID "
|
||||||
|
+ "FROM ~g~.EventPerson EP "
|
||||||
|
+ " INNER JOIN ?TT? TT1 ON (EP.personID=TT1.personID) "
|
||||||
|
+ "WHERE EP.eventID=? "
|
||||||
|
+ "GROUP BY EP.personID HAVING SUM(TT1.balance) < 0 ")
|
||||||
|
private StatementProvider sqlSelectEventParticipantIdsWithBalance;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@NonTransactionalProvider
|
||||||
|
@GolfProvider
|
||||||
|
@Statement(sql = "SELECT DISTINCT EP.personID, EP.epersonID "
|
||||||
|
+ "FROM ~g~.EventOption EO "
|
||||||
|
+ " INNER JOIN ~g~.EventPerson EP ON (EO.eventID=EP.eventID) "
|
||||||
|
+ " LEFT JOIN ~g~.EventPersonOption EPO ON (EO.optionID=EPO.optionID AND EP.epersonID=EPO.epersonID) "
|
||||||
|
+ "WHERE EO.eventID=? "
|
||||||
|
+ " AND (EO.liveline IS NULL OR EO.liveline<=CURRENT_DATE) "
|
||||||
|
+ " AND (EO.deadline IS NULL OR EO.deadline>=CURRENT_DATE) "
|
||||||
|
+ " AND EPO.optionID IS NULL ")
|
||||||
|
private StatementProvider sqlSelectEventParticipantIdsWithUnansweredOptions;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@NonTransactionalProvider
|
||||||
|
@GolfProvider
|
||||||
|
@Statement(sql = "SELECT DISTINCT EP.personID "
|
||||||
|
+ "FROM ~g~.Event E "
|
||||||
|
+ " INNER JOIN ~g~.Event E2 ON (E.seriesID=E2.seriesID) "
|
||||||
|
+ " INNER JOIN ~g~.EventPerson EP ON (E2.eventID=EP.eventID) "
|
||||||
|
+ "WHERE E.eventID=? AND E2.eventID<>? "
|
||||||
|
+ "UNION DISTINCT "
|
||||||
|
+ "SELECT personID FROM ~g~.EventPersonContract WHERE eventID=? ")
|
||||||
|
private StatementProvider sqlSelectSeriesParticipantIds;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@NonTransactionalProvider
|
||||||
|
@GolfProvider
|
||||||
|
@Statement(sql = "SELECT DISTINCT EP.personID "
|
||||||
|
+ "FROM ~g~.Event E "
|
||||||
|
+ " INNER JOIN ~g~.Event E2 ON (E.seriesID=E2.seriesID) "
|
||||||
|
+ " INNER JOIN ~g~.EventPerson EP ON (E2.eventID=EP.eventID) "
|
||||||
|
+ "WHERE E.eventID=? AND E2.eventID<>? "
|
||||||
|
+ " AND ((E2.deadline IS NOT NULL AND DATE_ADD(E2.deadline, INTERVAL ? WEEK)>=CURRENT_DATE) "
|
||||||
|
+ " OR (E2.liveline IS NOT NULL AND DATE_ADD(E2.liveline, INTERVAL ? WEEK)>=CURRENT_DATE)) "
|
||||||
|
+ "UNION DISTINCT "
|
||||||
|
+ "SELECT personID FROM ~g~.EventPersonContract WHERE eventID=? ")
|
||||||
|
private StatementProvider sqlSelectRecentSeriesParticipantIds;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DataSet fetchOne(BigInteger epersonId) throws SQLException {
|
protected DataSet fetchOne(BigInteger epersonId) throws SQLException {
|
||||||
FlexPreparedStatement fps = this.sqlSelectEventPersonByIds.buildPreparedStatement();
|
FlexPreparedStatement fps = this.sqlSelectEventPersonByIds.buildPreparedStatement();
|
||||||
try {
|
try {
|
||||||
fps.setBigintU(1, epersonId);
|
fps.setBigintU(1, epersonId);
|
||||||
return fps.executeQuery().getNextRow();
|
return fps.executeQuery().getNextRow();
|
||||||
} finally {
|
} finally {
|
||||||
fps.close();
|
fps.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@NonTransactionalProvider
|
@NonTransactionalProvider
|
||||||
@GolfProvider
|
@GolfProvider
|
||||||
@Statement(sql = "SELECT * FROM ~g~.EventPerson WHERE epersonID=?")
|
@Statement(sql = "SELECT * FROM ~g~.EventPerson WHERE epersonID=?")
|
||||||
private StatementProvider sqlSelectEventPersonById;
|
private StatementProvider sqlSelectEventPersonById;
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Map<BigInteger, DataSet> fetchBulk(Collection<BigInteger> epersonIds) throws SQLException {
|
|
||||||
FlexPreparedStatement fps = this.sqlSelectEventPersonByIds.buildPreparedStatement(epersonIds);
|
|
||||||
try {
|
|
||||||
return fps.executeQuery().getAllRows("epersonID", BigInteger.class);
|
|
||||||
} finally {
|
|
||||||
fps.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject
|
@Override
|
||||||
@NonTransactionalProvider
|
protected Map<BigInteger, DataSet> fetchBulk(Collection<BigInteger> epersonIds) throws SQLException {
|
||||||
@GolfProvider
|
FlexPreparedStatement fps = this.sqlSelectEventPersonByIds.buildPreparedStatement(epersonIds);
|
||||||
@Statement(sql = "SELECT * FROM ~g~.EventPerson WHERE epersonID IN (??)")
|
try {
|
||||||
private StatementProvider sqlSelectEventPersonByIds;
|
return fps.executeQuery().getAllRows("epersonID", BigInteger.class);
|
||||||
|
} finally {
|
||||||
|
fps.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@NonTransactionalProvider
|
||||||
|
@GolfProvider
|
||||||
|
@Statement(sql = "SELECT * FROM ~g~.EventPerson WHERE epersonID IN (??)")
|
||||||
|
private StatementProvider sqlSelectEventPersonByIds;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -154,8 +154,11 @@ public class TelegramEventService implements TelegramChannelSubscriber, Telegram
|
|||||||
if (inviteLink == null)
|
if (inviteLink == null)
|
||||||
throw new ServiceException("An invite could not be created");
|
throw new ServiceException("An invite could not be created");
|
||||||
|
|
||||||
SendMessage sendMessage = SendMessage.builder().allowSendingWithoutReply(true).chatId(userId).text(
|
SendMessage sendMessage = SendMessage.builder().allowSendingWithoutReply(true).chatId(userId)
|
||||||
"You have been invited to join the " + chat.getTitle() + " channel: " + inviteLink.getInviteLink())
|
.text("You have been invited to join the "
|
||||||
|
+ chat.getTitle()
|
||||||
|
+ " channel: "
|
||||||
|
+ inviteLink.getInviteLink())
|
||||||
.build();
|
.build();
|
||||||
this.telegramService.callEndpoint(sendMessage);
|
this.telegramService.callEndpoint(sendMessage);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user