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

closes #closes #2

parent 573a06c4
No related branches found
No related tags found
1 merge request!2Resolve "dct:rights Statement für Distributionen"
......@@ -74,6 +74,7 @@ public class CatalogFilter implements InitializingBean {
rewriteDownloadAndAccessURLs(model);
addDownloadURLs(model);
addAccessRights(model);
addRights(model);
return model;
}
......@@ -292,4 +293,24 @@ public class CatalogFilter implements InitializingBean {
urlReplacements.put(source, target);
}
}
/**
* Add a dct:rights statement to Distributions. The German DCAT-AP.de treats dct:rights as a not so
* important optional property and relies on dct:license. However, the European data portal values the
* dct:rights property highly.
*/
void addRights(Model model) {
final ResIterator it = model.listSubjectsWithProperty(RDF.type, DCAT.Distribution);
while (it.hasNext()) {
final Resource distribution = it.next();
final Resource rights = distribution.getPropertyResourceValue(DCTerms.rights);
final Resource license = distribution.getPropertyResourceValue(DCTerms.license);
if (rights == null && license != null) {
distribution.addProperty(DCTerms.rights, license);
}
}
}
}
......@@ -156,7 +156,7 @@ public class CatalogFilterTest {
/**
* Check that a <code>dct:accessRights http://publications.europa.eu/resource/authority/access-right/PUBLIC</code>
* statement ist added to each dataset.
* statement has been added to each dataset.
*/
@Test
public void work_will_add_accessRights() throws Exception {
......@@ -178,4 +178,29 @@ public class CatalogFilterTest {
inputStream.close();
}
/**
* Check that a dct:rights statement has been added to each distribution and is equal to the dct:license statement.
*/
@Test
public void work_will_add_rights() throws Exception {
final InputStream inputStream = getClass().getResourceAsStream("/with_collection.xml");
final Model model = catalogFilter.work(inputStream);
// Every dataset has a dct:accessRights statement
final ResIterator it = model.listSubjectsWithProperty(RDF.type, DCAT.Distribution);
int count = 0;
while (it.hasNext()) {
final Resource distribution = it.next();
count++;
final Resource rights = distribution.getPropertyResourceValue(DCTerms.rights);
final Resource license = distribution.getPropertyResourceValue(DCTerms.license);
assertNotNull(rights);
assertEquals( license, rights);
}
assertEquals(7, count);
inputStream.close();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment