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
  • Constructor Details

    • ServiceCalendarMergeStrategy

      public ServiceCalendarMergeStrategy()
  • Method Details

    • getEntityTypes

      public void getEntityTypes(Collection<Class<?>> entityTypes)
      Description copied from interface: EntityMergeStrategy
      Determine 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: AbstractCollectionEntityMergeStrategy
      An entity-specific method to determine the set of unique identifiers used by collection entities in the specified GTFS feed.
      Specified by:
      getKeys in class AbstractCollectionEntityMergeStrategy<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:
      scoreDuplicateKey in class AbstractCollectionEntityMergeStrategy<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 all ServiceCalendar, ServiceCalendarDate, and Trip entities in the source feed.
      Specified by:
      renameKey in class AbstractCollectionEntityMergeStrategy<org.onebusaway.gtfs.model.AgencyAndId>
      Parameters:
      context -
      oldId - the original id in the source input feed
      newId - 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 all ServiceCalendar and ServiceCalendarDate entities with the specified service_id to the merged output feed.
      Specified by:
      saveElementsForKey in class AbstractCollectionEntityMergeStrategy<org.onebusaway.gtfs.model.AgencyAndId>
      Parameters:
      context -
      serviceId - the identifier for the entity collection to save