mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-11 14:50:56 +00:00
added some methods to manage events and regattas as part of the events
This commit is contained in:
1 parent
a22ed4d592
commit
7612fbdec5
21 files changed
+779
-44
No files matched your search
@@ -65,8 +65,6 @@ import com.sap.sailing.expeditionconnector.ExpeditionListener;
|
||||
*
|
||||
*/
|
||||
public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetcher, RaceFetcher {
|
||||
Iterable<Event> getAllEvents();
|
||||
|
||||
/**
|
||||
* @return a thread-safe copy of the regattas currently known by the service; it's safe for callers to iterate over
|
||||
* the iterable returned, and no risk of a {@link ConcurrentModificationException} exists
|
||||
@@ -408,4 +406,25 @@ public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetch
|
||||
* <b>Caution:</b> All relevant contents of this service instance will be replaced by the stream contents.
|
||||
*/
|
||||
void initiallyFillFrom(ObjectInputStream ois) throws IOException, ClassNotFoundException;
|
||||
|
||||
|
||||
/**
|
||||
* @return a thread-safe copy of the events 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<Event> getAllEvents();
|
||||
|
||||
/**
|
||||
* Creates a new event with the name <code>eventName</code>, the description <code>desciption</code> and the
|
||||
* regattas with the names in <code>regattaNames</code> and saves it in the database.
|
||||
*
|
||||
* @param eventName
|
||||
* The name of the new event
|
||||
* @param venue
|
||||
* The venue of the new event
|
||||
* @param regattaNames
|
||||
* The names of the regattas contained in the new event.<br />
|
||||
* @return The new event
|
||||
*/
|
||||
Event addEvent(String eventName, String venue, List<String> regattaNames);
|
||||
}
|
||||
+23
-2
@@ -36,6 +36,7 @@ import com.sap.sailing.domain.base.RaceDefinition;
|
||||
import com.sap.sailing.domain.base.Regatta;
|
||||
import com.sap.sailing.domain.base.RegattaListener;
|
||||
import com.sap.sailing.domain.base.Waypoint;
|
||||
import com.sap.sailing.domain.base.impl.EventImpl;
|
||||
import com.sap.sailing.domain.base.impl.RegattaImpl;
|
||||
import com.sap.sailing.domain.common.DefaultLeaderboardName;
|
||||
import com.sap.sailing.domain.common.RaceIdentifier;
|
||||
@@ -193,14 +194,21 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
|
||||
// This is more for debugging purposes than for anything else.
|
||||
addFlexibleLeaderboard(DefaultLeaderboardName.DEFAULT_LEADERBOARD_NAME, new int[] { 5, 8 });
|
||||
loadStoredLeaderboardsAndGroups();
|
||||
loadStoredEvents();
|
||||
}
|
||||
|
||||
public RacingEventServiceImpl(MongoDBService mongoDBService) {
|
||||
this(MongoFactory.INSTANCE.getDomainObjectFactory(mongoDBService), MongoFactory.INSTANCE.getMongoObjectFactory(mongoDBService));
|
||||
}
|
||||
|
||||
|
||||
private void loadStoredEvents() {
|
||||
for(Event event: domainObjectFactory.loadAllEvents()) {
|
||||
eventsByName.put(event.getName(), event);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadStoredLeaderboardsAndGroups() {
|
||||
// Loading all leaderboard groups and putting the contained leaderboards
|
||||
// Loading all leaderboard groups and the contained leaderboards
|
||||
for (LeaderboardGroup leaderboardGroup : domainObjectFactory.getAllLeaderboardGroups()) {
|
||||
leaderboardGroupsByName.put(leaderboardGroup.getName(), leaderboardGroup);
|
||||
for (Leaderboard leaderboard : leaderboardGroup.getLeaderboards()) {
|
||||
@@ -1231,4 +1239,17 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
|
||||
this.delayToLiveInMillis = delayToLiveInMillis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Event addEvent(String eventName, String venue, List<String> regattaNames) {
|
||||
Event result = new EventImpl(eventName, venue);
|
||||
synchronized (eventsByName) {
|
||||
if (eventsByName.containsKey(eventName)) {
|
||||
throw new IllegalArgumentException("Event with name " + eventName + " already exists");
|
||||
}
|
||||
eventsByName.put(eventName, result);
|
||||
}
|
||||
mongoObjectFactory.storeEvent(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.sap.sailing.server.operationaltransformation;
|
||||
|
||||
public abstract class AbstractEventOperation<ResultType> extends AbstractRacingEventServiceOperation<ResultType> {
|
||||
private static final long serialVersionUID = 1200611694004927369L;
|
||||
private final String eventName;
|
||||
|
||||
public AbstractEventOperation(String eventName) {
|
||||
super();
|
||||
this.eventName = eventName;
|
||||
}
|
||||
|
||||
protected String getEventName() {
|
||||
return eventName;
|
||||
}
|
||||
|
||||
protected boolean affectsSameEvent(AbstractEventOperation<?> other) {
|
||||
return getEventName().equals(other.getEventName());
|
||||
}
|
||||
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.sap.sailing.server.operationaltransformation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.base.Event;
|
||||
import com.sap.sailing.server.RacingEventService;
|
||||
import com.sap.sailing.server.RacingEventServiceOperation;
|
||||
|
||||
public class CreateEvent extends AbstractEventOperation<Event> {
|
||||
private static final long serialVersionUID = 308389324918359960L;
|
||||
private final String venue;
|
||||
private final List<String> regattaNames;
|
||||
|
||||
public CreateEvent(String eventName, String venue, List<String> regattaNames) {
|
||||
super(eventName);
|
||||
this.venue = venue;
|
||||
this.regattaNames = regattaNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RacingEventServiceOperation<?> transformClientOp(RacingEventServiceOperation<?> serverOp) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RacingEventServiceOperation<?> transformServerOp(RacingEventServiceOperation<?> clientOp) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Event internalApplyTo(RacingEventService toState) {
|
||||
return toState.addEvent(getEventName(), venue, regattaNames);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user