From d6a32d71d5c3a492bfac2edaff25037a7e00496e Mon Sep 17 00:00:00 2001 From: Markus Schneider Date: Wed, 29 Jan 2014 16:28:32 +0100 Subject: [PATCH 1/8] Added ELF project bronhouder, theme modules for HY --- .../ipo/cds/admin/admin-securityContext.xml | 12 +- pom.xml | 4 +- theme-hydronode/pom.xml | 42 ++ .../src/main/assembly/assembly-sql.xml | 18 + .../src/main/feeds/datasettypecodes.xml | 33 ++ .../ipo/cds/etl/theme/hydronode/Context.java | 15 + .../cds/etl/theme/hydronode/HydroNode.java | 208 ++++++++++ .../theme/hydronode/HydroNodeValidator.java | 319 ++++++++++++++ .../ipo/cds/etl/theme/hydronode/Message.java | 114 +++++ .../theme/hydronode/config/DatasetConfig.java | 60 +++ .../etl/theme/hydronode/config/Package.java | 4 + .../etl/theme/hydronode/messages.properties | 2 + .../hydronode/transform-bron-to-inspire.sql | 44 ++ .../etl/theme/hydronode/validator.messages | 57 +++ .../main/sql/create-bron-schema-hydronode.sql | 20 + .../sql/populate-manager-schema-hydronode.sql | 12 + .../populate-metadata-schema-hydrography.sql | 83 ++++ .../ProductionFacilityValidatorTest.java | 392 ++++++++++++++++++ .../theme/hydronode/ValidatorsValidTest.java | 16 + theme-watercourselink/pom.xml | 42 ++ .../src/main/assembly/assembly-sql.xml | 18 + .../src/main/feeds/datasettypecodes.xml | 33 ++ .../etl/theme/watercourselink/Context.java | 15 + .../etl/theme/watercourselink/Message.java | 114 +++++ .../watercourselink/WatercourseLink.java | 208 ++++++++++ .../WatercourseLinkValidator.java | 319 ++++++++++++++ .../watercourselink/config/DatasetConfig.java | 60 +++ .../theme/watercourselink/config/Package.java | 4 + .../theme/watercourselink/messages.properties | 2 + .../transform-bron-to-inspire.sql | 44 ++ .../theme/watercourselink/validator.messages | 57 +++ .../create-bron-schema-watercourselink.sql | 20 + ...opulate-manager-schema-watercourselink.sql | 12 + .../watercourselink/ValidatorsValidTest.java | 16 + .../WatercourseLinkValidatorTest.java | 392 ++++++++++++++++++ 35 files changed, 2804 insertions(+), 7 deletions(-) create mode 100644 theme-hydronode/pom.xml create mode 100644 theme-hydronode/src/main/assembly/assembly-sql.xml create mode 100644 theme-hydronode/src/main/feeds/datasettypecodes.xml create mode 100644 theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/Context.java create mode 100644 theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/HydroNode.java create mode 100644 theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/HydroNodeValidator.java create mode 100644 theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/Message.java create mode 100644 theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/config/DatasetConfig.java create mode 100644 theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/config/Package.java create mode 100644 theme-hydronode/src/main/resources/nl/ipo/cds/etl/theme/hydronode/messages.properties create mode 100644 theme-hydronode/src/main/resources/nl/ipo/cds/etl/theme/hydronode/transform-bron-to-inspire.sql create mode 100644 theme-hydronode/src/main/resources/nl/ipo/cds/etl/theme/hydronode/validator.messages create mode 100644 theme-hydronode/src/main/sql/create-bron-schema-hydronode.sql create mode 100644 theme-hydronode/src/main/sql/populate-manager-schema-hydronode.sql create mode 100644 theme-hydronode/src/main/sql/populate-metadata-schema-hydrography.sql create mode 100644 theme-hydronode/src/test/java/nl/ipo/cds/etl/theme/hydronode/ProductionFacilityValidatorTest.java create mode 100644 theme-hydronode/src/test/java/nl/ipo/cds/etl/theme/hydronode/ValidatorsValidTest.java create mode 100644 theme-watercourselink/pom.xml create mode 100644 theme-watercourselink/src/main/assembly/assembly-sql.xml create mode 100644 theme-watercourselink/src/main/feeds/datasettypecodes.xml create mode 100644 theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/Context.java create mode 100644 theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/Message.java create mode 100644 theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLink.java create mode 100644 theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLinkValidator.java create mode 100644 theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/config/DatasetConfig.java create mode 100644 theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/config/Package.java create mode 100644 theme-watercourselink/src/main/resources/nl/ipo/cds/etl/theme/watercourselink/messages.properties create mode 100644 theme-watercourselink/src/main/resources/nl/ipo/cds/etl/theme/watercourselink/transform-bron-to-inspire.sql create mode 100644 theme-watercourselink/src/main/resources/nl/ipo/cds/etl/theme/watercourselink/validator.messages create mode 100644 theme-watercourselink/src/main/sql/create-bron-schema-watercourselink.sql create mode 100644 theme-watercourselink/src/main/sql/populate-manager-schema-watercourselink.sql create mode 100644 theme-watercourselink/src/test/java/nl/ipo/cds/etl/theme/watercourselink/ValidatorsValidTest.java create mode 100644 theme-watercourselink/src/test/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLinkValidatorTest.java diff --git a/admin/src/main/resources/nl/ipo/cds/admin/admin-securityContext.xml b/admin/src/main/resources/nl/ipo/cds/admin/admin-securityContext.xml index 7c24ecaa..d6245970 100644 --- a/admin/src/main/resources/nl/ipo/cds/admin/admin-securityContext.xml +++ b/admin/src/main/resources/nl/ipo/cds/admin/admin-securityContext.xml @@ -15,17 +15,17 @@ http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> - - - - - + + + + + - + diff --git a/pom.xml b/pom.xml index 73a0ccaa..d9cb6cd4 100644 --- a/pom.xml +++ b/pom.xml @@ -579,12 +579,14 @@ theme-areamanagement theme-exposedelements theme-habitat + theme-hydronode theme-hazardarea theme-productionfacility theme-productioninstallation theme-productioninstallationpart theme-protectedsites theme-riskzone + theme-watercourselink validation - \ No newline at end of file + diff --git a/theme-hydronode/pom.xml b/theme-hydronode/pom.xml new file mode 100644 index 00000000..218a3242 --- /dev/null +++ b/theme-hydronode/pom.xml @@ -0,0 +1,42 @@ + + 4.0.0 + + nl.ipo.cds + cds-parent + 2.2-SNAPSHOT + + theme-hydronode + CDS - Theme HydroNode + + + + maven-assembly-plugin + + + + single + + package + + + + true + + src/main/assembly/assembly-sql.xml + + + + + + + + nl.ipo.cds + etl-proces + + + nl.ipo.cds + etl-test + test + + + diff --git a/theme-hydronode/src/main/assembly/assembly-sql.xml b/theme-hydronode/src/main/assembly/assembly-sql.xml new file mode 100644 index 00000000..922dd489 --- /dev/null +++ b/theme-hydronode/src/main/assembly/assembly-sql.xml @@ -0,0 +1,18 @@ + + + sql + + zip + + false + + + + src/main/sql + sql + + **/*.* + + + + \ No newline at end of file diff --git a/theme-hydronode/src/main/feeds/datasettypecodes.xml b/theme-hydronode/src/main/feeds/datasettypecodes.xml new file mode 100644 index 00000000..a4f6e599 --- /dev/null +++ b/theme-hydronode/src/main/feeds/datasettypecodes.xml @@ -0,0 +1,33 @@ + + + + http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility + DatasetTypeCode Production Facility + + + http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility/lgrinr + LGR Inrichtingen + + + + http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility/lgrins + LGR Installaties + + + + http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility/lgrput + LGR Put + + + + http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility/lgrlus + LGR Bodemlus + + + + http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility/rkinr + Risicokaart Inrichtingen + + + + diff --git a/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/Context.java b/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/Context.java new file mode 100644 index 00000000..e7ed2acc --- /dev/null +++ b/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/Context.java @@ -0,0 +1,15 @@ +package nl.ipo.cds.etl.theme.hydronode; + +import nl.ipo.cds.validation.DefaultValidatorContext; +import nl.ipo.cds.validation.ValidationReporter; +import nl.ipo.cds.validation.gml.codelists.CodeListFactory; + +public class Context extends DefaultValidatorContext { + + public Context ( + final CodeListFactory codeListFactory, + final ValidationReporter reporter) { + super (codeListFactory, reporter); + } + +} diff --git a/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/HydroNode.java b/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/HydroNode.java new file mode 100644 index 00000000..8edc32b2 --- /dev/null +++ b/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/HydroNode.java @@ -0,0 +1,208 @@ +package nl.ipo.cds.etl.theme.hydronode; + +import nl.ipo.cds.etl.PersistableFeature; +import nl.ipo.cds.etl.db.annotation.Column; +import nl.ipo.cds.etl.db.annotation.Table; +import nl.ipo.cds.etl.theme.annotation.CodeSpace; +import nl.ipo.cds.etl.theme.annotation.MappableAttribute; + +import org.deegree.commons.tom.ows.CodeType; +import org.deegree.geometry.Geometry; + +@Table(name = "hydro_node", schema = "bron") +public class HydroNode extends PersistableFeature { + + @Column(name = "inspire_id_dataset_code") + private CodeType inspireIdDatasetCode; + + @Column(name = "inspire_id_local_id") + private String inspireIdLocalId; + + @Column(name = "production_facility_id") + private String productionFacilityId; + + @Column(name = "thematic_identifier") + private String thematicIdentifier; + + @Column(name = "thematic_identifier_scheme") + private String thematicIdentifierScheme; + + @Column(name = "geometry") + private Geometry geometry; + + @Column(name = "function_activity") + private CodeType functionActivity; + + @Column(name = "function_input") + private CodeType functionInput; + + @Column(name = "function_output") + private CodeType functionOutput; + + @Column(name = "function_description") + private String functionDescription; + + @Column(name = "name") + private String name; + + @Column(name = "surface_geometry") + private Geometry surfaceGeometry; + + @Column(name = "status_type") + private CodeType statusType; + + @Column(name = "status_description") + private String statusDescription; + + + @MappableAttribute + @CodeSpace("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility") + public CodeType getInspireIdDatasetCode() { + return inspireIdDatasetCode; + } + + @MappableAttribute + @CodeSpace("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility") + public void setInspireIdDatasetCode(CodeType inspireIdDatasetCode) { + this.inspireIdDatasetCode = inspireIdDatasetCode; + } + + @MappableAttribute + public String getInspireIdLocalId() { + return inspireIdLocalId; + } + + @MappableAttribute + public void setInspireIdLocalId(String inspireIdLocalId) { + this.inspireIdLocalId = inspireIdLocalId; + } + + @MappableAttribute + public Geometry getGeometry() { + return geometry; + } + + @MappableAttribute + public void setGeometry(Geometry geometry) { + this.geometry = geometry; + } + + @MappableAttribute + public String getProductionFacilityId() { + return productionFacilityId; + } + + @MappableAttribute + public void setProductionFacilityId(String productionFacilityId) { + this.productionFacilityId = productionFacilityId; + } + + @MappableAttribute + public String getThematicIdentifier() { + return thematicIdentifier; + } + + @MappableAttribute + public void setThematicIdentifier(String thematicIdentifier) { + this.thematicIdentifier = thematicIdentifier; + } + + @MappableAttribute + public String getThematicIdentifierScheme() { + return thematicIdentifierScheme; + } + + @MappableAttribute + public void setThematicIdentifierScheme(String thematicIdentifierScheme) { + this.thematicIdentifierScheme = thematicIdentifierScheme; + } + + @MappableAttribute + @CodeSpace("http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue") + public CodeType getFunctionActivity() { + return functionActivity; + } + + @MappableAttribute + @CodeSpace("http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue") + public void setFunctionActivity(CodeType functionActivity) { + this.functionActivity = functionActivity; + } + + @MappableAttribute + @CodeSpace("http://inspire.ec.europa.eu/codeList/ProductCPAValue") + public CodeType getFunctionInput() { + return functionInput; + } + + @MappableAttribute + @CodeSpace("http://inspire.ec.europa.eu/codeList/ProductCPAValue") + public void setFunctionInput(CodeType functionInput) { + this.functionInput = functionInput; + } + + @MappableAttribute + @CodeSpace("http://inspire.ec.europa.eu/codeList/ProductCPAValue") + public CodeType getFunctionOutput() { + return functionOutput; + } + + @MappableAttribute + @CodeSpace("http://inspire.ec.europa.eu/codeList/ProductCPAValue") + public void setFunctionOutput(CodeType functionOutput) { + this.functionOutput = functionOutput; + } + + @MappableAttribute + public String getFunctionDescription() { + return functionDescription; + } + + @MappableAttribute + public void setFunctionDescription(String functionDescription) { + this.functionDescription = functionDescription; + } + + @MappableAttribute + public String getName() { + return name; + } + + @MappableAttribute + public void setName(String name) { + this.name = name; + } + + @MappableAttribute + public Geometry getSurfaceGeometry() { + return surfaceGeometry; + } + + @MappableAttribute + public void setSurfaceGeometry(Geometry surfaceGeometry) { + this.surfaceGeometry = surfaceGeometry; + } + + @MappableAttribute + @CodeSpace("http://inspire.ec.europa.eu/codeList/ConditionOfFacilityValue") + public CodeType getStatusType() { + return statusType; + } + + @MappableAttribute + @CodeSpace("http://inspire.ec.europa.eu/codeList/ConditionOfFacilityValue") + public void setStatusType(CodeType statusType) { + this.statusType = statusType; + } + + @MappableAttribute + public String getStatusDescription() { + return statusDescription; + } + + @MappableAttribute + public void setStatusDescription(String statusDescription) { + this.statusDescription = statusDescription; + } + +} diff --git a/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/HydroNodeValidator.java b/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/HydroNodeValidator.java new file mode 100644 index 00000000..7e2cb280 --- /dev/null +++ b/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/HydroNodeValidator.java @@ -0,0 +1,319 @@ +package nl.ipo.cds.etl.theme.hydronode; + +import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_CODE_CODESPACE_INVALID; +import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_CODE_INVALID; +import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_EMPTY; +import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_GROUP_INCONSISTENT; +import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_NULL; +import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_DISCONTINUITY; +import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_EMPTY_MULTIGEOMETRY; +import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_EXTERIOR_RING_CW; +import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_INTERIOR_DISCONNECTED; +import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_INTERIOR_RINGS_TOUCH; +import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_INTERIOR_RINGS_WITHIN; +import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_INTERIOR_RING_CCW; +import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_INTERIOR_RING_OUTSIDE_EXTERIOR; +import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_INTERIOR_RING_TOUCHES_EXTERIOR; +import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE; +import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_POINT_DUPLICATION; +import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_RING_NOT_CLOSED; +import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_RING_SELF_INTERSECTION; +import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_SELF_INTERSECTION; +import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_SRS_NOT_RD; +import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_SRS_NULL; + +import java.util.Map; + +import nl.ipo.cds.domain.EtlJob; +import nl.ipo.cds.etl.AbstractValidator; +import nl.ipo.cds.validation.AttributeExpression; +import nl.ipo.cds.validation.ValidationReporter; +import nl.ipo.cds.validation.Validator; +import nl.ipo.cds.validation.constants.Constant; +import nl.ipo.cds.validation.execute.CompilerException; +import nl.ipo.cds.validation.geometry.GeometryExpression; +import nl.ipo.cds.validation.gml.CodeExpression; +import nl.ipo.cds.validation.gml.codelists.CodeListFactory; + +import org.deegree.geometry.Geometry; + +public class HydroNodeValidator extends AbstractValidator { + + private final CodeExpression inspireIdDatasetCode = code ("inspireIdDatasetCode"); + + private final AttributeExpression inspireIdLocalId = stringAttr ("inspireIdLocalId"); + + private final AttributeExpression productionFacilityId = stringAttr ("productionFacilityId"); + + private final AttributeExpression thematicIdentifier = stringAttr ("thematicIdentifier"); + + private final AttributeExpression thematicIdentifierScheme = stringAttr ("thematicIdentifierScheme"); + + private final GeometryExpression geometry = geometry ("geometry"); + + private final CodeExpression functionActivity = code ("functionActivity"); + + private final CodeExpression functionInput = code ("functionInput"); + + private final CodeExpression functionOutput = code ("functionOutput"); + + private final AttributeExpression functionDescription = stringAttr ("functionDescription"); + + private final AttributeExpression name = stringAttr ("name"); + + private final GeometryExpression surfaceGeometry = geometry ("surfaceGeometry"); + + private final AttributeExpression statusDescription = stringAttr ("statusDescription"); + + private final CodeExpression statusType = code ("statusType"); + + private final Constant inspireIdDatasetCodeSpace = constant ("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility"); + + private final Constant functionActivityCodeSpace = constant ("http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue"); + + private final Constant functionInputCodeSpace = constant ("http://inspire.ec.europa.eu/codeList/ProductCPAValue"); + + private final Constant functionOutputCodeSpace = constant ("http://inspire.ec.europa.eu/codeList/ProductCPAValue"); + + private final Constant statusTypeCodeSpace = constant ("http://inspire.ec.europa.eu/codeList/ConditionOfFacilityValue"); + + public HydroNodeValidator(final Map validatorMessages) throws CompilerException { + super(Context.class, HydroNode.class, validatorMessages); + compile(); + } + + @Override + public Context beforeJob(final EtlJob job, final CodeListFactory codeListFactory, + final ValidationReporter reporter) { + return new Context(codeListFactory, reporter); + } + + public Validator getInspireIdDatasetCodeValidator () { + return validate ( + and( + validate (not (inspireIdDatasetCode.isNull ())).message (ATTRIBUTE_NULL, constant (inspireIdDatasetCode.name)), + validate (not (isBlank (inspireIdDatasetCode.code()))).message (ATTRIBUTE_EMPTY, constant (inspireIdDatasetCode.name)), + validate (inspireIdDatasetCode.hasCodeSpace (inspireIdDatasetCodeSpace)).message (ATTRIBUTE_CODE_CODESPACE_INVALID, inspireIdDatasetCode.codeSpace(), constant(inspireIdDatasetCode.name), inspireIdDatasetCodeSpace), + validate (inspireIdDatasetCode.isValid ()).message (ATTRIBUTE_CODE_INVALID, inspireIdDatasetCode.code(), constant (inspireIdDatasetCode.name), inspireIdDatasetCodeSpace) + ).shortCircuit() + ); + } + + public Validator getInspireIdLocalIdValidator () { + return validate ( + and( + validate (not (inspireIdLocalId.isNull ())).message (ATTRIBUTE_NULL, constant(inspireIdLocalId.name)), + validate (not (isBlank (inspireIdLocalId))).message (ATTRIBUTE_EMPTY, constant(inspireIdLocalId.name)) + ).shortCircuit() + ); + } + + public Validator getProductionFacilityIdValidator () { + return validate ( + and( + validate (not (productionFacilityId.isNull ())).message (ATTRIBUTE_NULL, constant(productionFacilityId.name)), + validate (not (isBlank (productionFacilityId))).message (ATTRIBUTE_EMPTY, constant(productionFacilityId.name)) + ).shortCircuit() + ); + } + + public Validator getThematicIdentifierValidator () { + return validate ( + and( + ifExp (not (or (thematicIdentifier.isNull (), isBlank (thematicIdentifier))), + and ( + validate (not (thematicIdentifierScheme.isNull())).message (ATTRIBUTE_GROUP_INCONSISTENT, constant (thematicIdentifierScheme.name), constant (thematicIdentifier.name)), + validate (not (isBlank (thematicIdentifierScheme))).message (ATTRIBUTE_GROUP_INCONSISTENT, constant (thematicIdentifierScheme.name), constant (thematicIdentifier.name)) + ).shortCircuit(), + constant(true) + ), + ifExp (not (or (thematicIdentifierScheme.isNull (), isBlank (thematicIdentifierScheme))), + and ( + validate (not (thematicIdentifier.isNull())).message (ATTRIBUTE_GROUP_INCONSISTENT, constant (thematicIdentifier.name), constant (thematicIdentifierScheme.name)), + validate (not (isBlank (thematicIdentifier))).message (ATTRIBUTE_GROUP_INCONSISTENT, constant (thematicIdentifier.name), constant (thematicIdentifierScheme.name)) + ).shortCircuit(), + constant(true) + ) + ) + ); + } + + public Validator getGeometryValidator () { + return validate ( + and ( + // The following validations short-circuit, there must be a non-null and non-empty, non-point geometry: + validate (not (geometry.isNull ())).message (ATTRIBUTE_NULL, constant(geometry.name)), + // Non short-circuited validations: + and ( + // Short circuit to prevent the interiorDisconnected validation if + // any of the other validations fail: + and ( + and ( + validate (not (geometry.hasCurveDuplicatePoint ())).message (GEOMETRY_POINT_DUPLICATION, lastLocation ()), + validate (not (geometry.hasCurveDiscontinuity ())).message (GEOMETRY_DISCONTINUITY), + validate (not (geometry.hasCurveSelfIntersection ())).message (GEOMETRY_SELF_INTERSECTION, lastLocation ()), + validate (not (geometry.hasUnclosedRing ())).message (GEOMETRY_RING_NOT_CLOSED), + validate (not (geometry.hasRingSelfIntersection ())).message (GEOMETRY_RING_SELF_INTERSECTION, lastLocation ()), + validate (not (geometry.hasTouchingInteriorRings ())).message(GEOMETRY_INTERIOR_RINGS_TOUCH, lastLocation ()), + validate (not (geometry.hasInteriorRingsWithin ())).message (GEOMETRY_INTERIOR_RINGS_WITHIN) + ), + validate (not (geometry.isInteriorDisconnected ())).message (GEOMETRY_INTERIOR_DISCONNECTED) + ).shortCircuit (), + + // Non-blocking validations: + validate (not (geometry.hasExteriorRingCW ())).nonBlocking ().message (GEOMETRY_EXTERIOR_RING_CW), + validate (not (geometry.hasInteriorRingCCW ())).nonBlocking ().message (GEOMETRY_INTERIOR_RING_CCW), + validate (not (geometry.hasInteriorRingTouchingExterior ())).nonBlocking ().message (GEOMETRY_INTERIOR_RING_TOUCHES_EXTERIOR, lastLocation ()), + validate (not (geometry.hasInteriorRingOutsideExterior ())).nonBlocking ().message (GEOMETRY_INTERIOR_RING_OUTSIDE_EXTERIOR), + + // SRS validations: + and ( + validate (geometry.hasSrs ()).message (GEOMETRY_SRS_NULL), + validate (geometry.isSrs (constant ("28992"))).message (GEOMETRY_SRS_NOT_RD, geometry.srsName ()) + ).shortCircuit() + ) + ).shortCircuit () + ); + } + + public Validator getFunctionActivityValidator () { + return validate ( + and( + validate (not (functionActivity.isNull ())).message (ATTRIBUTE_NULL, constant(functionActivity.name)), + validate (functionActivity.hasCodeSpace (functionActivityCodeSpace)).message (ATTRIBUTE_CODE_CODESPACE_INVALID, functionActivity.codeSpace(), constant(functionActivity.name), functionActivityCodeSpace), + validate (not (isBlank (functionActivity.code()))).message (ATTRIBUTE_EMPTY, constant(functionActivity.name)) + // must be deactivated as long as codelist http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue is empty +// validate (functionActivity.isValid ()).message (ATTRIBUTE_CODE_INVALID, functionActivity.code(), constant(functionActivity.name), functionActivityCodeSpace) + ).shortCircuit() + ); + } + + public Validator getFunctionInputValidator () { + return validate ( + ifExp ( + functionInput.isNull (), + constant(true), + and( + validate (functionInput.hasCodeSpace (functionInputCodeSpace)).message (ATTRIBUTE_CODE_CODESPACE_INVALID, functionInput.codeSpace(), constant(functionInput.name), functionInputCodeSpace), + validate (not (isBlank (functionInput.code()))).message (ATTRIBUTE_EMPTY, constant(functionInput.name)) + // must be deactivated as long as codelist http://inspire.ec.europa.eu/codeList/ProductCPAValue is empty +// validate (functionInput.isValid ()).message (ATTRIBUTE_CODE_INVALID, functionInput.code(), constant(functionInput.name), functionInputCodeSpace) + ).shortCircuit() + ) + ); + } + + public Validator getFunctionOutputValidator () { + return validate ( + ifExp ( + functionOutput.isNull (), + constant(true), + and( + validate (functionOutput.hasCodeSpace (functionOutputCodeSpace)).message (ATTRIBUTE_CODE_CODESPACE_INVALID, functionOutput.codeSpace(), constant(functionOutput.name), functionOutputCodeSpace), + validate (not (isBlank (functionOutput.code()))).message (ATTRIBUTE_EMPTY, constant(functionOutput.name)) + // must be deactivated as long as codelist http://inspire.ec.europa.eu/codeList/ProductCPAValue is empty +// validate (functionOutput.isValid ()).message (ATTRIBUTE_CODE_INVALID, functionOutput.code(), constant(functionOutput.name), functionOutputCodeSpace) + ).shortCircuit() + ) + ); + } + + public Validator getFunctionDescriptionValidator () { + return validate ( + ifExp ( + functionDescription.isNull (), + constant(true), + validate (not (isBlank (functionDescription))).message (ATTRIBUTE_EMPTY, constant(functionDescription.name)) + ) + ); + } + + public Validator getNameValidator () { + return validate ( + ifExp ( + name.isNull (), + constant(true), + validate (not (isBlank (name))).message (ATTRIBUTE_EMPTY, constant(name.name)) + ) + ); + } + + public Validator getSurfaceGeometryValidator () { + return validate ( + ifExp( + surfaceGeometry.isNull (), + constant(true), + and ( + // The following validations short-circuit, there must be a non-empty, Surface geometry: + validate (not (surfaceGeometry.isEmptyMultiGeometry())).message (GEOMETRY_EMPTY_MULTIGEOMETRY), + validate (surfaceGeometry.isSurfaceOrMultiSurface()).message (GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE), + // Non short-circuited validations: + and ( + // Short circuit to prevent the interiorDisconnected validation if + // any of the other validations fail: + and ( + and ( + validate (not (surfaceGeometry.hasCurveDuplicatePoint ())).message (GEOMETRY_POINT_DUPLICATION, lastLocation ()), + validate (not (surfaceGeometry.hasCurveDiscontinuity ())).message (GEOMETRY_DISCONTINUITY), + validate (not (surfaceGeometry.hasCurveSelfIntersection ())).message (GEOMETRY_SELF_INTERSECTION, lastLocation ()), + validate (not (surfaceGeometry.hasUnclosedRing ())).message (GEOMETRY_RING_NOT_CLOSED), + validate (not (surfaceGeometry.hasRingSelfIntersection ())).message (GEOMETRY_RING_SELF_INTERSECTION, lastLocation ()), + validate (not (surfaceGeometry.hasTouchingInteriorRings ())).message(GEOMETRY_INTERIOR_RINGS_TOUCH, lastLocation ()), + validate (not (surfaceGeometry.hasInteriorRingsWithin ())).message (GEOMETRY_INTERIOR_RINGS_WITHIN) + ), + validate (not (surfaceGeometry.isInteriorDisconnected ())).message (GEOMETRY_INTERIOR_DISCONNECTED) + ).shortCircuit (), + + // Non-blocking validations: + validate (not (surfaceGeometry.hasExteriorRingCW ())).nonBlocking ().message (GEOMETRY_EXTERIOR_RING_CW), + validate (not (surfaceGeometry.hasInteriorRingCCW ())).nonBlocking ().message (GEOMETRY_INTERIOR_RING_CCW), + validate (not (surfaceGeometry.hasInteriorRingTouchingExterior ())).nonBlocking ().message (GEOMETRY_INTERIOR_RING_TOUCHES_EXTERIOR, lastLocation ()), + validate (not (surfaceGeometry.hasInteriorRingOutsideExterior ())).nonBlocking ().message (GEOMETRY_INTERIOR_RING_OUTSIDE_EXTERIOR), + + // SRS validations: + and ( + validate (surfaceGeometry.hasSrs ()).message (GEOMETRY_SRS_NULL), + validate (surfaceGeometry.isSrs (constant ("28992"))).message (GEOMETRY_SRS_NOT_RD, surfaceGeometry.srsName ()) + ).shortCircuit() + ) + ).shortCircuit () + ) + ); + } + + public Validator getStatusValidator () { + return validate ( + not ( + and ( + statusType.isNull(), + not (statusDescription.isNull()) + ) + ) + ).message (ATTRIBUTE_GROUP_INCONSISTENT, constant(statusType.name), constant(statusDescription.name)); + } + + public Validator getStatusDescriptionValidator () { + return validate ( + ifExp ( + statusDescription.isNull (), + constant(true), + validate (not (isBlank (statusDescription))).message (ATTRIBUTE_EMPTY, constant(statusDescription.name)) + ) + ); + } + + public Validator getStatusTypeValidator () { + return validate ( + ifExp ( + statusType.isNull (), + constant(true), + and( + validate (statusType.hasCodeSpace (statusTypeCodeSpace)).message (ATTRIBUTE_CODE_CODESPACE_INVALID, statusType.codeSpace(), constant(statusType.name), statusTypeCodeSpace), + validate (not (isBlank (statusType.code()))).message (ATTRIBUTE_EMPTY, constant(statusType.name)), + validate (statusType.isValid ()).message (ATTRIBUTE_CODE_INVALID, statusType.code(), constant(statusType.name), statusTypeCodeSpace) + ).shortCircuit() + ) + ); + } + +} diff --git a/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/Message.java b/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/Message.java new file mode 100644 index 00000000..dbbb5eb8 --- /dev/null +++ b/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/Message.java @@ -0,0 +1,114 @@ +package nl.ipo.cds.etl.theme.hydronode; + +import java.util.ArrayList; +import java.util.List; + +import nl.idgis.commons.jobexecutor.JobLogger.LogLevel; +import nl.ipo.cds.etl.ValidatorMessageKey; +import nl.ipo.cds.validation.AttributeExpression; +import nl.ipo.cds.validation.Expression; + +public enum Message implements ValidatorMessageKey { + + ATTRIBUTE_NULL, + ATTRIBUTE_EMPTY, + ATTRIBUTE_NOT_URL, + ATTRIBUTE_VALUE_NEGATIVE, + ATTRIBUTE_VALUE_TOO_LOW, + ATTRIBUTE_VALUE_TOO_HIGH, + ATTRIBUTE_CODE_CODESPACE_INVALID, + ATTRIBUTE_CODE_INVALID, + ATTRIBUTE_GROUP_INCONSISTENT, + + GEOMETRY_EMPTY_MULTIGEOMETRY, + GEOMETRY_ONLY_POINT_OR_MULTIPOINT, + GEOMETRY_ONLY_CURVE_OR_MULTICURVE, + GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE, + GEOMETRY_POINT_NOT_ALLOWED, + GEOMETRY_POINT_DUPLICATION(Integer.MAX_VALUE, true), + GEOMETRY_EXTERIOR_RING_CW(LogLevel.WARNING), + GEOMETRY_INTERIOR_RING_CCW(LogLevel.WARNING), + GEOMETRY_DISCONTINUITY(Integer.MAX_VALUE, true), + GEOMETRY_SELF_INTERSECTION(Integer.MAX_VALUE, true), + GEOMETRY_RING_NOT_CLOSED(Integer.MAX_VALUE, true), + GEOMETRY_RING_SELF_INTERSECTION(Integer.MAX_VALUE, true), + GEOMETRY_INTERIOR_RINGS_TOUCH(Integer.MAX_VALUE, true), + GEOMETRY_INTERIOR_RINGS_INTERSECT(Integer.MAX_VALUE, true), + GEOMETRY_INTERIOR_RINGS_WITHIN(Integer.MAX_VALUE, true), + GEOMETRY_INTERIOR_RING_TOUCHES_EXTERIOR(Integer.MAX_VALUE, true), + GEOMETRY_INTERIOR_RING_INTERSECTS_EXTERIOR(Integer.MAX_VALUE, true), + GEOMETRY_INTERIOR_RING_OUTSIDE_EXTERIOR(Integer.MAX_VALUE, true), + GEOMETRY_INTERIOR_DISCONNECTED(Integer.MAX_VALUE, true), + GEOMETRY_SRS_NULL, + GEOMETRY_SRS_NOT_RD("EPSG:28992"), + + HAS_MORE_ERRORS(LogLevel.WARNING) + ; + + private final String[] params; + + private final LogLevel logLevel; + + private final int maxMessageLog; + + private final boolean addToShapeFile; + + private Message(LogLevel logLevel, Integer maxMessageLog, boolean addToShapeFile, String... params) { + this.maxMessageLog = maxMessageLog == null ? 10 : maxMessageLog; + this.logLevel = logLevel == null ? LogLevel.ERROR : logLevel; + this.addToShapeFile = addToShapeFile; + this.params = params; + } + + private Message(LogLevel logLevel, Integer maxMessageLog, String... params) { + this(logLevel, maxMessageLog, false, params); + } + + private Message(Integer maxMessageLog, boolean addToShapeFile, String... params) { + this(null, maxMessageLog, addToShapeFile, params); + } + + private Message(LogLevel logLevel) { + this(logLevel, null, false); + } + + private Message(String... params) { + this(null, null, false, params); + } + + @Override + public boolean isBlocking() { + return getLogLevel ().equals (LogLevel.ERROR); + } + + @Override + public List> getMessageParameters () { + final List> params = new ArrayList<> (); + // why twice??? + params.add (new AttributeExpression ("id", String.class)); + params.add (new AttributeExpression ("id", String.class)); + params.add (new AttributeExpression ("inspireIdLocalId", String.class)); + return params; + } + + @Override + public int getMaxMessageLog() { + return maxMessageLog; + } + + @Override + public boolean isAddToShapeFile () { + return addToShapeFile; + } + + @Override + public LogLevel getLogLevel() { + return logLevel; + } + + @Override + public Message getMaxMessageKey() { + return HAS_MORE_ERRORS; + } + +} diff --git a/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/config/DatasetConfig.java b/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/config/DatasetConfig.java new file mode 100644 index 00000000..186e58ee --- /dev/null +++ b/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/config/DatasetConfig.java @@ -0,0 +1,60 @@ +package nl.ipo.cds.etl.theme.hydronode.config; + +import java.util.Properties; + +import javax.inject.Inject; +import javax.inject.Named; + +import nl.ipo.cds.attributemapping.operations.discover.OperationDiscoverer; +import nl.ipo.cds.etl.Transformer; +import nl.ipo.cds.etl.theme.DefaultThemeConfig; +import nl.ipo.cds.etl.theme.ThemeConfig; +import nl.ipo.cds.etl.theme.hydronode.HydroNode; +import nl.ipo.cds.etl.theme.hydronode.HydroNodeValidator; +import nl.ipo.cds.etl.util.ScriptExecutor; +import nl.ipo.cds.etl.util.ScriptTransformer; +import nl.ipo.cds.validation.execute.CompilerException; + +import org.springframework.beans.factory.config.PropertiesFactoryBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.ClassPathResource; + +@Configuration (value = "hydroNode.DatasetConfig") +public class DatasetConfig { + + private static final String THEME_NAME = "HydroNode"; + + @Bean + @Inject + public ThemeConfig hydroNodeThemeConfig ( + final HydroNodeValidator validator, + final OperationDiscoverer operationDiscoverer) { + return new DefaultThemeConfig (THEME_NAME, HydroNode.class, validator, operationDiscoverer); + } + + @Bean + public Transformer hydroNodeTransformer(final ScriptExecutor scriptExecutor) { + return new ScriptTransformer(scriptExecutor, new ClassPathResource ("nl/ipo/cds/etl/theme/hydronode/transform-bron-to-inspire.sql"), THEME_NAME); + } + + @Configuration (value = "hydroNode.Validators") + public static class Validators { + @Bean + @Inject + public HydroNodeValidator hydroNodeValidator ( + final @Named ("hydroNodeValidationMessages") Properties validatorMessages) throws CompilerException { + return new HydroNodeValidator (validatorMessages); + } + } + + @Configuration (value = "hydroNode.Messages") + public static class Messages { + @Bean + public PropertiesFactoryBean hydroNodeValidationMessages () { + final PropertiesFactoryBean properties = new PropertiesFactoryBean (); + properties.setLocation (new ClassPathResource ("nl/ipo/cds/etl/theme/hydronode/validator.messages")); + return properties; + } + } +} diff --git a/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/config/Package.java b/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/config/Package.java new file mode 100644 index 00000000..e6af9ab7 --- /dev/null +++ b/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/config/Package.java @@ -0,0 +1,4 @@ +package nl.ipo.cds.etl.theme.hydronode.config; + +public interface Package { +} diff --git a/theme-hydronode/src/main/resources/nl/ipo/cds/etl/theme/hydronode/messages.properties b/theme-hydronode/src/main/resources/nl/ipo/cds/etl/theme/hydronode/messages.properties new file mode 100644 index 00000000..139597f9 --- /dev/null +++ b/theme-hydronode/src/main/resources/nl/ipo/cds/etl/theme/hydronode/messages.properties @@ -0,0 +1,2 @@ + + diff --git a/theme-hydronode/src/main/resources/nl/ipo/cds/etl/theme/hydronode/transform-bron-to-inspire.sql b/theme-hydronode/src/main/resources/nl/ipo/cds/etl/theme/hydronode/transform-bron-to-inspire.sql new file mode 100644 index 00000000..a1f8248e --- /dev/null +++ b/theme-hydronode/src/main/resources/nl/ipo/cds/etl/theme/hydronode/transform-bron-to-inspire.sql @@ -0,0 +1,44 @@ +delete from inspire.production_facility; + +insert into inspire.production_facility ( + id, + job_id, + gfid, + inspire_id_namespace, + inspire_id_local_id, + production_facility_id, + thematic_identifier, + thematic_identifier_scheme, + function_activity, + function_input, + function_output, + function_description, + name, + status_nil_reason, + status_xsi_nil, + status_type, + status_description, + geometry, + surface_geometry + ) +select + id, + job_id, + gfid, + 'NL.' || inspire_id_dataset_code, + inspire_id_local_id, + production_facility_id, + thematic_identifier, + thematic_identifier_scheme, + function_activity, + function_input, + function_output, + function_description, + "name", + CASE WHEN status_type IS NULL THEN 'UNKNOWN' END, + CASE WHEN status_type IS NULL THEN 'true' END, + status_type, + status_description, + geometry, + surface_geometry +from bron.production_facility; diff --git a/theme-hydronode/src/main/resources/nl/ipo/cds/etl/theme/hydronode/validator.messages b/theme-hydronode/src/main/resources/nl/ipo/cds/etl/theme/hydronode/validator.messages new file mode 100644 index 00000000..e663decf --- /dev/null +++ b/theme-hydronode/src/main/resources/nl/ipo/cds/etl/theme/hydronode/validator.messages @@ -0,0 +1,57 @@ +FEATURE=feature: ${0}, inspireIdLocalId: ${1} + +ATTRIBUTE_NULL=Het attribuut "${2}" ontbreekt, ${FEATURE} +ATTRIBUTE_EMPTY=Het attribuut "${2}" is leeg, ${FEATURE} +ATTRIBUTE_NOT_URL=De waarde "${2}" van het attribuut "${3}" is geen valide URL, ${FEATURE} +ATTRIBUTE_VALUE_NEGATIVE=De waarde "${2}" van het attribuut "${3}" is negatief, ${FEATURE} +ATTRIBUTE_CODE_CODESPACE_INVALID=De 'codeSpace' "${2}" van attribuut "${3}" is niet valide (verwacht: "${4}"), ${FEATURE} +ATTRIBUTE_CODE_INVALID=De code "${2}" van het attribuut "${3}" is niet valide met betrekking tot de code-lijst "${4}", ${FEATURE} +ATTRIBUTE_VALUE_TOO_LOW=De waarde "${2}" van het attribuut "${3}" is te laag (limiet "${4}"), ${FEATURE} +ATTRIBUTE_VALUE_TOO_HIGH=De waarde "${2}" van het attribuut "${3}" is te hoog (limiet "${4}"), ${FEATURE} +ATTRIBUTE_GROUP_INCONSISTENT=Het attribuut "${2}" kan niet worden weggelaten, als er één of meerdere andere attributen uit de groep (zoals "${3}") aanwezig zijn, ${FEATURE} + +GEOMETRY_NULL_BASE=geometrie ontbreekt +GEOMETRY_EMPTY_MULTIGEOMETRY_BASE=multi geometrie is leeg +GEOMETRY_ONLY_POINT_OR_MULTIPOINT_BASE=geometrie has wrong type: must be a point (or a multi point) +GEOMETRY_ONLY_CURVE_OR_MULTICURVE_BASE=geometrie has wrong type: must be a linestring (or a multi linestring) +GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE_BASE=geometrie has wrong type: must be a polygon (or a multi polygon) +GEOMETRY_POINT_DUPLICATION_BASE=geometrie bevat duplicaat punten, locatie: ${2} +GEOMETRY_EXTERIOR_RING_CW_BASE=geometrie bevat een buitenring met CW oriëntatie +GEOMETRY_INTERIOR_RING_CCW_BASE=geometrie bevat een binnenring met CCW oriëntatie +GEOMETRY_DISCONTINUITY_BASE=geometrie bevat lijnelementen die niet aansluiten +GEOMETRY_SELF_INTERSECTION_BASE=geometrie bevat een lijn die zichzelf snijdt, locatie: ${2} +GEOMETRY_RING_NOT_CLOSED_BASE=geometrie bevat een niet gesloten ring +GEOMETRY_RING_SELF_INTERSECTION_BASE=geometrie bevat een ring die zichzelf snijdt, locatie: ${2} +GEOMETRY_INTERIOR_RINGS_TOUCH_BASE=geometrie bevat een binnenring die zichzelf raakt, locatie: ${2} +GEOMETRY_INTERIOR_RINGS_INTERSECT_BASE=geometrie bevat een binnenring die zichzelf snijdt, locatie: ${2} +GEOMETRY_INTERIOR_RINGS_WITHIN_BASE=geometrie bevat een binnenring binnen een andere binnenring +GEOMETRY_INTERIOR_RING_TOUCHES_EXTERIOR_BASE=geometrie bevat een binnenring die een buitenring raakt, locatie: ${2} +GEOMETRY_INTERIOR_RING_INTERSECTS_EXTERIOR_BASE=geometrie bevat een binnenring die een buitenring snijdt, locatie: ${2} +GEOMETRY_INTERIOR_RING_OUTSIDE_EXTERIOR_BASE=geometrie bevat een binnenring die niet binnen een buitenring ligt +GEOMETRY_INTERIOR_DISCONNECTED_BASE=geometrie bevat een verbroken polygoon +GEOMETRY_SRS_NULL_BASE=Het attribuut "srsName" ontbreekt bij het geometrie-element +GEOMETRY_SRS_NOT_RD_BASE=Het attribuut "srsName" bij element "geometry" heeft een andere waarde dan "EPSG:28992" (RD_New) + +GEOMETRY_NULL=${GEOMETRY_NULL_BASE}, ${FEATURE} +GEOMETRY_EMPTY_MULTIGEOMETRY=${GEOMETRY_EMPTY_MULTIGEOMETRY_BASE}, ${FEATURE} +GEOMETRY_ONLY_POINT_OR_MULTIPOINT=${GEOMETRY_ONLY_POINT_OR_MULTIPOINT_BASE}, ${FEATURE} +GEOMETRY_ONLY_CURVE_OR_MULTICURVE=${GEOMETRY_ONLY_CURVE_OR_MULTICURVE_BASE}, ${FEATURE} +GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE=${GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE_BASE}, ${FEATURE} +GEOMETRY_POINT_DUPLICATION=${GEOMETRY_POINT_DUPLICATION_BASE}, ${FEATURE} +GEOMETRY_EXTERIOR_RING_CW=${GEOMETRY_EXTERIOR_RING_CW_BASE}, ${FEATURE} +GEOMETRY_INTERIOR_RING_CCW=${GEOMETRY_INTERIOR_RING_CCW_BASE}, ${FEATURE} +GEOMETRY_DISCONTINUITY=${GEOMETRY_DISCONTINUITY_BASE}, ${FEATURE} +GEOMETRY_SELF_INTERSECTION=${GEOMETRY_SELF_INTERSECTION_BASE}, ${FEATURE} +GEOMETRY_RING_NOT_CLOSED=${GEOMETRY_RING_NOT_CLOSED_BASE}, ${FEATURE} +GEOMETRY_RING_SELF_INTERSECTION=${GEOMETRY_RING_SELF_INTERSECTION_BASE}, ${FEATURE} +GEOMETRY_INTERIOR_RINGS_TOUCH=${GEOMETRY_INTERIOR_RINGS_TOUCH_BASE}, ${FEATURE} +GEOMETRY_INTERIOR_RINGS_INTERSECT=${GEOMETRY_INTERIOR_RINGS_INTERSECT_BASE}, ${FEATURE} +GEOMETRY_INTERIOR_RINGS_WITHIN=${GEOMETRY_INTERIOR_RINGS_WITHIN_BASE}, ${FEATURE} +GEOMETRY_INTERIOR_RING_TOUCHES_EXTERIOR=${GEOMETRY_INTERIOR_RING_TOUCHES_EXTERIOR_BASE}, ${FEATURE} +GEOMETRY_INTERIOR_RING_INTERSECTS_EXTERIOR=${GEOMETRY_INTERIOR_RING_INTERSECTS_EXTERIOR_BASE}, ${FEATURE} +GEOMETRY_INTERIOR_RING_OUTSIDE_EXTERIOR=${GEOMETRY_INTERIOR_RING_OUTSIDE_EXTERIOR_BASE}, ${FEATURE} +GEOMETRY_INTERIOR_DISCONNECTED=${GEOMETRY_INTERIOR_DISCONNECTED_BASE}, ${FEATURE} +GEOMETRY_SRS_NULL=${GEOMETRY_SRS_NULL_BASE}, ${FEATURE} +GEOMETRY_SRS_NOT_RD=${GEOMETRY_SRS_NOT_RD_BASE} (gevonden waarde: ${1}), ${FEATURE} + +HAS_MORE_ERRORS=Er zijn meer meldingen die niet werden gerapporteerd diff --git a/theme-hydronode/src/main/sql/create-bron-schema-hydronode.sql b/theme-hydronode/src/main/sql/create-bron-schema-hydronode.sql new file mode 100644 index 00000000..6530b643 --- /dev/null +++ b/theme-hydronode/src/main/sql/create-bron-schema-hydronode.sql @@ -0,0 +1,20 @@ + +create table bron.hydro_node ( + id serial, + job_id bigint, + gfid text, + + inspire_id_dataset_code text not null, + inspire_id_local_id text not null, + + primary key (id), + constraint fk_job_id foreign key (job_id) references manager.job (id) +); +SELECT AddGeometryColumn ('bron','hydro_node','geometry',28992,'GEOMETRY',2); +ALTER TABLE bron.hydro_node ALTER COLUMN "geometry" SET NOT NULL; + +CREATE INDEX idx_bron_hydro_node_geometry ON bron.hydro_node USING GIST (geometry); + +GRANT SELECT, INSERT, UPDATE, DELETE, TRIGGER ON bron.hydro_node TO inspire; +GRANT USAGE, SELECT, UPDATE ON SEQUENCE bron.hydro_node_id_seq TO inspire; +---------------------------------- diff --git a/theme-hydronode/src/main/sql/populate-manager-schema-hydronode.sql b/theme-hydronode/src/main/sql/populate-manager-schema-hydronode.sql new file mode 100644 index 00000000..3b253e31 --- /dev/null +++ b/theme-hydronode/src/main/sql/populate-manager-schema-hydronode.sql @@ -0,0 +1,12 @@ +-- +-- HydroNode +-- +-- Names must match constants defined corresponding ThemeConfig +insert into manager.thema (id, naam) values ((select nextval('manager.hibernate_sequence')), 'HydroNode'); + +insert into manager.datasettype (id, naam, thema_id) values ((select nextval('manager.hibernate_sequence')), 'HydroNetworkNodesNL', (select id from manager.thema t where t.naam = 'HydroNode')); + +insert into manager.bronhouder (id, code, contact_naam, contact_adres, contact_postcode, contact_plaats, naam, contact_emailadres, contact_telefoonnummer, common_name) select nextval('manager.hibernate_sequence'), 'elf', 'ELF Project', '', '', '', 'ELF Project', 'inspire@idgis.nl', '', 'elfproject' where not exists (select * from manager.bronhouder where code = 'elf'); + +insert into manager.themabronhouderauthorization (thema_id, bronhouder_id) values ( (select id from manager.thema where naam = 'HydroNode'), (select id from manager.bronhouder where code = 'elf') ); +-- diff --git a/theme-hydronode/src/main/sql/populate-metadata-schema-hydrography.sql b/theme-hydronode/src/main/sql/populate-metadata-schema-hydrography.sql new file mode 100644 index 00000000..8490cd73 --- /dev/null +++ b/theme-hydronode/src/main/sql/populate-metadata-schema-hydrography.sql @@ -0,0 +1,83 @@ + +-- +-- metadata Hydrography +-- + +-- One serviceprovider for all services of this INSPIRE theme +DELETE FROM metadata.si_keyword where serviceidentification_id IN (select serviceidentification_id from metadata.service where name='view_HY' OR name='download_HY'); +DELETE FROM metadata.si_accessconstraint where serviceidentification_id IN (select serviceidentification_id from metadata.service where name='view_HY' OR name='download_HY'); +DELETE FROM metadata.service_datasetmetadata where service_id IN (select id from metadata.service where name='view_HY' OR name='download_HY'); +DELETE FROM metadata.service where name='view_HY' OR name='download_HY'; +DELETE FROM metadata.serviceidentification where servicepath like '%view_HY%' OR servicepath like '%download_HY%'; +DELETE FROM metadata.extendedcapabilities where metadataurl like '%view_HY%' OR metadataurl like '%download_HY%'; + +DELETE FROM metadata.si_keyword where serviceidentification_id IN (select serviceidentification_id from metadata.service where name='wms_HY_NL' OR name='wfs_HY_NL'); +DELETE FROM metadata.si_accessconstraint where serviceidentification_id IN (select serviceidentification_id from metadata.service where name='wms_HY_NL' OR name='wfs_HY_NL'); +DELETE FROM metadata.service_datasetmetadata where service_id IN (select id from metadata.service where name='wms_HY_NL' OR name='wfs_HY_NL'); +DELETE FROM metadata.service where name='wms_HY_NL' OR name='wfs_HY_NL'; +DELETE FROM metadata.serviceidentification where servicepath like '%wms_HY_NL%' OR servicepath like '%wfs_HY_NL%'; +DELETE FROM metadata.extendedcapabilities where metadataurl like '%wms_HY_NL%' OR metadataurl like '%wfs_HY_NL%'; + +DELETE FROM metadata.sp_deliverypoint where serviceprovider_id IN (select id from metadata.serviceprovider where individualname like '%Hydrography%'); +DELETE FROM metadata.sp_emailaddress where serviceprovider_id IN (select id from metadata.serviceprovider where individualname like '%Hydrography%'); +DELETE FROM metadata.sp_faxnumber where serviceprovider_id IN (select id from metadata.serviceprovider where individualname like '%Hydrography%'); +DELETE FROM metadata.sp_phonenumber where serviceprovider_id IN (select id from metadata.serviceprovider where individualname like '%Hydrography%'); +DELETE FROM metadata.serviceprovider where individualname like '%Hydrography%'; + +INSERT INTO metadata.serviceprovider (id,administrativearea,city,contactinstructions,country,hoursofservice,individualname,onlineresource,organizationname,positionname,postalcode,providername,providersite,role) + VALUES ((select nextval('metadata.hibernate_sequence')), '', '', NULL, '', NULL, 'Functioneel beheerder, Hydrography', NULL, 'ELF Project', 'pointOfContact', '', NULL, NULL, NULL); + +-- INSPIRE View and Download service + +INSERT INTO metadata.extendedcapabilities (id,metadataurl) VALUES ((select nextval('metadata.hibernate_sequence')), 'view_HY'); +INSERT INTO metadata.extendedcapabilities (id,metadataurl) VALUES ((select nextval('metadata.hibernate_sequence')), 'download_HY'); + +INSERT INTO metadata.serviceidentification (id,abstract,fees,servicetype,servicepath,title) + VALUES ((select nextval('metadata.hibernate_sequence')), 'Deze View service heeft betrekking op Hydrography.', 'no conditions apply', 'WMS', 'Hydrography/services/view_HY', 'INSPIRE View service voor Hydrography'); +INSERT INTO metadata.serviceidentification (id,abstract,fees,servicetype,servicepath,title) + VALUES ((select nextval('metadata.hibernate_sequence')), 'Deze Download service heeft betrekking op Hydrography.', 'none', 'WFS', 'Hydrography/services/download_HY', 'INSPIRE Download service voor Hydrography'); + +INSERT INTO metadata.service (id,description,name,serviceidentification_id,serviceprovider_id, extendedcapabilities_id) VALUES ((select nextval('metadata.hibernate_sequence')), 'omschrijving view_HY', 'view_HY', (select id from metadata.serviceidentification where servicepath='Hydrography/services/view_HY'), (select id from metadata.serviceprovider where individualname like '%Hydrography%'), (select id from metadata.extendedcapabilities where metadataurl='view_HY')); +INSERT INTO metadata.service (id,description,name,serviceidentification_id,serviceprovider_id, extendedcapabilities_id) VALUES ((select nextval('metadata.hibernate_sequence')), 'omschrijving download_HY', 'download_HY', (select id from metadata.serviceidentification where servicepath='Hydrography/services/download_HY'), (select id from metadata.serviceprovider where individualname like '%Hydrography%'), (select id from metadata.extendedcapabilities where metadataurl='download_HY')); + +INSERT INTO metadata.service_datasetmetadata (service_id, name, namespace, url,"index") VALUES ((select id from metadata.service where name='view_HY'), 'HY.HydroNode', '', 'X', 0); +INSERT INTO metadata.service_datasetmetadata (service_id, name, namespace, url,"index") VALUES ((select id from metadata.service where name='view_HY'), 'HY.WaterCourseLink', '', 'X', 1); + +INSERT INTO metadata.si_accessconstraint (serviceidentification_id,accessconstraint,"index") VALUES ((select serviceidentification_id from metadata.service where name='view_HY'), 'anders', 0); + +INSERT INTO metadata.si_keyword (serviceidentification_id,codespace,"value","index" ) VALUES ((select serviceidentification_id from metadata.service where name='view_HY'), 'ISO', 'infoMapAccessService', 0); +INSERT INTO metadata.si_keyword (serviceidentification_id,codespace,"value","index" ) VALUES ((select serviceidentification_id from metadata.service where name='view_HY'), 'GEMET - INSPIRE themes, version 1.0', 'Hydrography', 1); +INSERT INTO metadata.si_keyword (serviceidentification_id,codespace,"value","index" ) VALUES ((select serviceidentification_id from metadata.service where name='download_HY'), 'ISO', 'infoFeatureAccessService', 0); +INSERT INTO metadata.si_keyword (serviceidentification_id,codespace,"value","index" ) VALUES ((select serviceidentification_id from metadata.service where name='download_HY'), 'GEMET - INSPIRE themes, version 1.0', 'Hydrography', 1); + +-- si-version is not filled + +INSERT INTO metadata.sp_deliverypoint (serviceprovider_id,deliverypoint,"index") VALUES ((select serviceprovider_id from metadata.service where name='view_HY'), '', 0); +INSERT INTO metadata.sp_emailaddress (serviceprovider_id, emailaddress,"index") VALUES ((select serviceprovider_id from metadata.service where name='view_HY'), 'inspire@idgis.nl', 0); +INSERT INTO metadata.sp_faxnumber (serviceprovider_id ,faxnumber,"index") VALUES ((select serviceprovider_id from metadata.service where name='view_HY'), '', 0); +INSERT INTO metadata.sp_phonenumber (serviceprovider_id,phonenumber,"index") VALUES ((select serviceprovider_id from metadata.service where name='view_HY'), '', 0); +-------------------------------- + +-- WMS & WFS with NL / flat structure + + +INSERT INTO metadata.extendedcapabilities (id,metadataurl) VALUES ((select nextval('metadata.hibernate_sequence')), 'wms_HY_NL'); +INSERT INTO metadata.extendedcapabilities (id,metadataurl) VALUES ((select nextval('metadata.hibernate_sequence')), 'wfs_HY_NL'); + +INSERT INTO metadata.serviceidentification (id,abstract,fees,servicetype,servicepath,title) + VALUES ((select nextval('metadata.hibernate_sequence')), 'Deze WMS service heeft betrekking op Hydrography.', 'no conditions apply', 'WMS', 'Hydrography/services/wms_HY_NL', 'WMS service voor Hydrography'); +INSERT INTO metadata.serviceidentification (id,abstract,fees,servicetype,servicepath,title) + VALUES ((select nextval('metadata.hibernate_sequence')), 'Deze WFS service heeft betrekking op Hydrography.', 'none', 'WFS', 'Hydrography/services/wfs_HY_NL', 'WFS service voor Hydrography'); + +INSERT INTO metadata.service (id,description,name,serviceidentification_id,serviceprovider_id, extendedcapabilities_id) VALUES ((select nextval('metadata.hibernate_sequence')), 'omschrijving wms_HY_NL', 'wms_HY_NL', (select id from metadata.serviceidentification where servicepath='Hydrography/services/wms_HY_NL'), (select id from metadata.serviceprovider where individualname like '%Hydrography%'), (select id from metadata.extendedcapabilities where metadataurl='wms_HY_NL')); +INSERT INTO metadata.service (id,description,name,serviceidentification_id,serviceprovider_id, extendedcapabilities_id) VALUES ((select nextval('metadata.hibernate_sequence')), 'omschrijving wfs_HY_NL', 'wfs_HY_NL', (select id from metadata.serviceidentification where servicepath='Hydrography/services/wfs_HY_NL'), (select id from metadata.serviceprovider where individualname like '%Hydrography%'), (select id from metadata.extendedcapabilities where metadataurl='wfs_HY_NL')); + +INSERT INTO metadata.service_datasetmetadata (service_id, name, namespace, url,"index") VALUES ((select id from metadata.service where name='wms_HY_NL'), 'HY.HydroNode_NL', '', 'X', 0); +INSERT INTO metadata.service_datasetmetadata (service_id, name, namespace, url,"index") VALUES ((select id from metadata.service where name='wms_HY_NL'), 'HY.WaterCourseLink_NL', '', 'X', 1); + +INSERT INTO metadata.si_accessconstraint (serviceidentification_id,accessconstraint,"index") VALUES ((select serviceidentification_id from metadata.service where name='wms_HY_NL'), 'anders', 0); + +INSERT INTO metadata.si_keyword (serviceidentification_id,codespace,"value","index" ) VALUES ((select serviceidentification_id from metadata.service where name='wms_HY_NL'), 'ISO', 'infoMapAccessService', 0); +INSERT INTO metadata.si_keyword (serviceidentification_id,codespace,"value","index" ) VALUES ((select serviceidentification_id from metadata.service where name='wms_HY_NL'), 'GEMET - INSPIRE themes, version 1.0', 'Hydrography', 1); +INSERT INTO metadata.si_keyword (serviceidentification_id,codespace,"value","index" ) VALUES ((select serviceidentification_id from metadata.service where name='wfs_HY_NL'), 'ISO', 'infoFeatureAccessService', 0); +INSERT INTO metadata.si_keyword (serviceidentification_id,codespace,"value","index" ) VALUES ((select serviceidentification_id from metadata.service where name='wfs_HY_NL'), 'GEMET - INSPIRE themes, version 1.0', 'Hydrography', 1); diff --git a/theme-hydronode/src/test/java/nl/ipo/cds/etl/theme/hydronode/ProductionFacilityValidatorTest.java b/theme-hydronode/src/test/java/nl/ipo/cds/etl/theme/hydronode/ProductionFacilityValidatorTest.java new file mode 100644 index 00000000..e5b7874d --- /dev/null +++ b/theme-hydronode/src/test/java/nl/ipo/cds/etl/theme/hydronode/ProductionFacilityValidatorTest.java @@ -0,0 +1,392 @@ +package nl.ipo.cds.etl.theme.hydronode; + +import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_CODE_CODESPACE_INVALID; +import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_CODE_INVALID; +import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_EMPTY; +import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_GROUP_INCONSISTENT; +import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_NULL; +import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_EMPTY_MULTIGEOMETRY; +import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE; +import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_POINT_DUPLICATION; +import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_SELF_INTERSECTION; +import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_SRS_NOT_RD; +import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_SRS_NULL; + +import java.util.Collections; + +import nl.ipo.cds.etl.test.GeometryConstants; +import nl.ipo.cds.etl.test.ValidationRunner; +import nl.ipo.cds.etl.theme.hydronode.Context; +import nl.ipo.cds.etl.theme.hydronode.Message; +import nl.ipo.cds.etl.theme.hydronode.HydroNode; +import nl.ipo.cds.etl.theme.hydronode.HydroNodeValidator; + +import org.deegree.commons.tom.ows.CodeType; +import org.junit.Before; +import org.junit.Test; + +public class ProductionFacilityValidatorTest { + + private HydroNodeValidator validator; + private ValidationRunner runner; + private GeometryConstants geom; + + @Before + public void createValidator() throws Exception { + validator = new HydroNodeValidator(Collections.emptyMap()); + runner = new ValidationRunner<>(validator, HydroNode.class); + geom = new GeometryConstants("EPSG:28992"); + } + + private ValidationRunner.Runner run(final String validationName) { + return runner.validation(validationName); + } + + @Test + public void getInspireIdDatasetCodeValidator () throws Throwable { + + run ("inspireIdDatasetCode") + .with (null) + .assertOnlyKey (ATTRIBUTE_NULL); + + run ("inspireIdDatasetCode") + .with (new CodeType("")) + .assertOnlyKey (ATTRIBUTE_EMPTY); + + run ("inspireIdDatasetCode") + .with (new CodeType("bogus")) + .assertOnlyKey (ATTRIBUTE_CODE_CODESPACE_INVALID); + + run ("inspireIdDatasetCode") + .withCodeList ("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility", "lgrinr") + .with (new CodeType("value1", "http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility")) + .assertOnlyKey (ATTRIBUTE_CODE_INVALID); + + run ("inspireIdDatasetCode") + .withCodeList ("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility", "lgrinr") + .with (new CodeType("lgrinr", "http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility")) + .assertNoMessages(); + } + + @Test + public void getInspireIdLocalIdValidator () throws Throwable { + + run ("inspireIdLocalId") + .with (null) + .assertOnlyKey (ATTRIBUTE_NULL); + + run ("inspireIdLocalId") + .with ("") + .assertOnlyKey (ATTRIBUTE_EMPTY); + + run ("inspireIdLocalId") + .with ("nl1000") + .assertNoMessages(); + } + + @Test + public void getProductionFacilityIdValidator () throws Throwable { + + run ("productionFacilityId") + .with (null) + .assertOnlyKey (ATTRIBUTE_NULL); + + run ("productionFacilityId") + .with ("") + .assertOnlyKey (ATTRIBUTE_EMPTY); + + run ("productionFacilityId") + .with ("nl1000") + .assertNoMessages(); + } + + @Test + public void getThematicIdentifierValidator () throws Throwable { + + HydroNode feature = new HydroNode(); + feature.setThematicIdentifier("a"); + feature.setThematicIdentifierScheme(null); + run ("thematicIdentifier") + .withFeature(feature ) + .assertOnlyKey (ATTRIBUTE_GROUP_INCONSISTENT); + + feature.setThematicIdentifier(null); + feature.setThematicIdentifierScheme("a"); + run ("thematicIdentifier") + .withFeature(feature ) + .assertOnlyKey (ATTRIBUTE_GROUP_INCONSISTENT); + + feature.setThematicIdentifier(null); + feature.setThematicIdentifierScheme(null); + run ("thematicIdentifier") + .withFeature(feature ) + .assertNoMessages (); + + feature.setThematicIdentifier("a"); + feature.setThematicIdentifierScheme("b"); + run ("thematicIdentifier") + .withFeature(feature ) + .assertNoMessages (); + } + + @Test + public void testGeometry () throws Exception { + + run ("geometry") + .with (null) + .assertOnlyKey (ATTRIBUTE_NULL); + + run ("geometry") + .with (geom.lineString (null)) + .assertOnlyKey (GEOMETRY_SRS_NULL); + + run ("geometry") + .with (geom.lineString (geom.getSrs ("EPSG:3857"))) + .assertOnlyKey (GEOMETRY_SRS_NOT_RD); + + run ("geometry") + .with (geom.point (1,2)) + .assertNoMessages (); + + run ("geometry") + .with (geom.lineString ()) + .assertNoMessages (); + + run ("geometry") + .with (geom.multiPolygon()) + .assertNoMessages (); + + run ("geometry") + .with (geom.lineStringDuplicatePoint ()) + .assertOnlyKey (GEOMETRY_POINT_DUPLICATION); + + run ("geometry") + .with (geom.lineStringSelfIntersection ()) + .assertOnlyKey (GEOMETRY_SELF_INTERSECTION); + } + + @Test + public void getFunctionActivityValidator () throws Throwable { + + run ("functionActivity") + .with (null) + .assertKey (ATTRIBUTE_NULL); + + run ("functionActivity") + .with (new CodeType("")) + .assertKey (ATTRIBUTE_CODE_CODESPACE_INVALID); + + run ("functionActivity") + .with (new CodeType("bogus")) + .assertOnlyKey (ATTRIBUTE_CODE_CODESPACE_INVALID); + + run ("functionActivity") + .withCodeList ("http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue", "lgrinr") + .with (new CodeType("value1", "http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue")) + .assertNoMessages(); +// code value validation deactivated +// .assertOnlyKey (ATTRIBUTE_CODE_INVALID); + + run ("functionActivity") + .withCodeList ("http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue", "lgrinr") + .with (new CodeType("lgrinr", "http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue")) + .assertNoMessages(); + } + + @Test + public void getFunctionInputValidator () throws Throwable { + + run ("functionInput") + .with (null) + .assertNoMessages(); + + run ("functionInput") + .with (new CodeType("")) + .assertKey (ATTRIBUTE_CODE_CODESPACE_INVALID); + + run ("functionInput") + .with (new CodeType("bogus")) + .assertOnlyKey (ATTRIBUTE_CODE_CODESPACE_INVALID); + + run ("functionInput") + .withCodeList ("http://inspire.ec.europa.eu/codeList/ProductCPAValue", "lgrinr") + .with (new CodeType("value1", "http://inspire.ec.europa.eu/codeList/ProductCPAValue")) + .assertNoMessages(); +// code value validation deactivated +// .assertOnlyKey (ATTRIBUTE_CODE_INVALID); + + + run ("functionInput") + .withCodeList ("http://inspire.ec.europa.eu/codeList/ProductCPAValue", "lgrinr") + .with (new CodeType("lgrinr", "http://inspire.ec.europa.eu/codeList/ProductCPAValue")) + .assertNoMessages(); + } + + @Test + public void getFunctionOutputValidator () throws Throwable { + + run ("functionOutput") + .with (null) + .assertNoMessages(); + + run ("functionOutput") + .with (new CodeType("")) + .assertKey (ATTRIBUTE_CODE_CODESPACE_INVALID); + + run ("functionOutput") + .with (new CodeType("bogus")) + .assertOnlyKey (ATTRIBUTE_CODE_CODESPACE_INVALID); + + run ("functionOutput") + .withCodeList ("http://inspire.ec.europa.eu/codeList/ProductCPAValue", "lgrinr") + .with (new CodeType("value1", "http://inspire.ec.europa.eu/codeList/ProductCPAValue")) + .assertNoMessages(); +// code value validation deactivated +// .assertOnlyKey (ATTRIBUTE_CODE_INVALID); + + + run ("functionOutput") + .withCodeList ("http://inspire.ec.europa.eu/codeList/ProductCPAValue", "lgrinr") + .with (new CodeType("lgrinr", "http://inspire.ec.europa.eu/codeList/ProductCPAValue")) + .assertNoMessages(); + } + + @Test + public void getFunctionDescriptionValidator () throws Throwable { + + run ("functionDescription") + .with (null) + .assertNoMessages(); + + run ("functionDescription") + .with ("") + .assertOnlyKey (ATTRIBUTE_EMPTY); + + run ("functionDescription") + .with ("nl1000") + .assertNoMessages(); + } + + @Test + public void getNameValidator () throws Throwable { + + run ("name") + .with (null) + .assertNoMessages(); + + run ("name") + .with ("") + .assertOnlyKey (ATTRIBUTE_EMPTY); + + run ("name") + .with ("nl1000") + .assertNoMessages(); + } + + @Test + public void testSurfaceGeometry () throws Exception { + + run ("surfaceGeometry") + .with (null) + .assertNoMessages (); + + run ("surfaceGeometry") + .with (geom.point (1,2)) + .assertOnlyKey (GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE); + + run ("surfaceGeometry") + .with (geom.lineString (null)) + .assertOnlyKey (GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE); + + run ("surfaceGeometry") + .with (geom.multiPoint ()) + .assertOnlyKey (GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE); + + run ("surfaceGeometry") + .with (geom.emptyMultiPolygon()) + .assertOnlyKey (GEOMETRY_EMPTY_MULTIGEOMETRY); + + run ("surfaceGeometry") + .with (geom.polygon(null)) + .assertOnlyKey (GEOMETRY_SRS_NULL); + + run ("surfaceGeometry") + .with (geom.polygon()) + .assertNoMessages (); + + run ("surfaceGeometry") + .with (geom.multiPolygon()) + .assertNoMessages (); + } + + @Test + public void getStatusValidator () throws Throwable { + + HydroNode feature = new HydroNode(); + feature.setStatusDescription("a"); + feature.setStatusType(null); + run ("status") + .withFeature(feature ) + .assertOnlyKey (ATTRIBUTE_GROUP_INCONSISTENT); + + feature = new HydroNode(); + feature.setStatusDescription("a"); + feature.setStatusType(new CodeType("b")); + run ("status") + .withFeature(feature ) + .assertNoMessages(); + + feature = new HydroNode(); + feature.setStatusType(new CodeType("b")); + run ("status") + .withFeature(feature ) + .assertNoMessages(); + + feature = new HydroNode(); + run ("status") + .withFeature(feature ) + .assertNoMessages(); + } + + @Test + public void getStatusTypeValidator () throws Throwable { + + run ("statusType") + .with (null) + .assertNoMessages(); + + run ("statusType") + .with (new CodeType("")) + .assertKey (ATTRIBUTE_CODE_CODESPACE_INVALID); + + run ("statusType") + .with (new CodeType("bogus")) + .assertOnlyKey (ATTRIBUTE_CODE_CODESPACE_INVALID); + + run ("statusType") + .withCodeList ("http://inspire.ec.europa.eu/codeList/ConditionOfFacilityValue", "functional") + .with (new CodeType("value1", "http://inspire.ec.europa.eu/codeList/ConditionOfFacilityValue")) + .assertOnlyKey (ATTRIBUTE_CODE_INVALID); + + run ("statusType") + .withCodeList ("http://inspire.ec.europa.eu/codeList/ConditionOfFacilityValue", "functional") + .with (new CodeType("functional", "http://inspire.ec.europa.eu/codeList/ConditionOfFacilityValue")) + .assertNoMessages(); + } + + @Test + public void getStatusDescriptionValidator () throws Throwable { + + run ("statusDescription") + .with (null) + .assertNoMessages(); + + run ("statusDescription") + .with ("") + .assertOnlyKey (ATTRIBUTE_EMPTY); + + run ("statusDescription") + .with ("nl1000") + .assertNoMessages(); + } +} diff --git a/theme-hydronode/src/test/java/nl/ipo/cds/etl/theme/hydronode/ValidatorsValidTest.java b/theme-hydronode/src/test/java/nl/ipo/cds/etl/theme/hydronode/ValidatorsValidTest.java new file mode 100644 index 00000000..80205302 --- /dev/null +++ b/theme-hydronode/src/test/java/nl/ipo/cds/etl/theme/hydronode/ValidatorsValidTest.java @@ -0,0 +1,16 @@ +package nl.ipo.cds.etl.theme.hydronode; + +import java.util.Collections; + +import nl.ipo.cds.etl.theme.hydronode.HydroNodeValidator; + +import org.junit.Test; + +public class ValidatorsValidTest { + + @Test + public void testValidatorValid () throws Exception { + new HydroNodeValidator (Collections.emptyMap ()); + } + +} diff --git a/theme-watercourselink/pom.xml b/theme-watercourselink/pom.xml new file mode 100644 index 00000000..2d14c93d --- /dev/null +++ b/theme-watercourselink/pom.xml @@ -0,0 +1,42 @@ + + 4.0.0 + + nl.ipo.cds + cds-parent + 2.2-SNAPSHOT + + theme-watercourselink + CDS - Theme WatercourseLink + + + + maven-assembly-plugin + + + + single + + package + + + + true + + src/main/assembly/assembly-sql.xml + + + + + + + + nl.ipo.cds + etl-proces + + + nl.ipo.cds + etl-test + test + + + diff --git a/theme-watercourselink/src/main/assembly/assembly-sql.xml b/theme-watercourselink/src/main/assembly/assembly-sql.xml new file mode 100644 index 00000000..922dd489 --- /dev/null +++ b/theme-watercourselink/src/main/assembly/assembly-sql.xml @@ -0,0 +1,18 @@ + + + sql + + zip + + false + + + + src/main/sql + sql + + **/*.* + + + + \ No newline at end of file diff --git a/theme-watercourselink/src/main/feeds/datasettypecodes.xml b/theme-watercourselink/src/main/feeds/datasettypecodes.xml new file mode 100644 index 00000000..a4f6e599 --- /dev/null +++ b/theme-watercourselink/src/main/feeds/datasettypecodes.xml @@ -0,0 +1,33 @@ + + + + http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility + DatasetTypeCode Production Facility + + + http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility/lgrinr + LGR Inrichtingen + + + + http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility/lgrins + LGR Installaties + + + + http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility/lgrput + LGR Put + + + + http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility/lgrlus + LGR Bodemlus + + + + http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility/rkinr + Risicokaart Inrichtingen + + + + diff --git a/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/Context.java b/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/Context.java new file mode 100644 index 00000000..40282bce --- /dev/null +++ b/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/Context.java @@ -0,0 +1,15 @@ +package nl.ipo.cds.etl.theme.watercourselink; + +import nl.ipo.cds.validation.DefaultValidatorContext; +import nl.ipo.cds.validation.ValidationReporter; +import nl.ipo.cds.validation.gml.codelists.CodeListFactory; + +public class Context extends DefaultValidatorContext { + + public Context ( + final CodeListFactory codeListFactory, + final ValidationReporter reporter) { + super (codeListFactory, reporter); + } + +} diff --git a/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/Message.java b/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/Message.java new file mode 100644 index 00000000..b84881da --- /dev/null +++ b/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/Message.java @@ -0,0 +1,114 @@ +package nl.ipo.cds.etl.theme.watercourselink; + +import java.util.ArrayList; +import java.util.List; + +import nl.idgis.commons.jobexecutor.JobLogger.LogLevel; +import nl.ipo.cds.etl.ValidatorMessageKey; +import nl.ipo.cds.validation.AttributeExpression; +import nl.ipo.cds.validation.Expression; + +public enum Message implements ValidatorMessageKey { + + ATTRIBUTE_NULL, + ATTRIBUTE_EMPTY, + ATTRIBUTE_NOT_URL, + ATTRIBUTE_VALUE_NEGATIVE, + ATTRIBUTE_VALUE_TOO_LOW, + ATTRIBUTE_VALUE_TOO_HIGH, + ATTRIBUTE_CODE_CODESPACE_INVALID, + ATTRIBUTE_CODE_INVALID, + ATTRIBUTE_GROUP_INCONSISTENT, + + GEOMETRY_EMPTY_MULTIGEOMETRY, + GEOMETRY_ONLY_POINT_OR_MULTIPOINT, + GEOMETRY_ONLY_CURVE_OR_MULTICURVE, + GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE, + GEOMETRY_POINT_NOT_ALLOWED, + GEOMETRY_POINT_DUPLICATION(Integer.MAX_VALUE, true), + GEOMETRY_EXTERIOR_RING_CW(LogLevel.WARNING), + GEOMETRY_INTERIOR_RING_CCW(LogLevel.WARNING), + GEOMETRY_DISCONTINUITY(Integer.MAX_VALUE, true), + GEOMETRY_SELF_INTERSECTION(Integer.MAX_VALUE, true), + GEOMETRY_RING_NOT_CLOSED(Integer.MAX_VALUE, true), + GEOMETRY_RING_SELF_INTERSECTION(Integer.MAX_VALUE, true), + GEOMETRY_INTERIOR_RINGS_TOUCH(Integer.MAX_VALUE, true), + GEOMETRY_INTERIOR_RINGS_INTERSECT(Integer.MAX_VALUE, true), + GEOMETRY_INTERIOR_RINGS_WITHIN(Integer.MAX_VALUE, true), + GEOMETRY_INTERIOR_RING_TOUCHES_EXTERIOR(Integer.MAX_VALUE, true), + GEOMETRY_INTERIOR_RING_INTERSECTS_EXTERIOR(Integer.MAX_VALUE, true), + GEOMETRY_INTERIOR_RING_OUTSIDE_EXTERIOR(Integer.MAX_VALUE, true), + GEOMETRY_INTERIOR_DISCONNECTED(Integer.MAX_VALUE, true), + GEOMETRY_SRS_NULL, + GEOMETRY_SRS_NOT_RD("EPSG:28992"), + + HAS_MORE_ERRORS(LogLevel.WARNING) + ; + + private final String[] params; + + private final LogLevel logLevel; + + private final int maxMessageLog; + + private final boolean addToShapeFile; + + private Message(LogLevel logLevel, Integer maxMessageLog, boolean addToShapeFile, String... params) { + this.maxMessageLog = maxMessageLog == null ? 10 : maxMessageLog; + this.logLevel = logLevel == null ? LogLevel.ERROR : logLevel; + this.addToShapeFile = addToShapeFile; + this.params = params; + } + + private Message(LogLevel logLevel, Integer maxMessageLog, String... params) { + this(logLevel, maxMessageLog, false, params); + } + + private Message(Integer maxMessageLog, boolean addToShapeFile, String... params) { + this(null, maxMessageLog, addToShapeFile, params); + } + + private Message(LogLevel logLevel) { + this(logLevel, null, false); + } + + private Message(String... params) { + this(null, null, false, params); + } + + @Override + public boolean isBlocking() { + return getLogLevel ().equals (LogLevel.ERROR); + } + + @Override + public List> getMessageParameters () { + final List> params = new ArrayList<> (); + // why twice??? + params.add (new AttributeExpression ("id", String.class)); + params.add (new AttributeExpression ("id", String.class)); + params.add (new AttributeExpression ("inspireIdLocalId", String.class)); + return params; + } + + @Override + public int getMaxMessageLog() { + return maxMessageLog; + } + + @Override + public boolean isAddToShapeFile () { + return addToShapeFile; + } + + @Override + public LogLevel getLogLevel() { + return logLevel; + } + + @Override + public Message getMaxMessageKey() { + return HAS_MORE_ERRORS; + } + +} diff --git a/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLink.java b/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLink.java new file mode 100644 index 00000000..59f77750 --- /dev/null +++ b/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLink.java @@ -0,0 +1,208 @@ +package nl.ipo.cds.etl.theme.watercourselink; + +import nl.ipo.cds.etl.PersistableFeature; +import nl.ipo.cds.etl.db.annotation.Column; +import nl.ipo.cds.etl.db.annotation.Table; +import nl.ipo.cds.etl.theme.annotation.CodeSpace; +import nl.ipo.cds.etl.theme.annotation.MappableAttribute; + +import org.deegree.commons.tom.ows.CodeType; +import org.deegree.geometry.Geometry; + +@Table(name = "watercourse_link", schema = "bron") +public class WatercourseLink extends PersistableFeature { + + @Column(name = "inspire_id_dataset_code") + private CodeType inspireIdDatasetCode; + + @Column(name = "inspire_id_local_id") + private String inspireIdLocalId; + + @Column(name = "production_facility_id") + private String productionFacilityId; + + @Column(name = "thematic_identifier") + private String thematicIdentifier; + + @Column(name = "thematic_identifier_scheme") + private String thematicIdentifierScheme; + + @Column(name = "geometry") + private Geometry geometry; + + @Column(name = "function_activity") + private CodeType functionActivity; + + @Column(name = "function_input") + private CodeType functionInput; + + @Column(name = "function_output") + private CodeType functionOutput; + + @Column(name = "function_description") + private String functionDescription; + + @Column(name = "name") + private String name; + + @Column(name = "surface_geometry") + private Geometry surfaceGeometry; + + @Column(name = "status_type") + private CodeType statusType; + + @Column(name = "status_description") + private String statusDescription; + + + @MappableAttribute + @CodeSpace("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility") + public CodeType getInspireIdDatasetCode() { + return inspireIdDatasetCode; + } + + @MappableAttribute + @CodeSpace("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility") + public void setInspireIdDatasetCode(CodeType inspireIdDatasetCode) { + this.inspireIdDatasetCode = inspireIdDatasetCode; + } + + @MappableAttribute + public String getInspireIdLocalId() { + return inspireIdLocalId; + } + + @MappableAttribute + public void setInspireIdLocalId(String inspireIdLocalId) { + this.inspireIdLocalId = inspireIdLocalId; + } + + @MappableAttribute + public Geometry getGeometry() { + return geometry; + } + + @MappableAttribute + public void setGeometry(Geometry geometry) { + this.geometry = geometry; + } + + @MappableAttribute + public String getProductionFacilityId() { + return productionFacilityId; + } + + @MappableAttribute + public void setProductionFacilityId(String productionFacilityId) { + this.productionFacilityId = productionFacilityId; + } + + @MappableAttribute + public String getThematicIdentifier() { + return thematicIdentifier; + } + + @MappableAttribute + public void setThematicIdentifier(String thematicIdentifier) { + this.thematicIdentifier = thematicIdentifier; + } + + @MappableAttribute + public String getThematicIdentifierScheme() { + return thematicIdentifierScheme; + } + + @MappableAttribute + public void setThematicIdentifierScheme(String thematicIdentifierScheme) { + this.thematicIdentifierScheme = thematicIdentifierScheme; + } + + @MappableAttribute + @CodeSpace("http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue") + public CodeType getFunctionActivity() { + return functionActivity; + } + + @MappableAttribute + @CodeSpace("http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue") + public void setFunctionActivity(CodeType functionActivity) { + this.functionActivity = functionActivity; + } + + @MappableAttribute + @CodeSpace("http://inspire.ec.europa.eu/codeList/ProductCPAValue") + public CodeType getFunctionInput() { + return functionInput; + } + + @MappableAttribute + @CodeSpace("http://inspire.ec.europa.eu/codeList/ProductCPAValue") + public void setFunctionInput(CodeType functionInput) { + this.functionInput = functionInput; + } + + @MappableAttribute + @CodeSpace("http://inspire.ec.europa.eu/codeList/ProductCPAValue") + public CodeType getFunctionOutput() { + return functionOutput; + } + + @MappableAttribute + @CodeSpace("http://inspire.ec.europa.eu/codeList/ProductCPAValue") + public void setFunctionOutput(CodeType functionOutput) { + this.functionOutput = functionOutput; + } + + @MappableAttribute + public String getFunctionDescription() { + return functionDescription; + } + + @MappableAttribute + public void setFunctionDescription(String functionDescription) { + this.functionDescription = functionDescription; + } + + @MappableAttribute + public String getName() { + return name; + } + + @MappableAttribute + public void setName(String name) { + this.name = name; + } + + @MappableAttribute + public Geometry getSurfaceGeometry() { + return surfaceGeometry; + } + + @MappableAttribute + public void setSurfaceGeometry(Geometry surfaceGeometry) { + this.surfaceGeometry = surfaceGeometry; + } + + @MappableAttribute + @CodeSpace("http://inspire.ec.europa.eu/codeList/ConditionOfFacilityValue") + public CodeType getStatusType() { + return statusType; + } + + @MappableAttribute + @CodeSpace("http://inspire.ec.europa.eu/codeList/ConditionOfFacilityValue") + public void setStatusType(CodeType statusType) { + this.statusType = statusType; + } + + @MappableAttribute + public String getStatusDescription() { + return statusDescription; + } + + @MappableAttribute + public void setStatusDescription(String statusDescription) { + this.statusDescription = statusDescription; + } + +} diff --git a/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLinkValidator.java b/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLinkValidator.java new file mode 100644 index 00000000..c75b7512 --- /dev/null +++ b/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLinkValidator.java @@ -0,0 +1,319 @@ +package nl.ipo.cds.etl.theme.watercourselink; + +import static nl.ipo.cds.etl.theme.watercourselink.Message.ATTRIBUTE_CODE_CODESPACE_INVALID; +import static nl.ipo.cds.etl.theme.watercourselink.Message.ATTRIBUTE_CODE_INVALID; +import static nl.ipo.cds.etl.theme.watercourselink.Message.ATTRIBUTE_EMPTY; +import static nl.ipo.cds.etl.theme.watercourselink.Message.ATTRIBUTE_GROUP_INCONSISTENT; +import static nl.ipo.cds.etl.theme.watercourselink.Message.ATTRIBUTE_NULL; +import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_DISCONTINUITY; +import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_EMPTY_MULTIGEOMETRY; +import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_EXTERIOR_RING_CW; +import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_INTERIOR_DISCONNECTED; +import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_INTERIOR_RINGS_TOUCH; +import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_INTERIOR_RINGS_WITHIN; +import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_INTERIOR_RING_CCW; +import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_INTERIOR_RING_OUTSIDE_EXTERIOR; +import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_INTERIOR_RING_TOUCHES_EXTERIOR; +import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE; +import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_POINT_DUPLICATION; +import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_RING_NOT_CLOSED; +import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_RING_SELF_INTERSECTION; +import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_SELF_INTERSECTION; +import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_SRS_NOT_RD; +import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_SRS_NULL; + +import java.util.Map; + +import nl.ipo.cds.domain.EtlJob; +import nl.ipo.cds.etl.AbstractValidator; +import nl.ipo.cds.validation.AttributeExpression; +import nl.ipo.cds.validation.ValidationReporter; +import nl.ipo.cds.validation.Validator; +import nl.ipo.cds.validation.constants.Constant; +import nl.ipo.cds.validation.execute.CompilerException; +import nl.ipo.cds.validation.geometry.GeometryExpression; +import nl.ipo.cds.validation.gml.CodeExpression; +import nl.ipo.cds.validation.gml.codelists.CodeListFactory; + +import org.deegree.geometry.Geometry; + +public class WatercourseLinkValidator extends AbstractValidator { + + private final CodeExpression inspireIdDatasetCode = code ("inspireIdDatasetCode"); + + private final AttributeExpression inspireIdLocalId = stringAttr ("inspireIdLocalId"); + + private final AttributeExpression productionFacilityId = stringAttr ("productionFacilityId"); + + private final AttributeExpression thematicIdentifier = stringAttr ("thematicIdentifier"); + + private final AttributeExpression thematicIdentifierScheme = stringAttr ("thematicIdentifierScheme"); + + private final GeometryExpression geometry = geometry ("geometry"); + + private final CodeExpression functionActivity = code ("functionActivity"); + + private final CodeExpression functionInput = code ("functionInput"); + + private final CodeExpression functionOutput = code ("functionOutput"); + + private final AttributeExpression functionDescription = stringAttr ("functionDescription"); + + private final AttributeExpression name = stringAttr ("name"); + + private final GeometryExpression surfaceGeometry = geometry ("surfaceGeometry"); + + private final AttributeExpression statusDescription = stringAttr ("statusDescription"); + + private final CodeExpression statusType = code ("statusType"); + + private final Constant inspireIdDatasetCodeSpace = constant ("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility"); + + private final Constant functionActivityCodeSpace = constant ("http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue"); + + private final Constant functionInputCodeSpace = constant ("http://inspire.ec.europa.eu/codeList/ProductCPAValue"); + + private final Constant functionOutputCodeSpace = constant ("http://inspire.ec.europa.eu/codeList/ProductCPAValue"); + + private final Constant statusTypeCodeSpace = constant ("http://inspire.ec.europa.eu/codeList/ConditionOfFacilityValue"); + + public WatercourseLinkValidator(final Map validatorMessages) throws CompilerException { + super(Context.class, WatercourseLink.class, validatorMessages); + compile(); + } + + @Override + public Context beforeJob(final EtlJob job, final CodeListFactory codeListFactory, + final ValidationReporter reporter) { + return new Context(codeListFactory, reporter); + } + + public Validator getInspireIdDatasetCodeValidator () { + return validate ( + and( + validate (not (inspireIdDatasetCode.isNull ())).message (ATTRIBUTE_NULL, constant (inspireIdDatasetCode.name)), + validate (not (isBlank (inspireIdDatasetCode.code()))).message (ATTRIBUTE_EMPTY, constant (inspireIdDatasetCode.name)), + validate (inspireIdDatasetCode.hasCodeSpace (inspireIdDatasetCodeSpace)).message (ATTRIBUTE_CODE_CODESPACE_INVALID, inspireIdDatasetCode.codeSpace(), constant(inspireIdDatasetCode.name), inspireIdDatasetCodeSpace), + validate (inspireIdDatasetCode.isValid ()).message (ATTRIBUTE_CODE_INVALID, inspireIdDatasetCode.code(), constant (inspireIdDatasetCode.name), inspireIdDatasetCodeSpace) + ).shortCircuit() + ); + } + + public Validator getInspireIdLocalIdValidator () { + return validate ( + and( + validate (not (inspireIdLocalId.isNull ())).message (ATTRIBUTE_NULL, constant(inspireIdLocalId.name)), + validate (not (isBlank (inspireIdLocalId))).message (ATTRIBUTE_EMPTY, constant(inspireIdLocalId.name)) + ).shortCircuit() + ); + } + + public Validator getProductionFacilityIdValidator () { + return validate ( + and( + validate (not (productionFacilityId.isNull ())).message (ATTRIBUTE_NULL, constant(productionFacilityId.name)), + validate (not (isBlank (productionFacilityId))).message (ATTRIBUTE_EMPTY, constant(productionFacilityId.name)) + ).shortCircuit() + ); + } + + public Validator getThematicIdentifierValidator () { + return validate ( + and( + ifExp (not (or (thematicIdentifier.isNull (), isBlank (thematicIdentifier))), + and ( + validate (not (thematicIdentifierScheme.isNull())).message (ATTRIBUTE_GROUP_INCONSISTENT, constant (thematicIdentifierScheme.name), constant (thematicIdentifier.name)), + validate (not (isBlank (thematicIdentifierScheme))).message (ATTRIBUTE_GROUP_INCONSISTENT, constant (thematicIdentifierScheme.name), constant (thematicIdentifier.name)) + ).shortCircuit(), + constant(true) + ), + ifExp (not (or (thematicIdentifierScheme.isNull (), isBlank (thematicIdentifierScheme))), + and ( + validate (not (thematicIdentifier.isNull())).message (ATTRIBUTE_GROUP_INCONSISTENT, constant (thematicIdentifier.name), constant (thematicIdentifierScheme.name)), + validate (not (isBlank (thematicIdentifier))).message (ATTRIBUTE_GROUP_INCONSISTENT, constant (thematicIdentifier.name), constant (thematicIdentifierScheme.name)) + ).shortCircuit(), + constant(true) + ) + ) + ); + } + + public Validator getGeometryValidator () { + return validate ( + and ( + // The following validations short-circuit, there must be a non-null and non-empty, non-point geometry: + validate (not (geometry.isNull ())).message (ATTRIBUTE_NULL, constant(geometry.name)), + // Non short-circuited validations: + and ( + // Short circuit to prevent the interiorDisconnected validation if + // any of the other validations fail: + and ( + and ( + validate (not (geometry.hasCurveDuplicatePoint ())).message (GEOMETRY_POINT_DUPLICATION, lastLocation ()), + validate (not (geometry.hasCurveDiscontinuity ())).message (GEOMETRY_DISCONTINUITY), + validate (not (geometry.hasCurveSelfIntersection ())).message (GEOMETRY_SELF_INTERSECTION, lastLocation ()), + validate (not (geometry.hasUnclosedRing ())).message (GEOMETRY_RING_NOT_CLOSED), + validate (not (geometry.hasRingSelfIntersection ())).message (GEOMETRY_RING_SELF_INTERSECTION, lastLocation ()), + validate (not (geometry.hasTouchingInteriorRings ())).message(GEOMETRY_INTERIOR_RINGS_TOUCH, lastLocation ()), + validate (not (geometry.hasInteriorRingsWithin ())).message (GEOMETRY_INTERIOR_RINGS_WITHIN) + ), + validate (not (geometry.isInteriorDisconnected ())).message (GEOMETRY_INTERIOR_DISCONNECTED) + ).shortCircuit (), + + // Non-blocking validations: + validate (not (geometry.hasExteriorRingCW ())).nonBlocking ().message (GEOMETRY_EXTERIOR_RING_CW), + validate (not (geometry.hasInteriorRingCCW ())).nonBlocking ().message (GEOMETRY_INTERIOR_RING_CCW), + validate (not (geometry.hasInteriorRingTouchingExterior ())).nonBlocking ().message (GEOMETRY_INTERIOR_RING_TOUCHES_EXTERIOR, lastLocation ()), + validate (not (geometry.hasInteriorRingOutsideExterior ())).nonBlocking ().message (GEOMETRY_INTERIOR_RING_OUTSIDE_EXTERIOR), + + // SRS validations: + and ( + validate (geometry.hasSrs ()).message (GEOMETRY_SRS_NULL), + validate (geometry.isSrs (constant ("28992"))).message (GEOMETRY_SRS_NOT_RD, geometry.srsName ()) + ).shortCircuit() + ) + ).shortCircuit () + ); + } + + public Validator getFunctionActivityValidator () { + return validate ( + and( + validate (not (functionActivity.isNull ())).message (ATTRIBUTE_NULL, constant(functionActivity.name)), + validate (functionActivity.hasCodeSpace (functionActivityCodeSpace)).message (ATTRIBUTE_CODE_CODESPACE_INVALID, functionActivity.codeSpace(), constant(functionActivity.name), functionActivityCodeSpace), + validate (not (isBlank (functionActivity.code()))).message (ATTRIBUTE_EMPTY, constant(functionActivity.name)) + // must be deactivated as long as codelist http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue is empty +// validate (functionActivity.isValid ()).message (ATTRIBUTE_CODE_INVALID, functionActivity.code(), constant(functionActivity.name), functionActivityCodeSpace) + ).shortCircuit() + ); + } + + public Validator getFunctionInputValidator () { + return validate ( + ifExp ( + functionInput.isNull (), + constant(true), + and( + validate (functionInput.hasCodeSpace (functionInputCodeSpace)).message (ATTRIBUTE_CODE_CODESPACE_INVALID, functionInput.codeSpace(), constant(functionInput.name), functionInputCodeSpace), + validate (not (isBlank (functionInput.code()))).message (ATTRIBUTE_EMPTY, constant(functionInput.name)) + // must be deactivated as long as codelist http://inspire.ec.europa.eu/codeList/ProductCPAValue is empty +// validate (functionInput.isValid ()).message (ATTRIBUTE_CODE_INVALID, functionInput.code(), constant(functionInput.name), functionInputCodeSpace) + ).shortCircuit() + ) + ); + } + + public Validator getFunctionOutputValidator () { + return validate ( + ifExp ( + functionOutput.isNull (), + constant(true), + and( + validate (functionOutput.hasCodeSpace (functionOutputCodeSpace)).message (ATTRIBUTE_CODE_CODESPACE_INVALID, functionOutput.codeSpace(), constant(functionOutput.name), functionOutputCodeSpace), + validate (not (isBlank (functionOutput.code()))).message (ATTRIBUTE_EMPTY, constant(functionOutput.name)) + // must be deactivated as long as codelist http://inspire.ec.europa.eu/codeList/ProductCPAValue is empty +// validate (functionOutput.isValid ()).message (ATTRIBUTE_CODE_INVALID, functionOutput.code(), constant(functionOutput.name), functionOutputCodeSpace) + ).shortCircuit() + ) + ); + } + + public Validator getFunctionDescriptionValidator () { + return validate ( + ifExp ( + functionDescription.isNull (), + constant(true), + validate (not (isBlank (functionDescription))).message (ATTRIBUTE_EMPTY, constant(functionDescription.name)) + ) + ); + } + + public Validator getNameValidator () { + return validate ( + ifExp ( + name.isNull (), + constant(true), + validate (not (isBlank (name))).message (ATTRIBUTE_EMPTY, constant(name.name)) + ) + ); + } + + public Validator getSurfaceGeometryValidator () { + return validate ( + ifExp( + surfaceGeometry.isNull (), + constant(true), + and ( + // The following validations short-circuit, there must be a non-empty, Surface geometry: + validate (not (surfaceGeometry.isEmptyMultiGeometry())).message (GEOMETRY_EMPTY_MULTIGEOMETRY), + validate (surfaceGeometry.isSurfaceOrMultiSurface()).message (GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE), + // Non short-circuited validations: + and ( + // Short circuit to prevent the interiorDisconnected validation if + // any of the other validations fail: + and ( + and ( + validate (not (surfaceGeometry.hasCurveDuplicatePoint ())).message (GEOMETRY_POINT_DUPLICATION, lastLocation ()), + validate (not (surfaceGeometry.hasCurveDiscontinuity ())).message (GEOMETRY_DISCONTINUITY), + validate (not (surfaceGeometry.hasCurveSelfIntersection ())).message (GEOMETRY_SELF_INTERSECTION, lastLocation ()), + validate (not (surfaceGeometry.hasUnclosedRing ())).message (GEOMETRY_RING_NOT_CLOSED), + validate (not (surfaceGeometry.hasRingSelfIntersection ())).message (GEOMETRY_RING_SELF_INTERSECTION, lastLocation ()), + validate (not (surfaceGeometry.hasTouchingInteriorRings ())).message(GEOMETRY_INTERIOR_RINGS_TOUCH, lastLocation ()), + validate (not (surfaceGeometry.hasInteriorRingsWithin ())).message (GEOMETRY_INTERIOR_RINGS_WITHIN) + ), + validate (not (surfaceGeometry.isInteriorDisconnected ())).message (GEOMETRY_INTERIOR_DISCONNECTED) + ).shortCircuit (), + + // Non-blocking validations: + validate (not (surfaceGeometry.hasExteriorRingCW ())).nonBlocking ().message (GEOMETRY_EXTERIOR_RING_CW), + validate (not (surfaceGeometry.hasInteriorRingCCW ())).nonBlocking ().message (GEOMETRY_INTERIOR_RING_CCW), + validate (not (surfaceGeometry.hasInteriorRingTouchingExterior ())).nonBlocking ().message (GEOMETRY_INTERIOR_RING_TOUCHES_EXTERIOR, lastLocation ()), + validate (not (surfaceGeometry.hasInteriorRingOutsideExterior ())).nonBlocking ().message (GEOMETRY_INTERIOR_RING_OUTSIDE_EXTERIOR), + + // SRS validations: + and ( + validate (surfaceGeometry.hasSrs ()).message (GEOMETRY_SRS_NULL), + validate (surfaceGeometry.isSrs (constant ("28992"))).message (GEOMETRY_SRS_NOT_RD, surfaceGeometry.srsName ()) + ).shortCircuit() + ) + ).shortCircuit () + ) + ); + } + + public Validator getStatusValidator () { + return validate ( + not ( + and ( + statusType.isNull(), + not (statusDescription.isNull()) + ) + ) + ).message (ATTRIBUTE_GROUP_INCONSISTENT, constant(statusType.name), constant(statusDescription.name)); + } + + public Validator getStatusDescriptionValidator () { + return validate ( + ifExp ( + statusDescription.isNull (), + constant(true), + validate (not (isBlank (statusDescription))).message (ATTRIBUTE_EMPTY, constant(statusDescription.name)) + ) + ); + } + + public Validator getStatusTypeValidator () { + return validate ( + ifExp ( + statusType.isNull (), + constant(true), + and( + validate (statusType.hasCodeSpace (statusTypeCodeSpace)).message (ATTRIBUTE_CODE_CODESPACE_INVALID, statusType.codeSpace(), constant(statusType.name), statusTypeCodeSpace), + validate (not (isBlank (statusType.code()))).message (ATTRIBUTE_EMPTY, constant(statusType.name)), + validate (statusType.isValid ()).message (ATTRIBUTE_CODE_INVALID, statusType.code(), constant(statusType.name), statusTypeCodeSpace) + ).shortCircuit() + ) + ); + } + +} diff --git a/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/config/DatasetConfig.java b/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/config/DatasetConfig.java new file mode 100644 index 00000000..edfe6dbb --- /dev/null +++ b/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/config/DatasetConfig.java @@ -0,0 +1,60 @@ +package nl.ipo.cds.etl.theme.watercourselink.config; + +import java.util.Properties; + +import javax.inject.Inject; +import javax.inject.Named; + +import nl.ipo.cds.attributemapping.operations.discover.OperationDiscoverer; +import nl.ipo.cds.etl.Transformer; +import nl.ipo.cds.etl.theme.DefaultThemeConfig; +import nl.ipo.cds.etl.theme.ThemeConfig; +import nl.ipo.cds.etl.theme.watercourselink.WatercourseLink; +import nl.ipo.cds.etl.theme.watercourselink.WatercourseLinkValidator; +import nl.ipo.cds.etl.util.ScriptExecutor; +import nl.ipo.cds.etl.util.ScriptTransformer; +import nl.ipo.cds.validation.execute.CompilerException; + +import org.springframework.beans.factory.config.PropertiesFactoryBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.ClassPathResource; + +@Configuration (value = "watercourseLink.DatasetConfig") +public class DatasetConfig { + + private static final String THEME_NAME = "WatercourseLink"; + + @Bean + @Inject + public ThemeConfig watercourseLinkThemeConfig ( + final WatercourseLinkValidator validator, + final OperationDiscoverer operationDiscoverer) { + return new DefaultThemeConfig (THEME_NAME, WatercourseLink.class, validator, operationDiscoverer); + } + + @Bean + public Transformer watercourseLinkTransformer(final ScriptExecutor scriptExecutor) { + return new ScriptTransformer(scriptExecutor, new ClassPathResource ("nl/ipo/cds/etl/theme/watercourselink/transform-bron-to-inspire.sql"), THEME_NAME); + } + + @Configuration (value = "watercourseLink.Validators") + public static class Validators { + @Bean + @Inject + public WatercourseLinkValidator watercourseLinkValidator ( + final @Named ("watercourseLinkValidationMessages") Properties validatorMessages) throws CompilerException { + return new WatercourseLinkValidator (validatorMessages); + } + } + + @Configuration (value = "watercourseLink.Messages") + public static class Messages { + @Bean + public PropertiesFactoryBean watercourseLinkValidationMessages () { + final PropertiesFactoryBean properties = new PropertiesFactoryBean (); + properties.setLocation (new ClassPathResource ("nl/ipo/cds/etl/theme/watercourselink/validator.messages")); + return properties; + } + } +} diff --git a/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/config/Package.java b/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/config/Package.java new file mode 100644 index 00000000..e0923c46 --- /dev/null +++ b/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/config/Package.java @@ -0,0 +1,4 @@ +package nl.ipo.cds.etl.theme.watercourselink.config; + +public interface Package { +} diff --git a/theme-watercourselink/src/main/resources/nl/ipo/cds/etl/theme/watercourselink/messages.properties b/theme-watercourselink/src/main/resources/nl/ipo/cds/etl/theme/watercourselink/messages.properties new file mode 100644 index 00000000..139597f9 --- /dev/null +++ b/theme-watercourselink/src/main/resources/nl/ipo/cds/etl/theme/watercourselink/messages.properties @@ -0,0 +1,2 @@ + + diff --git a/theme-watercourselink/src/main/resources/nl/ipo/cds/etl/theme/watercourselink/transform-bron-to-inspire.sql b/theme-watercourselink/src/main/resources/nl/ipo/cds/etl/theme/watercourselink/transform-bron-to-inspire.sql new file mode 100644 index 00000000..a1f8248e --- /dev/null +++ b/theme-watercourselink/src/main/resources/nl/ipo/cds/etl/theme/watercourselink/transform-bron-to-inspire.sql @@ -0,0 +1,44 @@ +delete from inspire.production_facility; + +insert into inspire.production_facility ( + id, + job_id, + gfid, + inspire_id_namespace, + inspire_id_local_id, + production_facility_id, + thematic_identifier, + thematic_identifier_scheme, + function_activity, + function_input, + function_output, + function_description, + name, + status_nil_reason, + status_xsi_nil, + status_type, + status_description, + geometry, + surface_geometry + ) +select + id, + job_id, + gfid, + 'NL.' || inspire_id_dataset_code, + inspire_id_local_id, + production_facility_id, + thematic_identifier, + thematic_identifier_scheme, + function_activity, + function_input, + function_output, + function_description, + "name", + CASE WHEN status_type IS NULL THEN 'UNKNOWN' END, + CASE WHEN status_type IS NULL THEN 'true' END, + status_type, + status_description, + geometry, + surface_geometry +from bron.production_facility; diff --git a/theme-watercourselink/src/main/resources/nl/ipo/cds/etl/theme/watercourselink/validator.messages b/theme-watercourselink/src/main/resources/nl/ipo/cds/etl/theme/watercourselink/validator.messages new file mode 100644 index 00000000..e663decf --- /dev/null +++ b/theme-watercourselink/src/main/resources/nl/ipo/cds/etl/theme/watercourselink/validator.messages @@ -0,0 +1,57 @@ +FEATURE=feature: ${0}, inspireIdLocalId: ${1} + +ATTRIBUTE_NULL=Het attribuut "${2}" ontbreekt, ${FEATURE} +ATTRIBUTE_EMPTY=Het attribuut "${2}" is leeg, ${FEATURE} +ATTRIBUTE_NOT_URL=De waarde "${2}" van het attribuut "${3}" is geen valide URL, ${FEATURE} +ATTRIBUTE_VALUE_NEGATIVE=De waarde "${2}" van het attribuut "${3}" is negatief, ${FEATURE} +ATTRIBUTE_CODE_CODESPACE_INVALID=De 'codeSpace' "${2}" van attribuut "${3}" is niet valide (verwacht: "${4}"), ${FEATURE} +ATTRIBUTE_CODE_INVALID=De code "${2}" van het attribuut "${3}" is niet valide met betrekking tot de code-lijst "${4}", ${FEATURE} +ATTRIBUTE_VALUE_TOO_LOW=De waarde "${2}" van het attribuut "${3}" is te laag (limiet "${4}"), ${FEATURE} +ATTRIBUTE_VALUE_TOO_HIGH=De waarde "${2}" van het attribuut "${3}" is te hoog (limiet "${4}"), ${FEATURE} +ATTRIBUTE_GROUP_INCONSISTENT=Het attribuut "${2}" kan niet worden weggelaten, als er één of meerdere andere attributen uit de groep (zoals "${3}") aanwezig zijn, ${FEATURE} + +GEOMETRY_NULL_BASE=geometrie ontbreekt +GEOMETRY_EMPTY_MULTIGEOMETRY_BASE=multi geometrie is leeg +GEOMETRY_ONLY_POINT_OR_MULTIPOINT_BASE=geometrie has wrong type: must be a point (or a multi point) +GEOMETRY_ONLY_CURVE_OR_MULTICURVE_BASE=geometrie has wrong type: must be a linestring (or a multi linestring) +GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE_BASE=geometrie has wrong type: must be a polygon (or a multi polygon) +GEOMETRY_POINT_DUPLICATION_BASE=geometrie bevat duplicaat punten, locatie: ${2} +GEOMETRY_EXTERIOR_RING_CW_BASE=geometrie bevat een buitenring met CW oriëntatie +GEOMETRY_INTERIOR_RING_CCW_BASE=geometrie bevat een binnenring met CCW oriëntatie +GEOMETRY_DISCONTINUITY_BASE=geometrie bevat lijnelementen die niet aansluiten +GEOMETRY_SELF_INTERSECTION_BASE=geometrie bevat een lijn die zichzelf snijdt, locatie: ${2} +GEOMETRY_RING_NOT_CLOSED_BASE=geometrie bevat een niet gesloten ring +GEOMETRY_RING_SELF_INTERSECTION_BASE=geometrie bevat een ring die zichzelf snijdt, locatie: ${2} +GEOMETRY_INTERIOR_RINGS_TOUCH_BASE=geometrie bevat een binnenring die zichzelf raakt, locatie: ${2} +GEOMETRY_INTERIOR_RINGS_INTERSECT_BASE=geometrie bevat een binnenring die zichzelf snijdt, locatie: ${2} +GEOMETRY_INTERIOR_RINGS_WITHIN_BASE=geometrie bevat een binnenring binnen een andere binnenring +GEOMETRY_INTERIOR_RING_TOUCHES_EXTERIOR_BASE=geometrie bevat een binnenring die een buitenring raakt, locatie: ${2} +GEOMETRY_INTERIOR_RING_INTERSECTS_EXTERIOR_BASE=geometrie bevat een binnenring die een buitenring snijdt, locatie: ${2} +GEOMETRY_INTERIOR_RING_OUTSIDE_EXTERIOR_BASE=geometrie bevat een binnenring die niet binnen een buitenring ligt +GEOMETRY_INTERIOR_DISCONNECTED_BASE=geometrie bevat een verbroken polygoon +GEOMETRY_SRS_NULL_BASE=Het attribuut "srsName" ontbreekt bij het geometrie-element +GEOMETRY_SRS_NOT_RD_BASE=Het attribuut "srsName" bij element "geometry" heeft een andere waarde dan "EPSG:28992" (RD_New) + +GEOMETRY_NULL=${GEOMETRY_NULL_BASE}, ${FEATURE} +GEOMETRY_EMPTY_MULTIGEOMETRY=${GEOMETRY_EMPTY_MULTIGEOMETRY_BASE}, ${FEATURE} +GEOMETRY_ONLY_POINT_OR_MULTIPOINT=${GEOMETRY_ONLY_POINT_OR_MULTIPOINT_BASE}, ${FEATURE} +GEOMETRY_ONLY_CURVE_OR_MULTICURVE=${GEOMETRY_ONLY_CURVE_OR_MULTICURVE_BASE}, ${FEATURE} +GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE=${GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE_BASE}, ${FEATURE} +GEOMETRY_POINT_DUPLICATION=${GEOMETRY_POINT_DUPLICATION_BASE}, ${FEATURE} +GEOMETRY_EXTERIOR_RING_CW=${GEOMETRY_EXTERIOR_RING_CW_BASE}, ${FEATURE} +GEOMETRY_INTERIOR_RING_CCW=${GEOMETRY_INTERIOR_RING_CCW_BASE}, ${FEATURE} +GEOMETRY_DISCONTINUITY=${GEOMETRY_DISCONTINUITY_BASE}, ${FEATURE} +GEOMETRY_SELF_INTERSECTION=${GEOMETRY_SELF_INTERSECTION_BASE}, ${FEATURE} +GEOMETRY_RING_NOT_CLOSED=${GEOMETRY_RING_NOT_CLOSED_BASE}, ${FEATURE} +GEOMETRY_RING_SELF_INTERSECTION=${GEOMETRY_RING_SELF_INTERSECTION_BASE}, ${FEATURE} +GEOMETRY_INTERIOR_RINGS_TOUCH=${GEOMETRY_INTERIOR_RINGS_TOUCH_BASE}, ${FEATURE} +GEOMETRY_INTERIOR_RINGS_INTERSECT=${GEOMETRY_INTERIOR_RINGS_INTERSECT_BASE}, ${FEATURE} +GEOMETRY_INTERIOR_RINGS_WITHIN=${GEOMETRY_INTERIOR_RINGS_WITHIN_BASE}, ${FEATURE} +GEOMETRY_INTERIOR_RING_TOUCHES_EXTERIOR=${GEOMETRY_INTERIOR_RING_TOUCHES_EXTERIOR_BASE}, ${FEATURE} +GEOMETRY_INTERIOR_RING_INTERSECTS_EXTERIOR=${GEOMETRY_INTERIOR_RING_INTERSECTS_EXTERIOR_BASE}, ${FEATURE} +GEOMETRY_INTERIOR_RING_OUTSIDE_EXTERIOR=${GEOMETRY_INTERIOR_RING_OUTSIDE_EXTERIOR_BASE}, ${FEATURE} +GEOMETRY_INTERIOR_DISCONNECTED=${GEOMETRY_INTERIOR_DISCONNECTED_BASE}, ${FEATURE} +GEOMETRY_SRS_NULL=${GEOMETRY_SRS_NULL_BASE}, ${FEATURE} +GEOMETRY_SRS_NOT_RD=${GEOMETRY_SRS_NOT_RD_BASE} (gevonden waarde: ${1}), ${FEATURE} + +HAS_MORE_ERRORS=Er zijn meer meldingen die niet werden gerapporteerd diff --git a/theme-watercourselink/src/main/sql/create-bron-schema-watercourselink.sql b/theme-watercourselink/src/main/sql/create-bron-schema-watercourselink.sql new file mode 100644 index 00000000..b7eedb29 --- /dev/null +++ b/theme-watercourselink/src/main/sql/create-bron-schema-watercourselink.sql @@ -0,0 +1,20 @@ + +create table bron.watercourse_link ( + id serial, + job_id bigint, + gfid text, + + inspire_id_dataset_code text not null, + inspire_id_local_id text not null, + + primary key (id), + constraint fk_job_id foreign key (job_id) references manager.job (id) +); +SELECT AddGeometryColumn ('bron','watercourse_link','geometry',28992,'GEOMETRY',2); +ALTER TABLE bron.watercourse_link ALTER COLUMN "geometry" SET NOT NULL; + +CREATE INDEX idx_bron_watercourse_link_geometry ON bron.watercourse_link USING GIST (geometry); + +GRANT SELECT, INSERT, UPDATE, DELETE, TRIGGER ON bron.watercourse_link TO inspire; +GRANT USAGE, SELECT, UPDATE ON SEQUENCE bron.watercourse_link_id_seq TO inspire; +---------------------------------- diff --git a/theme-watercourselink/src/main/sql/populate-manager-schema-watercourselink.sql b/theme-watercourselink/src/main/sql/populate-manager-schema-watercourselink.sql new file mode 100644 index 00000000..838b8cf5 --- /dev/null +++ b/theme-watercourselink/src/main/sql/populate-manager-schema-watercourselink.sql @@ -0,0 +1,12 @@ +-- +-- WatercourseLink +-- +-- Names must match constants defined corresponding ThemeConfig +insert into manager.thema (id, naam) values ((select nextval('manager.hibernate_sequence')), 'WatercourseLink'); + +insert into manager.datasettype (id, naam, thema_id) values ((select nextval('manager.hibernate_sequence')), 'HydroNetworkNodesNL', (select id from manager.thema t where t.naam = 'WatercourseLink')); + +insert into manager.bronhouder (id, code, contact_naam, contact_adres, contact_postcode, contact_plaats, naam, contact_emailadres, contact_telefoonnummer, common_name) select nextval('manager.hibernate_sequence'), 'elf', 'ELF Project', '', '', '', 'ELF Project', 'inspire@idgis.nl', '', 'elfproject' where not exists (select * from manager.bronhouder where code = 'elf'); + +insert into manager.themabronhouderauthorization (thema_id, bronhouder_id) values ( (select id from manager.thema where naam = 'WatercourseLink'), (select id from manager.bronhouder where code = 'elf') ); +-- diff --git a/theme-watercourselink/src/test/java/nl/ipo/cds/etl/theme/watercourselink/ValidatorsValidTest.java b/theme-watercourselink/src/test/java/nl/ipo/cds/etl/theme/watercourselink/ValidatorsValidTest.java new file mode 100644 index 00000000..e7d7a93d --- /dev/null +++ b/theme-watercourselink/src/test/java/nl/ipo/cds/etl/theme/watercourselink/ValidatorsValidTest.java @@ -0,0 +1,16 @@ +package nl.ipo.cds.etl.theme.watercourselink; + +import java.util.Collections; + +import nl.ipo.cds.etl.theme.watercourselink.WatercourseLinkValidator; + +import org.junit.Test; + +public class ValidatorsValidTest { + + @Test + public void testValidatorValid () throws Exception { + new WatercourseLinkValidator (Collections.emptyMap ()); + } + +} diff --git a/theme-watercourselink/src/test/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLinkValidatorTest.java b/theme-watercourselink/src/test/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLinkValidatorTest.java new file mode 100644 index 00000000..a196587c --- /dev/null +++ b/theme-watercourselink/src/test/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLinkValidatorTest.java @@ -0,0 +1,392 @@ +package nl.ipo.cds.etl.theme.watercourselink; + +import static nl.ipo.cds.etl.theme.watercourselink.Message.ATTRIBUTE_CODE_CODESPACE_INVALID; +import static nl.ipo.cds.etl.theme.watercourselink.Message.ATTRIBUTE_CODE_INVALID; +import static nl.ipo.cds.etl.theme.watercourselink.Message.ATTRIBUTE_EMPTY; +import static nl.ipo.cds.etl.theme.watercourselink.Message.ATTRIBUTE_GROUP_INCONSISTENT; +import static nl.ipo.cds.etl.theme.watercourselink.Message.ATTRIBUTE_NULL; +import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_EMPTY_MULTIGEOMETRY; +import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE; +import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_POINT_DUPLICATION; +import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_SELF_INTERSECTION; +import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_SRS_NOT_RD; +import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_SRS_NULL; + +import java.util.Collections; + +import nl.ipo.cds.etl.test.GeometryConstants; +import nl.ipo.cds.etl.test.ValidationRunner; +import nl.ipo.cds.etl.theme.watercourselink.Context; +import nl.ipo.cds.etl.theme.watercourselink.Message; +import nl.ipo.cds.etl.theme.watercourselink.WatercourseLink; +import nl.ipo.cds.etl.theme.watercourselink.WatercourseLinkValidator; + +import org.deegree.commons.tom.ows.CodeType; +import org.junit.Before; +import org.junit.Test; + +public class WatercourseLinkValidatorTest { + + private WatercourseLinkValidator validator; + private ValidationRunner runner; + private GeometryConstants geom; + + @Before + public void createValidator() throws Exception { + validator = new WatercourseLinkValidator(Collections.emptyMap()); + runner = new ValidationRunner<>(validator, WatercourseLink.class); + geom = new GeometryConstants("EPSG:28992"); + } + + private ValidationRunner.Runner run(final String validationName) { + return runner.validation(validationName); + } + + @Test + public void getInspireIdDatasetCodeValidator () throws Throwable { + + run ("inspireIdDatasetCode") + .with (null) + .assertOnlyKey (ATTRIBUTE_NULL); + + run ("inspireIdDatasetCode") + .with (new CodeType("")) + .assertOnlyKey (ATTRIBUTE_EMPTY); + + run ("inspireIdDatasetCode") + .with (new CodeType("bogus")) + .assertOnlyKey (ATTRIBUTE_CODE_CODESPACE_INVALID); + + run ("inspireIdDatasetCode") + .withCodeList ("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility", "lgrinr") + .with (new CodeType("value1", "http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility")) + .assertOnlyKey (ATTRIBUTE_CODE_INVALID); + + run ("inspireIdDatasetCode") + .withCodeList ("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility", "lgrinr") + .with (new CodeType("lgrinr", "http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility")) + .assertNoMessages(); + } + + @Test + public void getInspireIdLocalIdValidator () throws Throwable { + + run ("inspireIdLocalId") + .with (null) + .assertOnlyKey (ATTRIBUTE_NULL); + + run ("inspireIdLocalId") + .with ("") + .assertOnlyKey (ATTRIBUTE_EMPTY); + + run ("inspireIdLocalId") + .with ("nl1000") + .assertNoMessages(); + } + + @Test + public void getProductionFacilityIdValidator () throws Throwable { + + run ("productionFacilityId") + .with (null) + .assertOnlyKey (ATTRIBUTE_NULL); + + run ("productionFacilityId") + .with ("") + .assertOnlyKey (ATTRIBUTE_EMPTY); + + run ("productionFacilityId") + .with ("nl1000") + .assertNoMessages(); + } + + @Test + public void getThematicIdentifierValidator () throws Throwable { + + WatercourseLink feature = new WatercourseLink(); + feature.setThematicIdentifier("a"); + feature.setThematicIdentifierScheme(null); + run ("thematicIdentifier") + .withFeature(feature ) + .assertOnlyKey (ATTRIBUTE_GROUP_INCONSISTENT); + + feature.setThematicIdentifier(null); + feature.setThematicIdentifierScheme("a"); + run ("thematicIdentifier") + .withFeature(feature ) + .assertOnlyKey (ATTRIBUTE_GROUP_INCONSISTENT); + + feature.setThematicIdentifier(null); + feature.setThematicIdentifierScheme(null); + run ("thematicIdentifier") + .withFeature(feature ) + .assertNoMessages (); + + feature.setThematicIdentifier("a"); + feature.setThematicIdentifierScheme("b"); + run ("thematicIdentifier") + .withFeature(feature ) + .assertNoMessages (); + } + + @Test + public void testGeometry () throws Exception { + + run ("geometry") + .with (null) + .assertOnlyKey (ATTRIBUTE_NULL); + + run ("geometry") + .with (geom.lineString (null)) + .assertOnlyKey (GEOMETRY_SRS_NULL); + + run ("geometry") + .with (geom.lineString (geom.getSrs ("EPSG:3857"))) + .assertOnlyKey (GEOMETRY_SRS_NOT_RD); + + run ("geometry") + .with (geom.point (1,2)) + .assertNoMessages (); + + run ("geometry") + .with (geom.lineString ()) + .assertNoMessages (); + + run ("geometry") + .with (geom.multiPolygon()) + .assertNoMessages (); + + run ("geometry") + .with (geom.lineStringDuplicatePoint ()) + .assertOnlyKey (GEOMETRY_POINT_DUPLICATION); + + run ("geometry") + .with (geom.lineStringSelfIntersection ()) + .assertOnlyKey (GEOMETRY_SELF_INTERSECTION); + } + + @Test + public void getFunctionActivityValidator () throws Throwable { + + run ("functionActivity") + .with (null) + .assertKey (ATTRIBUTE_NULL); + + run ("functionActivity") + .with (new CodeType("")) + .assertKey (ATTRIBUTE_CODE_CODESPACE_INVALID); + + run ("functionActivity") + .with (new CodeType("bogus")) + .assertOnlyKey (ATTRIBUTE_CODE_CODESPACE_INVALID); + + run ("functionActivity") + .withCodeList ("http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue", "lgrinr") + .with (new CodeType("value1", "http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue")) + .assertNoMessages(); +// code value validation deactivated +// .assertOnlyKey (ATTRIBUTE_CODE_INVALID); + + run ("functionActivity") + .withCodeList ("http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue", "lgrinr") + .with (new CodeType("lgrinr", "http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue")) + .assertNoMessages(); + } + + @Test + public void getFunctionInputValidator () throws Throwable { + + run ("functionInput") + .with (null) + .assertNoMessages(); + + run ("functionInput") + .with (new CodeType("")) + .assertKey (ATTRIBUTE_CODE_CODESPACE_INVALID); + + run ("functionInput") + .with (new CodeType("bogus")) + .assertOnlyKey (ATTRIBUTE_CODE_CODESPACE_INVALID); + + run ("functionInput") + .withCodeList ("http://inspire.ec.europa.eu/codeList/ProductCPAValue", "lgrinr") + .with (new CodeType("value1", "http://inspire.ec.europa.eu/codeList/ProductCPAValue")) + .assertNoMessages(); +// code value validation deactivated +// .assertOnlyKey (ATTRIBUTE_CODE_INVALID); + + + run ("functionInput") + .withCodeList ("http://inspire.ec.europa.eu/codeList/ProductCPAValue", "lgrinr") + .with (new CodeType("lgrinr", "http://inspire.ec.europa.eu/codeList/ProductCPAValue")) + .assertNoMessages(); + } + + @Test + public void getFunctionOutputValidator () throws Throwable { + + run ("functionOutput") + .with (null) + .assertNoMessages(); + + run ("functionOutput") + .with (new CodeType("")) + .assertKey (ATTRIBUTE_CODE_CODESPACE_INVALID); + + run ("functionOutput") + .with (new CodeType("bogus")) + .assertOnlyKey (ATTRIBUTE_CODE_CODESPACE_INVALID); + + run ("functionOutput") + .withCodeList ("http://inspire.ec.europa.eu/codeList/ProductCPAValue", "lgrinr") + .with (new CodeType("value1", "http://inspire.ec.europa.eu/codeList/ProductCPAValue")) + .assertNoMessages(); +// code value validation deactivated +// .assertOnlyKey (ATTRIBUTE_CODE_INVALID); + + + run ("functionOutput") + .withCodeList ("http://inspire.ec.europa.eu/codeList/ProductCPAValue", "lgrinr") + .with (new CodeType("lgrinr", "http://inspire.ec.europa.eu/codeList/ProductCPAValue")) + .assertNoMessages(); + } + + @Test + public void getFunctionDescriptionValidator () throws Throwable { + + run ("functionDescription") + .with (null) + .assertNoMessages(); + + run ("functionDescription") + .with ("") + .assertOnlyKey (ATTRIBUTE_EMPTY); + + run ("functionDescription") + .with ("nl1000") + .assertNoMessages(); + } + + @Test + public void getNameValidator () throws Throwable { + + run ("name") + .with (null) + .assertNoMessages(); + + run ("name") + .with ("") + .assertOnlyKey (ATTRIBUTE_EMPTY); + + run ("name") + .with ("nl1000") + .assertNoMessages(); + } + + @Test + public void testSurfaceGeometry () throws Exception { + + run ("surfaceGeometry") + .with (null) + .assertNoMessages (); + + run ("surfaceGeometry") + .with (geom.point (1,2)) + .assertOnlyKey (GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE); + + run ("surfaceGeometry") + .with (geom.lineString (null)) + .assertOnlyKey (GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE); + + run ("surfaceGeometry") + .with (geom.multiPoint ()) + .assertOnlyKey (GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE); + + run ("surfaceGeometry") + .with (geom.emptyMultiPolygon()) + .assertOnlyKey (GEOMETRY_EMPTY_MULTIGEOMETRY); + + run ("surfaceGeometry") + .with (geom.polygon(null)) + .assertOnlyKey (GEOMETRY_SRS_NULL); + + run ("surfaceGeometry") + .with (geom.polygon()) + .assertNoMessages (); + + run ("surfaceGeometry") + .with (geom.multiPolygon()) + .assertNoMessages (); + } + + @Test + public void getStatusValidator () throws Throwable { + + WatercourseLink feature = new WatercourseLink(); + feature.setStatusDescription("a"); + feature.setStatusType(null); + run ("status") + .withFeature(feature ) + .assertOnlyKey (ATTRIBUTE_GROUP_INCONSISTENT); + + feature = new WatercourseLink(); + feature.setStatusDescription("a"); + feature.setStatusType(new CodeType("b")); + run ("status") + .withFeature(feature ) + .assertNoMessages(); + + feature = new WatercourseLink(); + feature.setStatusType(new CodeType("b")); + run ("status") + .withFeature(feature ) + .assertNoMessages(); + + feature = new WatercourseLink(); + run ("status") + .withFeature(feature ) + .assertNoMessages(); + } + + @Test + public void getStatusTypeValidator () throws Throwable { + + run ("statusType") + .with (null) + .assertNoMessages(); + + run ("statusType") + .with (new CodeType("")) + .assertKey (ATTRIBUTE_CODE_CODESPACE_INVALID); + + run ("statusType") + .with (new CodeType("bogus")) + .assertOnlyKey (ATTRIBUTE_CODE_CODESPACE_INVALID); + + run ("statusType") + .withCodeList ("http://inspire.ec.europa.eu/codeList/ConditionOfFacilityValue", "functional") + .with (new CodeType("value1", "http://inspire.ec.europa.eu/codeList/ConditionOfFacilityValue")) + .assertOnlyKey (ATTRIBUTE_CODE_INVALID); + + run ("statusType") + .withCodeList ("http://inspire.ec.europa.eu/codeList/ConditionOfFacilityValue", "functional") + .with (new CodeType("functional", "http://inspire.ec.europa.eu/codeList/ConditionOfFacilityValue")) + .assertNoMessages(); + } + + @Test + public void getStatusDescriptionValidator () throws Throwable { + + run ("statusDescription") + .with (null) + .assertNoMessages(); + + run ("statusDescription") + .with ("") + .assertOnlyKey (ATTRIBUTE_EMPTY); + + run ("statusDescription") + .with ("nl1000") + .assertNoMessages(); + } +} From bf9c1c9160a0aabc36a89e300af79d5026db8ab9 Mon Sep 17 00:00:00 2001 From: Markus Schneider Date: Wed, 29 Jan 2014 18:40:46 +0100 Subject: [PATCH 2/8] More work on mapping of Hydrography --- .../datasources/feature/fdsInspireHY.xml | 40 ++ .../datasources/feature/fdsInspireHYFull.xml | 346 ++++++++++++++++ deegree-workspaces/Hydrography/jdbc/conHY.xml | 3 + .../Hydrography/services/download_HY.xml | 36 ++ .../services/download_HY_metadata.xml | 50 +++ .../Hydrography/spring/cds-inspire.xml | 3 + .../cds/etl/theme/hydronode/HydroNode.java | 149 ------- .../theme/hydronode/HydroNodeValidator.java | 354 +++++----------- .../sql/populate-manager-schema-hydronode.sql | 2 +- .../hydronode/HydroNodeValidatorTest.java | 139 +++++++ .../ProductionFacilityValidatorTest.java | 392 ------------------ .../watercourselink/WatercourseLink.java | 156 +------ .../WatercourseLinkValidator.java | 170 -------- ...opulate-manager-schema-watercourselink.sql | 2 +- .../WatercourseLinkValidatorTest.java | 58 --- themes/pom.xml | 10 + 16 files changed, 733 insertions(+), 1177 deletions(-) create mode 100644 deegree-workspaces/Hydrography/datasources/feature/fdsInspireHY.xml create mode 100644 deegree-workspaces/Hydrography/datasources/feature/fdsInspireHYFull.xml create mode 100644 deegree-workspaces/Hydrography/jdbc/conHY.xml create mode 100644 deegree-workspaces/Hydrography/services/download_HY.xml create mode 100644 deegree-workspaces/Hydrography/services/download_HY_metadata.xml create mode 100644 deegree-workspaces/Hydrography/spring/cds-inspire.xml create mode 100644 theme-hydronode/src/test/java/nl/ipo/cds/etl/theme/hydronode/HydroNodeValidatorTest.java delete mode 100644 theme-hydronode/src/test/java/nl/ipo/cds/etl/theme/hydronode/ProductionFacilityValidatorTest.java diff --git a/deegree-workspaces/Hydrography/datasources/feature/fdsInspireHY.xml b/deegree-workspaces/Hydrography/datasources/feature/fdsInspireHY.xml new file mode 100644 index 00000000..3cd19f62 --- /dev/null +++ b/deegree-workspaces/Hydrography/datasources/feature/fdsInspireHY.xml @@ -0,0 +1,40 @@ + + conHY + EPSG:28992 + http://www.inspire-provincies.nl/schemas/hy-n/3.0/HydroNetwork.xsd + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/deegree-workspaces/Hydrography/datasources/feature/fdsInspireHYFull.xml b/deegree-workspaces/Hydrography/datasources/feature/fdsInspireHYFull.xml new file mode 100644 index 00000000..7ab3bb79 --- /dev/null +++ b/deegree-workspaces/Hydrography/datasources/feature/fdsInspireHYFull.xml @@ -0,0 +1,346 @@ + + inspire + EPSG:4258 + ../../appschemas/inspire/hy-n/3.0/HydroNetwork.xsd + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/deegree-workspaces/Hydrography/jdbc/conHY.xml b/deegree-workspaces/Hydrography/jdbc/conHY.xml new file mode 100644 index 00000000..adfa6fd4 --- /dev/null +++ b/deegree-workspaces/Hydrography/jdbc/conHY.xml @@ -0,0 +1,3 @@ + + cds-inspire + diff --git a/deegree-workspaces/Hydrography/services/download_HY.xml b/deegree-workspaces/Hydrography/services/download_HY.xml new file mode 100644 index 00000000..9e2c7ca7 --- /dev/null +++ b/deegree-workspaces/Hydrography/services/download_HY.xml @@ -0,0 +1,36 @@ + + + + 2.0.0 + + + fdsInspireAM + + EPSG:28992 + EPSG:4326 + EPSG:4258 + EPSG:3035 + EPSG:3034 + EPSG:2583 + EPSG:25831 + EPSG:25832 + urn:ogc:def:crs:EPSG::28992 + urn:ogc:def:crs:EPSG::4326 + urn:ogc:def:crs:EPSG::4258 + urn:ogc:def:crs:EPSG::3035 + urn:ogc:def:crs:EPSG::3034 + urn:ogc:def:crs:EPSG::25830 + urn:ogc:def:crs:EPSG::25831 + urn:ogc:def:crs:EPSG::25832 + + -1 + + + application/gml+xml; version=3.2 + text/xml; subtype=gml/3.2.1 + + true + + + + diff --git a/deegree-workspaces/Hydrography/services/download_HY_metadata.xml b/deegree-workspaces/Hydrography/services/download_HY_metadata.xml new file mode 100644 index 00000000..b20bad50 --- /dev/null +++ b/deegree-workspaces/Hydrography/services/download_HY_metadata.xml @@ -0,0 +1,50 @@ + + + cds-inspire + + + + + + To be replaced by the DatabaseMetadataProvider + application/vnd.iso.19139+xml + + + + dut + + + + dut + + + + + + + + + + To be replaced by the DatabaseMetadataProvider + application/vnd.iso.19139+xml + + + + dut + + + + dut + + + + + + diff --git a/deegree-workspaces/Hydrography/spring/cds-inspire.xml b/deegree-workspaces/Hydrography/spring/cds-inspire.xml new file mode 100644 index 00000000..690c72e2 --- /dev/null +++ b/deegree-workspaces/Hydrography/spring/cds-inspire.xml @@ -0,0 +1,3 @@ + + nl.ipo.cds.deegree.Config + diff --git a/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/HydroNode.java b/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/HydroNode.java index 8edc32b2..01c1650b 100644 --- a/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/HydroNode.java +++ b/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/HydroNode.java @@ -18,43 +18,12 @@ public class HydroNode extends PersistableFeature { @Column(name = "inspire_id_local_id") private String inspireIdLocalId; - @Column(name = "production_facility_id") - private String productionFacilityId; - - @Column(name = "thematic_identifier") - private String thematicIdentifier; - - @Column(name = "thematic_identifier_scheme") - private String thematicIdentifierScheme; - @Column(name = "geometry") private Geometry geometry; - @Column(name = "function_activity") - private CodeType functionActivity; - - @Column(name = "function_input") - private CodeType functionInput; - - @Column(name = "function_output") - private CodeType functionOutput; - - @Column(name = "function_description") - private String functionDescription; - @Column(name = "name") private String name; - @Column(name = "surface_geometry") - private Geometry surfaceGeometry; - - @Column(name = "status_type") - private CodeType statusType; - - @Column(name = "status_description") - private String statusDescription; - - @MappableAttribute @CodeSpace("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility") public CodeType getInspireIdDatasetCode() { @@ -87,122 +56,4 @@ public void setGeometry(Geometry geometry) { this.geometry = geometry; } - @MappableAttribute - public String getProductionFacilityId() { - return productionFacilityId; - } - - @MappableAttribute - public void setProductionFacilityId(String productionFacilityId) { - this.productionFacilityId = productionFacilityId; - } - - @MappableAttribute - public String getThematicIdentifier() { - return thematicIdentifier; - } - - @MappableAttribute - public void setThematicIdentifier(String thematicIdentifier) { - this.thematicIdentifier = thematicIdentifier; - } - - @MappableAttribute - public String getThematicIdentifierScheme() { - return thematicIdentifierScheme; - } - - @MappableAttribute - public void setThematicIdentifierScheme(String thematicIdentifierScheme) { - this.thematicIdentifierScheme = thematicIdentifierScheme; - } - - @MappableAttribute - @CodeSpace("http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue") - public CodeType getFunctionActivity() { - return functionActivity; - } - - @MappableAttribute - @CodeSpace("http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue") - public void setFunctionActivity(CodeType functionActivity) { - this.functionActivity = functionActivity; - } - - @MappableAttribute - @CodeSpace("http://inspire.ec.europa.eu/codeList/ProductCPAValue") - public CodeType getFunctionInput() { - return functionInput; - } - - @MappableAttribute - @CodeSpace("http://inspire.ec.europa.eu/codeList/ProductCPAValue") - public void setFunctionInput(CodeType functionInput) { - this.functionInput = functionInput; - } - - @MappableAttribute - @CodeSpace("http://inspire.ec.europa.eu/codeList/ProductCPAValue") - public CodeType getFunctionOutput() { - return functionOutput; - } - - @MappableAttribute - @CodeSpace("http://inspire.ec.europa.eu/codeList/ProductCPAValue") - public void setFunctionOutput(CodeType functionOutput) { - this.functionOutput = functionOutput; - } - - @MappableAttribute - public String getFunctionDescription() { - return functionDescription; - } - - @MappableAttribute - public void setFunctionDescription(String functionDescription) { - this.functionDescription = functionDescription; - } - - @MappableAttribute - public String getName() { - return name; - } - - @MappableAttribute - public void setName(String name) { - this.name = name; - } - - @MappableAttribute - public Geometry getSurfaceGeometry() { - return surfaceGeometry; - } - - @MappableAttribute - public void setSurfaceGeometry(Geometry surfaceGeometry) { - this.surfaceGeometry = surfaceGeometry; - } - - @MappableAttribute - @CodeSpace("http://inspire.ec.europa.eu/codeList/ConditionOfFacilityValue") - public CodeType getStatusType() { - return statusType; - } - - @MappableAttribute - @CodeSpace("http://inspire.ec.europa.eu/codeList/ConditionOfFacilityValue") - public void setStatusType(CodeType statusType) { - this.statusType = statusType; - } - - @MappableAttribute - public String getStatusDescription() { - return statusDescription; - } - - @MappableAttribute - public void setStatusDescription(String statusDescription) { - this.statusDescription = statusDescription; - } - } diff --git a/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/HydroNodeValidator.java b/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/HydroNodeValidator.java index 7e2cb280..bf51d0a0 100644 --- a/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/HydroNodeValidator.java +++ b/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/HydroNodeValidator.java @@ -3,10 +3,8 @@ import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_CODE_CODESPACE_INVALID; import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_CODE_INVALID; import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_EMPTY; -import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_GROUP_INCONSISTENT; import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_NULL; import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_DISCONTINUITY; -import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_EMPTY_MULTIGEOMETRY; import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_EXTERIOR_RING_CW; import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_INTERIOR_DISCONNECTED; import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_INTERIOR_RINGS_TOUCH; @@ -14,7 +12,6 @@ import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_INTERIOR_RING_CCW; import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_INTERIOR_RING_OUTSIDE_EXTERIOR; import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_INTERIOR_RING_TOUCHES_EXTERIOR; -import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE; import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_POINT_DUPLICATION; import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_RING_NOT_CLOSED; import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_RING_SELF_INTERSECTION; @@ -37,283 +34,122 @@ import org.deegree.geometry.Geometry; -public class HydroNodeValidator extends AbstractValidator { +public class HydroNodeValidator extends + AbstractValidator { - private final CodeExpression inspireIdDatasetCode = code ("inspireIdDatasetCode"); + private final CodeExpression inspireIdDatasetCode = code("inspireIdDatasetCode"); - private final AttributeExpression inspireIdLocalId = stringAttr ("inspireIdLocalId"); + private final AttributeExpression inspireIdLocalId = stringAttr("inspireIdLocalId"); - private final AttributeExpression productionFacilityId = stringAttr ("productionFacilityId"); + private final GeometryExpression geometry = geometry("geometry"); - private final AttributeExpression thematicIdentifier = stringAttr ("thematicIdentifier"); + private final Constant inspireIdDatasetCodeSpace = constant("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility"); - private final AttributeExpression thematicIdentifierScheme = stringAttr ("thematicIdentifierScheme"); - - private final GeometryExpression geometry = geometry ("geometry"); - - private final CodeExpression functionActivity = code ("functionActivity"); - - private final CodeExpression functionInput = code ("functionInput"); - - private final CodeExpression functionOutput = code ("functionOutput"); - - private final AttributeExpression functionDescription = stringAttr ("functionDescription"); - - private final AttributeExpression name = stringAttr ("name"); - - private final GeometryExpression surfaceGeometry = geometry ("surfaceGeometry"); - - private final AttributeExpression statusDescription = stringAttr ("statusDescription"); - - private final CodeExpression statusType = code ("statusType"); - - private final Constant inspireIdDatasetCodeSpace = constant ("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility"); - - private final Constant functionActivityCodeSpace = constant ("http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue"); - - private final Constant functionInputCodeSpace = constant ("http://inspire.ec.europa.eu/codeList/ProductCPAValue"); - - private final Constant functionOutputCodeSpace = constant ("http://inspire.ec.europa.eu/codeList/ProductCPAValue"); - - private final Constant statusTypeCodeSpace = constant ("http://inspire.ec.europa.eu/codeList/ConditionOfFacilityValue"); - - public HydroNodeValidator(final Map validatorMessages) throws CompilerException { + public HydroNodeValidator(final Map validatorMessages) + throws CompilerException { super(Context.class, HydroNode.class, validatorMessages); compile(); } @Override - public Context beforeJob(final EtlJob job, final CodeListFactory codeListFactory, + public Context beforeJob(final EtlJob job, + final CodeListFactory codeListFactory, final ValidationReporter reporter) { return new Context(codeListFactory, reporter); } - public Validator getInspireIdDatasetCodeValidator () { - return validate ( - and( - validate (not (inspireIdDatasetCode.isNull ())).message (ATTRIBUTE_NULL, constant (inspireIdDatasetCode.name)), - validate (not (isBlank (inspireIdDatasetCode.code()))).message (ATTRIBUTE_EMPTY, constant (inspireIdDatasetCode.name)), - validate (inspireIdDatasetCode.hasCodeSpace (inspireIdDatasetCodeSpace)).message (ATTRIBUTE_CODE_CODESPACE_INVALID, inspireIdDatasetCode.codeSpace(), constant(inspireIdDatasetCode.name), inspireIdDatasetCodeSpace), - validate (inspireIdDatasetCode.isValid ()).message (ATTRIBUTE_CODE_INVALID, inspireIdDatasetCode.code(), constant (inspireIdDatasetCode.name), inspireIdDatasetCodeSpace) - ).shortCircuit() - ); - } - - public Validator getInspireIdLocalIdValidator () { - return validate ( - and( - validate (not (inspireIdLocalId.isNull ())).message (ATTRIBUTE_NULL, constant(inspireIdLocalId.name)), - validate (not (isBlank (inspireIdLocalId))).message (ATTRIBUTE_EMPTY, constant(inspireIdLocalId.name)) - ).shortCircuit() - ); - } - - public Validator getProductionFacilityIdValidator () { - return validate ( - and( - validate (not (productionFacilityId.isNull ())).message (ATTRIBUTE_NULL, constant(productionFacilityId.name)), - validate (not (isBlank (productionFacilityId))).message (ATTRIBUTE_EMPTY, constant(productionFacilityId.name)) - ).shortCircuit() - ); - } - - public Validator getThematicIdentifierValidator () { - return validate ( - and( - ifExp (not (or (thematicIdentifier.isNull (), isBlank (thematicIdentifier))), - and ( - validate (not (thematicIdentifierScheme.isNull())).message (ATTRIBUTE_GROUP_INCONSISTENT, constant (thematicIdentifierScheme.name), constant (thematicIdentifier.name)), - validate (not (isBlank (thematicIdentifierScheme))).message (ATTRIBUTE_GROUP_INCONSISTENT, constant (thematicIdentifierScheme.name), constant (thematicIdentifier.name)) - ).shortCircuit(), - constant(true) - ), - ifExp (not (or (thematicIdentifierScheme.isNull (), isBlank (thematicIdentifierScheme))), - and ( - validate (not (thematicIdentifier.isNull())).message (ATTRIBUTE_GROUP_INCONSISTENT, constant (thematicIdentifier.name), constant (thematicIdentifierScheme.name)), - validate (not (isBlank (thematicIdentifier))).message (ATTRIBUTE_GROUP_INCONSISTENT, constant (thematicIdentifier.name), constant (thematicIdentifierScheme.name)) - ).shortCircuit(), - constant(true) - ) - ) - ); - } - - public Validator getGeometryValidator () { - return validate ( - and ( - // The following validations short-circuit, there must be a non-null and non-empty, non-point geometry: - validate (not (geometry.isNull ())).message (ATTRIBUTE_NULL, constant(geometry.name)), + public Validator getInspireIdDatasetCodeValidator() { + return validate(and( + validate(not(inspireIdDatasetCode.isNull())).message( + ATTRIBUTE_NULL, constant(inspireIdDatasetCode.name)), + validate(not(isBlank(inspireIdDatasetCode.code()))).message( + ATTRIBUTE_EMPTY, constant(inspireIdDatasetCode.name)), + validate( + inspireIdDatasetCode + .hasCodeSpace(inspireIdDatasetCodeSpace)) + .message(ATTRIBUTE_CODE_CODESPACE_INVALID, + inspireIdDatasetCode.codeSpace(), + constant(inspireIdDatasetCode.name), + inspireIdDatasetCodeSpace), + validate(inspireIdDatasetCode.isValid()).message( + ATTRIBUTE_CODE_INVALID, inspireIdDatasetCode.code(), + constant(inspireIdDatasetCode.name), + inspireIdDatasetCodeSpace)).shortCircuit()); + } + + public Validator getInspireIdLocalIdValidator() { + return validate(and( + validate(not(inspireIdLocalId.isNull())).message( + ATTRIBUTE_NULL, constant(inspireIdLocalId.name)), + validate(not(isBlank(inspireIdLocalId))).message( + ATTRIBUTE_EMPTY, constant(inspireIdLocalId.name))) + .shortCircuit()); + } + + public Validator getGeometryValidator() { + return validate(and( + // The following validations short-circuit, there must be a non-null and + // non-empty, non-point geometry: + validate(not(geometry.isNull())).message(ATTRIBUTE_NULL, + constant(geometry.name)), // Non short-circuited validations: - and ( - // Short circuit to prevent the interiorDisconnected validation if - // any of the other validations fail: - and ( - and ( - validate (not (geometry.hasCurveDuplicatePoint ())).message (GEOMETRY_POINT_DUPLICATION, lastLocation ()), - validate (not (geometry.hasCurveDiscontinuity ())).message (GEOMETRY_DISCONTINUITY), - validate (not (geometry.hasCurveSelfIntersection ())).message (GEOMETRY_SELF_INTERSECTION, lastLocation ()), - validate (not (geometry.hasUnclosedRing ())).message (GEOMETRY_RING_NOT_CLOSED), - validate (not (geometry.hasRingSelfIntersection ())).message (GEOMETRY_RING_SELF_INTERSECTION, lastLocation ()), - validate (not (geometry.hasTouchingInteriorRings ())).message(GEOMETRY_INTERIOR_RINGS_TOUCH, lastLocation ()), - validate (not (geometry.hasInteriorRingsWithin ())).message (GEOMETRY_INTERIOR_RINGS_WITHIN) - ), - validate (not (geometry.isInteriorDisconnected ())).message (GEOMETRY_INTERIOR_DISCONNECTED) - ).shortCircuit (), - - // Non-blocking validations: - validate (not (geometry.hasExteriorRingCW ())).nonBlocking ().message (GEOMETRY_EXTERIOR_RING_CW), - validate (not (geometry.hasInteriorRingCCW ())).nonBlocking ().message (GEOMETRY_INTERIOR_RING_CCW), - validate (not (geometry.hasInteriorRingTouchingExterior ())).nonBlocking ().message (GEOMETRY_INTERIOR_RING_TOUCHES_EXTERIOR, lastLocation ()), - validate (not (geometry.hasInteriorRingOutsideExterior ())).nonBlocking ().message (GEOMETRY_INTERIOR_RING_OUTSIDE_EXTERIOR), - - // SRS validations: - and ( - validate (geometry.hasSrs ()).message (GEOMETRY_SRS_NULL), - validate (geometry.isSrs (constant ("28992"))).message (GEOMETRY_SRS_NOT_RD, geometry.srsName ()) - ).shortCircuit() - ) - ).shortCircuit () - ); - } - - public Validator getFunctionActivityValidator () { - return validate ( - and( - validate (not (functionActivity.isNull ())).message (ATTRIBUTE_NULL, constant(functionActivity.name)), - validate (functionActivity.hasCodeSpace (functionActivityCodeSpace)).message (ATTRIBUTE_CODE_CODESPACE_INVALID, functionActivity.codeSpace(), constant(functionActivity.name), functionActivityCodeSpace), - validate (not (isBlank (functionActivity.code()))).message (ATTRIBUTE_EMPTY, constant(functionActivity.name)) - // must be deactivated as long as codelist http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue is empty -// validate (functionActivity.isValid ()).message (ATTRIBUTE_CODE_INVALID, functionActivity.code(), constant(functionActivity.name), functionActivityCodeSpace) - ).shortCircuit() - ); - } - - public Validator getFunctionInputValidator () { - return validate ( - ifExp ( - functionInput.isNull (), - constant(true), and( - validate (functionInput.hasCodeSpace (functionInputCodeSpace)).message (ATTRIBUTE_CODE_CODESPACE_INVALID, functionInput.codeSpace(), constant(functionInput.name), functionInputCodeSpace), - validate (not (isBlank (functionInput.code()))).message (ATTRIBUTE_EMPTY, constant(functionInput.name)) - // must be deactivated as long as codelist http://inspire.ec.europa.eu/codeList/ProductCPAValue is empty -// validate (functionInput.isValid ()).message (ATTRIBUTE_CODE_INVALID, functionInput.code(), constant(functionInput.name), functionInputCodeSpace) - ).shortCircuit() - ) - ); - } - - public Validator getFunctionOutputValidator () { - return validate ( - ifExp ( - functionOutput.isNull (), - constant(true), + // Short circuit to prevent the interiorDisconnected validation + // if + // any of the other validations fail: and( - validate (functionOutput.hasCodeSpace (functionOutputCodeSpace)).message (ATTRIBUTE_CODE_CODESPACE_INVALID, functionOutput.codeSpace(), constant(functionOutput.name), functionOutputCodeSpace), - validate (not (isBlank (functionOutput.code()))).message (ATTRIBUTE_EMPTY, constant(functionOutput.name)) - // must be deactivated as long as codelist http://inspire.ec.europa.eu/codeList/ProductCPAValue is empty -// validate (functionOutput.isValid ()).message (ATTRIBUTE_CODE_INVALID, functionOutput.code(), constant(functionOutput.name), functionOutputCodeSpace) - ).shortCircuit() - ) - ); - } - - public Validator getFunctionDescriptionValidator () { - return validate ( - ifExp ( - functionDescription.isNull (), - constant(true), - validate (not (isBlank (functionDescription))).message (ATTRIBUTE_EMPTY, constant(functionDescription.name)) - ) - ); - } - - public Validator getNameValidator () { - return validate ( - ifExp ( - name.isNull (), - constant(true), - validate (not (isBlank (name))).message (ATTRIBUTE_EMPTY, constant(name.name)) - ) - ); - } - - public Validator getSurfaceGeometryValidator () { - return validate ( - ifExp( - surfaceGeometry.isNull (), - constant(true), - and ( - // The following validations short-circuit, there must be a non-empty, Surface geometry: - validate (not (surfaceGeometry.isEmptyMultiGeometry())).message (GEOMETRY_EMPTY_MULTIGEOMETRY), - validate (surfaceGeometry.isSurfaceOrMultiSurface()).message (GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE), - // Non short-circuited validations: - and ( - // Short circuit to prevent the interiorDisconnected validation if - // any of the other validations fail: - and ( - and ( - validate (not (surfaceGeometry.hasCurveDuplicatePoint ())).message (GEOMETRY_POINT_DUPLICATION, lastLocation ()), - validate (not (surfaceGeometry.hasCurveDiscontinuity ())).message (GEOMETRY_DISCONTINUITY), - validate (not (surfaceGeometry.hasCurveSelfIntersection ())).message (GEOMETRY_SELF_INTERSECTION, lastLocation ()), - validate (not (surfaceGeometry.hasUnclosedRing ())).message (GEOMETRY_RING_NOT_CLOSED), - validate (not (surfaceGeometry.hasRingSelfIntersection ())).message (GEOMETRY_RING_SELF_INTERSECTION, lastLocation ()), - validate (not (surfaceGeometry.hasTouchingInteriorRings ())).message(GEOMETRY_INTERIOR_RINGS_TOUCH, lastLocation ()), - validate (not (surfaceGeometry.hasInteriorRingsWithin ())).message (GEOMETRY_INTERIOR_RINGS_WITHIN) - ), - validate (not (surfaceGeometry.isInteriorDisconnected ())).message (GEOMETRY_INTERIOR_DISCONNECTED) - ).shortCircuit (), + and(validate(not(geometry.hasCurveDuplicatePoint())) + .message(GEOMETRY_POINT_DUPLICATION, + lastLocation()), + validate(not(geometry.hasCurveDiscontinuity())) + .message(GEOMETRY_DISCONTINUITY), + validate( + not(geometry.hasCurveSelfIntersection())) + .message(GEOMETRY_SELF_INTERSECTION, + lastLocation()), + validate(not(geometry.hasUnclosedRing())) + .message(GEOMETRY_RING_NOT_CLOSED), + validate( + not(geometry.hasRingSelfIntersection())) + .message( + GEOMETRY_RING_SELF_INTERSECTION, + lastLocation()), + validate( + not(geometry.hasTouchingInteriorRings())) + .message(GEOMETRY_INTERIOR_RINGS_TOUCH, + lastLocation()), + validate(not(geometry.hasInteriorRingsWithin())) + .message(GEOMETRY_INTERIOR_RINGS_WITHIN)), + validate(not(geometry.isInteriorDisconnected())) + .message(GEOMETRY_INTERIOR_DISCONNECTED)) + .shortCircuit(), // Non-blocking validations: - validate (not (surfaceGeometry.hasExteriorRingCW ())).nonBlocking ().message (GEOMETRY_EXTERIOR_RING_CW), - validate (not (surfaceGeometry.hasInteriorRingCCW ())).nonBlocking ().message (GEOMETRY_INTERIOR_RING_CCW), - validate (not (surfaceGeometry.hasInteriorRingTouchingExterior ())).nonBlocking ().message (GEOMETRY_INTERIOR_RING_TOUCHES_EXTERIOR, lastLocation ()), - validate (not (surfaceGeometry.hasInteriorRingOutsideExterior ())).nonBlocking ().message (GEOMETRY_INTERIOR_RING_OUTSIDE_EXTERIOR), + validate(not(geometry.hasExteriorRingCW())) + .nonBlocking().message( + GEOMETRY_EXTERIOR_RING_CW), + validate(not(geometry.hasInteriorRingCCW())) + .nonBlocking().message( + GEOMETRY_INTERIOR_RING_CCW), + validate( + not(geometry.hasInteriorRingTouchingExterior())) + .nonBlocking() + .message( + GEOMETRY_INTERIOR_RING_TOUCHES_EXTERIOR, + lastLocation()), + validate(not(geometry.hasInteriorRingOutsideExterior())) + .nonBlocking() + .message( + GEOMETRY_INTERIOR_RING_OUTSIDE_EXTERIOR), // SRS validations: - and ( - validate (surfaceGeometry.hasSrs ()).message (GEOMETRY_SRS_NULL), - validate (surfaceGeometry.isSrs (constant ("28992"))).message (GEOMETRY_SRS_NOT_RD, surfaceGeometry.srsName ()) - ).shortCircuit() - ) - ).shortCircuit () - ) - ); - } - - public Validator getStatusValidator () { - return validate ( - not ( - and ( - statusType.isNull(), - not (statusDescription.isNull()) - ) - ) - ).message (ATTRIBUTE_GROUP_INCONSISTENT, constant(statusType.name), constant(statusDescription.name)); - } - - public Validator getStatusDescriptionValidator () { - return validate ( - ifExp ( - statusDescription.isNull (), - constant(true), - validate (not (isBlank (statusDescription))).message (ATTRIBUTE_EMPTY, constant(statusDescription.name)) - ) - ); - } - - public Validator getStatusTypeValidator () { - return validate ( - ifExp ( - statusType.isNull (), - constant(true), - and( - validate (statusType.hasCodeSpace (statusTypeCodeSpace)).message (ATTRIBUTE_CODE_CODESPACE_INVALID, statusType.codeSpace(), constant(statusType.name), statusTypeCodeSpace), - validate (not (isBlank (statusType.code()))).message (ATTRIBUTE_EMPTY, constant(statusType.name)), - validate (statusType.isValid ()).message (ATTRIBUTE_CODE_INVALID, statusType.code(), constant(statusType.name), statusTypeCodeSpace) - ).shortCircuit() - ) - ); + and( + validate(geometry.hasSrs()).message( + GEOMETRY_SRS_NULL), + validate(geometry.isSrs(constant("28992"))) + .message(GEOMETRY_SRS_NOT_RD, + geometry.srsName())) + .shortCircuit())).shortCircuit()); } } diff --git a/theme-hydronode/src/main/sql/populate-manager-schema-hydronode.sql b/theme-hydronode/src/main/sql/populate-manager-schema-hydronode.sql index 3b253e31..8decfd98 100644 --- a/theme-hydronode/src/main/sql/populate-manager-schema-hydronode.sql +++ b/theme-hydronode/src/main/sql/populate-manager-schema-hydronode.sql @@ -4,7 +4,7 @@ -- Names must match constants defined corresponding ThemeConfig insert into manager.thema (id, naam) values ((select nextval('manager.hibernate_sequence')), 'HydroNode'); -insert into manager.datasettype (id, naam, thema_id) values ((select nextval('manager.hibernate_sequence')), 'HydroNetworkNodesNL', (select id from manager.thema t where t.naam = 'HydroNode')); +insert into manager.datasettype (id, naam, thema_id) values ((select nextval('manager.hibernate_sequence')), 'HydroNodesNL', (select id from manager.thema t where t.naam = 'HydroNode')); insert into manager.bronhouder (id, code, contact_naam, contact_adres, contact_postcode, contact_plaats, naam, contact_emailadres, contact_telefoonnummer, common_name) select nextval('manager.hibernate_sequence'), 'elf', 'ELF Project', '', '', '', 'ELF Project', 'inspire@idgis.nl', '', 'elfproject' where not exists (select * from manager.bronhouder where code = 'elf'); diff --git a/theme-hydronode/src/test/java/nl/ipo/cds/etl/theme/hydronode/HydroNodeValidatorTest.java b/theme-hydronode/src/test/java/nl/ipo/cds/etl/theme/hydronode/HydroNodeValidatorTest.java new file mode 100644 index 00000000..cec8e46a --- /dev/null +++ b/theme-hydronode/src/test/java/nl/ipo/cds/etl/theme/hydronode/HydroNodeValidatorTest.java @@ -0,0 +1,139 @@ +package nl.ipo.cds.etl.theme.hydronode; + +import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_CODE_CODESPACE_INVALID; +import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_CODE_INVALID; +import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_EMPTY; +import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_GROUP_INCONSISTENT; +import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_NULL; +import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_EMPTY_MULTIGEOMETRY; +import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE; +import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_POINT_DUPLICATION; +import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_SELF_INTERSECTION; +import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_SRS_NOT_RD; +import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_SRS_NULL; + +import java.util.Collections; + +import nl.ipo.cds.etl.test.GeometryConstants; +import nl.ipo.cds.etl.test.ValidationRunner; +import nl.ipo.cds.etl.theme.hydronode.Context; +import nl.ipo.cds.etl.theme.hydronode.Message; +import nl.ipo.cds.etl.theme.hydronode.HydroNode; +import nl.ipo.cds.etl.theme.hydronode.HydroNodeValidator; + +import org.deegree.commons.tom.ows.CodeType; +import org.junit.Before; +import org.junit.Test; + +public class HydroNodeValidatorTest { + + private HydroNodeValidator validator; + private ValidationRunner runner; + private GeometryConstants geom; + + @Before + public void createValidator() throws Exception { + validator = new HydroNodeValidator(Collections.emptyMap()); + runner = new ValidationRunner<>(validator, HydroNode.class); + geom = new GeometryConstants("EPSG:28992"); + } + + private ValidationRunner.Runner run(final String validationName) { + return runner.validation(validationName); + } + + @Test + public void getInspireIdDatasetCodeValidator () throws Throwable { + + run ("inspireIdDatasetCode") + .with (null) + .assertOnlyKey (ATTRIBUTE_NULL); + + run ("inspireIdDatasetCode") + .with (new CodeType("")) + .assertOnlyKey (ATTRIBUTE_EMPTY); + + run ("inspireIdDatasetCode") + .with (new CodeType("bogus")) + .assertOnlyKey (ATTRIBUTE_CODE_CODESPACE_INVALID); + + run ("inspireIdDatasetCode") + .withCodeList ("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility", "lgrinr") + .with (new CodeType("value1", "http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility")) + .assertOnlyKey (ATTRIBUTE_CODE_INVALID); + + run ("inspireIdDatasetCode") + .withCodeList ("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility", "lgrinr") + .with (new CodeType("lgrinr", "http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility")) + .assertNoMessages(); + } + + @Test + public void getInspireIdLocalIdValidator () throws Throwable { + + run ("inspireIdLocalId") + .with (null) + .assertOnlyKey (ATTRIBUTE_NULL); + + run ("inspireIdLocalId") + .with ("") + .assertOnlyKey (ATTRIBUTE_EMPTY); + + run ("inspireIdLocalId") + .with ("nl1000") + .assertNoMessages(); + } + + @Test + public void testGeometry () throws Exception { + + run ("geometry") + .with (null) + .assertOnlyKey (ATTRIBUTE_NULL); + + run ("geometry") + .with (geom.lineString (null)) + .assertOnlyKey (GEOMETRY_SRS_NULL); + + run ("geometry") + .with (geom.lineString (geom.getSrs ("EPSG:3857"))) + .assertOnlyKey (GEOMETRY_SRS_NOT_RD); + + run ("geometry") + .with (geom.point (1,2)) + .assertNoMessages (); + + run ("geometry") + .with (geom.lineString ()) + .assertNoMessages (); + + run ("geometry") + .with (geom.multiPolygon()) + .assertNoMessages (); + + run ("geometry") + .with (geom.lineStringDuplicatePoint ()) + .assertOnlyKey (GEOMETRY_POINT_DUPLICATION); + + run ("geometry") + .with (geom.lineStringSelfIntersection ()) + .assertOnlyKey (GEOMETRY_SELF_INTERSECTION); + } + + @Test + public void getNameValidator () throws Throwable { + + run ("name") + .with (null) + .assertNoMessages(); + + run ("name") + .with ("") + .assertOnlyKey (ATTRIBUTE_EMPTY); + + run ("name") + .with ("nl1000") + .assertNoMessages(); + } + +} diff --git a/theme-hydronode/src/test/java/nl/ipo/cds/etl/theme/hydronode/ProductionFacilityValidatorTest.java b/theme-hydronode/src/test/java/nl/ipo/cds/etl/theme/hydronode/ProductionFacilityValidatorTest.java deleted file mode 100644 index e5b7874d..00000000 --- a/theme-hydronode/src/test/java/nl/ipo/cds/etl/theme/hydronode/ProductionFacilityValidatorTest.java +++ /dev/null @@ -1,392 +0,0 @@ -package nl.ipo.cds.etl.theme.hydronode; - -import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_CODE_CODESPACE_INVALID; -import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_CODE_INVALID; -import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_EMPTY; -import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_GROUP_INCONSISTENT; -import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_NULL; -import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_EMPTY_MULTIGEOMETRY; -import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE; -import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_POINT_DUPLICATION; -import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_SELF_INTERSECTION; -import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_SRS_NOT_RD; -import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_SRS_NULL; - -import java.util.Collections; - -import nl.ipo.cds.etl.test.GeometryConstants; -import nl.ipo.cds.etl.test.ValidationRunner; -import nl.ipo.cds.etl.theme.hydronode.Context; -import nl.ipo.cds.etl.theme.hydronode.Message; -import nl.ipo.cds.etl.theme.hydronode.HydroNode; -import nl.ipo.cds.etl.theme.hydronode.HydroNodeValidator; - -import org.deegree.commons.tom.ows.CodeType; -import org.junit.Before; -import org.junit.Test; - -public class ProductionFacilityValidatorTest { - - private HydroNodeValidator validator; - private ValidationRunner runner; - private GeometryConstants geom; - - @Before - public void createValidator() throws Exception { - validator = new HydroNodeValidator(Collections.emptyMap()); - runner = new ValidationRunner<>(validator, HydroNode.class); - geom = new GeometryConstants("EPSG:28992"); - } - - private ValidationRunner.Runner run(final String validationName) { - return runner.validation(validationName); - } - - @Test - public void getInspireIdDatasetCodeValidator () throws Throwable { - - run ("inspireIdDatasetCode") - .with (null) - .assertOnlyKey (ATTRIBUTE_NULL); - - run ("inspireIdDatasetCode") - .with (new CodeType("")) - .assertOnlyKey (ATTRIBUTE_EMPTY); - - run ("inspireIdDatasetCode") - .with (new CodeType("bogus")) - .assertOnlyKey (ATTRIBUTE_CODE_CODESPACE_INVALID); - - run ("inspireIdDatasetCode") - .withCodeList ("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility", "lgrinr") - .with (new CodeType("value1", "http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility")) - .assertOnlyKey (ATTRIBUTE_CODE_INVALID); - - run ("inspireIdDatasetCode") - .withCodeList ("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility", "lgrinr") - .with (new CodeType("lgrinr", "http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility")) - .assertNoMessages(); - } - - @Test - public void getInspireIdLocalIdValidator () throws Throwable { - - run ("inspireIdLocalId") - .with (null) - .assertOnlyKey (ATTRIBUTE_NULL); - - run ("inspireIdLocalId") - .with ("") - .assertOnlyKey (ATTRIBUTE_EMPTY); - - run ("inspireIdLocalId") - .with ("nl1000") - .assertNoMessages(); - } - - @Test - public void getProductionFacilityIdValidator () throws Throwable { - - run ("productionFacilityId") - .with (null) - .assertOnlyKey (ATTRIBUTE_NULL); - - run ("productionFacilityId") - .with ("") - .assertOnlyKey (ATTRIBUTE_EMPTY); - - run ("productionFacilityId") - .with ("nl1000") - .assertNoMessages(); - } - - @Test - public void getThematicIdentifierValidator () throws Throwable { - - HydroNode feature = new HydroNode(); - feature.setThematicIdentifier("a"); - feature.setThematicIdentifierScheme(null); - run ("thematicIdentifier") - .withFeature(feature ) - .assertOnlyKey (ATTRIBUTE_GROUP_INCONSISTENT); - - feature.setThematicIdentifier(null); - feature.setThematicIdentifierScheme("a"); - run ("thematicIdentifier") - .withFeature(feature ) - .assertOnlyKey (ATTRIBUTE_GROUP_INCONSISTENT); - - feature.setThematicIdentifier(null); - feature.setThematicIdentifierScheme(null); - run ("thematicIdentifier") - .withFeature(feature ) - .assertNoMessages (); - - feature.setThematicIdentifier("a"); - feature.setThematicIdentifierScheme("b"); - run ("thematicIdentifier") - .withFeature(feature ) - .assertNoMessages (); - } - - @Test - public void testGeometry () throws Exception { - - run ("geometry") - .with (null) - .assertOnlyKey (ATTRIBUTE_NULL); - - run ("geometry") - .with (geom.lineString (null)) - .assertOnlyKey (GEOMETRY_SRS_NULL); - - run ("geometry") - .with (geom.lineString (geom.getSrs ("EPSG:3857"))) - .assertOnlyKey (GEOMETRY_SRS_NOT_RD); - - run ("geometry") - .with (geom.point (1,2)) - .assertNoMessages (); - - run ("geometry") - .with (geom.lineString ()) - .assertNoMessages (); - - run ("geometry") - .with (geom.multiPolygon()) - .assertNoMessages (); - - run ("geometry") - .with (geom.lineStringDuplicatePoint ()) - .assertOnlyKey (GEOMETRY_POINT_DUPLICATION); - - run ("geometry") - .with (geom.lineStringSelfIntersection ()) - .assertOnlyKey (GEOMETRY_SELF_INTERSECTION); - } - - @Test - public void getFunctionActivityValidator () throws Throwable { - - run ("functionActivity") - .with (null) - .assertKey (ATTRIBUTE_NULL); - - run ("functionActivity") - .with (new CodeType("")) - .assertKey (ATTRIBUTE_CODE_CODESPACE_INVALID); - - run ("functionActivity") - .with (new CodeType("bogus")) - .assertOnlyKey (ATTRIBUTE_CODE_CODESPACE_INVALID); - - run ("functionActivity") - .withCodeList ("http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue", "lgrinr") - .with (new CodeType("value1", "http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue")) - .assertNoMessages(); -// code value validation deactivated -// .assertOnlyKey (ATTRIBUTE_CODE_INVALID); - - run ("functionActivity") - .withCodeList ("http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue", "lgrinr") - .with (new CodeType("lgrinr", "http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue")) - .assertNoMessages(); - } - - @Test - public void getFunctionInputValidator () throws Throwable { - - run ("functionInput") - .with (null) - .assertNoMessages(); - - run ("functionInput") - .with (new CodeType("")) - .assertKey (ATTRIBUTE_CODE_CODESPACE_INVALID); - - run ("functionInput") - .with (new CodeType("bogus")) - .assertOnlyKey (ATTRIBUTE_CODE_CODESPACE_INVALID); - - run ("functionInput") - .withCodeList ("http://inspire.ec.europa.eu/codeList/ProductCPAValue", "lgrinr") - .with (new CodeType("value1", "http://inspire.ec.europa.eu/codeList/ProductCPAValue")) - .assertNoMessages(); -// code value validation deactivated -// .assertOnlyKey (ATTRIBUTE_CODE_INVALID); - - - run ("functionInput") - .withCodeList ("http://inspire.ec.europa.eu/codeList/ProductCPAValue", "lgrinr") - .with (new CodeType("lgrinr", "http://inspire.ec.europa.eu/codeList/ProductCPAValue")) - .assertNoMessages(); - } - - @Test - public void getFunctionOutputValidator () throws Throwable { - - run ("functionOutput") - .with (null) - .assertNoMessages(); - - run ("functionOutput") - .with (new CodeType("")) - .assertKey (ATTRIBUTE_CODE_CODESPACE_INVALID); - - run ("functionOutput") - .with (new CodeType("bogus")) - .assertOnlyKey (ATTRIBUTE_CODE_CODESPACE_INVALID); - - run ("functionOutput") - .withCodeList ("http://inspire.ec.europa.eu/codeList/ProductCPAValue", "lgrinr") - .with (new CodeType("value1", "http://inspire.ec.europa.eu/codeList/ProductCPAValue")) - .assertNoMessages(); -// code value validation deactivated -// .assertOnlyKey (ATTRIBUTE_CODE_INVALID); - - - run ("functionOutput") - .withCodeList ("http://inspire.ec.europa.eu/codeList/ProductCPAValue", "lgrinr") - .with (new CodeType("lgrinr", "http://inspire.ec.europa.eu/codeList/ProductCPAValue")) - .assertNoMessages(); - } - - @Test - public void getFunctionDescriptionValidator () throws Throwable { - - run ("functionDescription") - .with (null) - .assertNoMessages(); - - run ("functionDescription") - .with ("") - .assertOnlyKey (ATTRIBUTE_EMPTY); - - run ("functionDescription") - .with ("nl1000") - .assertNoMessages(); - } - - @Test - public void getNameValidator () throws Throwable { - - run ("name") - .with (null) - .assertNoMessages(); - - run ("name") - .with ("") - .assertOnlyKey (ATTRIBUTE_EMPTY); - - run ("name") - .with ("nl1000") - .assertNoMessages(); - } - - @Test - public void testSurfaceGeometry () throws Exception { - - run ("surfaceGeometry") - .with (null) - .assertNoMessages (); - - run ("surfaceGeometry") - .with (geom.point (1,2)) - .assertOnlyKey (GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE); - - run ("surfaceGeometry") - .with (geom.lineString (null)) - .assertOnlyKey (GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE); - - run ("surfaceGeometry") - .with (geom.multiPoint ()) - .assertOnlyKey (GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE); - - run ("surfaceGeometry") - .with (geom.emptyMultiPolygon()) - .assertOnlyKey (GEOMETRY_EMPTY_MULTIGEOMETRY); - - run ("surfaceGeometry") - .with (geom.polygon(null)) - .assertOnlyKey (GEOMETRY_SRS_NULL); - - run ("surfaceGeometry") - .with (geom.polygon()) - .assertNoMessages (); - - run ("surfaceGeometry") - .with (geom.multiPolygon()) - .assertNoMessages (); - } - - @Test - public void getStatusValidator () throws Throwable { - - HydroNode feature = new HydroNode(); - feature.setStatusDescription("a"); - feature.setStatusType(null); - run ("status") - .withFeature(feature ) - .assertOnlyKey (ATTRIBUTE_GROUP_INCONSISTENT); - - feature = new HydroNode(); - feature.setStatusDescription("a"); - feature.setStatusType(new CodeType("b")); - run ("status") - .withFeature(feature ) - .assertNoMessages(); - - feature = new HydroNode(); - feature.setStatusType(new CodeType("b")); - run ("status") - .withFeature(feature ) - .assertNoMessages(); - - feature = new HydroNode(); - run ("status") - .withFeature(feature ) - .assertNoMessages(); - } - - @Test - public void getStatusTypeValidator () throws Throwable { - - run ("statusType") - .with (null) - .assertNoMessages(); - - run ("statusType") - .with (new CodeType("")) - .assertKey (ATTRIBUTE_CODE_CODESPACE_INVALID); - - run ("statusType") - .with (new CodeType("bogus")) - .assertOnlyKey (ATTRIBUTE_CODE_CODESPACE_INVALID); - - run ("statusType") - .withCodeList ("http://inspire.ec.europa.eu/codeList/ConditionOfFacilityValue", "functional") - .with (new CodeType("value1", "http://inspire.ec.europa.eu/codeList/ConditionOfFacilityValue")) - .assertOnlyKey (ATTRIBUTE_CODE_INVALID); - - run ("statusType") - .withCodeList ("http://inspire.ec.europa.eu/codeList/ConditionOfFacilityValue", "functional") - .with (new CodeType("functional", "http://inspire.ec.europa.eu/codeList/ConditionOfFacilityValue")) - .assertNoMessages(); - } - - @Test - public void getStatusDescriptionValidator () throws Throwable { - - run ("statusDescription") - .with (null) - .assertNoMessages(); - - run ("statusDescription") - .with ("") - .assertOnlyKey (ATTRIBUTE_EMPTY); - - run ("statusDescription") - .with ("nl1000") - .assertNoMessages(); - } -} diff --git a/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLink.java b/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLink.java index 59f77750..38a4afcb 100644 --- a/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLink.java +++ b/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLink.java @@ -18,43 +18,12 @@ public class WatercourseLink extends PersistableFeature { @Column(name = "inspire_id_local_id") private String inspireIdLocalId; - @Column(name = "production_facility_id") - private String productionFacilityId; - - @Column(name = "thematic_identifier") - private String thematicIdentifier; - - @Column(name = "thematic_identifier_scheme") - private String thematicIdentifierScheme; - @Column(name = "geometry") private Geometry geometry; - @Column(name = "function_activity") - private CodeType functionActivity; - - @Column(name = "function_input") - private CodeType functionInput; - - @Column(name = "function_output") - private CodeType functionOutput; - - @Column(name = "function_description") - private String functionDescription; - @Column(name = "name") private String name; - @Column(name = "surface_geometry") - private Geometry surfaceGeometry; - - @Column(name = "status_type") - private CodeType statusType; - - @Column(name = "status_description") - private String statusDescription; - - @MappableAttribute @CodeSpace("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility") public CodeType getInspireIdDatasetCode() { @@ -87,122 +56,15 @@ public void setGeometry(Geometry geometry) { this.geometry = geometry; } - @MappableAttribute - public String getProductionFacilityId() { - return productionFacilityId; - } - - @MappableAttribute - public void setProductionFacilityId(String productionFacilityId) { - this.productionFacilityId = productionFacilityId; - } - - @MappableAttribute - public String getThematicIdentifier() { - return thematicIdentifier; - } - - @MappableAttribute - public void setThematicIdentifier(String thematicIdentifier) { - this.thematicIdentifier = thematicIdentifier; - } - - @MappableAttribute - public String getThematicIdentifierScheme() { - return thematicIdentifierScheme; - } - - @MappableAttribute - public void setThematicIdentifierScheme(String thematicIdentifierScheme) { - this.thematicIdentifierScheme = thematicIdentifierScheme; - } - @MappableAttribute - @CodeSpace("http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue") - public CodeType getFunctionActivity() { - return functionActivity; - } - - @MappableAttribute - @CodeSpace("http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue") - public void setFunctionActivity(CodeType functionActivity) { - this.functionActivity = functionActivity; - } - - @MappableAttribute - @CodeSpace("http://inspire.ec.europa.eu/codeList/ProductCPAValue") - public CodeType getFunctionInput() { - return functionInput; - } - - @MappableAttribute - @CodeSpace("http://inspire.ec.europa.eu/codeList/ProductCPAValue") - public void setFunctionInput(CodeType functionInput) { - this.functionInput = functionInput; - } - - @MappableAttribute - @CodeSpace("http://inspire.ec.europa.eu/codeList/ProductCPAValue") - public CodeType getFunctionOutput() { - return functionOutput; - } - - @MappableAttribute - @CodeSpace("http://inspire.ec.europa.eu/codeList/ProductCPAValue") - public void setFunctionOutput(CodeType functionOutput) { - this.functionOutput = functionOutput; - } - - @MappableAttribute - public String getFunctionDescription() { - return functionDescription; - } - - @MappableAttribute - public void setFunctionDescription(String functionDescription) { - this.functionDescription = functionDescription; - } - - @MappableAttribute - public String getName() { - return name; - } - - @MappableAttribute - public void setName(String name) { - this.name = name; - } - - @MappableAttribute - public Geometry getSurfaceGeometry() { - return surfaceGeometry; - } - - @MappableAttribute - public void setSurfaceGeometry(Geometry surfaceGeometry) { - this.surfaceGeometry = surfaceGeometry; - } - - @MappableAttribute - @CodeSpace("http://inspire.ec.europa.eu/codeList/ConditionOfFacilityValue") - public CodeType getStatusType() { - return statusType; - } - - @MappableAttribute - @CodeSpace("http://inspire.ec.europa.eu/codeList/ConditionOfFacilityValue") - public void setStatusType(CodeType statusType) { - this.statusType = statusType; - } - - @MappableAttribute - public String getStatusDescription() { - return statusDescription; - } - - @MappableAttribute - public void setStatusDescription(String statusDescription) { - this.statusDescription = statusDescription; - } +// @MappableAttribute +// public String getName() { +// return name; +// } +// +// @MappableAttribute +// public void setName(String name) { +// this.name = name; +// } } diff --git a/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLinkValidator.java b/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLinkValidator.java index c75b7512..60a7817b 100644 --- a/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLinkValidator.java +++ b/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLinkValidator.java @@ -108,36 +108,6 @@ public Validator getInspireIdLocalIdValidator () { ); } - public Validator getProductionFacilityIdValidator () { - return validate ( - and( - validate (not (productionFacilityId.isNull ())).message (ATTRIBUTE_NULL, constant(productionFacilityId.name)), - validate (not (isBlank (productionFacilityId))).message (ATTRIBUTE_EMPTY, constant(productionFacilityId.name)) - ).shortCircuit() - ); - } - - public Validator getThematicIdentifierValidator () { - return validate ( - and( - ifExp (not (or (thematicIdentifier.isNull (), isBlank (thematicIdentifier))), - and ( - validate (not (thematicIdentifierScheme.isNull())).message (ATTRIBUTE_GROUP_INCONSISTENT, constant (thematicIdentifierScheme.name), constant (thematicIdentifier.name)), - validate (not (isBlank (thematicIdentifierScheme))).message (ATTRIBUTE_GROUP_INCONSISTENT, constant (thematicIdentifierScheme.name), constant (thematicIdentifier.name)) - ).shortCircuit(), - constant(true) - ), - ifExp (not (or (thematicIdentifierScheme.isNull (), isBlank (thematicIdentifierScheme))), - and ( - validate (not (thematicIdentifier.isNull())).message (ATTRIBUTE_GROUP_INCONSISTENT, constant (thematicIdentifier.name), constant (thematicIdentifierScheme.name)), - validate (not (isBlank (thematicIdentifier))).message (ATTRIBUTE_GROUP_INCONSISTENT, constant (thematicIdentifier.name), constant (thematicIdentifierScheme.name)) - ).shortCircuit(), - constant(true) - ) - ) - ); - } - public Validator getGeometryValidator () { return validate ( and ( @@ -176,144 +146,4 @@ public Validator getGeometryValidator () { ); } - public Validator getFunctionActivityValidator () { - return validate ( - and( - validate (not (functionActivity.isNull ())).message (ATTRIBUTE_NULL, constant(functionActivity.name)), - validate (functionActivity.hasCodeSpace (functionActivityCodeSpace)).message (ATTRIBUTE_CODE_CODESPACE_INVALID, functionActivity.codeSpace(), constant(functionActivity.name), functionActivityCodeSpace), - validate (not (isBlank (functionActivity.code()))).message (ATTRIBUTE_EMPTY, constant(functionActivity.name)) - // must be deactivated as long as codelist http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue is empty -// validate (functionActivity.isValid ()).message (ATTRIBUTE_CODE_INVALID, functionActivity.code(), constant(functionActivity.name), functionActivityCodeSpace) - ).shortCircuit() - ); - } - - public Validator getFunctionInputValidator () { - return validate ( - ifExp ( - functionInput.isNull (), - constant(true), - and( - validate (functionInput.hasCodeSpace (functionInputCodeSpace)).message (ATTRIBUTE_CODE_CODESPACE_INVALID, functionInput.codeSpace(), constant(functionInput.name), functionInputCodeSpace), - validate (not (isBlank (functionInput.code()))).message (ATTRIBUTE_EMPTY, constant(functionInput.name)) - // must be deactivated as long as codelist http://inspire.ec.europa.eu/codeList/ProductCPAValue is empty -// validate (functionInput.isValid ()).message (ATTRIBUTE_CODE_INVALID, functionInput.code(), constant(functionInput.name), functionInputCodeSpace) - ).shortCircuit() - ) - ); - } - - public Validator getFunctionOutputValidator () { - return validate ( - ifExp ( - functionOutput.isNull (), - constant(true), - and( - validate (functionOutput.hasCodeSpace (functionOutputCodeSpace)).message (ATTRIBUTE_CODE_CODESPACE_INVALID, functionOutput.codeSpace(), constant(functionOutput.name), functionOutputCodeSpace), - validate (not (isBlank (functionOutput.code()))).message (ATTRIBUTE_EMPTY, constant(functionOutput.name)) - // must be deactivated as long as codelist http://inspire.ec.europa.eu/codeList/ProductCPAValue is empty -// validate (functionOutput.isValid ()).message (ATTRIBUTE_CODE_INVALID, functionOutput.code(), constant(functionOutput.name), functionOutputCodeSpace) - ).shortCircuit() - ) - ); - } - - public Validator getFunctionDescriptionValidator () { - return validate ( - ifExp ( - functionDescription.isNull (), - constant(true), - validate (not (isBlank (functionDescription))).message (ATTRIBUTE_EMPTY, constant(functionDescription.name)) - ) - ); - } - - public Validator getNameValidator () { - return validate ( - ifExp ( - name.isNull (), - constant(true), - validate (not (isBlank (name))).message (ATTRIBUTE_EMPTY, constant(name.name)) - ) - ); - } - - public Validator getSurfaceGeometryValidator () { - return validate ( - ifExp( - surfaceGeometry.isNull (), - constant(true), - and ( - // The following validations short-circuit, there must be a non-empty, Surface geometry: - validate (not (surfaceGeometry.isEmptyMultiGeometry())).message (GEOMETRY_EMPTY_MULTIGEOMETRY), - validate (surfaceGeometry.isSurfaceOrMultiSurface()).message (GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE), - // Non short-circuited validations: - and ( - // Short circuit to prevent the interiorDisconnected validation if - // any of the other validations fail: - and ( - and ( - validate (not (surfaceGeometry.hasCurveDuplicatePoint ())).message (GEOMETRY_POINT_DUPLICATION, lastLocation ()), - validate (not (surfaceGeometry.hasCurveDiscontinuity ())).message (GEOMETRY_DISCONTINUITY), - validate (not (surfaceGeometry.hasCurveSelfIntersection ())).message (GEOMETRY_SELF_INTERSECTION, lastLocation ()), - validate (not (surfaceGeometry.hasUnclosedRing ())).message (GEOMETRY_RING_NOT_CLOSED), - validate (not (surfaceGeometry.hasRingSelfIntersection ())).message (GEOMETRY_RING_SELF_INTERSECTION, lastLocation ()), - validate (not (surfaceGeometry.hasTouchingInteriorRings ())).message(GEOMETRY_INTERIOR_RINGS_TOUCH, lastLocation ()), - validate (not (surfaceGeometry.hasInteriorRingsWithin ())).message (GEOMETRY_INTERIOR_RINGS_WITHIN) - ), - validate (not (surfaceGeometry.isInteriorDisconnected ())).message (GEOMETRY_INTERIOR_DISCONNECTED) - ).shortCircuit (), - - // Non-blocking validations: - validate (not (surfaceGeometry.hasExteriorRingCW ())).nonBlocking ().message (GEOMETRY_EXTERIOR_RING_CW), - validate (not (surfaceGeometry.hasInteriorRingCCW ())).nonBlocking ().message (GEOMETRY_INTERIOR_RING_CCW), - validate (not (surfaceGeometry.hasInteriorRingTouchingExterior ())).nonBlocking ().message (GEOMETRY_INTERIOR_RING_TOUCHES_EXTERIOR, lastLocation ()), - validate (not (surfaceGeometry.hasInteriorRingOutsideExterior ())).nonBlocking ().message (GEOMETRY_INTERIOR_RING_OUTSIDE_EXTERIOR), - - // SRS validations: - and ( - validate (surfaceGeometry.hasSrs ()).message (GEOMETRY_SRS_NULL), - validate (surfaceGeometry.isSrs (constant ("28992"))).message (GEOMETRY_SRS_NOT_RD, surfaceGeometry.srsName ()) - ).shortCircuit() - ) - ).shortCircuit () - ) - ); - } - - public Validator getStatusValidator () { - return validate ( - not ( - and ( - statusType.isNull(), - not (statusDescription.isNull()) - ) - ) - ).message (ATTRIBUTE_GROUP_INCONSISTENT, constant(statusType.name), constant(statusDescription.name)); - } - - public Validator getStatusDescriptionValidator () { - return validate ( - ifExp ( - statusDescription.isNull (), - constant(true), - validate (not (isBlank (statusDescription))).message (ATTRIBUTE_EMPTY, constant(statusDescription.name)) - ) - ); - } - - public Validator getStatusTypeValidator () { - return validate ( - ifExp ( - statusType.isNull (), - constant(true), - and( - validate (statusType.hasCodeSpace (statusTypeCodeSpace)).message (ATTRIBUTE_CODE_CODESPACE_INVALID, statusType.codeSpace(), constant(statusType.name), statusTypeCodeSpace), - validate (not (isBlank (statusType.code()))).message (ATTRIBUTE_EMPTY, constant(statusType.name)), - validate (statusType.isValid ()).message (ATTRIBUTE_CODE_INVALID, statusType.code(), constant(statusType.name), statusTypeCodeSpace) - ).shortCircuit() - ) - ); - } - } diff --git a/theme-watercourselink/src/main/sql/populate-manager-schema-watercourselink.sql b/theme-watercourselink/src/main/sql/populate-manager-schema-watercourselink.sql index 838b8cf5..b403228d 100644 --- a/theme-watercourselink/src/main/sql/populate-manager-schema-watercourselink.sql +++ b/theme-watercourselink/src/main/sql/populate-manager-schema-watercourselink.sql @@ -4,7 +4,7 @@ -- Names must match constants defined corresponding ThemeConfig insert into manager.thema (id, naam) values ((select nextval('manager.hibernate_sequence')), 'WatercourseLink'); -insert into manager.datasettype (id, naam, thema_id) values ((select nextval('manager.hibernate_sequence')), 'HydroNetworkNodesNL', (select id from manager.thema t where t.naam = 'WatercourseLink')); +insert into manager.datasettype (id, naam, thema_id) values ((select nextval('manager.hibernate_sequence')), 'WatercourseLinksNL', (select id from manager.thema t where t.naam = 'WatercourseLink')); insert into manager.bronhouder (id, code, contact_naam, contact_adres, contact_postcode, contact_plaats, naam, contact_emailadres, contact_telefoonnummer, common_name) select nextval('manager.hibernate_sequence'), 'elf', 'ELF Project', '', '', '', 'ELF Project', 'inspire@idgis.nl', '', 'elfproject' where not exists (select * from manager.bronhouder where code = 'elf'); diff --git a/theme-watercourselink/src/test/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLinkValidatorTest.java b/theme-watercourselink/src/test/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLinkValidatorTest.java index a196587c..f0e64d14 100644 --- a/theme-watercourselink/src/test/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLinkValidatorTest.java +++ b/theme-watercourselink/src/test/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLinkValidatorTest.java @@ -100,35 +100,6 @@ public void getProductionFacilityIdValidator () throws Throwable { .assertNoMessages(); } - @Test - public void getThematicIdentifierValidator () throws Throwable { - - WatercourseLink feature = new WatercourseLink(); - feature.setThematicIdentifier("a"); - feature.setThematicIdentifierScheme(null); - run ("thematicIdentifier") - .withFeature(feature ) - .assertOnlyKey (ATTRIBUTE_GROUP_INCONSISTENT); - - feature.setThematicIdentifier(null); - feature.setThematicIdentifierScheme("a"); - run ("thematicIdentifier") - .withFeature(feature ) - .assertOnlyKey (ATTRIBUTE_GROUP_INCONSISTENT); - - feature.setThematicIdentifier(null); - feature.setThematicIdentifierScheme(null); - run ("thematicIdentifier") - .withFeature(feature ) - .assertNoMessages (); - - feature.setThematicIdentifier("a"); - feature.setThematicIdentifierScheme("b"); - run ("thematicIdentifier") - .withFeature(feature ) - .assertNoMessages (); - } - @Test public void testGeometry () throws Exception { @@ -319,35 +290,6 @@ public void testSurfaceGeometry () throws Exception { .assertNoMessages (); } - @Test - public void getStatusValidator () throws Throwable { - - WatercourseLink feature = new WatercourseLink(); - feature.setStatusDescription("a"); - feature.setStatusType(null); - run ("status") - .withFeature(feature ) - .assertOnlyKey (ATTRIBUTE_GROUP_INCONSISTENT); - - feature = new WatercourseLink(); - feature.setStatusDescription("a"); - feature.setStatusType(new CodeType("b")); - run ("status") - .withFeature(feature ) - .assertNoMessages(); - - feature = new WatercourseLink(); - feature.setStatusType(new CodeType("b")); - run ("status") - .withFeature(feature ) - .assertNoMessages(); - - feature = new WatercourseLink(); - run ("status") - .withFeature(feature ) - .assertNoMessages(); - } - @Test public void getStatusTypeValidator () throws Throwable { diff --git a/themes/pom.xml b/themes/pom.xml index 1cade0ba..46a86e47 100644 --- a/themes/pom.xml +++ b/themes/pom.xml @@ -25,6 +25,11 @@ theme-habitat 2.2-SNAPSHOT + + nl.ipo.cds + theme-hydronode + 2.2-SNAPSHOT + nl.ipo.cds theme-hazardarea @@ -50,5 +55,10 @@ theme-riskzone 2.2-SNAPSHOT + + nl.ipo.cds + theme-watercourselink + 2.2-SNAPSHOT + \ No newline at end of file From be731168fc5a5d97b1e52fbad91b80719dec67ff Mon Sep 17 00:00:00 2001 From: Markus Schneider Date: Wed, 29 Jan 2014 23:12:16 +0100 Subject: [PATCH 3/8] theme-hydronode: Finished mapping --- .../src/main/feeds/datasettypecodes.xml | 28 +-- .../cds/etl/theme/hydronode/HydroNode.java | 29 +++- .../theme/hydronode/HydroNodeValidator.java | 160 +++++++----------- .../main/sql/create-bron-schema-hydronode.sql | 4 +- .../hydronode/HydroNodeValidatorTest.java | 45 ++--- 5 files changed, 102 insertions(+), 164 deletions(-) diff --git a/theme-hydronode/src/main/feeds/datasettypecodes.xml b/theme-hydronode/src/main/feeds/datasettypecodes.xml index a4f6e599..91f7cb96 100644 --- a/theme-hydronode/src/main/feeds/datasettypecodes.xml +++ b/theme-hydronode/src/main/feeds/datasettypecodes.xml @@ -1,32 +1,12 @@ - http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility - DatasetTypeCode Production Facility + http://www.inspire-provincies.nl/codeList/DatasetTypeCode/HydroNode + DatasetTypeCode HydroNode - http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility/lgrinr - LGR Inrichtingen - - - - http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility/lgrins - LGR Installaties - - - - http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility/lgrput - LGR Put - - - - http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility/lgrlus - LGR Bodemlus - - - - http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility/rkinr - Risicokaart Inrichtingen + http://www.inspire-provincies.nl/codeList/DatasetTypeCode/HydroNode/hydronodesnl + HydroNodesNL diff --git a/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/HydroNode.java b/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/HydroNode.java index 01c1650b..0349f9fb 100644 --- a/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/HydroNode.java +++ b/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/HydroNode.java @@ -24,14 +24,17 @@ public class HydroNode extends PersistableFeature { @Column(name = "name") private String name; + @Column(name = "category") + private CodeType category; + @MappableAttribute - @CodeSpace("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility") + @CodeSpace("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/HydroNode") public CodeType getInspireIdDatasetCode() { return inspireIdDatasetCode; } @MappableAttribute - @CodeSpace("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility") + @CodeSpace("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/HydroNode") public void setInspireIdDatasetCode(CodeType inspireIdDatasetCode) { this.inspireIdDatasetCode = inspireIdDatasetCode; } @@ -56,4 +59,26 @@ public void setGeometry(Geometry geometry) { this.geometry = geometry; } + @MappableAttribute + public String getName() { + return name; + } + + @MappableAttribute + public void setName(String name) { + this.name = name; + } + + @MappableAttribute + @CodeSpace("http://inspire.ec.europa.eu/codeList/HydroNodeCategoryValue") + public CodeType getCategory() { + return category; + } + + @MappableAttribute + @CodeSpace("http://inspire.ec.europa.eu/codeList/HydroNodeCategoryValue") + public void setCategory(CodeType category) { + this.category = category; + } + } diff --git a/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/HydroNodeValidator.java b/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/HydroNodeValidator.java index bf51d0a0..1b375117 100644 --- a/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/HydroNodeValidator.java +++ b/theme-hydronode/src/main/java/nl/ipo/cds/etl/theme/hydronode/HydroNodeValidator.java @@ -1,21 +1,8 @@ package nl.ipo.cds.etl.theme.hydronode; import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_CODE_CODESPACE_INVALID; -import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_CODE_INVALID; import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_EMPTY; import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_NULL; -import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_DISCONTINUITY; -import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_EXTERIOR_RING_CW; -import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_INTERIOR_DISCONNECTED; -import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_INTERIOR_RINGS_TOUCH; -import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_INTERIOR_RINGS_WITHIN; -import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_INTERIOR_RING_CCW; -import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_INTERIOR_RING_OUTSIDE_EXTERIOR; -import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_INTERIOR_RING_TOUCHES_EXTERIOR; -import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_POINT_DUPLICATION; -import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_RING_NOT_CLOSED; -import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_RING_SELF_INTERSECTION; -import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_SELF_INTERSECTION; import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_SRS_NOT_RD; import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_SRS_NULL; @@ -43,8 +30,14 @@ public class HydroNodeValidator extends private final GeometryExpression geometry = geometry("geometry"); - private final Constant inspireIdDatasetCodeSpace = constant("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility"); + private final Constant inspireIdDatasetCodeSpace = constant("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/HydroNode"); + private final AttributeExpression name = stringAttr ("name"); + + private final CodeExpression category = code ("category"); + + private final Constant categoryCodeSpace = constant ("http://inspire.ec.europa.eu/codeList/HydroNodeCategoryValue"); + public HydroNodeValidator(final Map validatorMessages) throws CompilerException { super(Context.class, HydroNode.class, validatorMessages); @@ -58,98 +51,61 @@ public Context beforeJob(final EtlJob job, return new Context(codeListFactory, reporter); } - public Validator getInspireIdDatasetCodeValidator() { - return validate(and( - validate(not(inspireIdDatasetCode.isNull())).message( - ATTRIBUTE_NULL, constant(inspireIdDatasetCode.name)), - validate(not(isBlank(inspireIdDatasetCode.code()))).message( - ATTRIBUTE_EMPTY, constant(inspireIdDatasetCode.name)), - validate( - inspireIdDatasetCode - .hasCodeSpace(inspireIdDatasetCodeSpace)) - .message(ATTRIBUTE_CODE_CODESPACE_INVALID, - inspireIdDatasetCode.codeSpace(), - constant(inspireIdDatasetCode.name), - inspireIdDatasetCodeSpace), - validate(inspireIdDatasetCode.isValid()).message( - ATTRIBUTE_CODE_INVALID, inspireIdDatasetCode.code(), - constant(inspireIdDatasetCode.name), - inspireIdDatasetCodeSpace)).shortCircuit()); + public Validator getInspireIdDatasetCodeValidator () { + return validate ( + and( + validate (not (inspireIdDatasetCode.isNull ())).message (ATTRIBUTE_NULL, constant (inspireIdDatasetCode.name)), + validate (not (isBlank (inspireIdDatasetCode.code()))).message (ATTRIBUTE_EMPTY, constant (inspireIdDatasetCode.name)), + validate (inspireIdDatasetCode.hasCodeSpace (inspireIdDatasetCodeSpace)).message (ATTRIBUTE_CODE_CODESPACE_INVALID, inspireIdDatasetCode.codeSpace(), constant(inspireIdDatasetCode.name), inspireIdDatasetCodeSpace) + ).shortCircuit() + ); } - public Validator getInspireIdLocalIdValidator() { - return validate(and( - validate(not(inspireIdLocalId.isNull())).message( - ATTRIBUTE_NULL, constant(inspireIdLocalId.name)), - validate(not(isBlank(inspireIdLocalId))).message( - ATTRIBUTE_EMPTY, constant(inspireIdLocalId.name))) - .shortCircuit()); + public Validator getInspireIdLocalIdValidator () { + return validate ( + and( + validate (not (inspireIdLocalId.isNull ())).message (ATTRIBUTE_NULL, constant(inspireIdLocalId.name)), + validate (not (isBlank (inspireIdLocalId))).message (ATTRIBUTE_EMPTY, constant(inspireIdLocalId.name)) + ).shortCircuit() + ); } - public Validator getGeometryValidator() { - return validate(and( - // The following validations short-circuit, there must be a non-null and - // non-empty, non-point geometry: - validate(not(geometry.isNull())).message(ATTRIBUTE_NULL, - constant(geometry.name)), - // Non short-circuited validations: - and( - // Short circuit to prevent the interiorDisconnected validation - // if - // any of the other validations fail: - and( - and(validate(not(geometry.hasCurveDuplicatePoint())) - .message(GEOMETRY_POINT_DUPLICATION, - lastLocation()), - validate(not(geometry.hasCurveDiscontinuity())) - .message(GEOMETRY_DISCONTINUITY), - validate( - not(geometry.hasCurveSelfIntersection())) - .message(GEOMETRY_SELF_INTERSECTION, - lastLocation()), - validate(not(geometry.hasUnclosedRing())) - .message(GEOMETRY_RING_NOT_CLOSED), - validate( - not(geometry.hasRingSelfIntersection())) - .message( - GEOMETRY_RING_SELF_INTERSECTION, - lastLocation()), - validate( - not(geometry.hasTouchingInteriorRings())) - .message(GEOMETRY_INTERIOR_RINGS_TOUCH, - lastLocation()), - validate(not(geometry.hasInteriorRingsWithin())) - .message(GEOMETRY_INTERIOR_RINGS_WITHIN)), - validate(not(geometry.isInteriorDisconnected())) - .message(GEOMETRY_INTERIOR_DISCONNECTED)) - .shortCircuit(), - - // Non-blocking validations: - validate(not(geometry.hasExteriorRingCW())) - .nonBlocking().message( - GEOMETRY_EXTERIOR_RING_CW), - validate(not(geometry.hasInteriorRingCCW())) - .nonBlocking().message( - GEOMETRY_INTERIOR_RING_CCW), - validate( - not(geometry.hasInteriorRingTouchingExterior())) - .nonBlocking() - .message( - GEOMETRY_INTERIOR_RING_TOUCHES_EXTERIOR, - lastLocation()), - validate(not(geometry.hasInteriorRingOutsideExterior())) - .nonBlocking() - .message( - GEOMETRY_INTERIOR_RING_OUTSIDE_EXTERIOR), - - // SRS validations: - and( - validate(geometry.hasSrs()).message( - GEOMETRY_SRS_NULL), - validate(geometry.isSrs(constant("28992"))) - .message(GEOMETRY_SRS_NOT_RD, - geometry.srsName())) - .shortCircuit())).shortCircuit()); + public Validator getGeometryValidator () { + return validate ( + and ( + // The following validations short-circuit, there must be a non-null and non-empty, non-point geometry: + validate (not (geometry.isNull ())).message (ATTRIBUTE_NULL, constant(geometry.name)), + // SRS validations: + and ( + validate (geometry.hasSrs ()).message (GEOMETRY_SRS_NULL), + validate (geometry.isSrs (constant ("28992"))).message (GEOMETRY_SRS_NOT_RD, geometry.srsName ()) + ).shortCircuit() + ).shortCircuit () + ); } + public Validator getNameValidator () { + return validate ( + and( + validate (not (name.isNull ())).message (ATTRIBUTE_NULL, constant(name.name)), + validate (not (isBlank (name))).message (ATTRIBUTE_EMPTY, constant(name.name)) + ).shortCircuit() + ); + } + + public Validator getCategoryValidator () { + return validate ( + ifExp ( + category.isNull (), + constant(true), + and( + validate (category.hasCodeSpace (categoryCodeSpace)).message (ATTRIBUTE_CODE_CODESPACE_INVALID, category.codeSpace(), constant(category.name), categoryCodeSpace), + validate (not (isBlank (category.code()))).message (ATTRIBUTE_EMPTY, constant(category.name)) + // must be deactivated as long as codelist http://inspire.ec.europa.eu/codeList/ProductCPAValue is empty +// validate (functionInput.isValid ()).message (ATTRIBUTE_CODE_INVALID, functionInput.code(), constant(functionInput.name), functionInputCodeSpace) + ).shortCircuit() + ) + ); + } + } diff --git a/theme-hydronode/src/main/sql/create-bron-schema-hydronode.sql b/theme-hydronode/src/main/sql/create-bron-schema-hydronode.sql index 6530b643..33cf7cb0 100644 --- a/theme-hydronode/src/main/sql/create-bron-schema-hydronode.sql +++ b/theme-hydronode/src/main/sql/create-bron-schema-hydronode.sql @@ -6,7 +6,9 @@ create table bron.hydro_node ( inspire_id_dataset_code text not null, inspire_id_local_id text not null, - + name text not null, + category text not null, + primary key (id), constraint fk_job_id foreign key (job_id) references manager.job (id) ); diff --git a/theme-hydronode/src/test/java/nl/ipo/cds/etl/theme/hydronode/HydroNodeValidatorTest.java b/theme-hydronode/src/test/java/nl/ipo/cds/etl/theme/hydronode/HydroNodeValidatorTest.java index cec8e46a..086f3b1e 100644 --- a/theme-hydronode/src/test/java/nl/ipo/cds/etl/theme/hydronode/HydroNodeValidatorTest.java +++ b/theme-hydronode/src/test/java/nl/ipo/cds/etl/theme/hydronode/HydroNodeValidatorTest.java @@ -3,12 +3,7 @@ import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_CODE_CODESPACE_INVALID; import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_CODE_INVALID; import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_EMPTY; -import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_GROUP_INCONSISTENT; import static nl.ipo.cds.etl.theme.hydronode.Message.ATTRIBUTE_NULL; -import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_EMPTY_MULTIGEOMETRY; -import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE; -import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_POINT_DUPLICATION; -import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_SELF_INTERSECTION; import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_SRS_NOT_RD; import static nl.ipo.cds.etl.theme.hydronode.Message.GEOMETRY_SRS_NULL; @@ -16,10 +11,6 @@ import nl.ipo.cds.etl.test.GeometryConstants; import nl.ipo.cds.etl.test.ValidationRunner; -import nl.ipo.cds.etl.theme.hydronode.Context; -import nl.ipo.cds.etl.theme.hydronode.Message; -import nl.ipo.cds.etl.theme.hydronode.HydroNode; -import nl.ipo.cds.etl.theme.hydronode.HydroNodeValidator; import org.deegree.commons.tom.ows.CodeType; import org.junit.Before; @@ -57,15 +48,15 @@ public void getInspireIdDatasetCodeValidator () throws Throwable { .with (new CodeType("bogus")) .assertOnlyKey (ATTRIBUTE_CODE_CODESPACE_INVALID); - run ("inspireIdDatasetCode") - .withCodeList ("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility", "lgrinr") - .with (new CodeType("value1", "http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility")) - .assertOnlyKey (ATTRIBUTE_CODE_INVALID); - - run ("inspireIdDatasetCode") - .withCodeList ("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility", "lgrinr") - .with (new CodeType("lgrinr", "http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility")) - .assertNoMessages(); +// run ("inspireIdDatasetCode") +// .withCodeList ("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility", "lgrinr") +// .with (new CodeType("value1", "http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility")) +// .assertOnlyKey (ATTRIBUTE_CODE_INVALID); +// +// run ("inspireIdDatasetCode") +// .withCodeList ("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility", "lgrinr") +// .with (new CodeType("lgrinr", "http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility")) +// .assertNoMessages(); } @Test @@ -102,22 +93,6 @@ public void testGeometry () throws Exception { run ("geometry") .with (geom.point (1,2)) .assertNoMessages (); - - run ("geometry") - .with (geom.lineString ()) - .assertNoMessages (); - - run ("geometry") - .with (geom.multiPolygon()) - .assertNoMessages (); - - run ("geometry") - .with (geom.lineStringDuplicatePoint ()) - .assertOnlyKey (GEOMETRY_POINT_DUPLICATION); - - run ("geometry") - .with (geom.lineStringSelfIntersection ()) - .assertOnlyKey (GEOMETRY_SELF_INTERSECTION); } @Test @@ -125,7 +100,7 @@ public void getNameValidator () throws Throwable { run ("name") .with (null) - .assertNoMessages(); + .assertOnlyKey (ATTRIBUTE_NULL); run ("name") .with ("") From 3b2dad77e14057243f7226549d68dca2e3c5199d Mon Sep 17 00:00:00 2001 From: Markus Schneider Date: Wed, 29 Jan 2014 23:34:19 +0100 Subject: [PATCH 4/8] theme-watercourselink: Finished mapping --- .../watercourselink/WatercourseLink.java | 47 +++- .../WatercourseLinkValidator.java | 112 +++----- .../create-bron-schema-watercourselink.sql | 3 + .../WatercourseLinkValidatorTest.java | 249 +----------------- 4 files changed, 82 insertions(+), 329 deletions(-) diff --git a/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLink.java b/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLink.java index 38a4afcb..5802239d 100644 --- a/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLink.java +++ b/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLink.java @@ -24,14 +24,20 @@ public class WatercourseLink extends PersistableFeature { @Column(name = "name") private String name; + @Column(name = "end_node_local_id") + private String endNodeLocalId; + + @Column(name = "start_node_local_id") + private String startNodeLocalId; + @MappableAttribute - @CodeSpace("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility") + @CodeSpace("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/WatercourseLink") public CodeType getInspireIdDatasetCode() { return inspireIdDatasetCode; } @MappableAttribute - @CodeSpace("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility") + @CodeSpace("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/WatercourseLink") public void setInspireIdDatasetCode(CodeType inspireIdDatasetCode) { this.inspireIdDatasetCode = inspireIdDatasetCode; } @@ -56,15 +62,34 @@ public void setGeometry(Geometry geometry) { this.geometry = geometry; } + @MappableAttribute + public String getName() { + return name; + } + + @MappableAttribute + public void setName(String name) { + this.name = name; + } + + @MappableAttribute + public String getEndNodeLocalId() { + return endNodeLocalId; + } + + @MappableAttribute + public void setEndNodeLocalId(String endNodeLocalId) { + this.endNodeLocalId = endNodeLocalId; + } + + @MappableAttribute + public String getStartNodeLocalId() { + return startNodeLocalId; + } -// @MappableAttribute -// public String getName() { -// return name; -// } -// -// @MappableAttribute -// public void setName(String name) { -// this.name = name; -// } + @MappableAttribute + public void setStartNodeLocalId(String startNodeLocalId) { + this.startNodeLocalId = startNodeLocalId; + } } diff --git a/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLinkValidator.java b/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLinkValidator.java index 60a7817b..76546b6d 100644 --- a/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLinkValidator.java +++ b/theme-watercourselink/src/main/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLinkValidator.java @@ -1,24 +1,8 @@ package nl.ipo.cds.etl.theme.watercourselink; import static nl.ipo.cds.etl.theme.watercourselink.Message.ATTRIBUTE_CODE_CODESPACE_INVALID; -import static nl.ipo.cds.etl.theme.watercourselink.Message.ATTRIBUTE_CODE_INVALID; import static nl.ipo.cds.etl.theme.watercourselink.Message.ATTRIBUTE_EMPTY; -import static nl.ipo.cds.etl.theme.watercourselink.Message.ATTRIBUTE_GROUP_INCONSISTENT; import static nl.ipo.cds.etl.theme.watercourselink.Message.ATTRIBUTE_NULL; -import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_DISCONTINUITY; -import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_EMPTY_MULTIGEOMETRY; -import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_EXTERIOR_RING_CW; -import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_INTERIOR_DISCONNECTED; -import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_INTERIOR_RINGS_TOUCH; -import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_INTERIOR_RINGS_WITHIN; -import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_INTERIOR_RING_CCW; -import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_INTERIOR_RING_OUTSIDE_EXTERIOR; -import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_INTERIOR_RING_TOUCHES_EXTERIOR; -import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE; -import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_POINT_DUPLICATION; -import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_RING_NOT_CLOSED; -import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_RING_SELF_INTERSECTION; -import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_SELF_INTERSECTION; import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_SRS_NOT_RD; import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_SRS_NULL; @@ -43,39 +27,15 @@ public class WatercourseLinkValidator extends AbstractValidator inspireIdLocalId = stringAttr ("inspireIdLocalId"); - private final AttributeExpression productionFacilityId = stringAttr ("productionFacilityId"); - - private final AttributeExpression thematicIdentifier = stringAttr ("thematicIdentifier"); - - private final AttributeExpression thematicIdentifierScheme = stringAttr ("thematicIdentifierScheme"); - private final GeometryExpression geometry = geometry ("geometry"); - private final CodeExpression functionActivity = code ("functionActivity"); - - private final CodeExpression functionInput = code ("functionInput"); - - private final CodeExpression functionOutput = code ("functionOutput"); - - private final AttributeExpression functionDescription = stringAttr ("functionDescription"); - private final AttributeExpression name = stringAttr ("name"); + + private final AttributeExpression endNodeLocalId = stringAttr ("endNodeLocalId"); + + private final AttributeExpression startNodeLocalId = stringAttr ("startNodeLocalId"); - private final GeometryExpression surfaceGeometry = geometry ("surfaceGeometry"); - - private final AttributeExpression statusDescription = stringAttr ("statusDescription"); - - private final CodeExpression statusType = code ("statusType"); - - private final Constant inspireIdDatasetCodeSpace = constant ("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility"); - - private final Constant functionActivityCodeSpace = constant ("http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue"); - - private final Constant functionInputCodeSpace = constant ("http://inspire.ec.europa.eu/codeList/ProductCPAValue"); - - private final Constant functionOutputCodeSpace = constant ("http://inspire.ec.europa.eu/codeList/ProductCPAValue"); - - private final Constant statusTypeCodeSpace = constant ("http://inspire.ec.europa.eu/codeList/ConditionOfFacilityValue"); + private final Constant inspireIdDatasetCodeSpace = constant ("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/WatercourseLink"); public WatercourseLinkValidator(final Map validatorMessages) throws CompilerException { super(Context.class, WatercourseLink.class, validatorMessages); @@ -93,8 +53,7 @@ public Validator getInspireIdDatasetCodeValidator () { and( validate (not (inspireIdDatasetCode.isNull ())).message (ATTRIBUTE_NULL, constant (inspireIdDatasetCode.name)), validate (not (isBlank (inspireIdDatasetCode.code()))).message (ATTRIBUTE_EMPTY, constant (inspireIdDatasetCode.name)), - validate (inspireIdDatasetCode.hasCodeSpace (inspireIdDatasetCodeSpace)).message (ATTRIBUTE_CODE_CODESPACE_INVALID, inspireIdDatasetCode.codeSpace(), constant(inspireIdDatasetCode.name), inspireIdDatasetCodeSpace), - validate (inspireIdDatasetCode.isValid ()).message (ATTRIBUTE_CODE_INVALID, inspireIdDatasetCode.code(), constant (inspireIdDatasetCode.name), inspireIdDatasetCodeSpace) + validate (inspireIdDatasetCode.hasCodeSpace (inspireIdDatasetCodeSpace)).message (ATTRIBUTE_CODE_CODESPACE_INVALID, inspireIdDatasetCode.codeSpace(), constant(inspireIdDatasetCode.name), inspireIdDatasetCodeSpace) ).shortCircuit() ); } @@ -113,37 +72,40 @@ public Validator getGeometryValidator () { and ( // The following validations short-circuit, there must be a non-null and non-empty, non-point geometry: validate (not (geometry.isNull ())).message (ATTRIBUTE_NULL, constant(geometry.name)), - // Non short-circuited validations: + // SRS validations: and ( - // Short circuit to prevent the interiorDisconnected validation if - // any of the other validations fail: - and ( - and ( - validate (not (geometry.hasCurveDuplicatePoint ())).message (GEOMETRY_POINT_DUPLICATION, lastLocation ()), - validate (not (geometry.hasCurveDiscontinuity ())).message (GEOMETRY_DISCONTINUITY), - validate (not (geometry.hasCurveSelfIntersection ())).message (GEOMETRY_SELF_INTERSECTION, lastLocation ()), - validate (not (geometry.hasUnclosedRing ())).message (GEOMETRY_RING_NOT_CLOSED), - validate (not (geometry.hasRingSelfIntersection ())).message (GEOMETRY_RING_SELF_INTERSECTION, lastLocation ()), - validate (not (geometry.hasTouchingInteriorRings ())).message(GEOMETRY_INTERIOR_RINGS_TOUCH, lastLocation ()), - validate (not (geometry.hasInteriorRingsWithin ())).message (GEOMETRY_INTERIOR_RINGS_WITHIN) - ), - validate (not (geometry.isInteriorDisconnected ())).message (GEOMETRY_INTERIOR_DISCONNECTED) - ).shortCircuit (), - - // Non-blocking validations: - validate (not (geometry.hasExteriorRingCW ())).nonBlocking ().message (GEOMETRY_EXTERIOR_RING_CW), - validate (not (geometry.hasInteriorRingCCW ())).nonBlocking ().message (GEOMETRY_INTERIOR_RING_CCW), - validate (not (geometry.hasInteriorRingTouchingExterior ())).nonBlocking ().message (GEOMETRY_INTERIOR_RING_TOUCHES_EXTERIOR, lastLocation ()), - validate (not (geometry.hasInteriorRingOutsideExterior ())).nonBlocking ().message (GEOMETRY_INTERIOR_RING_OUTSIDE_EXTERIOR), - - // SRS validations: - and ( - validate (geometry.hasSrs ()).message (GEOMETRY_SRS_NULL), - validate (geometry.isSrs (constant ("28992"))).message (GEOMETRY_SRS_NOT_RD, geometry.srsName ()) - ).shortCircuit() - ) + validate (geometry.hasSrs ()).message (GEOMETRY_SRS_NULL), + validate (geometry.isSrs (constant ("28992"))).message (GEOMETRY_SRS_NOT_RD, geometry.srsName ()) + ).shortCircuit() ).shortCircuit () ); } + public Validator getNameValidator () { + return validate ( + and( + validate (not (name.isNull ())).message (ATTRIBUTE_NULL, constant(name.name)), + validate (not (isBlank (name))).message (ATTRIBUTE_EMPTY, constant(name.name)) + ).shortCircuit() + ); + } + + public Validator getEndNodeLocalIdValidator () { + return validate ( + and( + validate (not (endNodeLocalId.isNull ())).message (ATTRIBUTE_NULL, constant(endNodeLocalId.name)), + validate (not (isBlank (endNodeLocalId))).message (ATTRIBUTE_EMPTY, constant(endNodeLocalId.name)) + ).shortCircuit() + ); + } + + public Validator getStartNodeLocalIdValidator () { + return validate ( + and( + validate (not (startNodeLocalId.isNull ())).message (ATTRIBUTE_NULL, constant(startNodeLocalId.name)), + validate (not (isBlank (startNodeLocalId))).message (ATTRIBUTE_EMPTY, constant(startNodeLocalId.name)) + ).shortCircuit() + ); + } + } diff --git a/theme-watercourselink/src/main/sql/create-bron-schema-watercourselink.sql b/theme-watercourselink/src/main/sql/create-bron-schema-watercourselink.sql index b7eedb29..eb4e0ac0 100644 --- a/theme-watercourselink/src/main/sql/create-bron-schema-watercourselink.sql +++ b/theme-watercourselink/src/main/sql/create-bron-schema-watercourselink.sql @@ -6,6 +6,9 @@ create table bron.watercourse_link ( inspire_id_dataset_code text not null, inspire_id_local_id text not null, + name text not null, + end_node_local_id text not null, + start_node_local_id text not null, primary key (id), constraint fk_job_id foreign key (job_id) references manager.job (id) diff --git a/theme-watercourselink/src/test/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLinkValidatorTest.java b/theme-watercourselink/src/test/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLinkValidatorTest.java index f0e64d14..ac68792b 100644 --- a/theme-watercourselink/src/test/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLinkValidatorTest.java +++ b/theme-watercourselink/src/test/java/nl/ipo/cds/etl/theme/watercourselink/WatercourseLinkValidatorTest.java @@ -1,14 +1,8 @@ package nl.ipo.cds.etl.theme.watercourselink; import static nl.ipo.cds.etl.theme.watercourselink.Message.ATTRIBUTE_CODE_CODESPACE_INVALID; -import static nl.ipo.cds.etl.theme.watercourselink.Message.ATTRIBUTE_CODE_INVALID; import static nl.ipo.cds.etl.theme.watercourselink.Message.ATTRIBUTE_EMPTY; -import static nl.ipo.cds.etl.theme.watercourselink.Message.ATTRIBUTE_GROUP_INCONSISTENT; import static nl.ipo.cds.etl.theme.watercourselink.Message.ATTRIBUTE_NULL; -import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_EMPTY_MULTIGEOMETRY; -import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE; -import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_POINT_DUPLICATION; -import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_SELF_INTERSECTION; import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_SRS_NOT_RD; import static nl.ipo.cds.etl.theme.watercourselink.Message.GEOMETRY_SRS_NULL; @@ -16,10 +10,6 @@ import nl.ipo.cds.etl.test.GeometryConstants; import nl.ipo.cds.etl.test.ValidationRunner; -import nl.ipo.cds.etl.theme.watercourselink.Context; -import nl.ipo.cds.etl.theme.watercourselink.Message; -import nl.ipo.cds.etl.theme.watercourselink.WatercourseLink; -import nl.ipo.cds.etl.theme.watercourselink.WatercourseLinkValidator; import org.deegree.commons.tom.ows.CodeType; import org.junit.Before; @@ -57,14 +47,14 @@ public void getInspireIdDatasetCodeValidator () throws Throwable { .with (new CodeType("bogus")) .assertOnlyKey (ATTRIBUTE_CODE_CODESPACE_INVALID); - run ("inspireIdDatasetCode") - .withCodeList ("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility", "lgrinr") - .with (new CodeType("value1", "http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility")) - .assertOnlyKey (ATTRIBUTE_CODE_INVALID); +// run ("inspireIdDatasetCode") +// .withCodeList ("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility", "lgrinr") +// .with (new CodeType("value1", "http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility")) +// .assertOnlyKey (ATTRIBUTE_CODE_INVALID); run ("inspireIdDatasetCode") - .withCodeList ("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility", "lgrinr") - .with (new CodeType("lgrinr", "http://www.inspire-provincies.nl/codeList/DatasetTypeCode/ProductionFacility")) + .withCodeList ("http://www.inspire-provincies.nl/codeList/DatasetTypeCode/WatercourseLink", "lgrinr") + .with (new CodeType("lgrinr", "http://www.inspire-provincies.nl/codeList/DatasetTypeCode/WatercourseLink")) .assertNoMessages(); } @@ -84,22 +74,6 @@ public void getInspireIdLocalIdValidator () throws Throwable { .assertNoMessages(); } - @Test - public void getProductionFacilityIdValidator () throws Throwable { - - run ("productionFacilityId") - .with (null) - .assertOnlyKey (ATTRIBUTE_NULL); - - run ("productionFacilityId") - .with ("") - .assertOnlyKey (ATTRIBUTE_EMPTY); - - run ("productionFacilityId") - .with ("nl1000") - .assertNoMessages(); - } - @Test public void testGeometry () throws Exception { @@ -115,220 +89,9 @@ public void testGeometry () throws Exception { .with (geom.lineString (geom.getSrs ("EPSG:3857"))) .assertOnlyKey (GEOMETRY_SRS_NOT_RD); - run ("geometry") - .with (geom.point (1,2)) - .assertNoMessages (); - run ("geometry") .with (geom.lineString ()) .assertNoMessages (); - - run ("geometry") - .with (geom.multiPolygon()) - .assertNoMessages (); - - run ("geometry") - .with (geom.lineStringDuplicatePoint ()) - .assertOnlyKey (GEOMETRY_POINT_DUPLICATION); - - run ("geometry") - .with (geom.lineStringSelfIntersection ()) - .assertOnlyKey (GEOMETRY_SELF_INTERSECTION); - } - - @Test - public void getFunctionActivityValidator () throws Throwable { - - run ("functionActivity") - .with (null) - .assertKey (ATTRIBUTE_NULL); - - run ("functionActivity") - .with (new CodeType("")) - .assertKey (ATTRIBUTE_CODE_CODESPACE_INVALID); - - run ("functionActivity") - .with (new CodeType("bogus")) - .assertOnlyKey (ATTRIBUTE_CODE_CODESPACE_INVALID); - - run ("functionActivity") - .withCodeList ("http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue", "lgrinr") - .with (new CodeType("value1", "http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue")) - .assertNoMessages(); -// code value validation deactivated -// .assertOnlyKey (ATTRIBUTE_CODE_INVALID); - - run ("functionActivity") - .withCodeList ("http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue", "lgrinr") - .with (new CodeType("lgrinr", "http://inspire.ec.europa.eu/codeList/EconomicActivityNACEValue")) - .assertNoMessages(); - } - - @Test - public void getFunctionInputValidator () throws Throwable { - - run ("functionInput") - .with (null) - .assertNoMessages(); - - run ("functionInput") - .with (new CodeType("")) - .assertKey (ATTRIBUTE_CODE_CODESPACE_INVALID); - - run ("functionInput") - .with (new CodeType("bogus")) - .assertOnlyKey (ATTRIBUTE_CODE_CODESPACE_INVALID); - - run ("functionInput") - .withCodeList ("http://inspire.ec.europa.eu/codeList/ProductCPAValue", "lgrinr") - .with (new CodeType("value1", "http://inspire.ec.europa.eu/codeList/ProductCPAValue")) - .assertNoMessages(); -// code value validation deactivated -// .assertOnlyKey (ATTRIBUTE_CODE_INVALID); - - - run ("functionInput") - .withCodeList ("http://inspire.ec.europa.eu/codeList/ProductCPAValue", "lgrinr") - .with (new CodeType("lgrinr", "http://inspire.ec.europa.eu/codeList/ProductCPAValue")) - .assertNoMessages(); } - @Test - public void getFunctionOutputValidator () throws Throwable { - - run ("functionOutput") - .with (null) - .assertNoMessages(); - - run ("functionOutput") - .with (new CodeType("")) - .assertKey (ATTRIBUTE_CODE_CODESPACE_INVALID); - - run ("functionOutput") - .with (new CodeType("bogus")) - .assertOnlyKey (ATTRIBUTE_CODE_CODESPACE_INVALID); - - run ("functionOutput") - .withCodeList ("http://inspire.ec.europa.eu/codeList/ProductCPAValue", "lgrinr") - .with (new CodeType("value1", "http://inspire.ec.europa.eu/codeList/ProductCPAValue")) - .assertNoMessages(); -// code value validation deactivated -// .assertOnlyKey (ATTRIBUTE_CODE_INVALID); - - - run ("functionOutput") - .withCodeList ("http://inspire.ec.europa.eu/codeList/ProductCPAValue", "lgrinr") - .with (new CodeType("lgrinr", "http://inspire.ec.europa.eu/codeList/ProductCPAValue")) - .assertNoMessages(); - } - - @Test - public void getFunctionDescriptionValidator () throws Throwable { - - run ("functionDescription") - .with (null) - .assertNoMessages(); - - run ("functionDescription") - .with ("") - .assertOnlyKey (ATTRIBUTE_EMPTY); - - run ("functionDescription") - .with ("nl1000") - .assertNoMessages(); - } - - @Test - public void getNameValidator () throws Throwable { - - run ("name") - .with (null) - .assertNoMessages(); - - run ("name") - .with ("") - .assertOnlyKey (ATTRIBUTE_EMPTY); - - run ("name") - .with ("nl1000") - .assertNoMessages(); - } - - @Test - public void testSurfaceGeometry () throws Exception { - - run ("surfaceGeometry") - .with (null) - .assertNoMessages (); - - run ("surfaceGeometry") - .with (geom.point (1,2)) - .assertOnlyKey (GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE); - - run ("surfaceGeometry") - .with (geom.lineString (null)) - .assertOnlyKey (GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE); - - run ("surfaceGeometry") - .with (geom.multiPoint ()) - .assertOnlyKey (GEOMETRY_ONLY_SURFACE_OR_MULTISURFACE); - - run ("surfaceGeometry") - .with (geom.emptyMultiPolygon()) - .assertOnlyKey (GEOMETRY_EMPTY_MULTIGEOMETRY); - - run ("surfaceGeometry") - .with (geom.polygon(null)) - .assertOnlyKey (GEOMETRY_SRS_NULL); - - run ("surfaceGeometry") - .with (geom.polygon()) - .assertNoMessages (); - - run ("surfaceGeometry") - .with (geom.multiPolygon()) - .assertNoMessages (); - } - - @Test - public void getStatusTypeValidator () throws Throwable { - - run ("statusType") - .with (null) - .assertNoMessages(); - - run ("statusType") - .with (new CodeType("")) - .assertKey (ATTRIBUTE_CODE_CODESPACE_INVALID); - - run ("statusType") - .with (new CodeType("bogus")) - .assertOnlyKey (ATTRIBUTE_CODE_CODESPACE_INVALID); - - run ("statusType") - .withCodeList ("http://inspire.ec.europa.eu/codeList/ConditionOfFacilityValue", "functional") - .with (new CodeType("value1", "http://inspire.ec.europa.eu/codeList/ConditionOfFacilityValue")) - .assertOnlyKey (ATTRIBUTE_CODE_INVALID); - - run ("statusType") - .withCodeList ("http://inspire.ec.europa.eu/codeList/ConditionOfFacilityValue", "functional") - .with (new CodeType("functional", "http://inspire.ec.europa.eu/codeList/ConditionOfFacilityValue")) - .assertNoMessages(); - } - - @Test - public void getStatusDescriptionValidator () throws Throwable { - - run ("statusDescription") - .with (null) - .assertNoMessages(); - - run ("statusDescription") - .with ("") - .assertOnlyKey (ATTRIBUTE_EMPTY); - - run ("statusDescription") - .with ("nl1000") - .assertNoMessages(); - } } From 203f2bbb61a7a0496bff8898ec894a31723e5ec4 Mon Sep 17 00:00:00 2001 From: Markus Schneider Date: Thu, 30 Jan 2014 00:10:14 +0100 Subject: [PATCH 5/8] Hydrography workspace: Got DLS working --- .../datasources/feature/fdsInspireHY.xml | 114 +++++++++++++++++- .../Hydrography/services/download_HY.xml | 2 +- 2 files changed, 109 insertions(+), 7 deletions(-) diff --git a/deegree-workspaces/Hydrography/datasources/feature/fdsInspireHY.xml b/deegree-workspaces/Hydrography/datasources/feature/fdsInspireHY.xml index 3cd19f62..9757cd3c 100644 --- a/deegree-workspaces/Hydrography/datasources/feature/fdsInspireHY.xml +++ b/deegree-workspaces/Hydrography/datasources/feature/fdsInspireHY.xml @@ -11,28 +11,130 @@ http://www.inspire-provincies.nl/schemas/hy-n/3.0/HydroNetwork.xsd true - + - + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/deegree-workspaces/Hydrography/services/download_HY.xml b/deegree-workspaces/Hydrography/services/download_HY.xml index 9e2c7ca7..a0792ec1 100644 --- a/deegree-workspaces/Hydrography/services/download_HY.xml +++ b/deegree-workspaces/Hydrography/services/download_HY.xml @@ -4,7 +4,7 @@ 2.0.0 - fdsInspireAM + fdsInspireHY EPSG:28992 EPSG:4326 From 841e1403d32c95ec8c1bb5ed534d8db83fc24c88 Mon Sep 17 00:00:00 2001 From: Markus Schneider Date: Thu, 30 Jan 2014 00:48:29 +0100 Subject: [PATCH 6/8] Fixed schema violations in Hydrography DLS output --- .../datasources/feature/fdsInspireHY.xml | 42 ++++++++++++------- .../transform-bron-to-inspire.sql | 38 ++++------------- .../create-bron-schema-watercourselink.sql | 2 +- .../create-inspire-schema-watercourselink.sql | 23 ++++++++++ 4 files changed, 59 insertions(+), 46 deletions(-) create mode 100644 theme-watercourselink/src/main/sql/create-inspire-schema-watercourselink.sql diff --git a/deegree-workspaces/Hydrography/datasources/feature/fdsInspireHY.xml b/deegree-workspaces/Hydrography/datasources/feature/fdsInspireHY.xml index 9757cd3c..7b71c98a 100644 --- a/deegree-workspaces/Hydrography/datasources/feature/fdsInspireHY.xml +++ b/deegree-workspaces/Hydrography/datasources/feature/fdsInspireHY.xml @@ -30,6 +30,10 @@ + + + + @@ -68,7 +72,7 @@ - + @@ -80,34 +84,31 @@ - + + + + + - - + @@ -137,6 +138,15 @@ + + + + + + + + + diff --git a/theme-watercourselink/src/main/resources/nl/ipo/cds/etl/theme/watercourselink/transform-bron-to-inspire.sql b/theme-watercourselink/src/main/resources/nl/ipo/cds/etl/theme/watercourselink/transform-bron-to-inspire.sql index a1f8248e..82072170 100644 --- a/theme-watercourselink/src/main/resources/nl/ipo/cds/etl/theme/watercourselink/transform-bron-to-inspire.sql +++ b/theme-watercourselink/src/main/resources/nl/ipo/cds/etl/theme/watercourselink/transform-bron-to-inspire.sql @@ -1,25 +1,15 @@ -delete from inspire.production_facility; +delete from inspire.watercourse_link; -insert into inspire.production_facility ( +insert into inspire.watercourse_link ( id, job_id, gfid, inspire_id_namespace, inspire_id_local_id, - production_facility_id, - thematic_identifier, - thematic_identifier_scheme, - function_activity, - function_input, - function_output, - function_description, name, - status_nil_reason, - status_xsi_nil, - status_type, - status_description, - geometry, - surface_geometry + end_node_href, + start_node_href, + geometry ) select id, @@ -27,18 +17,8 @@ select gfid, 'NL.' || inspire_id_dataset_code, inspire_id_local_id, - production_facility_id, - thematic_identifier, - thematic_identifier_scheme, - function_activity, - function_input, - function_output, - function_description, "name", - CASE WHEN status_type IS NULL THEN 'UNKNOWN' END, - CASE WHEN status_type IS NULL THEN 'true' END, - status_type, - status_description, - geometry, - surface_geometry -from bron.production_facility; + '#HY_N_HYDRO_NODE_' || end_node_local_id, + '#HY_N_HYDRO_NODE_' || start_node_local_id, + ST_LineMerge(geometry) +from bron.watercourse_link; diff --git a/theme-watercourselink/src/main/sql/create-bron-schema-watercourselink.sql b/theme-watercourselink/src/main/sql/create-bron-schema-watercourselink.sql index eb4e0ac0..4b85be1a 100644 --- a/theme-watercourselink/src/main/sql/create-bron-schema-watercourselink.sql +++ b/theme-watercourselink/src/main/sql/create-bron-schema-watercourselink.sql @@ -4,7 +4,7 @@ create table bron.watercourse_link ( job_id bigint, gfid text, - inspire_id_dataset_code text not null, + inspire_id_namespace text not null, inspire_id_local_id text not null, name text not null, end_node_local_id text not null, diff --git a/theme-watercourselink/src/main/sql/create-inspire-schema-watercourselink.sql b/theme-watercourselink/src/main/sql/create-inspire-schema-watercourselink.sql new file mode 100644 index 00000000..83ef5129 --- /dev/null +++ b/theme-watercourselink/src/main/sql/create-inspire-schema-watercourselink.sql @@ -0,0 +1,23 @@ + +create table inspire.watercourse_link ( + id serial, + job_id bigint, + gfid text, + + inspire_id_namespace text not null, + inspire_id_local_id text not null, + name text not null, + end_node_href text not null, + start_node_href text not null, + + primary key (id), + constraint fk_job_id foreign key (job_id) references manager.job (id) +); +SELECT AddGeometryColumn ('inspire','watercourse_link','geometry',28992,'GEOMETRY',2); +CREATE INDEX watercourse_link_geometry_idx ON inspire.watercourse_link USING gist(geometry); + +ALTER TABLE inspire.watercourse_link ALTER COLUMN "geometry" SET NOT NULL; + +GRANT SELECT, INSERT, UPDATE, DELETE, TRIGGER ON inspire.watercourse_link TO inspire; +GRANT USAGE, SELECT, UPDATE ON SEQUENCE inspire.watercourse_link_id_seq TO inspire; +---------------------------------- From 8d73d7888acef3ce6df7bcb55ebde2cf166a96f4 Mon Sep 17 00:00:00 2001 From: Markus Schneider Date: Thu, 30 Jan 2014 01:00:36 +0100 Subject: [PATCH 7/8] theme-hydronode: Fixed transform DDL. --- .../hydronode/transform-bron-to-inspire.sql | 45 +------------------ 1 file changed, 1 insertion(+), 44 deletions(-) diff --git a/theme-hydronode/src/main/resources/nl/ipo/cds/etl/theme/hydronode/transform-bron-to-inspire.sql b/theme-hydronode/src/main/resources/nl/ipo/cds/etl/theme/hydronode/transform-bron-to-inspire.sql index a1f8248e..dcc96ca7 100644 --- a/theme-hydronode/src/main/resources/nl/ipo/cds/etl/theme/hydronode/transform-bron-to-inspire.sql +++ b/theme-hydronode/src/main/resources/nl/ipo/cds/etl/theme/hydronode/transform-bron-to-inspire.sql @@ -1,44 +1 @@ -delete from inspire.production_facility; - -insert into inspire.production_facility ( - id, - job_id, - gfid, - inspire_id_namespace, - inspire_id_local_id, - production_facility_id, - thematic_identifier, - thematic_identifier_scheme, - function_activity, - function_input, - function_output, - function_description, - name, - status_nil_reason, - status_xsi_nil, - status_type, - status_description, - geometry, - surface_geometry - ) -select - id, - job_id, - gfid, - 'NL.' || inspire_id_dataset_code, - inspire_id_local_id, - production_facility_id, - thematic_identifier, - thematic_identifier_scheme, - function_activity, - function_input, - function_output, - function_description, - "name", - CASE WHEN status_type IS NULL THEN 'UNKNOWN' END, - CASE WHEN status_type IS NULL THEN 'true' END, - status_type, - status_description, - geometry, - surface_geometry -from bron.production_facility; +-- Nothing so far \ No newline at end of file From 18bb60ca08cf04b1bdf7d30f23c2a335a1ed93d0 Mon Sep 17 00:00:00 2001 From: Markus Schneider Date: Thu, 30 Jan 2014 01:20:02 +0100 Subject: [PATCH 8/8] Hydrography workspace: Added flat WFS --- .../Hydrography/datasources/feature/fdsHY.xml | 34 ++ .../datasources/feature/fdsInspireHYFull.xml | 346 ------------------ .../Hydrography/services/wfs_HY_NL.xml | 38 ++ .../services/wfs_HY_NL_metadata.xml | 50 +++ 4 files changed, 122 insertions(+), 346 deletions(-) create mode 100644 deegree-workspaces/Hydrography/datasources/feature/fdsHY.xml delete mode 100644 deegree-workspaces/Hydrography/datasources/feature/fdsInspireHYFull.xml create mode 100644 deegree-workspaces/Hydrography/services/wfs_HY_NL.xml create mode 100644 deegree-workspaces/Hydrography/services/wfs_HY_NL_metadata.xml diff --git a/deegree-workspaces/Hydrography/datasources/feature/fdsHY.xml b/deegree-workspaces/Hydrography/datasources/feature/fdsHY.xml new file mode 100644 index 00000000..90e30186 --- /dev/null +++ b/deegree-workspaces/Hydrography/datasources/feature/fdsHY.xml @@ -0,0 +1,34 @@ + + + conHY + + + + + + + + + + + EPSG:28992 + + + + + + + + + + + + + + EPSG:28992 + + + + + \ No newline at end of file diff --git a/deegree-workspaces/Hydrography/datasources/feature/fdsInspireHYFull.xml b/deegree-workspaces/Hydrography/datasources/feature/fdsInspireHYFull.xml deleted file mode 100644 index 7ab3bb79..00000000 --- a/deegree-workspaces/Hydrography/datasources/feature/fdsInspireHYFull.xml +++ /dev/null @@ -1,346 +0,0 @@ - - inspire - EPSG:4258 - ../../appschemas/inspire/hy-n/3.0/HydroNetwork.xsd - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/deegree-workspaces/Hydrography/services/wfs_HY_NL.xml b/deegree-workspaces/Hydrography/services/wfs_HY_NL.xml new file mode 100644 index 00000000..2b617505 --- /dev/null +++ b/deegree-workspaces/Hydrography/services/wfs_HY_NL.xml @@ -0,0 +1,38 @@ + + + + + 1.0.0 + 1.1.0 + 2.0.0 + + fdsHY + + + false + + + true + + + EPSG:28992 + EPSG:4326 + EPSG:4258 + EPSG:3035 + EPSG:3034 + EPSG:2583 + EPSG:25831 + EPSG:25832 + urn:ogc:def:crs:EPSG::28992 + urn:ogc:def:crs:EPSG::4326 + urn:ogc:def:crs:EPSG::4258 + urn:ogc:def:crs:EPSG::3035 + urn:ogc:def:crs:EPSG::3034 + urn:ogc:def:crs:EPSG::25830 + urn:ogc:def:crs:EPSG::25831 + urn:ogc:def:crs:EPSG::25832 + + + + diff --git a/deegree-workspaces/Hydrography/services/wfs_HY_NL_metadata.xml b/deegree-workspaces/Hydrography/services/wfs_HY_NL_metadata.xml new file mode 100644 index 00000000..b20bad50 --- /dev/null +++ b/deegree-workspaces/Hydrography/services/wfs_HY_NL_metadata.xml @@ -0,0 +1,50 @@ + + + cds-inspire + + + + + + To be replaced by the DatabaseMetadataProvider + application/vnd.iso.19139+xml + + + + dut + + + + dut + + + + + + + + + + To be replaced by the DatabaseMetadataProvider + application/vnd.iso.19139+xml + + + + dut + + + + dut + + + + + +