Skip to content

Commit

Permalink
Harvester / Simple URL / ODS improvement
Browse files Browse the repository at this point in the history
* Ignore "null" value
* Add support for "metas/dcat"
* Fix path for language when using v2 API
* Add spatial and temporal extent when available
* Add extra keywords based one "metas/dcat/temporal" and "metas/default/territory"
* Add resource identifier
* Add record count and geometry type
* Add lineage and credit
* Add references
* Cleanup namespaces

Follow up of #7201
Related to #8359
  • Loading branch information
fxprunayre committed Oct 11, 2024
1 parent c7f8e8b commit 87a8e3d
Show file tree
Hide file tree
Showing 9 changed files with 2,155 additions and 553 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
/*
* Copyright (C) 2001-2024 Food and Agriculture Organization of the
* United Nations (FAO-UN), United Nations World Food Programme (WFP)
* and United Nations Environment Programme (UNEP)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2,
* Rome - Italy. email: [email protected]
*/
package org.fao.geonet.schema.iso19115_3_2018;

import org.jdom.Namespace;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2001-2023 Food and Agriculture Organization of the
* Copyright (C) 2001-2024 Food and Agriculture Organization of the
* United Nations (FAO-UN), United Nations World Food Programme (WFP)
* and United Nations Environment Programme (UNEP)
*
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<health>
<theme>Santé</theme>
<theme>Health</theme>
<theme>Qualité de Vie</theme>
</health>
<environment>
<theme>Environnement</theme>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
/*
* Copyright (C) 2001-2024 Food and Agriculture Organization of the
* United Nations (FAO-UN), United Nations World Food Programme (WFP)
* and United Nations Environment Programme (UNEP)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2,
* Rome - Italy. email: [email protected]
*/
package org.fao.geonet.schema;

import org.fao.geonet.schema.iso19115_3_2018.ISO19115_3_2018SchemaPlugin;
Expand All @@ -14,9 +36,6 @@
import static org.junit.Assert.assertThat;
import static org.xmlunit.matchers.EvaluateXPathMatcher.hasXPath;

/**
* Created by francois on 3/24/14.
*/
public class LanguageXslProcessTest extends XslProcessTest {

public LanguageXslProcessTest() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright (C) 2001-2024 Food and Agriculture Organization of the
* United Nations (FAO-UN), United Nations World Food Programme (WFP)
* and United Nations Environment Programme (UNEP)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2,
* Rome - Italy. email: [email protected]
*/
package org.fao.geonet.schema;

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.fao.geonet.schema.iso19115_3_2018.ISO19115_3_2018SchemaPlugin;
import org.fao.geonet.schemas.XslProcessTest;
import org.fao.geonet.utils.Xml;
import org.jdom.Element;
import static org.junit.Assert.assertFalse;
import org.junit.Test;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.builder.Input;
import org.xmlunit.diff.DefaultNodeMatcher;
import org.xmlunit.diff.Diff;
import org.xmlunit.diff.ElementSelectors;

public class XslConversionTest extends XslProcessTest {

public XslConversionTest() {
super();
this.setNs(ISO19115_3_2018SchemaPlugin.allNamespaces);
}

@Test
public void testOdsConversion() throws Exception {
xslFile = Paths.get(testClass.getClassLoader().getResource("convert/fromJsonOpenDataSoft.xsl").toURI());
xmlFile = Paths.get(testClass.getClassLoader().getResource("ods.xml").toURI());
Path jsonFile = Paths.get(testClass.getClassLoader().getResource("ods.json").toURI());
String jsonString = Files.readString(jsonFile);
Element xmlFromJSON = Xml.getXmlFromJSON(jsonString);
xmlFromJSON.setName("record");
xmlFromJSON.addContent(new Element("nodeUrl").setText("https://www.odwb.be"));

Element inputElement = Xml.loadFile(xmlFile);
String expectedXml = Xml.getString(inputElement);

Element resultElement = Xml.transform(xmlFromJSON, xslFile);
String resultOfConversion = Xml.getString(resultElement);

Diff diff = DiffBuilder
.compare(Input.fromString(resultOfConversion))
.withTest(Input.fromString(expectedXml))
.withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byName))
.normalizeWhitespace()
.ignoreComments()
.checkForSimilar()
.build();
assertFalse(
String.format("Differences: %s", diff.toString()),
diff.hasDifferences());
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
/*
* Copyright (C) 2001-2024 Food and Agriculture Organization of the
* United Nations (FAO-UN), United Nations World Food Programme (WFP)
* and United Nations Environment Programme (UNEP)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2,
* Rome - Italy. email: [email protected]
*/
package org.fao.geonet.util;

public class XslUtil {
public static String twoCharLangCode(String iso3code) {
return iso3code.substring(0, 2);
}
public static String threeCharLangCode(String iso2code) {
return "fre";
}
}
Loading

0 comments on commit 87a8e3d

Please sign in to comment.