Compare commits

...

28 Commits

Author SHA1 Message Date
luca.frosini ce3c4af8eb Ignored MacOs File 2023-06-21 11:39:41 +02:00
Luca Frosini 8427224976 Removed -SNAPSHOT to release the component 2022-10-26 16:04:49 +02:00
Luca Frosini 8eb0e30897 Fixing JDK 11 compiling issue 2022-10-26 11:27:01 +02:00
Luca Frosini 54b20686aa added dependency scope 2022-10-26 11:02:52 +02:00
Luca Frosini 10b4c7dbf6 Fixing pom to compile di JDK 11 2022-10-26 10:32:13 +02:00
Luca Frosini d1ff03affc Merge branch 'master' of gitea@code-repo.d4science.org:gCubeSystem/grsf-publisher-ws.git 2022-10-26 10:22:45 +02:00
Luca Frosini f985363878 Merge remote-tracking branch 'origin/feature/23670' 2022-10-26 10:22:30 +02:00
Luca Frosini abb21c3988 Merge remote-tracking branch 'origin/feature/23670'
Conflicts:
	pom.xml
2022-09-12 10:28:18 +02:00
Luca Frosini 9e3bdeff3b Fixed bug on retriving email and fullname 2022-09-12 10:25:46 +02:00
Luca Frosini 84781a9a8d Fixed bug on retriving email and fullname 2022-09-12 10:24:30 +02:00
Luca Frosini 9f8e8a5f5e Changed sdg path 2022-09-09 16:24:05 +02:00
Luca Frosini 98eda28a8e Fixed project 2022-09-09 16:22:53 +02:00
Luca Frosini f00306cbb6 Fixed changelog 2022-09-02 14:53:48 +02:00
Luca Frosini 0fd88f657c Fixed changelog 2022-09-02 14:53:07 +02:00
Luca Frosini 9f182ededd fixed changelog 2022-09-02 14:52:52 +02:00
Luca Frosini dd8874178d Fixed changelog 2022-09-02 14:49:21 +02:00
Luca Frosini 40ea1235d9 Added "Assessment Methods" as group 2022-09-02 14:48:48 +02:00
Luca Frosini ca752576bc Added support for "Assessment Method" group 2022-09-02 14:44:37 +02:00
Luca Frosini 587c0971ad Improved test 2022-09-02 12:47:01 +02:00
Luca Frosini 3f29a00f05 Added test for json deserialization 2022-09-02 12:42:03 +02:00
Luca Frosini 13e9f7309e Fixed range 2022-08-31 12:09:47 +02:00
Luca Frosini 490619efe7 Upgraded grsf-common-library range 2022-08-31 12:09:03 +02:00
Luca Frosini 044d2edd05 Upgraded the version 2022-08-31 12:03:39 +02:00
Luca Frosini d6d373a94c Added change in changelog 2022-08-31 11:22:19 +02:00
Luca Frosini c28f0dcd65 Adding support for "FAO SDG 14.4.1 Questionnaire" source 2022-08-31 11:20:24 +02:00
Luca Frosini dbad160e36 Fixed test 2022-08-01 14:40:10 +02:00
Luca Frosini 6d37e4b939 Migrated request to social-service-client refs #23679 2022-08-01 14:39:25 +02:00
Luca Frosini 75b55cc8bb Hidden sensitive field from GRSF VRE 2022-05-23 15:17:50 +02:00
14 changed files with 149 additions and 34 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
target
.classpath
.project
/.DS_Store

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,17 @@
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]
- Adding support for "FAO SDG 14.4.1 Questionnaire" source [#23670]
## [v1.13.2]
- Migrated request to social-service-client [#23679]
- Added "Assessment Methods" as Group [#23409]
## [v1.13.1]
- Aligned code and wiki to the new requirements [#23167]
@ -10,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

20
pom.xml
View File

@ -11,7 +11,7 @@
<groupId>org.gcube.data-catalogue</groupId>
<artifactId>grsf-publisher-ws</artifactId>
<version>1.13.1</version>
<version>1.13.3</version>
<packaging>war</packaging>
<name>grsf-publisher-ws</name>
<description>Utility library to publish GRSF products on GRSF catalogue.</description>
@ -26,6 +26,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jsoup.version>1.10.1</jsoup.version>
<serviceClass>DataPublishing</serviceClass>
<maven.compiler.release>8</maven.compiler.release>
</properties>
<scm>
@ -39,7 +40,7 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>gcube-smartgears-bom</artifactId>
<version>2.1.1</version>
<version>2.2.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@ -50,12 +51,17 @@
<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, 3.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>storagehub-client-library</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.social-networking</groupId>
<artifactId>social-service-client</artifactId>
<version>[1.0.0, 2.0.0-SNAPSHOT)</version>
</dependency>
<!-- jsoup HTML parser library @ http://jsoup.org/ -->
<dependency>
<groupId>org.jsoup</groupId>
@ -162,6 +168,14 @@
<artifactId>jersey-test-framework-provider-jetty</artifactId>
<scope>test</scope>
</dependency>
<!-- Added to support Java 11 JDK -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<!-- END Added to support Java 11 JDK -->
</dependencies>
<build>

View File

@ -46,6 +46,7 @@ public class StockRecord extends Common{
@JsonProperty(Constants.ASSESSMENT_METHODS_JSON_KEY)
@CustomField(key=Constants.ASSESSMENT_METHODS_CUSTOM_KEY)
@Group(groupNameOverValue=Constants.ASSESSMENT_METHODS_CUSTOM_KEY, prependSourceToGroupName=false)
private List<String> assessmentMethods;
@JsonProperty(Constants.FIRMS_ABUNDANCE_LEVEL_JSON_KEY)

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

@ -31,6 +31,7 @@ import org.gcube.datacatalogue.common.caches.CacheInterface;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.Query;
import org.gcube.resources.discovery.client.queries.impl.QueryBox;
import org.gcube.social_networking.social_networking_client_library.UserClient;
import org.jsoup.Jsoup;
import org.jsoup.safety.Whitelist;
import org.slf4j.LoggerFactory;
@ -134,21 +135,18 @@ public abstract class HelperMethods {
* @return
* @throws Exception
*/
public static String getUserEmail(String context, String token){
public static String getUserEmail(String context, String token) throws Exception{
// check in cache
String result = null;
if((result = (String) userEmailCache.get(token)) != null){
return result;
String email = null;
if((email = (String) userEmailCache.get(token)) != null){
return email;
}else{
String baseUrl = new GcoreEndPointReaderSocial(context).getBasePath();
String url = baseUrl.endsWith("/") ? baseUrl + "users/getUserEmail?gcube-token=" + token :
baseUrl + "/users/getUserEmail?gcube-token=" + token;
logger.debug("Request url is " + url);
result = executGETHttpRequest(url, 200);
userEmailCache.insert(token, result);
UserClient userClient = new UserClient();
email = userClient.getEmail();
userEmailCache.insert(token, email);
}
return result;
return email;
}
/**
@ -158,21 +156,18 @@ public abstract class HelperMethods {
* @return
* @throws Exception
*/
public static String getUserFullname(String context, String token){
public static String getUserFullname(String context, String token) throws Exception{
// check in cache
String result = null;
if((result = (String) userFullnameCache.get(token)) != null){
return result;
String fullName = null;
if((fullName = (String) userFullnameCache.get(token)) != null){
return fullName;
}else{
String baseUrl = new GcoreEndPointReaderSocial(context).getBasePath();
String url = baseUrl.endsWith("/") ? baseUrl + "users/getUserFullname?gcube-token=" + token :
baseUrl + "/users/getUserFullname?gcube-token=" + token;
logger.debug("Request url is " + url);
result = executGETHttpRequest(url, 200);
userFullnameCache.insert(token, result);
UserClient userClient = new UserClient();
fullName = userClient.getFullName();
userFullnameCache.insert(token, fullName);
}
return result;
return fullName;
}
/**

View File

@ -70,7 +70,7 @@
</field>
<field>
<originalKey>Assessment Method</originalKey>
<modifiedKey>stock_data:Assessment Method</modifiedKey>
<modifiedKey>none:none</modifiedKey>
</field>
<field>
<originalKey>Abundance Level (FIRMS Standard)</originalKey>

View File

@ -270,7 +270,7 @@ public class JTests {
}
//@Test
public void testCaches(){
public void testCaches() throws Exception{
String context = "/gcube/devNext/NextNext";
String token = "";

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>