Class AbstractSingleEntityMergeStrategy<T>
java.lang.Object
org.onebusaway.gtfs_merge.strategies.AbstractEntityMergeStrategy
org.onebusaway.gtfs_merge.strategies.AbstractSingleEntityMergeStrategy<T>
- Type Parameters:
T- the type of the GTFS entity that this merge strategy handles
- All Implemented Interfaces:
EntityMergeStrategy
- Direct Known Subclasses:
AbstractIdentifiableSingleEntityMergeStrategy,AbstractNonIdentifiableSingleEntityMergeStrategy
Abstract base class that defines common methods and properties for merging single GTFS entities.
As opposed to collection-like entities (see
AbstractCollectionEntityMergeStrategy, single
entities usually stand alone, with one identifier usually corresponding to a single entity. The
majority of GTFS entities are single entities.
Of course, not all single entities actually have identifiers. For example, entities like
Frequency and Transfer do not have an explicit ids in a GTFS feed.
Non-identifiable entities such as these are handled by the AbstractNonIdentifiableSingleEntityMergeStrategy sub-class. Entities with explicit ids, like
Stop and Trip, are handled by the AbstractIdentifiableSingleEntityMergeStrategy sub-class.
This class contains methods and properties common to both identifiable and non-identifiable single entities.
- Author:
- bdferris
-
Field Summary
FieldsFields inherited from class org.onebusaway.gtfs_merge.strategies.AbstractEntityMergeStrategy
_duplicateDetectionStrategy, _logDuplicatesStrategy, _minElementDuplicateScoreForFuzzyMatch, _minElementsDuplicateScoreForAutoDetect, _minElementsInCommonScoreForAutoDetect -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringvoidgetEntityTypes(Collection<Class<?>> entityTypes) Determine the list of entity types handled by this merge strategy.protected org.onebusaway.gtfs.model.IdentityBean<?> getFuzzyDuplicate(GtfsMergeContext context, org.onebusaway.gtfs.model.IdentityBean<?> entity) UseEDuplicateDetectionStrategy.FUZZYbased duplication-detection to find a duplicate in the output merged feed for the specified entity.protected abstract org.onebusaway.gtfs.model.IdentityBean<?> getIdentityDuplicate(GtfsMergeContext context, org.onebusaway.gtfs.model.IdentityBean<?> entity) UseEDuplicateDetectionStrategy.IDENTITYbased duplication-detection to find a duplicate in the output merged feed for the specified entity.voidmerge(GtfsMergeContext context) Perform a merge operation for the entities specified in theGtfsMergeContext.protected voidmergeEntity(GtfsMergeContext context, org.onebusaway.gtfs.model.IdentityBean<?> entity) Protected Methodsprotected booleanrejectDuplicateOverDifferences(GtfsMergeContext context, T sourceEntity, T targetDuplicate) For some entity types, we may detect that two entities are duplicates in the source feed and the target merged feed, but the entities might have slight differences that prevent them from being represented as one merged entity in the output feed.protected abstract voidreplaceDuplicateEntry(GtfsMergeContext context, T oldEntity, T newEntity) If we've detected a duplicate for an entity in the source feed with some entity in the merged output feed, we want to replace all references to the old entity with the new merged entity.protected voidsave(GtfsMergeContext context, org.onebusaway.gtfs.model.IdentityBean<?> entity) Saves the specified entity to the merged output feed.Methods inherited from class org.onebusaway.gtfs_merge.strategies.AbstractEntityMergeStrategy
determineDuplicateDetectionStrategy, getDuplicateRenamingStrategy, pickBestDuplicateDetectionStrategy, setDuplicateDetectionStrategy, setDuplicateRenamingStrategy, setLogDuplicatesStrategy
-
Field Details
-
_entityType
-
-
Constructor Details
-
AbstractSingleEntityMergeStrategy
-
-
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.
-
merge
Description copied from interface:EntityMergeStrategyPerform a merge operation for the entities specified in theGtfsMergeContext. This method will be called repeated by theGtfsMerger, once for each input feed.- Parameters:
context- the merge state for the current merge operation
-
mergeEntity
protected void mergeEntity(GtfsMergeContext context, org.onebusaway.gtfs.model.IdentityBean<?> entity) Protected Methods -
getIdentityDuplicate
protected abstract org.onebusaway.gtfs.model.IdentityBean<?> getIdentityDuplicate(GtfsMergeContext context, org.onebusaway.gtfs.model.IdentityBean<?> entity) UseEDuplicateDetectionStrategy.IDENTITYbased duplication-detection to find a duplicate in the output merged feed for the specified entity.- Parameters:
context-entity-- Returns:
- a duplicate entity with the specified id or null if none exists.
-
getFuzzyDuplicate
protected org.onebusaway.gtfs.model.IdentityBean<?> getFuzzyDuplicate(GtfsMergeContext context, org.onebusaway.gtfs.model.IdentityBean<?> entity) UseEDuplicateDetectionStrategy.FUZZYbased duplication-detection to find a duplicate in the output merged feed for the specified entity.- Parameters:
context-entity-- Returns:
- a duplicate entity that fuzzily matches the specified entity or null if none exists.
-
rejectDuplicateOverDifferences
protected boolean rejectDuplicateOverDifferences(GtfsMergeContext context, T sourceEntity, T targetDuplicate) For some entity types, we may detect that two entities are duplicates in the source feed and the target merged feed, but the entities might have slight differences that prevent them from being represented as one merged entity in the output feed. Sub-classes can override this method to provide entity-specific logic for determining if two entities cannot be properly merged.- Parameters:
context-sourceEntity-targetDuplicate-- Returns:
-
replaceDuplicateEntry
If we've detected a duplicate for an entity in the source feed with some entity in the merged output feed, we want to replace all references to the old entity with the new merged entity. Sub-classes will override this method to provide logic specific to particular entity types, as it relates to updating entity references.- Parameters:
context-oldEntity- the old entity in the source feed that should be replacednewEntity- the new entity in the output merged feed that duplicates the old entity
-
save
Saves the specified entity to the merged output feed.- Parameters:
context-entity-
-
getDescription
- Specified by:
getDescriptionin classAbstractEntityMergeStrategy- Returns:
- a string description of the current entity merge strategy, typically identifying the entity-type to be merged
-