release 4.3
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/branches/data-access/spd-client-library/4.0@141993 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
commit
d23b6b7080
|
@ -0,0 +1,36 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry excluding="**" kind="src" output="target/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.7">
|
||||||
|
<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/classes"/>
|
||||||
|
</classpath>
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>spd-client-library</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
|
@ -0,0 +1,7 @@
|
||||||
|
#Fri Sep 20 15:12:31 CEST 2013
|
||||||
|
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/<project>=UTF-8
|
|
@ -0,0 +1,5 @@
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||||
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||||
|
org.eclipse.jdt.core.compiler.source=1.7
|
|
@ -0,0 +1,5 @@
|
||||||
|
#Fri Jul 06 19:36:30 CEST 2012
|
||||||
|
activeProfiles=
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
resolveWorkspaceProjects=true
|
||||||
|
version=1
|
|
@ -0,0 +1 @@
|
||||||
|
Used as a Library in the gCube Framework
|
|
@ -0,0 +1,6 @@
|
||||||
|
gCube System - License
|
||||||
|
------------------------------------------------------------
|
||||||
|
|
||||||
|
The gCube/gCore software is licensed as Free Open Source software conveying to the EUPL (http://ec.europa.eu/idabc/eupl).
|
||||||
|
The software and documentation is provided by its authors/distributors "as is" and no expressed or
|
||||||
|
implied warranty is given for its use, quality or fitness for a particular case.
|
|
@ -0,0 +1,2 @@
|
||||||
|
Lucio lelii (lucio.lelii@isti.cnr.it), CNR Pisa,
|
||||||
|
Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo".
|
|
@ -0,0 +1,47 @@
|
||||||
|
The gCube System - spd client library
|
||||||
|
|
||||||
|
------------------------------------------------------------
|
||||||
|
|
||||||
|
This work has been partially supported by the following European projects: DILIGENT (FP6-2003-IST-2),
|
||||||
|
D4Science (FP7-INFRA-2007-1.2.2), D4Science-II (FP7-INFRA-2008-1.2.2), iMarine (FP7-INFRASTRUCTURES-2011-2),
|
||||||
|
and EUBrazilOpenBio (FP7-ICT-2011-EU-Brazil).
|
||||||
|
|
||||||
|
|
||||||
|
Authors
|
||||||
|
-------
|
||||||
|
|
||||||
|
* Lucio Lelii (lucio.lelii@isti.cnr.it), CNR Pisa,
|
||||||
|
Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo".
|
||||||
|
|
||||||
|
|
||||||
|
Version and Release Date
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
v. 1.0.0 (04-05-2012)
|
||||||
|
* First release
|
||||||
|
|
||||||
|
|
||||||
|
Description
|
||||||
|
-----------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Download information
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Documentation
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Documentation is available on-line from the Projects Documentation Wiki:
|
||||||
|
https://gcube.wiki.gcube-system.org/gcube/index.php/Biodiversity_Access
|
||||||
|
|
||||||
|
|
||||||
|
Licensing
|
||||||
|
---------
|
||||||
|
|
||||||
|
This software is licensed under the terms you may find in the file named "LICENSE" in this directory.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
<ReleaseNotes>
|
||||||
|
<Changeset component="org.gcube.data-access.spd-client-library.1-0-0" date="2012-09-14">
|
||||||
|
<Change>species products discovery client library release</Change>
|
||||||
|
</Changeset>
|
||||||
|
<Changeset component="org.gcube.data-access.spd-client-library.1-1-0" date="2012-10-18">
|
||||||
|
<Change>new calls added</Change>
|
||||||
|
</Changeset>
|
||||||
|
<Changeset component="org.gcube.data-access.spd-client-library.1-2-0" date="2012-11-30">
|
||||||
|
<Change>new calls from execution portType</Change>
|
||||||
|
</Changeset>
|
||||||
|
<Changeset component="org.gcube.data-access.spd-client-library.2-0-0" date="2013-01-17">
|
||||||
|
<Change>porting to FWK framework</Change>
|
||||||
|
</Changeset>
|
||||||
|
<Changeset component="org.gcube.data-access.spd-client-library.3-0-0" date="2013-05-02">
|
||||||
|
<Change>porting to spd model 2.0.0 </Change>
|
||||||
|
</Changeset>
|
||||||
|
<Changeset component="org.gcube.data-access.spd-client-library.3-0-1" date="2013-07-18">
|
||||||
|
<Change>better exception management added</Change>
|
||||||
|
<Change>getErrorLink added to Execution PortType</Change>
|
||||||
|
</Changeset>
|
||||||
|
<Changeset component="org.gcube.data-access.spd-client-library.3-1-1" date="2013-10-24">
|
||||||
|
<Change>changed return of getPluginDescription in case of empty set of plugins</Change>
|
||||||
|
</Changeset>
|
||||||
|
<Changeset component="org.gcube.data-access.spd-client-library.4-0-0" date="2017-02-01">
|
||||||
|
<Change>moved to smartgears</Change>
|
||||||
|
</Changeset>
|
||||||
|
</ReleaseNotes>
|
|
@ -0,0 +1,42 @@
|
||||||
|
<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>INSTALL</include>
|
||||||
|
<include>MAINTAINERS</include>
|
||||||
|
<include>changelog.xml</include>
|
||||||
|
</includes>
|
||||||
|
<fileMode>755</fileMode>
|
||||||
|
<filtered>true</filtered>
|
||||||
|
</fileSet>
|
||||||
|
</fileSets>
|
||||||
|
<files>
|
||||||
|
<file>
|
||||||
|
<source>${distroDirectory}/profile.xml</source>
|
||||||
|
<outputDirectory>/</outputDirectory>
|
||||||
|
<filtered>true</filtered>
|
||||||
|
</file>
|
||||||
|
<file>
|
||||||
|
<source>target/${build.finalName}.jar</source>
|
||||||
|
<outputDirectory>/${artifactId}</outputDirectory>
|
||||||
|
</file>
|
||||||
|
<file>
|
||||||
|
<source>${distroDirectory}/svnpath.txt</source>
|
||||||
|
<outputDirectory>/${artifactId}</outputDirectory>
|
||||||
|
<filtered>true</filtered>
|
||||||
|
</file>
|
||||||
|
</files>
|
||||||
|
</assembly>
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Resource>
|
||||||
|
<ID></ID>
|
||||||
|
<Type>Service</Type>
|
||||||
|
<Profile>
|
||||||
|
<Description>${description}</Description>
|
||||||
|
<Class>DataAccess</Class>
|
||||||
|
<Name>${artifactId}</Name>
|
||||||
|
<Version>1.0.0</Version>
|
||||||
|
<Packages>
|
||||||
|
<Software>
|
||||||
|
<Description>${description}</Description>
|
||||||
|
<Name>${artifactId}</Name>
|
||||||
|
<Version>${version}</Version>
|
||||||
|
<MavenCoordinates>
|
||||||
|
<groupId>${groupId}</groupId>
|
||||||
|
<artifactId>${artifactId}</artifactId>
|
||||||
|
<version>${version}</version>
|
||||||
|
</MavenCoordinates>
|
||||||
|
<Type>library</Type>
|
||||||
|
<Files>
|
||||||
|
<File>${build.finalName}.jar</File>
|
||||||
|
</Files>
|
||||||
|
</Software>
|
||||||
|
</Packages>
|
||||||
|
</Profile>
|
||||||
|
</Resource>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,104 @@
|
||||||
|
<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/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<artifactId>maven-parent</artifactId>
|
||||||
|
<groupId>org.gcube.tools</groupId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<groupId>org.gcube.data.spd</groupId>
|
||||||
|
<artifactId>spd-client-library</artifactId>
|
||||||
|
<version>4.0.0-SNAPSHOT</version>
|
||||||
|
<name>spd-client-library</name>
|
||||||
|
<description>species products discovery client library</description>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.distribution</groupId>
|
||||||
|
<artifactId>gcube-bom</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.data.spd</groupId>
|
||||||
|
<artifactId>spd-model</artifactId>
|
||||||
|
<version>[3.0.0-SNAPSHOT, 4.0.0-SNAPSHOT)</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.core</groupId>
|
||||||
|
<artifactId>common-gcube-calls</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.common</groupId>
|
||||||
|
<artifactId>common-jaxrs-client</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.data.access</groupId>
|
||||||
|
<artifactId>streams</artifactId>
|
||||||
|
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.core</groupId>
|
||||||
|
<artifactId>common-generic-clients</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.glassfish.jersey.core</groupId>
|
||||||
|
<artifactId>jersey-client</artifactId>
|
||||||
|
<version>2.24.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.glassfish.jersey.media</groupId>
|
||||||
|
<artifactId>jersey-media-jaxb</artifactId>
|
||||||
|
<version>2.24.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
|
<version>1.6.4</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>4.10</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>local-deploy</id>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.gcube.tools</groupId>
|
||||||
|
<artifactId>maven-service-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>local-deploy</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,43 @@
|
||||||
|
package org.gcube.data.spd.client;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.xml.namespace.QName;
|
||||||
|
|
||||||
|
public class Constants {
|
||||||
|
|
||||||
|
/** Service name. */
|
||||||
|
public static final String SERVICE_NAME = "SpeciesProductsDiscovery";
|
||||||
|
|
||||||
|
/** Service class. */
|
||||||
|
public static final String SERVICE_CLASS = "DataAccess";
|
||||||
|
|
||||||
|
public static final int DEFAULT_TIMEOUT= (int) TimeUnit.SECONDS.toMillis(10);
|
||||||
|
|
||||||
|
public static final String NAMESPACE = "http://gcube-system.org/namespaces/data/speciesproductsdiscovery";
|
||||||
|
|
||||||
|
public static final QName MANAGER_QNAME = new QName(NAMESPACE, "manager");
|
||||||
|
|
||||||
|
public static final QName CLASSIFICATION_QNAME = new QName(NAMESPACE, "classification");
|
||||||
|
|
||||||
|
public static final QName OCCURRENCE_QNAME = new QName(NAMESPACE, "occurrence");
|
||||||
|
|
||||||
|
public static final QName EXECUTOR_QNAME = new QName(NAMESPACE, "executor");
|
||||||
|
|
||||||
|
public static final QName RESULTSET_QNAME = new QName(NAMESPACE, "resultset");
|
||||||
|
|
||||||
|
/*
|
||||||
|
public static final GcubeService<ManagerStubs> manager = service().withName(org.gcube.data.spd.model.service.Constants.manager_name).andInterface(ManagerStubs.class);
|
||||||
|
|
||||||
|
public static final GcubeService<ClassificationStubs> classification = service().withName(org.gcube.data.spd.model.service.Constants.classification_name).andInterface(ClassificationStubs.class);
|
||||||
|
|
||||||
|
public static final GcubeService<ExecutorStubs> executor = service().withName(org.gcube.data.spd.model.service.Constants.executor_name).andInterface(ExecutorStubs.class);
|
||||||
|
|
||||||
|
public static final GcubeService<OccurrenceStubs> occurrence = service().withName(org.gcube.data.spd.model.service.Constants.occurrence_name).andInterface(OccurrenceStubs.class);
|
||||||
|
|
||||||
|
private static final GcubeService<RemoteDispatcher> remoteDispatcher = service().withName(org.gcube.data.spd.model.service.Constants.remoteDispatcher_name).andInterface(RemoteDispatcher.class);
|
||||||
|
|
||||||
|
public static final RemoteDispatcher getRemoteDispatcherService(String address){
|
||||||
|
return stubFor(remoteDispatcher).at(address);
|
||||||
|
}*/
|
||||||
|
}
|
|
@ -0,0 +1,177 @@
|
||||||
|
package org.gcube.data.spd.client;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.xml.stream.XMLEventReader;
|
||||||
|
import javax.xml.stream.XMLEventWriter;
|
||||||
|
import javax.xml.stream.XMLInputFactory;
|
||||||
|
import javax.xml.stream.XMLOutputFactory;
|
||||||
|
import javax.xml.stream.XMLStreamConstants;
|
||||||
|
import javax.xml.stream.XMLStreamException;
|
||||||
|
import javax.xml.stream.events.EndElement;
|
||||||
|
import javax.xml.stream.events.StartElement;
|
||||||
|
import javax.xml.stream.events.XMLEvent;
|
||||||
|
|
||||||
|
import org.gcube.data.spd.client.plugins.AbstractPlugin;
|
||||||
|
import org.gcube.data.spd.client.proxies.ResultSetClient;
|
||||||
|
import org.glassfish.jersey.client.ChunkParser;
|
||||||
|
import org.glassfish.jersey.client.ChunkedInput;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
public abstract class JerseyRecordIterator<T> implements Iterator<T>, Closeable{
|
||||||
|
|
||||||
|
private Logger logger = LoggerFactory.getLogger(JerseyRecordIterator.class);
|
||||||
|
|
||||||
|
private ChunkedInput<String> chunkedInput;
|
||||||
|
|
||||||
|
private LinkedBlockingQueue<String> queue = new LinkedBlockingQueue<String>();
|
||||||
|
|
||||||
|
private long INTERNAL_TIMEOUT_IN_MILLIS = 1000;
|
||||||
|
|
||||||
|
private long timeoutInMillis;
|
||||||
|
|
||||||
|
private ResultSetClient resultSetClient;
|
||||||
|
|
||||||
|
private String locator;
|
||||||
|
|
||||||
|
private ChunkedInputReader chunkedInputReader;
|
||||||
|
|
||||||
|
public JerseyRecordIterator(ResultLocator locator, long timeout, TimeUnit timeoutUnit) {
|
||||||
|
this.resultSetClient = AbstractPlugin.resultset().at(locator.getHost(), locator.getPort()).build();
|
||||||
|
this.locator = locator.getLocator();
|
||||||
|
this.timeoutInMillis = timeoutUnit.toMillis(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
String currentElement;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
if (this.chunkedInput==null)
|
||||||
|
initializeChunckedInput();
|
||||||
|
|
||||||
|
|
||||||
|
if (chunkedInput.isClosed() && queue.isEmpty()) return false;
|
||||||
|
try {
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
|
String retrievedElement = null;
|
||||||
|
while(retrievedElement==null && (System.currentTimeMillis()-startTime)<=timeoutInMillis
|
||||||
|
&& (!chunkedInput.isClosed() || !queue.isEmpty() ))
|
||||||
|
retrievedElement = queue.poll(INTERNAL_TIMEOUT_IN_MILLIS, TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
|
currentElement = retrievedElement;
|
||||||
|
return currentElement!=null;
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
logger.warn("timeout expired", e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeChunckedInput(){
|
||||||
|
this.chunkedInput = resultSetClient.getResultSet(locator);
|
||||||
|
this.chunkedInput.setParser(new RecordChunkParser());
|
||||||
|
this.chunkedInputReader = new ChunkedInputReader();
|
||||||
|
this.chunkedInputReader.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T next() {
|
||||||
|
try {
|
||||||
|
return convertFromString(currentElement);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn("error deserializing element", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract T convertFromString(String element);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove() {
|
||||||
|
chunkedInput.close();
|
||||||
|
this.chunkedInputReader.interrupt();
|
||||||
|
resultSetClient.closeResultSet(locator);
|
||||||
|
queue = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException {
|
||||||
|
logger.debug("closing iterator");
|
||||||
|
this.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class RecordChunkParser implements ChunkParser{
|
||||||
|
|
||||||
|
public byte[] readChunk(InputStream responseStream) throws IOException {
|
||||||
|
XMLEventReader xmlr =null;
|
||||||
|
XMLOutputFactory of =null;
|
||||||
|
XMLEventWriter xmlSW =null;
|
||||||
|
try{
|
||||||
|
XMLInputFactory xmlif = XMLInputFactory.newInstance();
|
||||||
|
xmlr = xmlif.createXMLEventReader(responseStream);
|
||||||
|
of = XMLOutputFactory.newInstance();
|
||||||
|
xmlSW = null;
|
||||||
|
StringWriter sw=new StringWriter();
|
||||||
|
while (xmlr.hasNext() && queue!=null) {
|
||||||
|
XMLEvent e = xmlr.nextEvent();
|
||||||
|
int eventType = e.getEventType();
|
||||||
|
if (eventType == XMLStreamConstants.START_ELEMENT
|
||||||
|
&& ((StartElement) e).getName().getLocalPart().equals("Result")) {
|
||||||
|
xmlSW = of.createXMLEventWriter(sw);
|
||||||
|
} else if (eventType == XMLStreamConstants.END_ELEMENT
|
||||||
|
&& ((EndElement) e).getName().getLocalPart().equals("Result")) {
|
||||||
|
queue.add(sw.toString());
|
||||||
|
sw=new StringWriter();
|
||||||
|
xmlSW.close();
|
||||||
|
xmlSW= null;
|
||||||
|
}else if ( eventType == XMLStreamConstants.END_ELEMENT && ((EndElement) e).getName().getLocalPart().equals("Results")){
|
||||||
|
//THE STREAM IS ARRIVED
|
||||||
|
break;
|
||||||
|
} else if (xmlSW!=null){
|
||||||
|
xmlSW.add(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("error parsing the input",e);
|
||||||
|
throw new IOException(e);
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (xmlr!=null)
|
||||||
|
xmlr.close();
|
||||||
|
} catch (XMLStreamException e) {
|
||||||
|
logger.warn("error closing the event reader",e);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (xmlSW!=null)
|
||||||
|
xmlSW.close();
|
||||||
|
} catch (XMLStreamException e) {
|
||||||
|
logger.warn("error closing the event writer",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class ChunkedInputReader extends Thread{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
while (!chunkedInput.isClosed() && chunkedInput.read() != null) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package org.gcube.data.spd.client;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.xml.bind.JAXBException;
|
||||||
|
|
||||||
|
import org.gcube.data.spd.model.binding.Bindings;
|
||||||
|
import org.gcube.data.spd.model.products.ResultElement;
|
||||||
|
|
||||||
|
public class ResultElementRecordIterator<T extends ResultElement> extends JerseyRecordIterator<T> {
|
||||||
|
|
||||||
|
public ResultElementRecordIterator(ResultLocator locator,
|
||||||
|
long timeout, TimeUnit timeoutUnit) {
|
||||||
|
super(locator, timeout, timeoutUnit);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T convertFromString(String element) {
|
||||||
|
try {
|
||||||
|
return Bindings.fromXml(currentElement);
|
||||||
|
} catch (JAXBException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package org.gcube.data.spd.client;
|
||||||
|
|
||||||
|
import gr.uoa.di.madgik.grs.record.GenericRecord;
|
||||||
|
import gr.uoa.di.madgik.grs.record.field.StringField;
|
||||||
|
|
||||||
|
import org.gcube.data.spd.model.binding.Bindings;
|
||||||
|
import org.gcube.data.streams.exceptions.StreamSkipSignal;
|
||||||
|
import org.gcube.data.streams.generators.Generator;
|
||||||
|
|
||||||
|
public class ResultGenerator<T> implements Generator<GenericRecord, T> {
|
||||||
|
|
||||||
|
|
||||||
|
public ResultGenerator(){}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T yield(GenericRecord record) {
|
||||||
|
try {
|
||||||
|
return Bindings.<T>fromXml(((StringField)record.getField("result")).getPayload());
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new StreamSkipSignal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package org.gcube.data.spd.client;
|
||||||
|
|
||||||
|
public class ResultLocator {
|
||||||
|
|
||||||
|
private String host;
|
||||||
|
private int port;
|
||||||
|
private String locator;
|
||||||
|
|
||||||
|
public ResultLocator(String host, int port, String locator) {
|
||||||
|
super();
|
||||||
|
this.host = host;
|
||||||
|
this.port = port;
|
||||||
|
this.locator = locator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHost() {
|
||||||
|
return host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPort() {
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocator() {
|
||||||
|
return locator;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package org.gcube.data.spd.client;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
public class Utils {
|
||||||
|
|
||||||
|
public static String getLocatorFromResponse(Response response){
|
||||||
|
String path = response.getLocation().getPath();
|
||||||
|
String[] splitPath = path.split("/");
|
||||||
|
String locator = splitPath[splitPath.length-1].isEmpty()?splitPath[splitPath.length-2]:splitPath[splitPath.length-1];
|
||||||
|
return locator;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
package org.gcube.data.spd.client.plugins;
|
||||||
|
|
||||||
|
import javax.ws.rs.client.WebTarget;
|
||||||
|
|
||||||
|
import org.gcube.common.clients.Plugin;
|
||||||
|
import org.gcube.common.clients.ProxyBuilder;
|
||||||
|
import org.gcube.common.clients.ProxyBuilderImpl;
|
||||||
|
import org.gcube.data.spd.client.Constants;
|
||||||
|
import org.gcube.data.spd.client.proxies.ClassificationClient;
|
||||||
|
import org.gcube.data.spd.client.proxies.ExecutorClient;
|
||||||
|
import org.gcube.data.spd.client.proxies.ManagerClient;
|
||||||
|
import org.gcube.data.spd.client.proxies.OccurrenceClient;
|
||||||
|
import org.gcube.data.spd.client.proxies.ResultSetClient;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public abstract class AbstractPlugin<S,P> implements Plugin<S,P> {
|
||||||
|
|
||||||
|
private static final ManagerPlugin manager_plugin = new ManagerPlugin();
|
||||||
|
private static final OccurrencePlugin occurrence_plugin = new OccurrencePlugin();
|
||||||
|
private static final ClassificationPlugin classification_plugin = new ClassificationPlugin();
|
||||||
|
private static final ExecutorPlugin executor_plugin = new ExecutorPlugin();
|
||||||
|
private static final ResultSetPlugin resultset_plugin = new ResultSetPlugin();
|
||||||
|
|
||||||
|
|
||||||
|
public static ProxyBuilder<ManagerClient> manager() {
|
||||||
|
return new ProxyBuilderImpl<WebTarget,ManagerClient>(manager_plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProxyBuilder<ClassificationClient> classification() {
|
||||||
|
return new ProxyBuilderImpl<WebTarget,ClassificationClient>(classification_plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProxyBuilder<OccurrenceClient> occurrences() {
|
||||||
|
return new ProxyBuilderImpl<WebTarget,OccurrenceClient>(occurrence_plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProxyBuilder<ExecutorClient> executor() {
|
||||||
|
return new ProxyBuilderImpl<WebTarget,ExecutorClient>(executor_plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProxyBuilder<ResultSetClient> resultset() {
|
||||||
|
return new ProxyBuilderImpl<WebTarget,ResultSetClient>(resultset_plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final String name;
|
||||||
|
|
||||||
|
public AbstractPlugin(String name) {
|
||||||
|
this.name=name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String serviceClass() {
|
||||||
|
return Constants.SERVICE_CLASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String serviceName() {
|
||||||
|
return Constants.SERVICE_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String namespace() {
|
||||||
|
return Constants.NAMESPACE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String name() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
package org.gcube.data.spd.client.plugins;
|
||||||
|
|
||||||
|
import javax.ws.rs.client.WebTarget;
|
||||||
|
import javax.xml.transform.dom.DOMResult;
|
||||||
|
import javax.xml.ws.EndpointReference;
|
||||||
|
|
||||||
|
import org.gcube.common.calls.jaxrs.GcubeService;
|
||||||
|
import org.gcube.common.calls.jaxrs.TargetFactory;
|
||||||
|
import org.gcube.common.clients.config.ProxyConfig;
|
||||||
|
import org.gcube.common.clients.delegates.ProxyDelegate;
|
||||||
|
import org.gcube.data.spd.client.Constants;
|
||||||
|
import org.gcube.data.spd.client.proxies.ClassificationClient;
|
||||||
|
import org.gcube.data.spd.client.proxies.DefaultClassification;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
|
||||||
|
|
||||||
|
public class ClassificationPlugin extends AbstractPlugin<WebTarget,ClassificationClient> {
|
||||||
|
|
||||||
|
public ClassificationPlugin() {
|
||||||
|
super("species-products-discovery/gcube/service");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Exception convert(Exception e, ProxyConfig<?, ?> arg1) {
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClassificationClient newProxy(ProxyDelegate<WebTarget> delegate) {
|
||||||
|
return new DefaultClassification(delegate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WebTarget resolve(EndpointReference epr, ProxyConfig<?, ?> config)
|
||||||
|
throws Exception {
|
||||||
|
DOMResult result = new DOMResult();
|
||||||
|
epr.writeTo(result);
|
||||||
|
Node node =result.getNode();
|
||||||
|
Node child=node.getFirstChild();
|
||||||
|
String address = child.getTextContent();
|
||||||
|
GcubeService service = GcubeService.service().withName(Constants.CLASSIFICATION_QNAME).andPath("taxon");
|
||||||
|
return TargetFactory.stubFor(service).at(address);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
package org.gcube.data.spd.client.plugins;
|
||||||
|
|
||||||
|
import javax.ws.rs.client.WebTarget;
|
||||||
|
import javax.xml.transform.dom.DOMResult;
|
||||||
|
import javax.xml.ws.EndpointReference;
|
||||||
|
|
||||||
|
import org.gcube.common.calls.jaxrs.GcubeService;
|
||||||
|
import org.gcube.common.calls.jaxrs.TargetFactory;
|
||||||
|
import org.gcube.common.clients.config.ProxyConfig;
|
||||||
|
import org.gcube.common.clients.delegates.ProxyDelegate;
|
||||||
|
import org.gcube.data.spd.client.Constants;
|
||||||
|
import org.gcube.data.spd.client.proxies.DefaultExecutor;
|
||||||
|
import org.gcube.data.spd.client.proxies.ExecutorClient;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
|
||||||
|
public class ExecutorPlugin extends AbstractPlugin<WebTarget, ExecutorClient> {
|
||||||
|
|
||||||
|
public ExecutorPlugin() {
|
||||||
|
super("species-products-discovery/gcube/service");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Exception convert(Exception e, ProxyConfig<?, ?> arg1) {
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ExecutorClient newProxy(ProxyDelegate<WebTarget> delegate) {
|
||||||
|
return new DefaultExecutor(delegate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WebTarget resolve(EndpointReference epr, ProxyConfig<?, ?> config)
|
||||||
|
throws Exception {
|
||||||
|
DOMResult result = new DOMResult();
|
||||||
|
epr.writeTo(result);
|
||||||
|
Node node =result.getNode();
|
||||||
|
Node child=node.getFirstChild();
|
||||||
|
String address = child.getTextContent();
|
||||||
|
GcubeService service = GcubeService.service().withName(Constants.EXECUTOR_QNAME).andPath("job");
|
||||||
|
return TargetFactory.stubFor(service).at(address);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
package org.gcube.data.spd.client.plugins;
|
||||||
|
|
||||||
|
import javax.ws.rs.client.WebTarget;
|
||||||
|
import javax.xml.transform.dom.DOMResult;
|
||||||
|
import javax.xml.ws.EndpointReference;
|
||||||
|
|
||||||
|
import org.gcube.common.calls.jaxrs.GcubeService;
|
||||||
|
import org.gcube.common.calls.jaxrs.TargetFactory;
|
||||||
|
import org.gcube.common.clients.config.ProxyConfig;
|
||||||
|
import org.gcube.common.clients.delegates.ProxyDelegate;
|
||||||
|
import org.gcube.data.spd.client.Constants;
|
||||||
|
import org.gcube.data.spd.client.proxies.DefaultManager;
|
||||||
|
import org.gcube.data.spd.client.proxies.ManagerClient;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
|
||||||
|
public class ManagerPlugin extends AbstractPlugin<WebTarget, ManagerClient> {
|
||||||
|
|
||||||
|
public ManagerPlugin() {
|
||||||
|
super("species-products-discovery/gcube/service");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Exception convert(Exception e, ProxyConfig<?, ?> arg1) {
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ManagerClient newProxy(ProxyDelegate<WebTarget> delegate) {
|
||||||
|
return new DefaultManager(delegate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WebTarget resolve(EndpointReference epr, ProxyConfig<?, ?> config)
|
||||||
|
throws Exception {
|
||||||
|
DOMResult result = new DOMResult();
|
||||||
|
epr.writeTo(result);
|
||||||
|
Node node =result.getNode();
|
||||||
|
Node child=node.getFirstChild();
|
||||||
|
String address = child.getTextContent();
|
||||||
|
GcubeService service = GcubeService.service().withName(Constants.MANAGER_QNAME).andPath("retrieve");
|
||||||
|
return TargetFactory.stubFor(service).at(address);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package org.gcube.data.spd.client.plugins;
|
||||||
|
|
||||||
|
import javax.ws.rs.client.WebTarget;
|
||||||
|
import javax.xml.transform.dom.DOMResult;
|
||||||
|
import javax.xml.ws.EndpointReference;
|
||||||
|
|
||||||
|
import org.gcube.common.calls.jaxrs.GcubeService;
|
||||||
|
import org.gcube.common.calls.jaxrs.TargetFactory;
|
||||||
|
import org.gcube.common.clients.config.ProxyConfig;
|
||||||
|
import org.gcube.common.clients.delegates.ProxyDelegate;
|
||||||
|
import org.gcube.data.spd.client.Constants;
|
||||||
|
import org.gcube.data.spd.client.proxies.DefaultOccurrence;
|
||||||
|
import org.gcube.data.spd.client.proxies.OccurrenceClient;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
|
||||||
|
public class OccurrencePlugin extends AbstractPlugin<WebTarget, OccurrenceClient> {
|
||||||
|
|
||||||
|
public OccurrencePlugin(){
|
||||||
|
super("species-products-discovery/gcube/service");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Exception convert(Exception e, ProxyConfig<?, ?> arg1) {
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OccurrenceClient newProxy(ProxyDelegate<WebTarget> delegate) {
|
||||||
|
return new DefaultOccurrence(delegate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WebTarget resolve(EndpointReference epr, ProxyConfig<?, ?> config)
|
||||||
|
throws Exception {
|
||||||
|
DOMResult result = new DOMResult();
|
||||||
|
epr.writeTo(result);
|
||||||
|
Node node =result.getNode();
|
||||||
|
Node child=node.getFirstChild();
|
||||||
|
String address = child.getTextContent();
|
||||||
|
GcubeService service = GcubeService.service().withName(Constants.OCCURRENCE_QNAME).andPath("occurrence");
|
||||||
|
return TargetFactory.stubFor(service).at(address);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package org.gcube.data.spd.client.plugins;
|
||||||
|
|
||||||
|
import javax.ws.rs.client.WebTarget;
|
||||||
|
import javax.xml.transform.dom.DOMResult;
|
||||||
|
import javax.xml.ws.EndpointReference;
|
||||||
|
|
||||||
|
import org.gcube.common.calls.jaxrs.GcubeService;
|
||||||
|
import org.gcube.common.calls.jaxrs.TargetFactory;
|
||||||
|
import org.gcube.common.clients.config.ProxyConfig;
|
||||||
|
import org.gcube.common.clients.delegates.ProxyDelegate;
|
||||||
|
import org.gcube.data.spd.client.Constants;
|
||||||
|
import org.gcube.data.spd.client.proxies.DefaultResultSet;
|
||||||
|
import org.gcube.data.spd.client.proxies.ResultSetClient;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
|
||||||
|
public class ResultSetPlugin extends AbstractPlugin<WebTarget, ResultSetClient> {
|
||||||
|
|
||||||
|
public ResultSetPlugin(){
|
||||||
|
super("species-products-discovery/gcube/service");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Exception convert(Exception e, ProxyConfig<?, ?> arg1) {
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResultSetClient newProxy(ProxyDelegate<WebTarget> delegate) {
|
||||||
|
return new DefaultResultSet(delegate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WebTarget resolve(EndpointReference epr, ProxyConfig<?, ?> config)
|
||||||
|
throws Exception {
|
||||||
|
DOMResult result = new DOMResult();
|
||||||
|
epr.writeTo(result);
|
||||||
|
Node node =result.getNode();
|
||||||
|
Node child=node.getFirstChild();
|
||||||
|
String address = child.getTextContent();
|
||||||
|
GcubeService service = GcubeService.service().withName(Constants.RESULTSET_QNAME).andPath("resultset");
|
||||||
|
return TargetFactory.stubFor(service).at(address);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package org.gcube.data.spd.client.proxies;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.data.spd.model.products.TaxonomyItem;
|
||||||
|
import org.gcube.data.spd.model.service.exceptions.InvalidIdentifierException;
|
||||||
|
import org.gcube.data.spd.model.service.exceptions.UnsupportedCapabilityException;
|
||||||
|
import org.gcube.data.spd.model.service.exceptions.UnsupportedPluginException;
|
||||||
|
import org.gcube.data.streams.Stream;
|
||||||
|
|
||||||
|
public interface ClassificationClient {
|
||||||
|
|
||||||
|
public Stream<TaxonomyItem> getTaxonChildrenById(String id) throws UnsupportedPluginException,UnsupportedCapabilityException, InvalidIdentifierException;
|
||||||
|
|
||||||
|
public Stream<TaxonomyItem> getTaxaByIds(List<String> ids);
|
||||||
|
|
||||||
|
public Stream<TaxonomyItem> getTaxonTreeById(String id) throws UnsupportedPluginException,UnsupportedCapabilityException, InvalidIdentifierException;
|
||||||
|
|
||||||
|
public Stream<TaxonomyItem> getSynonymsById(String id) throws UnsupportedPluginException,UnsupportedCapabilityException, InvalidIdentifierException;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,115 @@
|
||||||
|
package org.gcube.data.spd.client.proxies;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.ws.rs.client.WebTarget;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
import org.gcube.common.clients.Call;
|
||||||
|
import org.gcube.common.clients.delegates.ProxyDelegate;
|
||||||
|
import org.gcube.data.spd.client.ResultElementRecordIterator;
|
||||||
|
import org.gcube.data.spd.client.ResultLocator;
|
||||||
|
import org.gcube.data.spd.client.Utils;
|
||||||
|
import org.gcube.data.spd.model.products.TaxonomyItem;
|
||||||
|
import org.gcube.data.spd.model.service.exceptions.InvalidIdentifierException;
|
||||||
|
import org.gcube.data.spd.model.service.exceptions.UnsupportedCapabilityException;
|
||||||
|
import org.gcube.data.spd.model.service.exceptions.UnsupportedPluginException;
|
||||||
|
import org.gcube.data.streams.Stream;
|
||||||
|
import org.gcube.data.streams.dsl.Streams;
|
||||||
|
|
||||||
|
public class DefaultClassification implements ClassificationClient{
|
||||||
|
|
||||||
|
private final ProxyDelegate<WebTarget> delegate;
|
||||||
|
|
||||||
|
public DefaultClassification(ProxyDelegate<WebTarget> config){
|
||||||
|
this.delegate = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Stream<TaxonomyItem> getTaxonChildrenById(final String id)
|
||||||
|
throws UnsupportedPluginException, UnsupportedCapabilityException,
|
||||||
|
InvalidIdentifierException {
|
||||||
|
Call<WebTarget, ResultLocator> call = new Call<WebTarget, ResultLocator>() {
|
||||||
|
@Override
|
||||||
|
public ResultLocator call(WebTarget manager) throws Exception {
|
||||||
|
Response response = manager.path("children").path(id).request().get(Response.class);
|
||||||
|
String host = manager.getUri().getHost();
|
||||||
|
int port = manager.getUri().getPort();
|
||||||
|
return new ResultLocator(host, port, Utils.getLocatorFromResponse(response));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
ResultLocator result = delegate.make(call);
|
||||||
|
ResultElementRecordIterator<TaxonomyItem> ri = new ResultElementRecordIterator<TaxonomyItem>(result, 2, TimeUnit.MINUTES);
|
||||||
|
return Streams.convert(ri);
|
||||||
|
}catch(Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO
|
||||||
|
@Override
|
||||||
|
public Stream<TaxonomyItem> getTaxaByIds(final List<String> ids) {
|
||||||
|
return null;
|
||||||
|
/*Call<WebTarget, ChunkedInput<String>> call = new Call<WebTarget, ChunkedInput<String>>() {
|
||||||
|
@Override
|
||||||
|
public ChunkedInput<String> call(WebTarget manager) throws Exception {
|
||||||
|
return null; }
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
return null;
|
||||||
|
}catch(Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Stream<TaxonomyItem> getTaxonTreeById(final String id)
|
||||||
|
throws UnsupportedPluginException, UnsupportedCapabilityException,
|
||||||
|
InvalidIdentifierException {
|
||||||
|
Call<WebTarget, ResultLocator> call = new Call<WebTarget, ResultLocator>() {
|
||||||
|
@Override
|
||||||
|
public ResultLocator call(WebTarget manager) throws Exception {
|
||||||
|
Response response = manager.path("tree").path(id).request().get(Response.class);
|
||||||
|
String host = manager.getUri().getHost();
|
||||||
|
int port = manager.getUri().getPort();
|
||||||
|
return new ResultLocator(host, port, Utils.getLocatorFromResponse(response));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
ResultLocator result = delegate.make(call);
|
||||||
|
ResultElementRecordIterator<TaxonomyItem> ri = new ResultElementRecordIterator<TaxonomyItem>(result, 2, TimeUnit.MINUTES);
|
||||||
|
|
||||||
|
return Streams.convert(ri);
|
||||||
|
}catch(Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Stream<TaxonomyItem> getSynonymsById(final String id)
|
||||||
|
throws UnsupportedPluginException, UnsupportedCapabilityException,
|
||||||
|
InvalidIdentifierException {
|
||||||
|
Call<WebTarget, ResultLocator> call = new Call<WebTarget, ResultLocator>() {
|
||||||
|
@Override
|
||||||
|
public ResultLocator call(WebTarget manager) throws Exception {
|
||||||
|
Response response = manager.path("synonyms").path(id).request().get(Response.class);
|
||||||
|
String host = manager.getUri().getHost();
|
||||||
|
int port = manager.getUri().getPort();
|
||||||
|
return new ResultLocator(host, port, Utils.getLocatorFromResponse(response));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
ResultLocator result = delegate.make(call);
|
||||||
|
ResultElementRecordIterator<TaxonomyItem> ri = new ResultElementRecordIterator<TaxonomyItem>(result, 2, TimeUnit.MINUTES);
|
||||||
|
|
||||||
|
return Streams.convert(ri);
|
||||||
|
}catch(Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,187 @@
|
||||||
|
package org.gcube.data.spd.client.proxies;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.ws.rs.client.Entity;
|
||||||
|
import javax.ws.rs.client.WebTarget;
|
||||||
|
|
||||||
|
import org.gcube.common.clients.Call;
|
||||||
|
import org.gcube.common.clients.delegates.ProxyDelegate;
|
||||||
|
import org.gcube.common.clients.stubs.jaxws.JAXWSUtils.Empty;
|
||||||
|
import org.gcube.data.spd.model.service.exceptions.InvalidIdentifierException;
|
||||||
|
import org.gcube.data.spd.model.service.types.CompleteJobStatus;
|
||||||
|
import org.gcube.data.spd.model.service.types.JobType;
|
||||||
|
import org.gcube.data.spd.model.service.types.SubmitJob;
|
||||||
|
import org.gcube.data.spd.model.util.SerializableList;
|
||||||
|
import org.gcube.data.streams.Stream;
|
||||||
|
|
||||||
|
public class DefaultExecutor implements ExecutorClient{
|
||||||
|
|
||||||
|
private final ProxyDelegate<WebTarget> delegate;
|
||||||
|
|
||||||
|
public DefaultExecutor(ProxyDelegate<WebTarget> delegate) {
|
||||||
|
super();
|
||||||
|
this.delegate = delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Call<WebTarget, String> getCallForJobs(final String input, final JobType job){
|
||||||
|
Call<WebTarget, String> call = new Call<WebTarget, String>() {
|
||||||
|
@Override
|
||||||
|
public String call(WebTarget executor) throws Exception {
|
||||||
|
SubmitJob jobRequest = new SubmitJob(input, job);
|
||||||
|
return executor.path("execute").request().post(Entity.xml(jobRequest), String.class);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return call;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getErrorLink(final String jobId) throws InvalidIdentifierException {
|
||||||
|
Call<WebTarget, String> call = new Call<WebTarget, String>() {
|
||||||
|
@Override
|
||||||
|
public String call(WebTarget executor) throws Exception {
|
||||||
|
return executor.path("error").path(jobId).request().get(String.class);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
return delegate.make(call);
|
||||||
|
}catch(Exception e) {
|
||||||
|
throw new InvalidIdentifierException();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getResultLink(final String jobId) throws InvalidIdentifierException {
|
||||||
|
Call<WebTarget, String> call = new Call<WebTarget, String>() {
|
||||||
|
@Override
|
||||||
|
public String call(WebTarget executor) throws Exception {
|
||||||
|
return executor.path("result").path(jobId).request().get(String.class);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
return delegate.make(call);
|
||||||
|
}catch(Exception e) {
|
||||||
|
throw new InvalidIdentifierException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompleteJobStatus getStatus(final String jobId)
|
||||||
|
throws InvalidIdentifierException {
|
||||||
|
Call<WebTarget, CompleteJobStatus> call = new Call<WebTarget, CompleteJobStatus>() {
|
||||||
|
@Override
|
||||||
|
public CompleteJobStatus call(WebTarget executor) throws Exception {
|
||||||
|
return executor.path("status").path(jobId).request().get(CompleteJobStatus.class);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
return delegate.make(call);
|
||||||
|
}catch(Exception e) {
|
||||||
|
throw new InvalidIdentifierException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeJob(final String jobId) throws InvalidIdentifierException {
|
||||||
|
Call<WebTarget, Empty> call = new Call<WebTarget, Empty>() {
|
||||||
|
@Override
|
||||||
|
public Empty call(WebTarget executor) throws Exception {
|
||||||
|
executor.path(jobId).request().delete();
|
||||||
|
return new Empty();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
delegate.make(call);
|
||||||
|
}catch(Exception e) {
|
||||||
|
throw new InvalidIdentifierException();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private Boolean sendInputCall(final String jobId, final List<String> input)
|
||||||
|
throws InvalidIdentifierException {
|
||||||
|
Call<WebTarget, Boolean> call = new Call<WebTarget, Boolean>() {
|
||||||
|
@Override
|
||||||
|
public Boolean call(WebTarget executor) throws Exception {
|
||||||
|
return executor.path("input").path(jobId).request().put(Entity.xml(new SerializableList<String>(input)), Boolean.class);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
return delegate.make(call);
|
||||||
|
}catch(Exception e) {
|
||||||
|
throw new InvalidIdentifierException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendInput(String jobId, Stream<String> stream) throws Exception{
|
||||||
|
int bunch = 30;
|
||||||
|
List<String> collected = new ArrayList<String>(30);
|
||||||
|
while (stream.hasNext()){
|
||||||
|
collected.add(stream.next());
|
||||||
|
if (collected.size()>=bunch){
|
||||||
|
if (!sendInputCall(jobId, collected))
|
||||||
|
throw new Exception();
|
||||||
|
collected.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (collected.size()>0)
|
||||||
|
if (!sendInputCall(jobId, collected))
|
||||||
|
throw new Exception();
|
||||||
|
|
||||||
|
sendInputCall(jobId, new ArrayList<String>(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String createDwCAByChildren(String taxonKey) throws Exception {
|
||||||
|
return delegate.make(getCallForJobs(taxonKey, JobType.DWCAByChildren));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String createDwCAByIds(Stream<String> ids) throws Exception {
|
||||||
|
String jobId = delegate.make(getCallForJobs(null, JobType.DWCAById));
|
||||||
|
try{
|
||||||
|
sendInput(jobId, ids);
|
||||||
|
}catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return jobId;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String createCSV(Stream<String> ids) throws Exception {
|
||||||
|
String jobId = delegate.make(getCallForJobs(null, JobType.CSV));
|
||||||
|
try{
|
||||||
|
sendInput(jobId, ids);
|
||||||
|
}catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return jobId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String createCSVforOM(Stream<String> ids) throws Exception {
|
||||||
|
String jobId = delegate.make(getCallForJobs(null, JobType.CSVForOM));
|
||||||
|
try{
|
||||||
|
sendInput(jobId, ids);
|
||||||
|
}catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return jobId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String createDarwincoreFromOccurrenceKeys(Stream<String> ids)
|
||||||
|
throws Exception {
|
||||||
|
String jobId = delegate.make(getCallForJobs(null, JobType.DarwinCore));
|
||||||
|
try{
|
||||||
|
sendInput(jobId, ids);
|
||||||
|
}catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return jobId;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
package org.gcube.data.spd.client.proxies;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.ws.rs.client.WebTarget;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
import org.gcube.common.clients.Call;
|
||||||
|
import org.gcube.common.clients.delegates.ProxyDelegate;
|
||||||
|
import org.gcube.data.spd.client.ResultElementRecordIterator;
|
||||||
|
import org.gcube.data.spd.client.ResultLocator;
|
||||||
|
import org.gcube.data.spd.client.Utils;
|
||||||
|
import org.gcube.data.spd.model.PluginDescription;
|
||||||
|
import org.gcube.data.spd.model.exceptions.InvalidQueryException;
|
||||||
|
import org.gcube.data.spd.model.products.ResultElement;
|
||||||
|
import org.gcube.data.spd.model.service.exceptions.UnsupportedCapabilityException;
|
||||||
|
import org.gcube.data.spd.model.service.exceptions.UnsupportedPluginException;
|
||||||
|
import org.gcube.data.spd.model.service.types.PluginDescriptions;
|
||||||
|
import org.gcube.data.streams.Stream;
|
||||||
|
import org.gcube.data.streams.dsl.Streams;
|
||||||
|
|
||||||
|
public class DefaultManager implements ManagerClient {
|
||||||
|
|
||||||
|
private final ProxyDelegate<WebTarget> delegate;
|
||||||
|
|
||||||
|
|
||||||
|
public DefaultManager(ProxyDelegate<WebTarget> config){
|
||||||
|
this.delegate = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends ResultElement> Stream<T> search(final String query)
|
||||||
|
throws InvalidQueryException, UnsupportedPluginException,
|
||||||
|
UnsupportedCapabilityException {
|
||||||
|
Call<WebTarget, ResultLocator> call = new Call<WebTarget, ResultLocator>() {
|
||||||
|
@Override
|
||||||
|
public ResultLocator call(WebTarget manager) throws Exception {
|
||||||
|
Response response = manager.path("search").queryParam("query", query).request().get(Response.class);
|
||||||
|
String host = manager.getUri().getHost();
|
||||||
|
int port = manager.getUri().getPort();
|
||||||
|
return new ResultLocator(host, port, Utils.getLocatorFromResponse(response));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
ResultLocator result = delegate.make(call);
|
||||||
|
|
||||||
|
ResultElementRecordIterator<T> ri = new ResultElementRecordIterator<T>(result, 2, TimeUnit.MINUTES);
|
||||||
|
return Streams.convert(ri);
|
||||||
|
}catch(Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PluginDescription> getPluginsDescription() {
|
||||||
|
Call<WebTarget, List<PluginDescription>> call = new Call<WebTarget, List<PluginDescription>>() {
|
||||||
|
@Override
|
||||||
|
public List<PluginDescription> call(WebTarget manager) throws Exception {
|
||||||
|
return manager.path("providers").request().get(PluginDescriptions.class).getDescriptions();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
return delegate.make(call);
|
||||||
|
}catch(Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,117 @@
|
||||||
|
package org.gcube.data.spd.client.proxies;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.ws.rs.client.WebTarget;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
import org.gcube.common.clients.Call;
|
||||||
|
import org.gcube.common.clients.delegates.ProxyDelegate;
|
||||||
|
import org.gcube.data.spd.client.ResultElementRecordIterator;
|
||||||
|
import org.gcube.data.spd.client.ResultLocator;
|
||||||
|
import org.gcube.data.spd.client.Utils;
|
||||||
|
import org.gcube.data.spd.model.PointInfo;
|
||||||
|
import org.gcube.data.spd.model.products.OccurrencePoint;
|
||||||
|
import org.gcube.data.streams.Stream;
|
||||||
|
import org.gcube.data.streams.dsl.Streams;
|
||||||
|
|
||||||
|
public class DefaultOccurrence implements OccurrenceClient {
|
||||||
|
|
||||||
|
private final ProxyDelegate<WebTarget> delegate;
|
||||||
|
|
||||||
|
public DefaultOccurrence(ProxyDelegate<WebTarget> config){
|
||||||
|
this.delegate = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Stream<OccurrencePoint> getByIds(final List<String> ids) {
|
||||||
|
Call<WebTarget, ResultLocator> call = new Call<WebTarget, ResultLocator>() {
|
||||||
|
@Override
|
||||||
|
public ResultLocator call(WebTarget manager) throws Exception {
|
||||||
|
manager = manager.path("ids");
|
||||||
|
for (String value: ids)
|
||||||
|
manager = manager.queryParam("ids", value);
|
||||||
|
System.out.println(manager.getUri().toString());
|
||||||
|
Response response = manager.request().get(Response.class);
|
||||||
|
String host = manager.getUri().getHost();
|
||||||
|
int port = manager.getUri().getPort();
|
||||||
|
return new ResultLocator(host, port, Utils.getLocatorFromResponse(response));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
ResultLocator result = delegate.make(call);
|
||||||
|
ResultElementRecordIterator<OccurrencePoint> ri = new ResultElementRecordIterator<OccurrencePoint>(result, 2, TimeUnit.MINUTES);
|
||||||
|
|
||||||
|
return Streams.convert(ri);
|
||||||
|
}catch(Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Stream<OccurrencePoint> getByKeys(final List<String> keys) {
|
||||||
|
Call<WebTarget, ResultLocator> call = new Call<WebTarget, ResultLocator>() {
|
||||||
|
@Override
|
||||||
|
public ResultLocator call(WebTarget manager) throws Exception {
|
||||||
|
manager = manager.path("keys");
|
||||||
|
for (String value: keys)
|
||||||
|
manager = manager.queryParam("keys", value);
|
||||||
|
System.out.println("calling "+manager.getUri().toString());
|
||||||
|
Response response = manager.request().get(Response.class);
|
||||||
|
String host = manager.getUri().getHost();
|
||||||
|
int port = manager.getUri().getPort();
|
||||||
|
return new ResultLocator(host, port, Utils.getLocatorFromResponse(response));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
ResultLocator result = delegate.make(call);
|
||||||
|
ResultElementRecordIterator<OccurrencePoint> ri = new ResultElementRecordIterator<OccurrencePoint>(result, 2, TimeUnit.MINUTES);
|
||||||
|
return Streams.convert(ri);
|
||||||
|
}catch(Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
@Override
|
||||||
|
public String createLayer(Stream<PointInfo> coordinatesStream) {
|
||||||
|
Stream<String> convertedStream = pipe(coordinatesStream).through(new Generator<PointInfo, String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String yield(PointInfo element) {
|
||||||
|
try {
|
||||||
|
return Bindings.toXml(element);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new StreamSkipSignal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
final String coordinateLocator = publishStringsIn(convertedStream).withDefaults().toString();
|
||||||
|
|
||||||
|
Call<OccurrenceStubs, String> call = new Call<OccurrenceStubs, String>() {
|
||||||
|
@Override
|
||||||
|
public String call(OccurrenceStubs occurrence) throws Exception {
|
||||||
|
return occurrence.createLayer(coordinateLocator);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
return delegate.make(call);
|
||||||
|
}catch(Exception e) {
|
||||||
|
throw again(e).asServiceException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String createLayer(Stream<PointInfo> coordinatesLocator) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
package org.gcube.data.spd.client.proxies;
|
||||||
|
|
||||||
|
import javax.ws.rs.client.WebTarget;
|
||||||
|
import javax.ws.rs.core.GenericType;
|
||||||
|
|
||||||
|
import org.gcube.common.clients.Call;
|
||||||
|
import org.gcube.common.clients.delegates.ProxyDelegate;
|
||||||
|
import org.gcube.common.clients.stubs.jaxws.JAXWSUtils.Empty;
|
||||||
|
import org.glassfish.jersey.client.ChunkedInput;
|
||||||
|
|
||||||
|
public class DefaultResultSet implements ResultSetClient {
|
||||||
|
|
||||||
|
private final ProxyDelegate<WebTarget> delegate;
|
||||||
|
|
||||||
|
public DefaultResultSet(ProxyDelegate<WebTarget> config){
|
||||||
|
this.delegate = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ChunkedInput<String> getResultSet(final String locator){
|
||||||
|
Call<WebTarget, ChunkedInput<String>> call = new Call<WebTarget, ChunkedInput<String>>() {
|
||||||
|
@Override
|
||||||
|
public ChunkedInput<String> call(WebTarget manager) throws Exception {
|
||||||
|
return manager.path(locator).request().get(new GenericType<ChunkedInput<String>>() {});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
return delegate.make(call);
|
||||||
|
|
||||||
|
}catch(Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void closeResultSet(final String locator){
|
||||||
|
Call<WebTarget, Empty> call = new Call<WebTarget, Empty>() {
|
||||||
|
@Override
|
||||||
|
public Empty call(WebTarget manager) throws Exception {
|
||||||
|
manager.path(locator).request().delete();
|
||||||
|
return new Empty();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
delegate.make(call);
|
||||||
|
}catch(Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package org.gcube.data.spd.client.proxies;
|
||||||
|
|
||||||
|
import org.gcube.data.spd.model.service.exceptions.InvalidIdentifierException;
|
||||||
|
import org.gcube.data.spd.model.service.types.CompleteJobStatus;
|
||||||
|
import org.gcube.data.streams.Stream;
|
||||||
|
|
||||||
|
public interface ExecutorClient {
|
||||||
|
|
||||||
|
public String createDwCAByChildren(String taxonKey) throws Exception;
|
||||||
|
|
||||||
|
public String getResultLink(String jobId) throws InvalidIdentifierException;
|
||||||
|
|
||||||
|
public String getErrorLink(String jobId) throws InvalidIdentifierException;
|
||||||
|
|
||||||
|
public CompleteJobStatus getStatus(String jobId) throws InvalidIdentifierException;
|
||||||
|
|
||||||
|
public void removeJob(String jobId) throws InvalidIdentifierException;
|
||||||
|
|
||||||
|
public String createDwCAByIds(final Stream<String> ids) throws Exception;
|
||||||
|
|
||||||
|
public String createCSV(final Stream<String> ids) throws Exception;
|
||||||
|
|
||||||
|
public String createCSVforOM(final Stream<String> ids) throws Exception;
|
||||||
|
|
||||||
|
public String createDarwincoreFromOccurrenceKeys(final Stream<String> ids) throws Exception;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package org.gcube.data.spd.client.proxies;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.data.spd.model.PluginDescription;
|
||||||
|
import org.gcube.data.spd.model.exceptions.InvalidQueryException;
|
||||||
|
import org.gcube.data.spd.model.products.ResultElement;
|
||||||
|
import org.gcube.data.spd.model.service.exceptions.UnsupportedCapabilityException;
|
||||||
|
import org.gcube.data.spd.model.service.exceptions.UnsupportedPluginException;
|
||||||
|
import org.gcube.data.streams.Stream;
|
||||||
|
|
||||||
|
public interface ManagerClient {
|
||||||
|
|
||||||
|
public <T extends ResultElement> Stream<T> search(String query) throws InvalidQueryException, UnsupportedPluginException, UnsupportedCapabilityException;
|
||||||
|
|
||||||
|
public List<PluginDescription> getPluginsDescription();
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package org.gcube.data.spd.client.proxies;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.data.spd.model.PointInfo;
|
||||||
|
import org.gcube.data.spd.model.products.OccurrencePoint;
|
||||||
|
import org.gcube.data.streams.Stream;
|
||||||
|
|
||||||
|
public interface OccurrenceClient {
|
||||||
|
|
||||||
|
public Stream<OccurrencePoint> getByIds(List<String> ids);
|
||||||
|
|
||||||
|
public String createLayer(Stream<PointInfo> coordinatesLocator);
|
||||||
|
|
||||||
|
public Stream<OccurrencePoint> getByKeys(List<String> keys);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package org.gcube.data.spd.client.proxies;
|
||||||
|
|
||||||
|
import org.glassfish.jersey.client.ChunkedInput;
|
||||||
|
|
||||||
|
public interface ResultSetClient {
|
||||||
|
|
||||||
|
ChunkedInput<String> getResultSet(String locator);
|
||||||
|
|
||||||
|
void closeResultSet(String locator);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<eml:eml xmlns:eml="eml://ecoinformatics.org/eml-2.1.1"
|
||||||
|
xmlns:md="eml://ecoinformatics.org/methods-2.1.1"
|
||||||
|
xmlns:proj="eml://ecoinformatics.org/project-2.1.1"
|
||||||
|
xmlns:d="eml://ecoinformatics.org/dataset-2.1.1"
|
||||||
|
xmlns:res="eml://ecoinformatics.org/resource-2.1.1"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns:dc="http://purl.org/dc/terms/"
|
||||||
|
packageId="e71fda1c-dcb9-4eae-81a9-183114978e44/eml-1.xml" system="GBIF-IPT" scope="system">
|
||||||
|
<dataset>
|
||||||
|
<title>The gCube System - Species Products Discovery Service</title>
|
||||||
|
<creator>
|
||||||
|
<individualName>
|
||||||
|
<givenName>Valentina</givenName>
|
||||||
|
<surName>Marioli</surName>
|
||||||
|
</individualName>
|
||||||
|
<organizationName>CNR Pisa, Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo"</organizationName>
|
||||||
|
<positionName></positionName>
|
||||||
|
<address>
|
||||||
|
<city>Pisa</city>
|
||||||
|
<administrativeArea></administrativeArea>
|
||||||
|
<postalCode></postalCode>
|
||||||
|
<country>Italy</country>
|
||||||
|
</address>
|
||||||
|
<phone></phone>
|
||||||
|
<electronicMailAddress>valentina.marioli@isti.cnr.it</electronicMailAddress>
|
||||||
|
<onlineUrl>https://gcube.wiki.gcube-system.org/gcube/index.php/Biodiversity_Access</onlineUrl>
|
||||||
|
</creator>
|
||||||
|
<pubDate></pubDate>
|
||||||
|
<language>en</language>
|
||||||
|
<abstract>
|
||||||
|
<para>This work has been partially supported by the following European projects: DILIGENT (FP6-2003-IST-2),
|
||||||
|
D4Science (FP7-INFRA-2007-1.2.2), D4Science-II (FP7-INFRA-2008-1.2.2),
|
||||||
|
iMarine (FP7-INFRASTRUCTURES-2011-2), and EUBrazilOpenBio (FP7-ICT-2011-EU-Brazil).</para>
|
||||||
|
</abstract>
|
||||||
|
<keywordSet>
|
||||||
|
<keyword>gCube</keyword>
|
||||||
|
<keyword>Species Discovery</keyword>
|
||||||
|
</keywordSet>
|
||||||
|
<intellectualRights>
|
||||||
|
<para>The gCube/gCore software is licensed as Free Open Source software conveying to the EUPL (http://ec.europa.eu/idabc/eupl).
|
||||||
|
The software and documentation is provided by its authors/distributors "as is" and no expressed or
|
||||||
|
implied warranty is given for its use, quality or fitness for a particular case.</para>
|
||||||
|
</intellectualRights>
|
||||||
|
<contact>
|
||||||
|
<individualName>
|
||||||
|
<givenName>Valentina</givenName>
|
||||||
|
<surName>Marioli</surName>
|
||||||
|
</individualName>
|
||||||
|
<electronicMailAddress>valentina.marioli@isti.cnr.it</electronicMailAddress>
|
||||||
|
</contact>
|
||||||
|
<methods>
|
||||||
|
</methods>
|
||||||
|
<project>
|
||||||
|
<title>Species Products Discovery Service</title>
|
||||||
|
</project>
|
||||||
|
</dataset>
|
||||||
|
<additionalMetadata>
|
||||||
|
</additionalMetadata>
|
||||||
|
</eml:eml>
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<archive xmlns="http://rs.tdwg.org/dwc/text/" metadata="eml.xml">
|
||||||
|
<core encoding="UTF-8" linesTerminatedBy="\n" fieldsTerminatedBy="\t" fieldsEnclosedBy="" ignoreHeaderLines="1" rowType="http://rs.tdwg.org/dwc/terms/Taxon">
|
||||||
|
<files>
|
||||||
|
<location>taxa.txt</location>
|
||||||
|
</files>
|
||||||
|
<id index="0"/>
|
||||||
|
<field index="0" term="http://rs.tdwg.org/dwc/terms/taxonID"/>
|
||||||
|
<field index="1" term="http://rs.tdwg.org/dwc/terms/acceptedNameUsageID"/>
|
||||||
|
<field index="2" term="http://rs.tdwg.org/dwc/terms/parentNameUsageID"/>
|
||||||
|
<field index="3" term="http://rs.tdwg.org/dwc/terms/scientificName"/>
|
||||||
|
<field index="4" term="http://rs.tdwg.org/dwc/terms/scientificNameAuthorship"/>
|
||||||
|
<field index="5" term="http://rs.tdwg.org/dwc/terms/nameAccordingTo"/>
|
||||||
|
<field index="6" term="http://rs.tdwg.org/dwc/terms/kingdom"/>
|
||||||
|
<field index="7" term="http://rs.tdwg.org/dwc/terms/phylum"/>
|
||||||
|
<field index="8" term="http://rs.tdwg.org/dwc/terms/class"/>
|
||||||
|
<field index="9" term="http://rs.tdwg.org/dwc/terms/order"/>
|
||||||
|
<field index="10" term="http://rs.tdwg.org/dwc/terms/family"/>
|
||||||
|
<field index="11" term="http://rs.tdwg.org/dwc/terms/genus"/>
|
||||||
|
<field index="12" term="http://rs.tdwg.org/dwc/terms/subgenus"/>
|
||||||
|
<field index="13" term="http://rs.tdwg.org/dwc/terms/specificEpithet"/>
|
||||||
|
<field index="14" term="http://rs.tdwg.org/dwc/terms/infraspecificEpithet"/>
|
||||||
|
<field index="15" term="http://rs.tdwg.org/dwc/terms/verbatimTaxonRank"/>
|
||||||
|
<field index="16" term="http://rs.tdwg.org/dwc/terms/taxonRank"/>
|
||||||
|
<field index="17" term="http://rs.tdwg.org/dwc/terms/taxonomicStatus"/>
|
||||||
|
<field index="18" term="http://purl.org/dc/terms/modified"/>
|
||||||
|
<field index="19" term="http://purl.org/dc/terms/bibliographicCitation"/>
|
||||||
|
<field index="20" term="http://rs.tdwg.org/dwc/terms/taxonRemarks"/>
|
||||||
|
</core>
|
||||||
|
<extension encoding="UTF-8" linesTerminatedBy="\n" fieldsTerminatedBy="\t" fieldsEnclosedBy="" ignoreHeaderLines="1" rowType="http://rs.gbif.org/terms/1.0/VernacularName">
|
||||||
|
<files>
|
||||||
|
<location>VernacularName.txt</location>
|
||||||
|
</files>
|
||||||
|
<coreid index="0"/>
|
||||||
|
<field index="1" term="http://rs.tdwg.org/dwc/terms/vernacularName"/>
|
||||||
|
<field index="2" term="http://purl.org/dc/terms/language"/>
|
||||||
|
<field index="3" term="http://rs.tdwg.org/dwc/terms/locality"/>
|
||||||
|
</extension>
|
||||||
|
</archive>
|
|
@ -0,0 +1,90 @@
|
||||||
|
package org.gcube.data.spd.client.manager;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
import org.gcube.data.spd.client.plugins.AbstractPlugin;
|
||||||
|
import org.gcube.data.spd.client.proxies.ExecutorClient;
|
||||||
|
import org.gcube.data.spd.client.proxies.ManagerClient;
|
||||||
|
import org.gcube.data.spd.model.products.Product;
|
||||||
|
import org.gcube.data.spd.model.products.Product.ProductType;
|
||||||
|
import org.gcube.data.spd.model.products.ResultItem;
|
||||||
|
import org.gcube.data.spd.model.service.types.CompleteJobStatus;
|
||||||
|
import org.gcube.data.spd.model.service.types.JobStatus;
|
||||||
|
import org.gcube.data.spd.model.service.types.NodeStatus;
|
||||||
|
import org.gcube.data.streams.Stream;
|
||||||
|
import org.gcube.data.streams.dsl.Streams;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
||||||
|
public class DWCATest {
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void OccurrenceJobFromSardaSarda() throws Exception{
|
||||||
|
|
||||||
|
SecurityTokenProvider.instance.set("94a3b80a-c66f-4000-ae2f-230f5dfad793-98187548");
|
||||||
|
ScopeProvider.instance.set("/gcube/devsec");
|
||||||
|
ExecutorClient creator = AbstractPlugin.executor().build();
|
||||||
|
|
||||||
|
//"CatalogueOfLife:13445516" chordata
|
||||||
|
//"CatalogueOfLife:13446218" cervidae
|
||||||
|
String jobId = createOccurrence(creator);
|
||||||
|
//String jobId = createOccurrence(creator);
|
||||||
|
CompleteJobStatus response= null;
|
||||||
|
do{
|
||||||
|
Thread.sleep(10000);
|
||||||
|
response= creator.getStatus(jobId);
|
||||||
|
System.out.println("thes status is "+response.getStatus());
|
||||||
|
System.out.println("the number of element read are "+response.getCompletedEntries());
|
||||||
|
if(response.getSubNodes()!=null)
|
||||||
|
for (NodeStatus status : response.getSubNodes())
|
||||||
|
System.out.println(status.getScientificName()+"--"+status.getStatus());
|
||||||
|
|
||||||
|
}while(response.getStatus()!=JobStatus.FAILED && response.getStatus()!=JobStatus.COMPLETED);
|
||||||
|
|
||||||
|
System.out.println("result uri "+creator.getResultLink(jobId));
|
||||||
|
System.out.println("error uri "+creator.getErrorLink(jobId));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static String createDWCAJobTest(ExecutorClient creator, String id) throws Exception {
|
||||||
|
return creator.createDwCAByChildren(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String createOccurrence(ExecutorClient creator) throws Exception {
|
||||||
|
Stream<String> keyStream =Streams.convert(new String[]{"Obis:522634-1695----", "Obis:465686-1695----", "Obis:429081-721----", "Obis:822676-1691----", "Obis:742361-119----", "Obis:447539-1695----", "GBIF:sarda||130||11956||57744173||","GBIF:sarda||82||400||50917042||","GBIF:sarda||427||14113||60499431||"});
|
||||||
|
return creator.createDarwincoreFromOccurrenceKeys(keyStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String createOccurrenceFromSardasarda(ExecutorClient creator) throws Exception {
|
||||||
|
|
||||||
|
ManagerClient manager = AbstractPlugin.manager().build();
|
||||||
|
|
||||||
|
Stream<ResultItem> rsStream = manager.search("SEARCH BY SN 'sarda sarda'");
|
||||||
|
|
||||||
|
List<String> keylist = new ArrayList<String>();
|
||||||
|
int i =0;
|
||||||
|
while (rsStream.hasNext()){
|
||||||
|
ResultItem rs = rsStream.next();
|
||||||
|
for (Product product: rs.getProducts())
|
||||||
|
if (product.getCount()>0 && product.getType()==ProductType.Occurrence) keylist.add(product.getKey());
|
||||||
|
if (i++>=5)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
rsStream.close();
|
||||||
|
|
||||||
|
System.out.println("keyList is "+keylist.size());
|
||||||
|
|
||||||
|
System.in.read();
|
||||||
|
|
||||||
|
Stream<String> keyStream =Streams.convert(keylist);
|
||||||
|
return creator.createCSV(keyStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
package org.gcube.data.spd.client.manager;
|
||||||
|
|
||||||
|
|
||||||
|
public class JobTest {
|
||||||
|
|
||||||
|
/* *//**
|
||||||
|
* @param args
|
||||||
|
*//*
|
||||||
|
public static void main(String[] args) throws Exception{
|
||||||
|
ScopeProvider.instance.set("/gcube/devsec");
|
||||||
|
getJobFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void getJobFile() throws Exception {
|
||||||
|
|
||||||
|
ExecutorClient creator = executor().build();
|
||||||
|
String link = creator.getResultLink("f63a96b0-e94b-11e2-a63c-e05c5bb7d509||8c788f50-eace-11e2-b167-8f9adc39871b");
|
||||||
|
System.out.println("resultLink is "+ link);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void getJobErorFile() throws Exception {
|
||||||
|
|
||||||
|
ExecutorClient creator = executor().build();
|
||||||
|
String link = creator.getErrorLink("f63a96b0-e94b-11e2-a63c-e05c5bb7d509||8c788f50-eace-11e2-b167-8f9adc39871b");
|
||||||
|
System.out.println("errorLink is "+ link);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void getStatus() throws Exception {
|
||||||
|
|
||||||
|
ExecutorClient creator = executor().build();
|
||||||
|
CompleteJobStatus status = creator.getStatus("f63a96b0-e94b-11e2-a63c-e05c5bb7d509||8c788f50-eace-11e2-b167-8f9adc39871b");
|
||||||
|
System.out.println("status is "+ status);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void getJobs() throws Exception {
|
||||||
|
|
||||||
|
ExecutorClient creator = executor().build();
|
||||||
|
CompleteJobStatus status = creator.getStatus("f63a96b0-e94b-11e2-a63c-e05c5bb7d509||8c788f50-eace-11e2-b167-8f9adc39871b");
|
||||||
|
System.out.println("status is "+ status);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
package org.gcube.data.spd.client.manager;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
import org.gcube.data.spd.client.plugins.AbstractPlugin;
|
||||||
|
import org.gcube.data.spd.client.proxies.ManagerClient;
|
||||||
|
import org.gcube.data.spd.client.proxies.OccurrenceClient;
|
||||||
|
import org.gcube.data.spd.model.PluginDescription;
|
||||||
|
import org.gcube.data.spd.model.products.OccurrencePoint;
|
||||||
|
import org.gcube.data.spd.model.products.Product;
|
||||||
|
import org.gcube.data.spd.model.products.ResultItem;
|
||||||
|
import org.gcube.data.streams.Stream;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
|
public class ManagerTest {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(ManagerTest.class);
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void search() throws Exception{
|
||||||
|
SecurityTokenProvider.instance.set("94a3b80a-c66f-4000-ae2f-230f5dfad793-98187548");
|
||||||
|
ScopeProvider.instance.set("/gcube/devsec");
|
||||||
|
ManagerClient manager = AbstractPlugin.manager().build();
|
||||||
|
|
||||||
|
Stream<ResultItem> stream = manager.search("SEARCH BY SN 'cetacea' IN OBIS WHERE coordinate >= 30.0 , 20.0 ");
|
||||||
|
|
||||||
|
List<String> productKeys = new ArrayList<String>();
|
||||||
|
|
||||||
|
int i =0;
|
||||||
|
while (stream.hasNext()){
|
||||||
|
if (i==10) break;
|
||||||
|
ResultItem item = stream.next();
|
||||||
|
|
||||||
|
for (Product prod : item.getProducts()){
|
||||||
|
System.out.println("type: "+prod.getType()+" - "+prod.getKey()+" - "+prod.getCount());
|
||||||
|
productKeys.add(prod.getKey());
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
stream.close();
|
||||||
|
|
||||||
|
OccurrenceClient occurrence = AbstractPlugin.occurrences().build();
|
||||||
|
Stream<OccurrencePoint> occurrenceStream = occurrence.getByKeys(productKeys);
|
||||||
|
|
||||||
|
int occIndex = 0;
|
||||||
|
|
||||||
|
while (occurrenceStream.hasNext()){
|
||||||
|
|
||||||
|
occIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("occurrence point found : "+occIndex);
|
||||||
|
occurrenceStream.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getPluginDescription() throws Exception{
|
||||||
|
SecurityTokenProvider.instance.set("94a3b80a-c66f-4000-ae2f-230f5dfad793-98187548");
|
||||||
|
ScopeProvider.instance.set("/gcube/devsec");
|
||||||
|
ManagerClient manager = AbstractPlugin.manager().build();
|
||||||
|
List<PluginDescription> pluginDescriptions = manager.getPluginsDescription();
|
||||||
|
System.out.println("plugin descriptions are "+pluginDescriptions.size());
|
||||||
|
for (PluginDescription description : pluginDescriptions)
|
||||||
|
System.out.println(description.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
package org.gcube.data.spd.client.manager;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
import org.gcube.data.spd.client.plugins.AbstractPlugin;
|
||||||
|
import org.gcube.data.spd.client.proxies.OccurrenceClient;
|
||||||
|
import org.gcube.data.spd.model.products.OccurrencePoint;
|
||||||
|
import org.gcube.data.streams.Stream;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
public class OccurrencesTest {
|
||||||
|
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(OccurrencesTest.class);
|
||||||
|
|
||||||
|
|
||||||
|
private static List<String> occurrenceIds=Arrays.asList("GBIF:1238408827","GBIF:1234813179","GBIF:1136918536","GBIF:1050224578",
|
||||||
|
"GBIF:1084012520","GBIF:1084013323","GBIF:1084013326","GBIF:1084013281", "GBIF:857015137","GBIF:856828010");
|
||||||
|
|
||||||
|
private static List<String> occurrenceKeys = Arrays.asList("GBIF:84028840-f762-11e1-a439-00145eb45e9a^^Marine and Coastal Management - Demersal Surveys (years 1991-1995) (AfrOBIS)^^Marine and Coastal Management - Demersal Surveys^^0e0fc0f0-828e-11d8-b7ed-b8a03c50a862^^Ocean Biogeographic Information System||5208593" , "GBIF:ed820bdb-4345-4143-a280-4fbffaacd31d^^The Pisces Collection at the Staatssammlung für Anthropologie und Paläoanatomie München^^Staatliche Naturwissenschaftliche Sammlungen Bayerns: The Pisces Collection at the Staatssammlung für Anthropologie und Paläoanatomie München^^0674aea0-a7e1-11d8-9534-b8a03c50a862^^Staatliche Naturwissenschaftliche Sammlungen Bayerns||5712279", "GBIF:8609f1a0-f762-11e1-a439-00145eb45e9a^^Marine and Coastal Management - Linefish Dataset (Second Semester of 1992) (AfrOBIS)^^Marine and Coastal Management - Linefish Dataset^^0e0fc0f0-828e-11d8-b7ed-b8a03c50a862^^Ocean Biogeographic Information System||5208602" );
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getOccurencesByIds() throws Exception{
|
||||||
|
SecurityTokenProvider.instance.set("94a3b80a-c66f-4000-ae2f-230f5dfad793-98187548");
|
||||||
|
ScopeProvider.instance.set("/gcube/devsec");
|
||||||
|
OccurrenceClient occurrences = AbstractPlugin.occurrences().build();
|
||||||
|
Stream<OccurrencePoint> stream = occurrences.getByIds(occurrenceIds);
|
||||||
|
|
||||||
|
int i =0;
|
||||||
|
while (stream.hasNext())
|
||||||
|
System.out.println(i+++")"+stream.next());
|
||||||
|
|
||||||
|
stream.close();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getOccurencesByKeys() throws Exception{
|
||||||
|
SecurityTokenProvider.instance.set("94a3b80a-c66f-4000-ae2f-230f5dfad793-98187548");
|
||||||
|
ScopeProvider.instance.set("/gcube/devsec");
|
||||||
|
OccurrenceClient occurrences = AbstractPlugin.occurrences().build();
|
||||||
|
|
||||||
|
Stream<OccurrencePoint> stream = occurrences.getByKeys(occurrenceKeys);
|
||||||
|
|
||||||
|
int i =0;
|
||||||
|
while (stream.hasNext())
|
||||||
|
System.out.println(i+++")"+stream.next());
|
||||||
|
|
||||||
|
stream.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
package org.gcube.data.spd.client.manager;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
public class TaxonTest {
|
||||||
|
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(TaxonTest.class);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*public static void main(String[] args) throws Exception{
|
||||||
|
getTaxonById();
|
||||||
|
getChilds();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void getChilds() throws UnsupportedPluginException, UnsupportedCapabilityException, InvalidIdentifierException{
|
||||||
|
ScopeProvider.instance.set("/gcube/devsec");
|
||||||
|
Classification classification = classification().build();
|
||||||
|
|
||||||
|
Stream<TaxonomyItem> item = classification.getTaxonChildrenById("CatalogueOfLife:12640178");
|
||||||
|
|
||||||
|
System.out.println("parent id is cataloguesOfLife:12640178");
|
||||||
|
|
||||||
|
while (item.hasNext()){
|
||||||
|
System.out.println("item:"+ item.next());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void getChildenTree() throws Exception{
|
||||||
|
ScopeProvider.instance.set("/gcube/devsec");
|
||||||
|
Classification classification = classification().build();
|
||||||
|
|
||||||
|
|
||||||
|
Stream<TaxonomyItem> item = classification.getTaxonTreeById("CatalogueOfLife:11946467");
|
||||||
|
|
||||||
|
int i =0;
|
||||||
|
while (item.hasNext()){
|
||||||
|
TaxonomyItem subitem = item.next();
|
||||||
|
System.out.println("item ("+i+++") "+ subitem.getId()+" !! "+ subitem.getRank()+" -- "+subitem.getParent());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void getSynonyms() throws IdNotValidException, Exception{
|
||||||
|
ScopeProvider.instance.set("/gcube/devsec");
|
||||||
|
Classification classification = classification().build();
|
||||||
|
Stream<TaxonomyItem> item = classification.getSynonymsById("WoRMS:273810");
|
||||||
|
|
||||||
|
int i =0;
|
||||||
|
while (item.hasNext()){
|
||||||
|
System.out.println("item ("+i+++") "+ item.next());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void getTaxonById() throws Exception{
|
||||||
|
ScopeProvider.instance.set("/gcube/devsec");
|
||||||
|
Classification classification = classification().build();
|
||||||
|
Stream<TaxonomyItem> item = classification.getTaxaByIds(convert(Collections.singletonList("CatalogueOfLife:12640178")));
|
||||||
|
|
||||||
|
System.out.println("taxon ----");
|
||||||
|
int i =0;
|
||||||
|
while (item.hasNext()){
|
||||||
|
System.out.println("item ("+i+++") "+ item.next());
|
||||||
|
}
|
||||||
|
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
log4j.appender.ROOT=org.apache.log4j.ConsoleAppender
|
||||||
|
log4j.appender.ROOT.layout=org.apache.log4j.PatternLayout
|
||||||
|
log4j.appender.ROOT.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p %c{2} [%t,%M:%L] %m%n
|
||||||
|
log4j.rootLogger=TRACE,A1
|
||||||
|
|
||||||
|
log4j.appender.A1=org.apache.log4j.ConsoleAppender
|
||||||
|
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
|
||||||
|
log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p %c{2} [%t,%M:%L] %m%n
|
||||||
|
log4j.appender.SPD-CL.layout=org.apache.log4j.PatternLayout
|
||||||
|
log4j.appender.SPD-CL.layout.ConversionPattern=[SPD-CL] %d{HH:mm:ss,SSS} %-5p %c{2} [%t,%M:%L] %m%n
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue