Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge upstream 4.2.8 into georchestra #10

Merged
merged 34 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d6146ee
New 4.2.3-SNAPSHOT version
juanluisrp Mar 7, 2023
a6753eb
OGC API Records / Update for new schema layout
fxprunayre Jan 27, 2023
5f04abe
OGC API Records / Update for new schema layout / test
fxprunayre Jan 30, 2023
e0275b8
OGC API Records / Update for new schema layout / Update test resources
fxprunayre Jan 30, 2023
46e054e
Release of v4.2.3-0 (#70)
juanluisrp Mar 7, 2023
53a7211
Update version for next 4.2.4-SNAPSHOT version
juanluisrp Mar 7, 2023
6ebd652
DCAT / DataService / Fix endpointUrl mapping.
fxprunayre Mar 29, 2023
9b28ca3
Build / Fix issue with JDK16+
fxprunayre Mar 28, 2023
c4992ff
Fix geojson item output and code improvements
josegar74 Apr 27, 2023
be4c7da
OGC API Records code improvements
josegar74 Apr 27, 2023
62db1dd
Release of v4.2.4-0.
fxprunayre May 10, 2023
eb5f59c
Update version for next 4.2.5-SNAPSHOT version.
fxprunayre May 10, 2023
b8a261c
OGC API Records / DCAT / Fix validation for endpointUrl
fxprunayre May 11, 2023
ec62042
OGC API Records / Collection / Item view may return error
fxprunayre May 11, 2023
7c790cf
Release of v4.2.5-0.
fxprunayre Jul 7, 2023
7242999
Update version to 4.2.6-SNAPSHOT
juanluisrp Jul 28, 2023
1142f30
Add OSGeo SNAPSHOT repository
juanluisrp Jul 28, 2023
a27a5d6
feat: add config to specify custom urls in ogc-api-records
f-necas Aug 3, 2023
c7dae5a
Release of v4.2.5-1
fxprunayre Aug 29, 2023
6c6ac42
Index model / Add new nilReason property
fxprunayre Aug 30, 2023
3d8fe91
fix: indentation
f-necas Aug 31, 2023
8d9e4bc
fix: adds docs
f-necas Aug 31, 2023
9fd683e
Merge pull request #91 from f-necas/feature/custom-link-url-rss
jahow Aug 31, 2023
5aa7f94
fix: fixing test and Checkstyle
f-necas Sep 19, 2023
f477508
Merge pull request #95 from f-necas/feature/custom-link-url-rss
jahow Sep 20, 2023
330017b
Fix markdown linter warnings
juanluisrp Oct 27, 2023
4461eb2
Release of 4.2.6-0 version
juanluisrp Oct 27, 2023
358f508
Align with GN 4.2.7
juanluisrp Nov 30, 2023
8a2d890
Create dependabot.yml
juanluisrp Nov 30, 2023
4829c1b
Bump actions/setup-java from 3 to 4
dependabot[bot] Nov 30, 2023
dc22334
Bump actions/checkout from 2 to 4
dependabot[bot] Nov 30, 2023
5bb8909
Bump docker/login-action from 2 to 3
dependabot[bot] Nov 30, 2023
4dff66a
Release of 4.2.8-0 version
josegar74 Jan 23, 2024
89240a0
Align geor-main on 4.2.8
f-necas Feb 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# docker-compose default environment variable values
COMPOSE_PROJECT_NAME=gncloud
TAG=0.3-SNAPSHOT
TAG=4.2.8-0
EUREKA_SERVER_URL=http://discovery:8761/eureka

# gn metadta postgres environment variables
Expand Down
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:

- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: "Checking out"
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: "Setting up Java"
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution : 'temurin'
java-version : '11'
Expand Down
2 changes: 1 addition & 1 deletion modules/library/common-error/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>gn-cloud-lib</artifactId>
<groupId>org.geonetwork-opensource.cloud</groupId>
<version>4.2.2</version>
<version>4.2.8-0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
7 changes: 6 additions & 1 deletion modules/library/common-index-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>gn-cloud-lib</artifactId>
<groupId>org.geonetwork-opensource.cloud</groupId>
<version>4.2.2</version>
<version>4.2.8-0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -32,6 +32,11 @@
<groupId>org.locationtech.jts.io</groupId>
<artifactId>jts-io-common</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,16 +336,17 @@ private Dataset getDataset(IndexRecord record, String uri, String resourceIdenti

record.getLinks().stream().forEach(link -> {
DcatDistributionBuilder dcatDistributionBuilder = DcatDistribution.builder()
.title(listOfNullable(link.getName()))
.description(listOfNullable(link.getDescription()))
.title(listOfNullable(link.getName().get(CommonField.defaultText)))
.description(listOfNullable(link.getDescription().get(CommonField.defaultText)))
// TODO <dcat:accessService rdf:parseType="Resource">...
// TODO: representation technique = gmd:MD_SpatialRepresentationTypeCode?
.representationTechnique(Subject.builder()
.skosConcept(SkosConcept.builder()
.prefLabel(link.getProtocol()).build()).build());

// TODO: depending on function/protocol build page/accessUrl/downloadUrl
dcatDistributionBuilder.accessUrl(new RdfResource(null, link.getUrl()));
dcatDistributionBuilder.accessUrl(new RdfResource(null,
link.getUrl().get(CommonField.defaultText)));

datasetBuilder.distribution(listOfNullable(DcatDistributionContainer.builder()
.distribution(dcatDistributionBuilder.build()).build()));
Expand All @@ -355,7 +356,7 @@ private Dataset getDataset(IndexRecord record, String uri, String resourceIdenti
record.getContactForResource().stream().map(contact ->
DcatContactPoint.builder()
.contact(VcardContact.builder()
.title(contact.getOrganisation())
.title(contact.getOrganisation().get(CommonField.defaultText))
.role(contact.getRole())
.hasEmail(contact.getEmail()).build()).build()
).collect(Collectors.toList()));
Expand Down Expand Up @@ -488,7 +489,8 @@ private DataService getDataService(IndexRecord record, String uri, String resour
}).collect(Collectors.toList()));

dataServiceBuilder.endpointUrl(
record.getLinks().stream().map(l -> l.getUrl())
record.getLinks().stream().map(l ->
new RdfResource(null, l.getUrl().get(defaultText)))
.collect(Collectors.toList()));

dataServiceBuilder.servesDataset(
Expand All @@ -503,7 +505,7 @@ private DataService getDataService(IndexRecord record, String uri, String resour
record.getContactForResource().stream().map(contact ->
DcatContactPoint.builder()
.contact(VcardContact.builder()
.title(contact.getOrganisation())
.title(contact.getOrganisation().get(CommonField.defaultText))
.role(contact.getRole())
.hasEmail(contact.getEmail()).build()).build()
).collect(Collectors.toList()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.fao.geonet.index.model.geojson.Record.RecordBuilder;
import org.fao.geonet.index.model.gn.Contact;
import org.fao.geonet.index.model.gn.IndexRecord;
import org.fao.geonet.index.model.gn.IndexRecordFieldNames.CommonField;
import org.fao.geonet.index.model.gn.ResourceDate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -61,9 +62,9 @@ public Record convert(IndexRecord record) {
record.getLinks().stream().forEach(link -> {

LinkBuilder linkBuilder = Link.builder()
.href(link.getUrl())
.href(link.getUrl().get(CommonField.defaultText))
.rel("item")
.title(link.getName())
.title(link.getName().get(CommonField.defaultText))
.type(link.getProtocol());

recordLinks.add(linkBuilder.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public static ObjectNode convert(IndexRecord record) {
ObjectNode distribution =
createThing(null, Types.DataDownload, root);
// Actual bytes of the media object, for example the image file or video file.
distribution.put("contentUrl", l.getUrl());
distribution.put("contentUrl", l.getUrl().get(CommonField.defaultText));
addOptional(distribution, "name", l.getName());
addOptional(distribution, "abstract", l.getDescription());
addOptional(distribution, "encodingFormat", l.getProtocol());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@

package org.fao.geonet.index.model.gn;

import static org.fao.geonet.index.model.gn.IndexRecordFieldNames.organisationName;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.HashMap;
import java.util.Map;
import lombok.Data;

@Data
Expand All @@ -14,7 +19,9 @@ public class Contact {

private String role;
private String individual;
private String organisation;

@JsonProperty(organisationName)
private Map<String, String> organisation = new HashMap<>();
private String email;
private String logo;
private String phone;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class IndexRecordFieldNames {
public static final String resourceDate = "resourceDate";
public static final String org = "Org";
public static final String orgForResource = "OrgForResource";
public static final String organisationName = "organisationObject";
public static final String recordLink = "recordLink";
public static final String link = "link";
public static final String coordinateSystem = "coordinateSystem";
Expand Down Expand Up @@ -61,4 +62,10 @@ public class CommonField {
public static final String key = "key";
public static final String link = "link";
}

public class LinkField {
public static final String url = "urlObject";
public static final String name = "nameObject";
public static final String description = "descriptionObject";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,27 @@

package org.fao.geonet.index.model.gn;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.HashMap;
import java.util.Map;
import lombok.Data;
import org.fao.geonet.index.model.gn.IndexRecordFieldNames.LinkField;

@Data
public class Link {

private String protocol;
private String url;
// TODO: Multilingual
private String name;
private String description;
@JsonProperty(IndexRecordFieldNames.LinkField.url)
private Map<String, String> url = new HashMap<>();

@JsonProperty(IndexRecordFieldNames.LinkField.name)
private Map<String, String> name = new HashMap<>();

@JsonProperty(LinkField.description)
private Map<String, String> description = new HashMap<>();
private String function;
private String applicationProfile;
private String group;
private String mimeType;
private String nilReason;
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,55 @@
package org.fao.geonet.index.model.gn;

import static org.fao.geonet.index.model.gn.IndexRecordFieldNames.CommonField.defaultText;
import static org.mockito.BDDMockito.given;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.io.IOException;
import java.io.StringWriter;
import java.nio.file.Files;
import java.util.List;
import com.fasterxml.jackson.databind.node.ObjectNode;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.PropertyException;
import org.fao.geonet.domain.MetadataType;
import org.fao.geonet.index.JsonUtils;
import org.fao.geonet.index.converter.DcatConverter;
import org.fao.geonet.index.converter.FormatterConfiguration;
import org.fao.geonet.index.converter.SchemaOrgConverter;
import org.fao.geonet.index.model.dcat2.CatalogRecord;
import org.fao.geonet.index.model.dcat2.DataService;
import org.fao.geonet.index.model.dcat2.Dataset;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.runner.RunWith;
import org.locationtech.jts.geom.Coordinate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.test.context.junit4.SpringRunner;

import static org.fao.geonet.index.model.gn.IndexRecordFieldNames.CommonField.defaultText;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = {DcatConverter.class})
public class IndexRecordTest {

@MockBean
FormatterConfiguration configuration;


@Autowired
DcatConverter dcatConverter;

@BeforeEach
public void setUp() {
given(this.configuration.buildLandingPageLink("")).willReturn("");
}

@Test
public void testJsonToPojo() throws IOException {
ObjectMapper objectMapper = JsonUtils.getObjectMapper();
Expand All @@ -33,14 +64,16 @@ public void testJsonToPojo() throws IOException {
Assert.assertEquals(
"High Resolution Layer: Water and Wetness 2015 (raster 100m), Mar. 2018",
record.resourceTitle.get(defaultText)
);
);

Assert.assertEquals(49, record.getOtherProperties().size());

Assert.assertEquals("gmd:MD_Metadata", record.getRoot());

Overview o = record.getOverview().get(0);
Assert.assertEquals("https://sdi.eea.europa.eu/public/catalogue-graphic-overview/8108e203-59db-4672-b9e0-c1863fd6523b.png", o.getUrl());
Assert.assertEquals(
"https://sdi.eea.europa.eu/public/catalogue-graphic-overview/8108e203-59db-4672-b9e0-c1863fd6523b.png",
o.getUrl());
Assert.assertEquals("Global overview", o.getLabel().get("default"));

String org = record.getOrg().get(0);
Expand All @@ -56,20 +89,61 @@ public void testJsonToPojo() throws IOException {

List<Link> links = record.getLinks();
Assert.assertEquals(1, links.size());
Assert.assertEquals("https://land.copernicus.eu/pan-european/high-resolution-layers/water-wetness/status-maps/2015/view", links.get(0).getUrl());
Assert.assertEquals(
"https://land.copernicus.eu/pan-european/high-resolution-layers/water-wetness/status-maps/2015/view",
links.get(0).getUrl().get("default"));

List<Coordinate> locations = record.getLocations();
Assert.assertEquals(47.10185, locations.get(0).getX(), .0001);
Assert.assertEquals(-22.3441, locations.get(0).getY(), .0001);

Assert.assertEquals("{\"type\":\"Polygon\",\"coordinates\":[[[-31.2684,27.6375],[-13.4198,27.6375],[-13.4198,66.5662],[-31.2684,66.5662],[-31.2684,27.6375]]]}",
Assert.assertEquals(
"{\"type\":\"Polygon\",\"coordinates\":[[[-31.2684,27.6375],[-13.4198,27.6375],[-13.4198,66.5662],[-31.2684,66.5662],[-31.2684,27.6375]]]}",
record.getGeometries().get(0));
} catch (JsonProcessingException e) {
e.printStackTrace();
Assert.fail();
}
}

@Test
public void testServiceJsonToDcatXML() throws IOException {
ObjectMapper objectMapper = JsonUtils.getObjectMapper();
String json = Files.readString(
new ClassPathResource("index-document-service.json").getFile().toPath());
JsonNode jsonNode = objectMapper.readTree(json);

try {
IndexRecord record = objectMapper.readValue(
jsonNode.get(IndexRecordFieldNames.source).toPrettyString(),
IndexRecord.class);
Assert.assertEquals(
"Zones de distribution en eau (ZDE) - Service de visualisation REST",
record.resourceTitle.get(defaultText)
);

JAXBContext context = null;
context = JAXBContext.newInstance(
CatalogRecord.class, Dataset.class, DataService.class);
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);

CatalogRecord catalogRecord = dcatConverter.convert(jsonNode);
StringWriter sw = new StringWriter();
marshaller.marshal(catalogRecord, sw);

} catch (JsonProcessingException e) {
e.printStackTrace();
Assert.fail();
} catch (PropertyException e) {
e.printStackTrace();
Assert.fail();
} catch (JAXBException e) {
e.printStackTrace();
Assert.fail();
}
}


@Test
Expand Down
Loading
Loading