Skip to content

Commit

Permalink
Interchange wait time and active dates validation
Browse files Browse the repository at this point in the history
  • Loading branch information
mansoor-sajjad committed Dec 10, 2024
1 parent f0a0879 commit 1871c83
Show file tree
Hide file tree
Showing 29 changed files with 5,050 additions and 123 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<entur.google.pubsub.emulator.download.skip>false</entur.google.pubsub.emulator.download.skip>
<camel.version>4.4.4</camel.version>
<entur.helpers.version>4.4</entur.helpers.version>
<netex-validator-java.version>8.0.0</netex-validator-java.version>
<netex-validator-java.version>8.0.2</netex-validator-java.version>
<netex-parser-java.version>3.1.29</netex-parser-java.version>
<jts-core.version>1.20.0</jts-core.version>
<commons-io.version>2.11.0</commons-io.version>
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/no/entur/antu/config/NetexDataConfig.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package no.entur.antu.config;

import static no.entur.antu.config.cache.CacheConfig.ACTIVE_DATES_CACHE;
import static no.entur.antu.config.cache.CacheConfig.LINE_INFO_CACHE;
import static no.entur.antu.config.cache.CacheConfig.SERVICE_JOURNEY_DAY_TYPES_CACHE;
import static no.entur.antu.config.cache.CacheConfig.SERVICE_JOURNEY_INTERCHANGE_INFO_CACHE;
import static no.entur.antu.config.cache.CacheConfig.SERVICE_JOURNEY_OPERATING_DAYS_CACHE;
import static no.entur.antu.config.cache.CacheConfig.SERVICE_JOURNEY_STOPS_CACHE;

