Class ServiceCalendarMergeStrategy
java.lang.Object
org.onebusaway.gtfs_merge.strategies.AbstractEntityMergeStrategy
org.onebusaway.gtfs_merge.strategies.AbstractCollectionEntityMergeStrategy<org.onebusaway.gtfs.model.AgencyAndId>
org.onebusaway.gtfs_merge.strategies.ServiceCalendarMergeStrategy
- All Implemented Interfaces:
EntityMergeStrategy
public class ServiceCalendarMergeStrategy
extends AbstractCollectionEntityMergeStrategy<org.onebusaway.gtfs.model.AgencyAndId>
Entity merge strategy for handling
ServiceCalendar and ServiceCalendarDate
entities. We merge them at the same time since they are both part of a larger entity collection
identified by a single service_id identifier.- Author:
- bdferris
-
Field Summary
Fields inherited from class org.onebusaway.gtfs_merge.strategies.AbstractEntityMergeStrategy
_duplicateDetectionStrategy, _logDuplicatesStrategy, _minElementDuplicateScoreForFuzzyMatch, _minElementsDuplicateScoreForAutoDetect, _minElementsInCommonScoreForAutoDetect -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidgetEntityTypes(Collection<Class<?>> entityTypes) Determine the list of entity types handled by this merge strategy.protected Collection<org.onebusaway.gtfs.model.AgencyAndId> getKeys(org.onebusaway.gtfs.services.GtfsRelationalDao dao) An entity-specific method to determine the set of unique identifiers used by collection entities in the specified GTFS feed.protected voidrenameKey(GtfsMergeContext context, org.onebusaway.gtfs.model.AgencyAndId oldId, org.onebusaway.gtfs.model.AgencyAndId newId) Replaces all references to the specified old service_id with the new service_id for allServiceCalendar,ServiceCalendarDate, andTripentities in the source feed.protected voidsaveElementsForKey(GtfsMergeContext context, org.onebusaway.gtfs.model.AgencyAndId serviceId) Writes allServiceCalendarandServiceCalendarDateentities with the specifiedservice_idto the merged output feed.protected doublescoreDuplicateKey(GtfsMergeContext context, org.onebusaway.gtfs.model.AgencyAndId key) We consider two service calendars to be duplicates if they share a lot of dates in common.Methods inherited from class org.onebusaway.gtfs_merge.strategies.AbstractCollectionEntityMergeStrategy
getDescription, getRawKey, merge, pickBestDuplicateDetectionStrategyMethods inherited from class org.onebusaway.gtfs_merge.strategies.AbstractEntityMergeStrategy
determineDuplicateDetectionStrategy, getDuplicateRenamingStrategy, setDuplicateDetectionStrategy, setDuplicateRenamingStrategy, setLogDuplicatesStrategy
-
Constructor Details
-
ServiceCalendarMergeStrategy
public ServiceCalendarMergeStrategy()
-
-
Method Details
-
getEntityTypes
Description copied from interface:EntityMergeStrategyDetermine the list of entity types handled by this merge strategy.- Parameters:
entityTypes- the handled types should be added to this output collection.
-
getKeys
protected Collection<org.onebusaway.gtfs.model.AgencyAndId> getKeys(org.onebusaway.gtfs.services.GtfsRelationalDao dao) Description copied from class:AbstractCollectionEntityMergeStrategyAn entity-specific method to determine the set of unique identifiers used by collection entities in the specified GTFS feed.- Specified by:
getKeysin classAbstractCollectionEntityMergeStrategy<org.onebusaway.gtfs.model.AgencyAndId>- Parameters:
dao-- Returns:
- the set of unique identifiers
-
scoreDuplicateKey
protected double scoreDuplicateKey(GtfsMergeContext context, org.onebusaway.gtfs.model.AgencyAndId key) We consider two service calendars to be duplicates if they share a lot of dates in common.This doesn't actually do so well when merging two feeds with different service calendars (eg. before and after a schedule shakeup), which is a trickier problem to solve.
- Specified by:
scoreDuplicateKeyin classAbstractCollectionEntityMergeStrategy<org.onebusaway.gtfs.model.AgencyAndId>- Parameters:
context-key-- Returns:
-
renameKey
protected void renameKey(GtfsMergeContext context, org.onebusaway.gtfs.model.AgencyAndId oldId, org.onebusaway.gtfs.model.AgencyAndId newId) Replaces all references to the specified old service_id with the new service_id for allServiceCalendar,ServiceCalendarDate, andTripentities in the source feed.- Specified by:
renameKeyin classAbstractCollectionEntityMergeStrategy<org.onebusaway.gtfs.model.AgencyAndId>- Parameters:
context-oldId- the original id in the source input feednewId- the new id, which replaces the old in the source input feed
-
saveElementsForKey
protected void saveElementsForKey(GtfsMergeContext context, org.onebusaway.gtfs.model.AgencyAndId serviceId) Writes allServiceCalendarandServiceCalendarDateentities with the specifiedservice_idto the merged output feed.- Specified by:
saveElementsForKeyin classAbstractCollectionEntityMergeStrategy<org.onebusaway.gtfs.model.AgencyAndId>- Parameters:
context-serviceId- the identifier for the entity collection to save
-