Skip to content

Commit

Permalink
Formatter / DCAT / Improve mapping for organization with multiple ind…
Browse files Browse the repository at this point in the history
…ividual.
  • Loading branch information
fxprunayre committed Sep 4, 2024
1 parent 8628bc4 commit 58c5363
Show file tree
Hide file tree
Showing 9 changed files with 2,318 additions and 2,176 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@
as="node()?"
select="$isoContactRoleToDcatCommonNames[. = $role]"/>

<xsl:variable name="allIndividualOrOrganisationWithoutIndividual"
select="*/cit:party//(cit:CI_Organisation[not(cit:individual)]|cit:CI_Individual)"
as="node()*"/>

<xsl:choose>
<xsl:when test="$dcatElementConfig">
<xsl:for-each-group select="*/cit:party/cit:CI_Organisation" group-by="cit:name">
<xsl:for-each-group select="$allIndividualOrOrganisationWithoutIndividual" group-by="cit:name">
<xsl:element name="{$dcatElementConfig/@key}">
<xsl:choose>
<xsl:when test="$dcatElementConfig/@as = 'vcard'">
Expand All @@ -69,7 +73,7 @@
Range: prov:Attribution
Usage note: Used to link to an Agent where the nature of the relationship is known but does not match one of the standard [DCTERMS] properties (dcterms:creator, dcterms:publisher). Use dcat:hadRole on the prov:Attribution to capture the responsibility of the Agent with respect to the Resource. See 15.1 Relationships between datasets and agents for usage examples.
-->
<xsl:for-each-group select="*/cit:party/cit:CI_Organisation" group-by="cit:name">
<xsl:for-each-group select="$allIndividualOrOrganisationWithoutIndividual" group-by="cit:name">
<prov:qualifiedAttribution>
<prov:Attribution>
<prov:agent>
Expand All @@ -95,19 +99,46 @@


<xsl:template name="rdf-contact-vcard">
<xsl:variable name="isindividual"
as="xs:boolean"
select="local-name() = 'CI_Individual'"/>
<xsl:variable name="individualName"
as="xs:string?"
select="if ($isindividual) then cit:name/*/text() else ''"/>
<xsl:variable name="organisation"
as="node()?"
select="if ($isindividual) then ancestor::cit:CI_Organisation else ."/>

<rdf:Description>
<xsl:call-template name="rdf-object-ref-attribute"/>

<rdf:type rdf:resource="http://www.w3.org/2006/vcard/ns#Organization"/>
<xsl:for-each select="cit:name">
<xsl:call-template name="rdf-localised">
<xsl:with-param name="nodeName" select="'vcard:fn'"/>
</xsl:call-template>
<xsl:if test="$individualName != ''">
<vcard:fn><xsl:value-of select="$individualName"/></vcard:fn>
</xsl:if>
<xsl:for-each select="$organisation/cit:name">
<vcard:org>
<rdf:Description>
<xsl:call-template name="rdf-localised">
<xsl:with-param name="nodeName" select="'vcard:organisation-name'"/>
</xsl:call-template>
</rdf:Description>
</vcard:org>
</xsl:for-each>


<xsl:variable name="contactInfo"
as="node()?"
select="if ($isindividual)
then $organisation/cit:contactInfo
else cit:contactInfo"/>

<!-- Priority on the individual email and fallback on org email-->
<xsl:for-each select="(cit:contactInfo/*/cit:address/*/cit:electronicMailAddress, $organisation/cit:contactInfo/*/cit:address/*/cit:electronicMailAddress)[1]">
<vcard:hasEmail rdf:resource="mailto:{*/text()}"/>
</xsl:for-each>
<xsl:for-each select="cit:contactInfo/*/cit:address">
<xsl:for-each select="*/cit:electronicMailAddress">
<vcard:hasEmail rdf:resource="mailto:{*/text()}"/>
</xsl:for-each>

<xsl:for-each select="$contactInfo/*/cit:address">
<xsl:if test="normalize-space(*/cit:city) != ''">
<vcard:hasAddress>
<vcard:Address>
Expand Down Expand Up @@ -145,23 +176,23 @@


