Skip to content
Snippets Groups Projects
Commit cc7d8cec authored by Jesper Zedlitz's avatar Jesper Zedlitz
Browse files

Angabe der Kategorie für Hochwertige Datensätze (HVD) gemäß GDI-DE Mapping

parent 048bdb18
No related branches found
No related tags found
No related merge requests found
...@@ -41,7 +41,6 @@ public class MDMetadata2Dataset { ...@@ -41,7 +41,6 @@ public class MDMetadata2Dataset {
private static final String LANGUAGE_DE = "de"; private static final String LANGUAGE_DE = "de";
private static final Logger log = LoggerFactory.getLogger(MDMetadata2Dataset.class); private static final Logger log = LoggerFactory.getLogger(MDMetadata2Dataset.class);
private static final String XPATH_OPERATION_GET_CAPABILITIES = "gmd:identificationInfo/*/srv:containsOperations/srv:SV_OperationMetadata[srv:operationName/gco:CharacterString/text()='GetCapabilities']"; private static final String XPATH_OPERATION_GET_CAPABILITIES = "gmd:identificationInfo/*/srv:containsOperations/srv:SV_OperationMetadata[srv:operationName/gco:CharacterString/text()='GetCapabilities']";
private static final Property PROPERTY_applicable_Legislation = ResourceFactory.createProperty("http://data.europa.eu/r5r/", "applicableLegislation");
static IRIFactory factory = IRIFactory.iriImplementation(); static IRIFactory factory = IRIFactory.iriImplementation();
private final Model model; private final Model model;
private final Map<String, String> keywordMapping = new HashMap<>(); private final Map<String, String> keywordMapping = new HashMap<>();
...@@ -813,10 +812,29 @@ public class MDMetadata2Dataset { ...@@ -813,10 +812,29 @@ public class MDMetadata2Dataset {
} }
// convert INSPIRE keywords into dcatap:applicableLegislation properties // convert INSPIRE keywords into dcatap:applicableLegislation properties
if (descriptiveKeywords.contains("inspireidentifiziert") if (descriptiveKeywords.contains("inspireidentifiziert")) {
|| descriptiveKeywords.contains("INSPIRE") dataset.addProperty(DCATAP.applicableLegislation, model.createResource("http://data.europa.eu/eli/dir/2007/2/2019-06-26"));
|| descriptiveKeywords.contains("inspire")) { }
dataset.addProperty(PROPERTY_applicable_Legislation, model.createResource("http://data.europa.eu/eli/dir/2007/2/2019-06-26"));
// Create the HVD properties in accordance with the GDI-DE mapping rules of 2024-03-20
final List<Node> hvdRelevantKeywordNodes =
metadata.selectNodes("gmd:identificationInfo/*/gmd:descriptiveKeywords/gmd:MD_Keywords[" +
"gmd:thesaurusName/gmd:CI_Citation/gmd:title/gco:CharacterString = 'High-value dataset categories'" +
" or gmd:thesaurusName/gmd:CI_Citation/gmd:title/gmx:Anchor/@xlink:href = 'http://data.europa.eu/bna/asd487ae75']");
if( !hvdRelevantKeywordNodes.isEmpty()) {
dataset.addProperty(DCATAP.applicableLegislation, model.createResource("http://data.europa.eu/eli/reg_impl/2023/138/oj"));
}
for (Node keyword : hvdRelevantKeywordNodes) {
Node characterString = keyword.selectSingleNode("./gmd:keyword/gco:CharacterString/text()");
Node anchorRef = keyword.selectSingleNode("./gmd:keyword/gmx:Anchor/@xlink:href");
if( characterString != null) {
dataset.addProperty(DCATAP.hvdCategory, Mapping.mapHvdCategory(characterString.getStringValue()));
}
if( anchorRef != null) {
dataset.addProperty(DCATAP.hvdCategory, model.createResource( anchorRef.getStringValue()));
}
} }
// convert preview image // convert preview image
...@@ -906,6 +924,8 @@ public class MDMetadata2Dataset { ...@@ -906,6 +924,8 @@ public class MDMetadata2Dataset {
return dataset; return dataset;
} }
private boolean isMultiFormatDataset(Element metadata) { private boolean isMultiFormatDataset(Element metadata) {
final List<Node> formatElements = metadata.selectNodes("gmd:distributionInfo/*/gmd:distributionFormat"); final List<Node> formatElements = metadata.selectNodes("gmd:distributionInfo/*/gmd:distributionFormat");
return formatElements.size() > 1; return formatElements.size() > 1;
......
...@@ -211,4 +211,23 @@ public class Mapping { ...@@ -211,4 +211,23 @@ public class Mapping {
throw new IllegalArgumentException(applicationProfile + " is not an allowed applicationProfile."); throw new IllegalArgumentException(applicationProfile + " is not an allowed applicationProfile.");
} }
} }
public static Resource mapHvdCategory(String germanName) {
if ("Georaum".equals(germanName)) {
return ResourceFactory.createResource("http://data.europa.eu/bna/c_ac64a52d");
} else if ("Erdbeobachtung und Umwelt".equals(germanName)) {
return ResourceFactory.createResource("http://data.europa.eu/bna/c_dd313021");
} else if ("Meteorologie".equals(germanName)) {
return ResourceFactory.createResource("http://data.europa.eu/bna/c_164e0bf5");
} else if ("Statistik".equals(germanName)) {
return ResourceFactory.createResource("http://data.europa.eu/bna/c_e1da4e07");
} else if ("Unternehmen und Eigentümerschaft von Unternehmen".equals(germanName)) {
return ResourceFactory.createResource("http://data.europa.eu/bna/c_a9135398");
} else if ("Mobilität".equals(germanName)) {
return ResourceFactory.createResource("http://data.europa.eu/bna/c_b79e35eb");
} else {
log.info("{} is not an allowed HVD category.", germanName);
throw new IllegalArgumentException(germanName + " is not an allowed HVD category.");
}
}
} }
package de.landsh.opendata.csw2dcat.vocabulary;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.rdf.model.Property;
import org.apache.jena.rdf.model.Resource;
public class DCATAP {
public static final String NS = "http://data.europa.eu/r5r/";
public static final Resource NAMESPACE;
public static final Property applicableLegislation;
public static final Property hvdCategory;
private static final Model m_model = ModelFactory.createDefaultModel();
static {
NAMESPACE = m_model.createResource(NS);
applicableLegislation = m_model.createProperty(NS, "applicableLegislation");
hvdCategory = m_model.createProperty(NS, "hvdCategory");
}
private DCATAP() {
}
public static String getURI() {
return NS;
}
}
...@@ -1328,4 +1328,34 @@ public class MDMetadata2DatasetTests { ...@@ -1328,4 +1328,34 @@ public class MDMetadata2DatasetTests {
assertEquals(FILE_TYPE_GML, distribution2.getProperty(DCTerms.format).getResource()); assertEquals(FILE_TYPE_GML, distribution2.getProperty(DCTerms.format).getResource());
assertEquals("WFS Landschaftsschutzgebiete (1:25.000)", distribution2.getProperty(DCTerms.title).getString()); assertEquals("WFS Landschaftsschutzgebiete (1:25.000)", distribution2.getProperty(DCTerms.title).getString());
} }
/**
* Specification of the HVD category as free text in characterString elements
* (in accordance with the GDI-DE mapping rules of 2024-03-20 variant a)
*/
@Test
public void convert_highValueDataset_a() throws DocumentException, IOException {
final Document inputDocument = saxReader.read(getClass().getResourceAsStream("/hvd1.xml"));
final Resource result = service.convert(inputDocument);
assertEquals("http://data.europa.eu/eli/reg_impl/2023/138/oj",
result.getPropertyResourceValue(DCATAP.applicableLegislation).getURI());
assertEquals("http://data.europa.eu/bna/c_ac64a52d",
result.getPropertyResourceValue(DCATAP.hvdCategory).getURI());
}
/**
* Referencing the EU vocabulary for HVD categories as gmx:Anchor elements
* (in accordance with the GDI-DE mapping rules of 2024-03-20 variant b)
*/
@Test
public void convert_highValueDataset_b() throws DocumentException, IOException {
final Document inputDocument = saxReader.read(getClass().getResourceAsStream("/hvd2.xml"));
final Resource result = service.convert(inputDocument);
assertEquals("http://data.europa.eu/eli/reg_impl/2023/138/oj",
result.getPropertyResourceValue(DCATAP.applicableLegislation).getURI());
assertEquals("http://data.europa.eu/bna/c_ac64a52d",
result.getPropertyResourceValue(DCATAP.hvdCategory).getURI());
}
} }
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment