commit gwt versio

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-common-library@157728 82a268e6-3cf1-43bd-a215-b396298e98cf
feature/19166
Costantino Perciante 7 years ago
parent 8985d6ebd3
commit 70ac2d0567

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry including="**/*.java" kind="src" output="target/grsf-common-library-1.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/grsf-common-library-1.0.0-SNAPSHOT/WEB-INF/classes" path="target/generated-sources/gwt">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/grsf-common-library-1.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/grsf-common-library-1.0.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>grsf-common-library</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</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>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/webapp"/>
<classpathentry kind="src" path="target/m2e-wtp/web-resources"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
<attributes>
<attribute name="hide" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
<classpathentry kind="output" path=""/>
</classpath>

@ -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/<project>=UTF-8

@ -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

@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

@ -0,0 +1,11 @@
<?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="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<property name="context-root" value="grsf-common-library"/>
<property name="java-output-path" value="/grsf-common-library/target/grsf-common-library-0.0.1-SNAPSHOT/WEB-INF/classes"/>
</wb-module>
</project-modules>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="wst.jsdt.web"/>
<installed facet="java" version="1.8"/>
<installed facet="jst.web" version="2.3"/>
<installed facet="wst.jsdt.web" version="1.0"/>
</faceted-project>

@ -0,0 +1 @@
org.eclipse.wst.jsdt.launching.baseBrowserLibrary

@ -0,0 +1,2 @@
disabled=06target
eclipse.preferences.version=1

@ -0,0 +1 @@
${gcube.license}

@ -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.

@ -0,0 +1,5 @@
<ReleaseNotes>
<Changeset component="org.gcube.data-catalogue.grsf-common-library.1-0-0" date="2017-10-31">
<Change>First Release</Change>
</Changeset>
</ReleaseNotes>

@ -0,0 +1,31 @@
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>servicearchive</id>
<formats>
<format>tar.gz</format>
</formats>
<baseDirectory>/</baseDirectory>
<fileSets>
<fileSet>
<directory>${distroDirectory}</directory>
<outputDirectory>/</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes>
<includes>
<include>README</include>
<include>LICENSE</include>
<include>changelog.xml</include>
<include>profile.xml</include>
</includes>
<fileMode>755</fileMode>
<filtered>true</filtered>
</fileSet>
</fileSets>
<files>
<file>
<source>target/${build.finalName}.${project.packaging}</source>
<outputDirectory>/${artifactId}</outputDirectory>
</file>
</files>
</assembly>

@ -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>${description}</Description>
<Class>PortletWidgets</Class>
<Name>${artifactId}</Name>
<Version>${version}</Version>
<Packages>
<Software>
<Name>${artifactId}</Name>
<Version>${version}</Version>
<MavenCoordinates>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
</MavenCoordinates>
<Files>
<File>target/${build.finalName}.jar</File>
</Files>
</Software>
</Packages>
</Profile>
</Resource>

@ -0,0 +1,188 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>maven-parent</artifactId>
<groupId>org.gcube.tools</groupId>
<version>1.0.0</version>
<relativePath />
</parent>
<groupId>org.gcube.data-catalogue</groupId>
<artifactId>grsf-common-library</artifactId>
<packaging>jar</packaging>
<version>1.0.0-SNAPSHOT</version>
<description>
Utility library to publish GRSF products on data catalogue.
</description>
<scm>
<connection>scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/${serviceClass}/${project.artifactId}</connection>
<developerConnection>scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/${serviceClass}/${project.artifactId}</developerConnection>
<url>https://svn.d4science.research-infrastructures.eu/gcube/trunk/${serviceClass}/${project.artifactId}</url>
</scm>
<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>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jsoup.version>1.10.1</jsoup.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>maven-smartgears-bom</artifactId>
<version>LATEST</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt</artifactId>
<version>${gwtVersion}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${gwtVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwtVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<version>${gwtVersion}</version>
<scope>provided</scope>
</dependency>
<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>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<!-- Generate compiled stuff in the folder used for developing mode -->
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>
<plugins>
<!-- Mojo's Maven Plugin for GWT -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.8.1</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test</goal>
<goal>generateAsync</goal>
</goals>
</execution>
</executions>
<!-- Plugin configuration. There are many available options, see gwt-maven-plugin
documentation at codehaus.org -->
<configuration>
<runTarget>GRSFCommon.html</runTarget>
<modules>
<module>org.gcube.datacatalogue.grsf_common_library.GRSFCommon</module>
</modules>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<configuration>
<descriptors>
<descriptor>${distroDirectory}/descriptor.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>servicearchive</id>
<phase>install</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>copy-profile</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>target</outputDirectory>
<resources>
<resource>
<directory>${distroDirectory}</directory>
<filtering>true</filtering>
<includes>
<include>profile.xml</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -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";
}

@ -0,0 +1,15 @@
package org.gcube.datacatalogue.common;
import com.google.gwt.core.client.EntryPoint;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class GRSFCommon implements EntryPoint {
/**
* This is the entry point method.
*/
public void onModuleLoad(){
}
}

@ -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,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='GRSFCommon'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' />
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.standard.Standard' />
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<!-- Specify the app entry point class. -->
<entry-point class='org.gcube.datacatalogue.common.GRSFCommon' />
<!-- Specify the paths for translatable code -->
<source path='common' />
</module>

@ -0,0 +1,63 @@
<!doctype html>
<!-- The DOCTYPE declaration above will set the -->
<!-- browser's rendering engine into -->
<!-- "Standards Mode". Replacing this declaration -->
<!-- with a "Quirks Mode" doctype may lead to some -->
<!-- differences in layout. -->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!-- -->
<!-- Consider inlining CSS to reduce the number of requested files -->
<!-- -->
<link type="text/css" rel="stylesheet" href="GRSFCommon.css">
<!-- -->
<!-- Any title is fine -->
<!-- -->
<title>Web Application Starter Project</title>
<!-- -->
<!-- This script loads your compiled module. -->
<!-- If you add any GWT meta tags, they must -->
<!-- be added before this line. -->
<!-- -->
<script type="text/javascript" language="javascript" src="GRSFCommon/GRSFCommon.nocache.js"></script>
</head>
<!-- -->
<!-- The body can have arbitrary html, or -->
<!-- you can leave the body empty if you want -->
<!-- to create a completely dynamic UI. -->
<!-- -->
<body>
<!-- OPTIONAL: include this if you want history support -->
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
<!-- RECOMMENDED if your web app will not function without JavaScript enabled -->
<noscript>
<div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
Your web browser must have JavaScript enabled
in order for this application to display correctly.
</div>
</noscript>
<h1>Web Application Starter Project</h1>
<table align="center">
<tr>
<td colspan="2" style="font-weight:bold;">Please enter your name:</td>
</tr>
<tr>
<td id="nameFieldContainer"></td>
<td id="sendButtonContainer"></td>
</tr>
<tr>
<td colspan="2" style="color:red;" id="errorLabelContainer"></td>
</tr>
</table>
</body>
</html>

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>GRSFCommon.html</welcome-file>
</welcome-file-list>
</web-app>

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to="GRSFCommon">
<!-- Inherit our applications main module. -->
<inherits name='org.gcube.datacatalogue.grsf_common_library.GRSFCommon' />
<!-- Specify the path to any remote services. -->
<servlet path="/GRSFCommon/greet" class="org.gcube.datacatalogue.grsf_common_library.server.GreetingServiceImpl" />
</module>
Loading…
Cancel
Save