mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-27 06:17:27 +00:00
Merge branch 'design2015' into design2015-races
Conflicts: java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/shared/dispatch/event/EventActionUtil.java
This commit is contained in:
commit
d9aa35dc9e
5 files changed
+72
-41
No files matched your search
+17
-3
@@ -18,6 +18,7 @@ import com.sap.sailing.domain.base.EventBase;
|
||||
import com.sap.sailing.domain.base.Fleet;
|
||||
import com.sap.sailing.domain.base.LeaderboardGroupBase;
|
||||
import com.sap.sailing.domain.base.RaceColumn;
|
||||
import com.sap.sailing.domain.base.Regatta;
|
||||
import com.sap.sailing.domain.common.dto.FleetDTO;
|
||||
import com.sap.sailing.domain.common.dto.LeaderboardDTO;
|
||||
import com.sap.sailing.domain.common.dto.RaceColumnDTO;
|
||||
@@ -429,14 +430,27 @@ public final class HomeServiceUtil {
|
||||
}
|
||||
|
||||
public static RegattaMetadataDTO toRegattaMetadataDTO(LeaderboardGroup leaderboardGroup, Leaderboard leaderboard) {
|
||||
RegattaMetadataDTO regattaDTO = new RegattaMetadataDTO(leaderboard.getName(), leaderboard.getDisplayName() != null ? leaderboard.getDisplayName() : leaderboard.getName());
|
||||
RegattaMetadataDTO regattaDTO = new RegattaMetadataDTO();
|
||||
fillRegattaFields(leaderboardGroup, leaderboard, regattaDTO);
|
||||
|
||||
return regattaDTO;
|
||||
}
|
||||
|
||||
public static void fillRegattaFields(LeaderboardGroup leaderboardGroup, Leaderboard leaderboard,
|
||||
RegattaMetadataDTO regattaDTO) {
|
||||
regattaDTO.setId(leaderboard.getName());
|
||||
regattaDTO.setDisplayName(leaderboard.getDisplayName() != null ? leaderboard.getDisplayName() : leaderboard.getName());
|
||||
regattaDTO.setBoatCategory(leaderboardGroup.getDisplayName() != null ? leaderboardGroup.getDisplayName() : leaderboardGroup.getName());
|
||||
regattaDTO.setCompetitorsCount(calculateCompetitorsCount(leaderboard));
|
||||
regattaDTO.setRaceCount(calculateRaceCount(leaderboard));
|
||||
regattaDTO.setTrackedRacesCount(calculateTrackedRaceCount(leaderboard));
|
||||
regattaDTO.setBoatClass(getBoatClassName(leaderboard));
|
||||
|
||||
return regattaDTO;
|
||||
if(leaderboard instanceof RegattaLeaderboard) {
|
||||
Regatta regatta = ((RegattaLeaderboard) leaderboard).getRegatta();
|
||||
regattaDTO.setStartDate(regatta.getStartDate() != null ? regatta.getStartDate().asDate() : null);
|
||||
regattaDTO.setEndDate(regatta.getEndDate() != null ? regatta.getEndDate().asDate() : null);
|
||||
}
|
||||
regattaDTO.setState(calculateRegattaState(regattaDTO));
|
||||
}
|
||||
|
||||
public static boolean hasLiveRace(LeaderboardDTO leaderboard) {
|
||||
|
||||
+19
-16
@@ -4,8 +4,6 @@ import java.util.UUID;
|
||||
|
||||
import com.google.gwt.core.shared.GwtIncompatible;
|
||||
import com.sap.sailing.domain.base.Event;
|
||||
import com.sap.sailing.domain.base.Fleet;
|
||||
import com.sap.sailing.domain.base.RaceColumn;
|
||||
import com.sap.sailing.domain.leaderboard.Leaderboard;
|
||||
import com.sap.sailing.domain.leaderboard.LeaderboardGroup;
|
||||
import com.sap.sailing.gwt.server.HomeServiceUtil;
|
||||
@@ -30,6 +28,10 @@ public final class EventActionUtil {
|
||||
void doForRace(RaceContext context);
|
||||
}
|
||||
|
||||
protected interface LeaderboardCallback {
|
||||
void doForLeaderboard(LeaderboardContext context);
|
||||
}
|
||||
|
||||
public static <T extends DTO> ResultWithTTL<T> withLiveRaceOrDefaultSchedule(DispatchContext context, UUID eventId, CalculationWithEvent<T> callback) {
|
||||
Event event = context.getRacingEventService().getEvent(eventId);
|
||||
EventState eventState = HomeServiceUtil.calculateEventState(event);
|
||||
@@ -60,27 +62,28 @@ public final class EventActionUtil {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void forRacesOfEvent(DispatchContext context, UUID eventId, RaceCallback callback) {
|
||||
public static void forLeaderboardsOfEvent(DispatchContext context, UUID eventId, LeaderboardCallback callback) {
|
||||
Event event = context.getRacingEventService().getEvent(eventId);
|
||||
for (LeaderboardGroup lg : event.getLeaderboardGroups()) {
|
||||
for (Leaderboard lb : lg.getLeaderboards()) {
|
||||
forRacesOfLeaderboard(context, event, lb, callback);
|
||||
for (LeaderboardGroup leaderboardGroup : event.getLeaderboardGroups()) {
|
||||
for (Leaderboard leaderboard : leaderboardGroup.getLeaderboards()) {
|
||||
callback.doForLeaderboard(new LeaderboardContext(event, leaderboardGroup, leaderboard));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void forRacesOfEvent(final DispatchContext context, UUID eventId, final RaceCallback callback) {
|
||||
forLeaderboardsOfEvent(context, eventId, new LeaderboardCallback() {
|
||||
@Override
|
||||
public void doForLeaderboard(LeaderboardContext leaderboardContext) {
|
||||
leaderboardContext.forRaces(context, callback);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void forRacesOfRegatta(DispatchContext context, UUID eventId, String regattaName, RaceCallback callback) {
|
||||
Event event = context.getRacingEventService().getEvent(eventId);
|
||||
// TODO check that the leaderboard is part of the event
|
||||
Leaderboard lb = context.getRacingEventService().getLeaderboardByName(regattaName);
|
||||
forRacesOfLeaderboard(context, event, lb, callback);
|
||||
}
|
||||
|
||||
private static void forRacesOfLeaderboard(DispatchContext context, Event event, Leaderboard lb, RaceCallback callback) {
|
||||
for(RaceColumn raceColumn : lb.getRaceColumns()) {
|
||||
for(Fleet fleet : raceColumn.getFleets()) {
|
||||
callback.doForRace(new RaceContext(event, lb, raceColumn, fleet, context.getRacingEventService()));
|
||||
}
|
||||
}
|
||||
Leaderboard leaderboard = context.getRacingEventService().getLeaderboardByName(regattaName);
|
||||
new LeaderboardContext(event, null, leaderboard).forRaces(context, callback);
|
||||
}
|
||||
}
|
||||
+2
-20
@@ -11,11 +11,8 @@ import java.util.logging.Logger;
|
||||
|
||||
import com.google.gwt.core.shared.GwtIncompatible;
|
||||
import com.sap.sailing.domain.base.Event;
|
||||
import com.sap.sailing.domain.base.Regatta;
|
||||
import com.sap.sailing.domain.leaderboard.FlexibleLeaderboard;
|
||||
import com.sap.sailing.domain.leaderboard.Leaderboard;
|
||||
import com.sap.sailing.domain.leaderboard.LeaderboardGroup;
|
||||
import com.sap.sailing.domain.leaderboard.RegattaLeaderboard;
|
||||
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;
|
||||
@@ -66,23 +63,8 @@ public class GetEventViewAction implements Action<EventViewDTO> {
|
||||
if(isFakeSeries && !HomeServiceUtil.isPartOfEvent(event, leaderboard)) {
|
||||
continue;
|
||||
}
|
||||
if(leaderboard instanceof RegattaLeaderboard) {
|
||||
Regatta regatta = context.getRacingEventService().getRegattaByName(leaderboard.getName());
|
||||
|
||||
RegattaMetadataDTO regattaDTO = HomeServiceUtil.toRegattaMetadataDTO(leaderboardGroup, leaderboard);
|
||||
regattaDTO.setStartDate(regatta.getStartDate() != null ? regatta.getStartDate().asDate() : null);
|
||||
regattaDTO.setEndDate(regatta.getEndDate() != null ? regatta.getEndDate().asDate() : null);
|
||||
regattaDTO.setState(HomeServiceUtil.calculateRegattaState(regattaDTO));
|
||||
dto.getRegattas().add(regattaDTO);
|
||||
|
||||
} else if(leaderboard instanceof FlexibleLeaderboard) {
|
||||
RegattaMetadataDTO regattaDTO = HomeServiceUtil.toRegattaMetadataDTO(leaderboardGroup, leaderboard);
|
||||
|
||||
regattaDTO.setStartDate(null);
|
||||
regattaDTO.setEndDate(null);
|
||||
regattaDTO.setState(HomeServiceUtil.calculateRegattaState(regattaDTO));
|
||||
dto.getRegattas().add(regattaDTO);
|
||||
}
|
||||
RegattaMetadataDTO regattaDTO = HomeServiceUtil.toRegattaMetadataDTO(leaderboardGroup, leaderboard);
|
||||
dto.getRegattas().add(regattaDTO);
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.SEVERE, "Catched exception while reading data for leaderboard " + leaderboard.getName(), e);
|
||||
}
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.sap.sailing.gwt.ui.shared.dispatch.event;
|
||||
|
||||
import com.sap.sailing.domain.base.Event;
|
||||
import com.sap.sailing.domain.base.Fleet;
|
||||
import com.sap.sailing.domain.base.RaceColumn;
|
||||
import com.sap.sailing.domain.leaderboard.Leaderboard;
|
||||
import com.sap.sailing.domain.leaderboard.LeaderboardGroup;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.DispatchContext;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.event.EventActionUtil.RaceCallback;
|
||||
|
||||
public class LeaderboardContext {
|
||||
|
||||
private final Event event;
|
||||
@SuppressWarnings("unused")
|
||||
private final LeaderboardGroup leaderboardGroup;
|
||||
private final Leaderboard leaderboard;
|
||||
|
||||
public LeaderboardContext(Event event, LeaderboardGroup leaderboardGroup, Leaderboard leaderboard) {
|
||||
this.event = event;
|
||||
this.leaderboardGroup = leaderboardGroup;
|
||||
this.leaderboard = leaderboard;
|
||||
}
|
||||
|
||||
public void forRaces(DispatchContext context, RaceCallback callback) {
|
||||
for(RaceColumn raceColumn : leaderboard.getRaceColumns()) {
|
||||
for(Fleet fleet : raceColumn.getFleets()) {
|
||||
callback.doForRace(new RaceContext(event, leaderboard, raceColumn, fleet, context.getRacingEventService()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package com.sap.sailing.gwt.ui.shared.eventview;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.DTO;
|
||||
|
||||
public class RegattaReferenceDTO implements IsSerializable, Comparable<RegattaReferenceDTO> {
|
||||
public class RegattaReferenceDTO implements DTO, Comparable<RegattaReferenceDTO> {
|
||||
private String id;
|
||||
private String displayName;
|
||||
|
||||
|
||||
Reference in new issue
Block a user