grsf-publisher-ws/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/groups/Source.java

63 lines
1.3 KiB
Java

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)
*/
public enum Source {
FIRMS("FIRMS"),
RAM("RAM"),
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
*/
public String getNameCkan(){
return subGroupNameOnCkan;
}
/**
* Return the original name
* @return
*/
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;
}
@Override
public String toString() {
return getOrigName();
}
}