import java.util.List;
Expand All @@ -25,6 +28,15 @@ NetexDataRepository netexDataRepository(
@Qualifier(
SERVICE_JOURNEY_STOPS_CACHE
) Map<String, Map<String, List<String>>> serviceJourneyStopsCache,
@Qualifier(
SERVICE_JOURNEY_DAY_TYPES_CACHE
) Map<String, Map<String, String>> serviceJourneyDayTypesCache,
@Qualifier(
ACTIVE_DATES_CACHE
) Map<String, Map<String, String>> activeDatesCache,
@Qualifier(
SERVICE_JOURNEY_OPERATING_DAYS_CACHE
) Map<String, Map<String, String>> serviceJourneyOperatingDaysCache,
@Qualifier(
SERVICE_JOURNEY_INTERCHANGE_INFO_CACHE
) Map<String, List<String>> serviceJourneyInterchangeInfoCache
Expand All @@ -33,6 +45,9 @@ NetexDataRepository netexDataRepository(
redissonClient,
lineInfoCache,
serviceJourneyStopsCache,
serviceJourneyDayTypesCache,
activeDatesCache,
serviceJourneyOperatingDaysCache,
serviceJourneyInterchangeInfoCache
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@

import java.util.List;
import java.util.Set;
import no.entur.antu.netexdata.collectors.DatedServiceJourneysCollector;
import no.entur.antu.netexdata.collectors.LineInfoCollector;
import no.entur.antu.netexdata.collectors.ServiceJourneyDayTypesCollector;
import no.entur.antu.netexdata.collectors.ServiceJourneyInterchangeInfoCollector;
import no.entur.antu.netexdata.collectors.ServiceJourneyStopsCollector;
import no.entur.antu.netexdata.collectors.activedatecollector.ActiveDatesCollector;
import no.entur.antu.organisation.OrganisationRepository;
import no.entur.antu.validation.validator.id.NetexIdValidator;
import no.entur.antu.validation.validator.interchange.distance.UnexpectedInterchangeDistanceValidator;
import no.entur.antu.validation.validator.interchange.duplicate.DuplicateInterchangesValidator;
import no.entur.antu.validation.validator.interchange.mandatoryfields.MandatoryFieldsValidator;
import no.entur.antu.validation.validator.interchange.stoppoints.StopPointsInVehicleJourneyValidator;
import no.entur.antu.validation.validator.interchange.waittime.UnexpectedWaitTimeAndActiveDatesValidator;
import no.entur.antu.validation.validator.journeypattern.stoppoint.distance.UnexpectedDistanceBetweenStopPointsValidator;
import no.entur.antu.validation.validator.journeypattern.stoppoint.identicalstoppoints.IdenticalStopPointsValidator;
import no.entur.antu.validation.validator.journeypattern.stoppoint.samequayref.SameQuayRefValidator;
Expand All @@ -41,7 +45,10 @@
import no.entur.antu.validation.validator.servicelink.distance.UnexpectedDistanceInServiceLinkValidator;
import no.entur.antu.validation.validator.servicelink.stoppoints.MismatchedStopPointsValidator;
import no.entur.antu.validation.validator.xpath.EnturTimetableDataValidationTreeFactory;
import org.entur.netex.validation.validator.*;
import org.entur.netex.validation.validator.DatasetValidator;
import org.entur.netex.validation.validator.NetexValidatorsRunner;
import org.entur.netex.validation.validator.ValidationReportEntryFactory;
import org.entur.netex.validation.validator.XPathValidator;
import org.entur.netex.validation.validator.id.NetexIdUniquenessValidator;
import org.entur.netex.validation.validator.id.NetexReferenceValidator;
import org.entur.netex.validation.validator.id.ReferenceToValidEntityTypeValidator;
Expand Down Expand Up @@ -180,6 +187,19 @@ public DuplicateLineNameValidator duplicateLineNameValidator(
);
}

@Bean
public UnexpectedWaitTimeAndActiveDatesValidator unexpectedWaitTimeValidator(
@Qualifier(
"validationReportEntryFactory"
) ValidationReportEntryFactory validationReportEntryFactory,
NetexDataRepository netexDataRepository
) {
return new UnexpectedWaitTimeAndActiveDatesValidator(
validationReportEntryFactory,
netexDataRepository
);
}

@Bean
public NetexValidatorsRunner timetableDataValidatorsRunner(
@Qualifier(
Expand Down Expand Up @@ -214,10 +234,14 @@ public NetexValidatorsRunner timetableDataValidatorsRunner(
StopPointsInVehicleJourneyValidator stopPointsInVehicleJourneyValidator,
DuplicateLineNameValidator duplicateLineNameValidator,
MissingReplacementValidator missingReplacementValidator,
UnexpectedWaitTimeAndActiveDatesValidator unexpectedWaitTimeAndActiveDatesValidator,
LineInfoCollector lineInfoCollector,
ServiceJourneyStopsCollector serviceJourneyStopsCollector,
ServiceJourneyInterchangeInfoCollector serviceJourneyInterchangeInfoCollector,
CommonDataRepositoryLoader commonDataRepository,
ActiveDatesCollector activeDatesCollector,
ServiceJourneyDayTypesCollector serviceJourneyDayTypesCollector,
DatedServiceJourneysCollector datedServiceJourneysCollector,
CommonDataRepositoryLoader commonDataRepositoryLoader,
NetexDataRepository netexDataRepository,
StopPlaceRepository stopPlaceRepository
) {
Expand Down Expand Up @@ -254,13 +278,17 @@ public NetexValidatorsRunner timetableDataValidatorsRunner(

List<DatasetValidator> netexTimetableDatasetValidators = List.of(
duplicateLineNameValidator,
stopPointsInVehicleJourneyValidator
stopPointsInVehicleJourneyValidator,
unexpectedWaitTimeAndActiveDatesValidator
);

List<NetexDataCollector> commonDataCollectors = List.of(
lineInfoCollector,
serviceJourneyInterchangeInfoCollector,
serviceJourneyStopsCollector
serviceJourneyStopsCollector,
activeDatesCollector,
serviceJourneyDayTypesCollector,
datedServiceJourneysCollector
);

return NetexValidatorsRunner
Expand All @@ -271,7 +299,7 @@ public NetexValidatorsRunner timetableDataValidatorsRunner(
.withJaxbValidators(jaxbValidators)
.withDatasetValidators(netexTimetableDatasetValidators)
.withNetexDataCollectors(commonDataCollectors)
.withCommonDataRepository(commonDataRepository)
.withCommonDataRepository(commonDataRepositoryLoader)
.withNetexDataRepository(netexDataRepository)
.withStopPlaceRepository(stopPlaceRepository)
.withValidationReportEntryFactory(validationReportEntryFactory)
Expand Down
38 changes: 38 additions & 0 deletions src/main/java/no/entur/antu/config/cache/CacheConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ public class CacheConfig {
public static final String LINE_INFO_CACHE = "linesInfoCache";
public static final String SERVICE_JOURNEY_INTERCHANGE_INFO_CACHE =
"serviceJourneyInterchangeInfoCache";
public static final String SERVICE_JOURNEY_DAY_TYPES_CACHE =
"serviceJourneyDayTypesCache";
public static final String SERVICE_JOURNEY_STOPS_CACHE =
"serviceJourneyStopsCache";
public static final String SERVICE_JOURNEY_OPERATING_DAYS_CACHE =
"serviceJourneyOperatingDaysCache";
public static final String ACTIVE_DATES_CACHE = "activeDatesCache";
public static final String QUAY_ID_NOT_FOUND_CACHE = "quayIdNotFoundCache";

private static final Kryo5Codec DEFAULT_CODEC = new Kryo5Codec();
Expand Down Expand Up @@ -172,6 +177,17 @@ public Map<String, List<String>> serviceJourneyInterchangeInfoCache(
);
}

@Bean(name = SERVICE_JOURNEY_DAY_TYPES_CACHE)
public Map<String, Map<String, String>> serviceJourneyDayTypesCache(
RedissonClient redissonClient
) {
return getOrCreateReportScopedCache(
redissonClient,
SERVICE_JOURNEY_DAY_TYPES_CACHE,
new CompositeCodec(new StringCodec(), new StringCodec())
);
}

@Bean(name = SERVICE_JOURNEY_STOPS_CACHE)
public Map<String, Map<String, List<String>>> serviceJourneyStopsCache(
RedissonClient redissonClient
Expand All @@ -183,6 +199,28 @@ public Map<String, Map<String, List<String>>> serviceJourneyStopsCache(
);
}

@Bean(name = ACTIVE_DATES_CACHE)
public Map<String, Map<String, String>> activeDatesCache(
RedissonClient redissonClient
) {
return getOrCreateReportScopedCache(
redissonClient,
ACTIVE_DATES_CACHE,
new CompositeCodec(new StringCodec(), new StringCodec())
);
}

@Bean(name = SERVICE_JOURNEY_OPERATING_DAYS_CACHE)
public Map<String, Map<String, String>> serviceJourneyOperatingDaysCache(
RedissonClient redissonClient
) {
return getOrCreateReportScopedCache(
redissonClient,
SERVICE_JOURNEY_OPERATING_DAYS_CACHE,
new CompositeCodec(new StringCodec(), new StringCodec())
);
}

@Bean
public NetexIdRepository netexIdRepository(
RedissonClient redissonClient,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package no.entur.antu.config.cache;

import static no.entur.antu.config.cache.CacheConfig.ACTIVE_DATES_CACHE;
import static no.entur.antu.config.cache.CacheConfig.LINE_INFO_CACHE;
import static no.entur.antu.config.cache.CacheConfig.SERVICE_JOURNEY_DAY_TYPES_CACHE;
import static no.entur.antu.config.cache.CacheConfig.SERVICE_JOURNEY_INTERCHANGE_INFO_CACHE;
import static no.entur.antu.config.cache.CacheConfig.SERVICE_JOURNEY_OPERATING_DAYS_CACHE;
import static no.entur.antu.config.cache.CacheConfig.SERVICE_JOURNEY_STOPS_CACHE;

import java.util.List;
import java.util.Map;
import no.entur.antu.netexdata.collectors.DatedServiceJourneysCollector;
import no.entur.antu.netexdata.collectors.LineInfoCollector;
import no.entur.antu.netexdata.collectors.ServiceJourneyDayTypesCollector;
import no.entur.antu.netexdata.collectors.ServiceJourneyInterchangeInfoCollector;
import no.entur.antu.netexdata.collectors.ServiceJourneyStopsCollector;
import no.entur.antu.netexdata.collectors.activedatecollector.ActiveDatesCollector;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
Expand All @@ -25,6 +31,29 @@ public LineInfoCollector lineInfoScraper(
return new LineInfoCollector(redissonClient, lineInfoCache);
}

@Bean
public ActiveDatesCollector activeDatesCollector(
RedissonClient redissonClient,
@Qualifier(
ACTIVE_DATES_CACHE
) Map<String, Map<String, String>> activeDatesCache
) {
return new ActiveDatesCollector(redissonClient, activeDatesCache);
}

@Bean
public DatedServiceJourneysCollector datedServiceJourneysCollector(
RedissonClient redissonClient,
@Qualifier(
SERVICE_JOURNEY_OPERATING_DAYS_CACHE
) Map<String, Map<String, String>> serviceJourneyOperatingDaysCache
) {
return new DatedServiceJourneysCollector(
redissonClient,
serviceJourneyOperatingDaysCache
);
}

@Bean
public ServiceJourneyInterchangeInfoCollector serviceJourneyInterchangeInfoCollector(
RedissonClient redissonClient,
Expand All @@ -38,6 +67,19 @@ public ServiceJourneyInterchangeInfoCollector serviceJourneyInterchangeInfoColle
);
}

@Bean
public ServiceJourneyDayTypesCollector serviceJourneyDayTypesCollector(
RedissonClient redissonClient,
@Qualifier(
SERVICE_JOURNEY_DAY_TYPES_CACHE
) Map<String, Map<String, String>> serviceJourneyDayTypesCache
) {
return new ServiceJourneyDayTypesCollector(
redissonClient,
serviceJourneyDayTypesCache
);
}

@Bean
public ServiceJourneyStopsCollector serviceJourneyStopsCollector(
RedissonClient redissonClient,
Expand Down
Loading

0 comments on commit 1871c83

Please sign in to comment.