ref 6078:TDM - Create a new widget to support operations's invocation on DataMiner

https://support.d4science.org/issues/6078

Updated to support DataMinerManagerWidget

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/data-miner-manager-cl@144880 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-03-13 18:58:10 +00:00
parent 6881202590
commit 6bff8fae98
5 changed files with 8 additions and 268 deletions

View File

@ -11,14 +11,14 @@ import java.io.Serializable;
public class ColumnItem implements Serializable {
private static final long serialVersionUID = -3451466410777498956L;
private Integer id;
private String id;
private String name;
public ColumnItem() {
super();
}
public ColumnItem(Integer id, String name) {
public ColumnItem(String id, String name) {
super();
this.id = id;
this.name = name;
@ -36,11 +36,11 @@ public class ColumnItem implements Serializable {
this.name = name;
}
public Integer getId() {
public String getId() {
return id;
}
public void setId(Integer id) {
public void setId(String id) {
this.id = id;
}

View File

@ -7,5 +7,5 @@ package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
*
*/
public enum ParameterType {
OBJECT, TABULAR, TABULAR_RESOURCE, FILE, ENUM, LIST, COLUMN, COLUMN_LIST, TABULAR_LIST, WKT, DATE, TIME;
OBJECT, TABULAR, FILE, ENUM, LIST, COLUMN, COLUMN_LIST, TABULAR_LIST, WKT, DATE, TIME;
}

View File

@ -18,6 +18,9 @@ public class TabularParameter extends Parameter {
private String defaultMimeType;
private ArrayList<String> supportedMimeTypes;
/**
*
*/

View File

@ -1,73 +0,0 @@
/**
*
*/
package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
import java.util.ArrayList;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class TabularResourceParameter extends Parameter {
private static final long serialVersionUID = 8038591467145151553L;
private String tabularResourceId;
private ArrayList<String> columns;
/**
*
*/
public TabularResourceParameter() {
super();
this.typology = ParameterType.TABULAR_RESOURCE;
}
/**
*
* @param name
* @param description
* @param tableName
*/
public TabularResourceParameter(String name, String description,
String tabularResourceId, ArrayList<String> columns) {
super(name, ParameterType.TABULAR_RESOURCE, description);
this.tabularResourceId = tabularResourceId;
this.columns = columns;
}
public String getTabularResourceId() {
return tabularResourceId;
}
public void setTabularResourceId(String tabularResourceId) {
this.tabularResourceId = tabularResourceId;
}
public ArrayList<String> getColumns() {
return columns;
}
public void setColumns(ArrayList<String> columns) {
this.columns = columns;
}
public String getPublicLink() {
return value;
}
public void setPublicLink(String publicLink) {
this.value = publicLink;
}
@Override
public String toString() {
return "TabularResourceParameter [tabularResourceId="
+ tabularResourceId + ", columns=" + columns + ", name=" + name
+ ", description=" + description + ", typology=" + typology
+ ", value=" + value + "]";
}
}

View File

@ -1,190 +0,0 @@
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.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.TabularResourceParameter;
import org.gcube.data.analysis.dataminermanagercl.shared.process.Operator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class TabularResourceTest extends TestCase {
private static Logger logger = LoggerFactory.getLogger(TabularResourceTest.class);
public void testExecute() {
if (Constants.TEST_ENABLE) {
logger.debug("Test Tabular Resource using DBScan");
try {
DataMinerService dataMinerService = new DataMinerService();
SClient sClient = dataMinerService.getClient();
Operator dBScanOperator = sClient
.getOperatorById("org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mappedclasses.clusterers.DBSCAN");
if (dBScanOperator == null) {
logger.error("Operator not found");
} else {
logger.debug("Operator Name: " + dBScanOperator.getName()
+ " (" + dBScanOperator.getId() + ")");
logger.debug("Operator: " + dBScanOperator);
List<Parameter> parameters = sClient
.getInputParameters(dBScanOperator);
logger.debug("Parameters: " + parameters);
for (Parameter parameter : parameters) {
logger.debug("Parameter:[Name=" + parameter.getName()
+ ", Typology=" + parameter.getTypology() + "]");
}
createRequest(dBScanOperator);
logger.debug("Start Computation");
ComputationId computationId = sClient
.startComputation(dBScanOperator);
logger.debug("Started ComputationId: " + computationId);
monitoringComputation(computationId, sClient);
}
assertTrue("Success", true);
} catch (Throwable e) {
logger.error(e.getLocalizedMessage());
e.printStackTrace();
assertTrue("Error", false);
}
} else {
assertTrue("Success", true);
}
}
private void monitoringComputation(final ComputationId computationId,
final SClient sClient) {
DMMonitorListener listener = new DMMonitorListener() {
@Override
public void running(double percentage) {
logger.debug("Operation Running: " + percentage);
}
@Override
public void failed(String message, Exception exception) {
logger.error("Operation Failed");
logger.error(message, exception);
}
@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");
TabularResourceParameter occurencePointsTabularResource = new TabularResourceParameter();
occurencePointsTabularResource.setName("OccurrencePointsTable");
occurencePointsTabularResource
.setPublicLink("http://data-d.d4science.org/SnBPSHJQOEI4UHQ0QkhnM2p3L2JGQytNTmtSb1FpUTFHbWJQNStIS0N6Yz0");
ColumnListParameter columnListParameter = new ColumnListParameter();
columnListParameter.setName("FeaturesColumnNames");
columnListParameter.setValue("depthmean|sstmnmax|salinitymin");
ObjectParameter occurencePointsClusterLabel = new ObjectParameter();
occurencePointsClusterLabel.setName("OccurrencePointsClusterLabel");
occurencePointsClusterLabel.setValue("Test");
ObjectParameter epsilon = new ObjectParameter();
epsilon.setName("epsilon");
epsilon.setValue("10");
ObjectParameter minPoints = new ObjectParameter();
minPoints.setName("min_points");
minPoints.setValue("1");
List<Parameter> parameters = new ArrayList<>();
parameters.add(occurencePointsTabularResource);
parameters.add(columnListParameter);
parameters.add(occurencePointsClusterLabel);
parameters.add(epsilon);
parameters.add(minPoints);
logger.debug("Parameters set: " + parameters);
operator.setOperatorParameters(parameters);
}
}