diff --git a/schemas/iso19115-3.2018/src/main/plugin/iso19115-3.2018/process/collection-updater.xsl b/schemas/iso19115-3.2018/src/main/plugin/iso19115-3.2018/process/collection-updater.xsl index 455b3dddb8b..d0a0a500ac8 100644 --- a/schemas/iso19115-3.2018/src/main/plugin/iso19115-3.2018/process/collection-updater.xsl +++ b/schemas/iso19115-3.2018/src/main/plugin/iso19115-3.2018/process/collection-updater.xsl @@ -88,7 +88,8 @@ merge="mri:defaultLocaleCode"/> + merge="." + limit="1"/> diff --git a/schemas/iso19139/src/main/plugin/iso19139/process/collection-merge-utility.xsl b/schemas/iso19139/src/main/plugin/iso19139/process/collection-merge-utility.xsl index 0ec3f34bc95..276fe528baf 100644 --- a/schemas/iso19139/src/main/plugin/iso19139/process/collection-merge-utility.xsl +++ b/schemas/iso19139/src/main/plugin/iso19139/process/collection-merge-utility.xsl @@ -30,7 +30,6 @@ extension-element-prefixes="saxon" exclude-result-prefixes="#all"> - @@ -51,6 +50,8 @@ select="$existingMembers//*[name() = $current/@name]"/> + --> - + @@ -81,7 +84,8 @@ + Groups: + --> diff --git a/schemas/iso19139/src/main/plugin/iso19139/process/collection-updater.xsl b/schemas/iso19139/src/main/plugin/iso19139/process/collection-updater.xsl index ff93b75e19d..72c0f134eb6 100644 --- a/schemas/iso19139/src/main/plugin/iso19139/process/collection-updater.xsl +++ b/schemas/iso19139/src/main/plugin/iso19139/process/collection-updater.xsl @@ -80,7 +80,8 @@ merge="gmd:LanguageCode"/> + merge="." + limit="1"/> diff --git a/services/src/test/java/org/fao/geonet/api/records/editing/ProcessApiTest.java b/services/src/test/java/org/fao/geonet/api/records/editing/ProcessApiTest.java new file mode 100644 index 00000000000..02b1a7045fe --- /dev/null +++ b/services/src/test/java/org/fao/geonet/api/records/editing/ProcessApiTest.java @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2001-2016 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: geonetwork@osgeo.org + */ +package org.fao.geonet.api.records.editing; + +import jeeves.server.context.ServiceContext; +import org.fao.geonet.kernel.mef.MEFLibIntegrationTest; +import org.fao.geonet.services.AbstractServiceIntegrationTest; +import org.junit.Before; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.mock.web.MockHttpSession; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.MvcResult; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.util.StreamUtils; +import org.springframework.web.context.WebApplicationContext; + +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Collection; + +import static org.junit.Assert.assertEquals; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + + +public class ProcessApiTest extends AbstractServiceIntegrationTest { + @Autowired + private WebApplicationContext wac; + private String seriesUuid; + + private ServiceContext context; + + public static Collection data() throws Exception { + ArrayList data = new ArrayList<>(); + data.add(new String[]{"collection-updater", "", "iso19139", "output.xml"}); + return data; + } + + @Before + public void setUp() throws Exception { + this.context = createServiceContext(); + createTestData(); + } + + private void createTestData() throws Exception { + final MEFLibIntegrationTest.ImportMetadata importMetadata = + new MEFLibIntegrationTest.ImportMetadata(this, context); + importMetadata.getMefFilesToLoad().add("/org/fao/geonet/api/records/samples/series-with-three-children.zip"); + importMetadata.invoke(); + seriesUuid = "46fccbdc-d848-47a7-a58d-2aabc21c07cf"; + } + + @Test + public void checkProcess() throws Exception { + MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build(); + MockHttpSession mockHttpSession = loginAsAdmin(); + + for (String[] testParameter : data()) { + String process = testParameter[0]; + String urlParams = testParameter[1]; + String schema = testParameter[2]; + String checkfile = testParameter[3]; + try { + String url = "/srv/api/processes/" + process + + "?uuids=" + seriesUuid + urlParams; + MvcResult result = mockMvc.perform(get(url) + .session(mockHttpSession) + .accept(MediaType.ALL_VALUE)) + .andExpect(status().isOk()) + .andReturn(); + + assertEquals( + url, + StreamUtils.copyToString( + ProcessApiTest.class.getResourceAsStream( + String.format("%s-%s-%s", + schema, process, checkfile) + ), + StandardCharsets.UTF_8) + .trim(), + result.getResponse().getContentAsString() + .replaceAll("\\r\\n?", "\n") + .trim() + ); + } catch (Exception e) { + e.printStackTrace(); + } + } + } +} diff --git a/services/src/test/resources/org/fao/geonet/api/records/editing/iso19139-collection-updater-output.xml b/services/src/test/resources/org/fao/geonet/api/records/editing/iso19139-collection-updater-output.xml new file mode 100644 index 00000000000..d70bcff8ad1 --- /dev/null +++ b/services/src/test/resources/org/fao/geonet/api/records/editing/iso19139-collection-updater-output.xml @@ -0,0 +1,648 @@ + + + + + 46fccbdc-d848-47a7-a58d-2aabc21c07cf + + + + + + + + + + + + + + European Environment Agency + + + + + + + Kongens Nytorv 6 + + + Copenhagen + + + K + + + 1050 + + + Denmark + + + sdi@eea.europa.eu + + + + + + + + + + + + 2023-10-17T06:19:09.898Z + + + ISO 19115:2003/19139 + + + 1.0 + + + + + + + Coastal Zones + + + + + 2020-11-12 + + + + + + + + + + + + + copernicus_coastal-zones_s + + + + + + + The Coastal Zones provides detailed land cover and land use information for all European coastal territory to a landward distance of 10 km with total area mapped of approximately 730,000 km². + +The product has a six years update cycle and is now available for the 2012 and 2018 reference years with the 2012-2018 change layer. + +The Coastal Zones is part of the European Union’s Copernicus Land Monitoring Service. + + + + + European Union represented by the European Commission - Directorate-General for Defence Industry and Space + + + + + + + Oudergemse laan 45 + + + Brussels + + + 1040 + + + Belgium + + + DEFIS-C3@ec.europa.eu + + + + + + + http://copernicus.eu + + + WWW:LINK-1.0-http--link + + + Website of the Copernicus Programme + + + + + + + + + + + + + + + + + European Environment Agency + + + + + + + Kongens Nytorv 6 + + + Copenhagen + + + K + + + 1050 + + + Denmark + + + copernicus@eea.europa.eu + + + + + + + https://land.copernicus.eu + + + WWW:LINK-1.0-http--link + + + Copernicus Land Portal + + + + + + + + + + + + + + + + + https://sdi.eea.europa.eu/public/catalogue-graphic-overview/205e2db2-4e35-4b1b-bf84-271c4a82248c.png + + + + + + + United Kingdom + + + EEA38 (from 2020) + + + + + + + + Continents, countries, sea regions of the world. + + + + + 2015-07-17 + + + + + + + + + + geonetwork.thesaurus.external.place.regions + + + + + + + + + + + geospatial data + + + + + + + + EEA categories + + + + + 2010-07-06 + + + + + + + + + + geonetwork.thesaurus.local.theme.eea-categories + + + + + + + + + + + Copernicus + + + Coastal Zones 2018 + + + CZ2018 + + + CLMS + + + Local component + + + Coastal Zones 2012 + + + CZ2012 + + + Coastal Zones Change 2012-2018 + + + CZ2012-2018 + + + + + + + + EEA keyword list + + + + + 2002-03-01 + + + + + + + + + + + + + + Land use + + + + + + + + EEA topics + + + + + 2020-09-24 + + + + + + + + + + geonetwork.thesaurus.external.theme.eea-topics + + + + + + + + + + + land use + + + hydrography + + + landscape alteration + + + land cover + + + coastal area + + + + + + + + GEMET + + + + + 2018-08-16 + + + + + + + + + + geonetwork.thesaurus.external.theme.gemet + + + + + + + + + + + Hydrography + + + Land use + + + Land cover + + + + + + + + GEMET - INSPIRE themes, version 1.0 + + + + + 2008-06-01 + + + + + + + + + + geonetwork.thesaurus.external.theme.httpinspireeceuropaeutheme-theme + + + + + + + + + + + European + + + + + + + + Spatial scope + + + + + 2019-05-22 + + + + + + + + + + geonetwork.thesaurus.external.theme.httpinspireeceuropaeumetadatacodelistSpatialScope-SpatialScope + + + + + + + + + + + + + 205e2db2-4e35-4b1b-bf84-271c4a82248c + + + + + + + + + + + + + + fe8d5d51-36ab-46d4-be61-dcfad7c308f1 + + + + + + + + + + + + + + c88e743d-e838-49e1-8c80-54f26bcf4ab8 + + + + + + + + + + + + + + + + + 10000 + + + + + + + + + + + + + environment + + + imageryBaseMapsEarthCover + + + + + + + -52.00 + + + 42.00 + + + 27.00 + + + 71.00 + + + + + + + + 2010-01-01 + 2014-12-31 + + + + + + + + + 2010-01-01 + 2019-12-31 + + + + + + + + + 2017-01-01 + 2019-12-31 + + + + + + + + + + + + + + + + + Minimum Mapping Unit + + + + + + ha + + + + + + + + + + + + + Minimum Mapping Width + + + + + + + m + + + + + + + + + + + + + diff --git a/services/src/test/resources/org/fao/geonet/api/records/samples/series-with-three-children.zip b/services/src/test/resources/org/fao/geonet/api/records/samples/series-with-three-children.zip new file mode 100644 index 00000000000..41d2c711459 Binary files /dev/null and b/services/src/test/resources/org/fao/geonet/api/records/samples/series-with-three-children.zip differ