61 lines
1.3 KiB
Java
61 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;
|
|
|
|
|
|
/**
|
|
* Type for Stock/Fishery records
|
|
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
|
*/
|
|
public enum Type {
|
|
|
|
Assesment_Unit("Assesment Unit"),
|
|
Resource("Resource"),
|
|
Fishing_Activity("Fishing Activity"), // for fishery
|
|
Fishing_Description("Fishing Description"); // for fishery
|
|
|
|
private String subGroupNameOrig;
|
|
private String subGroupNameOnCkan;
|
|
|
|
private Type(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 Type onDeserialize(String typeString) {
|
|
if(typeString != null) {
|
|
for(Type type : Type.values()) {
|
|
if(type.getOrigName().equalsIgnoreCase(typeString.trim()))
|
|
return type;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
}
|