Adding support for "FAO SDG 14.4.1 Questionnaire" source

This commit is contained in:
Luca Frosini 2022-08-31 11:22:28 +02:00
parent 91c0103dc5
commit 9eb98dea3f
3 changed files with 35 additions and 23 deletions

View File

@ -3,6 +3,10 @@
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.3.3-SNAPSHOT]
- Adding support for "FAO SDG 14.4.1 Questionnaire" source [#23670]
## [v1.3.2]
- Updated Labels [#23167]

View File

@ -14,7 +14,7 @@
<groupId>org.gcube.data-catalogue</groupId>
<artifactId>grsf-common-library</artifactId>
<packaging>jar</packaging>
<version>1.3.2</version>
<version>1.3.3-SNAPSHOT</version>
<description>Common library for GRSF service and management panel</description>
<properties>

View File

@ -1,7 +1,6 @@
package org.gcube.datacatalogue.common.enums;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonCreator;
@ -13,60 +12,69 @@ import com.fasterxml.jackson.annotation.JsonValue;
*/
public enum Sources {
FIRMS("FIRMS"),
RAM("RAM"),
FISHSOURCE("FishSource"),
GRSF("GRSF");
FIRMS("FIRMS","firms"),
RAM("RAM","ram"),
FISHSOURCE("FishSource", "fishsource"),
GRSF("GRSF", "grsf"),
SDG("FAO SDG 14.4.1 Questionnaire","sdg14.4.1");
private String subGroupNameOrig;
private String sourceName;
private String urlPath;
private Sources(String origName) {
this.subGroupNameOrig = origName;
private Sources(String sourceName, String urlPath) {
this.sourceName = sourceName;
this.urlPath = urlPath;
}
/**
* Return the original name
* @return
*/
public String getOrigName(){
return subGroupNameOrig;
public String getSourceName(){
return sourceName;
}
@JsonValue
public String onSerialize(){
return subGroupNameOrig.toLowerCase();
return urlPath;
}
@JsonCreator
public static Sources onDeserialize(String sourceString) {
if(sourceString != null) {
for(Sources source : Sources.values()) {
if (source.toString().equalsIgnoreCase(sourceString.trim()))
if (source.urlPath.equalsIgnoreCase(sourceString.trim()))
return source;
}
}
return null;
}
public String getURLPath() {
return urlPath;
}
@Override
public String toString() {
return getOrigName();
return urlPath;
}
public static String getAsList(){
return "[" + Arrays.asList(
FIRMS.toString().toLowerCase(),
RAM.toString().toLowerCase(),
FISHSOURCE.toString().toLowerCase(),
GRSF.toString().toLowerCase()) + "]";
public static String getJsonArrayAsString(){
return "[" + FIRMS.urlPath + "," +
RAM.urlPath + "," +
FISHSOURCE.urlPath + "," +
GRSF.urlPath + "," +
SDG.urlPath + "," + "]";
}
public static List<String> getListNames(){
public static List<String> listNames(){
List<String> valuesString = new ArrayList<String>(Sources.values().length);
for(Sources source : Sources.values())
valuesString.add(source.getOrigName());
for(Sources source : Sources.values()) {
valuesString.add(source.getSourceName());
}
return valuesString;
}
}