First Implementation
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/data-miner-manager-cl@133498 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
827e874c8e
commit
6d6717c735
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" 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>data-miner-manager-cl</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.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,6 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding//src/main/resources=UTF-8
|
||||
encoding//src/test/java=UTF-8
|
||||
encoding//src/test/resources=UTF-8
|
||||
encoding/<project>=UTF-8
|
||||
encoding/src=UTF-8
|
|
@ -0,0 +1,13 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
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.7
|
|
@ -0,0 +1,4 @@
|
|||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
|
@ -0,0 +1,239 @@
|
|||
<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>data-miner-manager-cl</groupId>
|
||||
<artifactId>data-miner-manager-cl</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
|
||||
<name>data-miner-manager-cl</name>
|
||||
<description>DataMiner Manager Client Library</description>
|
||||
|
||||
|
||||
<scm>
|
||||
<url>https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/data-miner-manager-cl</url>
|
||||
</scm>
|
||||
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<name>Giancarlo Panichi</name>
|
||||
<email>g.panichi@isti.cnr.it</email>
|
||||
<organization>CNR Pisa, Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo"</organization>
|
||||
<roles>
|
||||
<role>architect</role>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<properties>
|
||||
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
|
||||
<distroDirectory>distro</distroDirectory>
|
||||
<configDirectory>config</configDirectory>
|
||||
|
||||
|
||||
<!-- Java Version -->
|
||||
<javaVersion>1.7</javaVersion>
|
||||
|
||||
<KEYS>${env.KEYS}</KEYS>
|
||||
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
</properties>
|
||||
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>localRun</id>
|
||||
<dependencies>
|
||||
<!-- Logger -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>xerces</groupId>
|
||||
<artifactId>xerces</artifactId>
|
||||
<version>2.4.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Storage -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
<artifactId>storage-manager-core</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
<artifactId>storage-manager-wrapper</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Home Library <dependency> <groupId>org.gcube.common</groupId> <artifactId>home-library</artifactId>
|
||||
<scope>runtime</scope> </dependency> <dependency> <groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library-jcr</artifactId> <scope>runtime</scope> </dependency>
|
||||
<dependency> <groupId>org.gcube.common</groupId> <artifactId>home-library-model</artifactId>
|
||||
<scope>runtime</scope> </dependency> -->
|
||||
|
||||
<!-- Authorization -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>common-authorization</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>authorization-client</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- Authorization -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>common-authorization</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>authorization-client</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Storage -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
<artifactId>storage-manager-core</artifactId>
|
||||
<version>[2.1.0-SNAPSHOT,) </version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
<artifactId>storage-manager-wrapper</artifactId>
|
||||
<version>[2.1.0-SNAPSHOT,)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Information System Client IC-Client -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.resources.discovery</groupId>
|
||||
<artifactId>ic-client</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Nord52 -->
|
||||
<dependency>
|
||||
<groupId>org.n52.wps</groupId>
|
||||
<artifactId>52n-wps-client-lib</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>gt-opengis</artifactId>
|
||||
<groupId>org.geotools</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>xerces</groupId>
|
||||
<artifactId>xercesImpl</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- LOGGING -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>1.7.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
|
||||
<repository>
|
||||
<id>gCubeExternal</id>
|
||||
<name>gcube-externals</name>
|
||||
<url>http://maven.research-infrastructures.eu/nexus/content/repositories/gcube-externals/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>n52-releases</id>
|
||||
<name>52n Releases</name>
|
||||
<url>http://52north.org/maven/repo/releases/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
|
||||
<!-- <repository> -->
|
||||
<!-- <id>52north-releases</id> -->
|
||||
<!-- <name>52north-releases</name> -->
|
||||
<!-- <url>http://maven.research-infrastructures.eu/nexus/content/repositories/52north-releases/</url> -->
|
||||
<!-- </repository> -->
|
||||
|
||||
</repositories>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>gcube-bom</artifactId>
|
||||
<version>LATEST</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,93 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.server;
|
||||
|
||||
import static org.gcube.common.authorization.client.Constants.authorizationService;
|
||||
|
||||
import org.gcube.common.authorization.library.AuthorizationEntry;
|
||||
import org.gcube.common.authorization.library.provider.AuthorizationProvider;
|
||||
import org.gcube.common.authorization.library.provider.ClientInfo;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.authorization.library.provider.UserInfo;
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.dmservice.SClient;
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.dmservice.SClient4WPSBuilder;
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.dmservice.SClientBuilder;
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.dmservice.SClientDirector;
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.util.ServiceCredential;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.Constants;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.exception.ServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class DataMinerService {
|
||||
|
||||
private static Logger logger = LoggerFactory
|
||||
.getLogger(DataMinerService.class);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param userName
|
||||
* @param scope
|
||||
* @param token
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static SClient getClient()
|
||||
throws Exception {
|
||||
|
||||
ServiceCredential serviceCredential = getServiceCredential();
|
||||
SClientBuilder sBuilder = new SClient4WPSBuilder(serviceCredential);
|
||||
SClientDirector director = new SClientDirector();
|
||||
director.setSClientBuilder(sBuilder);
|
||||
director.constructSClient();
|
||||
SClient sClient = director.getSClient();
|
||||
logger.debug("" + sClient);
|
||||
return sClient;
|
||||
|
||||
}
|
||||
|
||||
private static ServiceCredential getServiceCredential()
|
||||
throws ServiceException {
|
||||
String userName = null;
|
||||
String token = null;
|
||||
String scope = null;
|
||||
|
||||
if (Constants.DEBUG) {
|
||||
logger.debug("Debug Mode");
|
||||
userName = Constants.DEFAULT_USER;
|
||||
scope = Constants.DEFAULT_SCOPE;
|
||||
token = Constants.DEFAULT_TOKEN;
|
||||
} else {
|
||||
logger.debug("Production Mode");
|
||||
try {
|
||||
logger.debug("Retrieving token credentials");
|
||||
// get username from SmartGears
|
||||
ClientInfo tokenInfo = (UserInfo) AuthorizationProvider.instance
|
||||
.get().getClient();
|
||||
userName = tokenInfo.getId();
|
||||
token = SecurityTokenProvider.instance.get();
|
||||
AuthorizationEntry entry = authorizationService().get(token);
|
||||
scope = entry.getContext();
|
||||
} catch (Exception e) {
|
||||
logger.error("Error Retrieving token credentials: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ServiceCredential serviceCredential = new ServiceCredential(userName,
|
||||
scope, token);
|
||||
|
||||
logger.debug("Credential: " + serviceCredential);
|
||||
|
||||
return serviceCredential;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.server.dmservice;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.OutputData;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationData;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationId;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.process.ComputationStatus;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.process.Operator;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.process.OperatorsClassification;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Client of service
|
||||
*
|
||||
* @author giancarlo email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public abstract class SClient implements Serializable{
|
||||
|
||||
|
||||
private static final long serialVersionUID = 7087349607933493388L;
|
||||
|
||||
public SClient() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the list of operators
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public abstract List<OperatorsClassification> getOperatorsClassifications()
|
||||
throws Exception;
|
||||
|
||||
/**
|
||||
* Retrieve the operator by id
|
||||
*
|
||||
* @param id operator id
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public abstract Operator getOperatorById(String id) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* Get input paramters of the operator
|
||||
*
|
||||
* @param operator operator
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public abstract List<Parameter> getInputParameters(Operator operator)
|
||||
throws Exception;
|
||||
|
||||
/**
|
||||
* Start Computation
|
||||
*
|
||||
* @param operator operator
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public abstract ComputationId startComputation(Operator operator)
|
||||
throws Exception;
|
||||
|
||||
/**
|
||||
* Cance a computation
|
||||
*
|
||||
* @param computationId computation Id
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public abstract String cancelComputation(ComputationId computationId)
|
||||
throws Exception;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get Computation Status
|
||||
*
|
||||
* @param computationId computation Id
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public abstract ComputationStatus getComputationStatus(
|
||||
ComputationId computationId) throws Exception;
|
||||
|
||||
/**
|
||||
* Get Output of computation
|
||||
*
|
||||
* @param computationId
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public abstract OutputData getOutputDataByComputationId(
|
||||
ComputationId computationId) throws Exception;
|
||||
|
||||
/**
|
||||
* Get Computation Data by computation properties
|
||||
*
|
||||
* @param computationProperties computation properties
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public abstract ComputationData getComputationDataByComputationProperties(
|
||||
Map<String, String> computationProperties) throws Exception;
|
||||
|
||||
/**
|
||||
* Resubmit a computation only by computation properties
|
||||
*
|
||||
* @param computationProperties
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public abstract ComputationId resubmitComputation(
|
||||
Map<String, String> computationProperties) throws Exception;
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SClient";
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,41 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.server.dmservice;
|
||||
|
||||
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.util.ServiceCredential;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.exception.ServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Builder of Client 4 WPS Service
|
||||
*
|
||||
* @author "Giancarlo Panichi" email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class SClient4WPSBuilder extends SClientBuilder {
|
||||
private static Logger logger = LoggerFactory
|
||||
.getLogger(SClient4WPSBuilder.class);
|
||||
private ServiceCredential serviceCredendial;
|
||||
|
||||
public SClient4WPSBuilder(ServiceCredential serviceCredential) {
|
||||
this.serviceCredendial= serviceCredential;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildSClient() throws ServiceException {
|
||||
try {
|
||||
logger.debug("Build SC4WPS");
|
||||
logger.debug("ServiceCredential: " + serviceCredendial);
|
||||
SClient sClient = new SClient4WPS(serviceCredendial);
|
||||
|
||||
sClientSpec.setSClient(sClient);
|
||||
} catch (Throwable e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getLocalizedMessage(),e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.server.dmservice;
|
||||
|
||||
/**
|
||||
* Abstract class for build client of service
|
||||
*
|
||||
* @author "Giancarlo Panichi" email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public abstract class SClientBuilder {
|
||||
protected SClientSpec sClientSpec;
|
||||
|
||||
public SClientSpec getSClientSpec() {
|
||||
return sClientSpec;
|
||||
}
|
||||
|
||||
public void createSpec() {
|
||||
sClientSpec = new SClientSpec();
|
||||
|
||||
}
|
||||
|
||||
public abstract void buildSClient() throws Exception;
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.server.dmservice;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Director
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class SClientDirector {
|
||||
SClientBuilder sClientBuilder;
|
||||
|
||||
public void setSClientBuilder(
|
||||
SClientBuilder sClientBuilder) {
|
||||
this.sClientBuilder = sClientBuilder;
|
||||
}
|
||||
|
||||
public SClient getSClient() {
|
||||
return sClientBuilder.getSClientSpec().getSClient();
|
||||
|
||||
}
|
||||
|
||||
public void constructSClient() throws Exception {
|
||||
sClientBuilder.createSpec();
|
||||
sClientBuilder.buildSClient();
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.server.dmservice;
|
||||
|
||||
/**
|
||||
* Specification
|
||||
*
|
||||
* @author "Giancarlo Panichi" email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class SClientSpec {
|
||||
private SClient sClient;
|
||||
|
||||
public SClient getSClient() {
|
||||
return sClient;
|
||||
}
|
||||
|
||||
public void setSClient(SClient sClient) {
|
||||
this.sClient = sClient;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.server.dmservice.wps;
|
||||
|
||||
import org.n52.wps.client.AbstractClientGETRequest;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class DClientDescribeProcessRequest extends AbstractClientGETRequest {
|
||||
|
||||
private static String IDENTIFIER_REQ_PARAM_NAME = "identifier";
|
||||
private static String REQUEST_REQ_PARAM_VALUE = "DescribeProcess";
|
||||
|
||||
public DClientDescribeProcessRequest() {
|
||||
super();
|
||||
setRequestParamValue(REQUEST_REQ_PARAM_VALUE);
|
||||
}
|
||||
|
||||
public void setIdentifier(String[] ids) {
|
||||
String idsString = "";
|
||||
for(int i = 0; i < ids.length; i++) {
|
||||
idsString = idsString + ids[i];
|
||||
if(i != ids.length -1) {
|
||||
idsString = idsString + ",";
|
||||
}
|
||||
}
|
||||
requestParams.put(IDENTIFIER_REQ_PARAM_NAME, idsString);
|
||||
}
|
||||
|
||||
public boolean valid() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.server.dmservice.wps;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.opengis.wps.x100.InputDescriptionType;
|
||||
import net.opengis.wps.x100.OutputDescriptionType;
|
||||
import net.opengis.wps.x100.ProcessDescriptionType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ProcessInformations implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 4729933672312944832L;
|
||||
private ProcessDescriptionType processDescription;
|
||||
private InputDescriptionType[] inputs;
|
||||
private OutputDescriptionType[] outputs;
|
||||
|
||||
public ProcessInformations(ProcessDescriptionType processDescription) {
|
||||
super();
|
||||
this.processDescription = processDescription;
|
||||
this.inputs = new InputDescriptionType[0];
|
||||
this.outputs = new OutputDescriptionType[0];
|
||||
}
|
||||
|
||||
public ProcessInformations(ProcessDescriptionType processDescription,
|
||||
InputDescriptionType[] inputs, OutputDescriptionType[] outputs) {
|
||||
super();
|
||||
this.processDescription = processDescription;
|
||||
this.inputs = inputs;
|
||||
this.outputs = outputs;
|
||||
}
|
||||
|
||||
public ProcessDescriptionType getProcessDescription() {
|
||||
return processDescription;
|
||||
}
|
||||
|
||||
public void setProcessDescription(
|
||||
ProcessDescriptionType processDescription) {
|
||||
this.processDescription = processDescription;
|
||||
}
|
||||
|
||||
public InputDescriptionType[] getInputs() {
|
||||
return inputs;
|
||||
}
|
||||
|
||||
public void setInputs(InputDescriptionType[] inputs) {
|
||||
this.inputs = inputs;
|
||||
}
|
||||
|
||||
public OutputDescriptionType[] getOutputs() {
|
||||
return outputs;
|
||||
}
|
||||
|
||||
public void setOutputs(OutputDescriptionType[] outputs) {
|
||||
this.outputs = outputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProcessInformations [processDescription="
|
||||
+ processDescription + ", inputs="
|
||||
+ Arrays.toString(inputs) + ", outputs="
|
||||
+ Arrays.toString(outputs) + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.server.dmservice.wps;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ResponseWPS implements Serializable {
|
||||
private static final long serialVersionUID = 3449817768583395068L;
|
||||
private String data;
|
||||
private String description;
|
||||
private String mimeType;
|
||||
|
||||
public ResponseWPS() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ResponseWPS(String data, String description, String mimeType) {
|
||||
super();
|
||||
this.data = data;
|
||||
this.description = description;
|
||||
this.mimeType = mimeType;
|
||||
}
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getMimeType() {
|
||||
return mimeType;
|
||||
}
|
||||
|
||||
public void setMimeType(String mimeType) {
|
||||
this.mimeType = mimeType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ResponseWPS [data=" + data + ", description=" + description
|
||||
+ ", mimeType=" + mimeType + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,781 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.server.dmservice.wps;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Serializable;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import net.opengis.ows.x11.ExceptionReportDocument;
|
||||
import net.opengis.ows.x11.OperationDocument.Operation;
|
||||
import net.opengis.wps.x100.CapabilitiesDocument;
|
||||
import net.opengis.wps.x100.ExecuteDocument;
|
||||
import net.opengis.wps.x100.ExecuteResponseDocument;
|
||||
import net.opengis.wps.x100.ProcessBriefType;
|
||||
import net.opengis.wps.x100.ProcessDescriptionType;
|
||||
import net.opengis.wps.x100.ProcessDescriptionsDocument;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.xmlbeans.XmlException;
|
||||
import org.apache.xmlbeans.XmlObject;
|
||||
import org.apache.xmlbeans.XmlOptions;
|
||||
import org.n52.wps.client.ClientCapabiltiesRequest;
|
||||
import org.n52.wps.client.WPSClientException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class SClient4WPSSession implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -1387670579312851370L;
|
||||
private static Logger logger = LoggerFactory
|
||||
.getLogger(SClient4WPSSession.class);
|
||||
private static final String OGC_OWS_URI = "http://www.opengeospatial.net/ows";
|
||||
private static String SUPPORTED_VERSION = "1.0.0";
|
||||
|
||||
// private static StatWPSClientSession session;
|
||||
private HashMap<String, CapabilitiesDocument> loggedServices;
|
||||
private XmlOptions options = null;
|
||||
|
||||
// a Map of <url, all available process descriptions>
|
||||
public HashMap<String, ProcessDescriptionsDocument> processDescriptions;
|
||||
private String user;
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* Initializes a WPS client session.
|
||||
*
|
||||
*/
|
||||
public SClient4WPSSession(String user, String password) {
|
||||
super();
|
||||
logger.debug("Create SClient4WPSSession: [user=" + user
|
||||
+ ", password=" + password + "]");
|
||||
this.user = user;
|
||||
this.password = password;
|
||||
options = new XmlOptions();
|
||||
options.setLoadStripWhitespace();
|
||||
options.setLoadTrimTextBuffer();
|
||||
loggedServices = new HashMap<String, CapabilitiesDocument>();
|
||||
processDescriptions = new HashMap<String, ProcessDescriptionsDocument>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects to a WPS and retrieves Capabilities plus puts all available
|
||||
* Descriptions into cache.
|
||||
*
|
||||
* @param url
|
||||
* the entry point for the service. This is used as id for
|
||||
* further identification of the service.
|
||||
* @return true, if connect succeeded, false else.
|
||||
* @throws WPSClientException
|
||||
*/
|
||||
|
||||
public boolean connect(String url) throws WPSClientException {
|
||||
logger.info("CONNECT: " + url);
|
||||
logger.info("LoggedSevices: " + loggedServices.keySet());
|
||||
if (loggedServices.containsKey(url)) {
|
||||
logger.info("Service already registered: " + url);
|
||||
return false;
|
||||
}
|
||||
logger.debug("Service not registered");
|
||||
CapabilitiesDocument capsDoc = retrieveCapsViaGET(url);
|
||||
if (capsDoc != null) {
|
||||
logger.debug("Adding caps to logged services " + url);
|
||||
loggedServices.put(url, capsDoc);
|
||||
logger.debug("Logged Services key: " + loggedServices.keySet());
|
||||
} else {
|
||||
logger.error("CapsDoc is null!");
|
||||
}
|
||||
|
||||
ProcessDescriptionsDocument processDescs = describeAllProcesses(url);
|
||||
if (processDescs != null && capsDoc != null) {
|
||||
logger.info("Adding processes descriptions to logged services "
|
||||
+ url);
|
||||
processDescriptions.put(url, processDescs);
|
||||
logger.debug("ProcessDescriptions key: "
|
||||
+ processDescriptions.keySet());
|
||||
return true;
|
||||
|
||||
} else {
|
||||
logger.error("ProcessDescs is null!");
|
||||
}
|
||||
|
||||
logger.warn("retrieving caps failed, caps are null");
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects to a WPS and retrieves Capabilities plus puts all available
|
||||
* Descriptions into cache.
|
||||
*
|
||||
* @param url
|
||||
* the entry point for the service. This is used as id for
|
||||
* further identification of the service.
|
||||
* @return true, if connect succeeded, false else.
|
||||
* @throws WPSClientException
|
||||
*/
|
||||
public boolean connectForMonitoring(String url) throws WPSClientException {
|
||||
logger.info("CONNECT");
|
||||
if (loggedServices.containsKey(url)) {
|
||||
logger.info("Service already registered: " + url);
|
||||
return false;
|
||||
}
|
||||
|
||||
logger.warn("retrieving caps failed, caps are null");
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* removes a service from the session
|
||||
*
|
||||
* @param url
|
||||
*/
|
||||
public void disconnect(String url) {
|
||||
/*
|
||||
* if (loggedServices.containsKey(url)) { loggedServices.remove(url);
|
||||
* processDescriptions.remove(url);
|
||||
* logger.info("service removed successfully: " + url); }
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the serverIDs of all loggedServices
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<String> getLoggedServices() {
|
||||
if (loggedServices != null && loggedServices.keySet() != null) {
|
||||
return new ArrayList<String>(loggedServices.keySet());
|
||||
} else {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* informs you if the descriptions for the specified service is already in
|
||||
* the session. in normal case it should return true :)
|
||||
*
|
||||
* @param serverID
|
||||
* @return success
|
||||
*/
|
||||
public boolean descriptionsAvailableInCache(String serverID) {
|
||||
return processDescriptions.containsKey(serverID);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the cached processdescriptions of a service.
|
||||
*
|
||||
* @param serverID
|
||||
* @return success
|
||||
* @throws IOException
|
||||
*/
|
||||
private ProcessDescriptionsDocument getProcessDescriptionsFromCache(
|
||||
String wpsUrl) throws IOException {
|
||||
if (!descriptionsAvailableInCache(wpsUrl)) {
|
||||
try {
|
||||
connect(wpsUrl);
|
||||
} catch (WPSClientException e) {
|
||||
throw new IOException("Could not initialize WPS " + wpsUrl);
|
||||
}
|
||||
}
|
||||
return processDescriptions.get(wpsUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* return the processDescription for a specific process from Cache.
|
||||
*
|
||||
* @param serverID
|
||||
* @param processID
|
||||
* @return a ProcessDescription for a specific process from Cache.
|
||||
* @throws IOException
|
||||
*/
|
||||
public ProcessDescriptionType getProcessDescription(String serverID,
|
||||
String processID) throws IOException {
|
||||
ProcessDescriptionType[] processes = getProcessDescriptionsFromCache(
|
||||
serverID).getProcessDescriptions().getProcessDescriptionArray();
|
||||
for (ProcessDescriptionType process : processes) {
|
||||
if (process.getIdentifier().getStringValue().equals(processID)) {
|
||||
return process;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delivers all ProcessDescriptions from a WPS
|
||||
*
|
||||
* @param wpsUrl
|
||||
* the URL of the WPS
|
||||
* @return An Array of ProcessDescriptions
|
||||
* @throws IOException
|
||||
*/
|
||||
public ProcessDescriptionType[] getAllProcessDescriptions(String wpsUrl)
|
||||
throws IOException {
|
||||
return getProcessDescriptionsFromCache(wpsUrl).getProcessDescriptions()
|
||||
.getProcessDescriptionArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* looks up, if the service exists already in session.
|
||||
*/
|
||||
public boolean serviceAlreadyRegistered(String serverID) {
|
||||
return loggedServices.containsKey(serverID);
|
||||
}
|
||||
|
||||
/**
|
||||
* provides you the cached capabilities for a specified service.
|
||||
*
|
||||
* @param url
|
||||
* @return
|
||||
*/
|
||||
public CapabilitiesDocument getWPSCaps(String url) {
|
||||
return loggedServices.get(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* retrieves all current available ProcessDescriptions of a WPS. Mention: to
|
||||
* get the current list of all processes, which will be requested, the
|
||||
* cached capabilities will be used. Please keep that in mind. the retrieved
|
||||
* descriptions will not be cached, so only transient information!
|
||||
*
|
||||
* @param url
|
||||
* @return
|
||||
* @throws WPSClientException
|
||||
*/
|
||||
public ProcessDescriptionsDocument describeAllProcesses(String url)
|
||||
throws WPSClientException {
|
||||
CapabilitiesDocument doc = loggedServices.get(url);
|
||||
if (doc == null) {
|
||||
logger.warn("serviceCaps are null, perhaps server does not exist");
|
||||
return null;
|
||||
}
|
||||
ProcessBriefType[] processes = doc.getCapabilities()
|
||||
.getProcessOfferings().getProcessArray();
|
||||
String[] processIDs = new String[processes.length];
|
||||
for (int i = 0; i < processIDs.length; i++) {
|
||||
processIDs[i] = processes[i].getIdentifier().getStringValue();
|
||||
}
|
||||
return describeProcess(processIDs, url);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* retrieves the desired description for a service. the retrieved
|
||||
* information will not be held in cache!
|
||||
*
|
||||
* @param processIDs
|
||||
* one or more processIDs
|
||||
* @param serverID
|
||||
* @throws WPSClientException
|
||||
*/
|
||||
public ProcessDescriptionsDocument describeProcess(String[] processIDs,
|
||||
String serverID) throws WPSClientException {
|
||||
|
||||
CapabilitiesDocument caps = this.loggedServices.get(serverID);
|
||||
Operation[] operations = caps.getCapabilities().getOperationsMetadata()
|
||||
.getOperationArray();
|
||||
String url = null;
|
||||
for (Operation operation : operations) {
|
||||
if (operation.getName().equals("DescribeProcess")) {
|
||||
url = operation.getDCPArray()[0].getHTTP().getGetArray()[0]
|
||||
.getHref();
|
||||
}
|
||||
}
|
||||
if (url == null) {
|
||||
throw new WPSClientException(
|
||||
"Missing DescribeOperation in Capabilities");
|
||||
}
|
||||
return retrieveDescriptionViaGET(processIDs, url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a process at a WPS
|
||||
*
|
||||
* @param url
|
||||
* url of server not the entry additionally defined in the caps.
|
||||
* @param execute
|
||||
* Execute document
|
||||
* @return either an ExecuteResponseDocument or an InputStream if asked for
|
||||
* RawData or an Exception Report
|
||||
*/
|
||||
private Object execute(String serverID, ExecuteDocument execute,
|
||||
boolean rawData) throws WPSClientException {
|
||||
CapabilitiesDocument caps = loggedServices.get(serverID);
|
||||
Operation[] operations = caps.getCapabilities().getOperationsMetadata()
|
||||
.getOperationArray();
|
||||
String url = null;
|
||||
for (Operation operation : operations) {
|
||||
if (operation.getName().equals("Execute")) {
|
||||
url = operation.getDCPArray()[0].getHTTP().getPostArray()[0]
|
||||
.getHref();
|
||||
}
|
||||
}
|
||||
if (url == null) {
|
||||
throw new WPSClientException(
|
||||
"Caps does not contain any information about the entry point for process execution");
|
||||
}
|
||||
execute.getExecute().setVersion(SUPPORTED_VERSION);
|
||||
return retrieveExecuteResponseViaPOST(url, execute, rawData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a process at a WPS
|
||||
*
|
||||
* @param url
|
||||
* url of server not the entry additionally defined in the caps.
|
||||
* @param execute
|
||||
* Execute document
|
||||
* @return either an ExecuteResponseDocument or an InputStream if asked for
|
||||
* RawData or an Exception Report
|
||||
*/
|
||||
public Object execute(String serverID, ExecuteDocument execute)
|
||||
throws WPSClientException {
|
||||
if (execute.getExecute().isSetResponseForm() == true
|
||||
&& execute.getExecute().isSetResponseForm() == true
|
||||
&& execute.getExecute().getResponseForm().isSetRawDataOutput() == true) {
|
||||
return execute(serverID, execute, true);
|
||||
} else {
|
||||
return execute(serverID, execute, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private CapabilitiesDocument retrieveCapsViaGET(String url)
|
||||
throws WPSClientException {
|
||||
logger.debug("retrieveCapsViaGET: " + url);
|
||||
ClientCapabiltiesRequest req = new ClientCapabiltiesRequest();
|
||||
url = req.getRequest(url);
|
||||
|
||||
try {
|
||||
String authString = user + ":" + password;
|
||||
logger.debug("auth string: " + authString);
|
||||
byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
|
||||
String encoded = new String(authEncBytes);
|
||||
logger.debug("Base64 encoded auth string: " + encoded);
|
||||
|
||||
URL urlObj = new URL(url);
|
||||
HttpURLConnection connection = (HttpURLConnection) urlObj
|
||||
.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setDoOutput(true);
|
||||
connection.setRequestProperty("Authorization", "Basic " + encoded);
|
||||
InputStream is = connection.getInputStream();
|
||||
Document doc = checkInputStream(is);
|
||||
CapabilitiesDocument capabilitiesDocument = CapabilitiesDocument.Factory
|
||||
.parse(doc, options);
|
||||
return capabilitiesDocument;
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException(
|
||||
"Capabilities URL seems to be unvalid: " + url, e);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException(
|
||||
"Error occured while retrieving capabilities from url: "
|
||||
+ url, e);
|
||||
} catch (XmlException e) {
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException("Error occured while parsing XML", e);
|
||||
}
|
||||
}
|
||||
|
||||
private ProcessDescriptionsDocument retrieveDescriptionViaGET(
|
||||
String[] processIDs, String url) throws WPSClientException {
|
||||
try {
|
||||
logger.debug("RetrieveDescription GET: " + processIDs + " url:"
|
||||
+ url);
|
||||
|
||||
Path tempFile = Files.createTempFile("WPSProcessDescriptions",
|
||||
"txt");
|
||||
|
||||
List<String> lines = new ArrayList<>();
|
||||
lines.add("<wps:ProcessDescriptions xmlns:wps=\"http://www.opengis.net/wps/1.0.0\" "
|
||||
+ "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
|
||||
+ "xmlns:ows=\"http://www.opengis.net/ows/1.1\" "
|
||||
+ "xsi:schemaLocation=\"http://www.opengis.net/wps/1.0.0 "
|
||||
+ "http://schemas.opengis.net/wps/1.0.0/wpsDescribeProcess_response.xsd\" "
|
||||
+ "xml:lang=\"en-US\" "
|
||||
+ "service=\"WPS\" version=\"1.0.0\">");
|
||||
Files.write(tempFile, lines, Charset.defaultCharset(),
|
||||
StandardOpenOption.APPEND);
|
||||
|
||||
for (String processId : processIDs) {
|
||||
String[] process = { processId };
|
||||
DClientDescribeProcessRequest req = new DClientDescribeProcessRequest();
|
||||
req.setIdentifier(process);
|
||||
String requestURL = req.getRequest(url);
|
||||
|
||||
String authString = user + ":" + password;
|
||||
logger.debug("auth string: " + authString);
|
||||
byte[] authEncBytes = Base64
|
||||
.encodeBase64(authString.getBytes());
|
||||
String encoded = new String(authEncBytes);
|
||||
logger.debug("Base64 encoded auth string: " + encoded);
|
||||
|
||||
URL urlObj = new URL(requestURL);
|
||||
HttpURLConnection connection = (HttpURLConnection) urlObj
|
||||
.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setDoOutput(true);
|
||||
connection.setRequestProperty("Authorization", "Basic "
|
||||
+ encoded);
|
||||
InputStream is = connection.getInputStream();
|
||||
lines=retrievesSingleDescription(is);
|
||||
Files.write(tempFile, lines, Charset.defaultCharset(),
|
||||
StandardOpenOption.APPEND);
|
||||
}
|
||||
lines = new ArrayList<>();
|
||||
lines.add("</wps:ProcessDescriptions>");
|
||||
Files.write(tempFile, lines, Charset.defaultCharset(),
|
||||
StandardOpenOption.APPEND);
|
||||
|
||||
logger.debug(tempFile.toString());
|
||||
Document doc=null;
|
||||
try (InputStream inputStream = Files.newInputStream(tempFile,
|
||||
StandardOpenOption.READ)){
|
||||
doc = checkInputStream(inputStream);
|
||||
|
||||
}
|
||||
ProcessDescriptionsDocument processDescriptionsDocument = ProcessDescriptionsDocument.Factory.parse(doc, options);
|
||||
|
||||
Files.delete(tempFile);
|
||||
return processDescriptionsDocument;
|
||||
|
||||
|
||||
} catch (MalformedURLException e) {
|
||||
logger.error("URL seems not to be valid");
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException("URL seems not to be valid", e);
|
||||
} catch (IOException e) {
|
||||
logger.error("Error occured while receiving data");
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException("Error occured while receiving data",
|
||||
e);
|
||||
} catch (XmlException e) {
|
||||
logger.error("Error occured while parsing ProcessDescription document");
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException(
|
||||
"Error occured while parsing ProcessDescription document",
|
||||
e);
|
||||
} catch (Throwable e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException(e.getLocalizedMessage(),
|
||||
new Exception(e));
|
||||
}
|
||||
}
|
||||
|
||||
protected List<String> retrievesSingleDescription(InputStream is) throws WPSClientException {
|
||||
try {
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(is));
|
||||
|
||||
List<String> lines = new ArrayList<>();
|
||||
String line = null;
|
||||
boolean elementProcessDescriptionsFound = false;
|
||||
boolean elementProcessDescriptionsClosureFound = false;
|
||||
|
||||
while ((line = br.readLine()) != null) {
|
||||
if (elementProcessDescriptionsFound) {
|
||||
if (elementProcessDescriptionsClosureFound) {
|
||||
if (line.contains("</wps:ProcessDescriptions>")) {
|
||||
break;
|
||||
} else {
|
||||
lines.add(line);
|
||||
}
|
||||
} else {
|
||||
int closeIndex = line.indexOf(">");
|
||||
if (closeIndex != -1) {
|
||||
elementProcessDescriptionsClosureFound = true;
|
||||
if (closeIndex == line.length() - 1) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (line.contains("<wps:ProcessDescriptions")) {
|
||||
elementProcessDescriptionsFound = true;
|
||||
int closeIndex = line.indexOf(">");
|
||||
if (closeIndex != -1) {
|
||||
elementProcessDescriptionsClosureFound = true;
|
||||
if (closeIndex == line.length() - 1) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return lines;
|
||||
} catch (Throwable e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException(e.getLocalizedMessage(),
|
||||
new Exception(e));
|
||||
}
|
||||
}
|
||||
|
||||
private InputStream retrieveDataViaPOST(XmlObject obj, String urlString)
|
||||
throws WPSClientException {
|
||||
try {
|
||||
logger.debug("RetrieveDataViaPost(): " + urlString);
|
||||
String authString = user + ":" + password;
|
||||
logger.debug("auth string: " + authString);
|
||||
byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
|
||||
String encoded = new String(authEncBytes);
|
||||
logger.debug("Base64 encoded auth string: " + encoded);
|
||||
|
||||
URL url = new URL(urlString);
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("POST");
|
||||
conn.setRequestProperty("Authorization", "Basic " + encoded);
|
||||
conn.setRequestProperty("Accept-Encoding", "gzip");
|
||||
conn.setRequestProperty("Content-Type", "text/xml");
|
||||
conn.setDoOutput(true);
|
||||
obj.save(conn.getOutputStream());
|
||||
InputStream input = null;
|
||||
String encoding = conn.getContentEncoding();
|
||||
if (encoding != null && encoding.equalsIgnoreCase("gzip")) {
|
||||
input = new GZIPInputStream(conn.getInputStream());
|
||||
} else {
|
||||
input = conn.getInputStream();
|
||||
}
|
||||
return input;
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException("URL seems to be unvalid", e);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException("Error while transmission", e);
|
||||
}
|
||||
}
|
||||
|
||||
private Document checkInputStream(InputStream is) throws WPSClientException {
|
||||
try {
|
||||
DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance();
|
||||
fac.setNamespaceAware(true);
|
||||
Document doc = fac.newDocumentBuilder().parse(is);
|
||||
logger.debug("Document: " + doc);
|
||||
if (doc == null) {
|
||||
logger.error("Document is null");
|
||||
throw new WPSClientException(
|
||||
"Error in check input stream: Document is null");
|
||||
}
|
||||
|
||||
if (getFirstElementNode(doc.getFirstChild()).getLocalName().equals(
|
||||
"ExceptionReport")
|
||||
&& getFirstElementNode(doc.getFirstChild())
|
||||
.getNamespaceURI().equals(OGC_OWS_URI)) {
|
||||
try {
|
||||
ExceptionReportDocument exceptionDoc = ExceptionReportDocument.Factory
|
||||
.parse(doc);
|
||||
logger.debug(exceptionDoc.xmlText(options));
|
||||
throw new WPSClientException(
|
||||
"Error occured while executing query", exceptionDoc);
|
||||
} catch (XmlException e) {
|
||||
throw new WPSClientException(
|
||||
"Error while parsing ExceptionReport retrieved from server",
|
||||
e);
|
||||
}
|
||||
} else {
|
||||
logger.debug("No Exception Report");
|
||||
}
|
||||
return doc;
|
||||
} catch (SAXException e) {
|
||||
logger.error("Error while parsing input: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException("Error while parsing input", e);
|
||||
} catch (IOException e) {
|
||||
logger.error("Error occured while transfer: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException("Error occured while transfer", e);
|
||||
} catch (ParserConfigurationException e) {
|
||||
logger.error("Error occured, parser is not correctly configured: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException(
|
||||
"Error occured, parser is not correctly configured", e);
|
||||
} catch (WPSClientException e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private Node getFirstElementNode(Node node) {
|
||||
if (node == null) {
|
||||
return null;
|
||||
}
|
||||
if (node.getNodeType() == Node.ELEMENT_NODE) {
|
||||
return node;
|
||||
} else {
|
||||
return getFirstElementNode(node.getNextSibling());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* either an ExecuteResponseDocument or an InputStream if asked for RawData
|
||||
* or an Exception Report
|
||||
*
|
||||
* @param url
|
||||
* @param doc
|
||||
* @param rawData
|
||||
* @return
|
||||
* @throws WPSClientException
|
||||
*/
|
||||
private Object retrieveExecuteResponseViaPOST(String url,
|
||||
ExecuteDocument doc, boolean rawData) throws WPSClientException {
|
||||
InputStream is = retrieveDataViaPOST(doc, url);
|
||||
if (rawData) {
|
||||
return is;
|
||||
}
|
||||
Document documentObj = checkInputStream(is);
|
||||
ExceptionReportDocument erDoc = null;
|
||||
try {
|
||||
|
||||
return ExecuteResponseDocument.Factory.parse(documentObj);
|
||||
} catch (XmlException e) {
|
||||
try {
|
||||
erDoc = ExceptionReportDocument.Factory.parse(documentObj);
|
||||
} catch (XmlException e1) {
|
||||
throw new WPSClientException(
|
||||
"Error occured while parsing executeResponse", e);
|
||||
}
|
||||
return erDoc;
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getProcessNames(String url) throws IOException {
|
||||
ProcessDescriptionType[] processes = getProcessDescriptionsFromCache(
|
||||
url).getProcessDescriptions().getProcessDescriptionArray();
|
||||
String[] processNames = new String[processes.length];
|
||||
for (int i = 0; i < processNames.length; i++) {
|
||||
processNames[i] = processes[i].getIdentifier().getStringValue();
|
||||
}
|
||||
return processNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a process at a WPS
|
||||
*
|
||||
* @param url
|
||||
* url of server not the entry additionally defined in the caps.
|
||||
* @param executeAsGETString
|
||||
* KVP Execute request
|
||||
* @return either an ExecuteResponseDocument or an InputStream if asked for
|
||||
* RawData or an Exception Report
|
||||
*/
|
||||
public Object executeViaGET(String urlString, String executeAsGETString)
|
||||
throws WPSClientException {
|
||||
urlString = urlString + executeAsGETString;
|
||||
logger.debug("ExecuteViaGet() Url: " + urlString);
|
||||
try {
|
||||
// TODO
|
||||
String authString = user + ":" + password;
|
||||
logger.debug("auth string: " + authString);
|
||||
byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
|
||||
String encoded = new String(authEncBytes);
|
||||
logger.debug("Base64 encoded auth string: " + encoded);
|
||||
|
||||
URL url = new URL(urlString);
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("GET");
|
||||
conn.setRequestProperty("Authorization", "Basic " + encoded);
|
||||
conn.setDoOutput(true);
|
||||
InputStream is = conn.getInputStream();
|
||||
|
||||
if (executeAsGETString.toUpperCase().contains("RAWDATA")) {
|
||||
logger.debug("ExecuteAsGETString as RAWDATA");
|
||||
return is;
|
||||
}
|
||||
Document doc = checkInputStream(is);
|
||||
ExceptionReportDocument erDoc = null;
|
||||
logger.debug("ExecuteAsGETString as Document");
|
||||
|
||||
try {
|
||||
return ExecuteResponseDocument.Factory.parse(doc);
|
||||
} catch (XmlException e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
erDoc = ExceptionReportDocument.Factory.parse(doc);
|
||||
} catch (XmlException e1) {
|
||||
e1.printStackTrace();
|
||||
throw new WPSClientException(
|
||||
"Error occured while parsing executeResponse", e);
|
||||
|
||||
}
|
||||
throw new WPSClientException(
|
||||
"Error occured while parsing executeResponse", erDoc);
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException(
|
||||
"Capabilities URL seems to be unvalid: " + urlString, e);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException(
|
||||
"Error occured while retrieving capabilities from url: "
|
||||
+ urlString, e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String cancelComputation(String url, String computationId)
|
||||
throws WPSClientException {
|
||||
|
||||
try {
|
||||
String authString = user + ":" + password;
|
||||
logger.debug("auth string: " + authString);
|
||||
byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
|
||||
String encoded = new String(authEncBytes);
|
||||
logger.debug("Base64 encoded auth string: " + encoded);
|
||||
|
||||
url += "?id=" + computationId;
|
||||
URL urlObj = new URL(url);
|
||||
HttpURLConnection connection = (HttpURLConnection) urlObj
|
||||
.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setDoOutput(true);
|
||||
connection.setRequestProperty("Authorization", "Basic " + encoded);
|
||||
String responseMessage = connection.getResponseMessage();
|
||||
return responseMessage;
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException(
|
||||
"Capabilities URL seems to be unvalid: " + url, e);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new WPSClientException(
|
||||
"Error occured while retrieving capabilities from url: "
|
||||
+ url, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,556 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.server.dmservice.wps;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.opengis.ows.x11.AllowedValuesDocument.AllowedValues;
|
||||
import net.opengis.ows.x11.DomainMetadataType;
|
||||
import net.opengis.ows.x11.ValueType;
|
||||
import net.opengis.wps.x100.ComplexDataDescriptionType;
|
||||
import net.opengis.wps.x100.InputDescriptionType;
|
||||
import net.opengis.wps.x100.LiteralInputType;
|
||||
import net.opengis.wps.x100.LiteralOutputType;
|
||||
import net.opengis.wps.x100.OutputDescriptionType;
|
||||
import net.opengis.wps.x100.SupportedComplexDataInputType;
|
||||
import net.opengis.wps.x100.SupportedComplexDataType;
|
||||
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.exception.ServiceException;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.ColumnListParameter;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.ColumnParameter;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.DateParameter;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.EnumParameter;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.FileParameter;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.ListParameter;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.ObjectParameter;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.TabularListParameter;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.TabularParameter;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.TimeParameter;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.WKTGeometryType;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.WKTParameter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class WPS2DM {
|
||||
private final static String SEPARATOR = "|";
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(WPS2DM.class);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param title
|
||||
* @param minOcc
|
||||
* @param maxOcc
|
||||
* @param rangeOccs
|
||||
* @param id
|
||||
* @param crs
|
||||
* @return
|
||||
*/
|
||||
public static Parameter manageBoundingBoxInformation(String title,
|
||||
int minOcc, int maxOcc, int rangeOccs, String id, String crs) {
|
||||
Parameter converted = null;
|
||||
title = "Bounding Box Input in OGC 06-121r3 spec. E.g. 102,46,103,47,urn:ogc:def:crs:EPSG:4328 "
|
||||
+ title;
|
||||
if (crs != null && crs.length() > 0)
|
||||
title += " Supported CRS " + crs;
|
||||
|
||||
title = buildParameterDescription(title, null, null, minOcc, maxOcc,
|
||||
null);
|
||||
if ((maxOcc == 1) || (maxOcc < 0) || (maxOcc == 0))
|
||||
converted = new ObjectParameter(id, title, String.class.getName(),
|
||||
" ");
|
||||
|
||||
else
|
||||
converted = new ListParameter(id, title, String.class.getName(),
|
||||
SEPARATOR);
|
||||
|
||||
return converted;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param title
|
||||
* @param minOcc
|
||||
* @param maxOcc
|
||||
* @param rangeOccs
|
||||
* @param defaultValue
|
||||
* @param id
|
||||
* @param uoms
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public static Parameter manageLiteral(String title, int minOcc, int maxOcc,
|
||||
int rangeOccs, String defaultValue, String id, String uoms,
|
||||
DomainMetadataType type) {
|
||||
Parameter converted = null;
|
||||
logger.debug("WPS type:" + type.getStringValue());
|
||||
String guessedType = guessWPSLiteralType(type);
|
||||
logger.debug("Guessed type: " + guessedType);
|
||||
|
||||
// rebuild title
|
||||
if ((defaultValue == null || defaultValue.trim().length() == 0))
|
||||
defaultValue = guessDefaultValue(guessedType);
|
||||
|
||||
logger.debug("Guessed default value: " + defaultValue);
|
||||
|
||||
title = buildParameterDescription(title, null, uoms, minOcc, maxOcc,
|
||||
defaultValue);
|
||||
if ((maxOcc == 1) || (maxOcc < 0) || (maxOcc == 0)) {
|
||||
if (title != null && !title.isEmpty()) {
|
||||
if (title.contains("[a sequence of names of columns from ")) {
|
||||
Pattern pattern = Pattern
|
||||
.compile("a sequence of names of columns from (\\w+) separated by (\\p{ASCII})");
|
||||
Matcher matcher = pattern.matcher(title);
|
||||
logger.debug("Machter title: " + title);
|
||||
logger.debug("Machter find: " + matcher.find());
|
||||
logger.debug("Machter group: " + matcher.group());
|
||||
logger.debug("Machter start: " + matcher.start());
|
||||
logger.debug("Machter end: " + matcher.end());
|
||||
logger.debug("Machter Group Count: " + matcher.groupCount());
|
||||
String referredTabularParameterName = matcher.group(1);
|
||||
logger.debug("Matcher referredTabularParameterName: "
|
||||
+ referredTabularParameterName);
|
||||
String separator = matcher.group(2);
|
||||
logger.debug("Matcher separator: " + separator);
|
||||
|
||||
converted = new ColumnListParameter(id, title,
|
||||
referredTabularParameterName, separator);
|
||||
} else {
|
||||
if (title.contains("[the name of a column from ")) {
|
||||
Pattern pattern = Pattern
|
||||
.compile("the name of a column from (\\w+)");
|
||||
Matcher matcher = pattern.matcher(title);
|
||||
logger.debug("Machter title: " + title);
|
||||
logger.debug("Machter find: " + matcher.find());
|
||||
logger.debug("Machter group: " + matcher.group());
|
||||
logger.debug("Machter start: " + matcher.start());
|
||||
logger.debug("Machter end: " + matcher.end());
|
||||
logger.debug("Machter Group Count: "
|
||||
+ matcher.groupCount());
|
||||
String referredTabularParameterName = matcher.group(1);
|
||||
logger.debug("Matcher referredTabularParameterName: "
|
||||
+ referredTabularParameterName);
|
||||
|
||||
converted = new ColumnParameter(id, title,
|
||||
referredTabularParameterName, defaultValue);
|
||||
} else {
|
||||
if (title
|
||||
.contains("[a sequence of values separated by ")) {
|
||||
Pattern pattern = Pattern
|
||||
.compile("a sequence of values separated by (\\p{ASCII})");
|
||||
Matcher matcher = pattern.matcher(title);
|
||||
logger.debug("Machter title: " + title);
|
||||
logger.debug("Machter find: " + matcher.find());
|
||||
logger.debug("Machter group: " + matcher.group());
|
||||
logger.debug("Machter start: " + matcher.start());
|
||||
logger.debug("Machter end: " + matcher.end());
|
||||
logger.debug("Machter Group Count: "
|
||||
+ matcher.groupCount());
|
||||
|
||||
String separator = matcher.group(1);
|
||||
logger.debug("Matcher separator: " + separator);
|
||||
|
||||
converted = new ListParameter(id, title,
|
||||
guessedType, separator);
|
||||
} else {
|
||||
if (title.contains("[WKT_")) {
|
||||
logger.debug("WKT parameter: " + title);
|
||||
converted = retrieveWKTParameter(id, title,
|
||||
defaultValue);
|
||||
} else {
|
||||
if (title.contains("[DATE]")) {
|
||||
logger.debug("DATE parameter: " + title);
|
||||
title = title.replace("[DATE]", "");
|
||||
converted = new DateParameter(id, title,
|
||||
defaultValue);
|
||||
} else {
|
||||
if (title.contains("[TIME]")) {
|
||||
logger.debug("TIME parameter: " + title);
|
||||
title = title.replace("[TIME]", "");
|
||||
converted = new TimeParameter(id,
|
||||
title, defaultValue);
|
||||
} else {
|
||||
converted = new ObjectParameter(
|
||||
id,
|
||||
title,
|
||||
guessPrimitiveType(guessedType),
|
||||
defaultValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
converted = new ObjectParameter(id, title,
|
||||
guessPrimitiveType(guessedType), defaultValue);
|
||||
}
|
||||
|
||||
} else
|
||||
converted = new ListParameter(id, title, String.class.getName(),
|
||||
SEPARATOR);
|
||||
return converted;
|
||||
}
|
||||
|
||||
private static Parameter retrieveWKTParameter(String id, String title,
|
||||
String defaultValue) {
|
||||
|
||||
if (title.contains("[WKT_POINT]")) {
|
||||
title = title.replace("[WKT_POINT]", "");
|
||||
return new WKTParameter(id, title, WKTGeometryType.Point,
|
||||
defaultValue);
|
||||
} else {
|
||||
if (title.contains("[WKT_LINESTRING]")) {
|
||||
title = title.replace("[WKT_LINESTRING]", "");
|
||||
return new WKTParameter(id, title, WKTGeometryType.LineString,
|
||||
defaultValue);
|
||||
} else {
|
||||
if (title.contains("[WKT_POLYGON]")) {
|
||||
title = title.replace("[WKT_POLYGON]", "");
|
||||
return new WKTParameter(id, title, WKTGeometryType.Polygon,
|
||||
defaultValue);
|
||||
} else {
|
||||
if (title.contains("[WKT_CIRCLE]")) {
|
||||
title = title.replace("[WKT_CIRCLE]", "");
|
||||
return new WKTParameter(id, title,
|
||||
WKTGeometryType.Circle, defaultValue);
|
||||
} else {
|
||||
if (title.contains("[WKT_TRIANGLE]")) {
|
||||
title = title.replace("[WKT_TRIANGLE]", "");
|
||||
return new WKTParameter(id, title,
|
||||
WKTGeometryType.Triangle, defaultValue);
|
||||
} else {
|
||||
if (title.contains("[WKT_SQUARE]")) {
|
||||
title = title.replace("[WKT_SQUARE]", "");
|
||||
return new WKTParameter(id, title,
|
||||
WKTGeometryType.Square, defaultValue);
|
||||
} else {
|
||||
if (title.contains("[WKT_PENTAGON]")) {
|
||||
title = title.replace("[WKT_PENTAGON]", "");
|
||||
return new WKTParameter(id, title,
|
||||
WKTGeometryType.Pentagon,
|
||||
defaultValue);
|
||||
} else {
|
||||
if (title.contains("[WKT_HEXAGON]")) {
|
||||
title = title.replace("[WKT_HEXAGON]",
|
||||
"");
|
||||
return new WKTParameter(id, title,
|
||||
WKTGeometryType.Hexagon,
|
||||
defaultValue);
|
||||
} else {
|
||||
if (title.contains("[WKT_BOX]")) {
|
||||
title = title.replace("[WKT_BOX]",
|
||||
"");
|
||||
return new WKTParameter(id, title,
|
||||
WKTGeometryType.Box,
|
||||
defaultValue);
|
||||
} else {
|
||||
return new WKTParameter(id, title,
|
||||
WKTGeometryType.Polygon,
|
||||
defaultValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param maxMegaBytes
|
||||
* @param title
|
||||
* @param minOcc
|
||||
* @param maxOcc
|
||||
* @param rangeOccs
|
||||
* @param id
|
||||
* @param defaultType
|
||||
* @return
|
||||
*/
|
||||
public static Parameter manageComplexData(String maxMegaBytes,
|
||||
String title, int minOcc, int maxOcc, int rangeOccs, String id,
|
||||
ComplexDataDescriptionType defaultType,
|
||||
ComplexDataDescriptionType[] supportedTypes) {
|
||||
Parameter converted = null;
|
||||
String mimeType = null;
|
||||
String schema = null;
|
||||
String encoding = null;
|
||||
ArrayList<String> supportedMimeTypes = new ArrayList<String>();
|
||||
|
||||
// GenericFileDataConstants.MIME_TYPE_TEXT_XML
|
||||
mimeType = defaultType.getMimeType();
|
||||
schema = defaultType.getSchema();
|
||||
encoding = defaultType.getEncoding();
|
||||
|
||||
logger.debug("Default MimeType: " + mimeType);
|
||||
logger.debug("Default Schema: " + schema);
|
||||
logger.debug("Default Encoding: " + encoding);
|
||||
|
||||
for (ComplexDataDescriptionType supported : supportedTypes) {
|
||||
supportedMimeTypes.add(supported.getMimeType());
|
||||
}
|
||||
// rebuild title
|
||||
title = buildParameterDescription(title, maxMegaBytes, null, minOcc,
|
||||
maxOcc, null);
|
||||
if ((maxOcc == 1) || (maxOcc < 0) || (maxOcc == 0)) {
|
||||
if (title != null && !title.isEmpty()) {
|
||||
if (title.contains("[a http link to a table")) {
|
||||
converted = new TabularParameter(id, title, " ",
|
||||
new ArrayList<String>(), mimeType,
|
||||
supportedMimeTypes);
|
||||
} else {
|
||||
if (title.contains("[a http link to a file")) {
|
||||
converted = new FileParameter(id, title, mimeType,
|
||||
supportedMimeTypes);
|
||||
} else {
|
||||
if (title.contains("[a sequence of http links")) {
|
||||
Pattern pattern = Pattern
|
||||
.compile("\\[a sequence of http links separated by (\\p{ASCII}) , each indicating a table");
|
||||
|
||||
Matcher matcher = pattern.matcher(title);
|
||||
boolean match = false;
|
||||
if (match = matcher.find()) {
|
||||
logger.debug("Machter title: " + title);
|
||||
logger.debug("Machter find: " + match);
|
||||
logger.debug("Machter group: "
|
||||
+ matcher.group());
|
||||
logger.debug("Machter start: "
|
||||
+ matcher.start());
|
||||
logger.debug("Machter end: " + matcher.end());
|
||||
logger.debug("Machter Group Count: "
|
||||
+ matcher.groupCount());
|
||||
String separator = matcher.group(1);
|
||||
logger.debug("Matcher separator: " + separator);
|
||||
converted = new TabularListParameter(id, title,
|
||||
separator, mimeType, supportedMimeTypes);
|
||||
} else {
|
||||
converted = new FileParameter(id, title,
|
||||
mimeType, supportedMimeTypes);
|
||||
}
|
||||
} else {
|
||||
converted = new FileParameter(id, title, mimeType,
|
||||
supportedMimeTypes);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
converted = new FileParameter(id, title, mimeType,
|
||||
supportedMimeTypes);
|
||||
}
|
||||
} else {
|
||||
converted = new FileParameter(id, title, mimeType,
|
||||
supportedMimeTypes);
|
||||
}
|
||||
return converted;
|
||||
}
|
||||
|
||||
public static Parameter convert2DMType(InputDescriptionType wpsType)
|
||||
throws ServiceException {
|
||||
try {
|
||||
|
||||
String id = wpsType.getIdentifier().getStringValue();
|
||||
|
||||
String title = wpsType.getTitle() != null ? wpsType.getTitle()
|
||||
.getStringValue() : "";
|
||||
int minOcc = wpsType.getMinOccurs().intValue();
|
||||
int maxOcc = wpsType.getMaxOccurs().intValue();
|
||||
int rangeOccs = maxOcc - minOcc;
|
||||
if (rangeOccs == 0)
|
||||
rangeOccs = 1;
|
||||
|
||||
// default
|
||||
Parameter converted = new ObjectParameter(id, title,
|
||||
String.class.getName(), " ");
|
||||
if (rangeOccs > 1)
|
||||
converted = new ListParameter(id, title,
|
||||
String.class.getName(), SEPARATOR);
|
||||
|
||||
// Bounding Boxes
|
||||
if (wpsType.isSetBoundingBoxData()) {
|
||||
logger.debug("Conversion to DM Type->" + id
|
||||
+ " is a Bounding Box Input");
|
||||
converted = manageBoundingBoxInformation(title, minOcc, maxOcc,
|
||||
rangeOccs, id, wpsType.getBoundingBoxData()
|
||||
.getDefault().getCRS());
|
||||
}
|
||||
// Literals
|
||||
else if (wpsType.isSetLiteralData()) {
|
||||
logger.debug("Conversion to DM Type->" + id
|
||||
+ " is a Literal Input");
|
||||
LiteralInputType literal = wpsType.getLiteralData();
|
||||
String uoms = literal.getUOMs() == null ? "" : literal
|
||||
.getUOMs().getDefault().getUOM().getStringValue();
|
||||
String defaultValue = literal.getDefaultValue();
|
||||
converted = manageLiteral(title, minOcc, maxOcc, rangeOccs,
|
||||
defaultValue, id, uoms, literal.getDataType());
|
||||
AllowedValues allowedValues = literal.getAllowedValues();
|
||||
if (allowedValues != null) {
|
||||
ValueType[] values = allowedValues.getValueArray();
|
||||
logger.debug("ValueType[]:" + Arrays.toString(values));
|
||||
List<String> enumValues = new ArrayList<>();
|
||||
|
||||
for (ValueType v : values) {
|
||||
enumValues.add(v.getStringValue());
|
||||
}
|
||||
if (values.length > 1) {
|
||||
ObjectParameter conv = (ObjectParameter) converted;
|
||||
converted = new EnumParameter(conv.getName(),
|
||||
conv.getDescription(), enumValues,
|
||||
conv.getDefaultValue());
|
||||
}
|
||||
}
|
||||
} else if (wpsType.isSetComplexData()) {
|
||||
logger.debug("Conversion to DM Type->" + id
|
||||
+ " is a Complex Input");
|
||||
SupportedComplexDataInputType complex = wpsType
|
||||
.getComplexData();
|
||||
String maxMegaBytes = complex.getMaximumMegabytes() != null ? complex
|
||||
.getMaximumMegabytes().toString() : "1";
|
||||
logger.debug("Max Megabytes: " + maxMegaBytes);
|
||||
converted = manageComplexData(maxMegaBytes, title, minOcc,
|
||||
maxOcc, rangeOccs, id,
|
||||
complex.getDefault().getFormat(), complex
|
||||
.getSupported().getFormatArray());
|
||||
|
||||
}
|
||||
|
||||
logger.debug("Conversion to DM Type->Name=" + id);
|
||||
logger.debug("Conversion to DM Type->Title=" + title);
|
||||
logger.debug("Conversion to DM Type->Number of Inputs to Manage="
|
||||
+ rangeOccs);
|
||||
|
||||
return converted;
|
||||
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
logger.error(e.getLocalizedMessage());
|
||||
throw new ServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static Parameter convert2DMType(OutputDescriptionType wpsType) {
|
||||
|
||||
String id = wpsType.getIdentifier().getStringValue();
|
||||
String title = wpsType.getTitle() != null ? wpsType.getTitle()
|
||||
.getStringValue() : "";
|
||||
|
||||
// default
|
||||
Parameter converted = new ObjectParameter(id, title,
|
||||
String.class.getName(), " ");
|
||||
|
||||
logger.debug("Conversion to DM Type->Output id:" + id);
|
||||
logger.debug("Conversion to DM Type->Title:" + title);
|
||||
|
||||
// Bounding Boxes
|
||||
if (wpsType.isSetBoundingBoxOutput()) {
|
||||
logger.debug("Bounding Box Output");
|
||||
converted = manageBoundingBoxInformation(title, -1, -1, -1, id, "");
|
||||
}
|
||||
// Literals
|
||||
else if (wpsType.isSetLiteralOutput()) {
|
||||
logger.debug("Literal Output");
|
||||
LiteralOutputType literal = wpsType.getLiteralOutput();
|
||||
String uoms = literal.getUOMs() == null ? "" : literal.getUOMs()
|
||||
.toString();
|
||||
converted = manageLiteral(title, -1, -1, -1, "", id, uoms,
|
||||
literal.getDataType());
|
||||
} else if (wpsType.isSetComplexOutput()) {
|
||||
logger.debug("Complex Output");
|
||||
SupportedComplexDataType complex = wpsType.getComplexOutput();
|
||||
converted = manageComplexData("", title, -1, -1, -1, id, complex
|
||||
.getDefault().getFormat(), complex.getSupported()
|
||||
.getFormatArray());
|
||||
}
|
||||
|
||||
return converted;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param title
|
||||
* @param maxMegabytes
|
||||
* @param UoM
|
||||
* @param minElements
|
||||
* @param maxElements
|
||||
* @param defaultValue
|
||||
* @return
|
||||
*/
|
||||
public static String buildParameterDescription(String title,
|
||||
String maxMegabytes, String UoM, int minElements, int maxElements,
|
||||
String defaultValue) {
|
||||
|
||||
String description = title;
|
||||
/*
|
||||
* String innerDescription = "";
|
||||
*
|
||||
* if (maxMegabytes != null && maxMegabytes.trim().length() > 0) {
|
||||
* innerDescription += "Max MB Size:" + maxMegabytes.trim() + "; "; } if
|
||||
* (UoM != null && UoM.trim().length() > 0) { innerDescription +=
|
||||
* "Unit of Measure:" + UoM.trim() + "; "; } if (minElements > 0) {
|
||||
* innerDescription += "Min N. of Entries:" + minElements + "; "; } if
|
||||
* (maxElements > 0) { innerDescription += "Max N. of Entries:" +
|
||||
* maxElements + "; "; } if (defaultValue != null &&
|
||||
* defaultValue.trim().length() > 0) { innerDescription += "default:" +
|
||||
* defaultValue.trim() + "; "; }
|
||||
*
|
||||
* if (innerDescription.length() > 0) description += " [" +
|
||||
* innerDescription.substring(0,
|
||||
* innerDescription.lastIndexOf(";")).trim() + "]";
|
||||
*/
|
||||
return description;
|
||||
|
||||
}
|
||||
|
||||
public static String guessWPSLiteralType(DomainMetadataType type) {
|
||||
|
||||
if (type == null || type.getStringValue() == null)
|
||||
return String.class.getName();
|
||||
else {
|
||||
String typeS = type.getReference().trim();
|
||||
if (typeS.length() == 0)
|
||||
return String.class.getName();
|
||||
else if (typeS.contains("float") || typeS.contains("double")
|
||||
|| typeS.contains("decimal"))
|
||||
return Double.class.getName();
|
||||
else if (typeS.contains("int"))
|
||||
return Integer.class.getName();
|
||||
else if (typeS.contains("long"))
|
||||
return Long.class.getName();
|
||||
else if (typeS.contains("short"))
|
||||
return Short.class.getName();
|
||||
}
|
||||
|
||||
return String.class.getName();
|
||||
}
|
||||
|
||||
public static String guessDefaultValue(String type) {
|
||||
if (type.equals(String.class.getName()))
|
||||
return " ";
|
||||
else
|
||||
return "0";
|
||||
}
|
||||
|
||||
public static String guessPrimitiveType(String type) {
|
||||
if (type.equals(Integer.class.getName())) {
|
||||
return Integer.class.getName();
|
||||
} else if (type.equals(String.class.getName())) {
|
||||
return String.class.getName();
|
||||
} else if (type.equals(Boolean.class.getName())) {
|
||||
return Boolean.class.getName();
|
||||
} else if (type.equals(Double.class.getName())) {
|
||||
return Double.class.getName();
|
||||
} else if (type.equals(Float.class.getName())) {
|
||||
return Float.class.getName();
|
||||
} else
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,155 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.server.dmservice.wps.computationsvalue;
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationItemPropertiesValue;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationValue;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationValueFile;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationValueFileList;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationValueImage;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ComputationValueBuilder {
|
||||
private static Logger logger = LoggerFactory
|
||||
.getLogger(ComputationValueBuilder.class);
|
||||
|
||||
private ArrayList<ComputationItemPropertiesValue> valueParameters;
|
||||
private LinkedHashMap<String, ComputationValue> computationsValueParameters;
|
||||
|
||||
public ComputationValueBuilder(
|
||||
ArrayList<ComputationItemPropertiesValue> valueParameters) {
|
||||
this.valueParameters = valueParameters;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public LinkedHashMap<String, ComputationValue> create() {
|
||||
computationsValueParameters = new LinkedHashMap<String, ComputationValue>();
|
||||
if (valueParameters != null && !valueParameters.isEmpty()) {
|
||||
for (ComputationItemPropertiesValue valueParameter : valueParameters) {
|
||||
String value = valueParameter.getValue();
|
||||
if (value != null && !value.isEmpty()
|
||||
&& value.startsWith("http")) {
|
||||
if (value.contains("|")) {
|
||||
ComputationValue valueFileList = createComputationValueFileList(value);
|
||||
computationsValueParameters.put(
|
||||
valueParameter.getKey(), valueFileList);
|
||||
} else {
|
||||
ComputationValue computationValue = retrieveFileName(value);
|
||||
computationsValueParameters.put(
|
||||
valueParameter.getKey(), computationValue);
|
||||
}
|
||||
} else {
|
||||
ComputationValue valueString = new ComputationValue(value);
|
||||
computationsValueParameters.put(valueParameter.getKey(),
|
||||
valueString);
|
||||
}
|
||||
}
|
||||
}
|
||||
logger.debug("CompuatationsValues: " + computationsValueParameters);
|
||||
return computationsValueParameters;
|
||||
|
||||
}
|
||||
|
||||
private ComputationValue createComputationValueFileList(String value) {
|
||||
ArrayList<ComputationValue> fileList = new ArrayList<>();
|
||||
int indexSeparator;
|
||||
String file;
|
||||
ComputationValue computationValue;
|
||||
while ((indexSeparator = value.indexOf("|")) != -1) {
|
||||
file = value.substring(0, indexSeparator);
|
||||
value = value.substring(indexSeparator + 1);
|
||||
computationValue = retrieveFileName(file);
|
||||
fileList.add(computationValue);
|
||||
}
|
||||
computationValue = retrieveFileName(value);
|
||||
fileList.add(computationValue);
|
||||
ComputationValueFileList computationValueFileList = new ComputationValueFileList(
|
||||
fileList, "|");
|
||||
return computationValueFileList;
|
||||
|
||||
}
|
||||
|
||||
private ComputationValue retrieveFileName(final String value) {
|
||||
URLConnection conn = null;
|
||||
logger.debug("Retrieve File Header from Storage for value: " + value);
|
||||
try {
|
||||
// Use URL connection because in internal network is more fast
|
||||
URL url = new URL(value);
|
||||
conn = url.openConnection();
|
||||
return extractFileName(conn, value);
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error("Retrieve File Name: " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
return new ComputationValueFile(value, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
private ComputationValue extractFileName(URLConnection conn, String value) {
|
||||
ComputationValue computationValue = null;
|
||||
String fileName = null;
|
||||
String mimeType = null;
|
||||
|
||||
logger.debug("Connection-Header: " + conn.getHeaderFields());
|
||||
|
||||
String contentDisposition = conn.getHeaderField("Content-Disposition");
|
||||
if (contentDisposition == null) {
|
||||
Map<String, List<String>> headerFields = conn.getHeaderFields();
|
||||
boolean found = false;
|
||||
for (String key : headerFields.keySet()) {
|
||||
List<String> headerField = headerFields.get(key);
|
||||
for (String fieldValue : headerField) {
|
||||
if (fieldValue.toLowerCase().contains("filename=")) {
|
||||
contentDisposition = fieldValue;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logger.debug("Content-Disposition: " + contentDisposition);
|
||||
// Content-Disposition="attachment; filename=abc.png"
|
||||
if (contentDisposition != null && contentDisposition.indexOf("=") != -1) {
|
||||
fileName = contentDisposition.split("=")[1]; // getting value
|
||||
// after '='
|
||||
if (fileName != null && !fileName.isEmpty()) {
|
||||
if (fileName.startsWith("\"")) {
|
||||
fileName = fileName.substring(1);
|
||||
}
|
||||
if (fileName.endsWith("\"")) {
|
||||
fileName = fileName.substring(0, fileName.length() - 1);
|
||||
}
|
||||
}
|
||||
} else { // fall back to random generated file name? }
|
||||
}
|
||||
mimeType = conn.getContentType();
|
||||
if ((mimeType != null && mimeType.compareToIgnoreCase("image/png") == 0)
|
||||
|| fileName != null && fileName.endsWith(".png")) {
|
||||
computationValue = new ComputationValueImage(value, fileName,
|
||||
mimeType);
|
||||
} else {
|
||||
computationValue = new ComputationValueFile(value, fileName,
|
||||
mimeType);
|
||||
}
|
||||
|
||||
return computationValue;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.server.is;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||
import org.gcube.resources.discovery.icclient.ICFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class InformationSystemUtils {
|
||||
|
||||
private static Logger logger = LoggerFactory
|
||||
.getLogger(InformationSystemUtils.class);
|
||||
|
||||
public static List<String> retrieveServiceAddress(String category,
|
||||
String name, String scope) throws Exception {
|
||||
try {
|
||||
|
||||
if (scope == null || scope.length() == 0)
|
||||
return new ArrayList<String>();
|
||||
|
||||
ScopeProvider.instance.set(scope);
|
||||
|
||||
SimpleQuery query = ICFactory.queryFor(ServiceEndpoint.class);
|
||||
query.addCondition(
|
||||
"$resource/Profile/Category/text() eq '" + category + "'")
|
||||
.addCondition(
|
||||
"$resource/Profile/Name/text() eq '" + name + "'")
|
||||
.setResult(
|
||||
"$resource/Profile/AccessPoint/Interface/Endpoint/text()");
|
||||
DiscoveryClient<String> client = ICFactory.client();
|
||||
List<String> addresses = client.submit(query);
|
||||
|
||||
return addresses;
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error in discovery DataMiner Service Endpoint in scope: "
|
||||
+ scope);
|
||||
logger.error("Error: " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.server.monitor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Timer;
|
||||
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.dmservice.SClient;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationId;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* DataManager basic Monitor
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class DMMonitor {
|
||||
private static Logger logger = LoggerFactory.getLogger(DMMonitor.class);
|
||||
private static final int SLEEP = 1000;
|
||||
private static final int DELAY = 2000;
|
||||
private static final int PERIOD = 1000;
|
||||
private ComputationId computationId;
|
||||
private SClient sClient;
|
||||
private ArrayList<DMMonitorListener> listeners = new ArrayList<DMMonitorListener>();
|
||||
private Timer timer;
|
||||
private boolean notEnd;
|
||||
|
||||
public DMMonitor(ComputationId computationId, SClient sClient) {
|
||||
logger.debug("DMMonitor");
|
||||
this.computationId = computationId;
|
||||
this.sClient = sClient;
|
||||
|
||||
}
|
||||
|
||||
public void add(DMMonitorListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
public void addAll(ArrayList<DMMonitorListener> listeners) {
|
||||
this.listeners.addAll(listeners);
|
||||
}
|
||||
|
||||
public void start() {
|
||||
try {
|
||||
logger.debug("Start Monitoring");
|
||||
notEnd=true;
|
||||
timer = new Timer(false);
|
||||
DMMonitorTask dmMonitorTask = new DMMonitorTask(this, computationId,
|
||||
sClient, listeners);
|
||||
logger.debug("Start: " + new Date());
|
||||
timer.schedule(dmMonitorTask, DELAY, PERIOD);
|
||||
|
||||
while (notEnd){
|
||||
Thread.sleep(SLEEP);
|
||||
}
|
||||
logger.debug("End run");
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
if (timer != null)
|
||||
timer.cancel();
|
||||
notEnd=false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.server.monitor;
|
||||
|
||||
/**
|
||||
* Defines a listener for operation progress.
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public interface DMMonitorListener {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Called when the operation is starting.
|
||||
*/
|
||||
public void accepted();
|
||||
|
||||
/**
|
||||
* Called when there is a progress for the operation.
|
||||
* @param elaborated the elaborated part.
|
||||
*/
|
||||
public void cancelled();
|
||||
|
||||
/**
|
||||
* Called when the operation is complete
|
||||
* @param percentage
|
||||
* @param endDate
|
||||
*/
|
||||
public void complete(double percentage);
|
||||
|
||||
|
||||
/**
|
||||
* Called when the operation is failed
|
||||
* @param exception
|
||||
* @param string
|
||||
*/
|
||||
public void failed(String message, Exception exception);
|
||||
|
||||
|
||||
/**
|
||||
* Called when the operation is running
|
||||
* @param percentage
|
||||
*/
|
||||
public void running(double percentage);
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.server.monitor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.dmservice.SClient;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationId;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.process.ComputationStatus;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.process.ComputationStatus.Status;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class DMMonitorTask extends TimerTask {
|
||||
private static Logger logger = LoggerFactory.getLogger(DMMonitorTask.class);
|
||||
private ArrayList<DMMonitorListener> listeners;
|
||||
private ComputationId computationId;
|
||||
private SClient sClient;
|
||||
private DMMonitor dmMonitor;
|
||||
|
||||
public DMMonitorTask(DMMonitor dmMonitor, ComputationId computationId, SClient sClient,
|
||||
ArrayList<DMMonitorListener> listeners) {
|
||||
this.computationId = computationId;
|
||||
this.sClient = sClient;
|
||||
this.listeners = listeners;
|
||||
this.dmMonitor=dmMonitor;
|
||||
logger.debug("DMMonitorTask");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void run() {
|
||||
logger.debug("Requesting operation progress");
|
||||
ComputationStatus computationStatus = null;
|
||||
try {
|
||||
computationStatus = sClient.getComputationStatus(computationId);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
logger.debug("ComputationStatus: " + computationStatus);
|
||||
if (computationStatus == null) {
|
||||
logger.error("ComputationStatus is null");
|
||||
return;
|
||||
}
|
||||
|
||||
Status status = computationStatus.getStatus();
|
||||
if (status == null) {
|
||||
logger.error("Status is null");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (status) {
|
||||
case ACCEPTED:
|
||||
fireAccepted(computationStatus);
|
||||
break;
|
||||
case CANCELLED:
|
||||
dmMonitor.cancel();
|
||||
fireCancelled(computationStatus);
|
||||
break;
|
||||
case COMPLETE:
|
||||
dmMonitor.cancel();
|
||||
fireComplete(computationStatus);
|
||||
break;
|
||||
case FAILED:
|
||||
dmMonitor.cancel();
|
||||
fireFailed(computationStatus);
|
||||
break;
|
||||
case RUNNING:
|
||||
fireRunning(computationStatus);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void fireAccepted(ComputationStatus computationStatus) {
|
||||
for (DMMonitorListener listener : listeners)
|
||||
listener.accepted();
|
||||
}
|
||||
|
||||
private void fireCancelled(ComputationStatus computationStatus) {
|
||||
for (DMMonitorListener listener : listeners)
|
||||
listener.cancelled();
|
||||
}
|
||||
|
||||
private void fireComplete(ComputationStatus computationStatus) {
|
||||
for (DMMonitorListener listener : listeners)
|
||||
listener.complete(computationStatus.getPercentage());
|
||||
}
|
||||
|
||||
private void fireFailed(ComputationStatus computationStatus) {
|
||||
for (DMMonitorListener listener : listeners)
|
||||
listener.failed(computationStatus.getMessage(),
|
||||
computationStatus.getError());
|
||||
}
|
||||
|
||||
private void fireRunning(ComputationStatus computationStatus) {
|
||||
for (DMMonitorListener listener : listeners)
|
||||
listener.running(computationStatus.getPercentage());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.server.storage;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.exception.ServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class StorageUtil {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(StorageUtil.class);
|
||||
|
||||
|
||||
public static String saveOnStorageInTemporalFile(InputStream is)
|
||||
throws ServiceException {
|
||||
try {
|
||||
logger.debug("SaveOnStorageInTemporalFile()");
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
|
||||
Double v = Math.random() * 10000;
|
||||
String tempFile = "P_" + sdf.format(new Date()) + "_"
|
||||
+ v.intValue() + ".xml";
|
||||
String remotePath = "/DataMiner/AlgoritmsParameters/" + tempFile;
|
||||
IClient client = new StorageClient("DataAnalysis", "DataMiner",
|
||||
"DataMiner", AccessType.PUBLIC, MemoryType.VOLATILE)
|
||||
.getClient();
|
||||
String storageId = client.put(true).LFile(is).RFile(remotePath);
|
||||
logger.debug("Storage id: " + storageId);
|
||||
String publicLink = client.getHttpUrl().RFile(remotePath);
|
||||
logger.debug("Storage public link: " + publicLink);
|
||||
return publicLink;
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.server.util;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ServiceCredential implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 3560918948310315680L;
|
||||
private String username;
|
||||
private String scope;
|
||||
private String token;
|
||||
|
||||
public ServiceCredential() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param user
|
||||
* @param scope
|
||||
* @param token
|
||||
*/
|
||||
public ServiceCredential(String username, String scope, String token) {
|
||||
super();
|
||||
this.username = username;
|
||||
this.scope = scope;
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
public void setScope(String scope) {
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ServiceCredential [username=" + username + ", scope=" + scope
|
||||
+ ", token=" + token + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.shared;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class Constants {
|
||||
public static final boolean DEBUG = true;
|
||||
public static final boolean TEST_ENABLE = true;
|
||||
|
||||
public static final String DEFAULT_USER = "giancarlo.panichi";
|
||||
//public final static String DEFAULT_SCOPE = "/gcube/devNext/NextNext";
|
||||
//public final static String DEFAULT_TOKEN = "ae1208f0-210d-47c9-9b24-d3f2dfcce05f-98187548";
|
||||
|
||||
public final static String DEFAULT_SCOPE = "/gcube/preprod/preVRE";
|
||||
public final static String DEFAULT_TOKEN = "04269c7d-dab7-498a-841d-8d38ae2d482b-98187548";
|
||||
|
||||
|
||||
|
||||
public static final String DATAMINER_SERVICE_CATEGORY = "DataAnalysis";
|
||||
public static final String DATA_MINER_SERVICE_NAME = "DataMiner";
|
||||
|
||||
|
||||
public static final String[] ClassificationNames = { "User Perspective" };
|
||||
// "Computation Perspective"};
|
||||
public static final String UserClassificationName = ClassificationNames[0];
|
||||
// public final static String computationClassificationName =
|
||||
// classificationNames[1];
|
||||
|
||||
// WPS Data Miner
|
||||
public static final String WPSWebProcessingService = "WebProcessingService";
|
||||
public static final String WPSCancelComputationServlet = "CancelComputationServlet";
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.data.analysis.dataminermanagercl.shared;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class StringUtil {
|
||||
|
||||
public static String getCapitalWords(String string) {
|
||||
String ris = "";
|
||||
|
||||
boolean precUnderscore = true;
|
||||
for (int i=0; i<string.length(); i++) {
|
||||
char c = string.charAt(i);
|
||||
|
||||
if (c == '_') {
|
||||
precUnderscore = true;
|
||||
ris += " ";
|
||||
} else {
|
||||
ris += (precUnderscore ? Character.toUpperCase(c) : Character.toLowerCase(c));
|
||||
if (precUnderscore == true)
|
||||
precUnderscore = false;
|
||||
}
|
||||
}
|
||||
return ris;
|
||||
}
|
||||
|
||||
public static String clean(String string) {
|
||||
return (string == null ? "" : string);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.shared.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ColumnItem implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -3451466410777498956L;
|
||||
private Integer id;
|
||||
private String name;
|
||||
|
||||
public ColumnItem() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ColumnItem(Integer id, String name) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ColumnItem [id=" + id + ", name=" + name + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.shared.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationId;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.output.Resource;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class OutputData implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -3039151542008171640L;
|
||||
private ComputationId computationId;
|
||||
private Resource resource;
|
||||
|
||||
public OutputData() {
|
||||
super();
|
||||
}
|
||||
|
||||
public OutputData(ComputationId computationId, Resource resource) {
|
||||
super();
|
||||
this.computationId = computationId;
|
||||
this.resource = resource;
|
||||
}
|
||||
|
||||
public ComputationId getComputationId() {
|
||||
return computationId;
|
||||
}
|
||||
|
||||
public Resource getResource() {
|
||||
return resource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OutputData [computationId=" + computationId + ", resource="
|
||||
+ resource + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,136 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.shared.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class TableItemSimple implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -1204016958353092014L;
|
||||
private String id;
|
||||
private String name;
|
||||
private String description;
|
||||
private String type;
|
||||
private ArrayList<ColumnItem> columns;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public TableItemSimple() {
|
||||
super();
|
||||
columns = new ArrayList<ColumnItem>();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* @param description
|
||||
* @param type
|
||||
*/
|
||||
public TableItemSimple(String id, String name, String description,
|
||||
String type) {
|
||||
super();
|
||||
columns = new ArrayList<ColumnItem>();
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id2
|
||||
* @param name2
|
||||
* @param description2
|
||||
*/
|
||||
public TableItemSimple(String id, String name, String description) {
|
||||
super();
|
||||
columns = new ArrayList<ColumnItem>();
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param description
|
||||
* the description to set
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* the type to set
|
||||
*/
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* the id to set
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public ArrayList<ColumnItem> getColumns() {
|
||||
return columns;
|
||||
}
|
||||
|
||||
public void setColumns(ArrayList<ColumnItem> columns) {
|
||||
this.columns = columns;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TableItemSimple [id=" + id + ", name=" + name
|
||||
+ ", description=" + description + ", type=" + type
|
||||
+ ", columns=" + columns + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.shared.data.computations;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ComputationData implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -3039151542008171640L;
|
||||
private ComputationId computationId;
|
||||
private LinkedHashMap<String, ComputationValue> inputParameters;
|
||||
private LinkedHashMap<String, ComputationValue> outputParameters;
|
||||
private String operatorDescription;
|
||||
private String startDate;
|
||||
private String endDate;
|
||||
private String status;
|
||||
private String executionType;
|
||||
private String vre;
|
||||
|
||||
public ComputationData() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ComputationData(ComputationId computationId,
|
||||
LinkedHashMap<String, ComputationValue> inputParameters,
|
||||
LinkedHashMap<String, ComputationValue> outputParameters,
|
||||
String operatorDescription, String startDate, String endDate,
|
||||
String status, String executionType, String vre) {
|
||||
super();
|
||||
this.computationId = computationId;
|
||||
this.inputParameters = inputParameters;
|
||||
this.outputParameters = outputParameters;
|
||||
this.operatorDescription = operatorDescription;
|
||||
this.startDate = startDate;
|
||||
this.endDate = endDate;
|
||||
this.status = status;
|
||||
this.executionType = executionType;
|
||||
this.vre = vre;
|
||||
}
|
||||
|
||||
public ComputationId getComputationId() {
|
||||
return computationId;
|
||||
}
|
||||
|
||||
public void setComputationId(ComputationId computationId) {
|
||||
this.computationId = computationId;
|
||||
}
|
||||
|
||||
public LinkedHashMap<String, ComputationValue> getInputParameters() {
|
||||
return inputParameters;
|
||||
}
|
||||
|
||||
public void setInputParameters(LinkedHashMap<String, ComputationValue> inputParameters) {
|
||||
this.inputParameters = inputParameters;
|
||||
}
|
||||
|
||||
public LinkedHashMap<String, ComputationValue> getOutputParameters() {
|
||||
return outputParameters;
|
||||
}
|
||||
|
||||
public void setOutputParameters(
|
||||
LinkedHashMap<String, ComputationValue> outputParameters) {
|
||||
this.outputParameters = outputParameters;
|
||||
}
|
||||
|
||||
public String getOperatorDescription() {
|
||||
return operatorDescription;
|
||||
}
|
||||
|
||||
public void setOperatorDescription(String operatorDescription) {
|
||||
this.operatorDescription = operatorDescription;
|
||||
}
|
||||
|
||||
public String getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(String startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public String getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(String endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getExecutionType() {
|
||||
return executionType;
|
||||
}
|
||||
|
||||
public void setExecutionType(String executionType) {
|
||||
this.executionType = executionType;
|
||||
}
|
||||
|
||||
public String getVre() {
|
||||
return vre;
|
||||
}
|
||||
|
||||
public void setVre(String vre) {
|
||||
this.vre = vre;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ComputationData [computationId=" + computationId
|
||||
+ ", inputParameters=" + inputParameters
|
||||
+ ", outputParameters=" + outputParameters
|
||||
+ ", operatorDescription=" + operatorDescription
|
||||
+ ", startDate=" + startDate + ", endDate=" + endDate
|
||||
+ ", status=" + status + ", executionType=" + executionType
|
||||
+ ", vre=" + vre + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.shared.data.computations;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ComputationId implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 7898676192287822723L;
|
||||
private String id;
|
||||
private String urlId;
|
||||
private String operatorId;
|
||||
private String operatorName;
|
||||
private String equivalentRequest;
|
||||
|
||||
public ComputationId() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ComputationId(String id, String urlId, String operatorId,
|
||||
String operatorName, String equivalentRequest) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.urlId = urlId;
|
||||
this.operatorId = operatorId;
|
||||
this.operatorName = operatorName;
|
||||
this.equivalentRequest = equivalentRequest;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUrlId() {
|
||||
return urlId;
|
||||
}
|
||||
|
||||
public void setUrlId(String urlId) {
|
||||
this.urlId = urlId;
|
||||
}
|
||||
|
||||
public String getOperatorId() {
|
||||
return operatorId;
|
||||
}
|
||||
|
||||
public void setOperatorId(String operatorId) {
|
||||
this.operatorId = operatorId;
|
||||
}
|
||||
|
||||
public String getOperatorName() {
|
||||
return operatorName;
|
||||
}
|
||||
|
||||
public void setOperatorName(String operatorName) {
|
||||
this.operatorName = operatorName;
|
||||
}
|
||||
|
||||
public String getEquivalentRequest() {
|
||||
return equivalentRequest;
|
||||
}
|
||||
|
||||
public void setEquivalentRequest(String equivalentRequest) {
|
||||
this.equivalentRequest = equivalentRequest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ComputationId [id=" + id + ", urlId=" + urlId + ", operatorId="
|
||||
+ operatorId + ", operatorName=" + operatorName
|
||||
+ ", equivalentRequest=" + equivalentRequest + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.shared.data.computations;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ComputationItemPropertiesValue implements Serializable,
|
||||
Comparable<ComputationItemPropertiesValue> {
|
||||
|
||||
private static final long serialVersionUID = 8917614711815918760L;
|
||||
private Integer order;
|
||||
private String key;
|
||||
private String value;
|
||||
|
||||
public ComputationItemPropertiesValue() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ComputationItemPropertiesValue(Integer order, String key,
|
||||
String value) {
|
||||
super();
|
||||
this.order = order;
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Integer getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
public void setOrder(Integer order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ComputationItemPropertiesValue o) {
|
||||
return order.compareTo(o.getOrder());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ComputationItemPropertiesValue [order=" + order + ", key="
|
||||
+ key + ", value=" + value + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.shared.data.computations;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ComputationValue implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -2047623108851748745L;
|
||||
protected ComputationValueType type;
|
||||
protected String value;
|
||||
|
||||
public ComputationValue() {
|
||||
super();
|
||||
this.type = ComputationValueType.String;
|
||||
}
|
||||
|
||||
public ComputationValue(ComputationValueType type) {
|
||||
super();
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public ComputationValue(String value) {
|
||||
super();
|
||||
this.type = ComputationValueType.String;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public ComputationValue(ComputationValueType type, String value) {
|
||||
super();
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public ComputationValueType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(ComputationValueType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ComputationValue [type=" + type + ", value=" + value + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.shared.data.computations;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ComputationValueFile extends ComputationValue {
|
||||
private static final long serialVersionUID = -5845606225432949795L;
|
||||
|
||||
private String fileName;
|
||||
private String mimeType;
|
||||
|
||||
public ComputationValueFile() {
|
||||
super(ComputationValueType.File);
|
||||
}
|
||||
|
||||
public ComputationValueFile(String url, String fileName, String mimeType) {
|
||||
super(ComputationValueType.File, url);
|
||||
this.fileName = fileName;
|
||||
this.mimeType = mimeType;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public String getMimeType() {
|
||||
return mimeType;
|
||||
}
|
||||
|
||||
public void setMimeType(String mimeType) {
|
||||
this.mimeType = mimeType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ComputationValueFile [fileName=" + fileName + ", mimeType="
|
||||
+ mimeType + ", type=" + type + ", value=" + value + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.shared.data.computations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ComputationValueFileList extends ComputationValue {
|
||||
private static final long serialVersionUID = -5845606225432949795L;
|
||||
|
||||
private ArrayList<ComputationValue> fileList;
|
||||
private String separator;
|
||||
|
||||
public ComputationValueFileList() {
|
||||
super(ComputationValueType.FileList);
|
||||
}
|
||||
|
||||
public ComputationValueFileList(ArrayList<ComputationValue> fileList,
|
||||
String separator) {
|
||||
super(ComputationValueType.FileList);
|
||||
this.fileList = fileList;
|
||||
this.separator = separator;
|
||||
value = new String();
|
||||
for (ComputationValue file : fileList) {
|
||||
value = value + file.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<ComputationValue> getFileList() {
|
||||
return fileList;
|
||||
}
|
||||
|
||||
public void setFileList(ArrayList<ComputationValue> fileList) {
|
||||
this.fileList = fileList;
|
||||
}
|
||||
|
||||
public String getSeparator() {
|
||||
return separator;
|
||||
}
|
||||
|
||||
public void setSeparator(String separator) {
|
||||
this.separator = separator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ComputationValueFileList [fileList=" + fileList
|
||||
+ ", separator=" + separator + ", type=" + type + ", value="
|
||||
+ value + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.shared.data.computations;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ComputationValueImage extends ComputationValue {
|
||||
private static final long serialVersionUID = -5845606225432949795L;
|
||||
|
||||
private String fileName;
|
||||
private String mimeType;
|
||||
|
||||
public ComputationValueImage(){
|
||||
super(ComputationValueType.Image);
|
||||
}
|
||||
|
||||
public ComputationValueImage(String url, String fileName, String mimeType) {
|
||||
super(ComputationValueType.Image, url);
|
||||
this.fileName = fileName;
|
||||
this.mimeType = mimeType;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public String getMimeType() {
|
||||
return mimeType;
|
||||
}
|
||||
|
||||
public void setMimeType(String mimeType) {
|
||||
this.mimeType = mimeType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ComputationValueImage [fileName=" + fileName + ", mimeType="
|
||||
+ mimeType + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.shared.data.computations;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public enum ComputationValueType {
|
||||
FileList, File, Image, String;
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.data.analysis.dataminermanagercl.shared.data.output;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class FileResource extends Resource {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 799627064179136509L;
|
||||
|
||||
private String url;
|
||||
private String mimeType;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public FileResource() {
|
||||
super();
|
||||
this.setResourceType(ResourceType.FILE);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param resourceId
|
||||
* @param name
|
||||
* @param description
|
||||
* @param url
|
||||
* @param mimeType
|
||||
*/
|
||||
public FileResource(String resourceId, String name, String description,
|
||||
String url, String mimeType) {
|
||||
super(resourceId, name, description, ResourceType.FILE);
|
||||
this.url = url;
|
||||
this.mimeType = mimeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the url
|
||||
*/
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param url
|
||||
* the url to set
|
||||
*/
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the mimeType
|
||||
*/
|
||||
public String getMimeType() {
|
||||
return mimeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mimeType
|
||||
* the mimeType to set
|
||||
*/
|
||||
public void setMimeType(String mimeType) {
|
||||
this.mimeType = mimeType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FileResource [url=" + url + ", mimeType=" + mimeType
|
||||
+ ", getResourceId()=" + getResourceId() + ", getName()="
|
||||
+ getName() + ", getDescription()=" + getDescription()
|
||||
+ ", getResourceType()=" + getResourceType() + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.data.analysis.dataminermanagercl.shared.data.output;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ImageResource extends Resource {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 8772836076910728324L;
|
||||
private String link;
|
||||
private String mimeType;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ImageResource() {
|
||||
super();
|
||||
this.setResourceType(ResourceType.IMAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param resourceId
|
||||
* @param name
|
||||
* @param description
|
||||
* @param link
|
||||
*/
|
||||
public ImageResource(String resourceId, String name, String description,
|
||||
String link, String mimeType) {
|
||||
super(resourceId, name, description, ResourceType.IMAGE);
|
||||
this.link = link;
|
||||
this.mimeType = mimeType;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return link
|
||||
*/
|
||||
public String getLink() {
|
||||
return link;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param link
|
||||
*/
|
||||
public void setLink(String link) {
|
||||
this.link = link;
|
||||
}
|
||||
|
||||
public String getMimeType() {
|
||||
return mimeType;
|
||||
}
|
||||
|
||||
public void setMimeType(String mimeType) {
|
||||
this.mimeType = mimeType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ImagesResource [link=" + link + ", mimeType=" + mimeType
|
||||
+ ", getResourceId()=" + getResourceId() + ", getName()="
|
||||
+ getName() + ", getDescription()=" + getDescription()
|
||||
+ ", getResourceType()=" + getResourceType() + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.data.analysis.dataminermanagercl.shared.data.output;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class MapResource extends Resource {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 8772836076910728324L;
|
||||
private LinkedHashMap<String, Resource> map;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public MapResource() {
|
||||
super();
|
||||
this.setResourceType(ResourceType.MAP);
|
||||
}
|
||||
|
||||
public MapResource(String resourceId, String name, String description,
|
||||
LinkedHashMap<String, Resource> map) {
|
||||
super(resourceId, name, description, ResourceType.MAP);
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
public Map<String, Resource> getMap() {
|
||||
return map;
|
||||
}
|
||||
|
||||
public void setMap(LinkedHashMap<String, Resource> map) {
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MapResource [map=" + map + ", getResourceId()="
|
||||
+ getResourceId() + ", getName()=" + getName()
|
||||
+ ", getDescription()=" + getDescription()
|
||||
+ ", getResourceType()=" + getResourceType() + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.data.analysis.dataminermanagercl.shared.data.output;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ObjectResource extends Resource {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 8772836076910728324L;
|
||||
private String value;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ObjectResource() {
|
||||
super();
|
||||
this.setResourceType(ResourceType.OBJECT);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ObjectResource(String resourceId, String name, String description,
|
||||
String value) {
|
||||
super(resourceId, name, description, ResourceType.OBJECT);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the url
|
||||
*/
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param url
|
||||
* the url to set
|
||||
*/
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ObjectResource [value=" + value + ", getResourceId()="
|
||||
+ getResourceId() + ", getName()=" + getName()
|
||||
+ ", getDescription()=" + getDescription()
|
||||
+ ", getResourceType()=" + getResourceType() + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,142 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.data.analysis.dataminermanagercl.shared.data.output;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class Resource implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1417885805472591661L;
|
||||
|
||||
public enum ResourceType {
|
||||
OBJECT, FILE, TABULAR, MAP, IMAGE, ERROR
|
||||
};
|
||||
|
||||
private String resourceId, name, description;
|
||||
private ResourceType resourceType;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public Resource() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param resourceId
|
||||
* @param name
|
||||
* @param description
|
||||
* @param resourceType
|
||||
*/
|
||||
public Resource(String resourceId, String name, String description,
|
||||
ResourceType resourceType) {
|
||||
super();
|
||||
this.resourceId = resourceId;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the resourceId
|
||||
*/
|
||||
public String getResourceId() {
|
||||
return resourceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resourceId
|
||||
* the resourceId to set
|
||||
*/
|
||||
public void setResourceId(String resourceId) {
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param description
|
||||
* the description to set
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the resourceType
|
||||
*/
|
||||
public ResourceType getResourceType() {
|
||||
return resourceType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resourceType
|
||||
* the resourceType to set
|
||||
*/
|
||||
public void setResourceType(ResourceType resourceType) {
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
|
||||
public boolean isTabular() {
|
||||
return this.resourceType == ResourceType.TABULAR;
|
||||
}
|
||||
|
||||
public boolean isObject() {
|
||||
return this.resourceType == ResourceType.OBJECT;
|
||||
}
|
||||
|
||||
public boolean isFile() {
|
||||
return this.resourceType == ResourceType.FILE;
|
||||
}
|
||||
|
||||
public boolean isMap() {
|
||||
return this.resourceType == ResourceType.MAP;
|
||||
}
|
||||
|
||||
public boolean isImages() {
|
||||
return this.resourceType == ResourceType.IMAGE;
|
||||
}
|
||||
|
||||
public boolean isError() {
|
||||
return this.resourceType == ResourceType.ERROR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Resource [resourceId=" + resourceId + ", name=" + name
|
||||
+ ", description=" + description + ", resourceType="
|
||||
+ resourceType + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.data.analysis.dataminermanagercl.shared.data.output;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class TableResource extends Resource {
|
||||
|
||||
private static final long serialVersionUID = -1506902532089828988L;
|
||||
private String template;
|
||||
|
||||
public TableResource() {
|
||||
super();
|
||||
this.setResourceType(ResourceType.TABULAR);
|
||||
}
|
||||
|
||||
public TableResource(String resourceId, String name, String description, String template) {
|
||||
super(resourceId, name, description, ResourceType.TABULAR);
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the template
|
||||
*/
|
||||
public String getTemplate() {
|
||||
return template;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param template
|
||||
* the template to set
|
||||
*/
|
||||
public void setTemplate(String template) {
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TableResource [template=" + template + ", getResourceId()="
|
||||
+ getResourceId() + ", getName()=" + getName()
|
||||
+ ", getDescription()=" + getDescription()
|
||||
+ ", getResourceType()=" + getResourceType() + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.data.analysis.dataminermanagercl.shared.exception;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ServiceException extends Exception {
|
||||
|
||||
|
||||
private static final long serialVersionUID = -2255657546267656458L;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ServiceException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
*/
|
||||
public ServiceException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
||||
public ServiceException(String message,Throwable t) {
|
||||
super(message,t);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ColumnListParameter extends Parameter {
|
||||
|
||||
private static final long serialVersionUID = -6743494426144267089L;
|
||||
private String referredTabularParameterName;
|
||||
// private List<String> columnNames = new ArrayList<String>();
|
||||
private String value;
|
||||
private String separator;
|
||||
|
||||
public ColumnListParameter() {
|
||||
super();
|
||||
this.typology = ParameterType.COLUMN_LIST;
|
||||
}
|
||||
|
||||
public ColumnListParameter(String name, String description,
|
||||
String referredTabularParameterName, String separator) {
|
||||
super(name, ParameterType.COLUMN_LIST, description);
|
||||
this.referredTabularParameterName = referredTabularParameterName;
|
||||
this.separator = separator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param referredTabularParameterName
|
||||
* the referredTabularParameterName to set
|
||||
*/
|
||||
public void setReferredTabularParameterName(
|
||||
String referredTabularParameterName) {
|
||||
this.referredTabularParameterName = referredTabularParameterName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the referredTabularParameterName
|
||||
*/
|
||||
public String getReferredTabularParameterName() {
|
||||
return referredTabularParameterName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the value
|
||||
*/
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the separator
|
||||
*/
|
||||
public String getSeparator() {
|
||||
return separator;
|
||||
}
|
||||
|
||||
public void setSeparator(String separator) {
|
||||
this.separator = separator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ColumnListParameter [referredTabularParameterName="
|
||||
+ referredTabularParameterName + ", value=" + value
|
||||
+ ", separator=" + separator + ", name=" + name
|
||||
+ ", description=" + description + ", typology=" + typology
|
||||
+ "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ColumnParameter extends Parameter {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -5084557326770554659L;
|
||||
private String referredTabularParameterName;
|
||||
private String defaultColumn;
|
||||
private String value;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ColumnParameter() {
|
||||
super();
|
||||
this.typology = ParameterType.COLUMN;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ColumnParameter(String name, String description,
|
||||
String referredTabularParameterName, String defaultColumn) {
|
||||
super(name, ParameterType.COLUMN, description);
|
||||
this.referredTabularParameterName = referredTabularParameterName;
|
||||
this.defaultColumn = defaultColumn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param referredTabularParameterName
|
||||
* the referredTabularParameterName to set
|
||||
*/
|
||||
public void setReferredTabularParameterName(
|
||||
String referredTabularParameterName) {
|
||||
this.referredTabularParameterName = referredTabularParameterName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the referredTabularParameterName
|
||||
*/
|
||||
public String getReferredTabularParameterName() {
|
||||
return referredTabularParameterName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the defaultValue
|
||||
*/
|
||||
public String getDefaultColumn() {
|
||||
return defaultColumn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param defaultValue
|
||||
* the defaultValue to set
|
||||
*/
|
||||
public void setDefaultColumn(String defaultColumn) {
|
||||
this.defaultColumn = defaultColumn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the value
|
||||
*/
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ColumnParameter [referredTabularParameterName="
|
||||
+ referredTabularParameterName + ", defaultColumn="
|
||||
+ defaultColumn + ", value=" + value + ", name=" + name
|
||||
+ ", description=" + description + ", typology=" + typology
|
||||
+ "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class DateParameter extends Parameter {
|
||||
|
||||
private static final long serialVersionUID = 1673874854501249519L;
|
||||
private String defaultValue;
|
||||
private String value;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public DateParameter() {
|
||||
super();
|
||||
this.typology = ParameterType.DATE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* @param defaultValue
|
||||
* @param value
|
||||
*/
|
||||
public DateParameter(String name, String description, String defaultValue) {
|
||||
super(name, ParameterType.DATE, description);
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the defaultValue
|
||||
*/
|
||||
public String getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param defaultValue
|
||||
* the defaultValue to set
|
||||
*/
|
||||
public void setDefaultValue(String defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the value
|
||||
*/
|
||||
@Override
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DateParameter [defaultValue=" + defaultValue + ", value="
|
||||
+ value + ", name=" + name + ", description=" + description
|
||||
+ ", typology=" + typology + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class EnumParameter extends Parameter {
|
||||
|
||||
private static final long serialVersionUID = 1673874854501249519L;
|
||||
private List<String> values = new ArrayList<String>();
|
||||
private String defaultValue;
|
||||
private String value;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public EnumParameter() {
|
||||
super();
|
||||
this.typology = ParameterType.ENUM;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* @param defaultValue
|
||||
* @param value
|
||||
*/
|
||||
public EnumParameter(String name, String description, List<String> values, String defaultValue) {
|
||||
super(name, ParameterType.ENUM, description);
|
||||
this.values = values;
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the defaultValue
|
||||
*/
|
||||
public String getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param defaultValue the defaultValue to set
|
||||
*/
|
||||
public void setDefaultValue(String defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param values the values to set
|
||||
*/
|
||||
public void setValues(List<String> values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the values
|
||||
*/
|
||||
public List<String> getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
public void addValue(String value) {
|
||||
this.values.add(value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return the value
|
||||
*/
|
||||
@Override
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EnumParameter [values=" + values + ", defaultValue="
|
||||
+ defaultValue + ", value=" + value + ", name=" + name
|
||||
+ ", description=" + description + ", typology=" + typology
|
||||
+ "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class FileParameter extends Parameter {
|
||||
|
||||
private static final long serialVersionUID = -2967577990287112937L;
|
||||
private String value;
|
||||
private String defaultMimeType;
|
||||
private ArrayList<String> supportedMimeTypes;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public FileParameter() {
|
||||
super();
|
||||
this.typology = ParameterType.FILE;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name
|
||||
* @param description
|
||||
* @param fileName
|
||||
* @param mimeType
|
||||
*/
|
||||
public FileParameter(String name, String description, String defaultMimeType, ArrayList<String> supportedMimeTypes) {
|
||||
super(name, ParameterType.FILE, description);
|
||||
this.defaultMimeType = defaultMimeType;
|
||||
this.supportedMimeTypes = supportedMimeTypes;
|
||||
}
|
||||
|
||||
public String getDefaultMimeType() {
|
||||
return defaultMimeType;
|
||||
}
|
||||
|
||||
public void setDefaultMimeType(String defaultMimeType) {
|
||||
this.defaultMimeType = defaultMimeType;
|
||||
}
|
||||
|
||||
public ArrayList<String> getSupportedMimeTypes() {
|
||||
return supportedMimeTypes;
|
||||
}
|
||||
|
||||
public void setSupportedMimeTypes(ArrayList<String> supportedMimeTypes) {
|
||||
this.supportedMimeTypes = supportedMimeTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void setValue(String value) {
|
||||
this.value=value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FileParameter [value=" + value + ", defaultMimeType="
|
||||
+ defaultMimeType + ", supportedMimeTypes="
|
||||
+ supportedMimeTypes + ", name=" + name + ", description="
|
||||
+ description + ", typology=" + typology + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ListParameter extends Parameter {
|
||||
|
||||
private static final long serialVersionUID = 5405965026753332225L;
|
||||
private String type;
|
||||
private String value;
|
||||
private String separator;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ListParameter() {
|
||||
super();
|
||||
this.typology = ParameterType.LIST;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param defaultValue
|
||||
* @param value
|
||||
*/
|
||||
public ListParameter(String name, String description, String type,
|
||||
String separator) {
|
||||
super(name, ParameterType.LIST, description);
|
||||
this.type = type;
|
||||
this.separator = separator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* the type to set
|
||||
*/
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the separator
|
||||
*/
|
||||
public String getSeparator() {
|
||||
return separator;
|
||||
}
|
||||
|
||||
public void setSeparator(String separator) {
|
||||
this.separator = separator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ListParameter [type=" + type + ", value=" + value
|
||||
+ ", separator=" + separator + ", name=" + name
|
||||
+ ", description=" + description + ", typology=" + typology
|
||||
+ "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
|
||||
package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ObjectParameter extends Parameter {
|
||||
|
||||
private static final long serialVersionUID = 1058462575242430851L;
|
||||
private String type;
|
||||
private String defaultValue;
|
||||
private String value;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ObjectParameter() {
|
||||
super();
|
||||
this.typology = ParameterType.OBJECT;
|
||||
}
|
||||
|
||||
|
||||
public ObjectParameter(String name, String description, String type, String defaultValue) {
|
||||
super(name, ParameterType.OBJECT, description);
|
||||
this.type = type;
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type the type to set
|
||||
*/
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the defaultValue
|
||||
*/
|
||||
public String getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param defaultValue the defaultValue to set
|
||||
*/
|
||||
public void setDefaultValue(String defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the value
|
||||
*/
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ObjectParameter [type=" + type + ", defaultValue="
|
||||
+ defaultValue + ", value=" + value + ", name=" + name
|
||||
+ ", description=" + description + ", typology=" + typology
|
||||
+ "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public abstract class Parameter implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -555286289487491703L;
|
||||
|
||||
protected String name;
|
||||
protected String description;
|
||||
protected ParameterType typology;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public Parameter() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* @param type
|
||||
* @param description
|
||||
* @param defaultValue
|
||||
* @param value
|
||||
*/
|
||||
public Parameter(String name, ParameterType type, String description) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.typology = type;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public abstract void setValue(String value);
|
||||
|
||||
public abstract String getValue();
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the typology
|
||||
*/
|
||||
public ParameterType getTypology() {
|
||||
return typology;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param typology
|
||||
* the typology to set
|
||||
*/
|
||||
public void setTypology(ParameterType typology) {
|
||||
this.typology = typology;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param description
|
||||
* the description to set
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Parameter [name=" + name + ", description=" + description
|
||||
+ ", typology=" + typology + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public enum ParameterType {
|
||||
OBJECT, TABULAR, FILE, ENUM, LIST, COLUMN, COLUMN_LIST, TABULAR_LIST, WKT, DATE, TIME;
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class TabularListParameter extends Parameter {
|
||||
|
||||
private static final long serialVersionUID = -1786477950530892502L;
|
||||
private String value;
|
||||
private String separator;
|
||||
private ArrayList<String> templates = new ArrayList<String>();
|
||||
private String defaultMimeType;
|
||||
private ArrayList<String> supportedMimeTypes;
|
||||
|
||||
// private List<String> tableNames = new ArrayList<String>();
|
||||
|
||||
public TabularListParameter() {
|
||||
super();
|
||||
this.typology = ParameterType.TABULAR_LIST;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param defaultValue
|
||||
* @param value
|
||||
*/
|
||||
public TabularListParameter(String name, String description,
|
||||
String separator, String defaultMimeType,
|
||||
ArrayList<String> supportedMimeTypes) {
|
||||
super(name, ParameterType.TABULAR_LIST, description);
|
||||
this.separator = separator;
|
||||
this.defaultMimeType = defaultMimeType;
|
||||
this.supportedMimeTypes = supportedMimeTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the separator
|
||||
*/
|
||||
public String getSeparator() {
|
||||
return separator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param templates
|
||||
* the templates to set
|
||||
*/
|
||||
public void setTemplates(ArrayList<String> templates) {
|
||||
this.templates = templates;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the templates
|
||||
*/
|
||||
public ArrayList<String> getTemplates() {
|
||||
return templates;
|
||||
}
|
||||
|
||||
public void addTemplate(String template) {
|
||||
templates.add(template);
|
||||
}
|
||||
|
||||
public String getDefaultMimeType() {
|
||||
return defaultMimeType;
|
||||
}
|
||||
|
||||
public void setDefaultMimeType(String defaultMimeType) {
|
||||
this.defaultMimeType = defaultMimeType;
|
||||
}
|
||||
|
||||
public ArrayList<String> getSupportedMimeTypes() {
|
||||
return supportedMimeTypes;
|
||||
}
|
||||
|
||||
public void setSupportedMimeTypes(ArrayList<String> supportedMimeTypes) {
|
||||
this.supportedMimeTypes = supportedMimeTypes;
|
||||
}
|
||||
|
||||
public void setSeparator(String separator) {
|
||||
this.separator = separator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TabularListParameter [value=" + value + ", separator="
|
||||
+ separator + ", templates=" + templates + ", defaultMimeType="
|
||||
+ defaultMimeType + ", supportedMimeTypes="
|
||||
+ supportedMimeTypes + ", name=" + name + ", description="
|
||||
+ description + ", typology=" + typology + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class TabularParameter extends Parameter {
|
||||
|
||||
private static final long serialVersionUID = 8038591467145151553L;
|
||||
private String tableName;
|
||||
private ArrayList<String> templates = new ArrayList<String>();
|
||||
private String defaultMimeType;
|
||||
private ArrayList<String> supportedMimeTypes;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public TabularParameter() {
|
||||
super();
|
||||
this.typology = ParameterType.TABULAR;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name
|
||||
* @param description
|
||||
* @param tableName
|
||||
*/
|
||||
public TabularParameter(String name, String description, String tableName,
|
||||
String defaultMimeType, ArrayList<String> supportedMimeTypes) {
|
||||
super(name, ParameterType.TABULAR, description);
|
||||
this.tableName = tableName;
|
||||
this.templates = null;
|
||||
this.defaultMimeType = defaultMimeType;
|
||||
this.supportedMimeTypes = supportedMimeTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name
|
||||
* @param description
|
||||
* @param tableName
|
||||
* @param templates
|
||||
*/
|
||||
public TabularParameter(String name, String description, String tableName,
|
||||
ArrayList<String> templates, String defaultMimeType,
|
||||
ArrayList<String> supportedMimeTypes) {
|
||||
super(name, ParameterType.TABULAR, description);
|
||||
this.tableName = tableName;
|
||||
this.templates = templates;
|
||||
this.defaultMimeType = defaultMimeType;
|
||||
this.supportedMimeTypes = supportedMimeTypes;
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
public ArrayList<String> getTemplates() {
|
||||
return templates;
|
||||
}
|
||||
|
||||
public void setTemplates(ArrayList<String> templates) {
|
||||
this.templates = templates;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return getTableName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(String value) {
|
||||
this.setTableName(value);
|
||||
}
|
||||
|
||||
public String getDefaultMimeType() {
|
||||
return defaultMimeType;
|
||||
}
|
||||
|
||||
public void setDefaultMimeType(String defaultMimeType) {
|
||||
this.defaultMimeType = defaultMimeType;
|
||||
}
|
||||
|
||||
public ArrayList<String> getSupportedMimeTypes() {
|
||||
return supportedMimeTypes;
|
||||
}
|
||||
|
||||
public void setSupportedMimeTypes(ArrayList<String> supportedMimeTypes) {
|
||||
this.supportedMimeTypes = supportedMimeTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TabularParameter [tableName=" + tableName + ", templates="
|
||||
+ templates + ", defaultMimeType=" + defaultMimeType
|
||||
+ ", supportedMimeTypes=" + supportedMimeTypes + ", name="
|
||||
+ name + ", description=" + description + ", typology="
|
||||
+ typology + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class TimeParameter extends Parameter {
|
||||
|
||||
private static final long serialVersionUID = 1673874854501249519L;
|
||||
private String defaultValue;
|
||||
private String value;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public TimeParameter() {
|
||||
super();
|
||||
this.typology = ParameterType.TIME;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* @param defaultValue
|
||||
* @param value
|
||||
*/
|
||||
public TimeParameter(String name, String description, String defaultValue) {
|
||||
super(name, ParameterType.TIME, description);
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the defaultValue
|
||||
*/
|
||||
public String getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param defaultValue
|
||||
* the defaultValue to set
|
||||
*/
|
||||
public void setDefaultValue(String defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the value
|
||||
*/
|
||||
@Override
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TimeParameter [defaultValue=" + defaultValue + ", value="
|
||||
+ value + ", name=" + name + ", description=" + description
|
||||
+ ", typology=" + typology + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public enum WKTGeometryType {
|
||||
Point("Point"), LineString("LineString"), Polygon("Polygon"), Circle(
|
||||
"Circle"), Triangle("Triangle"), Square("Square"), Pentagon(
|
||||
"Pentagon"), Hexagon("Hexagon"), Box("Box");
|
||||
|
||||
/**
|
||||
* @param text
|
||||
*/
|
||||
private WKTGeometryType(final String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
private final String label;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return name();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param label
|
||||
* @return
|
||||
*/
|
||||
public static WKTGeometryType getFromLabel(String label) {
|
||||
if (label == null || label.isEmpty())
|
||||
return null;
|
||||
|
||||
for (WKTGeometryType type : values()) {
|
||||
if (type.label.compareToIgnoreCase(label) == 0) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<WKTGeometryType> asList() {
|
||||
List<WKTGeometryType> list = Arrays.asList(values());
|
||||
return list;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class WKTParameter extends Parameter {
|
||||
|
||||
private static final long serialVersionUID = 1673874854501249519L;
|
||||
private WKTGeometryType wktGeometryType;
|
||||
private String defaultValue;
|
||||
private String value;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public WKTParameter() {
|
||||
super();
|
||||
this.typology = ParameterType.WKT;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* @param defaultValue
|
||||
* @param value
|
||||
*/
|
||||
public WKTParameter(String name, String description,
|
||||
WKTGeometryType wktGeometryType, String defaultValue) {
|
||||
super(name, ParameterType.WKT, description);
|
||||
this.wktGeometryType = wktGeometryType;
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the defaultValue
|
||||
*/
|
||||
public String getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param defaultValue
|
||||
* the defaultValue to set
|
||||
*/
|
||||
public void setDefaultValue(String defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the WKT Geometry Type
|
||||
*/
|
||||
public WKTGeometryType getWktGeometryType() {
|
||||
return wktGeometryType;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param wktGeometryType
|
||||
* set the WKT Geometry Type
|
||||
*/
|
||||
public void setWktGeometryType(WKTGeometryType wktGeometryType) {
|
||||
this.wktGeometryType = wktGeometryType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the value
|
||||
*/
|
||||
@Override
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WKTParameter [wktGeometryType=" + wktGeometryType
|
||||
+ ", defaultValue=" + defaultValue + ", value=" + value
|
||||
+ ", name=" + name + ", description=" + description
|
||||
+ ", typology=" + typology + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.shared.process;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ComputationStatus implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -1943128398882978439L;
|
||||
|
||||
public enum Status {
|
||||
ACCEPTED, RUNNING, COMPLETE, FAILED, CANCELLED;
|
||||
};
|
||||
|
||||
private double percentage;
|
||||
private Status status;
|
||||
private String message;
|
||||
private Exception error;
|
||||
|
||||
public ComputationStatus() {
|
||||
this.status = Status.ACCEPTED;
|
||||
}
|
||||
|
||||
public ComputationStatus(double percentage) {
|
||||
super();
|
||||
this.percentage = percentage;
|
||||
this.status = Status.RUNNING;
|
||||
}
|
||||
|
||||
public ComputationStatus(Status status, double percentage) {
|
||||
super();
|
||||
this.percentage = percentage;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public ComputationStatus(Exception error) {
|
||||
super();
|
||||
this.percentage = 100f;
|
||||
this.status = Status.FAILED;
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
public boolean isComplete() {
|
||||
return this.status == Status.COMPLETE;
|
||||
}
|
||||
|
||||
public boolean isFailed() {
|
||||
return this.status == Status.FAILED;
|
||||
}
|
||||
|
||||
public boolean isRunning() {
|
||||
return this.status == Status.RUNNING;
|
||||
}
|
||||
|
||||
public boolean isAccepted() {
|
||||
return this.status == Status.ACCEPTED;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return this.status == Status.CANCELLED;
|
||||
}
|
||||
|
||||
public boolean isPaused() {
|
||||
return false;
|
||||
// return this.status == Status.FAILED;
|
||||
}
|
||||
|
||||
public boolean isTerminated() {
|
||||
return status == Status.COMPLETE || status == Status.FAILED
|
||||
|| status == Status.CANCELLED;
|
||||
}
|
||||
|
||||
public double getPercentage() {
|
||||
return percentage;
|
||||
}
|
||||
|
||||
public void setPercentage(double percentage) {
|
||||
this.percentage = percentage;
|
||||
}
|
||||
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Status status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Exception getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public void setError(Exception error) {
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ComputationStatus [percentage=" + percentage + ", status="
|
||||
+ status + ", message=" + message + ", error=" + error + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,240 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.data.analysis.dataminermanagercl.shared.process;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.StringUtil;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class Operator implements Serializable, Comparable<Operator> {
|
||||
|
||||
private static final long serialVersionUID = -4084498655645951188L;
|
||||
private String id;
|
||||
private String name;
|
||||
private String briefDescription;
|
||||
private String description;
|
||||
private OperatorCategory category;
|
||||
private List<Parameter> operatorParameters = new ArrayList<Parameter>();
|
||||
private boolean hasImage = false;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public Operator() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @param briefDescription
|
||||
* @param description
|
||||
* @param category
|
||||
*/
|
||||
public Operator(String id, String briefDescription, String description,
|
||||
OperatorCategory category) {
|
||||
super();
|
||||
this.id = id;
|
||||
if (id != null)
|
||||
this.name = StringUtil.getCapitalWords(id);
|
||||
this.briefDescription = briefDescription;
|
||||
this.description = description;
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @param briefDescription
|
||||
* @param description
|
||||
* @param category
|
||||
* @param hasImage
|
||||
*/
|
||||
public Operator(String id, String briefDescription, String description,
|
||||
OperatorCategory category, boolean hasImage) {
|
||||
super();
|
||||
this.id = id;
|
||||
if (id != null)
|
||||
this.name = StringUtil.getCapitalWords(id);
|
||||
this.briefDescription = briefDescription;
|
||||
this.description = description;
|
||||
this.category = category;
|
||||
this.hasImage = hasImage;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @param briefDescription
|
||||
* @param description
|
||||
* @param category
|
||||
*/
|
||||
public Operator(String id, String name, String briefDescription,
|
||||
String description, OperatorCategory category) {
|
||||
super();
|
||||
this.id = id;
|
||||
if (name != null)
|
||||
this.name = StringUtil.getCapitalWords(name);
|
||||
this.briefDescription = briefDescription;
|
||||
this.description = description;
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @param name
|
||||
* @param briefDescription
|
||||
* @param description
|
||||
* @param category
|
||||
* @param operatorParameters
|
||||
* @param hasImage
|
||||
*/
|
||||
public Operator(String id, String name, String briefDescription,
|
||||
String description, OperatorCategory category,
|
||||
List<Parameter> operatorParameters, boolean hasImage) {
|
||||
super();
|
||||
this.id = id;
|
||||
if (name != null)
|
||||
this.name = StringUtil.getCapitalWords(name);
|
||||
this.briefDescription = briefDescription;
|
||||
this.description = description;
|
||||
this.category = category;
|
||||
this.operatorParameters = operatorParameters;
|
||||
this.hasImage = hasImage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* the id to set
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the briefDescription
|
||||
*/
|
||||
public String getBriefDescription() {
|
||||
return briefDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param briefDescription
|
||||
* the briefDescription to set
|
||||
*/
|
||||
public void setBriefDescription(String briefDescription) {
|
||||
this.briefDescription = briefDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param description
|
||||
* the description to set
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the category
|
||||
*/
|
||||
public OperatorCategory getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param category
|
||||
* the category to set
|
||||
*/
|
||||
public void setCategory(OperatorCategory category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the operatorParameters
|
||||
*/
|
||||
public List<Parameter> getOperatorParameters() {
|
||||
return operatorParameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param operatorParameters
|
||||
* the operatorParameters to set
|
||||
*/
|
||||
public void setOperatorParameters(List<Parameter> operatorParameters) {
|
||||
this.operatorParameters = operatorParameters;
|
||||
}
|
||||
|
||||
public void addOperatorParameter(Parameter operatorParameter) {
|
||||
this.operatorParameters.add(operatorParameter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean hasImage() {
|
||||
return hasImage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hasImage
|
||||
* the hasImage to set
|
||||
*/
|
||||
public void setHasImage(boolean hasImage) {
|
||||
this.hasImage = hasImage;
|
||||
}
|
||||
|
||||
public Operator clone() {
|
||||
return new Operator(id, name, briefDescription, description, category,
|
||||
new ArrayList<Parameter>(operatorParameters), hasImage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Operator [id=" + id + ", name=" + name + ", briefDescription="
|
||||
+ briefDescription + ", description=" + description
|
||||
+", operatorParameters="
|
||||
+ operatorParameters + ", hasImage=" + hasImage + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Operator o) {
|
||||
return id.compareTo(o.getId());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,226 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.data.analysis.dataminermanagercl.shared.process;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class OperatorCategory implements Serializable, Comparable<OperatorCategory> {
|
||||
|
||||
private static final long serialVersionUID = 7511425996378626337L;
|
||||
private String id;
|
||||
private String name;
|
||||
private String briefDescription;
|
||||
private String description;
|
||||
private List<Operator> operators = new ArrayList<Operator>();
|
||||
private boolean hasImage = false;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public OperatorCategory() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @param briefDescription
|
||||
* @param description
|
||||
*/
|
||||
public OperatorCategory(String id, String briefDescription, String description) {
|
||||
super();
|
||||
this.id = id;
|
||||
setNameFromId();
|
||||
this.briefDescription = briefDescription;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
* @param string2
|
||||
* @param string3
|
||||
* @param b
|
||||
*/
|
||||
public OperatorCategory(String id, String briefDescription, String description, boolean hasImage) {
|
||||
super();
|
||||
this.id = id;
|
||||
setNameFromId();
|
||||
this.briefDescription = briefDescription;
|
||||
this.description = description;
|
||||
this.hasImage = hasImage;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @param briefDescription
|
||||
* @param description
|
||||
* @param operators
|
||||
*/
|
||||
public OperatorCategory(String id, String briefDescription,
|
||||
String description, List<Operator> operators) {
|
||||
super();
|
||||
this.id = id;
|
||||
setNameFromId();
|
||||
this.briefDescription = briefDescription;
|
||||
this.description = description;
|
||||
this.operators = operators;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @param briefDescription
|
||||
* @param description
|
||||
* @param operators
|
||||
*/
|
||||
public OperatorCategory(String id, String name, String briefDescription,
|
||||
String description, List<Operator> operators) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.briefDescription = briefDescription;
|
||||
this.description = description;
|
||||
this.operators = operators;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the briefDescription
|
||||
*/
|
||||
public String getBriefDescription() {
|
||||
return briefDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param briefDescription the briefDescription to set
|
||||
*/
|
||||
public void setBriefDescription(String briefDescription) {
|
||||
this.briefDescription = briefDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param description the description to set
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the operators
|
||||
*/
|
||||
public List<Operator> getOperators() {
|
||||
return operators;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param operators the operators to set
|
||||
*/
|
||||
public void setOperators(List<Operator> operators) {
|
||||
this.operators = operators;
|
||||
}
|
||||
|
||||
public void addOperator(Operator operator) {
|
||||
this.operators.add(operator);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void setNameFromId() {
|
||||
if (id!=null) {
|
||||
String name = "";
|
||||
|
||||
boolean precUnderscore = true;
|
||||
for (int i=0; i<id.length(); i++) {
|
||||
char c = id.charAt(i);
|
||||
|
||||
if (c == '_') {
|
||||
precUnderscore = true;
|
||||
name += " ";
|
||||
} else {
|
||||
name += (precUnderscore ? Character.toUpperCase(c) : Character.toLowerCase(c));
|
||||
if (precUnderscore == true)
|
||||
precUnderscore = false;
|
||||
}
|
||||
}
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean hasImage() {
|
||||
return hasImage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hasImage the hasImage to set
|
||||
*/
|
||||
public void setHasImage(boolean hasImage) {
|
||||
this.hasImage = hasImage;
|
||||
}
|
||||
|
||||
public OperatorCategory clone() {
|
||||
OperatorCategory op = new OperatorCategory(id, name, briefDescription, description, new ArrayList<Operator>(operators));
|
||||
op.setHasImage(hasImage);
|
||||
return op;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OperatorCategory [id=" + id + ", name=" + name
|
||||
+ ", briefDescription=" + briefDescription + ", description="
|
||||
+ description + ", operators=" + operators + ", hasImage="
|
||||
+ hasImage + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(OperatorCategory o) {
|
||||
return id.compareTo(o.getId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.data.analysis.dataminermanagercl.shared.process;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class OperatorsClassification implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 7347445659350838584L;
|
||||
private String name;
|
||||
private List<OperatorCategory> operatorCategories = new ArrayList<OperatorCategory>();
|
||||
private List<Operator> operators = new ArrayList<Operator>();
|
||||
|
||||
public OperatorsClassification() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public OperatorsClassification(String name) {
|
||||
super();
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param operatorCategories
|
||||
* @param operators
|
||||
*/
|
||||
public OperatorsClassification(String name, List<OperatorCategory> operatorCategories,
|
||||
List<Operator> operators) {
|
||||
this(name);
|
||||
this.operatorCategories = operatorCategories;
|
||||
this.operators = operators;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the operatorCategories
|
||||
*/
|
||||
public List<OperatorCategory> getOperatorCategories() {
|
||||
return operatorCategories;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param operatorCategories the operatorCategories to set
|
||||
*/
|
||||
public void setOperatorCategories(List<OperatorCategory> operatorCategories) {
|
||||
this.operatorCategories = operatorCategories;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the operators
|
||||
*/
|
||||
public List<Operator> getOperators() {
|
||||
return operators;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param operators the operators to set
|
||||
*/
|
||||
public void setOperators(List<Operator> operators) {
|
||||
this.operators = operators;
|
||||
}
|
||||
|
||||
public Operator getOperatorById(String id) {
|
||||
if (id==null)
|
||||
return null;
|
||||
Operator operator = null;
|
||||
for (Operator op: operators)
|
||||
if (op.getId().contentEquals(id)) {
|
||||
operator = op;
|
||||
break;
|
||||
}
|
||||
return operator;
|
||||
}
|
||||
|
||||
public OperatorCategory getCategoryById(String id) {
|
||||
OperatorCategory category = null;
|
||||
for (OperatorCategory cat: operatorCategories)
|
||||
if (cat.getId().contentEquals(id)) {
|
||||
category = cat;
|
||||
break;
|
||||
}
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OperatorsClassification [name=" + name
|
||||
+ ", operatorCategories=" + operatorCategories + ", operators="
|
||||
+ operators + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.data.analysis.dataminermanagercl.shared.process;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class TemplateDescriptor {
|
||||
|
||||
public static TemplateDescriptor descriptors[] = {
|
||||
new TemplateDescriptor("HCAF", "HCAF Data Set", ""),
|
||||
new TemplateDescriptor("OCCURRENCE_SPECIES", "Occurrence Species Data Set", ""),
|
||||
new TemplateDescriptor("OCCURRENCE_AQUAMAPS", "Occurrence Aquamaps", ""),
|
||||
new TemplateDescriptor("HSPEN", "HSPEN Data Set", ""),
|
||||
new TemplateDescriptor("HSPEC", "HSPEC Data Set", ""),
|
||||
new TemplateDescriptor("CLUSTER", "Cluster Data Set", ""),
|
||||
new TemplateDescriptor("TRAININGSET", "Neural Network Training Set", ""),
|
||||
new TemplateDescriptor("TESTSET", "Neural Network Test Set", ""),
|
||||
new TemplateDescriptor("GENERIC", "Generic Data set", ""),
|
||||
new TemplateDescriptor("MINMAXLAT", "Min Max Lat Data Set", ""),
|
||||
new TemplateDescriptor("TIMESERIES", "time Series Data Set", ""),
|
||||
};
|
||||
|
||||
public static String[] s = new String[]{""};
|
||||
public static Map<String, String[][]> map;
|
||||
static {
|
||||
map = new HashMap<String, String[][]>();
|
||||
map.put("HCAF", new String[][]{
|
||||
{"csquarecode", "string"},
|
||||
{"depthmin", "real"},
|
||||
{"depthmax", "real"},
|
||||
{"depthmean", "real"},
|
||||
{"depthsd", "real"},
|
||||
{"sstanmean", "real"},
|
||||
{"sstansd", "real"},
|
||||
{"sstmnmax", "real"},
|
||||
{"sstmnmin", "real"},
|
||||
{"sstmnrange", "real"},
|
||||
{"sbtanmean", "real"},
|
||||
{"salinitymean", "real"},
|
||||
{"salinitysd", "real"},
|
||||
{"salinitymax", "real"},
|
||||
{"salinitymin", "real"},
|
||||
{"salinitybmean", "real"},
|
||||
{"primprodmean", "integer"},
|
||||
{"iceconann", "real"},
|
||||
{"iceconspr", "real"},
|
||||
{"iceconsum", "real"},
|
||||
{"iceconfal", "real"},
|
||||
{"iceconwin", "real"},
|
||||
{"faoaream", "integer"},
|
||||
{"eezall", "string"},
|
||||
{"lme", "integer"},
|
||||
{"landdist", "integer"},
|
||||
{"oceanarea", "real"},
|
||||
{"centerlat", "real"},
|
||||
{"centerlong", "real"},
|
||||
});
|
||||
}
|
||||
public static TemplateDescriptor defaultDescriptor = descriptors[0];
|
||||
|
||||
// public enum Template {
|
||||
// HCAF,
|
||||
// OCCURRENCE_SPECIES,
|
||||
// OCCURRENCE_AQUAMAPS,
|
||||
// HSPEN,
|
||||
// HSPEC,
|
||||
// CLUSTER,
|
||||
// TRAININGSET,
|
||||
// TESTSET,
|
||||
// GENERIC,
|
||||
// MINMAXLAT,
|
||||
// TIMESERIES,
|
||||
// }
|
||||
|
||||
|
||||
private String id, title, description;
|
||||
|
||||
/**
|
||||
* @param title
|
||||
* @param description
|
||||
*/
|
||||
public TemplateDescriptor(String id, String title, String description) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.shared.workspace;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class Computations implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 7375248981531583668L;
|
||||
private ItemDescription folder;
|
||||
|
||||
public Computations() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Computations(ItemDescription folder) {
|
||||
super();
|
||||
this.folder = folder;
|
||||
}
|
||||
|
||||
public ItemDescription getFolder() {
|
||||
return folder;
|
||||
}
|
||||
|
||||
public void setFolder(ItemDescription folder) {
|
||||
this.folder = folder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Computations [folder=" + folder + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.shared.workspace;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class DataMinerWorkArea implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -7906477664944910362L;
|
||||
private ItemDescription dataMinerWorkAreaFolder;
|
||||
private InputDataSets inputDataSets;
|
||||
private OutputDataSets outputDataSets;
|
||||
private Computations computations;
|
||||
|
||||
public DataMinerWorkArea() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dataMinerWorkAreaFolder
|
||||
*/
|
||||
public DataMinerWorkArea(ItemDescription dataMinerWorkAreaFolder) {
|
||||
super();
|
||||
this.dataMinerWorkAreaFolder = dataMinerWorkAreaFolder;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dataMinerWorkAreaFolder
|
||||
* @param inputDataSets
|
||||
* @param outputDataSets
|
||||
* @param computations
|
||||
*/
|
||||
public DataMinerWorkArea(ItemDescription dataMinerWorkAreaFolder,
|
||||
InputDataSets inputDataSets, OutputDataSets outputDataSets,
|
||||
Computations computations) {
|
||||
super();
|
||||
this.dataMinerWorkAreaFolder = dataMinerWorkAreaFolder;
|
||||
this.inputDataSets = inputDataSets;
|
||||
this.outputDataSets = outputDataSets;
|
||||
this.computations = computations;
|
||||
}
|
||||
|
||||
public ItemDescription getDataMinerWorkAreaFolder() {
|
||||
return dataMinerWorkAreaFolder;
|
||||
}
|
||||
|
||||
public void setDataMinerWorkAreaFolder(ItemDescription dataMinerWorkAreaFolder) {
|
||||
this.dataMinerWorkAreaFolder = dataMinerWorkAreaFolder;
|
||||
}
|
||||
|
||||
public InputDataSets getInputDataSets() {
|
||||
return inputDataSets;
|
||||
}
|
||||
|
||||
public void setInputDataSets(InputDataSets inputDataSets) {
|
||||
this.inputDataSets = inputDataSets;
|
||||
}
|
||||
|
||||
public OutputDataSets getOutputDataSets() {
|
||||
return outputDataSets;
|
||||
}
|
||||
|
||||
public void setOutputDataSets(OutputDataSets outputDataSets) {
|
||||
this.outputDataSets = outputDataSets;
|
||||
}
|
||||
|
||||
public Computations getComputations() {
|
||||
return computations;
|
||||
}
|
||||
|
||||
public void setComputations(Computations computations) {
|
||||
this.computations = computations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DataMinerWorkArea [dataMinerWorkAreaFolder="
|
||||
+ dataMinerWorkAreaFolder + ", inputDataSets=" + inputDataSets
|
||||
+ ", outputDataSets=" + outputDataSets + ", computations="
|
||||
+ computations + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.shared.workspace;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class InputDataSets implements Serializable {
|
||||
private static final long serialVersionUID = -4408116083736005844L;
|
||||
|
||||
private ItemDescription folder;
|
||||
|
||||
public InputDataSets() {
|
||||
super();
|
||||
}
|
||||
|
||||
public InputDataSets(ItemDescription folder) {
|
||||
super();
|
||||
this.folder = folder;
|
||||
}
|
||||
|
||||
public ItemDescription getFolder() {
|
||||
return folder;
|
||||
}
|
||||
|
||||
public void setFolder(ItemDescription folder) {
|
||||
this.folder = folder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ImportedData [folder=" + folder + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.shared.workspace;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ItemDescription implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -6624452446980057923L;
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
private String owner;
|
||||
private String path;
|
||||
private String type;
|
||||
private String publicLink;
|
||||
|
||||
public ItemDescription() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ItemDescription(String id, String name, String owner, String path,
|
||||
String type) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.owner = owner;
|
||||
this.path = path;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getPublicLink() {
|
||||
return publicLink;
|
||||
}
|
||||
|
||||
public void setPublicLink(String publicLink) {
|
||||
this.publicLink = publicLink;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare basic information with another ItemDescription not null
|
||||
*
|
||||
* @param itemDescription
|
||||
* @return boolean
|
||||
*
|
||||
*/
|
||||
public boolean compareInfo(ItemDescription itemDescription){
|
||||
if(itemDescription!=null && id.compareTo(itemDescription.getId())==0 &&
|
||||
name.compareTo(itemDescription.getName())==0 &&
|
||||
owner.compareTo(itemDescription.getOwner())==0 &&
|
||||
path.compareTo(itemDescription.getPath())==0 &&
|
||||
type.compareTo(itemDescription.getType())==0
|
||||
){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ItemDescription [id=" + id + ", name=" + name + ", owner="
|
||||
+ owner + ", path=" + path + ", type=" + type + ", publicLink="
|
||||
+ publicLink + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.shared.workspace;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class OutputDataSets implements Serializable {
|
||||
private static final long serialVersionUID = -8235652292513149983L;
|
||||
|
||||
private ItemDescription folder;
|
||||
|
||||
public OutputDataSets() {
|
||||
super();
|
||||
}
|
||||
|
||||
public OutputDataSets(ItemDescription folder) {
|
||||
super();
|
||||
this.folder = folder;
|
||||
}
|
||||
|
||||
public ItemDescription getFolder() {
|
||||
return folder;
|
||||
}
|
||||
|
||||
public void setFolder(ItemDescription folder) {
|
||||
this.folder = folder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ComputedData [folder=" + folder + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,201 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.DataMinerService;
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.dmservice.SClient;
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.monitor.DMMonitor;
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.monitor.DMMonitorListener;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.Constants;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.OutputData;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationId;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.output.MapResource;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.output.Resource;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.ColumnListParameter;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.ObjectParameter;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.TabularParameter;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.process.Operator;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class DBScanTest extends TestCase {
|
||||
private static Logger logger = LoggerFactory.getLogger(DBScanTest.class);
|
||||
|
||||
public void testExecute() {
|
||||
|
||||
if (Constants.TEST_ENABLE) {
|
||||
logger.debug("Test Dbscan");
|
||||
try {
|
||||
SClient sClient = DataMinerService.getClient();
|
||||
Operator dBScanOperator = sClient
|
||||
.getOperatorById("org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mappedclasses.clusterers.DBSCAN");
|
||||
|
||||
if (dBScanOperator == null) {
|
||||
logger.error("Operator not found");
|
||||
} else {
|
||||
logger.debug("Operator Name: " + dBScanOperator.getName()
|
||||
+ " (" + dBScanOperator.getId() + ")");
|
||||
logger.debug("Operator: " + dBScanOperator);
|
||||
List<Parameter> parameters = sClient
|
||||
.getInputParameters(dBScanOperator);
|
||||
logger.debug("Parameters: " + parameters);
|
||||
for (Parameter parameter : parameters) {
|
||||
logger.debug("Parameter:[Name=" + parameter.getName()
|
||||
+ ", Typology=" + parameter.getTypology() + "]");
|
||||
}
|
||||
|
||||
createRequest(dBScanOperator);
|
||||
logger.debug("Start Computation");
|
||||
ComputationId computationId = sClient
|
||||
.startComputation(dBScanOperator);
|
||||
logger.debug("Started ComputationId: " + computationId);
|
||||
monitoringComputation(computationId, sClient);
|
||||
}
|
||||
|
||||
assertTrue("Success", true);
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
assertTrue("Error", false);
|
||||
}
|
||||
|
||||
} else {
|
||||
assertTrue("Success", true);
|
||||
}
|
||||
}
|
||||
|
||||
private void monitoringComputation(final ComputationId computationId,
|
||||
final SClient sClient) {
|
||||
|
||||
DMMonitorListener listener = new DMMonitorListener() {
|
||||
|
||||
@Override
|
||||
public void running(double percentage) {
|
||||
logger.debug("Operation Running: " + percentage);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(String message, Exception exception) {
|
||||
logger.error("Operation Failed");
|
||||
logger.error(message);
|
||||
logger.error(exception.getStackTrace().toString());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(double percentage) {
|
||||
logger.debug("Operation Completed");
|
||||
logger.debug("Perc: " + percentage);
|
||||
retrieveOutput(computationId, sClient);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelled() {
|
||||
logger.debug("Operation Cancelled");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accepted() {
|
||||
logger.debug("Operation Accepted");
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
DMMonitor dmMonitor = new DMMonitor(computationId, sClient);
|
||||
dmMonitor.add(listener);
|
||||
dmMonitor.start();
|
||||
|
||||
}
|
||||
|
||||
private void retrieveOutput(ComputationId computationId, SClient sClient) {
|
||||
try {
|
||||
OutputData output = sClient
|
||||
.getOutputDataByComputationId(computationId);
|
||||
logger.debug("Output: " + output);
|
||||
Resource resource=output.getResource();
|
||||
if(resource.isMap()){
|
||||
MapResource mapResource=(MapResource) resource;
|
||||
for(String key: mapResource.getMap().keySet()){
|
||||
logger.debug("Entry: "+key+" = "+mapResource.getMap().get(key));
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifier=org.gcube.dataanalysis.wps.
|
||||
* statisticalmanager.synchserver.mappedclasses.clusterers.DBSCAN&
|
||||
* DataInputs= OccurrencePointsTable=http://data-d.d4science.org/
|
||||
* SnBPSHJQOEI4UHQ0QkhnM2p3L2JGQytNTmtSb1FpUTFHbWJQNStIS0N6Yz0;
|
||||
* FeaturesColumnNames=depthmean|sstmnmax|salinitymin;
|
||||
* OccurrencePointsClusterLabel=Test;epsilon=10;min_points=1;
|
||||
*
|
||||
* @param operator
|
||||
*/
|
||||
private void createRequest(Operator operator) {
|
||||
logger.debug("Create Request");
|
||||
|
||||
TabularParameter occurencePointsTable = new TabularParameter();
|
||||
occurencePointsTable.setName("OccurrencePointsTable");
|
||||
occurencePointsTable
|
||||
.setValue("http://data-d.d4science.org/SnBPSHJQOEI4UHQ0QkhnM2p3L2JGQytNTmtSb1FpUTFHbWJQNStIS0N6Yz0");
|
||||
occurencePointsTable.setDefaultMimeType("text/csv");
|
||||
ArrayList<String> supportedMimeTypes = new ArrayList<>(
|
||||
Arrays.asList(new String[] { "text/xml", "text/csv",
|
||||
"text/plain" }));
|
||||
occurencePointsTable.setSupportedMimeTypes(supportedMimeTypes);
|
||||
|
||||
ColumnListParameter columnListParameter = new ColumnListParameter();
|
||||
columnListParameter.setName("FeaturesColumnNames");
|
||||
columnListParameter
|
||||
.setReferredTabularParameterName("OccurrencePointsTable");
|
||||
columnListParameter.setSeparator("|");
|
||||
columnListParameter.setValue("depthmean|sstmnmax|salinitymin");
|
||||
|
||||
ObjectParameter occurencePointsClusterLabel = new ObjectParameter();
|
||||
occurencePointsClusterLabel.setName("OccurrencePointsClusterLabel");
|
||||
occurencePointsClusterLabel.setType("java.lang.String");
|
||||
occurencePointsClusterLabel.setValue("Test");
|
||||
|
||||
ObjectParameter epsilon = new ObjectParameter();
|
||||
epsilon.setName("epsilon");
|
||||
epsilon.setType("java.lang.Integer");
|
||||
epsilon.setValue("10");
|
||||
|
||||
ObjectParameter minPoints = new ObjectParameter();
|
||||
minPoints.setName("min_points");
|
||||
minPoints.setType("java.lang.Integer");
|
||||
minPoints.setValue("1");
|
||||
|
||||
List<Parameter> parameters = new ArrayList<>();
|
||||
parameters.add(occurencePointsTable);
|
||||
parameters.add(columnListParameter);
|
||||
parameters.add(occurencePointsClusterLabel);
|
||||
parameters.add(epsilon);
|
||||
parameters.add(minPoints);
|
||||
|
||||
logger.debug("Parameters set: " + parameters);
|
||||
operator.setOperatorParameters(parameters);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.DataMinerService;
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.dmservice.SClient;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.Constants;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.process.Operator;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.process.OperatorsClassification;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class DataMinerServiceTest extends TestCase {
|
||||
private static Logger logger = LoggerFactory
|
||||
.getLogger(DataMinerServiceTest.class);
|
||||
|
||||
public void testOperators() {
|
||||
|
||||
if (Constants.TEST_ENABLE) {
|
||||
logger.debug("Test Operators");
|
||||
try {
|
||||
SClient sClient = DataMinerService.getClient();
|
||||
List<OperatorsClassification> operatorsClassifications = sClient
|
||||
.getOperatorsClassifications();
|
||||
logger.debug("OperatorsClassifications: " + operatorsClassifications);
|
||||
|
||||
if(operatorsClassifications!=null && operatorsClassifications.size()>0){
|
||||
OperatorsClassification firstCategory=operatorsClassifications.get(0);
|
||||
if(firstCategory.getOperators()!=null&& !firstCategory.getOperators().isEmpty()){
|
||||
Operator operator=firstCategory.getOperators().get(0);
|
||||
logger.debug("First Operator: "+operator);
|
||||
List<Parameter> parameters=sClient.getInputParameters(operator);
|
||||
logger.debug("Parameters: "+parameters);
|
||||
|
||||
|
||||
} else {
|
||||
logger.debug("Operators void");
|
||||
}
|
||||
} else {
|
||||
logger.debug("OperatorsClassifcation void");
|
||||
}
|
||||
|
||||
assertTrue("Success",true);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
assertTrue("Error", false);
|
||||
}
|
||||
|
||||
} else {
|
||||
assertTrue("Success",true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void testOperarorName() {
|
||||
|
||||
if (Constants.TEST_ENABLE) {
|
||||
logger.debug("Test DBScan");
|
||||
try {
|
||||
SClient sClient = DataMinerService.getClient();
|
||||
List<OperatorsClassification> operatorsClassifications = sClient
|
||||
.getOperatorsClassifications();
|
||||
logger.debug("OperatorsClassifications rerieved");
|
||||
|
||||
if(operatorsClassifications!=null && operatorsClassifications.size()>0){
|
||||
for(OperatorsClassification oc:operatorsClassifications){
|
||||
for(Operator op:oc.getOperators()){
|
||||
logger.debug("Operator: "+op.getName()+" ("+op.getId()+")");
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
logger.debug("OperatorsClassifcation void");
|
||||
}
|
||||
|
||||
assertTrue("Success",true);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
assertTrue("Error", false);
|
||||
}
|
||||
|
||||
} else {
|
||||
assertTrue("Success",true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,166 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.DataMinerService;
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.dmservice.SClient;
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.monitor.DMMonitor;
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.monitor.DMMonitorListener;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.Constants;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.OutputData;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationId;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.output.MapResource;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.output.Resource;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.ObjectParameter;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.process.Operator;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ListDBInfoTest extends TestCase {
|
||||
private static Logger logger = LoggerFactory
|
||||
.getLogger(ListDBInfoTest.class);
|
||||
|
||||
public void testExecute() {
|
||||
if (Constants.TEST_ENABLE) {
|
||||
logger.debug("Test ListDBInfo");
|
||||
try {
|
||||
SClient sClient = DataMinerService.getClient();
|
||||
Operator operator = sClient
|
||||
.getOperatorById("org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mappedclasses.transducerers.LISTDBINFO");
|
||||
|
||||
if (operator == null) {
|
||||
logger.error("Operator not found");
|
||||
} else {
|
||||
logger.debug("Operator Name: " + operator.getName()
|
||||
+ " (" + operator.getId() + ")");
|
||||
logger.debug("Operator: " + operator);
|
||||
List<Parameter> parameters = sClient
|
||||
.getInputParameters(operator);
|
||||
logger.debug("Parameters: " + parameters);
|
||||
for (Parameter parameter : parameters) {
|
||||
logger.debug("Parameter:[Name=" + parameter.getName()
|
||||
+ ", Typology=" + parameter.getTypology() + "]");
|
||||
}
|
||||
|
||||
createRequest(operator);
|
||||
logger.debug("Start Computation");
|
||||
ComputationId computationId = sClient
|
||||
.startComputation(operator);
|
||||
logger.debug("Started ComputationId: " + computationId);
|
||||
monitoringComputation(computationId, sClient);
|
||||
}
|
||||
|
||||
assertTrue("Success", true);
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
assertTrue("Error", false);
|
||||
}
|
||||
|
||||
} else {
|
||||
assertTrue("Success", true);
|
||||
}
|
||||
}
|
||||
|
||||
private void monitoringComputation(final ComputationId computationId,
|
||||
final SClient sClient) {
|
||||
|
||||
DMMonitorListener listener = new DMMonitorListener() {
|
||||
|
||||
@Override
|
||||
public void running(double percentage) {
|
||||
logger.debug("Operation Running: " + percentage);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(String message, Exception exception) {
|
||||
logger.error("Operation Failed");
|
||||
logger.error(message);
|
||||
logger.error(exception.getStackTrace().toString());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(double percentage) {
|
||||
logger.debug("Operation Completed");
|
||||
logger.debug("Perc: " + percentage);
|
||||
retrieveOutput(computationId, sClient);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelled() {
|
||||
logger.debug("Operation Cancelled");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accepted() {
|
||||
logger.debug("Operation Accepted");
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
DMMonitor dmMonitor = new DMMonitor(computationId, sClient);
|
||||
dmMonitor.add(listener);
|
||||
dmMonitor.start();
|
||||
|
||||
}
|
||||
|
||||
private void retrieveOutput(ComputationId computationId, SClient sClient) {
|
||||
try {
|
||||
OutputData output = sClient
|
||||
.getOutputDataByComputationId(computationId);
|
||||
logger.debug("Output: " + output);
|
||||
Resource resource=output.getResource();
|
||||
if(resource.isMap()){
|
||||
MapResource mapResource=(MapResource) resource;
|
||||
for(String key: mapResource.getMap().keySet()){
|
||||
logger.debug("Entry: "+key+" = "+mapResource.getMap().get(key));
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Identifier=org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mappedclasses.transducerers.LISTDBINFO
|
||||
* &DataInputs=ResourceName=;
|
||||
*
|
||||
* @param operator
|
||||
*/
|
||||
private void createRequest(Operator operator) {
|
||||
logger.debug("Create Request");
|
||||
|
||||
ObjectParameter resourceName = new ObjectParameter();
|
||||
resourceName.setName("ResourceName");
|
||||
resourceName.setType("java.lang.String");
|
||||
//MaxNumber.setValue("CKanDatabase");
|
||||
resourceName.setValue("FishBase");
|
||||
|
||||
List<Parameter> parameters = new ArrayList<>();
|
||||
|
||||
parameters.add(resourceName);
|
||||
|
||||
logger.debug("Parameters set: " + parameters);
|
||||
operator.setOperatorParameters(parameters);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,165 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.DataMinerService;
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.dmservice.SClient;
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.monitor.DMMonitor;
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.monitor.DMMonitorListener;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.Constants;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.OutputData;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationId;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.output.MapResource;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.output.Resource;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.ObjectParameter;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.process.Operator;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ListDBNameTest extends TestCase {
|
||||
private static Logger logger = LoggerFactory.getLogger(ListDBNameTest.class);
|
||||
|
||||
public void testExecute() {
|
||||
|
||||
if (Constants.TEST_ENABLE) {
|
||||
logger.debug("Test ListDBName");
|
||||
try {
|
||||
SClient sClient = DataMinerService.getClient();
|
||||
Operator operator = sClient
|
||||
.getOperatorById("org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mappedclasses.transducerers.LISTDBNAMES");
|
||||
|
||||
if (operator == null) {
|
||||
logger.error("Operator not found");
|
||||
} else {
|
||||
logger.debug("Operator Name: " + operator.getName()
|
||||
+ " (" + operator.getId() + ")");
|
||||
logger.debug("Operator: " + operator);
|
||||
List<Parameter> parameters = sClient
|
||||
.getInputParameters(operator);
|
||||
logger.debug("Parameters: " + parameters);
|
||||
for (Parameter parameter : parameters) {
|
||||
logger.debug("Parameter:[Name=" + parameter.getName()
|
||||
+ ", Typology=" + parameter.getTypology() + "]");
|
||||
}
|
||||
|
||||
createRequest(operator);
|
||||
logger.debug("Start Computation");
|
||||
ComputationId computationId = sClient
|
||||
.startComputation(operator);
|
||||
logger.debug("Started ComputationId: " + computationId);
|
||||
monitoringComputation(computationId, sClient);
|
||||
}
|
||||
|
||||
assertTrue("Success", true);
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
assertTrue("Error", false);
|
||||
}
|
||||
|
||||
} else {
|
||||
assertTrue("Success", true);
|
||||
}
|
||||
}
|
||||
|
||||
private void monitoringComputation(final ComputationId computationId,
|
||||
final SClient sClient) {
|
||||
|
||||
DMMonitorListener listener = new DMMonitorListener() {
|
||||
|
||||
@Override
|
||||
public void running(double percentage) {
|
||||
logger.debug("Operation Running: " + percentage);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(String message, Exception exception) {
|
||||
logger.error("Operation Failed");
|
||||
logger.error(message);
|
||||
logger.error(exception.getStackTrace().toString());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(double percentage) {
|
||||
logger.debug("Operation Completed");
|
||||
logger.debug("Perc: " + percentage);
|
||||
retrieveOutput(computationId, sClient);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelled() {
|
||||
logger.debug("Operation Cancelled");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accepted() {
|
||||
logger.debug("Operation Accepted");
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
DMMonitor dmMonitor = new DMMonitor(computationId, sClient);
|
||||
dmMonitor.add(listener);
|
||||
dmMonitor.start();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void retrieveOutput(ComputationId computationId, SClient sClient) {
|
||||
try {
|
||||
OutputData output = sClient
|
||||
.getOutputDataByComputationId(computationId);
|
||||
logger.debug("Output: " + output);
|
||||
Resource resource=output.getResource();
|
||||
if(resource.isMap()){
|
||||
MapResource mapResource=(MapResource) resource;
|
||||
for(String key: mapResource.getMap().keySet()){
|
||||
logger.debug("Entry: "+key+" = "+mapResource.getMap().get(key));
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifier=org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mappedclasses.transducerers.LISTDBNAMES
|
||||
* &DataInputs=MaxNumber=-1;
|
||||
*
|
||||
* @param operator
|
||||
*/
|
||||
private void createRequest(Operator operator) {
|
||||
logger.debug("Create Request");
|
||||
|
||||
ObjectParameter maxNumber = new ObjectParameter();
|
||||
maxNumber.setName("MaxNumber");
|
||||
maxNumber.setType("java.lang.String");
|
||||
maxNumber.setValue("-1");
|
||||
|
||||
List<Parameter> parameters = new ArrayList<>();
|
||||
|
||||
parameters.add(maxNumber);
|
||||
|
||||
logger.debug("Parameters set: " + parameters);
|
||||
operator.setOperatorParameters(parameters);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,183 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.DataMinerService;
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.dmservice.SClient;
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.monitor.DMMonitor;
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.monitor.DMMonitorListener;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.Constants;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.OutputData;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationId;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.output.MapResource;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.output.ObjectResource;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.output.Resource;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.ObjectParameter;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.process.Operator;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ListDBSchemaTest extends TestCase {
|
||||
private static Logger logger = LoggerFactory
|
||||
.getLogger(ListDBSchemaTest.class);
|
||||
|
||||
public void testExecute() {
|
||||
if (Constants.TEST_ENABLE) {
|
||||
logger.debug("Test ListDBSchema");
|
||||
try {
|
||||
SClient sClient = DataMinerService.getClient();
|
||||
Operator operator = sClient
|
||||
.getOperatorById("org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mappedclasses.transducerers.LISTDBSCHEMA");
|
||||
|
||||
if (operator == null) {
|
||||
logger.error("Operator not found");
|
||||
} else {
|
||||
logger.debug("Operator Name: " + operator.getName() + " ("
|
||||
+ operator.getId() + ")");
|
||||
logger.debug("Operator: " + operator);
|
||||
List<Parameter> parameters = sClient
|
||||
.getInputParameters(operator);
|
||||
logger.debug("Parameters: " + parameters);
|
||||
for (Parameter parameter : parameters) {
|
||||
logger.debug("Parameter:[Name=" + parameter.getName()
|
||||
+ ", Typology=" + parameter.getTypology() + "]");
|
||||
}
|
||||
|
||||
createRequest(operator);
|
||||
logger.debug("Start Computation");
|
||||
ComputationId computationId = sClient
|
||||
.startComputation(operator);
|
||||
logger.debug("Started ComputationId: " + computationId);
|
||||
monitoringComputation(computationId, sClient);
|
||||
}
|
||||
|
||||
assertTrue("Success", true);
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
assertTrue("Error", false);
|
||||
}
|
||||
|
||||
} else {
|
||||
assertTrue("Success", true);
|
||||
}
|
||||
}
|
||||
|
||||
private void monitoringComputation(final ComputationId computationId,
|
||||
final SClient sClient) {
|
||||
|
||||
DMMonitorListener listener = new DMMonitorListener() {
|
||||
|
||||
@Override
|
||||
public void running(double percentage) {
|
||||
logger.debug("Operation Running: " + percentage);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(String message, Exception exception) {
|
||||
logger.error("Operation Failed");
|
||||
logger.error(message);
|
||||
logger.error(exception.getStackTrace().toString());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(double percentage) {
|
||||
logger.debug("Operation Completed");
|
||||
logger.debug("Perc: " + percentage);
|
||||
retrieveOutput(computationId, sClient);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelled() {
|
||||
logger.debug("Operation Cancelled");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accepted() {
|
||||
logger.debug("Operation Accepted");
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
DMMonitor dmMonitor = new DMMonitor(computationId, sClient);
|
||||
dmMonitor.add(listener);
|
||||
dmMonitor.start();
|
||||
|
||||
}
|
||||
|
||||
private void retrieveOutput(ComputationId computationId, SClient sClient) {
|
||||
try {
|
||||
OutputData output = sClient
|
||||
.getOutputDataByComputationId(computationId);
|
||||
logger.debug("Output: " + output);
|
||||
Resource resource = output.getResource();
|
||||
if (resource.isMap()) {
|
||||
MapResource mapResource = (MapResource) resource;
|
||||
for (String key : mapResource.getMap().keySet()) {
|
||||
logger.debug("Entry: " + key + " = "
|
||||
+ mapResource.getMap().get(key));
|
||||
if (mapResource.getMap().get(key) != null
|
||||
&& mapResource.getMap().get(key).isObject()) {
|
||||
ObjectResource objectResource = (ObjectResource) mapResource
|
||||
.getMap().get(key);
|
||||
logger.debug("[Name=" + objectResource.getName()
|
||||
+ ",Value=" + objectResource.getValue()
|
||||
+ ",Description="
|
||||
+ objectResource.getDescription()+"]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Identifier=org.gcube.dataanalysis.wps.statisticalmanager.synchserver.
|
||||
* mappedclasses.transducerers.LISTDBSCHEMA
|
||||
* &DataInputs=ResourceName=;DatabaseName=;
|
||||
*
|
||||
* @param operator
|
||||
*/
|
||||
private void createRequest(Operator operator) {
|
||||
logger.debug("Create Request");
|
||||
|
||||
ObjectParameter resourceName = new ObjectParameter();
|
||||
resourceName.setName("ResourceName");
|
||||
resourceName.setType("java.lang.String");
|
||||
resourceName.setValue("FishBase");
|
||||
|
||||
ObjectParameter databaseName = new ObjectParameter();
|
||||
databaseName.setName("DatabaseName");
|
||||
databaseName.setType("java.lang.String");
|
||||
databaseName.setValue("fishbase");
|
||||
|
||||
List<Parameter> parameters = new ArrayList<>();
|
||||
|
||||
parameters.add(resourceName);
|
||||
parameters.add(databaseName);
|
||||
|
||||
logger.debug("Parameters set: " + parameters);
|
||||
operator.setOperatorParameters(parameters);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,189 @@
|
|||
package org.gcube.data.analysis.dataminermanagercl.test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.DataMinerService;
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.dmservice.SClient;
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.monitor.DMMonitor;
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.monitor.DMMonitorListener;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.Constants;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.OutputData;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationId;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.output.MapResource;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.output.ObjectResource;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.output.Resource;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.ObjectParameter;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.process.Operator;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ListTablesTest extends TestCase {
|
||||
private static Logger logger = LoggerFactory
|
||||
.getLogger(ListTablesTest.class);
|
||||
|
||||
public void testExecute() {
|
||||
if (Constants.TEST_ENABLE) {
|
||||
logger.debug("Test ListTables");
|
||||
try {
|
||||
SClient sClient = DataMinerService.getClient();
|
||||
Operator operator = sClient
|
||||
.getOperatorById("org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mappedclasses.transducerers.LISTTABLES");
|
||||
|
||||
if (operator == null) {
|
||||
logger.error("Operator not found");
|
||||
} else {
|
||||
logger.debug("Operator Name: " + operator.getName() + " ("
|
||||
+ operator.getId() + ")");
|
||||
logger.debug("Operator: " + operator);
|
||||
List<Parameter> parameters = sClient
|
||||
.getInputParameters(operator);
|
||||
logger.debug("Parameters: " + parameters);
|
||||
for (Parameter parameter : parameters) {
|
||||
logger.debug("Parameter:[Name=" + parameter.getName()
|
||||
+ ", Typology=" + parameter.getTypology() + "]");
|
||||
}
|
||||
|
||||
createRequest(operator);
|
||||
logger.debug("Start Computation");
|
||||
ComputationId computationId = sClient
|
||||
.startComputation(operator);
|
||||
logger.debug("Started ComputationId: " + computationId);
|
||||
monitoringComputation(computationId, sClient);
|
||||
}
|
||||
|
||||
assertTrue("Success", true);
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
assertTrue("Error", false);
|
||||
}
|
||||
|
||||
} else {
|
||||
assertTrue("Success", true);
|
||||
}
|
||||
}
|
||||
|
||||
private void monitoringComputation(final ComputationId computationId,
|
||||
final SClient sClient) {
|
||||
|
||||
DMMonitorListener listener = new DMMonitorListener() {
|
||||
|
||||
@Override
|
||||
public void running(double percentage) {
|
||||
logger.debug("Operation Running: " + percentage);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(String message, Exception exception) {
|
||||
logger.error("Operation Failed");
|
||||
logger.error(message);
|
||||
logger.error(exception.getStackTrace().toString());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(double percentage) {
|
||||
logger.debug("Operation Completed");
|
||||
logger.debug("Perc: " + percentage);
|
||||
retrieveOutput(computationId, sClient);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelled() {
|
||||
logger.debug("Operation Cancelled");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accepted() {
|
||||
logger.debug("Operation Accepted");
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
DMMonitor dmMonitor = new DMMonitor(computationId, sClient);
|
||||
dmMonitor.add(listener);
|
||||
dmMonitor.start();
|
||||
|
||||
}
|
||||
|
||||
private void retrieveOutput(ComputationId computationId, SClient sClient) {
|
||||
try {
|
||||
OutputData output = sClient
|
||||
.getOutputDataByComputationId(computationId);
|
||||
logger.debug("Output: " + output);
|
||||
Resource resource = output.getResource();
|
||||
if (resource.isMap()) {
|
||||
MapResource mapResource = (MapResource) resource;
|
||||
for (String key : mapResource.getMap().keySet()) {
|
||||
logger.debug("Entry: " + key + " = "
|
||||
+ mapResource.getMap().get(key));
|
||||
if (mapResource.getMap().get(key) != null
|
||||
&& mapResource.getMap().get(key).isObject()) {
|
||||
ObjectResource objectResource = (ObjectResource) mapResource
|
||||
.getMap().get(key);
|
||||
logger.debug("[Name=" + objectResource.getName()
|
||||
+ ",Value=" + objectResource.getValue()
|
||||
+ ",Description="
|
||||
+ objectResource.getDescription() + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Identifier=org.gcube.dataanalysis.wps.statisticalmanager.synchserver.
|
||||
* mappedclasses.transducerers.LISTTABLES
|
||||
* &DataInputs=ResourceName=;DatabaseName=;SchemaName=;
|
||||
*
|
||||
* @param operator
|
||||
*/
|
||||
private void createRequest(Operator operator) {
|
||||
logger.debug("Create Request");
|
||||
|
||||
ObjectParameter resourceName = new ObjectParameter();
|
||||
resourceName.setName("ResourceName");
|
||||
resourceName.setType("java.lang.String");
|
||||
resourceName.setValue("FishBase");
|
||||
|
||||
ObjectParameter databaseName = new ObjectParameter();
|
||||
databaseName.setName("DatabaseName");
|
||||
databaseName.setType("java.lang.String");
|
||||
databaseName.setValue("fishbase");
|
||||
|
||||
ObjectParameter schemaName = new ObjectParameter();
|
||||
schemaName.setName("SchemaName");
|
||||
schemaName.setType("java.lang.String");
|
||||
schemaName.setValue("public");
|
||||
|
||||
List<Parameter> parameters = new ArrayList<>();
|
||||
|
||||
parameters.add(resourceName);
|
||||
parameters.add(databaseName);
|
||||
parameters.add(schemaName);
|
||||
|
||||
logger.debug("Parameters set: " + parameters);
|
||||
operator.setOperatorParameters(parameters);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
# A default log4j configuration for log4j users.
|
||||
#
|
||||
# To use this configuration, deploy it into your application's WEB-INF/classes
|
||||
# directory. You are also encouraged to edit it as you like.
|
||||
|
||||
log4j.rootLogger=DEBUG, stdout, rollingFile
|
||||
|
||||
# Redirect log messages to console
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.Target=System.out
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
|
||||
|
||||
|
||||
log4j.appender.rollingFile=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.rollingFile.File=test.log
|
||||
log4j.appender.rollingFile.MaxFileSize=20MB
|
||||
log4j.appender.rollingFile.MaxBackupIndex=2
|
||||
log4j.appender.rollingFile.layout = org.apache.log4j.PatternLayout
|
||||
log4j.appender.rollingFile.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
|
Loading…
Reference in New Issue