mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-11 06:40:53 +00:00
added a method in the SailingService to read all events from all registered sailing servers for the new homepage
This commit is contained in:
1 parent
4d1658f474
commit
57f5698712
6 files changed
+61
-11
No files matched your search
+2
@@ -93,6 +93,8 @@ public interface SailingService extends RemoteService {
|
||||
|
||||
List<EventDTO> getEvents();
|
||||
|
||||
List<SailingServerDTO> getPublicEventsOfAllSailingServers();
|
||||
|
||||
Pair<String, List<TracTracRaceRecordDTO>> listTracTracRacesInEvent(String eventJsonURL, boolean listHiddenRaces) throws Exception;
|
||||
|
||||
void trackWithTracTrac(RegattaIdentifier regattaToAddTo, Iterable<TracTracRaceRecordDTO> rrs, String liveURI,
|
||||
|
||||
+3
-1
@@ -323,6 +323,8 @@ public interface SailingServiceAsync {
|
||||
|
||||
void getEvents(AsyncCallback<List<EventDTO>> callback);
|
||||
|
||||
void getPublicEventsOfAllSailingServers(AsyncCallback<List<SailingServerDTO>> callback);
|
||||
|
||||
/**
|
||||
* Creates a {@link EventDTO} for the {@link com.sap.sailing.domain.base.Event} with the name <code>eventName</code>, which contains the
|
||||
* name, the description and a list with {@link RegattaDTO RegattaDTOs} contained in the event.<br />
|
||||
@@ -587,5 +589,5 @@ public interface SailingServiceAsync {
|
||||
AsyncCallback<Void> callback);
|
||||
|
||||
void copyCourseAndCompetitorsToOtherRaceLogs(Triple<String, String, String> raceLogFrom,
|
||||
Set<Triple<String, String, String>> raceLogsTo, AsyncCallback<Void> callback);
|
||||
Set<Triple<String, String, String>> raceLogsTo, AsyncCallback<Void> callback);
|
||||
}
|
||||
+28
@@ -61,6 +61,7 @@ import com.sap.sailing.domain.base.Course;
|
||||
import com.sap.sailing.domain.base.CourseArea;
|
||||
import com.sap.sailing.domain.base.CourseBase;
|
||||
import com.sap.sailing.domain.base.Event;
|
||||
import com.sap.sailing.domain.base.EventBase;
|
||||
import com.sap.sailing.domain.base.Fleet;
|
||||
import com.sap.sailing.domain.base.Mark;
|
||||
import com.sap.sailing.domain.base.Nationality;
|
||||
@@ -2953,6 +2954,22 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SailingServerDTO> getPublicEventsOfAllSailingServers() {
|
||||
List<SailingServerDTO> result = new ArrayList<SailingServerDTO>();
|
||||
for(Entry<SailingServer, List<EventBase>> serverAndEventsEntry: getService().getPublicEventsOfAllSailingServers().entrySet()) {
|
||||
SailingServer server = serverAndEventsEntry.getKey();
|
||||
List<EventDTO> eventDTOs = new ArrayList<EventDTO>();
|
||||
for (EventBase event : serverAndEventsEntry.getValue()) {
|
||||
EventDTO eventDTO = convertToEventDTO(event);
|
||||
eventDTOs.add(eventDTO);
|
||||
}
|
||||
SailingServerDTO sailingServerDTO = new SailingServerDTO(server.getName(), server.getURL().toExternalForm(), eventDTOs);
|
||||
result.add(sailingServerDTO);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEvent(UUID eventId, String eventName, Date startDate, Date endDate, VenueDTO venue, boolean isPublic, List<String> regattaNames) {
|
||||
TimePoint startTimePoint = startDate != null ? new MillisecondsTimePoint(startDate) : null;
|
||||
@@ -3017,6 +3034,17 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
return result;
|
||||
}
|
||||
|
||||
private EventDTO convertToEventDTO(EventBase event) {
|
||||
EventDTO eventDTO = new EventDTO(event.getName());
|
||||
eventDTO.venue = new VenueDTO();
|
||||
eventDTO.venue.setName(event.getVenue() != null ? event.getVenue().getName() : null);
|
||||
eventDTO.startDate = event.getStartDate() != null ? event.getStartDate().asDate() : null;
|
||||
eventDTO.endDate = event.getStartDate() != null ? event.getEndDate().asDate() : null;
|
||||
eventDTO.isPublic = event.isPublic();
|
||||
eventDTO.id = (UUID) event.getId();
|
||||
return eventDTO;
|
||||
}
|
||||
|
||||
private EventDTO convertToEventDTO(Event event) {
|
||||
EventDTO eventDTO = new EventDTO(event.getName());
|
||||
eventDTO.venue = new VenueDTO();
|
||||
|
||||
+15
-1
@@ -1,22 +1,36 @@
|
||||
package com.sap.sailing.gwt.ui.shared;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
import com.sap.sailing.domain.common.dto.NamedDTO;
|
||||
|
||||
public class SailingServerDTO extends NamedDTO implements IsSerializable {
|
||||
private static final long serialVersionUID = -4209262742778693873L;
|
||||
private String url;
|
||||
|
||||
private List<EventDTO> events;
|
||||
|
||||
// for GWT
|
||||
SailingServerDTO() {}
|
||||
|
||||
public SailingServerDTO(String name, String url) {
|
||||
super(name);
|
||||
this.url = url;
|
||||
this.events = null;
|
||||
}
|
||||
|
||||
public SailingServerDTO(String name, String url, List<EventDTO> events) {
|
||||
super(name);
|
||||
this.url = url;
|
||||
this.events = events;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public List<EventDTO> getEvents() {
|
||||
return events;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -397,7 +397,7 @@ public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetch
|
||||
* @return a thread-safe copy of the events of from all sailing server instances currently known by the service; it's safe for callers to iterate over
|
||||
* the iterable returned, and no risk of a {@link ConcurrentModificationException} exists
|
||||
*/
|
||||
Iterable<Pair<SailingServer, EventBase>> getEventsFromAllSailingServers();
|
||||
Map<SailingServer, List<EventBase>> getPublicEventsOfAllSailingServers();
|
||||
|
||||
Iterable<SailingServer> getSailingServers();
|
||||
|
||||
|
||||
+12
-8
@@ -199,7 +199,7 @@ public class RacingEventServiceImpl implements RacingEventServiceWithTestSupport
|
||||
/**
|
||||
* Holds the {@link Event} objects for the events of all registerd sailing server instances.
|
||||
*/
|
||||
protected final ConcurrentHashMap<Serializable, Pair<SailingServer, EventBase>> cachedEventsOfAllSailingServerInstancesById;
|
||||
protected final ConcurrentHashMap<SailingServer, List<EventBase>> cachedEventsOfAllSailingServerInstances;
|
||||
|
||||
/**
|
||||
* Holds the {@link Regatta} objects for those races registered with this service. Note that there may be
|
||||
@@ -373,7 +373,7 @@ public class RacingEventServiceImpl implements RacingEventServiceWithTestSupport
|
||||
|
||||
regattasByName = new ConcurrentHashMap<String, Regatta>();
|
||||
eventsById = new ConcurrentHashMap<Serializable, Event>();
|
||||
cachedEventsOfAllSailingServerInstancesById = new ConcurrentHashMap<Serializable, Pair<SailingServer, EventBase>>();
|
||||
cachedEventsOfAllSailingServerInstances = new ConcurrentHashMap<SailingServer, List<EventBase>>();
|
||||
regattaTrackingCache = new ConcurrentHashMap<>();
|
||||
raceTrackersByRegatta = new ConcurrentHashMap<>();
|
||||
raceTrackersByID = new ConcurrentHashMap<>();
|
||||
@@ -508,12 +508,16 @@ public class RacingEventServiceImpl implements RacingEventServiceWithTestSupport
|
||||
} catch (InterruptedException e1) {
|
||||
}
|
||||
|
||||
synchronized (cachedEventsOfAllSailingServerInstancesById) {
|
||||
cachedEventsOfAllSailingServerInstancesById.clear();
|
||||
synchronized (cachedEventsOfAllSailingServerInstances) {
|
||||
cachedEventsOfAllSailingServerInstances.clear();
|
||||
|
||||
for (Pair<SailingServer, EventBase> serverAndEventPair : allEvents) {
|
||||
if (serverAndEventPair.getB().getId() != null)
|
||||
cachedEventsOfAllSailingServerInstancesById.put(serverAndEventPair.getB().getId(), serverAndEventPair);
|
||||
List<EventBase> events = cachedEventsOfAllSailingServerInstances.get(serverAndEventPair.getA());
|
||||
if(events == null) {
|
||||
events = new ArrayList<EventBase>();
|
||||
cachedEventsOfAllSailingServerInstances.put(serverAndEventPair.getA(), events);
|
||||
}
|
||||
events.add(serverAndEventPair.getB());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -863,8 +867,8 @@ public class RacingEventServiceImpl implements RacingEventServiceWithTestSupport
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Pair<SailingServer, EventBase>> getEventsFromAllSailingServers() {
|
||||
return Collections.unmodifiableCollection(new ArrayList<Pair<SailingServer, EventBase>>(cachedEventsOfAllSailingServerInstancesById.values()));
|
||||
public Map<SailingServer, List<EventBase>> getPublicEventsOfAllSailingServers() {
|
||||
return Collections.unmodifiableMap(new HashMap<SailingServer, List<EventBase>>(cachedEventsOfAllSailingServerInstances));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user