<xsl:template name="rdf-contact-foaf">
<xsl:variable name="individualName"
as="xs:string?"
select="(cit:individual/*/cit:name/*/text())[1]"/>
<xsl:variable name="isindividual"
as="xs:boolean"
select="$individualName != ''"/>
select="local-name() = 'CI_Individual'"/>
<xsl:variable name="individualName"
as="xs:string?"
select="if ($isindividual) then cit:name/*/text() else ''"/>
<xsl:variable name="organisation"
as="node()?"
select="cit:name"/>
select="if ($isindividual) then ancestor::cit:CI_Organisation else ."/>
<xsl:variable name="orgReference"
as="xs:string?"
select="gn-fn-dcat:rdf-object-ref(.)"/>
select="gn-fn-dcat:rdf-object-ref($organisation)"/>
<xsl:variable name="reference"
as="xs:string?"
select="if ($isindividual)
then gn-fn-dcat:rdf-object-ref(cit:individual/*)
else $orgReference"/>
then gn-fn-dcat:rdf-object-ref(.)
else $orgReference"/>

<rdf:Description>
<xsl:call-template name="rdf-object-ref-attribute">
Expand All @@ -174,7 +205,7 @@
<xsl:when test="$isindividual">
<foaf:name><xsl:value-of select="$individualName"/></foaf:name>
<org:memberOf>
<xsl:for-each select="$organisation">
<xsl:for-each select="$organisation/cit:name">
<foaf:Organization>
<xsl:call-template name="rdf-object-ref-attribute">
<xsl:with-param name="reference" select="$reference"/>
Expand All @@ -187,19 +218,25 @@
</org:memberOf>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="$organisation">
<xsl:for-each select="$organisation/cit:name">
<xsl:call-template name="rdf-localised">
<xsl:with-param name="nodeName" select="'foaf:name'"/>
</xsl:call-template>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>

<xsl:variable name="contactInfo"
as="node()?"
select="if ($isindividual)
then $organisation/cit:contactInfo
else cit:contactInfo"/>

<xsl:for-each select="cit:contactInfo/*/cit:address/*/cit:electronicMailAddress">
<!-- Priority on the individual email and fallback on org email-->
<xsl:for-each select="(cit:contactInfo/*/cit:address/*/cit:electronicMailAddress, $organisation/*/cit:address/*/cit:electronicMailAddress)[1]">
<foaf:mbox rdf:resource="mailto:{*/text()}"/>
</xsl:for-each>
<xsl:for-each select="cit:contactInfo/*/cit:onlineResource/*/cit:linkage">
<xsl:for-each select="$contactInfo/*/cit:onlineResource/*/cit:linkage">
<xsl:call-template name="rdf-localised">
<xsl:with-param name="nodeName" select="'foaf:workplaceHomepage'"/>
</xsl:call-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
*/
package org.fao.geonet.api.records.formatters;

import java.io.File;
import jeeves.server.context.ServiceContext;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.jena.graph.Graph;
import org.apache.jena.rdf.model.Model;
Expand Down Expand Up @@ -149,8 +151,8 @@ public void checkFormatter() throws Exception {
}


// FileUtils.writeStringToFile(new File("/tmp/rdf/" + String.format("%s-%s-%s",
// schema, formatter, checkfile)), actual, StandardCharsets.UTF_8);
// FileUtils.writeStringToFile(new File("/tmp/services/src/test/resources/org/fao/geonet/api/records/formatters/" + String.format("%s-%s-%s",
// schema, formatter, checkfile)), actual.replaceFirst("urn:uuid/.*</dct:identifier>", "urn:uuid/{uuid}</dct:identifier>"), StandardCharsets.UTF_8);

