From 517f43ba9dcd4b83118c87e09b3aee4c6f741a59 Mon Sep 17 00:00:00 2001 From: Sylvain Jermini Date: Wed, 2 Nov 2016 19:39:03 +0100 Subject: [PATCH] fix issue #237 --- .../api/admin/EventApiController.java | 4 +- src/main/java/alfio/model/EventStatistic.java | 98 +++++++++++++++++++ 2 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 src/main/java/alfio/model/EventStatistic.java diff --git a/src/main/java/alfio/controller/api/admin/EventApiController.java b/src/main/java/alfio/controller/api/admin/EventApiController.java index 6db9217507..9242f0abc8 100644 --- a/src/main/java/alfio/controller/api/admin/EventApiController.java +++ b/src/main/java/alfio/controller/api/admin/EventApiController.java @@ -154,8 +154,8 @@ public List getAllEventsForExternal(Principal principal, HttpServ } @RequestMapping(value = "/events", method = GET) - public List getAllEvents(Principal principal) { - return eventStatisticsManager.getAllEventsWithStatistics(principal.getName()).stream() + public List getAllEvents(Principal principal) { + return eventStatisticsManager.getAllEventsWithStatistics(principal.getName()).stream().map(EventStatistic::new) .sorted().collect(Collectors.toList()); } diff --git a/src/main/java/alfio/model/EventStatistic.java b/src/main/java/alfio/model/EventStatistic.java new file mode 100644 index 0000000000..340bad380a --- /dev/null +++ b/src/main/java/alfio/model/EventStatistic.java @@ -0,0 +1,98 @@ +/** + * This file is part of alf.io. + * + * alf.io is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * alf.io is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with alf.io. If not, see . + */ +package alfio.model; + +import alfio.model.modification.EventWithStatistics; +import alfio.model.modification.StatisticsContainer; +import alfio.model.transaction.PaymentProxy; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.List; + + +public class EventStatistic implements StatisticsContainer { + + + @JsonIgnore + private final EventWithStatistics eventWithStatistics; + + public EventStatistic(EventWithStatistics eventWithStatistics) { + this.eventWithStatistics = eventWithStatistics; + } + + public List getAllowedPaymentProxies() { + return eventWithStatistics.getAllowedPaymentProxies(); + } + + public boolean isWarningNeeded() { + return eventWithStatistics.isWarningNeeded(); + } + + public int getAvailableSeats() { + return eventWithStatistics.getAvailableSeats(); + } + + public String getFormattedBegin() { + return eventWithStatistics.getFormattedBegin(); + } + + public String getFormattedEnd() { + return eventWithStatistics.getFormattedEnd(); + } + + public boolean isExpired() { + return eventWithStatistics.isExpired(); + } + + public String getShortName() { + return eventWithStatistics.getShortName(); + } + + public String getDisplayName() { + return eventWithStatistics.getDisplayName(); + } + + @Override + public int getNotSoldTickets() { + return eventWithStatistics.getNotSoldTickets(); + } + + @Override + public int getSoldTickets() { + return eventWithStatistics.getSoldTickets(); + } + + @Override + public int getCheckedInTickets() { + return eventWithStatistics.getCheckedInTickets(); + } + + @Override + public int getNotAllocatedTickets() { + return eventWithStatistics.getNotAllocatedTickets(); + } + + @Override + public int getPendingTickets() { + return eventWithStatistics.getPendingTickets(); + } + + @Override + public int getDynamicAllocation() { + return eventWithStatistics.getDynamicAllocation(); + } +}