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

Handle dcat:DataServices correctly

Check that dcat:DataServices as preserved.
Do not add a dcat:downloadURL to a dcat:Distribution that is served by a DataService.
parent 10edaa24
No related branches found
No related tags found
1 merge request!5Resolve "DataService und DatasetSeries erhalten"
Pipeline #1255 passed
......@@ -130,8 +130,9 @@ public class CatalogFilter implements InitializingBean {
final Resource accessURL = distribution.getPropertyResourceValue(DCAT.accessURL);
final Resource downloadURL = distribution.getPropertyResourceValue(DCAT.downloadURL);
final boolean hasAccessService = distribution.hasProperty(DCAT.accessService);
if (downloadURL == null) {
if (downloadURL == null && !hasAccessService) {
distribution.addProperty(DCAT.downloadURL, accessURL);
}
}
......
......@@ -277,4 +277,49 @@ public class CatalogFilterTest {
assertTrue(model.listStatements(null, DCAT.startDate, (String) null).hasNext());
}
}
/**
* A data service must be preserved.
*/
@Test
public void dataservice() throws IOException {
try (final InputStream inputStream = getClass().getResourceAsStream("/dataservice.xml")) {
final Model model = catalogFilter.work(inputStream);
assertEquals(1, model.listStatements(null, RDF.type, DCAT.Dataset).toList().size(), "one dcat:Dataset");
assertEquals(4, model.listStatements(null, RDF.type, DCAT.Distribution).toList().size(), "four dcat:Distribution");
assertEquals(2, model.listStatements(null, RDF.type, DCAT.DataService).toList().size(), "two dcat:DataService");
}
}
/**
* In case of a dcat:DataService no dcat:downloadURL must be added to a dcat:Distribution
* <a href="https://www.dcat-ap.de/def/dcatde/2.0/implRules/#konvention-41">Konvention 41</a> states that a
* dcat:Distribution MUST NOT have a dcat:downloadURL property.
*/
@Test
public void addDownloadURLs_DataService() {
final Model model = parseRdf(getClass().getResourceAsStream("/dataservice.xml"));
catalogFilter.addDownloadURLs(model);
Resource distributionWithService1 = model.getResource("https://umweltgeodienste.schleswig-holstein.de/WMS_UWAT_NAT?");
Resource distributionWithService2 = model.getResource("https://umweltgeodienste.schleswig-holstein.de/WFS_UWAT?");
Resource distributionWithoutService1 = model.getResource("https://umweltgeodienste.schleswig-holstein.de/WFS_UWAT?service=wfs&version=2.0.0&request=GetFeature&typeNames=app:ramsar");
Resource distributionWithoutService2 = model.getResource("https://opendata.schleswig-holstein.de/data/llur55/ramsar_utm32.zip");
assertTrue(distributionWithService1.hasProperty(DCAT.accessURL));
assertTrue(distributionWithService1.hasProperty(DCAT.accessService));
assertFalse(distributionWithService1.hasProperty(DCAT.downloadURL), "a dcat:Distribution with a dcat:DataService MUST NOT have a dcat:downloadURL");
assertTrue(distributionWithService2.hasProperty(DCAT.accessURL));
assertTrue(distributionWithService2.hasProperty(DCAT.accessService));
assertFalse(distributionWithService2.hasProperty(DCAT.downloadURL), "a dcat:Distribution with a dcat:DataService MUST NOT have a dcat:downloadURL");
assertTrue(distributionWithoutService1.hasProperty(DCAT.accessURL));
assertTrue(distributionWithoutService1.hasProperty(DCAT.downloadURL));
assertTrue(distributionWithoutService2.hasProperty(DCAT.accessURL));
assertTrue(distributionWithoutService2.hasProperty(DCAT.downloadURL));
}
}
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