diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..1adae3b --- /dev/null +++ b/.classpath @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..50a21b1 --- /dev/null +++ b/.project @@ -0,0 +1,42 @@ + + + grsf-common-library + + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/.settings/.jsdtscope b/.settings/.jsdtscope new file mode 100644 index 0000000..b72a6a4 --- /dev/null +++ b/.settings/.jsdtscope @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..160c7b8 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 +encoding//src/test/java=UTF-8 +encoding//src/test/resources=UTF-8 +encoding//target/generated-sources/gwt=UTF-8 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..6e80039 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +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 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component new file mode 100644 index 0000000..9756d7b --- /dev/null +++ b/.settings/org.eclipse.wst.common.component @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 0000000..9f23f94 --- /dev/null +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.container b/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 0000000..3bd5d0a --- /dev/null +++ b/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.name b/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 0000000..05bd71b --- /dev/null +++ b/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/.settings/org.eclipse.wst.validation.prefs b/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 0000000..04cad8c --- /dev/null +++ b/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,2 @@ +disabled=06target +eclipse.preferences.version=1 diff --git a/distro/LICENSE b/distro/LICENSE new file mode 100644 index 0000000..2d9616a --- /dev/null +++ b/distro/LICENSE @@ -0,0 +1 @@ +${gcube.license} \ No newline at end of file diff --git a/distro/README b/distro/README new file mode 100644 index 0000000..0ba28d7 --- /dev/null +++ b/distro/README @@ -0,0 +1,62 @@ +The gCube System - ${name} +-------------------------------------------------- + +${description} + + +${gcube.description} + +${gcube.funding} + + +Version +-------------------------------------------------- + +${version} (${buildDate}) + +Please see the file named "changelog.xml" in this directory for the release notes. + + +Authors +-------------------------------------------------- + +* Costantino Perciante (costantino.perciante-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy). + +Maintainers +----------- + +* Costantino Perciante (costantino.perciante-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy). + +Download information +-------------------------------------------------- + +Source code is available from SVN: + ${scm.url} + +Binaries can be downloaded from the gCube website: + ${gcube.website} + + +Installation +-------------------------------------------------- + +Installation documentation is available on-line in the gCube Wiki: + ${gcube.wikiRoot} + +Documentation +-------------------------------------------------- + +Documentation is available on-line in the gCube Wiki: + ${gcube.wikiRoot} + +Support +-------------------------------------------------- + +Bugs and support requests can be reported in the gCube issue tracking tool: + ${gcube.issueTracking} + + +Licensing +-------------------------------------------------- + +This software is licensed under the terms you may find in the file named "LICENSE" in this directory. \ No newline at end of file diff --git a/distro/changelog.xml b/distro/changelog.xml new file mode 100644 index 0000000..f5bbe9c --- /dev/null +++ b/distro/changelog.xml @@ -0,0 +1,5 @@ + + + First Release + + diff --git a/distro/descriptor.xml b/distro/descriptor.xml new file mode 100644 index 0000000..b3f5628 --- /dev/null +++ b/distro/descriptor.xml @@ -0,0 +1,31 @@ + + servicearchive + + tar.gz + + / + + + ${distroDirectory} + / + true + + README + LICENSE + changelog.xml + profile.xml + + 755 + true + + + + + target/${build.finalName}.${project.packaging} + /${artifactId} + + + \ No newline at end of file diff --git a/distro/profile.xml b/distro/profile.xml new file mode 100644 index 0000000..12e3649 --- /dev/null +++ b/distro/profile.xml @@ -0,0 +1,25 @@ + + + + Service + + ${description} + PortletWidgets + ${artifactId} + ${version} + + + ${artifactId} + ${version} + + ${groupId} + ${artifactId} + ${version} + + + target/${build.finalName}.jar + + + + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..7464f11 --- /dev/null +++ b/pom.xml @@ -0,0 +1,188 @@ + + + + 4.0.0 + + maven-parent + org.gcube.tools + 1.0.0 + + + + org.gcube.data-catalogue + grsf-common-library + jar + 1.0.0-SNAPSHOT + + + Utility library to publish GRSF products on data catalogue. + + + + scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/${serviceClass}/${project.artifactId} + scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/${serviceClass}/${project.artifactId} + https://svn.d4science.research-infrastructures.eu/gcube/trunk/${serviceClass}/${project.artifactId} + + + + UTF-8 + 2.7.0 + 2.22.1 + ${project.basedir}/distro + ${project.build.directory}/${project.build.finalName} + distro + UTF-8 + 1.10.1 + + + + + + org.gcube.distribution + maven-smartgears-bom + LATEST + pom + import + + + com.google.gwt + gwt + ${gwtVersion} + pom + import + + + + + + + com.google.gwt + gwt-servlet + ${gwtVersion} + provided + + + com.google.gwt + gwt-user + ${gwtVersion} + provided + + + com.google.gwt + gwt-dev + ${gwtVersion} + provided + + + org.slf4j + slf4j-api + provided + + + org.glassfish.jersey.media + jersey-media-json-jackson + ${version.jersey} + provided + + + junit + junit + 4.11 + test + + + + + + ${webappDirectory}/WEB-INF/classes + + + src/main/java + + **/*.* + + + + src/main/resources + + **/*.* + + + + + + + + + + org.codehaus.mojo + gwt-maven-plugin + 2.8.1 + + + + compile + test + generateAsync + + + + + + GRSFCommon.html + + org.gcube.datacatalogue.grsf_common_library.GRSFCommon + + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.2 + + + ${distroDirectory}/descriptor.xml + + + + + servicearchive + install + + single + + + + + + org.apache.maven.plugins + maven-resources-plugin + 2.5 + + + copy-profile + install + + copy-resources + + + target + + + ${distroDirectory} + true + + profile.xml + + + + + + + + + + + diff --git a/src/main/java/org/gcube/datacatalogue/common/Constants.java b/src/main/java/org/gcube/datacatalogue/common/Constants.java new file mode 100644 index 0000000..c0b4f60 --- /dev/null +++ b/src/main/java/org/gcube/datacatalogue/common/Constants.java @@ -0,0 +1,112 @@ +package org.gcube.datacatalogue.common; + + +/** + * Constants shared between manager panel and service + * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) + */ +public class Constants { + + // 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"; + public static final String AUTHOR = "author"; + public static final String AUTHOR_CONTACT = "author_contact"; + public static final String VERSION = "version"; + public static final String MAINTAINER = "maintainer"; + public static final String MAINTAINER_CONTACT = "maintainer_contact"; + public static final String EXTRAS_FIELD = "extras_fields"; + public static final String EXTRAS_RESOURCES = "extras_resources"; + + // common record + public static final String UUID_KB_CUSTOM_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_CUSTOM_KEY = "system:type"; + public static final String SYSTEM_TYPE_FOR_SOURCES_VALUE = "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-_.]"; + public static final String ITEM_URL_FIELD = "GRSF Record URL"; + public static final String GRSF_ADMIN_ORGANIZATION_NAME = "grsf_admin"; + public static final String GENERIC_RESOURCE_NAME_MAP_KEY_NAMESPACES_STOCK = "GRSF Stock"; + public static final String GENERIC_RESOURCE_NAME_MAP_KEY_NAMESPACES_FISHERY = "GRSF Fishery"; + + // management constants area + public static final String MANAGEMENT_AREA_NAMESPACE = "management_area:"; + public static final String ANNOTATION_CUSTOM_KEY= "Annotation"; + +} diff --git a/src/main/java/org/gcube/datacatalogue/common/GRSFCommon.java b/src/main/java/org/gcube/datacatalogue/common/GRSFCommon.java new file mode 100644 index 0000000..9a72cc1 --- /dev/null +++ b/src/main/java/org/gcube/datacatalogue/common/GRSFCommon.java @@ -0,0 +1,15 @@ +package org.gcube.datacatalogue.common; + +import com.google.gwt.core.client.EntryPoint; + +/** + * Entry point classes define onModuleLoad(). + */ +public class GRSFCommon implements EntryPoint { + /** + * This is the entry point method. + */ + public void onModuleLoad(){ + + } +} diff --git a/src/main/java/org/gcube/datacatalogue/common/caches/CacheImpl.java b/src/main/java/org/gcube/datacatalogue/common/caches/CacheImpl.java new file mode 100644 index 0000000..3441573 --- /dev/null +++ b/src/main/java/org/gcube/datacatalogue/common/caches/CacheImpl.java @@ -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 implements CacheInterface { + + private static final org.slf4j.Logger logger = LoggerFactory.getLogger(CacheImpl.class); + + /** + * The hashmap + */ + private Map> 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 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 newBean = new CacheValueBean(obj, System.currentTimeMillis()); + cache.put(key, newBean); + return true; + } +} diff --git a/src/main/java/org/gcube/datacatalogue/common/caches/CacheInterface.java b/src/main/java/org/gcube/datacatalogue/common/caches/CacheInterface.java new file mode 100644 index 0000000..130e489 --- /dev/null +++ b/src/main/java/org/gcube/datacatalogue/common/caches/CacheInterface.java @@ -0,0 +1,26 @@ +package org.gcube.datacatalogue.common.caches; + +/** + * Generic interface + * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) + * @param the key type + * @param the value type + */ +public interface CacheInterface { + + /** + * 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); + +} diff --git a/src/main/java/org/gcube/datacatalogue/common/caches/CacheUtilities.java b/src/main/java/org/gcube/datacatalogue/common/caches/CacheUtilities.java new file mode 100644 index 0000000..3d4c169 --- /dev/null +++ b/src/main/java/org/gcube/datacatalogue/common/caches/CacheUtilities.java @@ -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 if expired, otherwise + */ + public static boolean expired(long beanTimestamp, long ttl){ + + long currentTime = System.currentTimeMillis(); + + if((beanTimestamp + ttl) <= currentTime) + return true; + else + return false; + + } +} diff --git a/src/main/java/org/gcube/datacatalogue/common/caches/CacheValueBean.java b/src/main/java/org/gcube/datacatalogue/common/caches/CacheValueBean.java new file mode 100644 index 0000000..f1efc06 --- /dev/null +++ b/src/main/java/org/gcube/datacatalogue/common/caches/CacheValueBean.java @@ -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 the value type + */ +public class CacheValueBean { + + 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 + "]"; + } +} diff --git a/src/main/java/org/gcube/datacatalogue/common/enums/Abundance_Level.java b/src/main/java/org/gcube/datacatalogue/common/enums/Abundance_Level.java new file mode 100644 index 0000000..c91439a --- /dev/null +++ b/src/main/java/org/gcube/datacatalogue/common/enums/Abundance_Level.java @@ -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(); + } +} diff --git a/src/main/java/org/gcube/datacatalogue/common/enums/Exploitation_Rate.java b/src/main/java/org/gcube/datacatalogue/common/enums/Exploitation_Rate.java new file mode 100644 index 0000000..edf6894 --- /dev/null +++ b/src/main/java/org/gcube/datacatalogue/common/enums/Exploitation_Rate.java @@ -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(); + } +} diff --git a/src/main/java/org/gcube/datacatalogue/common/enums/Fishery_Type.java b/src/main/java/org/gcube/datacatalogue/common/enums/Fishery_Type.java new file mode 100644 index 0000000..1400a35 --- /dev/null +++ b/src/main/java/org/gcube/datacatalogue/common/enums/Fishery_Type.java @@ -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(); + } +} diff --git a/src/main/java/org/gcube/datacatalogue/common/enums/Fishing_Pressure.java b/src/main/java/org/gcube/datacatalogue/common/enums/Fishing_Pressure.java new file mode 100644 index 0000000..61c8df1 --- /dev/null +++ b/src/main/java/org/gcube/datacatalogue/common/enums/Fishing_Pressure.java @@ -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(); + } + +} diff --git a/src/main/java/org/gcube/datacatalogue/common/enums/Product_Type.java b/src/main/java/org/gcube/datacatalogue/common/enums/Product_Type.java new file mode 100644 index 0000000..19e61c1 --- /dev/null +++ b/src/main/java/org/gcube/datacatalogue/common/enums/Product_Type.java @@ -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(); + } +} diff --git a/src/main/java/org/gcube/datacatalogue/common/enums/Production_System_Type.java b/src/main/java/org/gcube/datacatalogue/common/enums/Production_System_Type.java new file mode 100644 index 0000000..dc8c8f5 --- /dev/null +++ b/src/main/java/org/gcube/datacatalogue/common/enums/Production_System_Type.java @@ -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(); + } +} diff --git a/src/main/java/org/gcube/datacatalogue/common/enums/Sources.java b/src/main/java/org/gcube/datacatalogue/common/enums/Sources.java new file mode 100644 index 0000000..67f4325 --- /dev/null +++ b/src/main/java/org/gcube/datacatalogue/common/enums/Sources.java @@ -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()) + "]"; + } +} diff --git a/src/main/java/org/gcube/datacatalogue/common/enums/Status.java b/src/main/java/org/gcube/datacatalogue/common/enums/Status.java new file mode 100644 index 0000000..87d2e96 --- /dev/null +++ b/src/main/java/org/gcube/datacatalogue/common/enums/Status.java @@ -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(); + } +} diff --git a/src/main/java/org/gcube/datacatalogue/common/enums/Stock_Type.java b/src/main/java/org/gcube/datacatalogue/common/enums/Stock_Type.java new file mode 100644 index 0000000..fd37d48 --- /dev/null +++ b/src/main/java/org/gcube/datacatalogue/common/enums/Stock_Type.java @@ -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(); + } + +} diff --git a/src/main/resources/org/gcube/datacatalogue/grsf_common_library/GRSFCommon.gwt.xml b/src/main/resources/org/gcube/datacatalogue/grsf_common_library/GRSFCommon.gwt.xml new file mode 100644 index 0000000..ea835dc --- /dev/null +++ b/src/main/resources/org/gcube/datacatalogue/grsf_common_library/GRSFCommon.gwt.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/GRSFCommon.css b/src/main/webapp/GRSFCommon.css new file mode 100644 index 0000000..e69de29 diff --git a/src/main/webapp/GRSFCommon.html b/src/main/webapp/GRSFCommon.html new file mode 100644 index 0000000..af647cb --- /dev/null +++ b/src/main/webapp/GRSFCommon.html @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + Web Application Starter Project + + + + + + + + + + + + + + + + + + + + + + +

Web Application Starter Project

+ + + + + + + + + + + + +
Please enter your name:
+ + diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..c64aaac --- /dev/null +++ b/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,13 @@ + + + + + + + + GRSFCommon.html + + + diff --git a/src/test/resources/org/gcube/datacatalogue/grsf_common_library/GRSFCommonJUnit.gwt.xml b/src/test/resources/org/gcube/datacatalogue/grsf_common_library/GRSFCommonJUnit.gwt.xml new file mode 100644 index 0000000..7cd154d --- /dev/null +++ b/src/test/resources/org/gcube/datacatalogue/grsf_common_library/GRSFCommonJUnit.gwt.xml @@ -0,0 +1,9 @@ + + + + + + + + +