mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-06 20:33:54 +00:00
use pass id of last event in RaceLog for getCurrrentPassId()
This commit is contained in:
1 parent
101dba0d82
commit
ee7ebe1261
1 file changed
+2
-23
+2
-23
@@ -2,7 +2,6 @@ package com.sap.sailing.domain.abstractlog.race.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.NavigableSet;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLogEventAuthor;
|
||||
import com.sap.sailing.domain.abstractlog.impl.AbstractLogImpl;
|
||||
@@ -29,44 +28,24 @@ import com.sap.sailing.domain.tracking.impl.TrackImpl;
|
||||
*
|
||||
*/
|
||||
public class RaceLogImpl extends AbstractLogImpl<RaceLogEvent, RaceLogEventVisitor> implements RaceLog {
|
||||
private final static Logger logger = Logger.getLogger(RaceLogImpl.class.getName());
|
||||
|
||||
private static final long serialVersionUID = 98032278604708475L;
|
||||
private int currentPassId;
|
||||
|
||||
public RaceLogImpl(Serializable identifier) {
|
||||
super(identifier, new RaceLogEventComparator());
|
||||
this.currentPassId = DefaultPassId;
|
||||
}
|
||||
|
||||
public RaceLogImpl(String nameForReadWriteLock, Serializable identifier) {
|
||||
super(nameForReadWriteLock, identifier, new RaceLogEventComparator());
|
||||
this.currentPassId = DefaultPassId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentPassId() {
|
||||
return currentPassId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a new active pass id. Ignored if new and current are equal.
|
||||
*
|
||||
* @param newPassId
|
||||
* to be set.
|
||||
*/
|
||||
public void setCurrentPassId(int newPassId) {
|
||||
if (newPassId != this.currentPassId) {
|
||||
logger.finer(String.format("Changing pass id to %d", newPassId));
|
||||
this.currentPassId = newPassId;
|
||||
}
|
||||
//return pass id of last event, as pass is the top-level sorting criterion in RaceLogeventComparator
|
||||
return getUnrevokedEvents().last().getPassId();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSuccessfulAdd(RaceLogEvent event, boolean notifyListeners) {
|
||||
// FIXME with out-of-order delivery would destroy currentPassId; need to check at least the createdAt time
|
||||
// point
|
||||
setCurrentPassId(Math.max(event.getPassId(), this.currentPassId));
|
||||
super.onSuccessfulAdd(event, notifyListeners);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user