improved anniversary documentation

This commit is contained in:
Kai Boernert committed 2017-08-17 16:19:31 +02:00
1 parent 61d779c0da
commit 247980770e
3 files changed
+18 -7

No files matched your search

@@ -16,6 +16,11 @@ import com.sap.sailing.domain.common.RegattaAndRaceIdentifier;
import com.sap.sailing.server.RacingEventService;
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 {
private static final Logger logger = Logger.getLogger(AnniversaryCalculationScheduler.class.getName());
private static final long INITIAL_DELAY = 1000;
@@ -26,17 +31,20 @@ public class AnniversaryCalculationScheduler implements Runnable {
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);
/**
* 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);
}
public AnniversaryCalculationScheduler(RacingEventServiceImpl racingEventService, ScheduledExecutorService scheduledExecutorService) {
public AnniversaryCalculationScheduler(RacingEventServiceImpl racingEventService,
ScheduledExecutorService scheduledExecutorService) {
this.racingEventService = racingEventService;
listeners = new CopyOnWriteArraySet<>();
scheduledExecutorService.scheduleWithFixedDelay(this, INITIAL_DELAY, DELAY, TimeUnit.MILLISECONDS);
@@ -58,7 +66,7 @@ public class AnniversaryCalculationScheduler implements Runnable {
if (racingEventService == null || listeners.isEmpty()) {
return;
}
Map<RegattaAndRaceIdentifier,SimpleRaceInfo> store = new HashMap<>();
Map<RegattaAndRaceIdentifier, SimpleRaceInfo> store = new HashMap<>();
store.putAll(racingEventService.getRemoteRaceList());
store.putAll(racingEventService.getLocalRaceList());
store = Collections.unmodifiableMap(store);
@@ -72,7 +80,7 @@ public class AnniversaryCalculationScheduler implements Runnable {
}
/**
* retrieves for a given RegattaAndRaceIdentifier a DetailedRaceInfo
* retrieves for a given RegattaAndRaceIdentifier a DetailedRaceInfo
*/
public DetailedRaceInfo getFullAnniversaryData(RegattaAndRaceIdentifier regattaNameAndRaceName) {
return racingEventService.getFullDetailsForRaceCascading(regattaNameAndRaceName);
@@ -32,6 +32,7 @@ public class AnniversaryDeterminator implements ChangeListener {
}
public AnniversaryDeterminator(CachedOsgiTypeBasedServiceFinderFactory serviceFinderFactory,AnniversaryChecker... checkerToUse) {
knownAnniversaries = new ConcurrentHashMap<>();
mongoObjectFactory = PersistenceFactory.INSTANCE.getDefaultMongoObjectFactory(serviceFinderFactory);
try {
knownAnniversaries.putAll(mongoObjectFactory.getAnniversaryData());
@@ -42,7 +43,6 @@ public class AnniversaryDeterminator implements ChangeListener {
for(AnniversaryChecker toAdd:checkerToUse){
checkers.add(toAdd);
}
knownAnniversaries = new ConcurrentHashMap<>();
}
@Override
@@ -7,8 +7,11 @@ import com.sap.sailing.domain.anniversary.SimpleRaceInfo;
import com.sap.sailing.server.anniversary.AnniversaryDeterminator.AnniversaryChecker;
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 {
private final static int[] ANNIVERSARIES = new int[] { 10, 25, 50, 75 };
private final static int[] ANNIVERSARIES = new int[] { 10000, 25000, 50000, 75000 };
@Override
public List<Pair<Integer, SimpleRaceInfo>> determineAnniversaries(List<SimpleRaceInfo> raceinfos) {