diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..9cccab7
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.project b/.project
new file mode 100644
index 0000000..63d3b0e
--- /dev/null
+++ b/.project
@@ -0,0 +1,23 @@
+
+
+ data-miner-manager-cl
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+
+
+ org.eclipse.m2e.core.maven2Nature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..a4b1c22
--- /dev/null
+++ b/.settings/org.eclipse.core.resources.prefs
@@ -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/=UTF-8
+encoding/src=UTF-8
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..6b5aebc
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -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
diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..37fddc6
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,239 @@
+
+ 4.0.0
+
+
+ maven-parent
+ org.gcube.tools
+ 1.0.0
+
+
+
+ data-miner-manager-cl
+ data-miner-manager-cl
+ 1.0.0-SNAPSHOT
+
+ data-miner-manager-cl
+ DataMiner Manager Client Library
+
+
+
+ https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/data-miner-manager-cl
+
+
+
+
+
+ Giancarlo Panichi
+ g.panichi@isti.cnr.it
+ CNR Pisa, Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo"
+
+ architect
+ developer
+
+
+
+
+
+ ${project.build.directory}/${project.build.finalName}
+ distro
+ config
+
+
+
+ 1.7
+
+ ${env.KEYS}
+
+ UTF-8
+ UTF-8
+
+
+
+
+
+ localRun
+
+
+
+ org.slf4j
+ slf4j-api
+ compile
+
+
+ org.slf4j
+ slf4j-log4j12
+ runtime
+
+
+
+ xerces
+ xerces
+ 2.4.0
+
+
+
+
+ org.gcube.contentmanagement
+ storage-manager-core
+ runtime
+
+
+ org.gcube.contentmanagement
+ storage-manager-wrapper
+ runtime
+
+
+
+
+
+
+ org.gcube.common
+ common-authorization
+ runtime
+
+
+ org.gcube.common
+ authorization-client
+ runtime
+
+
+
+
+
+
+
+
+
+
+
+
+ org.gcube.common
+ common-authorization
+ provided
+
+
+ org.gcube.common
+ authorization-client
+ provided
+
+
+
+
+ org.gcube.contentmanagement
+ storage-manager-core
+ [2.1.0-SNAPSHOT,)
+ provided
+
+
+
+ org.gcube.contentmanagement
+ storage-manager-wrapper
+ [2.1.0-SNAPSHOT,)
+ provided
+
+
+
+
+ org.gcube.resources.discovery
+ ic-client
+
+
+
+
+ org.n52.wps
+ 52n-wps-client-lib
+ 3.2.0
+
+
+ gt-opengis
+ org.geotools
+
+
+ xerces
+ xercesImpl
+
+
+
+
+
+
+
+
+ org.slf4j
+ slf4j-api
+ provided
+
+
+
+ org.slf4j
+ slf4j-log4j12
+ 1.7.5
+ test
+
+
+
+
+
+
+
+
+ gCubeExternal
+ gcube-externals
+ http://maven.research-infrastructures.eu/nexus/content/repositories/gcube-externals/
+
+
+
+ n52-releases
+ 52n Releases
+ http://52north.org/maven/repo/releases/
+
+ true
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.gcube.distribution
+ gcube-bom
+ LATEST
+ pom
+ import
+
+
+
+
+
+
+ src
+
+
+ maven-compiler-plugin
+ 3.1
+
+
+ 1.7
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/DataMinerService.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/DataMinerService.java
new file mode 100644
index 0000000..97e2418
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/DataMinerService.java
@@ -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: g.panichi@isti.cnr.it
+ *
+ */
+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;
+
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/SClient.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/SClient.java
new file mode 100644
index 0000000..d11cb77
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/SClient.java
@@ -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: g.panichi@isti.cnr.it
+ *
+ */
+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 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 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 computationProperties) throws Exception;
+
+ /**
+ * Resubmit a computation only by computation properties
+ *
+ * @param computationProperties
+ * @return
+ * @throws Exception
+ */
+ public abstract ComputationId resubmitComputation(
+ Map computationProperties) throws Exception;
+
+
+ @Override
+ public String toString() {
+ return "SClient";
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/SClient4WPS.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/SClient4WPS.java
new file mode 100644
index 0000000..0b97d73
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/SClient4WPS.java
@@ -0,0 +1,1475 @@
+package org.gcube.data.analysis.dataminermanagercl.server.dmservice;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.math.BigInteger;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.opengis.wps.x100.CapabilitiesDocument;
+import net.opengis.wps.x100.ComplexDataType;
+import net.opengis.wps.x100.ExecuteDocument;
+import net.opengis.wps.x100.ExecuteResponseDocument;
+import net.opengis.wps.x100.ExecuteResponseDocument.ExecuteResponse.ProcessOutputs;
+import net.opengis.wps.x100.InputDescriptionType;
+import net.opengis.wps.x100.InputType;
+import net.opengis.wps.x100.OutputDataType;
+import net.opengis.wps.x100.OutputDescriptionType;
+import net.opengis.wps.x100.ProcessBriefType;
+import net.opengis.wps.x100.ProcessDescriptionType;
+import net.opengis.wps.x100.ResponseDocumentType;
+import net.opengis.wps.x100.StatusType;
+import net.opengis.wps.x100.SupportedComplexDataInputType;
+import net.opengis.wps.x100.impl.ExecuteResponseDocumentImpl;
+
+import org.apache.xmlbeans.XmlString;
+import org.gcube.data.analysis.dataminermanagercl.server.dmservice.wps.ProcessInformations;
+import org.gcube.data.analysis.dataminermanagercl.server.dmservice.wps.ResponseWPS;
+import org.gcube.data.analysis.dataminermanagercl.server.dmservice.wps.SClient4WPSSession;
+import org.gcube.data.analysis.dataminermanagercl.server.dmservice.wps.WPS2DM;
+import org.gcube.data.analysis.dataminermanagercl.server.dmservice.wps.computationsvalue.ComputationValueBuilder;
+import org.gcube.data.analysis.dataminermanagercl.server.is.InformationSystemUtils;
+import org.gcube.data.analysis.dataminermanagercl.server.storage.StorageUtil;
+import org.gcube.data.analysis.dataminermanagercl.server.util.ServiceCredential;
+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.ComputationData;
+import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationId;
+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.output.FileResource;
+import org.gcube.data.analysis.dataminermanagercl.shared.data.output.ImageResource;
+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.exception.ServiceException;
+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.process.ComputationStatus;
+import org.gcube.data.analysis.dataminermanagercl.shared.process.ComputationStatus.Status;
+import org.gcube.data.analysis.dataminermanagercl.shared.process.Operator;
+import org.gcube.data.analysis.dataminermanagercl.shared.process.OperatorCategory;
+import org.gcube.data.analysis.dataminermanagercl.shared.process.OperatorsClassification;
+import org.n52.wps.client.ExecuteRequestBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Client 4 WPS Service
+ *
+ *
+ * @author Giancarlo Panichi email: g.panichi@isti.cnr.it
+ *
+ */
+public class SClient4WPS extends SClient {
+
+ private static final long serialVersionUID = 1909871837115147159L;
+ private static Logger logger = LoggerFactory.getLogger(SClient4WPS.class);
+ // private static final int OPERATOR_BRIEF_DESCRIPTION_MAX_LENGHT = 170;
+ private static final String OTHERS = "OTHERS";
+
+ private String wpsToken;
+ private String wpsUser;
+ // private String wpsServiceURL;
+ private String wpsProcessingServlet;
+ private String wpsCancelComputationServlet;
+
+ private ProcessDescriptionType[] processesDescriptionType;
+ private ProcessBriefType[] processesBriefs;
+
+ private HashMap process;
+ private HashMap runningProcess;
+
+ private SClient4WPSSession wpsClient;
+
+ public SClient4WPS(ServiceCredential serviceCredential)
+ throws ServiceException {
+ super();
+ process = new HashMap<>();
+ runningProcess = new HashMap<>();
+ if (serviceCredential == null) {
+ logger.error("Error credetials are null!");
+ throw new ServiceException("Error credetials are null!");
+ } else {
+ String token = serviceCredential.getToken();
+ if (token == null || token.isEmpty()) {
+ logger.error("Error authorization token invalid: " + token);
+ throw new ServiceException(
+ "Error authorization token invalid: " + token);
+ } else {
+ wpsToken = token;
+ }
+
+ String userName = serviceCredential.getUsername();
+ if (userName == null || userName.isEmpty()) {
+ logger.error("Error invalid user name: " + userName);
+ throw new ServiceException("Error invalid user name: "
+ + userName);
+ } else {
+ wpsUser = userName;
+ }
+ List serviceAddress;
+ try {
+ serviceAddress = InformationSystemUtils.retrieveServiceAddress(
+ Constants.DATAMINER_SERVICE_CATEGORY,
+ Constants.DATA_MINER_SERVICE_NAME,
+ serviceCredential.getScope());
+ } catch (Exception e) {
+ logger.error("Error retrieving service address: "
+ + e.getLocalizedMessage());
+ e.printStackTrace();
+ throw new ServiceException(e.getLocalizedMessage(), e);
+ }
+ logger.debug("Service Address retrieved:" + serviceAddress);
+ if (serviceAddress == null || serviceAddress.size() < 1) {
+ logger.error("No DataMiner service address available!");
+ throw new ServiceException(
+ "No DataMiner service address available!");
+ } else {
+ logger.info("DataMiner service address found: "
+ + serviceAddress.get(0));
+ wpsProcessingServlet = serviceAddress.get(0);
+
+ int wpsWebProcessingServiceIndex = wpsProcessingServlet
+ .indexOf(Constants.WPSWebProcessingService);
+ if (wpsWebProcessingServiceIndex > 0) {
+ String wpsServiceUrl = wpsProcessingServlet.substring(0,
+ wpsWebProcessingServiceIndex);
+ wpsCancelComputationServlet = wpsServiceUrl
+ + Constants.WPSCancelComputationServlet;
+ logger.debug("Cancel computation servlet: "
+ + wpsCancelComputationServlet);
+
+ } else {
+ logger.error("Cancel computation servlet not available!");
+ throw new ServiceException(
+ "Cancel computation servlet not available!");
+ }
+
+ }
+
+ }
+
+ }
+
+ private SClient4WPSSession createWPSClientSession() {
+ if (wpsClient == null) {
+ wpsClient = new SClient4WPSSession(wpsUser, wpsToken);
+ logger.debug("Created StatWPSClientSession");
+ return wpsClient;
+ } else {
+ logger.debug("Use already created StatWPSClientSession");
+ return wpsClient;
+ }
+ }
+
+ @Override
+ public Operator getOperatorById(String id) throws Exception {
+ if (id == null || id.isEmpty()) {
+ String error = "Invalid operator request, id=" + id;
+ logger.error(error);
+ throw new ServiceException(error);
+ }
+
+ List operatorsClassifications = getOperatorsClassifications();
+
+ if (operatorsClassifications != null
+ && operatorsClassifications.size() > 0) {
+ Operator operator = null;
+ for (OperatorsClassification oc : operatorsClassifications) {
+ for (Operator op : oc.getOperators()) {
+ if (op.getId().compareToIgnoreCase(id) == 0) {
+ operator = op;
+ break;
+ }
+
+ }
+ if (operator != null) {
+ break;
+ }
+
+ }
+ if (operator == null) {
+ String error = "Operator not found (" + id + ")";
+ logger.error(error);
+ throw new ServiceException(error);
+ } else {
+ logger.debug("Operator Name: " + operator.getName() + " ("
+ + operator.getId() + ")");
+ logger.debug("Operator: " + operator);
+ return operator;
+ }
+
+ } else {
+ logger.debug("OperatorsClassification void");
+ String error = "Operator not found (" + id + ")";
+ logger.error(error);
+ throw new ServiceException(error);
+ }
+
+ }
+
+ @Override
+ public List getOperatorsClassifications()
+ throws ServiceException {
+
+ LinkedHashMap operatorsToCategoriesMap = new LinkedHashMap<>();
+ LinkedHashMap> categoriesToOperatorsMap = new LinkedHashMap<>();
+
+ requestCapability();
+ if (processesBriefs == null || processesDescriptionType == null) {
+ throw new ServiceException("Algorithms WPS not available!");
+ }
+
+ for (ProcessBriefType processBrief : processesBriefs) {
+ String categoryTitle = processBrief.getTitle().getStringValue();
+ String categoryName;
+ if (categoryTitle == null || categoryTitle.isEmpty()) {
+ categoryName = OTHERS;
+ } else {
+ String[] categorySplitted = categoryTitle.split(":");
+ if (categorySplitted.length < 1) {
+ categoryName = OTHERS;
+ } else {
+ categoryName = categorySplitted[0];
+ }
+ }
+ operatorsToCategoriesMap.put(processBrief.getIdentifier()
+ .getStringValue(), categoryName);
+ }
+
+ String briefDescription;
+ for (ProcessBriefType processDescriptionType : processesDescriptionType) {
+ briefDescription = processDescriptionType.getAbstract()
+ .getStringValue();
+
+ String categoryName = operatorsToCategoriesMap
+ .get(processDescriptionType.getIdentifier()
+ .getStringValue());
+ if (categoryName == null || categoryName.isEmpty()) {
+ categoryName = OTHERS;
+ }
+
+ List listOperators = categoriesToOperatorsMap
+ .get(categoryName);
+ if (listOperators == null) {
+ listOperators = new ArrayList<>();
+ }
+
+ listOperators
+ .add(new Operator(processDescriptionType.getIdentifier()
+ .getStringValue(), processDescriptionType
+ .getTitle().getStringValue(), briefDescription,
+ processDescriptionType.getAbstract()
+ .getStringValue(), null));
+
+ categoriesToOperatorsMap.put(categoryName, listOperators);
+
+ }
+
+ List categories = new ArrayList<>();
+ List operators = new ArrayList<>();
+
+ Comparator categoriesComparator = new Comparator() {
+ public int compare(OperatorCategory c1, OperatorCategory c2) {
+ return c1.getName().compareTo(c2.getName()); // use your logic
+ }
+ };
+
+ Comparator operatorsComparator = new Comparator() {
+ public int compare(Operator c1, Operator c2) {
+ return c1.getName().compareTo(c2.getName()); // use your logic
+ }
+ };
+
+ for (String categoryName : categoriesToOperatorsMap.keySet()) {
+ OperatorCategory category = new OperatorCategory(categoryName,
+ categoryName, categoryName);
+ List listOperators = categoriesToOperatorsMap
+ .get(categoryName);
+ for (Operator operator : listOperators) {
+ operator.setCategory(category);
+ }
+ Collections.sort(listOperators, operatorsComparator);
+ category.setOperators(listOperators);
+ operators.addAll(listOperators);
+ categories.add(category);
+ }
+
+ Collections.sort(operators, operatorsComparator);
+ Collections.sort(categories, categoriesComparator);
+
+ List operatorsClass = new ArrayList<>();
+
+ OperatorsClassification op = new OperatorsClassification(
+ Constants.UserClassificationName, categories, operators);
+
+ operatorsClass.add(op);
+
+ // logger.debug("OperatorClass: " + operatorsClass);
+ return operatorsClass;
+ }
+
+ private ProcessInformations describeProcess(String processId)
+ throws ServiceException {
+ return describeProcess(processId, null);
+ }
+
+ private ProcessInformations describeProcess(String processId,
+ URL processDescriptionURL) throws ServiceException {
+ if (process.containsKey(processId)) {
+ return process.get(processId);
+ }
+
+ SClient4WPSSession wpsClient = null;
+ try {
+ wpsClient = createWPSClientSession();
+
+ logger.debug("Describe Process WPS URL: " + wpsProcessingServlet);
+ ProcessDescriptionType processDescription = null;
+ for (int k = 0; k <= 3; k++) {
+ try {
+ processDescription = wpsClient.getProcessDescription(
+ wpsProcessingServlet, processId);
+ } catch (Throwable e) {
+ logger.error("Error getProcessDescription for process "
+ + processId + " with WPS URL: "
+ + wpsProcessingServlet);
+ if (k == 3)
+ throw e;
+ }
+ if (processDescription != null)
+ break;
+ }
+
+ ProcessInformations processInformations = new ProcessInformations(
+ processDescription);
+
+ if (processDescriptionURL != null)
+ processDescription.set(XmlString.Factory
+ .parse(processDescriptionURL));
+
+ logger.debug("ProcessDescription: " + processDescription);
+
+ InputDescriptionType[] inputList = processDescription
+ .getDataInputs().getInputArray();
+ logger.debug("WPSClient->Fetching Inputs");
+ for (InputDescriptionType input : inputList) {
+ logger.debug("WPSClient->Input: " + input);
+ }
+
+ OutputDescriptionType[] outputList = processDescription
+ .getProcessOutputs().getOutputArray();
+ logger.debug("WPSClient->Fetching Outputs");
+ for (OutputDescriptionType output : outputList) {
+ logger.debug("WPSClient->Output: " + output);
+ }
+
+ processInformations.setInputs(inputList);
+ processInformations.setOutputs(outputList);
+
+ process.put(processId, processInformations);
+
+ return processInformations;
+ } catch (Throwable e) {
+ logger.error(e.getLocalizedMessage());
+ e.printStackTrace();
+ throw new ServiceException(e.getLocalizedMessage(), e);
+ } finally {
+ wpsClient.disconnect(wpsProcessingServlet);
+ }
+ }
+
+ private void requestCapability() throws ServiceException {
+ SClient4WPSSession wpsClient = null;
+ processesDescriptionType = null;
+ processesBriefs = null;
+
+ try {
+ wpsClient = createWPSClientSession();
+
+ wpsClient.connect(wpsProcessingServlet);
+
+ processesDescriptionType = wpsClient
+ .getAllProcessDescriptions(wpsProcessingServlet);
+
+ CapabilitiesDocument capabilitiesDocument = wpsClient
+ .getWPSCaps(wpsProcessingServlet);
+
+ processesBriefs = capabilitiesDocument.getCapabilities()
+ .getProcessOfferings().getProcessArray();
+ return;
+
+ } catch (Throwable e) {
+ logger.error("RequestCapability(): " + e.getLocalizedMessage());
+ e.printStackTrace();
+ throw new ServiceException(e.getLocalizedMessage(), e);
+ } finally {
+ if (wpsClient != null) {
+ wpsClient.disconnect(wpsProcessingServlet);
+ }
+ }
+
+ }
+
+ private String executeProcessAsync(ExecuteRequestBuilder executeBuilder,
+ ProcessDescriptionType processDescription) throws ServiceException {
+ SClient4WPSSession wpsClient = null;
+ try {
+ try {
+
+ OutputDescriptionType[] odts = processDescription
+ .getProcessOutputs().getOutputArray();
+ for (OutputDescriptionType odt : odts) {
+ // executeBuilder.setMimeTypeForOutput("text/xml",
+ // "result");
+ if (odt.isSetComplexOutput())
+ executeBuilder.setMimeTypeForOutput("text/xml", odt
+ .getIdentifier().getStringValue());
+ }
+ } catch (Exception e) {
+ logger.debug("Execute Process-> Warning, no xml structured objects will be provided: "
+ + e.getLocalizedMessage());
+ e.printStackTrace();
+ }
+ // executeBuilder.setSchemaForOutput("http://schemas.opengis.net/gml/3.1.1/base/feature.xsd",
+ // "result");
+
+ ExecuteDocument execute = executeBuilder.getExecute();
+ execute.getExecute().setService("WPS");
+ // System.out.println("RESPONSE FORM:"+execute.getExecute().getResponseForm());
+ wpsClient = createWPSClientSession();
+ wpsClient.connect(wpsProcessingServlet);
+ logger.debug("Sending: " + execute);
+ if (execute.getExecute().getResponseForm() != null) {
+ ResponseDocumentType documentType = execute.getExecute()
+ .getResponseForm().getResponseDocument();
+ documentType.setStoreExecuteResponse(true);
+ documentType.setStatus(true);
+ documentType.setLineage(false);
+ execute.getExecute().getResponseForm()
+ .setResponseDocument(documentType);
+ }
+ Object responseObject = wpsClient.execute(wpsProcessingServlet,
+ execute);
+ String processLocation = null;
+ Date creationData = null;
+ if (responseObject != null) {
+ if (responseObject instanceof ExecuteResponseDocumentImpl) {
+ ExecuteResponseDocumentImpl executeResponseDocumentImpl = ((ExecuteResponseDocumentImpl) responseObject);
+ processLocation = executeResponseDocumentImpl
+ .getExecuteResponse().getStatusLocation();
+ creationData = executeResponseDocumentImpl
+ .getExecuteResponse().getStatus().getCreationTime()
+ .getTime();
+ } else {
+ throw new ServiceException(
+ "Invalid response from service, "
+ + "response isn't instance of ExecuteResponseDocumentImpl, class is "
+ + responseObject.getClass());
+ }
+ } else {
+ throw new ServiceException("Invalid Response from service, "
+ + responseObject);
+ }
+ logger.debug("Retrieved: [ProcessLocation=" + processLocation
+ + ", CreationDate=" + creationData + "]");
+ return processLocation;
+
+ } catch (Throwable e) {
+ logger.error("ExecuteProcessAsync: " + e.getLocalizedMessage());
+ e.printStackTrace();
+ throw new ServiceException(e.getLocalizedMessage(), e);
+ } finally {
+ try {
+ if (wpsClient != null)
+ wpsClient.disconnect(wpsProcessingServlet);
+ } catch (Exception e) {
+ logger.debug("Problems in wps disconnect! "
+ + e.getLocalizedMessage());
+ }
+ }
+ }
+
+ private ProcessOutputs retrieveProcessResult(String processLocation)
+ throws ServiceException {
+ SClient4WPSSession wpsClient = null;
+ try {
+ logger.debug("RetrieveProcessResult: " + processLocation);
+ wpsClient = createWPSClientSession();
+ // wpsClient.connectForMonitoring(webProcessingService);
+ // wpsClient.connect(url)
+
+ Object responseObject = null;
+ if (processLocation != null && processLocation.length() > 0)
+ responseObject = wpsClient.executeViaGET(processLocation, "");
+ else
+ throw new ServiceException("Process Location is null!");
+
+ logger.debug("Response:\n" + responseObject);
+ return ((ExecuteResponseDocument) responseObject)
+ .getExecuteResponse().getProcessOutputs();
+
+ } catch (Throwable e) {
+ logger.debug("RetrieveProcessResult: " + e.getLocalizedMessage());
+ e.printStackTrace();
+ throw new ServiceException(e.getLocalizedMessage(), e);
+ } finally {
+ wpsClient.disconnect(wpsProcessingServlet);
+ }
+ }
+
+ private static int calculateBBDimensions(String bbstring) {
+ String[] bbinput = bbstring.split(",");
+ int dimcounter = 0;
+ try {
+ for (int i = 0; i < bbinput.length; i++) {
+ Double.parseDouble(bbinput[i]);
+ dimcounter++;
+ }
+ } catch (Exception e) {
+ logger.debug("Dimensions Count: " + dimcounter);
+ }
+ return dimcounter;
+ }
+
+ private static void addBoundingBoxInput(
+ org.n52.wps.client.ExecuteRequestBuilder executeBuilder,
+ String identifier, String BBstring) {
+
+ ExecuteDocument executor = executeBuilder.getExecute();
+ InputType input1 = executor.getExecute().getDataInputs().addNewInput();
+ input1.addNewIdentifier().setStringValue(identifier);
+
+ net.opengis.ows.x11.BoundingBoxType bbtype = input1.addNewData()
+ .addNewBoundingBoxData();
+
+ // bboxInput=46,102,47,103,urn:ogc:def:crs:EPSG:6.6:4326,2
+ String[] bbinput = BBstring.split(",");
+ int dimensions = calculateBBDimensions(BBstring);
+ List lc = new ArrayList();
+ for (int i = 0; i < dimensions / 2; i++) {
+ lc.add(bbinput[i]);
+ }
+ List uc = new ArrayList();
+ for (int i = dimensions / 2; i < dimensions; i++) {
+ uc.add(bbinput[i]);
+ }
+
+ bbtype.setLowerCorner(lc);
+ bbtype.setUpperCorner(uc);
+
+ // int crsidx = bbinput[dimensions].indexOf("crs:");
+ String crs = bbinput[dimensions];
+ /*
+ * if (crsidx>=0) crs = bbinput[dimensions].substring(crsidx+4);
+ */
+ bbtype.setCrs(crs);
+ bbtype.setDimensions(new BigInteger("" + dimensions / 2));
+
+ }
+
+ private static LinkedHashMap retrieveURLsFromWPSResponse(
+ ComplexDataType cdt) {
+ org.w3c.dom.Node node = cdt.getDomNode();
+ LinkedHashMap urls = new LinkedHashMap<>();
+ getURLFromXML(node, urls);
+ for (String key : urls.keySet()) {
+ logger.debug("ResponseWPS Map: " + key + "-->" + urls.get(key));
+ }
+ return urls;
+ }
+
+ /*
+ * private static String getExceptionText(String exceptionText) { try {
+ * String excText = "ExceptionText>"; int idx =
+ * exceptionText.indexOf(excText); if (idx >= 0) { String exception =
+ * exceptionText.substring(idx + excText.length()); exception =
+ * exception.substring(0, exception.indexOf("")); exception = exception
+ * .replace("<", "") .replace(">", "") .replace("/", " ") .replace("\\",
+ * " ") .replaceAll( "[\\]\\[!\"#$%&'\\(\\)*+/:;<=>?@\\^_`{\\|}~-]",
+ * "_").trim(); exception = exception.replaceAll("[ ]+", " "); if
+ * (exception.length() > 200) exception = exception.substring(0, 200) +
+ * "..."; return exception; } else return "Process error in WPS Execution";
+ * } catch (Exception e) { e.printStackTrace(); return
+ * "Backend error in WPS Execution"; } }
+ */
+
+ private static void getURLFromXML(org.w3c.dom.Node node,
+ ResponseWPS responseWPS) {
+ if (node == null)
+ return;
+
+
+ logger.debug("Node Name: " + node.getNodeName());
+ if (node.getNodeName() == null) {
+ return;
+ }
+
+ if (node.getFirstChild() != null) {
+ logger.debug("Node Value: " + node.getFirstChild().getNodeValue());
+ } else {
+ logger.debug("FirstChild is NULL");
+ return;
+ }
+
+
+ String text;
+ switch (node.getNodeName()) {
+ case "d4science:Data":
+ text = node.getFirstChild().getNodeValue();
+ responseWPS.setData(text);
+ break;
+ case "d4science:Description":
+ text = node.getFirstChild().getNodeValue();
+ responseWPS.setDescription(text);
+ break;
+ case "d4science:MimeType":
+ text = node.getFirstChild().getNodeValue();
+ responseWPS.setMimeType(text);
+ break;
+ default:
+ break;
+ }
+ /* logger.debug("ResponseWPS:"+responseWPS); */
+
+ }
+
+ private static void getURLFromXML(org.w3c.dom.Node node,
+ LinkedHashMap urls) {
+ if (node == null)
+ return;
+
+ logger.debug("Node Name: " + node.getNodeName());
+
+ if (node.getNodeName() == null) {
+ return;
+ }
+
+ ResponseWPS responseWPS = null;
+ NodeList listnodes = node.getChildNodes();
+ int nChildren = listnodes.getLength();
+
+ switch (node.getNodeName()) {
+ case "ogr:Result":
+ NamedNodeMap attrs = node.getAttributes();
+ Node n = attrs.getNamedItem("fid");
+ String key = n.getNodeValue();
+ responseWPS = new ResponseWPS();
+ urls.put(key, responseWPS);
+ if (nChildren == 0) {
+
+ } else {
+ for (int i = 0; i < nChildren; i++) {
+ getURLFromXML(listnodes.item(i), responseWPS);
+
+ }
+ }
+ break;
+ default:
+ if (nChildren == 0) {
+
+ } else {
+ for (int i = 0; i < nChildren; i++) {
+ getURLFromXML(listnodes.item(i), urls);
+
+ }
+ }
+ break;
+
+ }
+
+ /*
+ *
+ * NodeList listnodes = node.getChildNodes(); int nChildren =
+ * listnodes.getLength();
+ *
+ * if (nChildren == 0) { String text = node.getNodeValue(); if (text !=
+ * null && (text.startsWith("https:") || text.startsWith("http:") ||
+ * text.startsWith("ftp:") || text.startsWith("smp:") || text
+ * .startsWith("file:"))) urls.add(text.trim()); else if (text != null
+ * && text.trim().length() > 0) urls.add(text.trim()); } else { for (int
+ * i = 0; i < nChildren; i++) { List childrenurls =
+ * getURLFromXML(listnodes.item(i)); urls.addAll(childrenurls);
+ *
+ * } } return urls;
+ */
+ }
+
+ // TODO
+ @Override
+ public List getInputParameters(Operator operator)
+ throws ServiceException {
+ try {
+ logger.info("Parameters of algorithm " + operator.getId());
+
+ ProcessInformations processInformations;
+ try {
+ processInformations = describeProcess(operator.getId());
+ } catch (Throwable e) {
+ logger.error("GetParameters: " + e.getLocalizedMessage());
+ e.printStackTrace();
+ throw new ServiceException(e.getLocalizedMessage());
+ }
+
+ logger.debug("ProcessInformation: " + processInformations);
+
+ List parameters = new ArrayList<>();
+
+ Parameter inputParameter;
+ for (InputDescriptionType inputDesc : processInformations
+ .getInputs()) {
+ inputParameter = WPS2DM.convert2DMType(inputDesc);
+ logger.debug("InputParameter: " + inputParameter);
+ parameters.add(inputParameter);
+ }
+
+ logger.debug("Parameters: " + parameters);
+ return parameters;
+
+ } catch (Throwable e) {
+ logger.error(e.getLocalizedMessage());
+ e.printStackTrace();
+ throw new ServiceException(e.getLocalizedMessage());
+ }
+
+ }
+
+ @Override
+ public ComputationId startComputation(Operator operator)
+ throws ServiceException {
+ ProcessInformations processInformations;
+ try {
+ processInformations = describeProcess(operator.getId());
+ } catch (Throwable e) {
+ logger.error("GetParameters: " + e.getLocalizedMessage());
+ e.printStackTrace();
+ throw new ServiceException(e.getLocalizedMessage(), e);
+ }
+
+ LinkedHashMap inputParameters = new LinkedHashMap<>();
+
+ Parameter inputParameter;
+ for (InputDescriptionType inputDesc : processInformations.getInputs()) {
+ inputParameter = WPS2DM.convert2DMType(inputDesc);
+ logger.debug("InputParameter: " + inputParameter);
+ inputParameters.put(inputParameter.getName(), inputParameter);
+ }
+
+ List params = operator.getOperatorParameters();
+ Map userInputs = new LinkedHashMap<>();
+ for (Parameter parm : params) {
+ userInputs.put(parm.getName(), parm.getValue());
+ logger.debug("UserInputs[key=" + parm.getName() + ", value="
+ + parm.getValue() + "]");
+ }
+
+ LinkedHashMap equivalentRequestMap = new LinkedHashMap<>();
+ String processUrl = compute(processInformations, userInputs,
+ inputParameters, equivalentRequestMap);
+ logger.debug("Stated Computation ProcessLocation:" + processUrl);
+
+ int idIndex = processUrl.lastIndexOf("?id=");
+ String id;
+ if (idIndex > -1) {
+ id = processUrl.substring(idIndex + 4, processUrl.length());
+ } else {
+ logger.error("Invalid processLocation: " + processUrl);
+ throw new ServiceException("Invalid processLocation: " + processUrl);
+ }
+
+ String equivalentRequest = wpsProcessingServlet + "?"
+ + "request=Execute&service=WPS&Version=1.0.0&gcube-token="
+ + wpsToken + "&lang=en-US&Identifier=" + operator.getId()
+ + "&DataInputs=";
+
+ for (String key : equivalentRequestMap.keySet()) {
+ equivalentRequest = equivalentRequest + key + "="
+ + equivalentRequestMap.get(key) + ";";
+ }
+
+ ComputationId computationId = new ComputationId(id, processUrl,
+ operator.getId(), operator.getName(), equivalentRequest);
+ logger.debug("ComputationId: " + computationId);
+
+ runningProcess.put(computationId, processInformations);
+
+ return computationId;
+ }
+
+ private String compute(ProcessInformations processInformations,
+ Map userInputs,
+ Map inputParameters,
+ LinkedHashMap equivalentRequestMap)
+ throws ServiceException {
+ try {
+ // setup the inputs
+ org.n52.wps.client.ExecuteRequestBuilder executeBuilder = new org.n52.wps.client.ExecuteRequestBuilder(
+ processInformations.getProcessDescription());
+ for (InputDescriptionType input : processInformations.getInputs()) {
+ String value = userInputs.get(input.getIdentifier()
+ .getStringValue());
+ if (value != null && value.trim().length() > 0) {
+ if (input.isSetLiteralData()) {
+ logger.debug("Configuring Literal: "
+ + input.getIdentifier().getStringValue()
+ + " to: " + value);
+ equivalentRequestMap.put(input.getIdentifier()
+ .getStringValue(), value);
+ executeBuilder.addLiteralData(input.getIdentifier()
+ .getStringValue(), value);
+
+ } else if (input.isSetBoundingBoxData()) {
+ logger.debug("Configuring Bounding Box: "
+ + input.getIdentifier().getStringValue()
+ + " to: " + value);
+ equivalentRequestMap.put(input.getIdentifier()
+ .getStringValue(), value);
+ addBoundingBoxInput(executeBuilder, input
+ .getIdentifier().getStringValue(), value);
+
+ } else {
+ if (input.isSetComplexData()) {
+ logger.debug("Configuring Complex: "
+ + input.getIdentifier().getStringValue()
+ + " to: " + value);
+ SupportedComplexDataInputType complex = input
+ .getComplexData();
+ Parameter par = inputParameters.get(input
+ .getIdentifier().getStringValue());
+
+ String publicLink;
+ if (par instanceof TabularListParameter) {
+ // TabularListParameter tabularListParameter =
+ // ((TabularListParameter) par);
+ InputStream tablesStream = new ByteArrayInputStream(
+ value.getBytes());
+ publicLink = StorageUtil
+ .saveOnStorageInTemporalFile(tablesStream);
+ } else {
+ publicLink = value;
+ }
+ equivalentRequestMap.put(input.getIdentifier()
+ .getStringValue(), value);
+ executeBuilder.addComplexDataReference(input
+ .getIdentifier().getStringValue(),
+ publicLink, complex.getDefault()
+ .getFormat().getSchema(), complex
+ .getDefault().getFormat()
+ .getEncoding(), complex
+ .getDefault().getFormat()
+ .getMimeType());
+
+ } else {
+ logger.error("This input parameter type is not supported by client library: "
+ + input);
+ throw new ServiceException(
+ "This input parameter is not supported by client library: "
+ + input);
+ }
+
+ }
+ }
+ }
+
+ // Submit the execution
+ String statusLocation = executeProcessAsync(executeBuilder,
+ processInformations.getProcessDescription());
+ logger.debug("Starting Process: " + statusLocation);
+ return statusLocation;
+
+ } catch (Throwable e) {
+ logger.error(e.getLocalizedMessage());
+ e.printStackTrace();
+ throw new ServiceException(e.getLocalizedMessage(), e);
+ }
+ }
+
+ @Override
+ public ComputationStatus getComputationStatus(ComputationId computationId)
+ throws ServiceException {
+ SClient4WPSSession wpsClient = null;
+ try {
+ logger.debug("GetComputationStatus(): ComputationId="
+ + computationId);
+ wpsClient = createWPSClientSession();
+ wpsClient.connectForMonitoring(wpsProcessingServlet);
+
+ Object responseObject = null;
+ if (computationId == null || computationId.getUrlId() == null
+ || computationId.getUrlId().isEmpty()) {
+ throw new ServiceException("Process Location is null!");
+ } else {
+ ComputationStatus computationStatus = null;
+ try {
+
+ responseObject = wpsClient.executeViaGET(
+ computationId.getUrlId(), "");
+
+ logger.debug("ComputationStatus ResponseObject: "
+ + responseObject);
+
+ if (responseObject instanceof ExecuteResponseDocumentImpl) {
+ if (((ExecuteResponseDocumentImpl) responseObject)
+ .getExecuteResponse() == null) {
+ logger.debug("WPS FAILURE: ExecuteResponse is null");
+
+ computationStatus = new ComputationStatus(
+ Status.FAILED, 100f);
+
+ } else {
+ StatusType statusType = ((ExecuteResponseDocumentImpl) responseObject)
+ .getExecuteResponse().getStatus();
+ if (statusType == null) {
+ logger.debug("WPS FAILURE: Status Type is null");
+ computationStatus = null;
+ } else {
+
+ String failure = statusType.getProcessFailed() == null ? null
+ : statusType.getProcessFailed()
+ .getExceptionReport()
+ .toString();
+ if ((failure != null && !failure.isEmpty())) {
+ logger.debug("WPS FAILURE: " + failure);
+ computationStatus = new ComputationStatus(
+ new ServiceException(failure));
+ } else {
+ String paused = statusType
+ .getProcessPaused() == null ? null
+ : statusType.getProcessPaused()
+ .getStringValue();
+ if (paused != null && !paused.isEmpty()) {
+ logger.debug("WPS PAUSED: " + paused);
+ computationStatus = new ComputationStatus(
+ new ServiceException(paused));
+ } else {
+ String success = statusType
+ .getProcessSucceeded() == null ? null
+ : statusType
+ .getProcessSucceeded();
+
+ if (success != null
+ && !success.isEmpty()) {
+ logger.debug("WPS SUCCESS");
+ computationStatus = new ComputationStatus(
+ Status.COMPLETE, 100f);
+ } else {
+ String accepted = statusType
+ .getProcessAccepted() == null ? null
+ : statusType
+ .getProcessAccepted();
+ if (accepted != null
+ && !accepted.isEmpty()) {
+ logger.debug("WPS ACCEPTED");
+ computationStatus = new ComputationStatus(
+ Status.ACCEPTED, 0f);
+ } else {
+ int status = statusType
+ .getProcessStarted() == null ? -1
+ : statusType
+ .getProcessStarted()
+ .getPercentCompleted();
+
+ if (status >= 0) {
+ Float statusd = (float) status;
+ try {
+ statusd = Float
+ .parseFloat(statusType
+ .getProcessStarted()
+ .getStringValue());
+ } catch (Exception e) {
+ logger.debug(e
+ .getLocalizedMessage());
+ }
+ logger.debug("WPS STATUS:"
+ + statusd);
+ computationStatus = new ComputationStatus(
+ Status.RUNNING,
+ statusd);
+ } else {
+ if (status == -1) {
+ logger.debug("WPS STATUS: Computation cancelled, "
+ + statusType
+ .getProcessStarted());
+ computationStatus = new ComputationStatus(
+ Status.CANCELLED,
+ -1);
+
+ } else {
+
+ logger.debug("WPS STATUS: Not Started, "
+ + statusType
+ .getProcessStarted());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ logger.debug("ComputationStatus: " + computationStatus);
+ return computationStatus;
+ } else {
+ logger.error("Error in ResponceObject: "
+ + responseObject);
+ logger.error("WPS FAILURE: ");
+ computationStatus = new ComputationStatus(
+ Status.FAILED, 100f);
+ return computationStatus;
+ }
+ } catch (Throwable e) {
+ logger.error("WPS FAILURE: " + e.getLocalizedMessage());
+ e.printStackTrace();
+ computationStatus = new ComputationStatus(Status.FAILED,
+ 100f);
+ return computationStatus;
+
+ }
+ }
+
+ } catch (Throwable e) {
+ logger.error("MonitorProcess: " + e.getLocalizedMessage());
+ e.printStackTrace();
+ throw new ServiceException(e.getLocalizedMessage(), e);
+ } finally {
+ wpsClient.disconnect(wpsProcessingServlet);
+ }
+
+ }
+
+ @Override
+ public OutputData getOutputDataByComputationId(ComputationId computationId)
+ throws ServiceException {
+ LinkedHashMap resources = retrieveOutput(computationId);
+ MapResource mapResource = new MapResource("mapResource", "Resources",
+ "Resources", resources);
+ OutputData outputData = new OutputData(computationId, mapResource);
+
+ return outputData;
+ }
+
+ private LinkedHashMap retrieveOutput(
+ ComputationId computationId) throws ServiceException {
+ LinkedHashMap outputResource = new LinkedHashMap<>();
+ LinkedHashMap outputParameters = new LinkedHashMap<>();
+ ProcessInformations processInformations = runningProcess
+ .get(computationId);
+
+ Parameter outputParameter;
+ if (processInformations != null
+ && processInformations.getOutputs() != null) {
+ for (OutputDescriptionType outputDesc : processInformations
+ .getOutputs()) {
+ outputParameter = WPS2DM.convert2DMType(outputDesc);
+ logger.debug("OutputParameter: " + outputParameter);
+ outputParameters
+ .put(outputParameter.getName(), outputParameter);
+ }
+ }
+
+ retrieveProcessOutput(computationId.getUrlId(), outputParameters,
+ outputResource);
+
+ return outputResource;
+
+ }
+
+ private void retrieveProcessOutput(String processLocation,
+ Map outputParameters,
+ Map outputResource) throws ServiceException {
+ ProcessOutputs outs = retrieveProcessResult(processLocation);
+ logger.debug("Process Executed");
+ // retrieve the output objs
+ if (outs == null)
+ throw new ServiceException(
+ "Error during the execution of the WPS process: returned an empty document");
+ else {
+ OutputDataType[] outputData = outs.getOutputArray();
+
+ for (OutputDataType out : outputData) {
+ String outputID = out.getIdentifier().getStringValue();
+ String value = "";
+ if (out.getData().isSetLiteralData()) {
+ value = out.getData().getLiteralData().getStringValue();
+ Parameter paramLiteral = outputParameters.get(outputID);
+ if (paramLiteral != null) {
+ paramLiteral.setValue(value);
+ logger.debug("Assigning value: " + value
+ + " to output named: " + outputID);
+ Resource resource = new ObjectResource(outputID,
+ paramLiteral.getName(),
+ paramLiteral.getDescription(),
+ paramLiteral.getValue());
+ outputResource.put(outputID, resource);
+ }
+ } else {
+ if (out.getData().isSetComplexData()) {
+ if (out.getReference() != null) {
+ value = out.getReference().getHref();
+ Parameter paramComplexData = outputParameters
+ .get(outputID);
+ if (paramComplexData != null) {
+ paramComplexData.setValue(value);
+ logger.debug("Assigning value: " + value
+ + " to output named: " + outputID);
+ Resource resource = new ObjectResource(
+ outputID, paramComplexData.getName(),
+ paramComplexData.getDescription(),
+ paramComplexData.getValue());
+ outputResource.put(outputID, resource);
+ }
+ } else
+ // remove the element name, which is not useful
+ outputParameters.remove(outputID);
+
+ ComplexDataType cdt = out.getData().getComplexData();
+ LinkedHashMap urls = retrieveURLsFromWPSResponse(cdt);
+
+ for (String key : urls.keySet()) {
+ logger.debug("Adding OBJ:" + key);
+ ResponseWPS responseWPS = urls.get(key);
+ ObjectParameter objP = new ObjectParameter(key,
+ responseWPS.getDescription(),
+ String.class.getName(), " ");
+ objP.setValue(responseWPS.getData());
+ logger.debug("ObjectParameter: " + objP);
+ outputParameters.put(key, objP);
+ if (responseWPS != null
+ && responseWPS.getMimeType() != null) {
+ Resource resource;
+ switch (responseWPS.getMimeType()) {
+ case "image/bmp":
+ case "image/gif":
+ case "image/jpeg":
+ case "image/png":
+ resource = new ImageResource(key,
+ responseWPS.getDescription(),
+ responseWPS.getDescription(),
+ responseWPS.getData(),
+ responseWPS.getMimeType());
+ outputResource.put(key, resource);
+ break;
+ case "text/csv":
+ if (responseWPS.getData() != null
+ && !responseWPS.getData().isEmpty()) {
+ if (responseWPS.getData().startsWith(
+ "http:")
+ || responseWPS.getData()
+ .startsWith("https:")
+ || responseWPS.getData()
+ .startsWith("smp:")) {
+ resource = new FileResource(key,
+ responseWPS
+ .getDescription(),
+ responseWPS
+ .getDescription(),
+ responseWPS.getData(),
+ responseWPS.getMimeType());
+ outputResource.put(key, resource);
+ } else {
+ resource = new ObjectResource(key,
+ responseWPS
+ .getDescription(),
+ responseWPS
+ .getDescription(),
+ responseWPS.getData());
+ outputResource.put(key, resource);
+ }
+ } else {
+ resource = new ObjectResource(key,
+ responseWPS.getDescription(),
+ responseWPS.getDescription(),
+ responseWPS.getData());
+ outputResource.put(key, resource);
+ }
+
+ break;
+ default:
+ if (responseWPS.getData() != null
+ && !responseWPS.getData().isEmpty()) {
+ if (responseWPS.getData().startsWith(
+ "http:")
+ || responseWPS.getData()
+ .startsWith("https:")
+ || responseWPS.getData()
+ .startsWith("smp:")) {
+ resource = new FileResource(key,
+ responseWPS
+ .getDescription(),
+ responseWPS
+ .getDescription(),
+ responseWPS.getData(),
+ responseWPS.getMimeType());
+ outputResource.put(key, resource);
+ } else {
+ resource = new ObjectResource(key,
+ responseWPS
+ .getDescription(),
+ responseWPS
+ .getDescription(),
+ responseWPS.getData());
+ outputResource.put(key, resource);
+ }
+ } else {
+ resource = new ObjectResource(key,
+ responseWPS.getDescription(),
+ responseWPS.getDescription(),
+ responseWPS.getData());
+ outputResource.put(key, resource);
+ }
+ break;
+ }
+
+ }
+ }
+ } else {
+ value = out.getData().getLiteralData().getStringValue();
+
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public String cancelComputation(ComputationId computationId)
+ throws ServiceException {
+ SClient4WPSSession wpsClient = null;
+ try {
+ wpsClient = createWPSClientSession();
+
+ String result = wpsClient.cancelComputation(
+ wpsCancelComputationServlet, computationId.getId());
+
+ return result;
+
+ } catch (Throwable e) {
+ e.printStackTrace();
+ throw new ServiceException(e.getLocalizedMessage(), e);
+ } finally {
+ if (wpsClient != null) {
+ wpsClient.disconnect(wpsProcessingServlet);
+ }
+ }
+
+ }
+
+ public ComputationId resubmitComputation(
+ Map computationProperties) throws ServiceException {
+ ProcessInformations processInformations;
+ if (computationProperties == null || computationProperties.isEmpty()) {
+ throw new ServiceException("Invalid computation properties: "
+ + computationProperties);
+ }
+ try {
+ processInformations = describeProcess(computationProperties
+ .get("operator_id"));
+ } catch (Throwable e) {
+ logger.error("GetParameters: " + e.getLocalizedMessage());
+ e.printStackTrace();
+ throw new ServiceException(e.getLocalizedMessage(), e);
+ }
+
+ LinkedHashMap inputParameters = new LinkedHashMap<>();
+
+ Parameter inputParameter;
+ for (InputDescriptionType inputDesc : processInformations.getInputs()) {
+ inputParameter = WPS2DM.convert2DMType(inputDesc);
+ logger.debug("InputParameter: " + inputParameter);
+ inputParameters.put(inputParameter.getName(), inputParameter);
+ }
+
+ Map userInputs = new LinkedHashMap<>();
+ for (String key : computationProperties.keySet()) {
+ if (key.startsWith("input")) {
+ int inputSeparatorIndex = key.indexOf("_");
+ String inputKey = key.substring(inputSeparatorIndex + 1);
+ if (inputKey.compareToIgnoreCase("user.name") != 0
+ && inputKey.compareToIgnoreCase("scope") != 0) {
+ userInputs.put(inputKey, computationProperties.get(key));
+ logger.debug("UserInputs[key=" + inputKey + ", value="
+ + computationProperties.get(key) + "]");
+ }
+
+ }
+ }
+
+ if (userInputs.isEmpty()) {
+ logger.error("Attention no inputs parameters retrieved for this computation: "
+ + computationProperties);
+ throw new ServiceException(
+ "Attention no inputs parameters retrieved for this computation: "
+ + computationProperties);
+ }
+
+ LinkedHashMap equivalentRequestMap = new LinkedHashMap<>();
+ String processUrl = compute(processInformations, userInputs,
+ inputParameters, equivalentRequestMap);
+ logger.debug("Stated Computation ProcessLocation:" + processUrl);
+
+ int idIndex = processUrl.lastIndexOf("?id=");
+ String id;
+ if (idIndex > -1) {
+ id = processUrl.substring(idIndex + 4, processUrl.length());
+ } else {
+ logger.error("Invalid processLocation: " + processUrl);
+ throw new ServiceException("Invalid processLocation: " + processUrl);
+ }
+
+ String equivalentRequest = wpsProcessingServlet + "?"
+ + "request=Execute&service=WPS&Version=1.0.0&gcube-token="
+ + wpsToken + "&lang=en-US&Identifier="
+ + computationProperties.get("operator_id") + "&DataInputs=";
+
+ for (String key : equivalentRequestMap.keySet()) {
+ equivalentRequest = equivalentRequest + key + "="
+ + equivalentRequestMap.get(key) + ";";
+ }
+
+ ComputationId computationId = new ComputationId(id, processUrl,
+ computationProperties.get("operator_id"),
+ computationProperties.get("operator_name"), equivalentRequest);
+ logger.debug("ComputationId: " + computationId);
+
+ runningProcess.put(computationId, processInformations);
+
+ return computationId;
+ }
+
+ @Override
+ public ComputationData getComputationDataByComputationProperties(
+ Map computationProperties) throws ServiceException {
+ try {
+ if (computationProperties == null
+ || computationProperties.isEmpty()) {
+ throw new Exception("Invalid computation properties: "
+ + computationProperties);
+ }
+
+ String compId = computationProperties.get("computation_id");
+
+ String operatorId = computationProperties.get("operator_id");
+ String operatorName = computationProperties.get("operator_name");
+ String operatorDescritpion = computationProperties
+ .get("operator_description");
+ String vre = computationProperties.get("VRE");
+ String startDate = computationProperties.get("start_date");
+ String endDate = computationProperties.get("end_date");
+ String status = computationProperties.get("status");
+ String executionType = computationProperties.get("execution_type");
+
+ ComputationId computationId = new ComputationId();
+ computationId.setId(compId);
+ computationId.setOperatorId(operatorId);
+ computationId.setOperatorName(operatorName);
+
+ ArrayList inputParametersAsProperties = new ArrayList<>();
+ ArrayList outputParametersAsProperties = new ArrayList<>();
+
+ for (String key : computationProperties.keySet()) {
+ if (key != null) {
+ if (key.startsWith("input")) {
+ int inputSeparatorIndex = key.indexOf("_");
+ String inputKey = key
+ .substring(inputSeparatorIndex + 1);
+ if (inputKey.compareToIgnoreCase("user.name") != 0
+ && inputKey.compareToIgnoreCase("scope") != 0) {
+ String inputOrder = key.substring(5,
+ inputSeparatorIndex);
+ Integer order;
+ try {
+ order = Integer.parseInt(inputOrder);
+ } catch (NumberFormatException e) {
+ order = 0;
+ }
+ ComputationItemPropertiesValue inputProps = new ComputationItemPropertiesValue(
+ order, inputKey,
+ computationProperties.get(key));
+ inputParametersAsProperties.add(inputProps);
+
+ }
+
+ } else {
+ if (key.startsWith("output")) {
+ int outputSeparatorIndex = key.indexOf("_");
+ String outputKey = key
+ .substring(outputSeparatorIndex + 1);
+
+ String outputOrder = key.substring(6,
+ outputSeparatorIndex);
+ Integer order;
+ try {
+ order = Integer.parseInt(outputOrder);
+ } catch (NumberFormatException e) {
+ order = 0;
+ }
+ ComputationItemPropertiesValue outputProps = new ComputationItemPropertiesValue(
+ order, outputKey,
+ computationProperties.get(key));
+
+ outputParametersAsProperties.add(outputProps);
+
+ }
+
+ }
+
+ }
+ }
+
+ Collections.sort(inputParametersAsProperties);
+ Collections.sort(outputParametersAsProperties);
+
+ ComputationValueBuilder computationValueBuilder = new ComputationValueBuilder(
+ inputParametersAsProperties);
+ LinkedHashMap inputParameters = computationValueBuilder
+ .create();
+ computationValueBuilder = new ComputationValueBuilder(
+ outputParametersAsProperties);
+ LinkedHashMap outputParameters = computationValueBuilder
+ .create();
+
+ logger.debug("inputParameters: " + inputParameters);
+ logger.debug("outputParameters: " + outputParameters);
+
+ ComputationData computationData = new ComputationData(
+ computationId, inputParameters, outputParameters,
+ operatorDescritpion, startDate, endDate, status,
+ executionType, vre);
+
+ logger.debug("ComputationData: " + computationData);
+ return computationData;
+
+ } catch (ServiceException e) {
+ logger.error("Error in getComutationDataByComputationProperties: "
+ + e.getLocalizedMessage());
+ e.printStackTrace();
+ throw e;
+ } catch (Throwable e) {
+ logger.error("Error in getComutationDataByComputationProperties: "
+ + e.getLocalizedMessage());
+ e.printStackTrace();
+ throw new ServiceException(e.getLocalizedMessage(), e);
+
+ }
+
+ }
+
+ @Override
+ public String toString() {
+ return "DataMiner WPS Client";
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/SClient4WPSBuilder.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/SClient4WPSBuilder.java
new file mode 100644
index 0000000..b28107e
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/SClient4WPSBuilder.java
@@ -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: g.panichi@isti.cnr.it
+ *
+ */
+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);
+ }
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/SClientBuilder.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/SClientBuilder.java
new file mode 100644
index 0000000..11bc458
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/SClientBuilder.java
@@ -0,0 +1,24 @@
+package org.gcube.data.analysis.dataminermanagercl.server.dmservice;
+
+/**
+ * Abstract class for build client of service
+ *
+ * @author "Giancarlo Panichi" email: g.panichi@isti.cnr.it
+ *
+ */
+public abstract class SClientBuilder {
+ protected SClientSpec sClientSpec;
+
+ public SClientSpec getSClientSpec() {
+ return sClientSpec;
+ }
+
+ public void createSpec() {
+ sClientSpec = new SClientSpec();
+
+ }
+
+ public abstract void buildSClient() throws Exception;
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/SClientDirector.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/SClientDirector.java
new file mode 100644
index 0000000..c919c2d
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/SClientDirector.java
@@ -0,0 +1,30 @@
+package org.gcube.data.analysis.dataminermanagercl.server.dmservice;
+
+
+
+/**
+ * Director
+ *
+ * @author "Giancarlo Panichi"
+ * email: g.panichi@isti.cnr.it
+ *
+ */
+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();
+
+ }
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/SClientSpec.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/SClientSpec.java
new file mode 100644
index 0000000..aec1b62
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/SClientSpec.java
@@ -0,0 +1,21 @@
+package org.gcube.data.analysis.dataminermanagercl.server.dmservice;
+
+/**
+ * Specification
+ *
+ * @author "Giancarlo Panichi" email: g.panichi@isti.cnr.it
+ *
+ */
+public class SClientSpec {
+ private SClient sClient;
+
+ public SClient getSClient() {
+ return sClient;
+ }
+
+ public void setSClient(SClient sClient) {
+ this.sClient = sClient;
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/wps/DClientDescribeProcessRequest.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/wps/DClientDescribeProcessRequest.java
new file mode 100644
index 0000000..71f0eaa
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/wps/DClientDescribeProcessRequest.java
@@ -0,0 +1,36 @@
+package org.gcube.data.analysis.dataminermanagercl.server.dmservice.wps;
+
+import org.n52.wps.client.AbstractClientGETRequest;
+
+/**
+ *
+ * @author Giancarlo Panichi
+ * email: g.panichi@isti.cnr.it
+ *
+ */
+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;
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/wps/ProcessInformations.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/wps/ProcessInformations.java
new file mode 100644
index 0000000..a9674a7
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/wps/ProcessInformations.java
@@ -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: g.panichi@isti.cnr.it
+ *
+ */
+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) + "]";
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/wps/ResponseWPS.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/wps/ResponseWPS.java
new file mode 100644
index 0000000..33d35cc
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/wps/ResponseWPS.java
@@ -0,0 +1,58 @@
+package org.gcube.data.analysis.dataminermanagercl.server.dmservice.wps;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author Giancarlo Panichi
+ * email: g.panichi@isti.cnr.it
+ *
+ */
+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 + "]";
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/wps/SClient4WPSSession.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/wps/SClient4WPSSession.java
new file mode 100644
index 0000000..8c01db7
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/wps/SClient4WPSSession.java
@@ -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: g.panichi@isti.cnr.it
+ *
+ */
+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 loggedServices;
+ private XmlOptions options = null;
+
+ // a Map of
+ public HashMap 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();
+ processDescriptions = new HashMap();
+ }
+
+ /**
+ * 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 getLoggedServices() {
+ if (loggedServices != null && loggedServices.keySet() != null) {
+ return new ArrayList(loggedServices.keySet());
+ } else {
+ return new ArrayList();
+ }
+ }
+
+ /**
+ * 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 lines = new ArrayList<>();
+ lines.add("");
+ 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("");
+ 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 retrievesSingleDescription(InputStream is) throws WPSClientException {
+ try {
+ BufferedReader br = new BufferedReader(new InputStreamReader(is));
+
+ List lines = new ArrayList<>();
+ String line = null;
+ boolean elementProcessDescriptionsFound = false;
+ boolean elementProcessDescriptionsClosureFound = false;
+
+ while ((line = br.readLine()) != null) {
+ if (elementProcessDescriptionsFound) {
+ if (elementProcessDescriptionsClosureFound) {
+ if (line.contains("")) {
+ 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("");
+ 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);
+ }
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/wps/WPS2DM.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/wps/WPS2DM.java
new file mode 100644
index 0000000..c0b852b
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/wps/WPS2DM.java
@@ -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 supportedMimeTypes = new ArrayList();
+
+ // 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(), 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 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;
+
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/wps/computationsvalue/ComputationValueBuilder.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/wps/computationsvalue/ComputationValueBuilder.java
new file mode 100644
index 0000000..751374b
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/dmservice/wps/computationsvalue/ComputationValueBuilder.java
@@ -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: g.panichi@isti.cnr.it
+ *
+ */
+public class ComputationValueBuilder {
+ private static Logger logger = LoggerFactory
+ .getLogger(ComputationValueBuilder.class);
+
+ private ArrayList valueParameters;
+ private LinkedHashMap computationsValueParameters;
+
+ public ComputationValueBuilder(
+ ArrayList valueParameters) {
+ this.valueParameters = valueParameters;
+ }
+
+ /**
+ *
+ */
+ public LinkedHashMap create() {
+ computationsValueParameters = new LinkedHashMap();
+ 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 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> headerFields = conn.getHeaderFields();
+ boolean found = false;
+ for (String key : headerFields.keySet()) {
+ List 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;
+ }
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/is/InformationSystemUtils.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/is/InformationSystemUtils.java
new file mode 100644
index 0000000..e8846ed
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/is/InformationSystemUtils.java
@@ -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: g.panichi@isti.cnr.it
+ *
+ */
+public class InformationSystemUtils {
+
+ private static Logger logger = LoggerFactory
+ .getLogger(InformationSystemUtils.class);
+
+ public static List retrieveServiceAddress(String category,
+ String name, String scope) throws Exception {
+ try {
+
+ if (scope == null || scope.length() == 0)
+ return new ArrayList();
+
+ 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 client = ICFactory.client();
+ List 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;
+ }
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/monitor/DMMonitor.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/monitor/DMMonitor.java
new file mode 100644
index 0000000..6d3bfae
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/monitor/DMMonitor.java
@@ -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: g.panichi@isti.cnr.it
+ *
+ */
+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 listeners = new ArrayList();
+ 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 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;
+
+ }
+
+
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/monitor/DMMonitorListener.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/monitor/DMMonitorListener.java
new file mode 100644
index 0000000..6cd1417
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/monitor/DMMonitorListener.java
@@ -0,0 +1,48 @@
+package org.gcube.data.analysis.dataminermanagercl.server.monitor;
+
+/**
+ * Defines a listener for operation progress.
+ *
+ * @author "Giancarlo Panichi"
+ * g.panichi@isti.cnr.it
+ *
+ */
+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);
+
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/monitor/DMMonitorTask.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/monitor/DMMonitorTask.java
new file mode 100644
index 0000000..5b074d8
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/monitor/DMMonitorTask.java
@@ -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" g.panichi@isti.cnr.it
+ *
+ */
+public class DMMonitorTask extends TimerTask {
+ private static Logger logger = LoggerFactory.getLogger(DMMonitorTask.class);
+ private ArrayList listeners;
+ private ComputationId computationId;
+ private SClient sClient;
+ private DMMonitor dmMonitor;
+
+ public DMMonitorTask(DMMonitor dmMonitor, ComputationId computationId, SClient sClient,
+ ArrayList 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());
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/storage/StorageUtil.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/storage/StorageUtil.java
new file mode 100644
index 0000000..2462d1c
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/storage/StorageUtil.java
@@ -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: g.panichi@isti.cnr.it
+ *
+ */
+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);
+ }
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/util/ServiceCredential.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/util/ServiceCredential.java
new file mode 100644
index 0000000..b9f79d9
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/server/util/ServiceCredential.java
@@ -0,0 +1,65 @@
+package org.gcube.data.analysis.dataminermanagercl.server.util;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author Giancarlo Panichi email: g.panichi@isti.cnr.it
+ *
+ */
+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 + "]";
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/Constants.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/Constants.java
new file mode 100644
index 0000000..4c750e3
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/Constants.java
@@ -0,0 +1,36 @@
+package org.gcube.data.analysis.dataminermanagercl.shared;
+
+/**
+ *
+ * @author Giancarlo Panichi
+ * email: g.panichi@isti.cnr.it
+ *
+ */
+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";
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/StringUtil.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/StringUtil.java
new file mode 100644
index 0000000..5846f8d
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/StringUtil.java
@@ -0,0 +1,36 @@
+/**
+ *
+ */
+package org.gcube.data.analysis.dataminermanagercl.shared;
+
+/**
+ *
+ * @author Giancarlo Panichi
+ * email: g.panichi@isti.cnr.it
+ *
+ */
+public class StringUtil {
+
+ public static String getCapitalWords(String string) {
+ String ris = "";
+
+ boolean precUnderscore = true;
+ for (int i=0; ig.panichi@isti.cnr.it
+ *
+ */
+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 + "]";
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/OutputData.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/OutputData.java
new file mode 100644
index 0000000..220c4fb
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/OutputData.java
@@ -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: g.panichi@isti.cnr.it
+ *
+ */
+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 + "]";
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/TableItemSimple.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/TableItemSimple.java
new file mode 100644
index 0000000..d716f77
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/TableItemSimple.java
@@ -0,0 +1,136 @@
+package org.gcube.data.analysis.dataminermanagercl.shared.data;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+
+
+/**
+ *
+ * @author Giancarlo Panichi
+ * email: g.panichi@isti.cnr.it
+ *
+ */
+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 columns;
+
+ /**
+ *
+ */
+ public TableItemSimple() {
+ super();
+ columns = new ArrayList();
+ }
+
+ /**
+ * @param name
+ * @param description
+ * @param type
+ */
+ public TableItemSimple(String id, String name, String description,
+ String type) {
+ super();
+ columns = new ArrayList();
+ 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();
+ 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 getColumns() {
+ return columns;
+ }
+
+ public void setColumns(ArrayList columns) {
+ this.columns = columns;
+ }
+
+ @Override
+ public String toString() {
+ return "TableItemSimple [id=" + id + ", name=" + name
+ + ", description=" + description + ", type=" + type
+ + ", columns=" + columns + "]";
+ }
+
+
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/computations/ComputationData.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/computations/ComputationData.java
new file mode 100644
index 0000000..edb4ddf
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/computations/ComputationData.java
@@ -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: g.panichi@isti.cnr.it
+ *
+ */
+public class ComputationData implements Serializable {
+
+ private static final long serialVersionUID = -3039151542008171640L;
+ private ComputationId computationId;
+ private LinkedHashMap inputParameters;
+ private LinkedHashMap 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 inputParameters,
+ LinkedHashMap 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 getInputParameters() {
+ return inputParameters;
+ }
+
+ public void setInputParameters(LinkedHashMap inputParameters) {
+ this.inputParameters = inputParameters;
+ }
+
+ public LinkedHashMap getOutputParameters() {
+ return outputParameters;
+ }
+
+ public void setOutputParameters(
+ LinkedHashMap 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 + "]";
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/computations/ComputationId.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/computations/ComputationId.java
new file mode 100644
index 0000000..2563b43
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/computations/ComputationId.java
@@ -0,0 +1,81 @@
+package org.gcube.data.analysis.dataminermanagercl.shared.data.computations;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author Giancarlo Panichi email: g.panichi@isti.cnr.it
+ *
+ */
+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 + "]";
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/computations/ComputationItemPropertiesValue.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/computations/ComputationItemPropertiesValue.java
new file mode 100644
index 0000000..cc1615c
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/computations/ComputationItemPropertiesValue.java
@@ -0,0 +1,66 @@
+package org.gcube.data.analysis.dataminermanagercl.shared.data.computations;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author Giancarlo Panichi email: g.panichi@isti.cnr.it
+ *
+ */
+public class ComputationItemPropertiesValue implements Serializable,
+ Comparable {
+
+ 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 + "]";
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/computations/ComputationValue.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/computations/ComputationValue.java
new file mode 100644
index 0000000..c944a47
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/computations/ComputationValue.java
@@ -0,0 +1,60 @@
+package org.gcube.data.analysis.dataminermanagercl.shared.data.computations;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author Giancarlo Panichi email: g.panichi@isti.cnr.it
+ *
+ */
+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 + "]";
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/computations/ComputationValueFile.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/computations/ComputationValueFile.java
new file mode 100644
index 0000000..b7a8629
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/computations/ComputationValueFile.java
@@ -0,0 +1,49 @@
+package org.gcube.data.analysis.dataminermanagercl.shared.data.computations;
+
+/**
+ *
+ * @author Giancarlo Panichi email: g.panichi@isti.cnr.it
+ *
+ */
+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 + "]";
+ }
+
+
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/computations/ComputationValueFileList.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/computations/ComputationValueFileList.java
new file mode 100644
index 0000000..f5fbd45
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/computations/ComputationValueFileList.java
@@ -0,0 +1,55 @@
+package org.gcube.data.analysis.dataminermanagercl.shared.data.computations;
+
+import java.util.ArrayList;
+
+/**
+ *
+ * @author Giancarlo Panichi email: g.panichi@isti.cnr.it
+ *
+ */
+public class ComputationValueFileList extends ComputationValue {
+ private static final long serialVersionUID = -5845606225432949795L;
+
+ private ArrayList fileList;
+ private String separator;
+
+ public ComputationValueFileList() {
+ super(ComputationValueType.FileList);
+ }
+
+ public ComputationValueFileList(ArrayList 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 getFileList() {
+ return fileList;
+ }
+
+ public void setFileList(ArrayList 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 + "]";
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/computations/ComputationValueImage.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/computations/ComputationValueImage.java
new file mode 100644
index 0000000..026b4eb
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/computations/ComputationValueImage.java
@@ -0,0 +1,47 @@
+package org.gcube.data.analysis.dataminermanagercl.shared.data.computations;
+
+/**
+ *
+ * @author Giancarlo Panichi email: g.panichi@isti.cnr.it
+ *
+ */
+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 + "]";
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/computations/ComputationValueType.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/computations/ComputationValueType.java
new file mode 100644
index 0000000..5095d5a
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/computations/ComputationValueType.java
@@ -0,0 +1,11 @@
+package org.gcube.data.analysis.dataminermanagercl.shared.data.computations;
+
+/**
+ *
+ * @author Giancarlo Panichi
+ * email: g.panichi@isti.cnr.it
+ *
+ */
+public enum ComputationValueType {
+ FileList, File, Image, String;
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/output/FileResource.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/output/FileResource.java
new file mode 100644
index 0000000..de30817
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/output/FileResource.java
@@ -0,0 +1,83 @@
+/**
+ *
+ */
+package org.gcube.data.analysis.dataminermanagercl.shared.data.output;
+
+/**
+ *
+ * @author Giancarlo Panichi email: g.panichi@isti.cnr.it
+ *
+ */
+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() + "]";
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/output/ImageResource.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/output/ImageResource.java
new file mode 100644
index 0000000..4bb6058
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/output/ImageResource.java
@@ -0,0 +1,75 @@
+/**
+ *
+ */
+package org.gcube.data.analysis.dataminermanagercl.shared.data.output;
+
+/**
+ *
+ * @author Giancarlo Panichi email: g.panichi@isti.cnr.it
+ *
+ */
+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() + "]";
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/output/MapResource.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/output/MapResource.java
new file mode 100644
index 0000000..8d86b38
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/output/MapResource.java
@@ -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: g.panichi@isti.cnr.it
+ *
+ */
+public class MapResource extends Resource {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8772836076910728324L;
+ private LinkedHashMap map;
+
+ /**
+ *
+ */
+ public MapResource() {
+ super();
+ this.setResourceType(ResourceType.MAP);
+ }
+
+ public MapResource(String resourceId, String name, String description,
+ LinkedHashMap map) {
+ super(resourceId, name, description, ResourceType.MAP);
+ this.map = map;
+ }
+
+ public Map getMap() {
+ return map;
+ }
+
+ public void setMap(LinkedHashMap map) {
+ this.map = map;
+ }
+
+ @Override
+ public String toString() {
+ return "MapResource [map=" + map + ", getResourceId()="
+ + getResourceId() + ", getName()=" + getName()
+ + ", getDescription()=" + getDescription()
+ + ", getResourceType()=" + getResourceType() + "]";
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/output/ObjectResource.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/output/ObjectResource.java
new file mode 100644
index 0000000..a7f9b11
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/output/ObjectResource.java
@@ -0,0 +1,61 @@
+/**
+ *
+ */
+package org.gcube.data.analysis.dataminermanagercl.shared.data.output;
+
+
+/**
+ *
+ * @author Giancarlo Panichi
+ * email: g.panichi@isti.cnr.it
+ *
+ */
+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() + "]";
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/output/Resource.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/output/Resource.java
new file mode 100644
index 0000000..4fdfc53
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/output/Resource.java
@@ -0,0 +1,142 @@
+/**
+ *
+ */
+package org.gcube.data.analysis.dataminermanagercl.shared.data.output;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author Giancarlo Panichi
+ * email: g.panichi@isti.cnr.it
+ *
+ */
+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 + "]";
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/output/TableResource.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/output/TableResource.java
new file mode 100644
index 0000000..23405ac
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/data/output/TableResource.java
@@ -0,0 +1,54 @@
+/**
+ *
+ */
+package org.gcube.data.analysis.dataminermanagercl.shared.data.output;
+
+
+
+/**
+ *
+ * @author Giancarlo Panichi
+ * email: g.panichi@isti.cnr.it
+ *
+ */
+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() + "]";
+ }
+
+
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/exception/ServiceException.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/exception/ServiceException.java
new file mode 100644
index 0000000..c2eb29e
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/exception/ServiceException.java
@@ -0,0 +1,38 @@
+/**
+ *
+ */
+package org.gcube.data.analysis.dataminermanagercl.shared.exception;
+
+/**
+ *
+ * @author "Giancarlo Panichi"
+ * g.panichi@isti.cnr.it
+ *
+ */
+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);
+ }
+
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/ColumnListParameter.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/ColumnListParameter.java
new file mode 100644
index 0000000..822c643
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/ColumnListParameter.java
@@ -0,0 +1,82 @@
+/**
+ *
+ */
+package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
+
+
+
+/**
+ *
+ * @author Giancarlo Panichi email: g.panichi@isti.cnr.it
+ *
+ */
+public class ColumnListParameter extends Parameter {
+
+ private static final long serialVersionUID = -6743494426144267089L;
+ private String referredTabularParameterName;
+ // private List columnNames = new ArrayList();
+ 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
+ + "]";
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/ColumnParameter.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/ColumnParameter.java
new file mode 100644
index 0000000..423e0bb
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/ColumnParameter.java
@@ -0,0 +1,93 @@
+/**
+ *
+ */
+package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
+
+
+/**
+ *
+ * @author Giancarlo Panichi email: g.panichi@isti.cnr.it
+ *
+ */
+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
+ + "]";
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/DateParameter.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/DateParameter.java
new file mode 100644
index 0000000..be20f36
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/DateParameter.java
@@ -0,0 +1,72 @@
+/**
+ *
+ */
+package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
+
+
+/**
+ *
+ * @author Giancarlo Panichi email: g.panichi@isti.cnr.it
+ *
+ */
+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 + "]";
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/EnumParameter.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/EnumParameter.java
new file mode 100644
index 0000000..bb0c0c7
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/EnumParameter.java
@@ -0,0 +1,102 @@
+/**
+ *
+ */
+package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *
+ * @author Giancarlo Panichi
+ * email: g.panichi@isti.cnr.it
+ *
+ */
+public class EnumParameter extends Parameter {
+
+ private static final long serialVersionUID = 1673874854501249519L;
+ private List values = new ArrayList();
+ 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 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 values) {
+ this.values = values;
+ }
+
+ /**
+ * @return the values
+ */
+ public List 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
+ + "]";
+ }
+
+
+
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/FileParameter.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/FileParameter.java
new file mode 100644
index 0000000..93bc6b5
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/FileParameter.java
@@ -0,0 +1,86 @@
+/**
+ *
+ */
+package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
+
+import java.util.ArrayList;
+
+
+/**
+ *
+ * @author Giancarlo Panichi
+ * email: g.panichi@isti.cnr.it
+ *
+ */
+public class FileParameter extends Parameter {
+
+ private static final long serialVersionUID = -2967577990287112937L;
+ private String value;
+ private String defaultMimeType;
+ private ArrayList 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 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 getSupportedMimeTypes() {
+ return supportedMimeTypes;
+ }
+
+ public void setSupportedMimeTypes(ArrayList 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 + "]";
+ }
+
+
+
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/ListParameter.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/ListParameter.java
new file mode 100644
index 0000000..dec7c43
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/ListParameter.java
@@ -0,0 +1,83 @@
+/**
+ *
+ */
+package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
+
+
+/**
+ *
+ * @author Giancarlo Panichi email: g.panichi@isti.cnr.it
+ *
+ */
+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
+ + "]";
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/ObjectParameter.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/ObjectParameter.java
new file mode 100644
index 0000000..5e2a12f
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/ObjectParameter.java
@@ -0,0 +1,90 @@
+
+package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
+
+
+/**
+ *
+ * @author Giancarlo Panichi
+ * email: g.panichi@isti.cnr.it
+ *
+ */
+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
+ + "]";
+ }
+
+
+
+
+
+
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/Parameter.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/Parameter.java
new file mode 100644
index 0000000..055e151
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/Parameter.java
@@ -0,0 +1,94 @@
+/**
+ *
+ */
+package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author Giancarlo Panichi email: g.panichi@isti.cnr.it
+ *
+ */
+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 + "]";
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/ParameterType.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/ParameterType.java
new file mode 100644
index 0000000..8925d84
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/ParameterType.java
@@ -0,0 +1,11 @@
+package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
+
+/**
+ *
+ * @author Giancarlo Panichi email: g.panichi@isti.cnr.it
+ *
+ */
+public enum ParameterType {
+ OBJECT, TABULAR, FILE, ENUM, LIST, COLUMN, COLUMN_LIST, TABULAR_LIST, WKT, DATE, TIME;
+}
\ No newline at end of file
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/TabularListParameter.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/TabularListParameter.java
new file mode 100644
index 0000000..219b1ad
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/TabularListParameter.java
@@ -0,0 +1,110 @@
+/**
+ *
+ */
+package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
+
+import java.util.ArrayList;
+
+/**
+ *
+ * @author Giancarlo Panichi
+ * email: g.panichi@isti.cnr.it
+ *
+ */
+public class TabularListParameter extends Parameter {
+
+ private static final long serialVersionUID = -1786477950530892502L;
+ private String value;
+ private String separator;
+ private ArrayList templates = new ArrayList();
+ private String defaultMimeType;
+ private ArrayList supportedMimeTypes;
+
+ // private List tableNames = new ArrayList();
+
+ public TabularListParameter() {
+ super();
+ this.typology = ParameterType.TABULAR_LIST;
+ }
+
+ /**
+ * @param defaultValue
+ * @param value
+ */
+ public TabularListParameter(String name, String description,
+ String separator, String defaultMimeType,
+ ArrayList 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 templates) {
+ this.templates = templates;
+ }
+
+ /**
+ * @return the templates
+ */
+ public ArrayList 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 getSupportedMimeTypes() {
+ return supportedMimeTypes;
+ }
+
+ public void setSupportedMimeTypes(ArrayList 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 + "]";
+ }
+
+
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/TabularParameter.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/TabularParameter.java
new file mode 100644
index 0000000..9d57ccc
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/TabularParameter.java
@@ -0,0 +1,113 @@
+/**
+ *
+ */
+package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
+
+import java.util.ArrayList;
+
+/**
+ *
+ * @author Giancarlo Panichi email: g.panichi@isti.cnr.it
+ *
+ */
+public class TabularParameter extends Parameter {
+
+ private static final long serialVersionUID = 8038591467145151553L;
+ private String tableName;
+ private ArrayList templates = new ArrayList();
+ private String defaultMimeType;
+ private ArrayList 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 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 templates, String defaultMimeType,
+ ArrayList 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 getTemplates() {
+ return templates;
+ }
+
+ public void setTemplates(ArrayList 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 getSupportedMimeTypes() {
+ return supportedMimeTypes;
+ }
+
+ public void setSupportedMimeTypes(ArrayList supportedMimeTypes) {
+ this.supportedMimeTypes = supportedMimeTypes;
+ }
+
+ @Override
+ public String toString() {
+ return "TabularParameter [tableName=" + tableName + ", templates="
+ + templates + ", defaultMimeType=" + defaultMimeType
+ + ", supportedMimeTypes=" + supportedMimeTypes + ", name="
+ + name + ", description=" + description + ", typology="
+ + typology + "]";
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/TimeParameter.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/TimeParameter.java
new file mode 100644
index 0000000..f160ae5
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/TimeParameter.java
@@ -0,0 +1,71 @@
+/**
+ *
+ */
+package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
+
+/**
+ *
+ * @author Giancarlo Panichi email: g.panichi@isti.cnr.it
+ *
+ */
+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 + "]";
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/WKTGeometryType.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/WKTGeometryType.java
new file mode 100644
index 0000000..710b508
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/WKTGeometryType.java
@@ -0,0 +1,60 @@
+package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ *
+ * @author Giancarlo Panichi
+ * email: g.panichi@isti.cnr.it
+ *
+ */
+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 asList() {
+ List list = Arrays.asList(values());
+ return list;
+ }
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/WKTParameter.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/WKTParameter.java
new file mode 100644
index 0000000..6c35bcf
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/parameters/WKTParameter.java
@@ -0,0 +1,93 @@
+/**
+ *
+ */
+package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
+
+
+/**
+ *
+ * @author Giancarlo Panichi email: g.panichi@isti.cnr.it
+ *
+ */
+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 + "]";
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/process/ComputationStatus.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/process/ComputationStatus.java
new file mode 100644
index 0000000..c0d2163
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/process/ComputationStatus.java
@@ -0,0 +1,117 @@
+package org.gcube.data.analysis.dataminermanagercl.shared.process;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author Giancarlo Panichi email: g.panichi@isti.cnr.it
+ *
+ */
+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 + "]";
+ }
+
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/process/Operator.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/process/Operator.java
new file mode 100644
index 0000000..a4d25f7
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/process/Operator.java
@@ -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: g.panichi@isti.cnr.it
+ *
+ */
+public class Operator implements Serializable, Comparable {
+
+ private static final long serialVersionUID = -4084498655645951188L;
+ private String id;
+ private String name;
+ private String briefDescription;
+ private String description;
+ private OperatorCategory category;
+ private List operatorParameters = new ArrayList();
+ 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 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 getOperatorParameters() {
+ return operatorParameters;
+ }
+
+ /**
+ * @param operatorParameters
+ * the operatorParameters to set
+ */
+ public void setOperatorParameters(List 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(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());
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/process/OperatorCategory.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/process/OperatorCategory.java
new file mode 100644
index 0000000..d8c4722
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/process/OperatorCategory.java
@@ -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: g.panichi@isti.cnr.it
+ *
+ */
+public class OperatorCategory implements Serializable, Comparable {
+
+ private static final long serialVersionUID = 7511425996378626337L;
+ private String id;
+ private String name;
+ private String briefDescription;
+ private String description;
+ private List operators = new ArrayList();
+ 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 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 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 getOperators() {
+ return operators;
+ }
+
+ /**
+ * @param operators the operators to set
+ */
+ public void setOperators(List 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(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());
+ }
+
+
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/process/OperatorsClassification.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/process/OperatorsClassification.java
new file mode 100644
index 0000000..c4a5b13
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/process/OperatorsClassification.java
@@ -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: g.panichi@isti.cnr.it
+ *
+ */
+public class OperatorsClassification implements Serializable {
+
+ private static final long serialVersionUID = 7347445659350838584L;
+ private String name;
+ private List operatorCategories = new ArrayList();
+ private List operators = new ArrayList();
+
+ public OperatorsClassification() {
+ super();
+ }
+
+ /**
+ *
+ */
+ public OperatorsClassification(String name) {
+ super();
+ this.name = name;
+ }
+
+ /**
+ * @param operatorCategories
+ * @param operators
+ */
+ public OperatorsClassification(String name, List operatorCategories,
+ List operators) {
+ this(name);
+ this.operatorCategories = operatorCategories;
+ this.operators = operators;
+ }
+
+ /**
+ * @return the operatorCategories
+ */
+ public List getOperatorCategories() {
+ return operatorCategories;
+ }
+
+ /**
+ * @param operatorCategories the operatorCategories to set
+ */
+ public void setOperatorCategories(List operatorCategories) {
+ this.operatorCategories = operatorCategories;
+ }
+
+ /**
+ * @return the operators
+ */
+ public List getOperators() {
+ return operators;
+ }
+
+ /**
+ * @param operators the operators to set
+ */
+ public void setOperators(List 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 + "]";
+ }
+
+
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/process/TemplateDescriptor.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/process/TemplateDescriptor.java
new file mode 100644
index 0000000..9df8049
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/process/TemplateDescriptor.java
@@ -0,0 +1,118 @@
+/**
+ *
+ */
+package org.gcube.data.analysis.dataminermanagercl.shared.process;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ *
+ * @author Giancarlo Panichi
+ * email: g.panichi@isti.cnr.it
+ *
+ */
+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 map;
+ static {
+ map = new HashMap();
+ 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;
+ }
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/workspace/Computations.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/workspace/Computations.java
new file mode 100644
index 0000000..8259123
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/workspace/Computations.java
@@ -0,0 +1,38 @@
+package org.gcube.data.analysis.dataminermanagercl.shared.workspace;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author Giancarlo Panichi email: g.panichi@isti.cnr.it
+ *
+ */
+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 + "]";
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/workspace/DataMinerWorkArea.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/workspace/DataMinerWorkArea.java
new file mode 100644
index 0000000..2e3379b
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/workspace/DataMinerWorkArea.java
@@ -0,0 +1,93 @@
+package org.gcube.data.analysis.dataminermanagercl.shared.workspace;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author "Giancarlo Panichi" g.panichi@isti.cnr.it
+ *
+ */
+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 + "]";
+ }
+
+
+
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/workspace/InputDataSets.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/workspace/InputDataSets.java
new file mode 100644
index 0000000..8c89187
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/workspace/InputDataSets.java
@@ -0,0 +1,38 @@
+package org.gcube.data.analysis.dataminermanagercl.shared.workspace;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author Giancarlo Panichi email: g.panichi@isti.cnr.it
+ *
+ */
+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 + "]";
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/workspace/ItemDescription.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/workspace/ItemDescription.java
new file mode 100644
index 0000000..73fa68e
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/workspace/ItemDescription.java
@@ -0,0 +1,112 @@
+package org.gcube.data.analysis.dataminermanagercl.shared.workspace;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author Giancarlo Panichi email: g.panichi@isti.cnr.it
+ *
+ */
+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 + "]";
+ }
+
+}
diff --git a/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/workspace/OutputDataSets.java b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/workspace/OutputDataSets.java
new file mode 100644
index 0000000..df7b544
--- /dev/null
+++ b/src/main/java/org/gcube/data/analysis/dataminermanagercl/shared/workspace/OutputDataSets.java
@@ -0,0 +1,38 @@
+package org.gcube.data.analysis.dataminermanagercl.shared.workspace;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author Giancarlo Panichi email: g.panichi@isti.cnr.it
+ *
+ */
+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 + "]";
+ }
+
+}
diff --git a/src/test/java/org/gcube/data/analysis/dataminermanagercl/test/DBScanTest.java b/src/test/java/org/gcube/data/analysis/dataminermanagercl/test/DBScanTest.java
new file mode 100644
index 0000000..2955d51
--- /dev/null
+++ b/src/test/java/org/gcube/data/analysis/dataminermanagercl/test/DBScanTest.java
@@ -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: g.panichi@isti.cnr.it
+ *
+ */
+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 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 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 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);
+
+ }
+
+}
diff --git a/src/test/java/org/gcube/data/analysis/dataminermanagercl/test/DataMinerServiceTest.java b/src/test/java/org/gcube/data/analysis/dataminermanagercl/test/DataMinerServiceTest.java
new file mode 100644
index 0000000..54a331a
--- /dev/null
+++ b/src/test/java/org/gcube/data/analysis/dataminermanagercl/test/DataMinerServiceTest.java
@@ -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: g.panichi@isti.cnr.it
+ *
+ */
+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 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 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 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);
+ }
+ }
+
+
+}
diff --git a/src/test/java/org/gcube/data/analysis/dataminermanagercl/test/ListDBInfoTest.java b/src/test/java/org/gcube/data/analysis/dataminermanagercl/test/ListDBInfoTest.java
new file mode 100644
index 0000000..39042c4
--- /dev/null
+++ b/src/test/java/org/gcube/data/analysis/dataminermanagercl/test/ListDBInfoTest.java
@@ -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: g.panichi@isti.cnr.it
+ *
+ */
+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 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 parameters = new ArrayList<>();
+
+ parameters.add(resourceName);
+
+ logger.debug("Parameters set: " + parameters);
+ operator.setOperatorParameters(parameters);
+
+ }
+
+}
diff --git a/src/test/java/org/gcube/data/analysis/dataminermanagercl/test/ListDBNameTest.java b/src/test/java/org/gcube/data/analysis/dataminermanagercl/test/ListDBNameTest.java
new file mode 100644
index 0000000..abb20a7
--- /dev/null
+++ b/src/test/java/org/gcube/data/analysis/dataminermanagercl/test/ListDBNameTest.java
@@ -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: g.panichi@isti.cnr.it
+ *
+ */
+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 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 parameters = new ArrayList<>();
+
+ parameters.add(maxNumber);
+
+ logger.debug("Parameters set: " + parameters);
+ operator.setOperatorParameters(parameters);
+
+ }
+
+}
diff --git a/src/test/java/org/gcube/data/analysis/dataminermanagercl/test/ListDBSchemaTest.java b/src/test/java/org/gcube/data/analysis/dataminermanagercl/test/ListDBSchemaTest.java
new file mode 100644
index 0000000..a1f6039
--- /dev/null
+++ b/src/test/java/org/gcube/data/analysis/dataminermanagercl/test/ListDBSchemaTest.java
@@ -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: g.panichi@isti.cnr.it
+ *
+ */
+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 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 parameters = new ArrayList<>();
+
+ parameters.add(resourceName);
+ parameters.add(databaseName);
+
+ logger.debug("Parameters set: " + parameters);
+ operator.setOperatorParameters(parameters);
+
+ }
+
+}
diff --git a/src/test/java/org/gcube/data/analysis/dataminermanagercl/test/ListTablesTest.java b/src/test/java/org/gcube/data/analysis/dataminermanagercl/test/ListTablesTest.java
new file mode 100644
index 0000000..5ba5eb0
--- /dev/null
+++ b/src/test/java/org/gcube/data/analysis/dataminermanagercl/test/ListTablesTest.java
@@ -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: g.panichi@isti.cnr.it
+ *
+ */
+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 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 parameters = new ArrayList<>();
+
+ parameters.add(resourceName);
+ parameters.add(databaseName);
+ parameters.add(schemaName);
+
+ logger.debug("Parameters set: " + parameters);
+ operator.setOperatorParameters(parameters);
+
+ }
+
+}
diff --git a/src/test/resources/log4j.properties b/src/test/resources/log4j.properties
new file mode 100644
index 0000000..87b68a3
--- /dev/null
+++ b/src/test/resources/log4j.properties
@@ -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