mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-22 12:03:58 +00:00
improved anniversary documentation
This commit is contained in:
1 parent
61d779c0da
commit
247980770e
3 files changed
+16
-5
No files matched your search
+11
-3
@@ -16,6 +16,11 @@ import com.sap.sailing.domain.common.RegattaAndRaceIdentifier;
|
|||||||
import com.sap.sailing.server.RacingEventService;
|
import com.sap.sailing.server.RacingEventService;
|
||||||
import com.sap.sailing.server.impl.RacingEventServiceImpl;
|
import com.sap.sailing.server.impl.RacingEventServiceImpl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is created by the Activator, and periodically collects all known local and remote races, it then calls any
|
||||||
|
* registered ChangeListeners with a map of all races in the form of {@link SimpleRaceInfo} keyed with
|
||||||
|
* {@link RegattaAndRaceIdentifier}
|
||||||
|
*/
|
||||||
public class AnniversaryCalculationScheduler implements Runnable {
|
public class AnniversaryCalculationScheduler implements Runnable {
|
||||||
private static final Logger logger = Logger.getLogger(AnniversaryCalculationScheduler.class.getName());
|
private static final Logger logger = Logger.getLogger(AnniversaryCalculationScheduler.class.getName());
|
||||||
private static final long INITIAL_DELAY = 1000;
|
private static final long INITIAL_DELAY = 1000;
|
||||||
@@ -26,17 +31,20 @@ public class AnniversaryCalculationScheduler implements Runnable {
|
|||||||
|
|
||||||
interface ChangeListener {
|
interface ChangeListener {
|
||||||
/**
|
/**
|
||||||
* If the listener is added to the AnniversaryCalculationScheduler , this is called once a minute, and is given an unsorted list of all races. This list is not modifiable and not threadsafe.
|
* If the listener is added to the AnniversaryCalculationScheduler , this is called once a minute, and is given
|
||||||
|
* an unsorted list of all races. This list is not modifiable and not threadsafe.
|
||||||
*/
|
*/
|
||||||
void uponUpdate(Collection<SimpleRaceInfo> collection);
|
void uponUpdate(Collection<SimpleRaceInfo> collection);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by the AnniversaryCalculationScheduler, when the ChangeListener is added to the AnniversaryCalculationScheduler
|
* Called by the AnniversaryCalculationScheduler, when the ChangeListener is added to the
|
||||||
|
* AnniversaryCalculationScheduler, this allows all ChangeListeners to use getFullAnniversaryData
|
||||||
*/
|
*/
|
||||||
void setAnniversaryCalculator(AnniversaryCalculationScheduler anniversaryCalculator);
|
void setAnniversaryCalculator(AnniversaryCalculationScheduler anniversaryCalculator);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AnniversaryCalculationScheduler(RacingEventServiceImpl racingEventService, ScheduledExecutorService scheduledExecutorService) {
|
public AnniversaryCalculationScheduler(RacingEventServiceImpl racingEventService,
|
||||||
|
ScheduledExecutorService scheduledExecutorService) {
|
||||||
this.racingEventService = racingEventService;
|
this.racingEventService = racingEventService;
|
||||||
listeners = new CopyOnWriteArraySet<>();
|
listeners = new CopyOnWriteArraySet<>();
|
||||||
scheduledExecutorService.scheduleWithFixedDelay(this, INITIAL_DELAY, DELAY, TimeUnit.MILLISECONDS);
|
scheduledExecutorService.scheduleWithFixedDelay(this, INITIAL_DELAY, DELAY, TimeUnit.MILLISECONDS);
|
||||||
|
|||||||
+1
-1
@@ -32,6 +32,7 @@ public class AnniversaryDeterminator implements ChangeListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public AnniversaryDeterminator(CachedOsgiTypeBasedServiceFinderFactory serviceFinderFactory,AnniversaryChecker... checkerToUse) {
|
public AnniversaryDeterminator(CachedOsgiTypeBasedServiceFinderFactory serviceFinderFactory,AnniversaryChecker... checkerToUse) {
|
||||||
|
knownAnniversaries = new ConcurrentHashMap<>();
|
||||||
mongoObjectFactory = PersistenceFactory.INSTANCE.getDefaultMongoObjectFactory(serviceFinderFactory);
|
mongoObjectFactory = PersistenceFactory.INSTANCE.getDefaultMongoObjectFactory(serviceFinderFactory);
|
||||||
try {
|
try {
|
||||||
knownAnniversaries.putAll(mongoObjectFactory.getAnniversaryData());
|
knownAnniversaries.putAll(mongoObjectFactory.getAnniversaryData());
|
||||||
@@ -42,7 +43,6 @@ public class AnniversaryDeterminator implements ChangeListener {
|
|||||||
for(AnniversaryChecker toAdd:checkerToUse){
|
for(AnniversaryChecker toAdd:checkerToUse){
|
||||||
checkers.add(toAdd);
|
checkers.add(toAdd);
|
||||||
}
|
}
|
||||||
knownAnniversaries = new ConcurrentHashMap<>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+4
-1
@@ -7,8 +7,11 @@ import com.sap.sailing.domain.anniversary.SimpleRaceInfo;
|
|||||||
import com.sap.sailing.server.anniversary.AnniversaryDeterminator.AnniversaryChecker;
|
import com.sap.sailing.server.anniversary.AnniversaryDeterminator.AnniversaryChecker;
|
||||||
import com.sap.sse.common.Util.Pair;
|
import com.sap.sse.common.Util.Pair;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This checker adds all races that are the 10kth,25kth,50kth or 75kth or are a factor 10 of one of those.
|
||||||
|
*/
|
||||||
public class QuarterChecker implements AnniversaryChecker {
|
public class QuarterChecker implements AnniversaryChecker {
|
||||||
private final static int[] ANNIVERSARIES = new int[] { 10, 25, 50, 75 };
|
private final static int[] ANNIVERSARIES = new int[] { 10000, 25000, 50000, 75000 };
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Pair<Integer, SimpleRaceInfo>> determineAnniversaries(List<SimpleRaceInfo> raceinfos) {
|
public List<Pair<Integer, SimpleRaceInfo>> determineAnniversaries(List<SimpleRaceInfo> raceinfos) {
|
||||||
|
|||||||
Reference in new issue
Block a user