Diff diff = DiffBuilder
.compare(Input.fromString(actual))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,22 +132,29 @@
<rdf:Description>
<rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Organization"/>
<rdf:type rdf:resource="http://www.w3.org/ns/prov#Agent"/>
<foaf:name xml:lang="fre">Helpdesk carto du SPW (SPW - Secrétariat général - SPW Digital - Département de la Géomatique - Direction de l'Intégration des géodonnées)</foaf:name>
<foaf:name xml:lang="fre">Helpdesk carto du SPW (SPW - Secrétariat général - SPW Digital - Département de la
Géomatique - Direction de l'Intégration des géodonnées)</foaf:name>
<foaf:mbox rdf:resource="mailto:[email protected]"/>
</rdf:Description>
</dct:creator>
<dct:publisher>
<rdf:Description>
<rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Organization"/>
<rdf:type rdf:resource="http://www.w3.org/ns/prov#Agent"/>
<foaf:name xml:lang="fre">Helpdesk carto du SPW (SPW - Secrétariat général - SPW Digital - Département de la Géomatique - Direction de l'Intégration des géodonnées)</foaf:name>
<foaf:name xml:lang="fre">Helpdesk carto du SPW (SPW - Secrétariat général - SPW Digital - Département de la
Géomatique - Direction de l'Intégration des géodonnées)</foaf:name>
<foaf:mbox rdf:resource="mailto:[email protected]"/>
</rdf:Description>
</dct:publisher>
<dcat:contactPoint>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2006/vcard/ns#Organization"/>
<vcard:fn xml:lang="fre">Helpdesk carto du SPW (SPW - Secrétariat général - SPW Digital - Département de la Géomatique - Direction de l'Intégration des géodonnées)</vcard:fn>
<vcard:org>
<rdf:Description>
<vcard:organisation-name xml:lang="fre">Helpdesk carto du SPW (SPW - Secrétariat général - SPW Digital - Département de la
Géomatique - Direction de l'Intégration des géodonnées)</vcard:organisation-name>
</rdf:Description>
</vcard:org>
<vcard:hasEmail rdf:resource="mailto:[email protected]"/>
</rdf:Description>
</dcat:contactPoint>
Expand All @@ -160,10 +167,35 @@
<foaf:name>Thierry Berthet</foaf:name>
<org:memberOf>
<foaf:Organization>
<foaf:name xml:lang="fre">Direction du Développement territorial (SPW - Territoire, Logement, Patrimoine, Énergie - Département de l'Aménagement du territoire et de l'Urbanisme - Direction du Développement territorial)</foaf:name>
<foaf:name xml:lang="fre">Direction du Développement territorial (SPW - Territoire, Logement, Patrimoine,
Énergie - Département de l'Aménagement du territoire et de l'Urbanisme - Direction du Développement
territorial)</foaf:name>
</foaf:Organization>
</org:memberOf>
<foaf:mbox rdf:resource="mailto:[email protected]"/>
</rdf:Description>
</prov:agent>
<dcat:hadRole>
<dcat:Role rdf:about="http://standards.iso.org/iso/19115/resources/Codelists/cat/codelists.xml#custodian">
<skos:prefLabel>custodian</skos:prefLabel>
</dcat:Role>
</dcat:hadRole>
</prov:Attribution>
</prov:qualifiedAttribution>
<prov:qualifiedAttribution>
<prov:Attribution>
<prov:agent>
<rdf:Description rdf:about="https://orcid.org/jb98765">
<rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person"/>
<rdf:type rdf:resource="http://www.w3.org/ns/prov#Agent"/>
<foaf:name>Jean Berthet</foaf:name>
<org:memberOf>
<foaf:Organization rdf:about="https://orcid.org/jb98765">
<foaf:name xml:lang="fre">Direction du Développement territorial (SPW - Territoire, Logement, Patrimoine,
Énergie - Département de l'Aménagement du territoire et de l'Urbanisme - Direction du Développement
territorial)</foaf:name>
</foaf:Organization>
</org:memberOf>
<foaf:mbox rdf:resource="mailto:[email protected]"/>
</rdf:Description>
</prov:agent>
<dcat:hadRole>
Expand Down Expand Up @@ -254,12 +286,14 @@
</dcat:theme>
<dcat:theme>
<skos:Concept rdf:about="http://inspire.ec.europa.eu/theme/mf">
<skos:prefLabel xml:lang="fre">Caractéristiques géographiques météorologiques</skos:prefLabel>
<skos:prefLabel xml:lang="fre">Caractéristiques géographiques
météorologiques</skos:prefLabel>
</skos:Concept>
</dcat:theme>
<dcat:theme>
<skos:Concept rdf:about="http://inspire.ec.europa.eu/theme/of">
<skos:prefLabel xml:lang="fre">Caractéristiques géographiques océanographiques</skos:prefLabel>
<skos:prefLabel xml:lang="fre">Caractéristiques géographiques
océanographiques</skos:prefLabel>
</skos:Concept>
</dcat:theme>
<dcat:theme>
Expand Down Expand Up @@ -363,7 +397,8 @@
<dct:conformsTo>
<dct:Standard>
<rdf:type rdf:resource="http://purl.org/dc/terms/Standard"/>
<rdfs:label xml:lang="fre">INSPIRE Data Specification on Transport Networks – Technical Guidelines, version 3.2</rdfs:label>
<rdfs:label xml:lang="fre">INSPIRE Data Specification on Transport Networks – Technical Guidelines,
version 3.2</rdfs:label>
<dct:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2014-04-17</dct:issued>
</dct:Standard>
</dct:conformsTo>
Expand Down Expand Up @@ -419,9 +454,9 @@
<dct:accrualPeriodicity>
<dct:Frequency rdf:about="http://standards.iso.org/iso/19115/resources/Codelists/cat/codelists.xml#asNeeded"/>
</dct:accrualPeriodicity>
<dct:accrualPeriodicity>
<dct:Frequency rdf:about="https://w3id.org/mobilitydcat-ap/update-frequency/15min"/>
</dct:accrualPeriodicity>
<dct:accrualPeriodicity>
<dct:Frequency rdf:about="https://w3id.org/mobilitydcat-ap/update-frequency/15min"/>
</dct:accrualPeriodicity>
<foaf:page>
<foaf:Document rdf:about="https://metawal.wallonie.be/geonetwork/srv/api/records/7fe2f305-1302-4297-b67e-792f55acd834/attachments/pds_codt.png">
<dct:description xml:lang="fre">pds_codt_pic</dct:description>
Expand Down Expand Up @@ -517,4 +552,4 @@
</foaf:Document>
</foaf:page>
</rdf:Description>
</rdf:RDF>
</rdf:RDF>
Loading

0 comments on commit 58c5363

Please sign in to comment.