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

closes #1

parent bc30ed7a
Branches
Tags
1 merge request!1Resolve "dct:accessRights hinzufügen"
......@@ -21,17 +21,21 @@ import java.util.*;
*/
public class CatalogFilter implements InitializingBean {
private static final Collection<Resource> UNWANTED_FORMATS = Arrays.asList(
ResourceFactory.createResource("http://publications.europa.eu/resource/authority/file-type/PDF"),
ResourceFactory.createResource("http://publications.europa.eu/resource/authority/file-type/DOC"),
ResourceFactory.createResource("http://publications.europa.eu/resource/authority/file-type/DOCX"),
ResourceFactory.createResource("http://publications.europa.eu/resource/authority/file-type/HTML")
);
private static final Resource ACCESS_RIGHTS_PUBLIC = ResourceFactory.createResource("http://publications.europa.eu/resource/authority/access-right/PUBLIC");
private static final Property LOCN_GEOMETRY = ResourceFactory.createProperty("http://www.w3.org/ns/locn#geometry");
final private Map<String, String> urlReplacements = new HashMap<>();
@Value("#{${replaceURL:''}}")
List<String> replaceURL;
@Value("${baseURL:http://localhost:8080/}")
private String baseURL;
......@@ -69,10 +73,28 @@ public class CatalogFilter implements InitializingBean {
rewriteHydraURLs(model);
rewriteDownloadAndAccessURLs(model);
addDownloadURLs(model);
addAccessRights(model);
return model;
}
/**
* It is totally important to the European data portal that there is an <code>accessRights = PUBLIC</code> statement
* for every dataset.
*/
private void addAccessRights(Model model) {
final ResIterator it = model.listSubjectsWithProperty(RDF.type, DCAT.Dataset);
while (it.hasNext()) {
final Resource dataset = it.next();
final Resource accessRight = dataset.getPropertyResourceValue(DCTerms.accessRights);
if (accessRight == null) {
dataset.addProperty(DCTerms.accessRights, ACCESS_RIGHTS_PUBLIC);
}
}
}
/**
* Add downloadURL properties to Distributions. The German DCAT-AP.de treats downloadURL as a not so
* important optional properties and relies on the accessURL. However, the European data portal values the
......
......@@ -8,6 +8,7 @@ import org.apache.jena.riot.RDFLanguages;
import org.apache.jena.riot.RDFParser;
import org.apache.jena.riot.system.ErrorHandlerFactory;
import org.apache.jena.vocabulary.DCAT;
import org.apache.jena.vocabulary.DCTerms;
import org.apache.jena.vocabulary.RDF;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
......@@ -152,4 +153,29 @@ public class CatalogFilterTest {
inputStream.close();
}
/**
* Check that a <code>dct:accessRights http://publications.europa.eu/resource/authority/access-right/PUBLIC</code>
* statement ist added to each dataset.
*/
@Test
public void work_will_add_accessRights() 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.Dataset);
int count = 0;
while (it.hasNext()) {
final Resource distribution = it.next();
count++;
final Resource accessRights = distribution.getPropertyResourceValue(DCTerms.accessRights);
assertNotNull(accessRights);
assertEquals("http://publications.europa.eu/resource/authority/access-right/PUBLIC", accessRights.getURI());
}
assertEquals(8, count);
inputStream.close();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment