Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -143,24 +143,24 @@ private Set<AssociatedResource> getAssociatedVirtualCatalog(Element metadata) {
/**
* For next records, resolve dcat:next elements
*/
private Set<AssociatedResource> getAssociatedNext(Element metadata) {
Set<AssociatedResource> results = getAssociatedResourcesByXpath(metadata, "*//dcat:next/@rdf:resource");
private Set<AssociatedResource> getAssociatedPrevious(Element metadata) {
Set<AssociatedResource> results = getAssociatedResourcesByXpath(metadata, "*//dcat:prev/@rdf:resource");
return results.stream()
.peek(ar -> ar.setAssociationType("nextResource"))
.peek(ar -> ar.setAssociationType("revisionOf"))
.collect(Collectors.toSet());
}

/**
* For previous records, find datasets that point to the current one with a dcat:next
*/
private Set<AssociatedResource> getAssociatedPrevious(Element metadata) {
private Set<AssociatedResource> getAssociatedNext(Element metadata) {
try {
String currentUuid = getCurrentUuid(metadata);
if (currentUuid == null) {
return Collections.emptySet();
}
var searchManager = ApplicationContextHolder.get().getBean(EsSearchManager.class);
var response = searchManager.query(String.format("+nextUUIDInSeries:\"%s\"", currentUuid), null,
var response = searchManager.query(String.format("+previousUUIDInSeries:\"%s\"", currentUuid), null,
Sets.newHashSet("uuid", "resourceTitleObject.default"), 0, 100);

if (response.hits().hits().isEmpty()) {
Expand All @@ -175,15 +175,15 @@ private Set<AssociatedResource> getAssociatedPrevious(Element metadata) {
AssociatedResource ar = new AssociatedResource(
(String) associatedRecord.get("uuid"),
"",
"previousResource",
"nextResource",
null,
((Map<String, String>) associatedRecord.get("resourceTitleObject")).get("default")
);
res.add(ar);
}
return res;
} catch (Exception e) {
Log.error(Log.JEEVES, "GET associated previous resources error: " + e.getMessage(), e);
Log.error(Log.JEEVES, "GET associated next resources error: " + e.getMessage(), e);
}
return Collections.emptySet();
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/plugin/dcat-ap/config/associated-panel/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
"isTemplate": "n"
},
"searchParamsPerType": {
"revisionOf-*": {
"type": [
"dataset",
"service"
]
},
"nextResource-*": {
"type": [
"dataset",
Expand Down
5 changes: 5 additions & 0 deletions src/main/plugin/dcat-ap/index-fields/index.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@
<xsl:value-of select="dcatutil:getUUIDByURI(normalize-space(@rdf:resource))"/>
</nextUUIDInSeries>
</xsl:for-each>
<xsl:for-each select="dcat:prev[normalize-space(@rdf:resource) != '']">
<previousUUIDInSeries>
<xsl:value-of select="dcatutil:getUUIDByURI(normalize-space(@rdf:resource))"/>
</previousUUIDInSeries>
</xsl:for-each>
<!-- Index more fields in this element -->
<xsl:apply-templates mode="index-extra-fields" select="."/>
</doc>
Expand Down
11 changes: 8 additions & 3 deletions src/main/plugin/dcat-ap/loc/dut/codelists.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@

<codelists>
<codelist name="dcat:Resource" alias="associationType">
<entry>
<!--<entry>
<code>nextResource</code>
<label>Volgende resource</label>
<description>Volgende resource in reeks</description>
<label>Volgende Resource</label>
<description>Volgende Resource in reeks</description>
</entry>-->
<entry>
<code>revisionOf</code>
<label>Vorherige Resource</label>
<description>Vorherige Resource in series</description>
</entry>
</codelist>
</codelists>
7 changes: 6 additions & 1 deletion src/main/plugin/dcat-ap/loc/eng/codelists.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@

<codelists>
<codelist name="dcat:Resource" alias="associationType">
<entry>
<!--<entry>
<code>nextResource</code>
<label>Next resource</label>
<description>Next resource in series</description>
</entry>-->
<entry>
<code>revisionOf</code>
<label>Previous resource</label>
<description>Previous resource in series</description>
</entry>
</codelist>
</codelists>
9 changes: 7 additions & 2 deletions src/main/plugin/dcat-ap/loc/fre/codelists.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@

<codelists>
<codelist name="dcat:Resource" alias="associationType">
<entry>
<!--<entry>
<code>nextResource</code>
<label>Ressource suivante</label>
<label>Version suivante</label>
<description>Ressource suivante dans la série</description>
</entry>-->
<entry>
<code>revisionOf</code>
<label>Version précédente</label>
<description>Ressource précédente dans la série</description>
</entry>
</codelist>
</codelists>
7 changes: 6 additions & 1 deletion src/main/plugin/dcat-ap/loc/ger/codelists.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@

<codelists>
<codelist name="dcat:Resource" alias="associationType">
<entry>
<!--<entry>
<code>nextResource</code>
<label>Nächste Ressource</label>
<description>Nächste Ressource in der Reihe</description>
</entry>-->
<entry>
<code>revisionOf</code>
<label>Vorherige Ressource</label>
<description>Vorherige Ressource in series</description>
</entry>
</codelist>
</codelists>
7 changes: 4 additions & 3 deletions src/main/plugin/dcat-ap/process/sibling-add.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
</xsl:for-each>
</xsl:template>

<xsl:template match="*[name() = ('dcat:Dataset', 'dcat:DataService', 'dcat:DatasetSeries') and $associationType = 'nextResource']">
<xsl:template match="*[name() = ('dcat:Dataset', 'dcat:DataService', 'dcat:DatasetSeries') and $associationType = ('nextResource', 'revisionOf')]">

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fxprunayre is there a reason for naming the new type revisionOf instead of prevResource, which would be more specific?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main reason was that it is the same value as in ISO. At some point we could also integrate version API done in geonetwork/core-geonetwork#9227 for DCAT records.

<xsl:variable name="resourceWithNext">
<xsl:copy>
<xsl:copy-of select="@*"/>
Expand All @@ -102,10 +102,11 @@
</xsl:if>
</xsl:for-each>
</xsl:variable>

<xsl:for-each select="$uriToAdd">
<dcat:next>
<xsl:element name="{if ($associationType = 'nextResource') then 'dcat:next' else 'dcat:prev'}">
<xsl:attribute name="rdf:resource" select="uri"/>
</dcat:next>
</xsl:element>
</xsl:for-each>
</xsl:copy>
</xsl:variable>
Expand Down
1 change: 1 addition & 0 deletions src/main/plugin/dcat-ap/process/sibling-remove.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
dcat:CatalogRecord[starts-with(@rdf:about, 'http') and @rdf:about = $uuidref]"/>

<xsl:template match="dcat:next[@rdf:resource = $uriRef]"/>
<xsl:template match="dcat:prev[@rdf:resource = $uriRef]"/>

<xsl:template match="@*|*|text()">
<xsl:copy>
Expand Down
Loading