fixing bug 2003: after master data import of a leaderboard group, the overall leaderboard must be added to the RacingEventService

This commit is contained in:
Axel Uhl committed 2014-06-16 22:30:02 +02:00
1 parent 8b54330e00
commit 2fcd084f74
5 files changed
+23 -13

No files matched your search

@@ -2,6 +2,7 @@ package com.sap.sailing.domain.base;
import com.sap.sailing.domain.common.RaceIdentifier;
import com.sap.sailing.domain.leaderboard.Leaderboard;
import com.sap.sailing.domain.leaderboard.MetaLeaderboard;
import com.sap.sailing.domain.racelog.RaceLog;
import com.sap.sailing.domain.racelog.RaceLogIdentifier;
import com.sap.sailing.domain.racelog.RaceLogInformation;
@@ -36,10 +37,11 @@ public interface RaceColumn extends Named {
RaceLogInformation getRaceLogInformation();
/**
* Gets the race column's race log associated to the passed fleet.
* Gets the race column's race log associated to the passed fleet. Note that the result may be <code>null</code>
* particularly for columns in a {@link MetaLeaderboard}.
*
* @param fleet
* @return the race log.
* @return the race log or <code>null</code> in case this column belongs to a {@link MetaLeaderboard}
*/
RaceLog getRaceLog(Fleet fleet);
@@ -24,18 +24,15 @@ public class RaceLogDeserializer implements JsonDeserializer<RaceLog> {
public RaceLog deserialize(JSONObject object) throws JsonDeserializationException {
Serializable id = (String)object.get(RaceLogSerializer.FIELD_RACELOG_IDENTIFIER);
RaceLog result = new RaceLogImpl(id);
if (object.get(RaceLogSerializer.FIELD_EVENTS) == null) {
return result;
}
JSONArray events = Helpers.getNestedArraySafe(object, RaceLogSerializer.FIELD_EVENTS);
for (Object eventObject : events) {
JSONObject eventJson = Helpers.toJSONObjectSafe(eventObject);
RaceLogEvent event = elementDeserializer.deserialize(eventJson);
result.add(event);
}
return result;
}
@@ -580,5 +580,10 @@ public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetch
void addEventWithoutReplication(Event event);
/**
* Adds the leaderboard group to this service; if the group has an overall leaderboard, the overall leaderboard
* is added to this service as well. For both, the group and the overall leaderboard, any previously existing
* objects by the same name of that type will be replaced.
*/
void addLeaderboardGroupWithoutReplication(LeaderboardGroup leaderboardGroup);
}
@@ -1901,6 +1901,9 @@ public class RacingEventServiceImpl implements RacingEventServiceWithTestSupport
} finally {
LockUtil.unlockAfterWrite(leaderboardGroupsByNameLock);
}
if (leaderboardGroup.hasOverallLeaderboard()) {
addLeaderboard(leaderboardGroup.getOverallLeaderboard());
}
mongoObjectFactory.storeLeaderboardGroup(leaderboardGroup);
}
@@ -223,15 +223,18 @@ public class ImportMasterDataOperation extends
for (RaceColumn raceColumn : leaderboard.getRaceColumns()) {
for (Fleet fleet : raceColumn.getFleets()) {
RaceLog log = raceColumn.getRaceLog(fleet);
RaceLogIdentifier identifier = raceColumn.getRaceLogIdentifier(fleet);
RaceLogEventVisitor storeVisitor = MongoRaceLogStoreFactory.INSTANCE.getMongoRaceLogStoreVisitor(identifier, mongoObjectFactory);
log.lockForRead();
try {
for (RaceLogEvent event : log.getRawFixes()) {
event.accept(storeVisitor);
if (log != null) {
RaceLogIdentifier identifier = raceColumn.getRaceLogIdentifier(fleet);
RaceLogEventVisitor storeVisitor = MongoRaceLogStoreFactory.INSTANCE.getMongoRaceLogStoreVisitor(
identifier, mongoObjectFactory);
log.lockForRead();
try {
for (RaceLogEvent event : log.getRawFixes()) {
event.accept(storeVisitor);
}
} finally {
log.unlockAfterRead();
}
} finally {
log.unlockAfterRead();
}
}
}