Skip to content

Commit

Permalink
add navigation links to physicalobject, event and photo deposits as s…
Browse files Browse the repository at this point in the history
…uggested by @asrivathsan
  • Loading branch information
Jorrit Poelen committed Sep 9, 2024
1 parent cc33b09 commit 75cd696
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 122 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class ZenodoMetaUtil {
public static final String UPLOAD_TYPE_EVENT = "event";
public static final String UPLOAD_TYPE_PHYSICAL_OBJECT = "physicalobject";
public static final String IMAGE_TYPE_PHOTO = "photo";
public static final String RESOURCE_TYPE_PHOTO = "image+inner:image-photo";
public static final String HAS_VERSION = "hasVersion";
public static final String IS_COMPILED_BY = "isCompiledBy";
public static final String RESOURCE_TYPE_SOFTWARE = "software";
Expand All @@ -73,6 +74,7 @@ public class ZenodoMetaUtil {
public static final String FIELD_CUSTOM_GBIF_DWC_RECORDED_BY_ID = "gbif-dwc:recordedByID";
public static final String FIELD_CUSTOM_DWC_BASIS_OF_RECORD = "dwc:basisOfRecord";
public static final String FIELD_CUSTOM_DWC_SCIENTIFIC_NAME = "dwc:scientificName";
public static final String DOCUMENTS = "documents";
static final String KEYWORDS = "keywords";
static final String CUSTOM = "custom";
public static final Pattern YEAR_PATTERN = Pattern.compile(".*(?<year>[12][0-9]{3}).*");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,15 @@ public static IRI getQueryForExistingDepositions(ZenodoConfig ctx, List<String>
}

public static IRI getQueryForExistingDepositions(ZenodoConfig ctx, List<String> contentIds, String method, String type) {
String query = "q=" + getQueryForIds(contentIds);
String prefix = communitiesPrefix(ctx);
String query = prefix + "q=" + getQueryForIds(contentIds);
query = appendTypeClause(type, query);
return getQuery(ctx.getEndpoint(), query, method);
}

private static String appendTypeClause(String type, String query) {
if (StringUtils.isNotBlank(type)) {
query = query + "&f=resource_type%3A" + type;
query = query + "&f=resource_type%3A" + JavaScriptAndPythonFriendlyURLEncodingUtil.urlEncode(type);
}
return query;
}
Expand All @@ -265,13 +266,17 @@ private static void findExistingRecords(ZenodoConfig ctx, List<String> ids, Coll
}

public static IRI getQueryForExistingRecords(ZenodoConfig ctx, List<String> ids, String type) {
String prefix = ctx.getCommunities().size() == 0
? ""
: "communities=" + JavaScriptAndPythonFriendlyURLEncodingUtil.urlEncode(StringUtils.join(ctx.getCommunities(), ",")) + "&";
String prefix = communitiesPrefix(ctx);
String queryPath = prefix + "all_versions=false&q=" + getQueryForIds(ids);
return getQuery(ctx.getEndpoint(), appendTypeClause(type, queryPath), "/api/records");
}

private static String communitiesPrefix(ZenodoConfig ctx) {
return ctx.getCommunities().size() == 0
? ""
: "communities=" + JavaScriptAndPythonFriendlyURLEncodingUtil.urlEncode(StringUtils.join(ctx.getCommunities(), ",")) + "&";
}

private static String getQueryForIds(List<String> ids) {
return ids.stream()
.map(JavaScriptAndPythonFriendlyURLEncodingUtil::urlEncode)
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,23 @@
"dwc:verbatimEventDate" : [ "2024-05-04/2024-05-08" ],
"dwc:locality" : [ "Berlin, Swiss Embassy" ],
"dwc:recordedBy" : [ "Donat Agosti" ],
"dwc:recordedByID" : [ "https://orcid.org/0000-0001-9286-1200" ],
"gbif-dwc:recordedByID" : [ "https://orcid.org/0000-0001-9286-1200" ]
"dwc:recordedByID" : [ "https://orcid.org/0000-0001-9286-1200" ]
},
"filename" : "event.json",
"related_identifiers" : [ {
"relation" : "isAlternateIdentifier",
"identifier" : "urn:lsid:MfN:Ento:SchweiBo1"
}, {
"relation" : "isVersionOf",
"identifier" : "https://sandbox.zenodo.org/search?q=alternate.identifier:%22urn%3Alsid%3AMfN%3AEnto%3ASchweiBo1%22&f=resource_type%3Aevent"
}, {
"relation" : "isVersionOf",
"identifier" : "https://sandbox.zenodo.org/api/records?communities=mfn-test&all_versions=false&q=alternate.identifier:%22urn%3Alsid%3AMfN%3AEnto%3ASchweiBo1%22&f=resource_type%3Aevent"
}, {
"relation" : "isAlternateIdentifier",
"identifier" : "hash://md5/672a403a43a9f8575ad5feeffc21bdc2"
}, {
"relation" : "hasVersion",
"identifier" : "hash://md5/672a403a43a9f8575ad5feeffc21bdc2"
}, {
"relation" : "isAlternateIdentifier",
"identifier" : "urn:lsid:MfN:Ento:SchweiBo1",
"resource_type" : "event"
}, {
"relation" : "isVersionOf",
"identifier" : "https://sandbox.zenodo.org/search?communities=mfn-test&q=alternate.identifier:%22urn%3Alsid%3AMfN%3AEnto%3ASchweiBo1%22&f=resource_type%3Aevent",
"resource_type" : "event"
} ],
"upload_type" : "event",
"creators" : [ {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"dwc:catalogNumber" : [ "BMT0009388" ],
"dwc:materialSampleID" : [ "urn:lsid:MfN:Ento:BMT0009388" ],
"ac:associatedSpecimenReference" : [ "urn:lsid:MfN:Ento:BMT0009388" ],
"dwc:institutionCode" : [ "MfN" ],
"ac:subjectPart" : [ "whole specimen" ],
"ac:captureDevice" : [ "CAMERA MAKE AND MODEL" ],
"ac:resourceCreationTechnique" : [ "Focal Stacking" ]
Expand All @@ -20,25 +21,20 @@
"identifier" : "hash://md5/f052cbac398bf340a620c421bfefa16d"
}, {
"relation" : "isAlternateIdentifier",
"identifier" : "urn:lsid:MfN:Ento:BMT0009388:BMT121_BMT0009388_stacked_01.tiff"
"identifier" : "urn:lsid:MfN:Ento:BMT0009388:BMT121_BMT0009388_stacked_01.tiff",
"resource_type" : "image+inner:image-photo"
}, {
"relation" : "isDerivedFrom",
"identifier" : "urn:lsid:MfN:Ento:BMT0009388"
"relation" : "documents",
"identifier" : "urn:lsid:MfN:Ento:BMT0009388",
"resource_type" : "physicalobject"
}, {
"relation" : "isVersionOf",
"identifier" : "https://sandbox.zenodo.org/search?q=alternate.identifier:%22hash%3A%2F%2Fmd5%2Ff052cbac398bf340a620c421bfefa16d%22&f=resource_type%3Aimage%2Binner%3Aimage-photo"
"identifier" : "https://sandbox.zenodo.org/search?communities=mfn-test&q=alternate.identifier:%22hash%3A%2F%2Fmd5%2Ff052cbac398bf340a620c421bfefa16d%22&f=resource_type%3Aimage%2Binner%3Aimage-photo",
"resource_type" : "image+inner:image-photo"
}, {
"relation" : "isVersionOf",
"identifier" : "https://sandbox.zenodo.org/api/records?communities=mfn-test&all_versions=false&q=alternate.identifier:%22hash%3A%2F%2Fmd5%2Ff052cbac398bf340a620c421bfefa16d%22&f=resource_type%3Aimage%2Binner%3Aimage-photo"
}, {
"relation" : "isDerivedFrom",
"identifier" : "https://sandbox.zenodo.org/search?q=alternate.identifier:%22urn%3Alsid%3AMfN%3AEnto%3ABMT0009388%22&f=resource_type%3Aphysicalobject"
}, {
"relation" : "isDerivedFrom",
"identifier" : "https://sandbox.zenodo.org/api/records?communities=mfn-test&all_versions=false&q=alternate.identifier:%22urn%3Alsid%3AMfN%3AEnto%3ABMT0009388%22&f=resource_type%3Aphysicalobject"
}, {
"relation" : "isDocumentedBy",
"identifier" : "https://zenodo.org/search?q=_files.checksum%3A%22md5%3Af052cbac398bf340a620c421bfefa16d%22&f=allversions%3Atrue"
"relation" : "documents",
"identifier" : "https://sandbox.zenodo.org/search?communities=mfn-test&q=alternate.identifier:%22urn%3Alsid%3AMfN%3AEnto%3ABMT0009388%22&f=resource_type%3Aphysicalobject",
"resource_type" : "physicalobject"
} ],
"http://www.w3.org/1999/02/22-rdf-syntax-ns#type" : "image/tiff",
"upload_type" : "image",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"metadata" : {
"title" : "Physical object urn:lsid:MfN:Ento:BMT0009388 sampled through event urn:lsid:MfN:Ento:SchweiBo1 on 2019-07-04",
"description" : "Physical object urn:lsid:MfN:Ento:BMT0009388 sampled through event urn:lsid:MfN:Ento:SchweiBo1 on 2019-07-04",
"custom" : {
"dwc:institutionCode" : [ "MfN" ],
"dwc:eventDate" : [ "2019-07-04" ],
Expand All @@ -15,29 +13,33 @@
"filename" : "BMT121_BMT0009388_stacked_01.tiff",
"related_identifiers" : [ {
"relation" : "isAlternateIdentifier",
"identifier" : "urn:lsid:MfN:Ento:BMT0009388"
"identifier" : "hash://md5/f052cbac398bf340a620c421bfefa16d"
}, {
"relation" : "isVersionOf",
"identifier" : "https://sandbox.zenodo.org/search?q=alternate.identifier:%22urn%3Alsid%3AMfN%3AEnto%3ABMT0009388%22&f=resource_type%3Aphysicalobject"
"relation" : "hasVersion",
"identifier" : "hash://md5/f052cbac398bf340a620c421bfefa16d"
}, {
"relation" : "isVersionOf",
"identifier" : "https://sandbox.zenodo.org/api/records?communities=mfn-test&all_versions=false&q=alternate.identifier:%22urn%3Alsid%3AMfN%3AEnto%3ABMT0009388%22&f=resource_type%3Aphysicalobject"
"relation" : "isAlternateIdentifier",
"identifier" : "urn:lsid:MfN:Ento:BMT0009388",
"resource_type" : "physicalobject"
}, {
"relation" : "isDerivedFrom",
"identifier" : "urn:lsid:MfN:Ento:SchweiBo1"
"relation" : "isVersionOf",
"identifier" : "https://sandbox.zenodo.org/search?communities=mfn-test&q=alternate.identifier:%22urn%3Alsid%3AMfN%3AEnto%3ABMT0009388%22&f=resource_type%3Aphysicalobject",
"resource_type" : "physicalobject"
}, {
"relation" : "isDerivedFrom",
"identifier" : "https://sandbox.zenodo.org/search?q=alternate.identifier:%22urn%3Alsid%3AMfN%3AEnto%3ASchweiBo1%22&f=resource_type%3Aevent"
"identifier" : "urn:lsid:MfN:Ento:SchweiBo1",
"resource_type" : "event"
}, {
"relation" : "isDerivedFrom",
"identifier" : "https://sandbox.zenodo.org/api/records?communities=mfn-test&all_versions=false&q=alternate.identifier:%22urn%3Alsid%3AMfN%3AEnto%3ASchweiBo1%22&f=resource_type%3Aevent"
}, {
"relation" : "isAlternateIdentifier",
"identifier" : "hash://md5/f052cbac398bf340a620c421bfefa16d"
"identifier" : "https://sandbox.zenodo.org/search?communities=mfn-test&q=alternate.identifier:%22urn%3Alsid%3AMfN%3AEnto%3ASchweiBo1%22&f=resource_type%3Aevent",
"resource_type" : "event"
}, {
"relation" : "hasVersion",
"identifier" : "hash://md5/f052cbac398bf340a620c421bfefa16d"
"relation" : "isDocumentedBy",
"identifier" : "https://sandbox.zenodo.org/search?communities=mfn-test&q=alternate.identifier:%22urn%3Alsid%3AMfN%3AEnto%3ABMT0009388%22&f=resource_type%3Aimage%2Binner%3Aimage-photo",
"resource_type" : "image+inner:image-photo"
} ],
"title" : "Physical object urn:lsid:MfN:Ento:BMT0009388 sampled through event urn:lsid:MfN:Ento:SchweiBo1 on 2019-07-04",
"description" : "Physical object urn:lsid:MfN:Ento:BMT0009388 sampled through event urn:lsid:MfN:Ento:SchweiBo1 on 2019-07-04",
"upload_type" : "physicalobject",
"creators" : [ {
"name" : "Museum für Naturkunde Berlin"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"metadata" : {
"title" : "Physical object urn:lsid:MfN:Ento:BMT0009388 sampled through event urn:lsid:MfN:Ento:SchweiBo1 on 2019-07-04",
"description" : "Physical object urn:lsid:MfN:Ento:BMT0009388 sampled through event urn:lsid:MfN:Ento:SchweiBo1 on 2019-07-04",
"custom" : {
"dwc:institutionCode" : [ "MfN" ],
"dwc:eventDate" : [ "2019-07-04" ],
Expand All @@ -12,32 +10,36 @@
"dwc:scientificName" : [ "incertae sedis" ],
"dwc:materialSampleID" : [ "urn:lsid:MfN:Ento:BMT0009388" ]
},
"filename" : "event.json",
"filename" : "occurrence.json",
"related_identifiers" : [ {
"relation" : "isAlternateIdentifier",
"identifier" : "urn:lsid:MfN:Ento:BMT0009388"
"identifier" : "hash://md5/70fa5b4dbb0e09282c907a859b019547"
}, {
"relation" : "isVersionOf",
"identifier" : "https://sandbox.zenodo.org/search?q=alternate.identifier:%22urn%3Alsid%3AMfN%3AEnto%3ABMT0009388%22&f=resource_type%3Aphysicalobject"
"relation" : "hasVersion",
"identifier" : "hash://md5/70fa5b4dbb0e09282c907a859b019547"
}, {
"relation" : "isVersionOf",
"identifier" : "https://sandbox.zenodo.org/api/records?communities=mfn-test&all_versions=false&q=alternate.identifier:%22urn%3Alsid%3AMfN%3AEnto%3ABMT0009388%22&f=resource_type%3Aphysicalobject"
"relation" : "isAlternateIdentifier",
"identifier" : "urn:lsid:MfN:Ento:BMT0009388",
"resource_type" : "physicalobject"
}, {
"relation" : "isDerivedFrom",
"identifier" : "urn:lsid:MfN:Ento:SchweiBo1"
"relation" : "isVersionOf",
"identifier" : "https://sandbox.zenodo.org/search?communities=mfn-test&q=alternate.identifier:%22urn%3Alsid%3AMfN%3AEnto%3ABMT0009388%22&f=resource_type%3Aphysicalobject",
"resource_type" : "physicalobject"
}, {
"relation" : "isDerivedFrom",
"identifier" : "https://sandbox.zenodo.org/search?q=alternate.identifier:%22urn%3Alsid%3AMfN%3AEnto%3ASchweiBo1%22&f=resource_type%3Aevent"
"identifier" : "urn:lsid:MfN:Ento:SchweiBo1",
"resource_type" : "event"
}, {
"relation" : "isDerivedFrom",
"identifier" : "https://sandbox.zenodo.org/api/records?communities=mfn-test&all_versions=false&q=alternate.identifier:%22urn%3Alsid%3AMfN%3AEnto%3ASchweiBo1%22&f=resource_type%3Aevent"
}, {
"relation" : "isAlternateIdentifier",
"identifier" : "hash://md5/70fa5b4dbb0e09282c907a859b019547"
"identifier" : "https://sandbox.zenodo.org/search?communities=mfn-test&q=alternate.identifier:%22urn%3Alsid%3AMfN%3AEnto%3ASchweiBo1%22&f=resource_type%3Aevent",
"resource_type" : "event"
}, {
"relation" : "hasVersion",
"identifier" : "hash://md5/70fa5b4dbb0e09282c907a859b019547"
"relation" : "isDocumentedBy",
"identifier" : "https://sandbox.zenodo.org/search?communities=mfn-test&q=alternate.identifier:%22urn%3Alsid%3AMfN%3AEnto%3ABMT0009388%22&f=resource_type%3Aimage%2Binner%3Aimage-photo",
"resource_type" : "image+inner:image-photo"
} ],
"title" : "Physical object urn:lsid:MfN:Ento:BMT0009388 sampled through event urn:lsid:MfN:Ento:SchweiBo1 on 2019-07-04",
"description" : "Physical object urn:lsid:MfN:Ento:BMT0009388 sampled through event urn:lsid:MfN:Ento:SchweiBo1 on 2019-07-04",
"upload_type" : "physicalobject",
"creators" : [ {
"name" : "Museum für Naturkunde Berlin"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import bio.guoda.preston.stream.ContentStreamHandler;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.sun.xml.internal.ws.policy.privateutil.PolicyUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.output.NullOutputStream;
import org.apache.commons.lang3.StringUtils;
Expand Down

0 comments on commit 75cd696

Please sign in to comment.