Class RoutedServicesLayerModifierImpl
- java.lang.Object
-
- org.goplanit.utils.event.EventProducerImpl
-
- org.goplanit.service.routed.modifier.RoutedServicesLayerModifierImpl
-
- All Implemented Interfaces:
EventProducer,RoutedServicesLayerModifier,RoutedServicesModifierEventProducer
public class RoutedServicesLayerModifierImpl extends EventProducerImpl implements RoutedServicesLayerModifier
Implementation ofRoutedServicesLayerModifier
-
-
Field Summary
Fields Modifier and Type Field Description protected RoutedServicesLayerImplroutedServicesLayer-
Fields inherited from class org.goplanit.utils.event.EventProducerImpl
listeners
-
-
Constructor Summary
Constructors Constructor Description RoutedServicesLayerModifierImpl(RoutedServicesLayerImpl routedServicesLayer)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(RoutedServicesModifierListener listener)Register listeners for events fired by a routed services modifiervoidaddListener(RoutedServicesModifierListener listener, RoutedServicesModifierEventType eventType)Register listeners for events fired by a routed services modifiervoidconsolidateIdenticallyScheduledTrips(Mode mode)Consolidate all PLANit RoutedTrips with identical relative timing schedules (but different departure times) into a single PLANit Routed trip.protected voidfireEvent(EventListener eventListener, Event event)Let derived class deal with the handling of the listener, where based on the derived event implementation the listener's concrete class can be determined which in turn allows for calling the right event callback method which is unknown at this base level since this event mechanism does not force a particular notification method signature on its listener interfacevoidrecreateManagedEntitiesIds()This method will recreate all ids of the routed services' components, but only when the containers used for them are the primary ManagedIdEntities containers, i.e., when the routed services layer is responsible for uniquely tracking all entities by their managed id.voidrecreateRoutedServicesIds()Recreate the ids of the routed services layer routedModeServices across all modesvoidrecreateRoutedTripScheduleDepartureIds()Recreate the ids of the routed services layer's routed trip departure ids across all scheduled trips across all modesvoidrecreateRoutedTripsIds()Recreate the ids of the routed services layer's routed trips (scheduled and frequency based) across all modesvoidremoveDuplicateTripDepartures(boolean recreateManagedDepartureIds)Remove all duplicate scheduled trip departures from the layer.voidremoveEmptyRoutedServicesByMode(boolean recreateRoutedServicesManagedEntitiesIds)Remove all RoutedServicesByMode instances from the layer in case they no longer have any services associated with themvoidremoveListener(RoutedServicesModifierListener listener)Remove listener for all event types it is registered forvoidremoveListener(RoutedServicesModifierListener listener, RoutedServicesModifierEventType eventType)Remove listener for given event typevoidremoveRoutedServicesWithoutTrips(boolean recreateRoutedServiceManagedIds, Mode... modes)Remove all routed services from the layer in case they no longer have any trips associated with them for the given modesvoidremoveScheduledTripsWithoutLegs(boolean recreateManagedEntitiesIds, Mode... modes)Remove all scheduled trips from the layer (for the given modes) in case they have no relative leg timings.voidtruncateToServiceNetwork()Method that will truncate all routed entities to available service network entities in its parent in case the parent service network has been altered for some reason, i.e., the service network entities might still exist as references on the routed services but no longer exist in the related service layer.-
Methods inherited from class org.goplanit.utils.event.EventProducerImpl
addListener, addListener, addListener, addListener, fireEvent, getEventTypesWithListeners, hasListener, hasListeners, numberOfListeners, removeAllListeners, removeListener, removeListener
-
-
-
-
Field Detail
-
routedServicesLayer
protected final RoutedServicesLayerImpl routedServicesLayer
-
-
Constructor Detail
-
RoutedServicesLayerModifierImpl
public RoutedServicesLayerModifierImpl(RoutedServicesLayerImpl routedServicesLayer)
Constructor- Parameters:
routedServicesLayer- this modifier acts upon
-
-
Method Detail
-
fireEvent
protected void fireEvent(EventListener eventListener, Event event)
Let derived class deal with the handling of the listener, where based on the derived event implementation the listener's concrete class can be determined which in turn allows for calling the right event callback method which is unknown at this base level since this event mechanism does not force a particular notification method signature on its listener interface- Specified by:
fireEventin classEventProducerImpl- Parameters:
eventListener- to notify for the eventevent- to process for the listener
-
truncateToServiceNetwork
public void truncateToServiceNetwork()
Method that will truncate all routed entities to available service network entities in its parent in case the parent service network has been altered for some reason, i.e., the service network entities might still exist as references on the routed services but no longer exist in the related service layer. To be used - for example - in tandem withServiceNetworkLayerModifier.removeUnmappedServiceNetworkEntities()which removes service network entities that are not attached to underlying physical network entities. this type of modification is useful for example when a parsed (routed) service network covers a larger area than the underlying physical network chosen, in which case some or many of the service routes are mapped to a service network that in turn could not be mapped to the physical network available. In those cases this method truncates all routes for which its service network elements are missing from its parent service layer (because they were fully or partially detached from a physical network and were removed because of it)Note that invoking this method will recreate all managed ids across the routed services due to gaps occurring after removal of unmapped entries
Note that this implementation will automatically overwrite all pre-existing XML ids with the internal ids of all managed id containers within the routed services layer to ensure uniqueness on both levels of ids.Listeners can be registered for existing id modification events
If, for some reason, the provided services by mode have no (more) entries the services by mode are removed from the layer. Same goes for routed services that have no more trips- Specified by:
truncateToServiceNetworkin interfaceRoutedServicesLayerModifier
-
consolidateIdenticallyScheduledTrips
public void consolidateIdenticallyScheduledTrips(Mode mode)
Consolidate all PLANit RoutedTrips with identical relative timing schedules (but different departure times) into a single PLANit Routed trip. Redundant trips are removed. Not that Ids are not updated when these entries are removed from their respective containers. This is left to the user to do manually afterwards if desired.- Specified by:
consolidateIdenticallyScheduledTripsin interfaceRoutedServicesLayerModifier- Parameters:
mode- to do this for
-
removeEmptyRoutedServicesByMode
public void removeEmptyRoutedServicesByMode(boolean recreateRoutedServicesManagedEntitiesIds)
Remove all RoutedServicesByMode instances from the layer in case they no longer have any services associated with themWhen recreateRoutedServicesManagedEntitiesIds is true, event for recreating routed services ids is fired for which a listener can be attached
- Specified by:
removeEmptyRoutedServicesByModein interfaceRoutedServicesLayerModifier- Parameters:
recreateRoutedServicesManagedEntitiesIds- when true recreate routed services ids, otherwise do not
-
removeRoutedServicesWithoutTrips
public void removeRoutedServicesWithoutTrips(boolean recreateRoutedServiceManagedIds, Mode... modes)Remove all routed services from the layer in case they no longer have any trips associated with them for the given modesWhen managed id entities are recreated, it will do so for routed services
- Specified by:
removeRoutedServicesWithoutTripsin interfaceRoutedServicesLayerModifier- Parameters:
recreateRoutedServiceManagedIds- when true recreate all managed ids on the layer, otherwise do notmodes- to do this for
-
removeScheduledTripsWithoutLegs
public void removeScheduledTripsWithoutLegs(boolean recreateManagedEntitiesIds, Mode... modes)Remove all scheduled trips from the layer (for the given modes) in case they have no relative leg timings. this might occur when only a single stop has been identified for a trip based on a parsed external data source for example, e.g., GTFS with a time period filter.When managed id entities are recreated, it will do so for trips and departure ids
- Specified by:
removeScheduledTripsWithoutLegsin interfaceRoutedServicesLayerModifier- Parameters:
recreateManagedEntitiesIds- when true recreate all managed ids on the layer, otherwise do notmodes- to do this for
-
removeDuplicateTripDepartures
public void removeDuplicateTripDepartures(boolean recreateManagedDepartureIds)
Remove all duplicate scheduled trip departures from the layer. This might occur when there are duplicates in the exogenous data source for exampleWhen ids are recreated, it will do so for departure ids only
- Specified by:
removeDuplicateTripDeparturesin interfaceRoutedServicesLayerModifier- Parameters:
recreateManagedDepartureIds- when true recreate all departure ids on the layer, otherwise do not
-
recreateManagedEntitiesIds
public void recreateManagedEntitiesIds()
This method will recreate all ids of the routed services' components, but only when the containers used for them are the primary ManagedIdEntities containers, i.e., when the routed services layer is responsible for uniquely tracking all entities by their managed id. If not, it will not recreate the ids.The reasoning is that if we would recreate ids of the container while the container does not contain all = let's say - routes, their managedId is no longer guaranteed to be unique which can lead to issues
Method can be used in conjunctions with the removal of parts of the routed services and the result is required to have unique contiguous ids All managed ids of the layer are recreated via
recreateRoutedServicesIds(),recreateRoutedTripsIds(), andrecreateRoutedTripScheduleDepartureIds()including their triggered events which will trigger callbacks to their event listeners (if any are registered)- Specified by:
recreateManagedEntitiesIdsin interfaceRoutedServicesLayerModifier
-
recreateRoutedTripScheduleDepartureIds
public void recreateRoutedTripScheduleDepartureIds()
Recreate the ids of the routed services layer's routed trip departure ids across all scheduled trips across all modes Triggers a ModifiedTripScheduleDepartureIdsEvent upon completion- Specified by:
recreateRoutedTripScheduleDepartureIdsin interfaceRoutedServicesLayerModifier
-
recreateRoutedTripsIds
public void recreateRoutedTripsIds()
Recreate the ids of the routed services layer's routed trips (scheduled and frequency based) across all modes Triggers a ModifiedRoutedTripIdsEvent upon completion- Specified by:
recreateRoutedTripsIdsin interfaceRoutedServicesLayerModifier
-
recreateRoutedServicesIds
public void recreateRoutedServicesIds()
Recreate the ids of the routed services layer routedModeServices across all modes Triggers a ModifiedRoutedServicesIdsEvent upon completion- Specified by:
recreateRoutedServicesIdsin interfaceRoutedServicesLayerModifier
-
addListener
public void addListener(RoutedServicesModifierListener listener)
Register listeners for events fired by a routed services modifier- Specified by:
addListenerin interfaceRoutedServicesModifierEventProducer- Parameters:
listener- to register
-
addListener
public void addListener(RoutedServicesModifierListener listener, RoutedServicesModifierEventType eventType)
Register listeners for events fired by a routed services modifier- Specified by:
addListenerin interfaceRoutedServicesModifierEventProducer- Parameters:
listener- to registereventType- to register listener for
-
removeListener
public void removeListener(RoutedServicesModifierListener listener, RoutedServicesModifierEventType eventType)
Remove listener for given event type- Specified by:
removeListenerin interfaceRoutedServicesModifierEventProducer- Parameters:
listener- to removeeventType- to unregister listener for
-
removeListener
public void removeListener(RoutedServicesModifierListener listener)
Remove listener for all event types it is registered for- Specified by:
removeListenerin interfaceRoutedServicesModifierEventProducer- Parameters:
listener- to remove
-
-