Class GtfsMergeContext

java.lang.Object
org.onebusaway.gtfs_merge.GtfsMergeContext

public class GtfsMergeContext extends Object
Manages state for the current merge operation, which is specific to particular feed and GTFS entity type.
Author:
bdferris
  • Constructor Details

    • GtfsMergeContext

      public GtfsMergeContext(org.onebusaway.gtfs.services.GtfsRelationalDao source, org.onebusaway.gtfs.services.GtfsMutableRelationalDao target, String prefix, Map<String,Object> entityByRawId)
  • Method Details

    • getSource

      public org.onebusaway.gtfs.services.GtfsRelationalDao getSource()
      Returns:
      the source feed GTFS DAO from which entities should be read.
    • getTarget

      public org.onebusaway.gtfs.services.GtfsMutableRelationalDao getTarget()
      Returns:
      the target feed GTFS DAO where merged entities should be written.
    • getPrefix

      public String getPrefix()
      Returns:
      a unique prefix that can be used to make duplicate or overlapping ids unique during the current merge operation.
    • putEntityWithRawId

      public void putEntityWithRawId(String rawId, Object entity)
      Indicate that an entity with the specified raw GTFS id as been added to the merged output GTFS feed. Since typically only a single entity can be added to a feed for a particular id, this method can be used in combination with getEntityForRawId(String) to detect id and entity collisions across feeds.
      Parameters:
      rawId -
      entity -
    • getEntityForRawId

      public Object getEntityForRawId(String rawId)
      Find an entity registered with putEntityWithRawId(String, Object) for the current entity type across feeds merged so far, including the current feed. Can be used to detect id and entity collisions across feeds.
      Parameters:
      rawId -
      Returns:
      an entity associated with the specified raw GTFS id for the current entity type, or null if no entity with the specified id exists.
    • isEntityJustAddedWithRawId

      public boolean isEntityJustAddedWithRawId(String rawId)
      It can be useful to know if an entity returned by getEntityForRawId(String) was added from the current source feed or from some previous feed.
      Parameters:
      rawId -
      Returns:
      true if an entity with the specified id was added from the feed currently being processed with a call to putEntityWithRawId(String, Object).
    • getNextSequenceCounter

      public int getNextSequenceCounter()
      Returns:
      a unique integer for the current merge operation.
    • getResolvedDuplicateDetectionStrategy

      public EDuplicateDetectionStrategy getResolvedDuplicateDetectionStrategy()
      Returns:
      the duplicate detection strategy that has been chosen for the current entity type.
    • setResolvedDuplicateDetectionStrategy

      public void setResolvedDuplicateDetectionStrategy(EDuplicateDetectionStrategy resolvedDuplicateDetectionStrategy)
      Set the duplicate detection strategy that has been chosen for this entity type. A strategy might have been specified directly by the user or we might have auto-detected the best strategy based on available data.
      Parameters:
      resolvedDuplicateDetectionStrategy -