Merge remote-tracking branch 'origin/feature/23670'

Conflicts:
	pom.xml
This commit is contained in:
Luca Frosini 2022-09-12 10:28:18 +02:00
commit abb21c3988
9 changed files with 107 additions and 9 deletions

View File

@ -1,4 +1,6 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8

View File

@ -3,6 +3,11 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v1.13.3-SNAPSHOT]
- Adding support for "FAO SDG 14.4.1 Questionnaire" source [#23670]
## [v1.13.2-SNAPSHOT]
- Migrated request to social-service-client [#23679]
@ -16,6 +21,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Tag are added also to legacy records [#23216]
- Fixed code which generated groups id from name [#23215]
## [v1.13.0]
### Added

View File

@ -11,7 +11,7 @@
<groupId>org.gcube.data-catalogue</groupId>
<artifactId>grsf-publisher-ws</artifactId>
<version>1.13.2-SNAPSHOT</version>
<version>1.13.3-SNAPSHOT</version>
<packaging>war</packaging>
<name>grsf-publisher-ws</name>
<description>Utility library to publish GRSF products on GRSF catalogue.</description>
@ -50,7 +50,7 @@
<dependency>
<groupId>org.gcube.data-catalogue</groupId>
<artifactId>grsf-common-library</artifactId>
<version>[1.0.0, 2.0.0-SNAPSHOT)</version>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>

View File

@ -51,7 +51,7 @@ import eu.trentorise.opendata.jackan.model.CkanDataset;
* @author Costantino Perciante (ISTI - CNR)
* @author Luca Frosini (ISTI - CNR)
*/
@Path("{source:firms|FIRMS|grsf|GRSF|FishSource|fishsource}/fishery/")
@Path("{source:firms|FIRMS|grsf|GRSF|FishSource|fishsource|sdg|SDG}/fishery/")
public class GrsfPublisherFisheryService {
// the context

View File

@ -51,7 +51,7 @@ import eu.trentorise.opendata.jackan.model.CkanDataset;
* @author Costantino Perciante (ISTI - CNR)
* @author Luca Frosini (ISTI - CNR)
*/
@Path("{source:firms|FIRMS|ram|RAM|grsf|GRSF|FishSource|fishsource}/stock/")
@Path("{source:firms|FIRMS|ram|RAM|grsf|GRSF|FishSource|fishsource|sdg|SDG}/stock/")
public class GrsfPublisherStockService {
// the context

View File

@ -4,7 +4,6 @@ import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@ -266,7 +265,7 @@ public class CommonServiceUtils {
if(match) {
StringBuffer stringBuffer = new StringBuffer();
if(prependSource) {
stringBuffer.append(source.toString());
stringBuffer.append(source.getURLPath());
stringBuffer.append(" ");
}
if(groupNameOverValue.isEmpty()) {
@ -289,7 +288,7 @@ public class CommonServiceUtils {
*/
private static void addRecordToGroups(Set<String> groups, Set<String> sourcesList, Product_Type productType, Sources sourceInPath) {
if(sourceInPath == Sources.GRSF) {
groups.add(getGroupId(Sources.GRSF.getOrigName())); // i.e. grsf_group
groups.add(getGroupId(Sources.GRSF.getURLPath())); // i.e. grsf_group
}else {
groups.add(getGroupId(Constants.SYSTEM_TYPE_LEGACY_RECORD)); // i.e. legacy_group
}
@ -543,7 +542,7 @@ public class CommonServiceUtils {
if(databaseSources!=null) {
for(Resource<Sources> source : databaseSources) {
Sources sourceName = source.getName();
sourcesList.add(sourceName.getOrigName().toLowerCase());
sourcesList.add(sourceName.getURLPath());
}
}
}
@ -719,6 +718,6 @@ public class CommonServiceUtils {
return Constants.GRSF_PRE_ORGANIZATION_NAME;
}
}else
return sourceInPath.getOrigName().toLowerCase();
return sourceInPath.getURLPath();
}
}

View File

@ -0,0 +1,38 @@
package org.gcube.data_catalogue.grsf_publish_ws;
import java.io.File;
import java.net.URL;
import org.gcube.data_catalogue.grsf_publish_ws.json.input.record.StockRecord;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public class TestJson {
private static final Logger logger = LoggerFactory.getLogger(Test.class);
public File getResourcesDirectory() throws Exception {
URL logbackFileURL = TestJson.class.getClassLoader().getResource("logback-test.xml");
File logbackFile = new File(logbackFileURL.toURI());
File resourcesDirectory = logbackFile.getParentFile();
return resourcesDirectory;
}
@Test
public void testJsonDeserialization() throws Exception {
File jsonQueryFile = new File(getResourcesDirectory(), "70ae6895-7d3d-4f4a-86f9-bcb17d41bff6.json");
ObjectMapper objectMapper = new ObjectMapper();
JsonNode jsonNode = objectMapper.readTree(jsonQueryFile);
logger.debug("{}", jsonNode);
StockRecord sr = objectMapper.readValue(jsonQueryFile, StockRecord.class);
logger.debug("{}", sr);
}
}

View File

@ -0,0 +1,34 @@
{
"stock_name" : "European hake - Southern Adriatic",
"license_id" : "CC-BY-SA-4.0",
"version" : 1.0,
"database_sources" : [ {
"name" : "FAO SDG 14.4.1 questionnaire",
"description" : "FAO SDG 14.4.1 questionnaire",
"url" : "https://www.fao.org/sustainable-development-goals/indicators/14.4.1/en/"
} ],
"stock_uri" : "https://github.com/grsf/resource/sdg_14_4_1/stock/70ae6895-7d3d-4f4a-86f9-bcb17d41bff6",
"grsf_uuid" : "70ae6895-7d3d-4f4a-86f9-bcb17d41bff6",
"short_name" : "European hake - Southern Adriatic",
"description" : "European hake - Southern Adriatic",
"grsf_type" : "assessment unit",
"species" : [ "Code: HKE, Classification System: ASFIS, Scientific Name: Merluccius merluccius" ],
"assessment_area" : [ "Code: 18, System: gfcm, Name: Southern Adriatic " ],
"source_of_information" : [ {
"name" : "https://www.fao.org/sustainable-development-goals/indicators/14.4.1/en/sdg-alb-1",
"description" : "",
"url" : "https://www.fao.org/sustainable-development-goals/indicators/14.4.1/en/sdg-alb-1"
} ],
"data_owner" : [ "Albania" ],
"assessment_methods" : [ "The official stock assessment concludes 'Overfished' with respect to abundance reference points. [Rep. Year or Assessment ID: 2019, Ref. Year: 2018]" ],
"connections_indicator" : "not connected",
"similarities_indicator" : "without similar records",
"landings" : [ {
"value" : "872",
"unit" : "Tonnes",
"reference_year" : 2018,
"reporting_year_or_assessment_id" : "2020",
"data_owner" : "Albania"
} ],
"citation" : "citation TBD"
}

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{0}: %msg%n</pattern>
</encoder>
</appender>
<logger name="org.gcube" level="INFO" />
<logger name="org.gcube.data_catalogue.grsf_publish_ws" level="TRACE" />
<root level="WARN">
<appender-ref ref="STDOUT" />
</root>
</configuration>