diff --git a/data/bld/Address.json b/data/adr/Address.json similarity index 100% rename from data/bld/Address.json rename to data/adr/Address.json diff --git a/data/adr/model.yaml b/data/adr/model.yaml new file mode 100644 index 00000000..74ce1447 --- /dev/null +++ b/data/adr/model.yaml @@ -0,0 +1,16 @@ +objectTypes: + Address: + attributes: + id: + type: String + identifier: true + cardinality: 1 + houseNumber: + type: Integer + cardinality: 1 + houseNumberAddition: + type: String + cardinality: 0..1 + postalCode: + type: String + cardinality: 0..1 diff --git a/data/bld/Building.json b/data/city/Building.json similarity index 100% rename from data/bld/Building.json rename to data/city/Building.json diff --git a/data/bld/BuildingPart.json b/data/city/BuildingPart.json similarity index 100% rename from data/bld/BuildingPart.json rename to data/city/BuildingPart.json diff --git a/data/bld/model.yaml b/data/city/model.yaml similarity index 67% rename from data/bld/model.yaml rename to data/city/model.yaml index 0675a999..f54a2ad7 100644 --- a/data/bld/model.yaml +++ b/data/city/model.yaml @@ -25,28 +25,12 @@ objectTypes: inverseName: consistsOf inverseCardinality: 0..* hasMainAddress: - target: Address + target: adr:Address cardinality: 1 inverseName: isMainAddressOf inverseCardinality: 1 hasSubAddress: - target: Address + target: adr:Address cardinality: 0..* inverseName: isSubAddressOf inverseCardinality: 1 - - Address: - attributes: - id: - type: String - identifier: true - cardinality: 1 - houseNumber: - type: Integer - cardinality: 1 - houseNumberAddition: - type: String - cardinality: 0..1 - postalCode: - type: String - cardinality: 0..1 diff --git a/data/geo/mapping.yaml b/data/geo/mapping.yaml index a78348e4..1b715fd5 100644 --- a/data/geo/mapping.yaml +++ b/data/geo/mapping.yaml @@ -2,12 +2,14 @@ targetModel: location: ../data/geo/model.yaml sourceModels: - bld: - location: ../data/bld/model.yaml + adr: + location: ../data/adr/model.yaml + city: + location: ../data/city/model.yaml objectTypeMappings: Construction: - sourceRoot: bld:Building + sourceRoot: city:Building propertyMappings: id: pathMappings: @@ -26,7 +28,7 @@ objectTypeMappings: type: merge Address: - sourceRoot: bld:Address + sourceRoot: adr:Address propertyMappings: id: pathMappings: @@ -43,7 +45,7 @@ objectTypeMappings: # TODO: auto-create inverse mappings isAddressOf: pathMappings: - - path: isMainAddressOf - - path: isSubAddressOf + - path: isMainAddressOf/isPartOf + - path: isSubAddressOf/isPartOf combiner: type: coalesce diff --git a/data/prc/Parcel.json b/data/land/Parcel.json similarity index 100% rename from data/prc/Parcel.json rename to data/land/Parcel.json diff --git a/data/prc/model.yaml b/data/land/model.yaml similarity index 100% rename from data/prc/model.yaml rename to data/land/model.yaml diff --git a/engine/src/test/java/nl/geostandaarden/imx/orchestrate/engine/OrchestrateEngineIT.java b/engine/src/test/java/nl/geostandaarden/imx/orchestrate/engine/OrchestrateEngineIT.java index 2425215d..b242a628 100644 --- a/engine/src/test/java/nl/geostandaarden/imx/orchestrate/engine/OrchestrateEngineIT.java +++ b/engine/src/test/java/nl/geostandaarden/imx/orchestrate/engine/OrchestrateEngineIT.java @@ -38,7 +38,10 @@ class OrchestrateEngineIT { private static final SpatialExtension SPATIAL_EXTENSION = new SpatialExtension(); private static ModelMapping MODEL_MAPPING; @Mock - private DataRepository dataRepositoryMock; + private DataRepository adrRepositoryMock; + + @Mock + private DataRepository cityRepositoryMock; private OrchestrateEngine engine; @@ -56,7 +59,8 @@ static void beforeAll() throws IOException { void beforeEach() { engine = OrchestrateEngine.builder() .modelMapping(MODEL_MAPPING) - .source("bld", () -> dataRepositoryMock) + .source("adr", () -> adrRepositoryMock) + .source("city", () -> cityRepositoryMock) .extension(SPATIAL_EXTENSION) .build(); } @@ -78,7 +82,17 @@ void fetch() { .build()) .build(); - when(dataRepositoryMock.findOne(any(ObjectRequest.class))) + when(adrRepositoryMock.findOne(any(ObjectRequest.class))) + .thenAnswer(invocation -> { + var objectType = ((ObjectRequest) invocation.getArgument(0)).getObjectType(); + + return switch (objectType.getName()) { + case "Address" -> Mono.just(Map.of("id", "A0001", "houseNumber", 23, "postalCode", "1234AB")); + default -> throw new IllegalStateException(); + }; + }); + + when(cityRepositoryMock.findOne(any(ObjectRequest.class))) .thenAnswer(invocation -> { var objectType = ((ObjectRequest) invocation.getArgument(0)).getObjectType(); @@ -86,12 +100,11 @@ void fetch() { case "Building" -> Mono.just(Map.of("id", "B0001", "area", 123, "geometry", Map.of("type", "Polygon", "coordinates", List.of(List.of(List.of(0, 0), List.of(10, 0), List.of(10, 10), List.of(0, 10), List.of(0, 0)))))); - case "Address" -> Mono.just(Map.of("id", "A0001", "houseNumber", 23, "postalCode", "1234AB")); default -> throw new IllegalStateException(); }; }); - when(dataRepositoryMock.find(any(CollectionRequest.class))) + when(cityRepositoryMock.find(any(CollectionRequest.class))) .thenAnswer(invocation -> { var objectType = ((CollectionRequest) invocation.getArgument(0)).getObjectType(); diff --git a/gateway/src/main/resources/application-local.yml b/gateway/src/main/resources/application-local.yml index e1f9b115..8dd4ba53 100644 --- a/gateway/src/main/resources/application-local.yml +++ b/gateway/src/main/resources/application-local.yml @@ -6,7 +6,11 @@ logging: orchestrate: mapping: ../data/geo/mapping.yaml sources: - bld: + adr: type: file options: - dataPath: ../data/bld + dataPath: ../data/adr + city: + type: file + options: + dataPath: ../data/city diff --git a/gateway/src/test/resources/application-it.yml b/gateway/src/test/resources/application-it.yml index b945e3f7..4791c06e 100644 --- a/gateway/src/test/resources/application-it.yml +++ b/gateway/src/test/resources/application-it.yml @@ -1,7 +1,11 @@ orchestrate: mapping: ../data/geo/mapping.yaml sources: - bld: + adr: type: file options: - dataPath: ../data/bld + dataPath: ../data/adr + city: + type: file + options: + dataPath: ../data/city