use of org.onebusaway.transit_data_federation.services.realtime.BlockLocationListener in project onebusaway-application-modules by camsys.
the class BlockLocationServiceImpl method putBlockLocationRecord.
/**
* We add the {@link BlockInstance} to the local cache and persist it to
* a back-end data-store if necessary
*
* @param scheduledBlockLocation TODO
* @param samples
*/
private void putBlockLocationRecord(BlockInstance blockInstance, VehicleLocationRecord record, ScheduledBlockLocation scheduledBlockLocation, ScheduleDeviationSamples samples) {
// Cache the result
VehicleLocationCacheElements elements = _cache.addRecord(blockInstance, record, scheduledBlockLocation, samples);
if (!CollectionsLibrary.isEmpty(_blockLocationListeners)) {
/**
* We only fill in the block location if we have listeners
*/
BlockLocation location = getBlockLocation(blockInstance, elements, scheduledBlockLocation, record.getTimeOfRecord());
if (location != null) {
for (BlockLocationListener listener : _blockLocationListeners) {
listener.handleBlockLocation(location);
}
}
}
if (_persistBlockLocationRecords) {
List<BlockLocationRecord> blockLocationRecords = getVehicleLocationRecordAsBlockLocationRecord(blockInstance, record, scheduledBlockLocation);
addPredictionToPersistenceQueue(blockLocationRecords);
}
}
Aggregations