mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-11 06:40:53 +00:00
let RecordCompetitorGPSFix only transmit competitor ID instead of full competitor, reducing message size for mass data
This commit is contained in:
1 parent
5410a6e871
commit
86d4bdea46
4 files changed
+20
-10
No files matched your search
@@ -1,5 +1,7 @@
|
||||
package com.sap.sailing.domain.base;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sap.sailing.domain.common.WithID;
|
||||
import com.sap.sse.common.Named;
|
||||
|
||||
@@ -21,4 +23,6 @@ public interface RaceDefinition extends Named, WithID {
|
||||
Course getCourse();
|
||||
|
||||
Iterable<Competitor> getCompetitors();
|
||||
|
||||
Competitor getCompetitorById(Serializable competitorID);
|
||||
}
|
||||
+10
-7
@@ -1,8 +1,7 @@
|
||||
package com.sap.sailing.domain.base.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
@@ -13,7 +12,7 @@ import com.sap.sailing.domain.common.impl.NamedImpl;
|
||||
public class RaceDefinitionImpl extends NamedImpl implements RaceDefinition {
|
||||
private static final long serialVersionUID = -1900955198751393727L;
|
||||
private final Course course;
|
||||
private final Iterable<Competitor> competitors;
|
||||
private final LinkedHashMap<Serializable, Competitor> competitorsById;
|
||||
private final BoatClass boatClass;
|
||||
private final Serializable id;
|
||||
|
||||
@@ -26,11 +25,10 @@ public class RaceDefinitionImpl extends NamedImpl implements RaceDefinition {
|
||||
assert name != null;
|
||||
|
||||
this.course = course;
|
||||
Set<Competitor> competitorsAsLinkedHashSet = new LinkedHashSet<Competitor>();
|
||||
this.competitorsById = new LinkedHashMap<>();
|
||||
for (Competitor competitor : competitors) {
|
||||
competitorsAsLinkedHashSet.add(competitor);
|
||||
competitorsById.put(competitor.getId(), competitor);
|
||||
}
|
||||
this.competitors = competitorsAsLinkedHashSet;
|
||||
this.boatClass = boatClass;
|
||||
this.id = id;
|
||||
}
|
||||
@@ -47,7 +45,12 @@ public class RaceDefinitionImpl extends NamedImpl implements RaceDefinition {
|
||||
|
||||
@Override
|
||||
public Iterable<Competitor> getCompetitors() {
|
||||
return competitors;
|
||||
return competitorsById.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Competitor getCompetitorById(Serializable competitorID) {
|
||||
return competitorsById.get(competitorID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -234,7 +234,7 @@ public class ReplicationPanel extends FlowPanel {
|
||||
i++;
|
||||
registeredReplicas.insertRow(i);
|
||||
registeredReplicas.setWidget(i, 1, new Label(stringMessages.totalSize()));
|
||||
registeredReplicas.setWidget(i, 2, new Label(""+replica.getNumberOfBytesSent()+"b ("+replica.getNumberOfBytesSent()/1000.0+"kB)"));
|
||||
registeredReplicas.setWidget(i, 2, new Label(""+replica.getNumberOfBytesSent()+"B ("+replica.getNumberOfBytesSent()/1024.0/1024.0+"MB)"));
|
||||
i++;
|
||||
for (Map.Entry<String, Integer> e : replica.getOperationCountByOperationClassName().entrySet()) {
|
||||
registeredReplicas.insertRow(i);
|
||||
|
||||
+5
-2
@@ -1,5 +1,7 @@
|
||||
package com.sap.sailing.server.operationaltransformation;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.common.RegattaAndRaceIdentifier;
|
||||
import com.sap.sailing.domain.tracking.DynamicTrackedRace;
|
||||
@@ -9,12 +11,12 @@ import com.sap.sailing.server.RacingEventServiceOperation;
|
||||
|
||||
public class RecordCompetitorGPSFix extends AbstractRaceOperation<Void> {
|
||||
private static final long serialVersionUID = 5847067037829132465L;
|
||||
private final Competitor competitor;
|
||||
private final Serializable competitorID;
|
||||
private final GPSFixMoving gpsFix;
|
||||
|
||||
public RecordCompetitorGPSFix(RegattaAndRaceIdentifier raceIdentifier, Competitor competitor, GPSFixMoving gpsFix) {
|
||||
super(raceIdentifier);
|
||||
this.competitor = competitor;
|
||||
this.competitorID = competitor.getId();
|
||||
this.gpsFix = gpsFix;
|
||||
}
|
||||
|
||||
@@ -30,6 +32,7 @@ public class RecordCompetitorGPSFix extends AbstractRaceOperation<Void> {
|
||||
@Override
|
||||
public Void internalApplyTo(RacingEventService toState) throws Exception {
|
||||
DynamicTrackedRace trackedRace = (DynamicTrackedRace) toState.getTrackedRace(getRaceIdentifier());
|
||||
Competitor competitor = trackedRace.getRace().getCompetitorById(competitorID);
|
||||
trackedRace.recordFix(competitor, gpsFix);
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user