mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-07 12:51:02 +00:00
Merge branch 'design2015-mobile' of ssh://sapsailing.com/home/trac/git into design2015-mobile
# By Steffen Schaefer # Via Steffen Schaefer * 'design2015-mobile' of ssh://sapsailing.com/home/trac/git: Initial implementation of event statistics calculation Adjusted visibility of default constructors that are only needed for GWT serialization
This commit is contained in:
commit
8887fd3901
13 files changed
+97
-24
No files matched your search
+14
-1
@@ -5,9 +5,13 @@ import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sailing.gwt.home.client.place.event.regatta.tabs.reload.RefreshableWidget;
|
||||
import com.sap.sailing.gwt.home.mobile.partials.section.MobileSection;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.event.EventStatisticsDTO;
|
||||
|
||||
public class StatisticsBox extends Composite {
|
||||
public class StatisticsBox extends Composite implements RefreshableWidget<EventStatisticsDTO> {
|
||||
private static final StringMessages MSG = StringMessages.INSTANCE;
|
||||
|
||||
public static final String ICON_REGATTAS_FOUGHT = "images/mobile/icon_regattasFought.svg";
|
||||
public static final String ICON_COMPATITORS_COUNT = "images/mobile/icon_averageSpeed.svg";
|
||||
@@ -30,4 +34,13 @@ public class StatisticsBox extends Composite {
|
||||
itemContainerUi.addContent(new StatisticsBoxItem(iconUrl, name, count));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(EventStatisticsDTO statistics, long nextUpdate, int updateNo) {
|
||||
itemContainerUi.clearContent();
|
||||
addItem(StatisticsBox.ICON_REGATTAS_FOUGHT, MSG.regattas(), statistics.getRegattasFoughtCount());
|
||||
addItem(StatisticsBox.ICON_COMPATITORS_COUNT, MSG.competitors(), statistics.getCompetitorsCount());
|
||||
addItem(StatisticsBox.ICON_RACES_COUNT, MSG.races(), statistics.getRacesRunCount());
|
||||
addItem(StatisticsBox.ICON_TRACKED_COUNT, MSG.trackedRaces(), statistics.getTrackedRacesCount());
|
||||
}
|
||||
|
||||
}
|
||||
-2
@@ -15,7 +15,6 @@ import com.sap.sailing.gwt.home.client.place.event.AbstractEventPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.event.EventContext;
|
||||
import com.sap.sailing.gwt.home.client.place.start.StartPlace;
|
||||
import com.sap.sailing.gwt.home.mobile.app.MobileApplicationClientFactory;
|
||||
import com.sap.sailing.gwt.home.mobile.partials.statisticsBox.StatisticsDTO;
|
||||
import com.sap.sailing.gwt.home.mobile.places.event.EventView.Presenter;
|
||||
import com.sap.sailing.gwt.home.mobile.places.latestnews.LatestNewsPlace;
|
||||
import com.sap.sailing.gwt.home.shared.app.PlaceNavigation;
|
||||
@@ -71,7 +70,6 @@ public class EventActivity extends AbstractActivity implements Presenter {
|
||||
}
|
||||
view.setQuickFinderValues(place.getCtx().getEventDTO().getRegattas());
|
||||
view.getQuickfinder().addSelectionHandler(new QuickfinderSelectionHandler());
|
||||
view.setStatistics(new StatisticsDTO()); // TODO set correct stats
|
||||
view.setNavigator(clientFactory.getNavigator());
|
||||
clientFactory.getHomeService().getMediaForEvent(currentEventUUId, new AsyncCallback<MediaDTO>() {
|
||||
@Override
|
||||
|
||||
-3
@@ -7,7 +7,6 @@ import com.google.gwt.event.logical.shared.HasSelectionHandlers;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sailing.gwt.home.client.place.event.EventContext;
|
||||
import com.sap.sailing.gwt.home.mobile.app.MobilePlacesNavigator;
|
||||
import com.sap.sailing.gwt.home.mobile.partials.statisticsBox.StatisticsDTO;
|
||||
import com.sap.sailing.gwt.home.shared.app.PlaceNavigation;
|
||||
import com.sap.sailing.gwt.home.shared.dispatch.DispatchSystem;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.news.NewsEntryDTO;
|
||||
@@ -38,8 +37,6 @@ public interface EventView {
|
||||
void gotoNewsPlace(Collection<NewsEntryDTO> newsEntries);
|
||||
}
|
||||
|
||||
void setStatistics(StatisticsDTO statistics);
|
||||
|
||||
void setNavigator(MobilePlacesNavigator navigator);
|
||||
}
|
||||
|
||||
+2
-9
@@ -20,13 +20,13 @@ import com.sap.sailing.gwt.home.mobile.partials.quickfinder.Quickfinder;
|
||||
import com.sap.sailing.gwt.home.mobile.partials.regattaStatus.RegattaStatus;
|
||||
import com.sap.sailing.gwt.home.mobile.partials.simpleinfoblock.SimpleInfoBlock;
|
||||
import com.sap.sailing.gwt.home.mobile.partials.statisticsBox.StatisticsBox;
|
||||
import com.sap.sailing.gwt.home.mobile.partials.statisticsBox.StatisticsDTO;
|
||||
import com.sap.sailing.gwt.home.mobile.partials.updatesBox.UpdatesBox;
|
||||
import com.sap.sailing.gwt.home.mobile.places.event.overview.EventOverviewStage;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.ListResult;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.event.GetEventOverviewNewsAction;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.event.GetEventOverviewStageAction;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.event.GetEventStatisticsAction;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.event.GetRegattasAndLiveRacesForEventAction;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.news.NewsEntryDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.eventview.RegattaMetadataDTO;
|
||||
@@ -67,6 +67,7 @@ public class EventViewImpl extends Composite implements EventView {
|
||||
refreshManager.add(overviewStageUi, new GetEventOverviewStageAction(eventId));
|
||||
refreshManager.add(regattaStatusUi, new GetRegattasAndLiveRacesForEventAction(eventId));
|
||||
refreshManager.add(newsRefreshable, new GetEventOverviewNewsAction(presenter.getCtx().getEventDTO().getId()));
|
||||
refreshManager.add(statisticsBoxUi, new GetEventStatisticsAction(currentPresenter.getCtx().getEventDTO().getId()));
|
||||
impressionsUi.getElement().getStyle().setDisplay(Display.NONE);
|
||||
}
|
||||
|
||||
@@ -84,14 +85,6 @@ public class EventViewImpl extends Composite implements EventView {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStatistics(StatisticsDTO statistics) {
|
||||
statisticsBoxUi.addItem(StatisticsBox.ICON_REGATTAS_FOUGHT, MSG.regattas(), statistics.getRegattasFoughtCount());
|
||||
statisticsBoxUi.addItem(StatisticsBox.ICON_COMPATITORS_COUNT, MSG.competitors(), statistics.getCompetitorsCount());
|
||||
statisticsBoxUi.addItem(StatisticsBox.ICON_RACES_COUNT, MSG.races(), statistics.getRacesRunCount());
|
||||
statisticsBoxUi.addItem(StatisticsBox.ICON_TRACKED_COUNT, MSG.trackedRaces(), statistics.getTrackedRacesCount());
|
||||
}
|
||||
|
||||
@Override
|
||||
public HasSelectionHandlers<String> getQuickfinder() {
|
||||
return quickFinderUi;
|
||||
|
||||
+19
-2
@@ -1,12 +1,29 @@
|
||||
package com.sap.sailing.gwt.home.mobile.partials.statisticsBox;
|
||||
package com.sap.sailing.gwt.ui.shared.dispatch.event;
|
||||
|
||||
public class StatisticsDTO {
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.DTO;
|
||||
|
||||
public class EventStatisticsDTO implements DTO {
|
||||
|
||||
private Integer regattasFoughtCount;
|
||||
private Integer competitorsCount;
|
||||
private Integer racesRunCount;
|
||||
private Integer trackedRacesCount;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private EventStatisticsDTO() {
|
||||
}
|
||||
|
||||
public EventStatisticsDTO(Integer regattasFoughtCount, Integer competitorsCount, Integer racesRunCount,
|
||||
Integer trackedRacesCount) {
|
||||
super();
|
||||
this.regattasFoughtCount = regattasFoughtCount;
|
||||
this.competitorsCount = competitorsCount;
|
||||
this.racesRunCount = racesRunCount;
|
||||
this.trackedRacesCount = trackedRacesCount;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Integer getRegattasFoughtCount() {
|
||||
return regattasFoughtCount;
|
||||
}
|
||||
+2
-1
@@ -20,7 +20,8 @@ import com.sap.sailing.news.impl.LeaderboardUpdateNewsItem;
|
||||
public class GetEventOverviewNewsAction implements Action<ResultWithTTL<ListResult<NewsEntryDTO>>> {
|
||||
private UUID eventId;
|
||||
|
||||
public GetEventOverviewNewsAction() {
|
||||
@SuppressWarnings("unused")
|
||||
private GetEventOverviewNewsAction() {
|
||||
}
|
||||
|
||||
public GetEventOverviewNewsAction(UUID eventId) {
|
||||
|
||||
+2
-1
@@ -21,7 +21,8 @@ public class GetEventOverviewStageAction implements Action<ResultWithTTL<EventOv
|
||||
|
||||
private UUID eventId;
|
||||
|
||||
public GetEventOverviewStageAction() {
|
||||
@SuppressWarnings("unused")
|
||||
private GetEventOverviewStageAction() {
|
||||
}
|
||||
|
||||
public GetEventOverviewStageAction(UUID eventId) {
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package com.sap.sailing.gwt.ui.shared.dispatch.event;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.gwt.core.shared.GwtIncompatible;
|
||||
import com.sap.sailing.domain.base.Event;
|
||||
import com.sap.sailing.domain.leaderboard.Leaderboard;
|
||||
import com.sap.sailing.domain.leaderboard.LeaderboardGroup;
|
||||
import com.sap.sailing.gwt.server.HomeServiceUtil;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.Action;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.DispatchContext;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.ResultWithTTL;
|
||||
|
||||
public class GetEventStatisticsAction implements Action<ResultWithTTL<EventStatisticsDTO>> {
|
||||
private UUID eventId;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private GetEventStatisticsAction() {
|
||||
}
|
||||
|
||||
public GetEventStatisticsAction(UUID eventId) {
|
||||
this.eventId = eventId;
|
||||
}
|
||||
|
||||
@GwtIncompatible
|
||||
public ResultWithTTL<EventStatisticsDTO> execute(DispatchContext context) {
|
||||
Event event = context.getRacingEventService().getEvent(eventId);
|
||||
if (event == null) {
|
||||
throw new RuntimeException("Event not found");
|
||||
}
|
||||
|
||||
int competitors = 0;
|
||||
int races = 0;
|
||||
int trackedRaces = 0;
|
||||
int regattas = 0;
|
||||
|
||||
for(LeaderboardGroup lg: event.getLeaderboardGroups()) {
|
||||
for(Leaderboard leaderboard : lg.getLeaderboards()) {
|
||||
competitors += HomeServiceUtil.calculateCompetitorsCount(leaderboard);
|
||||
races += HomeServiceUtil.calculateRaceCount(leaderboard);
|
||||
trackedRaces += HomeServiceUtil.calculateTrackedRaceCount(leaderboard);
|
||||
regattas++;
|
||||
}
|
||||
}
|
||||
|
||||
return new ResultWithTTL<EventStatisticsDTO>(1000 * 60 * 5, new EventStatisticsDTO(regattas, competitors, races, trackedRaces));
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -28,7 +28,8 @@ import com.sap.sse.common.media.MediaTagConstants;
|
||||
public class GetEventViewAction implements Action<EventViewDTO> {
|
||||
private UUID eventId;
|
||||
|
||||
public GetEventViewAction() {
|
||||
@SuppressWarnings("unused")
|
||||
private GetEventViewAction() {
|
||||
}
|
||||
|
||||
public GetEventViewAction(UUID eventId) {
|
||||
|
||||
+2
-1
@@ -14,7 +14,8 @@ public class GetLiveRacesForEventAction implements Action<ResultWithTTL<LiveRace
|
||||
|
||||
private UUID eventId;
|
||||
|
||||
public GetLiveRacesForEventAction() {
|
||||
@SuppressWarnings("unused")
|
||||
private GetLiveRacesForEventAction() {
|
||||
}
|
||||
|
||||
public GetLiveRacesForEventAction(UUID eventId) {
|
||||
|
||||
+2
-1
@@ -11,7 +11,8 @@ public class GetLiveRacesForRegattaAction implements Action<ResultWithTTL<LiveRa
|
||||
private UUID eventId;
|
||||
private String regattaName;
|
||||
|
||||
public GetLiveRacesForRegattaAction() {
|
||||
@SuppressWarnings("unused")
|
||||
private GetLiveRacesForRegattaAction() {
|
||||
}
|
||||
|
||||
public GetLiveRacesForRegattaAction(UUID eventId, String regattaName) {
|
||||
|
||||
+2
-1
@@ -8,7 +8,8 @@ import com.sap.sailing.gwt.ui.shared.dispatch.DispatchContext;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.ResultWithTTL;
|
||||
|
||||
public class GetRaceListViewAction implements Action<ResultWithTTL<RaceListViewDTO>> {
|
||||
public GetRaceListViewAction() {
|
||||
@SuppressWarnings("unused")
|
||||
private GetRaceListViewAction() {
|
||||
}
|
||||
|
||||
public GetRaceListViewAction(UUID eventId) {
|
||||
|
||||
+2
-1
@@ -23,7 +23,8 @@ public class GetRegattasAndLiveRacesForEventAction implements Action<ResultWithT
|
||||
|
||||
private UUID eventId;
|
||||
|
||||
public GetRegattasAndLiveRacesForEventAction() {
|
||||
@SuppressWarnings("unused")
|
||||
private GetRegattasAndLiveRacesForEventAction() {
|
||||
}
|
||||
|
||||
public GetRegattasAndLiveRacesForEventAction(UUID eventId) {
|
||||
|
||||
Reference in new issue
Block a user