Skip to content

Commit

Permalink
Merging no longer needed
Browse files Browse the repository at this point in the history
  • Loading branch information
testower committed Jan 24, 2025
1 parent 063b149 commit 032ea2b
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 85 deletions.
11 changes: 0 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,6 @@
<artifactId>gt-main</artifactId>
<version>32.1</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>1.5.5.Final</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.5.5.Final</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.entur.lamassu.delta.GBFSEntityDelta;
import org.entur.lamassu.delta.GBFSFileDelta;
import org.entur.lamassu.mapper.entitymapper.StationMapper;
import org.entur.lamassu.mapper.entitymapper.StationMergeMapper;
import org.entur.lamassu.metrics.MetricsService;
import org.entur.lamassu.model.entities.Station;
import org.entur.lamassu.model.provider.FeedProvider;
Expand Down Expand Up @@ -71,7 +70,6 @@ public UpdateContext(
private final EntityCache<Station> stationCache;
private final StationSpatialIndex spatialIndex;
private final StationMapper stationMapper;
private final StationMergeMapper stationMergeMapper;
private final MetricsService metricsService;
private final SpatialIndexIdGeneratorService spatialIndexService;

Expand All @@ -82,14 +80,12 @@ public StationsUpdater(
EntityCache<Station> stationCache,
StationSpatialIndex spatialIndex,
StationMapper stationMapper,
StationMergeMapper stationMergeMapper,
MetricsService metricsService,
SpatialIndexIdGeneratorService spatialIndexService
) {
this.stationCache = stationCache;
this.spatialIndex = spatialIndex;
this.stationMapper = stationMapper;
this.stationMergeMapper = stationMergeMapper;
this.metricsService = metricsService;
this.spatialIndexService = spatialIndexService;
}
Expand Down Expand Up @@ -236,24 +232,22 @@ private void processDeltaUpdate(
}

if (currentStation != null) {
context.spatialIndexIdsToRemove.add(
spatialIndexService.createStationIndexId(currentStation, context.feedProvider)
);

Station mappedStation = stationMapper.mapStation(
stationInformation,
entityDelta.entity(),
context.feedProvider.getSystemId(),
context.feedProvider.getLanguage()
);

context.spatialIndexIdsToRemove.add(
spatialIndexService.createStationIndexId(currentStation, context.feedProvider)
);

// Merge the mapped station into the current station
stationMergeMapper.updateStation(currentStation, mappedStation);
context.addedAndUpdatedStations.put(currentStation.getId(), currentStation);
context.addedAndUpdatedStations.put(mappedStation.getId(), mappedStation);

context.spatialIndexUpdateMap.put(
spatialIndexService.createStationIndexId(currentStation, context.feedProvider),
currentStation
spatialIndexService.createStationIndexId(mappedStation, context.feedProvider),
mappedStation
);
} else {
logger.debug(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.entur.lamassu.delta.GBFSEntityDelta;
import org.entur.lamassu.delta.GBFSFileDelta;
import org.entur.lamassu.mapper.entitymapper.VehicleMapper;
import org.entur.lamassu.mapper.entitymapper.VehicleMergeMapper;
import org.entur.lamassu.metrics.MetricsService;
import org.entur.lamassu.model.entities.Vehicle;
import org.entur.lamassu.model.provider.FeedProvider;
Expand Down Expand Up @@ -61,7 +60,6 @@ public UpdateContext(FeedProvider feedProvider) {
private final EntityCache<Vehicle> vehicleCache;
private final VehicleSpatialIndex spatialIndex;
private final VehicleMapper vehicleMapper;
private final VehicleMergeMapper vehicleMergeMapper;
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private final MetricsService metricsService;
private final SpatialIndexIdGeneratorService spatialIndexService;
Expand All @@ -72,15 +70,13 @@ public VehiclesUpdater(
EntityCache<Vehicle> vehicleCache,
VehicleSpatialIndex spatialIndex,
VehicleMapper vehicleMapper,
VehicleMergeMapper vehicleMergeMapper,
MetricsService metricsService,
SpatialIndexIdGeneratorService spatialIndexService,
VehicleFilter vehicleFilter
) {
this.vehicleCache = vehicleCache;
this.spatialIndex = spatialIndex;
this.vehicleMapper = vehicleMapper;
this.vehicleMergeMapper = vehicleMergeMapper;
this.metricsService = metricsService;
this.spatialIndexService = spatialIndexService;
this.vehicleFilter = vehicleFilter;
Expand Down Expand Up @@ -180,21 +176,20 @@ private void processDeltaUpdate(
Vehicle currentVehicle = vehicleCache.get(entityDelta.entityId());

if (currentVehicle != null) {
context.spatialIndexIdsToRemove.add(
spatialIndexService.createVehicleIndexId(currentVehicle, context.feedProvider)
);

Vehicle mappedVehicle = vehicleMapper.mapVehicle(
entityDelta.entity(),
context.feedProvider.getSystemId()
);

context.spatialIndexIdsToRemove.add(
spatialIndexService.createVehicleIndexId(currentVehicle, context.feedProvider)
);

vehicleMergeMapper.updateVehicle(currentVehicle, mappedVehicle);
context.addedAndUpdatedVehicles.put(currentVehicle.getId(), currentVehicle);
context.addedAndUpdatedVehicles.put(mappedVehicle.getId(), mappedVehicle);

context.spatialIndexUpdateMap.put(
spatialIndexService.createVehicleIndexId(currentVehicle, context.feedProvider),
currentVehicle
spatialIndexService.createVehicleIndexId(mappedVehicle, context.feedProvider),
mappedVehicle
);
} else {
logger.debug(
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import org.entur.lamassu.delta.GBFSFileDelta;
import org.entur.lamassu.mapper.entitymapper.RentalUrisMapper;
import org.entur.lamassu.mapper.entitymapper.StationMapper;
import org.entur.lamassu.mapper.entitymapper.StationMergeMapper;
import org.entur.lamassu.mapper.entitymapper.StationMergeMapperImpl;
import org.entur.lamassu.mapper.entitymapper.TranslationMapper;
import org.entur.lamassu.metrics.MetricsService;
import org.entur.lamassu.model.entities.FormFactor;
Expand Down Expand Up @@ -60,7 +58,6 @@ class StationsUpdaterTest {
private EntityCache<VehicleType> vehicleTypeCache;

private StationMapper stationMapper;
private StationMergeMapper stationMergeMapper;
private SpatialIndexIdGeneratorService spatialIndexIdGeneratorService;
private StationsUpdater stationsUpdater;

Expand All @@ -70,15 +67,13 @@ void setUp() {
TranslationMapper translationMapper = new TranslationMapper();
RentalUrisMapper rentalUrisMapper = new RentalUrisMapper();
stationMapper = new StationMapper(translationMapper, rentalUrisMapper);
stationMergeMapper = new StationMergeMapperImpl();

spatialIndexIdGeneratorService = new SpatialIndexIdGeneratorService(vehicleTypeCache);
stationsUpdater =
new StationsUpdater(
stationCache,
spatialIndex,
stationMapper,
stationMergeMapper,
metricsService,
spatialIndexIdGeneratorService
);
Expand Down Expand Up @@ -399,7 +394,6 @@ void shouldRemoveExistingStationsWhenBaseIsNull() {
stationCache,
spatialIndex,
stationMapper,
stationMergeMapper,
metricsService,
spatialIndexIdGeneratorService
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import org.entur.lamassu.delta.GBFSFileDelta;
import org.entur.lamassu.mapper.entitymapper.RentalUrisMapper;
import org.entur.lamassu.mapper.entitymapper.VehicleMapper;
import org.entur.lamassu.mapper.entitymapper.VehicleMergeMapper;
import org.entur.lamassu.mapper.entitymapper.VehicleMergeMapperImpl;
import org.entur.lamassu.metrics.MetricsService;
import org.entur.lamassu.model.entities.FormFactor;
import org.entur.lamassu.model.entities.PropulsionType;
Expand Down Expand Up @@ -54,7 +52,6 @@ class VehiclesUpdaterTest {
private VehicleFilter vehicleFilter;

private VehicleMapper vehicleMapper;
private VehicleMergeMapper vehicleMergeMapper;
private SpatialIndexIdGeneratorService spatialIndexIdGeneratorService;
private VehiclesUpdater vehiclesUpdater;

Expand All @@ -63,7 +60,6 @@ void setUp() {
// Initialize real mappers
RentalUrisMapper rentalUrisMapper = new RentalUrisMapper();
vehicleMapper = new VehicleMapper(rentalUrisMapper);
vehicleMergeMapper = new VehicleMergeMapperImpl();

// Initialize real services
spatialIndexIdGeneratorService = new SpatialIndexIdGeneratorService(vehicleTypeCache);
Expand All @@ -73,7 +69,6 @@ void setUp() {
vehicleCache,
spatialIndex,
vehicleMapper,
vehicleMergeMapper,
metricsService,
spatialIndexIdGeneratorService,
vehicleFilter
Expand Down

0 comments on commit 032ea2b

Please sign in to comment.