Skip to content

Commit

Permalink
Introduce ValidationRule and ValidationIssue (#601)
Browse files Browse the repository at this point in the history
  • Loading branch information
vpaturet authored Nov 28, 2024
1 parent 3c6f4b1 commit 76d701d
Show file tree
Hide file tree
Showing 88 changed files with 1,381 additions and 2,901 deletions.
18 changes: 17 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
<entur.google.pubsub.emulator.download.skip>false</entur.google.pubsub.emulator.download.skip>
<camel.version>4.4.4</camel.version>
<entur.helpers.version>3.0</entur.helpers.version>
<netex-validator-java.version>6.0.2</netex-validator-java.version>
<netex-validator-java.version>7.0.0</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>
<zt-zip.version>1.17</zt-zip.version>
<redisson.version>3.39.0</redisson.version>
Expand All @@ -41,6 +42,7 @@

<!-- empty argLine property, the value is set up by Jacoco during unit tests execution -->
<argLine/>

</properties>

<dependencyManagement>
Expand Down Expand Up @@ -202,6 +204,13 @@
</dependency>

<!-- Other -->

<dependency>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-core</artifactId>
<version>${jts-core.version}</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
Expand Down Expand Up @@ -296,6 +305,13 @@
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>osgeo</id>
<name>Open Source Geospatial Foundation Repository</name>
<url>https://repo.osgeo.org/repository/release/</url>
</repository>
</repositories>

<profiles>
<profile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,16 @@ public ValidationTreeFactory stopPlaceDataValidationTreeFactory() {
public XPathRuleValidator stopPlaceDataXPathValidator(
@Qualifier(
"stopPlaceDataValidationTreeFactory"
) ValidationTreeFactory validationTreeFactory,
ValidationReportEntryFactory validationReportEntryFactory
) ValidationTreeFactory validationTreeFactory
) {
return new XPathRuleValidator(
validationTreeFactory,
validationReportEntryFactory
);
return new XPathRuleValidator(validationTreeFactory);
}

@Bean
public NetexValidatorsRunner stopPlaceDataValidatorsRunner(
@Qualifier(
"validationReportEntryFactory"
) ValidationReportEntryFactory validationReportEntryFactory,
NetexSchemaValidator netexSchemaValidator,
@Qualifier("stopPlaceDataXPathValidator") XPathRuleValidator xpathValidator,
NetexIdValidator netexIdValidator,
Expand All @@ -82,6 +81,7 @@ public NetexValidatorsRunner stopPlaceDataValidatorsRunner(
.withNetexXMLParser(netexXMLParser)
.withNetexSchemaValidator(netexSchemaValidator)
.withXPathValidators(netexValidators)
.withValidationReportEntryFactory(validationReportEntryFactory)
.build();
}
}
140 changes: 36 additions & 104 deletions src/main/java/no/entur/antu/config/TimetableDataValidatorConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,156 +74,84 @@ public ValidationTreeFactory timetableDataValidationTreeFactory(
public XPathRuleValidator timetableDataXPathValidator(
@Qualifier(
"timetableDataValidationTreeFactory"
) ValidationTreeFactory validationTreeFactory,
ValidationReportEntryFactory validationReportEntryFactory
) ValidationTreeFactory validationTreeFactory
) {
return new XPathRuleValidator(
validationTreeFactory,
validationReportEntryFactory
);
return new XPathRuleValidator(validationTreeFactory);
}

@Bean
public UnexpectedDistanceBetweenStopPointsValidator unexpectedDistanceBetweenStopPointsValidator(
@Qualifier(
"validationReportEntryFactory"
) ValidationReportEntryFactory validationReportEntryFactory
) {
return new UnexpectedDistanceBetweenStopPointsValidator(
validationReportEntryFactory
);
public UnexpectedDistanceBetweenStopPointsValidator unexpectedDistanceBetweenStopPointsValidator() {
return new UnexpectedDistanceBetweenStopPointsValidator();
}

@Bean
public IdenticalStopPointsValidator identicalStopPointsValidator(
@Qualifier(
"validationReportEntryFactory"
) ValidationReportEntryFactory validationReportEntryFactory
) {
return new IdenticalStopPointsValidator(validationReportEntryFactory);
public IdenticalStopPointsValidator identicalStopPointsValidator() {
return new IdenticalStopPointsValidator();
}

@Bean
public SameQuayRefValidator sameQuayRefValidator(
@Qualifier(
"validationReportEntryFactory"
) ValidationReportEntryFactory validationReportEntryFactory
) {
return new SameQuayRefValidator(validationReportEntryFactory);
public SameQuayRefValidator sameQuayRefValidator() {
return new SameQuayRefValidator();
}

@Bean
public SameStopPointsValidator sameStopPointsValidator(
@Qualifier(
"validationReportEntryFactory"
) ValidationReportEntryFactory validationReportEntryFactory
) {
return new SameStopPointsValidator(validationReportEntryFactory);
public SameStopPointsValidator sameStopPointsValidator() {
return new SameStopPointsValidator();
}

@Bean
public StopPointsCountValidator stopPointsCountValidator(
@Qualifier(
"validationReportEntryFactory"
) ValidationReportEntryFactory validationReportEntryFactory
) {
return new StopPointsCountValidator(validationReportEntryFactory);
public StopPointsCountValidator stopPointsCountValidator() {
return new StopPointsCountValidator();
}

@Bean
public MissingPassengerStopAssignmentValidator missingPassengerStopAssignmentValidator(
@Qualifier(
"validationReportEntryFactory"
) ValidationReportEntryFactory validationReportEntryFactory
) {
return new MissingPassengerStopAssignmentValidator(
validationReportEntryFactory
);
public MissingPassengerStopAssignmentValidator missingPassengerStopAssignmentValidator() {
return new MissingPassengerStopAssignmentValidator();
}

@Bean
public NonIncreasingPassingTimeValidator nonIncreasingPassingTimeValidator(
@Qualifier(
"validationReportEntryFactory"
) ValidationReportEntryFactory validationReportEntryFactory
) {
return new NonIncreasingPassingTimeValidator(validationReportEntryFactory);
public NonIncreasingPassingTimeValidator nonIncreasingPassingTimeValidator() {
return new NonIncreasingPassingTimeValidator();
}

@Bean
public UnexpectedSpeedValidator unexpectedSpeedValidator(
@Qualifier(
"validationReportEntryFactory"
) ValidationReportEntryFactory validationReportEntryFactory
) {
return new UnexpectedSpeedValidator(validationReportEntryFactory);
public UnexpectedSpeedValidator unexpectedSpeedValidator() {
return new UnexpectedSpeedValidator();
}

@Bean
public UnexpectedDistanceInServiceLinkValidator unexpectedDistanceInServiceLinkValidator(
@Qualifier(
"validationReportEntryFactory"
) ValidationReportEntryFactory validationReportEntryFactory
) {
return new UnexpectedDistanceInServiceLinkValidator(
validationReportEntryFactory
);
public UnexpectedDistanceInServiceLinkValidator unexpectedDistanceInServiceLinkValidator() {
return new UnexpectedDistanceInServiceLinkValidator();
}

@Bean
public MismatchedStopPointsValidator mismatchedStopPointsValidator(
@Qualifier(
"validationReportEntryFactory"
) ValidationReportEntryFactory validationReportEntryFactory
) {
return new MismatchedStopPointsValidator(validationReportEntryFactory);
public MismatchedStopPointsValidator mismatchedStopPointsValidator() {
return new MismatchedStopPointsValidator();
}

@Bean
public MandatoryFieldsValidator mandatoryFieldsValidator(
@Qualifier(
"validationReportEntryFactory"
) ValidationReportEntryFactory validationReportEntryFactory
) {
return new MandatoryFieldsValidator(validationReportEntryFactory);
public MandatoryFieldsValidator mandatoryFieldsValidator() {
return new MandatoryFieldsValidator();
}

@Bean
public DuplicateInterchangesValidator duplicateInterchangesValidator(
@Qualifier(
"validationReportEntryFactory"
) ValidationReportEntryFactory validationReportEntryFactory
) {
return new DuplicateInterchangesValidator(validationReportEntryFactory);
public DuplicateInterchangesValidator duplicateInterchangesValidator() {
return new DuplicateInterchangesValidator();
}

@Bean
public InvalidServiceAlterationValidator missingServiceAlterationValidator(
@Qualifier(
"validationReportEntryFactory"
) ValidationReportEntryFactory validationReportEntryFactory
) {
return new InvalidServiceAlterationValidator(validationReportEntryFactory);
public InvalidServiceAlterationValidator missingServiceAlterationValidator() {
return new InvalidServiceAlterationValidator();
}

@Bean
public MissingReplacementValidator missingReplacementValidator(
@Qualifier(
"validationReportEntryFactory"
) ValidationReportEntryFactory validationReportEntryFactory
) {
return new MissingReplacementValidator(validationReportEntryFactory);
public MissingReplacementValidator missingReplacementValidator() {
return new MissingReplacementValidator();
}

@Bean
public UnexpectedInterchangeDistanceValidator unexpectedInterchangeDistanceValidator(
@Qualifier(
"validationReportEntryFactory"
) ValidationReportEntryFactory validationReportEntryFactory
) {
return new UnexpectedInterchangeDistanceValidator(
validationReportEntryFactory
);
public UnexpectedInterchangeDistanceValidator unexpectedInterchangeDistanceValidator() {
return new UnexpectedInterchangeDistanceValidator();
}

@Bean
Expand Down Expand Up @@ -254,6 +182,9 @@ public DuplicateLineNameValidator duplicateLineNameValidator(

@Bean
public NetexValidatorsRunner timetableDataValidatorsRunner(
@Qualifier(
"validationReportEntryFactory"
) ValidationReportEntryFactory validationReportEntryFactory,
NetexSchemaValidator netexSchemaValidator,
@Qualifier(
"timetableDataXPathValidator"
Expand Down Expand Up @@ -343,6 +274,7 @@ public NetexValidatorsRunner timetableDataValidatorsRunner(
.withCommonDataRepository(commonDataRepository)
.withNetexDataRepository(netexDataRepository)
.withStopPlaceRepository(stopPlaceRepository)
.withValidationReportEntryFactory(validationReportEntryFactory)
.build();
}
}
54 changes: 12 additions & 42 deletions src/main/java/no/entur/antu/config/ValidatorConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,43 +78,23 @@ public ValidationReportEntryFactory validationReportEntryFactory(
}

@Bean
public NetexIdValidator netexIdValidator(
@Qualifier(
"validationReportEntryFactory"
) ValidationReportEntryFactory validationReportEntryFactory
) {
return new NetexIdValidator(validationReportEntryFactory);
public NetexIdValidator netexIdValidator() {
return new NetexIdValidator();
}

@Bean
public VersionOnLocalNetexIdValidator versionOnLocalNetexIdValidator(
@Qualifier(
"validationReportEntryFactory"
) ValidationReportEntryFactory validationReportEntryFactory
) {
return new VersionOnLocalNetexIdValidator(validationReportEntryFactory);
public VersionOnLocalNetexIdValidator versionOnLocalNetexIdValidator() {
return new VersionOnLocalNetexIdValidator();
}

@Bean
public VersionOnRefToLocalNetexIdValidator versionOnRefToLocalNetexIdValidator(
@Qualifier(
"validationReportEntryFactory"
) ValidationReportEntryFactory validationReportEntryFactory
) {
return new VersionOnRefToLocalNetexIdValidator(
validationReportEntryFactory
);
public VersionOnRefToLocalNetexIdValidator versionOnRefToLocalNetexIdValidator() {
return new VersionOnRefToLocalNetexIdValidator();
}

@Bean
public ReferenceToValidEntityTypeValidator refToValidEntityTypeValidator(
@Qualifier(
"validationReportEntryFactory"
) ValidationReportEntryFactory validationReportEntryFactory
) {
return new ReferenceToValidEntityTypeValidator(
validationReportEntryFactory
);
public ReferenceToValidEntityTypeValidator refToValidEntityTypeValidator() {
return new ReferenceToValidEntityTypeValidator();
}

@Bean
Expand All @@ -127,10 +107,7 @@ public ReferenceToNsrValidator nsrRefValidator(
@Bean
public NetexReferenceValidator netexReferenceValidator(
NetexIdRepository netexIdRepository,
ReferenceToNsrValidator referenceToNsrValidator,
@Qualifier(
"validationReportEntryFactory"
) ValidationReportEntryFactory validationReportEntryFactory
ReferenceToNsrValidator referenceToNsrValidator
) {
List<ExternalReferenceValidator> externalReferenceValidators =
new ArrayList<>();
Expand All @@ -141,22 +118,15 @@ public NetexReferenceValidator netexReferenceValidator(
externalReferenceValidators.add(referenceToNsrValidator);
return new NetexReferenceValidator(
netexIdRepository,
externalReferenceValidators,
validationReportEntryFactory
externalReferenceValidators
);
}

@Bean
public NetexIdUniquenessValidator netexIdUniquenessValidator(
NetexIdRepository netexIdRepository,
@Qualifier(
"validationReportEntryFactory"
) ValidationReportEntryFactory validationReportEntryFactory
NetexIdRepository netexIdRepository
) {
return new NetexIdUniquenessValidator(
netexIdRepository,
validationReportEntryFactory
);
return new NetexIdUniquenessValidator(netexIdRepository);
}

@Bean
Expand Down
Loading

0 comments on commit 76d701d

Please sign in to comment.