added json serializers and deserializers
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@132952 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
34aabbcf27
commit
11ab8b15eb
|
@ -2,6 +2,9 @@ package org.gcube.data_catalogue.grsf_publish_ws.utils.groups;
|
|||
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.HelperMethods;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* Abundance_Level for Stock records
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
|
@ -10,7 +13,7 @@ public enum Abundance_Level {
|
|||
|
||||
Intermediate_Abundance("Intermediate abundance"),
|
||||
Low_Abundance("Low abundance"),
|
||||
Uncertain_Not_Assesed("Uncertain/Not assesed");
|
||||
Uncertain_Not_Assessed("Uncertain/Not assessed");
|
||||
|
||||
private String subGroupNameOrig;
|
||||
private String subGroupNameOnCkan;
|
||||
|
@ -35,4 +38,21 @@ public enum Abundance_Level {
|
|||
public String getOrigName(){
|
||||
return subGroupNameOrig;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String onSerialize(){
|
||||
return subGroupNameOrig.replaceAll("[^A-Za-z]", " ").toLowerCase();
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static Abundance_Level onDeserialize(String abundanceString) {
|
||||
if(abundanceString != null) {
|
||||
for (Abundance_Level abundanceValue : Abundance_Level.values()) {
|
||||
if(abundanceValue.getOrigName().replaceAll("[^A-Za-z]", " ").equalsIgnoreCase(abundanceString))
|
||||
return abundanceValue;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,9 @@ package org.gcube.data_catalogue.grsf_publish_ws.utils.groups;
|
|||
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.HelperMethods;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* Exploitation_Rate for Stock records
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
|
@ -35,4 +38,20 @@ public enum Exploitation_Rate {
|
|||
public String getOrigName(){
|
||||
return subGroupNameOrig;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String onSerialize(){
|
||||
return subGroupNameOrig.toLowerCase();
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static Exploitation_Rate onDeserialize(String exploitationString) {
|
||||
if(exploitationString != null) {
|
||||
for (Exploitation_Rate exploitationValue : Exploitation_Rate.values()) {
|
||||
if(exploitationValue.getOrigName().equalsIgnoreCase(exploitationString))
|
||||
return exploitationValue;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,9 @@ package org.gcube.data_catalogue.grsf_publish_ws.utils.groups;
|
|||
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.HelperMethods;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* Production_System_Type for Fishery records
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
|
@ -40,5 +43,21 @@ public enum Production_System_Type {
|
|||
public String getOrigName(){
|
||||
return subGroupNameOrig;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String onSerialize(){
|
||||
return subGroupNameOrig.replaceAll("[^A-Za-z]", " ").toLowerCase();
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static Production_System_Type onDeserialize(String productionString) {
|
||||
if(productionString != null) {
|
||||
for (Production_System_Type productionValue : Production_System_Type.values()) {
|
||||
if(productionValue.getOrigName().replaceAll("[^A-Za-z]", " ").equalsIgnoreCase(productionString))
|
||||
return productionValue;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,9 @@ package org.gcube.data_catalogue.grsf_publish_ws.utils.groups;
|
|||
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.HelperMethods;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* Source Group and sub groups (for both Stock and Fishery) -> look at "Database Sources"
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
|
@ -10,16 +13,16 @@ public enum Source {
|
|||
|
||||
FIRMS("FIRMS"),
|
||||
RAM("RAM"),
|
||||
FishSource("FishSource");
|
||||
|
||||
FISHSOURCE("FishSource");
|
||||
|
||||
private String subGroupNameOrig;
|
||||
private String subGroupNameOnCkan;
|
||||
|
||||
|
||||
private Source(String origName) {
|
||||
this.subGroupNameOrig = origName;
|
||||
this.subGroupNameOnCkan = HelperMethods.getGroupNameOnCkan(origName);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the name the group has on ckan
|
||||
* @return
|
||||
|
@ -27,7 +30,7 @@ public enum Source {
|
|||
public String getNameCkan(){
|
||||
return subGroupNameOnCkan;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the original name
|
||||
* @return
|
||||
|
@ -35,4 +38,20 @@ public enum Source {
|
|||
public String getOrigName(){
|
||||
return subGroupNameOrig;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String onSerialize(){
|
||||
return subGroupNameOrig.toLowerCase();
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static Source onDeserialize(String sourceString) {
|
||||
if(sourceString != null) {
|
||||
for(Source source : Source.values()) {
|
||||
if (source.toString().equalsIgnoreCase(sourceString.trim()))
|
||||
return source;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,9 @@ package org.gcube.data_catalogue.grsf_publish_ws.utils.groups;
|
|||
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.HelperMethods;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* Status Group and sub groups (for both Stock and Fishery)
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
|
@ -34,5 +37,21 @@ public enum Status {
|
|||
public String getOrigName(){
|
||||
return subGroupNameOrig;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String onSerialize(){
|
||||
return subGroupNameOrig.toLowerCase();
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static Status onDeserialize(String statusString) {
|
||||
if(statusString != null) {
|
||||
for(Status status : Status.values()) {
|
||||
if (status.toString().equalsIgnoreCase(statusString.trim()))
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,9 @@ package org.gcube.data_catalogue.grsf_publish_ws.utils.groups;
|
|||
|
||||
import org.gcube.data_catalogue.grsf_publish_ws.utils.HelperMethods;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
|
||||
/**
|
||||
* Type for Stock/Fishery records
|
||||
|
@ -12,8 +15,7 @@ public enum Type {
|
|||
Assesment_Unit("Assesment Unit"),
|
||||
Resource("Resource"),
|
||||
Fishing_Activity("Fishing Activity"), // for fishery
|
||||
Fishing_Description("Fishing Description") // for fishery
|
||||
;
|
||||
Fishing_Description("Fishing Description"); // for fishery
|
||||
|
||||
private String subGroupNameOrig;
|
||||
private String subGroupNameOnCkan;
|
||||
|
@ -38,5 +40,21 @@ public enum Type {
|
|||
public String getOrigName(){
|
||||
return subGroupNameOrig;
|
||||
}
|
||||
|
||||
|
||||
@JsonValue
|
||||
public String onSerialize(){
|
||||
return subGroupNameOrig.toLowerCase();
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static Type onDeserialize(String typeString) {
|
||||
if(typeString != null) {
|
||||
for(Type type : Type.values()) {
|
||||
if(type.getOrigName().equalsIgnoreCase(typeString.trim()))
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue