mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-27 06:17:27 +00:00
Split up in several actions with different refresh intervals and
implemented auto refresh for race list
This commit is contained in:
1 parent
71f289fa3b
commit
dff8016da5
5 files changed
+69
-97
No files matched your search
+22
-19
@@ -32,14 +32,18 @@ import com.sap.sailing.gwt.home.client.place.event.partials.racelist.SortableRac
|
||||
import com.sap.sailing.gwt.home.client.place.event.partials.regattaraces.EventRegattaRaces;
|
||||
import com.sap.sailing.gwt.home.client.place.event.regatta.EventRegattaView.Presenter;
|
||||
import com.sap.sailing.gwt.home.client.place.event.regatta.RegattaTabView;
|
||||
import com.sap.sailing.gwt.home.client.place.event.regatta.tabs.reload.RefreshManager;
|
||||
import com.sap.sailing.gwt.home.client.place.event.regatta.tabs.reload.RefreshableWidget;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.shared.LeaderboardGroupDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.RaceGroupDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.StrippedLeaderboardDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.ResultWithTTL;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.event.GetRaceListViewAction;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.SortedSetResult;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.event.GetFinishedRacesAction;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.event.GetLiveRacesForRegattaAction;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.event.GetRegattaWithProgressAction;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.event.RaceListRaceDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.event.RaceListViewDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.regatta.RegattaWithProgressDTO;
|
||||
import com.sap.sse.common.Util.Triple;
|
||||
|
||||
/**
|
||||
@@ -109,27 +113,21 @@ public class RegattaRacesTabView extends Composite implements RegattaTabView<Reg
|
||||
|
||||
@Override
|
||||
public void start(RegattaRacesPlace myPlace, final AcceptsOneWidget contentArea) {
|
||||
RefreshManager refreshManager = new RefreshManager(this, currentPresenter.getDispatch());
|
||||
if (SHOW_NEW_RACES_LIST) {
|
||||
listNavigationPanelUi.removeFromParent(); // TODO temporary removed
|
||||
// listNavigationPanelUi.addAction(Navigation.SORT_LIST_FORMAT, true);
|
||||
// listNavigationPanelUi.addAction(Navigation.COMPETITION_FORMAT, false);
|
||||
|
||||
GetRaceListViewAction action = new GetRaceListViewAction(myPlace.getCtx().getEventDTO().getId(), myPlace.getRegattaId());
|
||||
currentPresenter.getDispatch().execute(action, new AsyncCallback<ResultWithTTL<RaceListViewDTO>>() {
|
||||
refreshManager.add(liveRacesList, new GetLiveRacesForRegattaAction(myPlace.getCtx().getEventDTO().getId(), myPlace.getRegattaId()));
|
||||
refreshManager.add(new RefreshableWidget<RegattaWithProgressDTO>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
public void setData(RegattaWithProgressDTO data, long nextUpdate, int updateNo) {
|
||||
regattaInfoContainerUi.setWidget(new MultiRegattaListItem(data));
|
||||
}
|
||||
@Override
|
||||
public void onSuccess(ResultWithTTL<RaceListViewDTO> result) {
|
||||
regattaInfoContainerUi.setWidget(new MultiRegattaListItem(result.getDto().getProgress()));
|
||||
liveRacesList.setListData(result.getDto().getLiveRaces());
|
||||
finishedRacesList.setListData(result.getDto().getFinishedRaces());
|
||||
// for (RaceListSeriesDTO series : result.getDto().getRacesForCompetitionFormat()) {
|
||||
// compFormatContainerUi.add(new RegattaCompetitionSeries(currentPresenter, series));
|
||||
// }
|
||||
contentArea.setWidget(RegattaRacesTabView.this);
|
||||
}
|
||||
});
|
||||
}, new GetRegattaWithProgressAction(myPlace.getCtx().getEventDTO().getId(), myPlace.getRegattaId()));
|
||||
refreshManager.add(finishedRacesList, new GetFinishedRacesAction(myPlace.getCtx().getEventDTO().getId(), myPlace.getRegattaId()));
|
||||
|
||||
oldContentContainer.removeFromParent();
|
||||
} else {
|
||||
regattaInfoContainerUi.removeFromParent();
|
||||
@@ -146,7 +144,6 @@ public class RegattaRacesTabView extends Composite implements RegattaTabView<Reg
|
||||
EventRegattaRaces regattaRaces = new EventRegattaRaces(currentPresenter);
|
||||
oldContentContainer.setWidget(regattaRaces);
|
||||
regattaRaces.setRaces(selectedRegatta.getC(), false, selectedRegatta.getB(), selectedRegatta.getA());
|
||||
contentArea.setWidget(RegattaRacesTabView.this);
|
||||
} else {
|
||||
// createEventWithoutRegattasView(event, panel);
|
||||
}
|
||||
@@ -160,6 +157,7 @@ public class RegattaRacesTabView extends Composite implements RegattaTabView<Reg
|
||||
}
|
||||
});
|
||||
}
|
||||
contentArea.setWidget(RegattaRacesTabView.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -205,7 +203,7 @@ public class RegattaRacesTabView extends Composite implements RegattaTabView<Reg
|
||||
}
|
||||
}
|
||||
|
||||
private class RaceListFinishedRaces extends AbstractRaceList<RaceListRaceDTO> {
|
||||
private class RaceListFinishedRaces extends AbstractRaceList<RaceListRaceDTO> implements RefreshableWidget<SortedSetResult<RaceListRaceDTO>> {
|
||||
private final SortableRaceListColumn<RaceListRaceDTO, ?> durationColumn = RaceListColumnFactory.getDurationColumn();
|
||||
private final SortableRaceListColumn<RaceListRaceDTO, ?> windfixesCountColumn = RaceListColumnFactory.getWindFixesCountColumn();
|
||||
private final SortableRaceListColumn<RaceListRaceDTO, ?> videoCountColumn = RaceListColumnFactory.getVideoCountColumn();
|
||||
@@ -215,6 +213,11 @@ public class RegattaRacesTabView extends Composite implements RegattaTabView<Reg
|
||||
public RaceListFinishedRaces(EventView.Presenter presenter) {
|
||||
super(presenter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(SortedSetResult<RaceListRaceDTO> data, long nextUpdate, int updateNo) {
|
||||
setListData(data.getValues());
|
||||
}
|
||||
|
||||
public void setListData(Collection<RaceListRaceDTO> data) {
|
||||
boolean hasFleets = RaceListDataUtil.hasFleets(data);
|
||||
|
||||
+7
-6
@@ -6,28 +6,29 @@ import com.google.gwt.core.shared.GwtIncompatible;
|
||||
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;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.SortedSetResult;
|
||||
|
||||
public class GetRaceListViewAction implements Action<ResultWithTTL<RaceListViewDTO>> {
|
||||
public class GetFinishedRacesAction implements Action<ResultWithTTL<SortedSetResult<RaceListRaceDTO>>> {
|
||||
|
||||
private UUID eventId;
|
||||
private String regattaId;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private GetRaceListViewAction() {
|
||||
private GetFinishedRacesAction() {
|
||||
}
|
||||
|
||||
public GetRaceListViewAction(UUID eventId, String regattaId) {
|
||||
public GetFinishedRacesAction(UUID eventId, String regattaId) {
|
||||
this.eventId = eventId;
|
||||
this.regattaId = regattaId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@GwtIncompatible
|
||||
public ResultWithTTL<RaceListViewDTO> execute(DispatchContext context) {
|
||||
public ResultWithTTL<SortedSetResult<RaceListRaceDTO>> execute(DispatchContext context) {
|
||||
RaceListDataCalculator raceListDataCalculator = new RaceListDataCalculator();
|
||||
EventActionUtil.forRacesOfRegatta(context, eventId, regattaId, raceListDataCalculator);
|
||||
ResultWithTTL<RaceListViewDTO> result = raceListDataCalculator.getResult(context, eventId, regattaId);
|
||||
|
||||
return result;
|
||||
return new ResultWithTTL<>(EventActionUtil.getEventStateDependentTTL(context, eventId, 5 * 60 * 1000),
|
||||
new SortedSetResult<>(raceListDataCalculator.getResult()));
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.sap.sailing.gwt.ui.shared.dispatch.event;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.gwt.core.shared.GwtIncompatible;
|
||||
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;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.regatta.RegattaWithProgressDTO;
|
||||
|
||||
public class GetRegattaWithProgressAction implements Action<ResultWithTTL<RegattaWithProgressDTO>> {
|
||||
|
||||
private UUID eventId;
|
||||
private String regattaId;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private GetRegattaWithProgressAction() {
|
||||
}
|
||||
|
||||
public GetRegattaWithProgressAction(UUID eventId, String regattaId) {
|
||||
this.eventId = eventId;
|
||||
this.regattaId = regattaId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@GwtIncompatible
|
||||
public ResultWithTTL<RegattaWithProgressDTO> execute(DispatchContext context) {
|
||||
return new ResultWithTTL<>(EventActionUtil.getEventStateDependentTTL(context, eventId, 5 * 60 * 1000),
|
||||
EventActionUtil.getLeaderboardContext(context, eventId, regattaId).getRegattaWithProgress(context));
|
||||
}
|
||||
}
|
||||
+9
-14
@@ -1,30 +1,25 @@
|
||||
package com.sap.sailing.gwt.ui.shared.dispatch.event;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.Collection;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import com.google.gwt.core.shared.GwtIncompatible;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.DispatchContext;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.ResultWithTTL;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.event.EventActionUtil.RaceCallback;
|
||||
|
||||
@GwtIncompatible
|
||||
public class RaceListDataCalculator implements RaceCallback {
|
||||
private final RaceRefreshCalculator refreshCalculator = new RaceRefreshCalculator();
|
||||
// private final RegattaProgressCalculator progressCalculator = new RegattaProgressCalculator();
|
||||
private final RaceListViewDTO result = new RaceListViewDTO();
|
||||
private final TreeSet<RaceListRaceDTO> races = new TreeSet<>();
|
||||
|
||||
@Override
|
||||
public void doForRace(RaceContext context) {
|
||||
refreshCalculator.doForRace(context);
|
||||
// progressCalculator.doForRace(context);
|
||||
result.add(context.getLiveRaceOrNull());
|
||||
result.add(context.getFinishedRaceOrNull());
|
||||
RaceListRaceDTO finishedRace = context.getFinishedRaceOrNull();
|
||||
if(finishedRace != null) {
|
||||
races.add(finishedRace);
|
||||
}
|
||||
}
|
||||
|
||||
public ResultWithTTL<RaceListViewDTO> getResult(DispatchContext context, UUID eventId, String regattaId) {
|
||||
LeaderboardContext leaderboardContext = EventActionUtil.getLeaderboardContext(context, eventId, regattaId);
|
||||
result.setProgress(leaderboardContext.getRegattaWithProgress(context));
|
||||
return new ResultWithTTL<>(EventActionUtil.getEventStateDependentTTL(context, eventId, refreshCalculator.getTTL()), result);
|
||||
public Collection<RaceListRaceDTO> getResult() {
|
||||
return races;
|
||||
}
|
||||
|
||||
}
|
||||
-58
@@ -1,58 +0,0 @@
|
||||
package com.sap.sailing.gwt.ui.shared.dispatch.event;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.DTO;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.regatta.RegattaWithProgressDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.race.RaceMetadataDTO;
|
||||
|
||||
public class RaceListViewDTO implements DTO {
|
||||
|
||||
private TreeSet<LiveRaceDTO> liveRaces = new TreeSet<>();
|
||||
|
||||
private TreeSet<RaceListRaceDTO> finishedRaces = new TreeSet<>();
|
||||
|
||||
private RegattaWithProgressDTO progress;
|
||||
|
||||
public void add(LiveRaceDTO liveRace) {
|
||||
add(liveRaces, liveRace);
|
||||
}
|
||||
|
||||
public void add(RaceListRaceDTO finishedRace) {
|
||||
add(finishedRaces, finishedRace);
|
||||
}
|
||||
|
||||
private <T extends RaceMetadataDTO> void add(TreeSet<T> set, T race) {
|
||||
if (race != null) {
|
||||
set.add(race);
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<LiveRaceDTO> getLiveRaces() {
|
||||
return liveRaces;
|
||||
}
|
||||
|
||||
public Collection<RaceListRaceDTO> getFinishedRaces() {
|
||||
return finishedRaces;
|
||||
}
|
||||
|
||||
public Collection<RaceListSeriesDTO> getRacesForCompetitionFormat() {
|
||||
RaceListSeriesDTO withFleets = new RaceListSeriesDTO("Fleets");
|
||||
RaceListSeriesDTO noFleets = new RaceListSeriesDTO("");
|
||||
for (RaceListRaceDTO race : finishedRaces) {
|
||||
RaceListSeriesDTO series = race.getFleet() == null ? noFleets : withFleets;
|
||||
series.addRace(race);
|
||||
}
|
||||
return Arrays.asList(withFleets, noFleets);
|
||||
}
|
||||
|
||||
public RegattaWithProgressDTO getProgress() {
|
||||
return progress;
|
||||
}
|
||||
|
||||
public void setProgress(RegattaWithProgressDTO progress) {
|
||||
this.progress = progress;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user