mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-16 17:21:00 +00:00
Cleans up closing DeviceMappings, warns if mapping is in RaceLog
This commit is contained in:
1 parent
babaa5aafe
commit
47ccb5039d
4 files changed
+41
-20
No files matched your search
+12
@@ -0,0 +1,12 @@
|
||||
package com.sap.sailing.domain.common;
|
||||
|
||||
public class RaceLogEventNotFoundException extends Exception {
|
||||
private static final long serialVersionUID = 4595827888350748956L;
|
||||
|
||||
@SuppressWarnings("unused") // required for some serialization frameworks such as GWT RPC
|
||||
public RaceLogEventNotFoundException() {}
|
||||
|
||||
public RaceLogEventNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
+1
-4
@@ -486,9 +486,6 @@ public interface SailingService extends RemoteService, FileStorageManagementGwtS
|
||||
|
||||
List<String> getDeserializableDeviceIdentifierTypes();
|
||||
|
||||
void closeOpenEndedDeviceMapping(String leaderboardName, String raceColumnName, String fleetName, DeviceMappingDTO mapping,
|
||||
Date closingTimePoint) throws NoCorrespondingServiceRegisteredException, TransformationException;
|
||||
|
||||
/**
|
||||
* Revoke the events in the {@code RaceLog} that are identified by the {@code eventIds}.
|
||||
* This only affects such events that implement {@link Revokable}.
|
||||
@@ -588,7 +585,7 @@ public interface SailingService extends RemoteService, FileStorageManagementGwtS
|
||||
|
||||
void revokeRaceAndRegattaLogEvents(String leaderboardName, List<UUID> eventIds) throws NotRevokableException, DoesNotHaveRegattaLogException;
|
||||
|
||||
void closeOpenEndedDeviceMapping(String leaderboardName, DeviceMappingDTO mappingDto, Date closingTimePoint) throws TransformationException;
|
||||
void closeOpenEndedDeviceMapping(String leaderboardName, DeviceMappingDTO mappingDto, Date closingTimePoint) throws TransformationException, DoesNotHaveRegattaLogException;
|
||||
|
||||
void addDeviceMappingToRegattaLog(String leaderboardName, DeviceMappingDTO dto)
|
||||
throws NoCorrespondingServiceRegisteredException, TransformationException, DoesNotHaveRegattaLogException;
|
||||
|
||||
-3
@@ -646,9 +646,6 @@ public interface SailingServiceAsync extends ServerInfoRetriever, FileStorageMan
|
||||
void getDeviceMappingsFromRaceLog(String leaderboardName, String raceColumnName, String fleetName,
|
||||
AsyncCallback<List<DeviceMappingDTO>> callback);
|
||||
|
||||
void closeOpenEndedDeviceMapping(String leaderboardName, String raceColumnName, String fleetName,
|
||||
DeviceMappingDTO mapping, Date closingTimePoint, AsyncCallback<Void> callback);
|
||||
|
||||
void revokeRaceAndRegattaLogEvents(String leaderboardName, String raceColumnName, String fleetName,
|
||||
List<UUID> eventIds, AsyncCallback<Void> callback);
|
||||
|
||||
|
||||
+28
-13
@@ -52,6 +52,7 @@ import java.util.zip.GZIPInputStream;
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.InvalidSyntaxException;
|
||||
import org.osgi.framework.ServiceReference;
|
||||
@@ -161,6 +162,7 @@ import com.sap.sailing.domain.common.PolarSheetsXYDiagramData;
|
||||
import com.sap.sailing.domain.common.Position;
|
||||
import com.sap.sailing.domain.common.RaceFetcher;
|
||||
import com.sap.sailing.domain.common.RaceIdentifier;
|
||||
import com.sap.sailing.domain.common.RaceLogEventNotFoundException;
|
||||
import com.sap.sailing.domain.common.RankingMetrics;
|
||||
import com.sap.sailing.domain.common.RegattaAndRaceIdentifier;
|
||||
import com.sap.sailing.domain.common.RegattaFetcher;
|
||||
@@ -5270,15 +5272,9 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
throw new RuntimeException("Can only map devices to competitors or marks");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeOpenEndedDeviceMapping(String leaderboardName, String raceColumnName, String fleetName,
|
||||
DeviceMappingDTO mappingDTO, Date closingTimePoint) throws NoCorrespondingServiceRegisteredException, TransformationException {
|
||||
List<AbstractLog<?, ?>> logHierarchy = getLogHierarchy(leaderboardName, raceColumnName, fleetName);
|
||||
closeOpenEndedDeviceMapping(logHierarchy, mappingDTO, closingTimePoint);
|
||||
}
|
||||
|
||||
private void closeOpenEndedDeviceMapping(List<AbstractLog<?, ?>> logHierarchy, DeviceMappingDTO mappingDTO, Date closingTimePoint) throws TransformationException {
|
||||
private void closeOpenEndedDeviceMapping(List<AbstractLog<?, ?>> logHierarchy, DeviceMappingDTO mappingDTO, Date closingTimePoint) throws TransformationException, RaceLogEventNotFoundException {
|
||||
boolean successfullyClosed = false;
|
||||
for (AbstractLog<?, ?> abstractLog : logHierarchy) {
|
||||
//check if abstractLog is the correct log for the closingEvent
|
||||
final AbstractLogEvent<?> event;
|
||||
@@ -5289,6 +5285,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
abstractLog.unlockAfterRead();
|
||||
}
|
||||
if (event != null) {
|
||||
successfullyClosed = true;
|
||||
DeviceMapping<?> mapping = convertToDeviceMapping(mappingDTO);
|
||||
if (abstractLog instanceof RegattaLog) {
|
||||
RegattaLog regattaLog = (RegattaLog) abstractLog;
|
||||
@@ -5309,6 +5306,10 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!successfullyClosed){
|
||||
throw new RaceLogEventNotFoundException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -5766,12 +5767,26 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeOpenEndedDeviceMapping(String leaderboardName, DeviceMappingDTO mappingDTO, Date closingTimePoint) throws TransformationException {
|
||||
List<AbstractLog<?, ?>> logs = getLogHierarchy(leaderboardName);
|
||||
closeOpenEndedDeviceMapping(logs, mappingDTO, closingTimePoint);
|
||||
public void closeOpenEndedDeviceMapping(String leaderboardName, DeviceMappingDTO mappingDTO, Date closingTimePoint) throws TransformationException, DoesNotHaveRegattaLogException {
|
||||
RegattaLog regattaLog = getRegattaLogInternal(leaderboardName);
|
||||
|
||||
List<AbstractLog<?, ?>> logList = new ArrayList<>();
|
||||
logList.add(regattaLog);
|
||||
try {
|
||||
closeOpenEndedDeviceMapping(logList, mappingDTO, closingTimePoint);
|
||||
} catch (RaceLogEventNotFoundException e) {
|
||||
logger.warning("Device Mapping Event couldn't be found on RegattaLog, checking in RaceLog (deprecated)");
|
||||
|
||||
List<AbstractLog<?, ?>> logs = getLogHierarchy(leaderboardName);
|
||||
try {
|
||||
closeOpenEndedDeviceMapping(logs, mappingDTO, closingTimePoint);
|
||||
} catch (RaceLogEventNotFoundException e1) {
|
||||
logger.warning("Device Mapping Event could also not be found in RaceLogs");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets all the logs corresponding to a leaderboard. This includes all the RaceLogs of the leaderBoard's raceColumns
|
||||
* @param leaderboardName
|
||||
|
||||
Reference in new issue
Block a user