-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OGCAPI - GeoJSON output improvements #118
OGCAPI - GeoJSON output improvements #118
Conversation
This is for example one things improved in GN5 codebase https://github.com/GeoCat/geonetwork/blob/data-upload/src/shared/index-model/src/test/java/org/geonetwork/index/model/record/IndexRecordTest.java where the index can read/write a document for GN4 index (geonetwork/geonetwork#4). BTW for OGC API Records, you probably have all properties needed in the microservice model.
AFAIK, only OGC API Records is used in that repository so it should be quite safe. |
Thanks, @fxprunayre, for your reply. I think for searching and most things, everything needed is in the Index - the queryables work very well. I am a bit worried about some info (from the xml) not being in the index json for displaying the record-details-page, but most things are there. I included the XML incase this happens. |
@josegar74 @fxprunayre - I am planning on merging this wed evening (european time). |
Quality Gate passedIssues Measures |
Fix NPE on DCAT item response eg. http://localhost:9901/collections/main/items/f946d4e0-710b-11dc-83f9-000086f6a62e?f=dcat ``` 2024-11-19 11:15:29.659 ERROR 547670 --- [nio-9901-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.RuntimeException: java.lang.NullPointerException] with root cause java.lang.NullPointerException: null at org.fao.geonet.index.converter.DcatConverter.convert(DcatConverter.java:128) ~[classes/:na] at org.fao.geonet.ogcapi.records.controller.ItemApiController.collectionsCollectionIdItemsRecordIdGetAsJsonLd(ItemApiController.java:365) ~[classes/:na] at org.fao.geonet.ogcapi.records.controller.ItemApiController.collectionsCollectionIdItemsRecordIdGet(ItemApiController.java:191) ~[classes/:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na] at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE] a ``` DCAT conversion is for now based on Elasticsearch index document which is properly returned for search but not for the items operation with now the new GeoJSON document with `doc.get("properties").get("gn-elastic-index-record")` which can be used for the conversion. DCAT will be better supported with formatters geonetwork/geonetwork#72 but for 4.4.6, this is relevant to be fixed. Related to #118
Fix NPE on DCAT item response eg. http://localhost:9901/collections/main/items/f946d4e0-710b-11dc-83f9-000086f6a62e?f=dcat ``` 2024-11-19 11:15:29.659 ERROR 547670 --- [nio-9901-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.RuntimeException: java.lang.NullPointerException] with root cause java.lang.NullPointerException: null at org.fao.geonet.index.converter.DcatConverter.convert(DcatConverter.java:128) ~[classes/:na] at org.fao.geonet.ogcapi.records.controller.ItemApiController.collectionsCollectionIdItemsRecordIdGetAsJsonLd(ItemApiController.java:365) ~[classes/:na] at org.fao.geonet.ogcapi.records.controller.ItemApiController.collectionsCollectionIdItemsRecordIdGet(ItemApiController.java:191) ~[classes/:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na] at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE] a ``` DCAT conversion is for now based on Elasticsearch index document which is properly returned for search but not for the items operation with now the new GeoJSON document with `doc.get("properties").get("gn-elastic-index-record")` which can be used for the conversion. DCAT will be better supported with formatters geonetwork/geonetwork#72 but for 4.4.6, this is relevant to be fixed. Related to #118
This PR improves the GeoJSON output to be more compliant with the OGCAPI-Records specification.
gn-elastic-index-record
property that has the IndexRecord (Elastic JSON Index document) in itgn-record-xml
property that has the metadata record's XML text in it.NOTE:
The
geometries
property was in a "JSON Strings", but I've converted it to a normal JSON object. I also added agetGeometriesAsJsonString()
method to access it as normal. I also added ageometriesAsJsonString
property to the JSON with the old format.I was a little worried about changing the GeoJSON output too much (other things might depend on it). So, I created an
IGeoJsonConverter
interface with two implementation.GeoJsonConverter
(the old one) andOgcApiGeoJsonConverter
(the new one).I noticed a few bugs, which I've fixed.
I've added a few more
OgcApi*
model objects.Here is an example of the new GeoJSON output - based on one of the "iso19139" Geonetwork sample records.
gn-elastic-index-record
(all the elastic index properties)gn-record-xml
(underlying metadata iso19139 xml)items.geojson
Table 8 & 9 from the spec: