added common classes
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-common-library@157652 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
b885fb3eb1
commit
9ac37deb40
|
@ -25,6 +25,7 @@
|
|||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
|
|
13
.project
13
.project
|
@ -5,6 +5,11 @@
|
|||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.common.project.facet.core.builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
|
@ -15,9 +20,17 @@
|
|||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
|
||||
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
<wb-module deploy-name="grsf-common-library">
|
||||
<wb-resource deploy-path="/" source-path="/src/main/java"/>
|
||||
<wb-resource deploy-path="/" source-path="/src/main/resources"/>
|
||||
</wb-module>
|
||||
</project-modules>
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faceted-project>
|
||||
<installed facet="java" version="1.8"/>
|
||||
<installed facet="jst.utility" version="1.0"/>
|
||||
</faceted-project>
|
49
pom.xml
49
pom.xml
|
@ -24,10 +24,22 @@
|
|||
<url>https://svn.d4science.research-infrastructures.eu/gcube/trunk/${serviceClass}/${project.artifactId}</url>
|
||||
</scm>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>maven-smartgears-bom</artifactId>
|
||||
<version>LATEST</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<gwtVersion>2.7.0</gwtVersion>
|
||||
<version.jersey>2.22.1</version.jersey>
|
||||
<distroDirectory>${project.basedir}/distro</distroDirectory>
|
||||
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
|
||||
<distroDirectory>distro</distroDirectory>
|
||||
|
@ -35,6 +47,20 @@
|
|||
<jsoup.version>1.10.1</jsoup.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.media</groupId>
|
||||
<artifactId>jersey-media-json-jackson</artifactId>
|
||||
<version>${version.jersey}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<!-- Generate compiled stuff in the folder used for developing mode -->
|
||||
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
|
||||
|
@ -54,29 +80,6 @@
|
|||
</resources>
|
||||
|
||||
<plugins>
|
||||
|
||||
<!-- GWT Maven Plugin -->
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>gwt-maven-plugin</artifactId>
|
||||
<version>${gwtVersion}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<!-- Plugin configuration. There are many available options, see gwt-maven-plugin
|
||||
documentation at codehaus.org -->
|
||||
<configuration>
|
||||
<runTarget>GRSFManageWidget.html</runTarget>
|
||||
<modules>
|
||||
<module>org.gcube.datacatalogue.grsf_manage_widget.GRSFManageWidget</module>
|
||||
</modules>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- SA Plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
|
|
@ -7,7 +7,7 @@ package org.gcube.datacatalogue.common;
|
|||
*/
|
||||
public class Constants {
|
||||
|
||||
// base record
|
||||
// base record (only custom field key)
|
||||
public static final String CATALOG_ID = "catalog_id";
|
||||
public static final String DESCRIPTION = "description";
|
||||
public static final String LICENSE_ID = "license_id";
|
||||
|
@ -19,5 +19,89 @@ public class Constants {
|
|||
public static final String EXTRAS_FIELD = "extras_fields";
|
||||
public static final String EXTRAS_RESOURCES = "extras_resources";
|
||||
|
||||
// common record
|
||||
public static final String UUID_KB_KEY = "GRSF UUID";
|
||||
public static final String UUID_KB_JSON_KEY = "grsf_uuid";
|
||||
public static final String DOMAIN_CUSTOM_KEY = "Domain";
|
||||
public static final String DATA_OWNER_CUSTOM_KEY = "Data owner";
|
||||
public static final String DATA_OWNER_JSON_KEY = "data_owner";
|
||||
public static final String DATABASE_SOURCES_JSON_KEY = "database_sources";
|
||||
public static final String SOURCES_OF_INFORMATION_JSON_KEY = "source_of_information";
|
||||
public static final String REFERS_TO_JSON_KEY = "refers_to";
|
||||
public static final String SHORT_NAME_CUSTOM_KEY = "Short Name";
|
||||
public static final String SHORT_NAME_JSON_KEY = "short_name";
|
||||
public static final String TRACEABILITY_FLAG_CUSTOM_KEY = "Traceability Flag";
|
||||
public static final String TRACEABILITY_FLAG_JSON_KEY = "traceability_flag";
|
||||
public static final String CATCHES_CUSTOM_KEY = "Catches";
|
||||
public static final String CATCHES_JSON_KEY = "catches";
|
||||
public static final String LANDINGS_CUSTOM_KEY = "Landings";
|
||||
public static final String LANDINGS_JSON_KEY = "landings";
|
||||
public static final String SPECIES_CUSTOM_KEY = "Species";
|
||||
public static final String SPECIES_JSON_KEY = "species";
|
||||
public static final String STATUS_OF_THE_GRSF_RECORD_CUSTOM_KEY = "Status of the GRSF record";
|
||||
public static final String STATUS_OF_THE_GRSF_RECORD_JSON_KEY = "status_grsf_record";
|
||||
public static final String SIMILAR_GRSF_RECORDS_CUSTOM_KEY = "Similar GRSF Records";
|
||||
public static final String SIMILAR_GRSF_RECORDS_JSON_KEY = "similar_grsf_records";
|
||||
public static final String SIMILAR_SOURCE_RECORDS_CUSTOM_KEY = "Similar Source Records";
|
||||
public static final String SIMILAR_SOURCE_RECORDS_JSON_KEY = "similar_source_records";
|
||||
public static final String GRSF_SEMANTIC_IDENTIFIER_CUSTOM_KEY = "GRSF Semantic identifier";
|
||||
public static final String GRSF_SEMANTIC_IDENTIFIER_JSON_KEY = "grsf_semantic_identifier";
|
||||
public static final String GRSF_TYPE_CUSTOM_KEY = "GRSF Type";
|
||||
public static final String GRSF_TYPE_JSON_KEY = "grsf_type";
|
||||
public static final String MANAGEMENT_ENTITIES_CUSTOM_KEY = "Management Body/Authority(ies)";
|
||||
public static final String MANAGEMENT_ENTITIES_JSON_KEY = "management_body_authorities";
|
||||
|
||||
// stock record
|
||||
public static final String STOCK_NAME_CUSTOM_KEY = "Stock Name";
|
||||
public static final String STOCK_NAME_JSON_KEY = "stock_name";
|
||||
public static final String ASSESSMENT_AREA_CUSTOM_KEY = "Assessment Area";
|
||||
public static final String ASSESSMENT_AREA_JSON_KEY = "assessment_area";
|
||||
public static final String EXPLOITING_FISHERY_CUSTOM_KEY = "Exploiting Fishery";
|
||||
public static final String EXPLOITING_FISHERY_JSON_KEY = "exploiting_fishery";
|
||||
public static final String ASSESSMENT_METHODS_CUSTOM_KEY = "Assessment Methods";
|
||||
public static final String ASSESSMENT_METHODS_JSON_KEY = "assessment_methods";
|
||||
public static final String FIRMS_ABUNDANCE_LEVEL_CUSTOM_KEY = "Abundance Level (FIRMS Standard)";
|
||||
public static final String FIRMS_ABUNDANCE_LEVEL_JSON_KEY = "firms_standard_abundance_level";
|
||||
public static final String ABUNDANCE_LEVEL_CUSTOM_KEY = "Abundance Level";
|
||||
public static final String ABUNDANCE_LEVEL_JSON_KEY = "abundance_level";
|
||||
public static final String FISHING_PRESSURE_FIRMS_CUSTOM_KEY = "Fishing Pressure (FIRMS Standard)";
|
||||
public static final String FISHING_PRESSURE_FIRMS_JSON_KEY = "firms_standard_fishing_pressure";
|
||||
public static final String FISHING_PRESSURE_CUSTOM_KEY = "Fishing Pressure";
|
||||
public static final String FISHING_PRESSURE_JSON_KEY = "fishing_pressure";
|
||||
public static final String STATE_AND_TREND_MARINE_RESOURCE_CUSTOM_KEY = "State and trend of Marine Resource";
|
||||
public static final String STATE_AND_TREND_MARINE_RESOURCE_JSON_KEY = "state_and_trend_of_marine_resources";
|
||||
public static final String FAO_CATEGORIES_CUSTOM_KEY = "Fao Categories";
|
||||
public static final String FAO_CATEGORIES_JSON_KEY = "fao_categories";
|
||||
public static final String SCIENTIFIC_ADVICE_CUSTOM_KEY = "Scientific advice";
|
||||
public static final String SCIENTIFIC_ADVICE_JSON_KEY = "scientific_advice";
|
||||
public static final String ASSESSOR_CUSTOM_KEY = "Assessor";
|
||||
public static final String ASSESSOR_JSON_KEY = "assessor";
|
||||
|
||||
|
||||
// fishery record
|
||||
public static final String FISHERY_NAME_CUSTOM_KEY = "Fishery Name";
|
||||
public static final String FISHERY_NAME_JSON_KEY = "fishery_name";
|
||||
public static final String FISHING_AREA_CUSTOM_KEY = "Fishing area";
|
||||
public static final String FISHING_AREA_JSON_KEY = "fishing_area";
|
||||
public static final String RESOURCES_EXPLOITED_CUSTOM_KEY = "Resources Exploited";
|
||||
public static final String RESOURCES_EXPLOITED_JSON_KEY = "resources_exploited";
|
||||
public static final String FLAG_STATE_CUSTOM_KEY = "Flag State";
|
||||
public static final String FLAG_STATE_JSON_KEY = "flag_state";
|
||||
public static final String JURISDICTION_AREA_CUSTOM_KEY = "Jurisdiction Area";
|
||||
public static final String JURISDICTION_AREA_JSON_KEY = "jurisdiction_area";
|
||||
public static final String PRODUCTION_SYSTEM_TYPE_CUSTOM_KEY = "Type of Production System";
|
||||
public static final String PRODUCTION_SYSTEM_TYPE_JSON_KEY = "production_system_type";
|
||||
public static final String FISHING_GEAR_CUSTOM_KEY = "Fishing gear";
|
||||
public static final String FISHING_GEAR_JSON_KEY = "fishing_gear";
|
||||
|
||||
|
||||
// other fields/regex
|
||||
public static final String DEFAULT_LICENSE = "CC-BY-SA-4.0";
|
||||
public static final String SYSTEM_TYPE = "system:type";
|
||||
public static final String SYSTEM_TYPE_FOR_SOURCES = "Legacy";
|
||||
public static final String GRSF_DATABASE_SOURCE = "Database Source";
|
||||
public static final int TIME_SERIES_TAKE_LAST_VALUES = 5;
|
||||
public static final String REGEX_TAGS = "[^\\s\\w-_.]";
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
package org.gcube.datacatalogue.common.caches;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Cache implementation.
|
||||
* @author Costantino Perciante at ISTI-CNR
|
||||
* (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public class CacheImpl <K, V> implements CacheInterface<K, V> {
|
||||
|
||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(CacheImpl.class);
|
||||
|
||||
/**
|
||||
* The hashmap
|
||||
*/
|
||||
private Map<K, CacheValueBean<V>> cache;
|
||||
|
||||
/**
|
||||
* Cache entry expires after EXPIRED_AFTER ms
|
||||
*/
|
||||
private long ttl;
|
||||
|
||||
public CacheImpl(long timeout){
|
||||
ttl = timeout;
|
||||
cache = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public V get(K key) {
|
||||
|
||||
if(cache.containsKey(key)){
|
||||
CacheValueBean<V> bean = cache.get(key);
|
||||
if(CacheUtilities.expired(bean.getTTL(), ttl)){
|
||||
cache.remove(key);
|
||||
logger.debug("Amount of space in the infrastructure used expired for key " + key + ", returning null");
|
||||
}
|
||||
else
|
||||
return bean.getValue();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean insert(K key, V obj) {
|
||||
CacheValueBean<V> newBean = new CacheValueBean<V>(obj, System.currentTimeMillis());
|
||||
cache.put(key, newBean);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package org.gcube.datacatalogue.common.caches;
|
||||
|
||||
/**
|
||||
* Generic interface
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
* @param <K> the key type
|
||||
* @param <V> the value type
|
||||
*/
|
||||
public interface CacheInterface <K,V>{
|
||||
|
||||
/**
|
||||
* Retrieve a value V from the cache
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public V get(K key);
|
||||
|
||||
/**
|
||||
* Insert an object V with key K into the cache
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public boolean insert(K key, V value);
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package org.gcube.datacatalogue.common.caches;
|
||||
|
||||
/**
|
||||
* Utility functions for caches
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public class CacheUtilities {
|
||||
/**
|
||||
* Check if the bean expired
|
||||
* @param beanTimestamp
|
||||
* @param ttl
|
||||
* @return <true> if expired, <false> otherwise
|
||||
*/
|
||||
public static boolean expired(long beanTimestamp, long ttl){
|
||||
|
||||
long currentTime = System.currentTimeMillis();
|
||||
|
||||
if((beanTimestamp + ttl) <= currentTime)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package org.gcube.datacatalogue.common.caches;
|
||||
|
||||
/**
|
||||
* A bean object to be used as value within the cache. It contains a TTL value too.
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
* @param <V> the value type
|
||||
*/
|
||||
public class CacheValueBean <V>{
|
||||
|
||||
private V value;
|
||||
private long TTL;
|
||||
|
||||
/**
|
||||
* @param value
|
||||
* @param TTL
|
||||
*/
|
||||
public CacheValueBean(V value, long ttl) {
|
||||
super();
|
||||
this.value = value;
|
||||
this.TTL = ttl;
|
||||
}
|
||||
public V getValue() {
|
||||
return value;
|
||||
}
|
||||
public void setValue(V value) {
|
||||
this.value = value;
|
||||
}
|
||||
public long getTTL() {
|
||||
return TTL;
|
||||
}
|
||||
public void setTTL(long ttl) {
|
||||
this.TTL = ttl;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CacheValueBean [value=" + value + ", TTL=" + TTL + "]";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package org.gcube.datacatalogue.common.enums;
|
||||
|
||||
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)
|
||||
*/
|
||||
public enum Abundance_Level {
|
||||
|
||||
Intermediate_Abundance("Intermediate abundance"),
|
||||
Low_Abundance("Low abundance"),
|
||||
Uncertain_Not_Assessed("Uncertain/Not assessed"),
|
||||
Not_applicable("Not applicable"),
|
||||
Pre_exploitation_Or_High_Abundance("Pre-exploitation biomass or high abundance"),
|
||||
Depleted("Depleted"),
|
||||
Virgin_Or_High_Abundance("Virgin or High abundance");
|
||||
|
||||
private String subGroupNameOrig;
|
||||
|
||||
private Abundance_Level(String origName) {
|
||||
this.subGroupNameOrig = origName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original name
|
||||
* @return
|
||||
*/
|
||||
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.trim().replaceAll("[^A-Za-z]", " ")))
|
||||
return abundanceValue;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getOrigName();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package org.gcube.datacatalogue.common.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
|
||||
/**
|
||||
* Exploitation_Rate for Stock records
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public enum Exploitation_Rate {
|
||||
|
||||
Not_Applicable("Not applicable"),
|
||||
Moderate_Fishing_Mortality("Moderate fishing mortality"),
|
||||
High_Fishing_Mortality("High fishing mortality"),
|
||||
No_Or_Low_Fishing_Mortality("No or low fishing mortality"),
|
||||
Uncertain_Not_assessed("Uncertain/Not assessed");
|
||||
|
||||
private String subGroupNameOrig;
|
||||
|
||||
private Exploitation_Rate(String origName) {
|
||||
this.subGroupNameOrig = origName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original name
|
||||
* @return
|
||||
*/
|
||||
public String getOrigName(){
|
||||
return subGroupNameOrig;
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static Exploitation_Rate onDeserialize(String exploitationString) {
|
||||
if(exploitationString != null) {
|
||||
for (Exploitation_Rate exploitationValue : Exploitation_Rate.values()) {
|
||||
if(exploitationValue.getOrigName().replaceAll("[^A-Za-z]", " ").equalsIgnoreCase(exploitationString.trim().replaceAll("[^A-Za-z]", " ")))
|
||||
return exploitationValue;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getOrigName();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package org.gcube.datacatalogue.common.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
|
||||
/**
|
||||
* Type for Fishery records
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public enum Fishery_Type {
|
||||
|
||||
Fishing_Activity("Fishing Activity"), // for fishery
|
||||
Fishing_Description("Fishing Description"); // for fishery
|
||||
|
||||
private String subGroupNameOrig;
|
||||
|
||||
private Fishery_Type(String origName) {
|
||||
this.subGroupNameOrig = origName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original name
|
||||
* @return
|
||||
*/
|
||||
public String getOrigName(){
|
||||
return subGroupNameOrig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the json value
|
||||
* @return
|
||||
*/
|
||||
@JsonValue
|
||||
public String onSerialize(){
|
||||
return subGroupNameOrig.toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get back an enum from json string
|
||||
* @param typeString
|
||||
* @return
|
||||
*/
|
||||
@JsonCreator
|
||||
public static Fishery_Type onDeserialize(String typeString) {
|
||||
if(typeString != null) {
|
||||
for(Fishery_Type type : Fishery_Type.values()) {
|
||||
if(type.getOrigName().equalsIgnoreCase(typeString.trim()))
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by reflection
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getOrigName();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package org.gcube.datacatalogue.common.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
|
||||
|
||||
/**
|
||||
* Fishing_Pressure for Stock records
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public enum Fishing_Pressure {
|
||||
|
||||
Not_Applicable("Not applicable"),
|
||||
Moderate_Fishing_Mortality("Moderate fishing mortality"),
|
||||
High_Fishing_Mortality("High fishing mortality"),
|
||||
No_Or_Low_Fishing_Mortality("No or low fishing mortality"),
|
||||
Uncertain_Not_assessed("Uncertain/Not assessed");
|
||||
|
||||
private String subGroupNameOrig;
|
||||
|
||||
private Fishing_Pressure(String origName) {
|
||||
this.subGroupNameOrig = origName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original name
|
||||
* @return
|
||||
*/
|
||||
public String getOrigName(){
|
||||
return subGroupNameOrig;
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static Fishing_Pressure onDeserialize(String fishing_Pressure) {
|
||||
if(fishing_Pressure != null) {
|
||||
for (Fishing_Pressure fishingPressure : Fishing_Pressure.values()) {
|
||||
if(fishingPressure.getOrigName().replaceAll("[^A-Za-z]", " ").equalsIgnoreCase(fishing_Pressure.trim().replaceAll("[^A-Za-z]", " ")))
|
||||
return fishingPressure;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getOrigName();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package org.gcube.datacatalogue.common.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* The type of product, i.e. Stock or Fishery
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public enum Product_Type {
|
||||
|
||||
FISHERY("Fishery"),
|
||||
STOCK("Stock");
|
||||
|
||||
private String subGroupNameOrig;
|
||||
|
||||
private Product_Type(String origName) {
|
||||
this.subGroupNameOrig = origName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original name
|
||||
* @return
|
||||
*/
|
||||
public String getOrigName(){
|
||||
return subGroupNameOrig;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String onSerialize(){
|
||||
return subGroupNameOrig.toLowerCase();
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static Product_Type onDeserialize(String recordTypeString) {
|
||||
if(recordTypeString != null) {
|
||||
for(Product_Type source : Product_Type.values()) {
|
||||
if (source.toString().equalsIgnoreCase(recordTypeString.trim()))
|
||||
return source;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getOrigName();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package org.gcube.datacatalogue.common.enums;
|
||||
|
||||
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)
|
||||
*/
|
||||
public enum Production_System_Type {
|
||||
|
||||
Subsistence("Subsistence"),
|
||||
Recreational("Recreational"),
|
||||
Commercial("Commercial"),
|
||||
Artisanal("Artisanal"),
|
||||
Semi_Industrial("Semi-industrial"),
|
||||
Industrial("Industrial"),
|
||||
Exploratory_fishery("Exploratory fishery"),
|
||||
Unspecified("Unspecified");
|
||||
|
||||
private String subGroupNameOrig;
|
||||
|
||||
private Production_System_Type(String origName) {
|
||||
this.subGroupNameOrig = origName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original name
|
||||
* @return
|
||||
*/
|
||||
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.trim().replaceAll("[^A-Za-z]", " ")))
|
||||
return productionValue;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getOrigName();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package org.gcube.datacatalogue.common.enums;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
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 Sources {
|
||||
|
||||
FIRMS("FIRMS"),
|
||||
RAM("RAM"),
|
||||
FISHSOURCE("FishSource"),
|
||||
GRSF("GRSF");
|
||||
|
||||
private String subGroupNameOrig;
|
||||
|
||||
private Sources(String origName) {
|
||||
this.subGroupNameOrig = origName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original name
|
||||
* @return
|
||||
*/
|
||||
public String getOrigName(){
|
||||
return subGroupNameOrig;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String onSerialize(){
|
||||
return subGroupNameOrig.toLowerCase();
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static Sources onDeserialize(String sourceString) {
|
||||
if(sourceString != null) {
|
||||
for(Sources source : Sources.values()) {
|
||||
if (source.toString().equalsIgnoreCase(sourceString.trim()))
|
||||
return source;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getOrigName();
|
||||
}
|
||||
|
||||
public static String getAsList(){
|
||||
return "[" + Arrays.asList(
|
||||
FIRMS.toString().toLowerCase(),
|
||||
RAM.toString().toLowerCase(),
|
||||
FISHSOURCE.toString().toLowerCase(),
|
||||
GRSF.toString().toLowerCase()) + "]";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package org.gcube.datacatalogue.common.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* Status Group and sub groups (for both Stock and Fishery, only Aggregated records)
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public enum Status {
|
||||
|
||||
Pending("Pending"),
|
||||
Approved("Approved"),
|
||||
Rejected("Rejected"),
|
||||
Archived("Archived"),
|
||||
Hidden("Hidden"),
|
||||
Merged("Merged");
|
||||
|
||||
private String origName;
|
||||
|
||||
private Status(String origName) {
|
||||
this.origName = origName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original name
|
||||
* @return
|
||||
*/
|
||||
public String getOrigName(){
|
||||
return origName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the json value
|
||||
* @return
|
||||
*/
|
||||
@JsonValue
|
||||
public String onSerialize(){
|
||||
return origName.toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get back an enum from json string
|
||||
* @param statusString
|
||||
* @return
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by reflection
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getOrigName();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package org.gcube.datacatalogue.common.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
/**
|
||||
* Stock types
|
||||
* @author Costantino Perciante at ISTI-CNR
|
||||
* (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public enum Stock_Type {
|
||||
|
||||
Assessment_Unit("Assessment Unit"),
|
||||
Marine_Resource("Marine Resource");
|
||||
|
||||
private String subGroupNameOrig;
|
||||
|
||||
private Stock_Type(String origName) {
|
||||
this.subGroupNameOrig = origName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original name
|
||||
* @return
|
||||
*/
|
||||
public String getOrigName(){
|
||||
return subGroupNameOrig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the json value
|
||||
* @return
|
||||
*/
|
||||
@JsonValue
|
||||
public String onSerialize(){
|
||||
return subGroupNameOrig.toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get back an enum from json string
|
||||
* @param typeString
|
||||
* @return
|
||||
*/
|
||||
@JsonCreator
|
||||
public static Stock_Type onDeserialize(String typeString) {
|
||||
if(typeString != null) {
|
||||
for(Stock_Type type : Stock_Type.values()) {
|
||||
if(type.getOrigName().equalsIgnoreCase(typeString.trim().toLowerCase()) || type.getOrigName().toLowerCase().contains(typeString.trim().toLowerCase()))
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by reflection
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getOrigName();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<ID></ID>
|
||||
<Type>Service</Type>
|
||||
<Profile>
|
||||
<Description>Utility library to publish GRSF products on data catalogue.</Description>
|
||||
<Class>PortletWidgets</Class>
|
||||
<Name>grsf-common-library</Name>
|
||||
<Version>1-0-0-SNAPSHOT</Version>
|
||||
<Packages>
|
||||
<Software>
|
||||
<Name>grsf-common-library</Name>
|
||||
<Version>1-0-0-SNAPSHOT</Version>
|
||||
<MavenCoordinates>
|
||||
<groupId>org.gcube.data-catalogue</groupId>
|
||||
<artifactId>grsf-common-library</artifactId>
|
||||
<version>1-0-0-SNAPSHOT</version>
|
||||
</MavenCoordinates>
|
||||
<Files>
|
||||
<File>target/grsf-common-library-1-0-0-SNAPSHOT.jar</File>
|
||||
</Files>
|
||||
</Software>
|
||||
</Packages>
|
||||
</Profile>
|
||||
</Resource>
|
Loading…
Reference in New Issue