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

Filtern von Nicht-Regierungsorganisationen

closes #4
parent 8d54a9f5
Branches
No related tags found
No related merge requests found
......@@ -36,6 +36,9 @@ public class CatalogFilter implements InitializingBean {
@Value("#{${replaceURL:''}}")
List<String> replaceURL;
@Value("#{${unwantedPublishers:''}}")
List<String> unwantedPublishers;
@Value("${baseURL:http://localhost:8080/}")
private String baseURL;
......@@ -58,7 +61,7 @@ public class CatalogFilter implements InitializingBean {
final ResIterator it = model.listSubjectsWithProperty(RDF.type, DCAT.Dataset);
while (it.hasNext()) {
final Resource dataset = it.next();
if (hasAtLeastOneValidDistribution(dataset) || isCollection(dataset)) {
if (includeThisDataset(dataset)) {
usedDistributionIds.addAll(getDistributionsForDataset(dataset));
} else {
model.remove(dataset.listProperties());
......@@ -79,6 +82,22 @@ public class CatalogFilter implements InitializingBean {
return model;
}
/**
* Determine if the specified dataset follows the rules of GovData and should be included in the output.
*
* @param dataset RDF data of the dataset
* @return true if the dataset should be included
*/
private boolean includeThisDataset(Resource dataset) {
return isDatasetOfPublicAdministration(dataset) && (hasAtLeastOneValidDistribution(dataset) || isCollection(dataset));
}
boolean isDatasetOfPublicAdministration(Resource dataset) {
final Resource publisher = dataset.getPropertyResourceValue(DCTerms.publisher);
final String uri = publisher == null ? null : publisher.getURI();
return unwantedPublishers == null || !unwantedPublishers.contains(uri);
}
/**
* It is totally important to the European data portal that there is an <code>accessRights = PUBLIC</code> statement
* for every dataset.
......
......@@ -2,3 +2,4 @@ baseURL=http://localhost:8080/
remoteURL=https://opendata.schleswig-holstein.de/
replaceURL= {'http://10.61.35.179/','https://opendata.schleswig-holstein.de/','http://134.245.19.83/','https://opendata.zitsh.de/' }
unwantedPublishers={'https://opendata.schleswig-holstein.de/organization/ec64ed4a-014c-4ab4-8678-ac77a3acac3e','https://opendata.schleswig-holstein.de/organization/f49b003d-a807-48d4-99da-10786e8fb6bc','https://opendata.schleswig-holstein.de/organization/64ca6728-f1ef-4177-a85d-9d5bd7d9f98b','https://opendata.schleswig-holstein.de/organization/b3cb8786-fe47-4370-b9e2-b5deb48ed0ed','https://opendata.schleswig-holstein.de/organization/b8119e6c-c0f4-4782-b0e1-7b635fc9d34c','https://opendata.schleswig-holstein.de/organization/b342e494-84f1-4210-92e0-caa525b9bddb','https://opendata.schleswig-holstein.de/organization/2383e356-4902-41ca-a25d-7a58f2eccc40','https://opendata.schleswig-holstein.de/organization/a2977a42-eff6-4f88-b4ff-7735c64d1afc','https://opendata.schleswig-holstein.de/organization/7c98f0d5-f35c-44d6-9195-016b83c8bb3e','https://opendata.schleswig-holstein.de/organization/3bcf68c9-aa47-47c7-a07a-48637e1cabfe','https://opendata.schleswig-holstein.de/organization/a4ce8cad-cc0a-4dba-9eed-42af709ab1a5','https://opendata.schleswig-holstein.de/organization/f2f63ad5-cb4f-4da9-87bc-7b65e54c112b','https://opendata.schleswig-holstein.de/organization/ee4df032-ec5f-4726-b7ad-a2c708fb53ec','https://opendata.schleswig-holstein.de/organization/0533e1b4-06f5-42e9-a3b4-c3dd55e94410'}
......@@ -14,9 +14,9 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
......@@ -125,7 +125,7 @@ public class CatalogFilterTest {
@Test
public void rewriteDownloadAndAccessURLs() throws Exception {
catalogFilter.replaceURL = Arrays.asList("http://example.org/","https://opendata.sh/","https://www.statistik-nord.de/","https://data.sh/");
catalogFilter.replaceURL = Arrays.asList("http://example.org/", "https://opendata.sh/", "https://www.statistik-nord.de/", "https://data.sh/");
catalogFilter.afterPropertiesSet();
final Model model = parseRdf(getClass().getResourceAsStream("/with_downloadURL.xml"));
......@@ -196,7 +196,7 @@ public class CatalogFilterTest {
final Resource rights = distribution.getPropertyResourceValue(DCTerms.rights);
final Resource license = distribution.getPropertyResourceValue(DCTerms.license);
assertNotNull(rights);
assertEquals( license, rights);
assertEquals(license, rights);
}
assertEquals(7, count);
......@@ -213,4 +213,21 @@ public class CatalogFilterTest {
final InputStream inputStream = getClass().getResourceAsStream("/invalid_iri.xml");
final Model model = catalogFilter.work(inputStream);
}
/**
* The filter will remove datasets from non government organizations.
*/
@Test
public void work_will_remove_non_government_organization() throws IOException {
catalogFilter.unwantedPublishers = Collections.singletonList("https://opendata.schleswig-holstein.de/organization/ee4df032-ec5f-4726-b7ad-a2c708fb53ec");
final InputStream inputStream = getClass().getResourceAsStream("/two-organizations.xml");
final Model model = catalogFilter.work(inputStream);
Assertions.assertEquals(1, countInstances(model, DCAT.Dataset));
Assertions.assertEquals(1, countInstances(model, DCAT.Distribution));
inputStream.close();
}
}
<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:locn="http://www.w3.org/ns/locn#"
xmlns:hydra="http://www.w3.org/ns/hydra/core#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dcat="http://www.w3.org/ns/dcat#"
xmlns:dct="http://purl.org/dc/terms/"
xmlns:schema="http://schema.org/"
xmlns:skos="http://www.w3.org/2004/02/skos/core#"
xmlns:dcatde="http://dcat-ap.de/def/dcatde/"
>
<dcat:Catalog rdf:about="https://opendata.schleswig-holstein.de">
<dcat:dataset>
<dcat:Dataset rdf:about="http://llur.landsh.de/pegel/114437/Wasserstand">
<dct:description>
Alle Daten sind Rohdaten ohne Gewähr. Das Land Schleswig-Holstein übernimmt keine Gewähr für die Aktualität, Korrektheit, Vollständigkeit oder Qualität der dargestellten Informationen. Haftungsansprüche sind grundsätzlich ausgeschlossen.
[Informationen zum Pegel](https://www.umweltdaten.landsh.de/pegel/jsp/pegel.jsp?mstnr=114437&amp;wsize=free)
Der Datensatz enthält folgende Felder
* **Zeit** im Format `dd.MM.yyyy HH:mm:ss`
* **Wasserstand** in cm
* **Status** Angabe "qualitätsgesichert" oder "nicht qualitätsgesichert"
Zeichensatz ist ISO-8859-1, Spaltentrenner ist Semikolon.
</dct:description>
<dct:publisher rdf:resource="http://141.91.184.90/organization/llur"/>
<dct:spatial>
<dct:Location rdf:nodeID="Nd869d4b6e9764341a8777d9c943ce549">
<locn:geometry rdf:datatype="https://www.iana.org/assignments/media-types/application/vnd.geo+json">{"type": "Point", "coordinates": [8.940064939, 54.547327331]}</locn:geometry>
<locn:geometry rdf:datatype="http://www.opengis.net/ont/geosparql#wktLiteral">POINT (8.9401 54.5473)</locn:geometry>
</dct:Location>
</dct:spatial>
<dcat:theme rdf:resource="http://publications.europa.eu/resource/authority/data-theme/ENVI"/>
<dcat:distribution rdf:resource="http://llur.landsh.de/pegel/114437/Wasserstand.csv"/>
<dcat:keyword>Wasserstand</dcat:keyword>
<dcat:keyword>Online-Pegel</dcat:keyword>
<dct:identifier>http://llur.landsh.de/pegel/114437/Wasserstand</dct:identifier>
<dct:title>Wasserstand Pegel Arlau-Schleuse BP - Arlau</dct:title>
<dcat:keyword>Arlau</dcat:keyword>
<dct:license rdf:resource="http://dcat-ap.de/def/licenses/dl-by-de/2.0"/>
<dcat:keyword>in Betrieb</dcat:keyword>
<dcat:keyword>Pegel</dcat:keyword>
<dct:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2022-01-17T00:00:00</dct:modified>
<dcatde:licenseAttributionByText>LLUR-SH</dcatde:licenseAttributionByText>
<dct:temporal>
<dct:PeriodOfTime rdf:nodeID="N12c1687db1e149eabe09948684d599f1">
<schema:startDate rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">1998-10-15T00:00:00</schema:startDate>
<schema:endDate rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2022-01-17T00:00:00</schema:endDate>
</dct:PeriodOfTime>
</dct:temporal>
<dcatde:contributorID rdf:resource="http://dcat-ap.de/def/contributors/schleswigHolstein"/>
<dct:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2019-11-11T00:00:00</dct:issued>
<dct:language rdf:resource="http://publications.europa.eu/resource/authority/language/DEU"/>
</dcat:Dataset>
</dcat:dataset>
<dcat:dataset>
<dcat:Dataset rdf:about="https://opendata.schleswig-holstein.de/dataset/15909dac-9544-4e28-88a5-a7c8e3f21263">
<dct:license rdf:resource="http://dcat-ap.de/def/licenses/cc-by/4.0"/>
<dcat:keyword>Historisches Adressbuch</dcat:keyword>
<dcat:distribution rdf:resource="https://opendata-stage.schleswig-holstein.de/dataset/940acb9a-e828-43bc-9de0-68dc9a16a76c/resource/97d04f9b-7272-474f-bbeb-0251d7ed7986"/>
<dct:identifier>940acb9a-e828-43bc-9de0-68dc9a16a76c</dct:identifier>
<dct:temporal>
<dct:PeriodOfTime rdf:nodeID="N1bd26fd15b254e17a253c3ec31b444a6">
<schema:startDate rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">1934-01-01T00:00:00</schema:startDate>
<schema:endDate rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">1934-12-31T00:00:00</schema:endDate>
</dct:PeriodOfTime>
</dct:temporal>
<dcat:keyword>Adressbuch</dcat:keyword>
<dct:description>Daten des *Adreßbuch der Stadt Kiel und Umgegend 1934*, erfasst von Freiwilligen mit dem Daten-Erfassungs-Sytem (DES) des Vereins für Computergenealogie.&#13;
&#13;
[Beschreibung der Quelle und des Projekts](https://wiki-de.genealogy.net/Kiel/Adressbuch_1934)&#13;
&#13;
[Online-Suche in den Daten](https://des.genealogy.net/kiel1934/search)&#13;
&#13;
Folgende Spalten sind in der Datei enthalten:&#13;
&#13;
- `page` - Bezeichnung der Seite, auf der sich der Eintrag befindet&#13;
- `lastname` - Nachname &#13;
- `firstname` - Vorname(n)&#13;
- `Beruf o. ä.` - Beruf der erfassten Person eingetragen, wie er in der Vorlage genannt ist. Eine Negativaussage (z.B. "ohne Beruf") wird ebenfalls in diesem Feld notiert. Auch Angaben wie "Rentner", "Invalide" oder ähnliches werden im Berufsfeld erfasst, da die Person aufgrund dieses Status ihr Einkommen bezieht. &#13;
- `Adresse` - Adresse, wie sie im Adressbuch eingetragen ist&#13;
- `Ortsname` - Name des Wohnplatzes&#13;
- `Ortskennung` - URI des Wohnplatzes im [Geschichtlichen Ortsverzeichnis](https://gov.genealogy.net)&#13;
- `Firmenname` - Name der Firma, sofern es sich um einen Firmeneintrag handelt&#13;
- `Familienstand` - Familienstand wie *Witwe*, *Frau*, *Fräulein*&#13;
- `Vorname Bezugsperson` - z.B. Name des verstorbenen Ehemannes im Fall einer Witwe&#13;
- `Beruf Bezugsperson` - z.B. Beruf des verstorbenen Ehemannes im Fall einer Witwe&#13;
- `Eigentümer` - Zum Teil ist im Adressbuch vermerkt, dass es sich bei der Person um den Eigentümer des Hauses handelt. Dann steht in diesem Feld der Wert `Eigentümer`&#13;
- `Verwalter` - Zum Teil ist im Adressbuch vermerkt, dass es sich bei der Person um den Verwalter des Hauses handelt. Dann steht in diesem Feld der Wert `Verwalter`&#13;
- `wohnt nicht im Haus` - Ist im Adressbuch zu erkennen, dass die genannte Person nicht in an der Adresse wohnt (sondern z.B. der Inhaber des hier befindlichen Geschäfts ist), so ist in dieser Spalte ein `ja` eingetragen.&#13;
- `Funktionsträger` - Ist in diesem Feld ein `ja` eingetragen, hat die Person an dem genannten Ort ein Amt (z.B. Gutsvorsteher) inne, wohnt aber nicht unbedingt dort.&#13;
- `id` - eindeutige Kennung des Eintrags im DES. Durch Vorstellen von `https://des.genealogy.net/search/show/` gelangt man zur Webseite des Eintrags.&#13;
</dct:description>
<dcatde:licenseAttributionByText>CompGen - Verein für Computergenealogie</dcatde:licenseAttributionByText>
<dct:publisher rdf:resource="https://opendata.schleswig-holstein.de/organization/ee4df032-ec5f-4726-b7ad-a2c708fb53ec"/>
<dct:title>Adressbuch Kiel 1934</dct:title>
<dct:spatial rdf:resource="http://dcat-ap.de/def/politicalGeocoding/districtKey/01002"/>
<dcatde:contributorID rdf:resource="http://dcat-ap.de/def/contributors/schleswigHolstein"/>
<dct:language rdf:resource="http://publications.europa.eu/resource/authority/language/DEU"/>
<dcat:keyword>Coding da Vinci 2021</dcat:keyword>
<dcat:theme rdf:resource="http://publications.europa.eu/resource/authority/data-theme/EDUC"/>
<dct:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2021-04-16T10:18:01.505418</dct:modified>
<dct:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2021-03-15T00:00:00</dct:issued>
</dcat:Dataset>
</dcat:dataset>
</dcat:Catalog>
<dcat:Distribution rdf:about="https://opendata-stage.schleswig-holstein.de/dataset/940acb9a-e828-43bc-9de0-68dc9a16a76c/resource/97d04f9b-7272-474f-bbeb-0251d7ed7986">
<dct:title>kiel1934.csv</dct:title>
<dcat:accessURL rdf:resource="https://opendatarepo.lsh.uni-kiel.de/data/compgen/kiel1934.csv"/>
<dcatde:licenseAttributionByText>CompGen - Verein für Computergenealogie</dcatde:licenseAttributionByText>
<dcat:mediaType>text/csv</dcat:mediaType>
<dct:format rdf:resource="http://publications.europa.eu/resource/authority/file-type/CSV"/>
<dct:license rdf:resource="http://dcat-ap.de/def/licenses/cc-by/4.0"/>
</dcat:Distribution>
<dcat:Distribution rdf:about="http://llur.landsh.de/pegel/114437/Wasserstand.csv">
<dct:license rdf:resource="http://dcat-ap.de/def/licenses/dl-by-de/2.0"/>
<dct:format rdf:resource="http://publications.europa.eu/resource/authority/file-type/CSV"/>
<dcatde:licenseAttributionByText>LLUR-SH</dcatde:licenseAttributionByText>
<dcat:accessURL rdf:resource="https://www.umweltdaten.landsh.de/nuis/wafis/pegel/hydro/hy_wst_download.php?sta_no_s=114437&amp;thema=W&amp;von=15.10.1998&amp;bis=17.01.2022&amp;sdatkat=null"/>
<dct:title>114437.csv</dct:title>
</dcat:Distribution>
</rdf:RDF>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment