Skip to content

Commit

Permalink
Harvester / Simple URL / Add support for JSON document containing onl…
Browse files Browse the repository at this point in the history
…y one record. eg. zenodo
  • Loading branch information
fxprunayre committed Dec 18, 2024
1 parent 7a47468 commit c55e21c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.io.CharStreams;
import jeeves.server.context.ServiceContext;
Expand Down Expand Up @@ -208,7 +209,17 @@ public HarvestResult harvest(Logger log) throws Exception {
private void collectRecordsFromJson(JsonNode jsonObj,
Map<String, Element> uuids,
Aligner aligner) {
JsonNode nodes = jsonObj.at(params.loopElement);
JsonNode nodes = null;
if (".".equals(params.loopElement)) {
ObjectMapper objectMapper = new ObjectMapper();
ArrayNode jsonNodes = objectMapper.createArrayNode();
jsonNodes.add(jsonObj);
nodes = jsonNodes;
} else {
nodes = jsonObj.at(params.loopElement);
}


log.debug(String.format("%d records found in JSON response.", nodes.size()));

nodes.forEach(jsonRecord -> {
Expand Down
25 changes: 12 additions & 13 deletions schemas/iso19115-3.2018/src/test/resources/zenodo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
xmlns:mrd="http://standards.iso.org/iso/19115/-3/mrd/1.0"
xmlns:mri="http://standards.iso.org/iso/19115/-3/mri/1.0"
xmlns:mrl="http://standards.iso.org/iso/19115/-3/mrl/2.0"
xmlns:xlink="http://www.w3.org/1999/xlink"
>
xmlns:xlink="http://www.w3.org/1999/xlink">
<mdb:metadataIdentifier>
<mcc:MD_Identifier>
<mcc:code>
Expand Down Expand Up @@ -51,7 +50,7 @@
<cit:individual>
<cit:CI_Individual>
<cit:name>
<gco:CharacterString>Guillaume</gco:CharacterString>
<gco:CharacterString>Guillaume Maze</gco:CharacterString>
</cit:name>
<cit:partyIdentifier>
<mcc:MD_Identifier>
Expand Down Expand Up @@ -83,7 +82,7 @@
<cit:individual>
<cit:CI_Individual>
<cit:name>
<gco:CharacterString>Kevin</gco:CharacterString>
<gco:CharacterString>Kevin Balem</gco:CharacterString>
</cit:name>
<cit:partyIdentifier>
<mcc:MD_Identifier>
Expand Down Expand Up @@ -158,11 +157,11 @@
<gco:CharacterString>&lt;p&gt;Argo is a real-time global ocean in situ observing system. It provides thousands
of highly accurate ocean measurements every day. The Argo dataset has now accumulated more than 2.3 million
vertical ocean profiles and accessing it for scientific analysis remains a challenge.&lt;/p&gt; &lt;p&gt;The
Argo expert community, focused on delivering a curated dataset of the best scientific quality
possible, has never provided its user base with a Python software package to easily access and manipulate Argo
measurements: the argopy software aims to fill this gap. &lt;strong&gt;The argopy software can be used to
easily fetch and manipulate measurements from Argo floats&lt;/strong&gt;. It is dedicated to scientists
without knowledge of the Argo data management system but is also designed to accommodate expert requirements.&lt;/p&gt;
Argo expert community, focused on delivering a curated dataset of the best scientific quality possible, has
never provided its user base with a Python software package to easily access and manipulate Argo measurements:
the argopy software aims to fill this gap. &lt;strong&gt;The argopy software can be used to easily fetch and
manipulate measurements from Argo floats&lt;/strong&gt;. It is dedicated to scientists without knowledge of
the Argo data management system but is also designed to accommodate expert requirements.&lt;/p&gt;
</gco:CharacterString>
</mri:abstract>
<mri:pointOfContact>
Expand All @@ -180,7 +179,7 @@
<cit:individual>
<cit:CI_Individual>
<cit:name>
<gco:CharacterString>Guillaume</gco:CharacterString>
<gco:CharacterString>Guillaume Maze</gco:CharacterString>
</cit:name>
<cit:partyIdentifier>
<mcc:MD_Identifier>
Expand Down Expand Up @@ -213,7 +212,7 @@
<cit:individual>
<cit:CI_Individual>
<cit:name>
<gco:CharacterString>Kevin</gco:CharacterString>
<gco:CharacterString>Kevin Balem</gco:CharacterString>
</cit:name>
<cit:partyIdentifier>
<mcc:MD_Identifier>
Expand Down Expand Up @@ -246,7 +245,7 @@
<cit:individual>
<cit:CI_Individual>
<cit:name>
<gco:CharacterString>Tyler</gco:CharacterString>
<gco:CharacterString>Tyler Tucker</gco:CharacterString>
</cit:name>
<cit:partyIdentifier>
<mcc:MD_Identifier>
Expand Down Expand Up @@ -279,7 +278,7 @@
<cit:individual>
<cit:CI_Individual>
<cit:name>
<gco:CharacterString>Filipe</gco:CharacterString>
<gco:CharacterString>Filipe Fernandes</gco:CharacterString>
</cit:name>
<cit:partyIdentifier>
<mcc:MD_Identifier>
Expand Down

0 comments on commit c55e21c

Please sign in to comment.