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@144855 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-03-10 19:11:18 +00:00
parent 1eaf71e604
commit 6881202590
8 changed files with 427 additions and 42 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<classpathentry kind="src" output="target/data-miner-manager-cl-1.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
@ -29,5 +29,5 @@
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="output" path="target/data-miner-manager-cl-1.2.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

59
pom.xml
View File

@ -9,9 +9,9 @@
</parent>
<groupId>data-miner-manager-cl</groupId>
<groupId>org.gcube.data.analysis</groupId>
<artifactId>data-miner-manager-cl</artifactId>
<version>1.1.0-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
<name>data-miner-manager-cl</name>
<description>DataMiner Manager Client Library</description>
@ -42,6 +42,14 @@
<!-- Java Version -->
<javaVersion>1.7</javaVersion>
<!-- GWT configuration -->
<gwtVersion>2.6.1</gwtVersion>
<gwtLogVersion>3.3.2</gwtLogVersion>
<!-- <gxtVersion>3.1.1</gxtVersion> -->
<!-- <gxt2Version>2.6.1</gxt2Version> -->
<KEYS>${env.KEYS}</KEYS>
@ -221,14 +229,46 @@
<build>
<!-- Generate compiled stuff in the folder used for developing mode -->
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
<sourceDirectory>src/main/java</sourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>
<plugins>
<!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version> </plugin> -->
<!-- GWT Maven Plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwtVersion}</version>
<executions>
<execution>
<goals>
<goal>resources</goal>
</goals>
</execution>
</executions>
<configuration>
<runTarget>DataMinerManagerCL.html</runTarget>
<hostedWebapp>${webappDirectory}</hostedWebapp>
<module>org.gcube.data.analysis.dataminermanagercl.dataminermanagercl</module>
<!-- <compileSourcesArtifacts> <artifact>com.github.highcharts4gwt:highcharts</artifact>
</compileSourcesArtifacts> -->
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
@ -237,15 +277,8 @@
<target>${javaVersion}</target>
</configuration>
</plugin>
<!--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
</plugin>
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
@ -265,8 +298,8 @@
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='dataminermanagercl'>
<inherits name='com.google.gwt.user.User' />
<inherits name="com.google.gwt.http.HTTP" />
<!-- <inherits name='com.google.gwt.user.theme.clean.Clean' /> -->
<inherits name='com.sencha.gxt.ui.GXT' />
<!-- <inherits name="com.extjs.gxt.ui.GXT" /> -->
<!-- <inherits name="com.google.gwt.logging.Logging" /> -->
<inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" />
<!--
<entry-point
class='org.gcube.portlets.widgets.dataminermanagerwidget.client.DataMinerManager' />
-->
<!-- <set-property name="log_ConsoleLogger" value="ENABLED" /> <set-property
name="log_DivLogger" value="ENABLED" /> <set-property name="log_GWTLogger"
value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED"
/> -->
<set-property name="log_ConsoleLogger" value="DISABLED" />
<set-property name="log_DivLogger" value="DISABLED" />
<set-property name="log_GWTLogger" value="DISABLED" />
<set-property name="log_SystemLogger" value="DISABLED" />
<source path='client' />
<source path='shared' />
</module>

View File

@ -119,7 +119,7 @@ public class SClient4WPS extends SClient {
wpsToken = token;
}
String userName = serviceCredentials.getUsername();
String userName = serviceCredentials.getUserName();
if (userName == null || userName.isEmpty()) {
logger.error("Error invalid user name: " + userName);
throw new ServiceException("Error invalid user name: "
@ -197,7 +197,7 @@ public class SClient4WPS extends SClient {
wpsToken = token;
}
String userName = serviceCredentials.getUsername();
String userName = serviceCredentials.getUserName();
if (userName == null || userName.isEmpty()) {
logger.error("Error invalid user name: " + userName);
throw new ServiceException("Error invalid user name: "

View File

@ -11,33 +11,82 @@ import java.io.Serializable;
public class ServiceCredentials implements Serializable {
private static final long serialVersionUID = 3560918948310315680L;
private String username;
private String userName;
private String fullName;
private String name;
private String lastName;
private String email;
private String scope;
private String groupId;
private String groupName;
private String userAvatarURL;
private String token;
public ServiceCredentials() {
super();
}
/**
*
* @param user
* @param scope
* @param token
*/
public ServiceCredentials(String username, String scope, String token) {
public ServiceCredentials(String userName, String scope, String token) {
super();
this.username = username;
this.userName = userName;
this.scope = scope;
this.token = token;
}
public String getUsername() {
return username;
public ServiceCredentials(String userName, String fullName, String name,
String lastName, String email, String scope, String groupId,
String groupName, String userAvatarURL, String token) {
super();
this.userName = userName;
this.fullName = fullName;
this.name = name;
this.lastName = lastName;
this.email = email;
this.scope = scope;
this.groupId = groupId;
this.groupName = groupName;
this.userAvatarURL = userAvatarURL;
this.token = token;
}
public void setUsername(String username) {
this.username = username;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getScope() {
@ -48,6 +97,30 @@ public class ServiceCredentials implements Serializable {
this.scope = scope;
}
public String getGroupId() {
return groupId;
}
public void setGroupId(String groupId) {
this.groupId = groupId;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public String getUserAvatarURL() {
return userAvatarURL;
}
public void setUserAvatarURL(String userAvatarURL) {
this.userAvatarURL = userAvatarURL;
}
public String getToken() {
return token;
}
@ -58,10 +131,11 @@ public class ServiceCredentials implements Serializable {
@Override
public String toString() {
return "ServiceCredentials [username=" + username + ", scope=" + scope
+ ", token=" + token + "]";
return "ServiceCredentials [userName=" + userName + ", fullName="
+ fullName + ", name=" + name + ", lastName=" + lastName
+ ", email=" + email + ", scope=" + scope + ", groupId="
+ groupId + ", groupName=" + groupName + ", userAvatarURL="
+ userAvatarURL + ", token=" + token + "]";
}
}
}

View File

@ -3,6 +3,8 @@
*/
package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
import java.util.ArrayList;
/**
*
* @author Giancarlo Panichi email: <a
@ -12,6 +14,8 @@ package org.gcube.data.analysis.dataminermanagercl.shared.parameters;
public class TabularResourceParameter extends Parameter {
private static final long serialVersionUID = 8038591467145151553L;
private String tabularResourceId;
private ArrayList<String> columns;
/**
*
@ -28,24 +32,42 @@ public class TabularResourceParameter extends Parameter {
* @param tableName
*/
public TabularResourceParameter(String name, String description,
String tabularResourceId) {
String tabularResourceId, ArrayList<String> columns) {
super(name, ParameterType.TABULAR_RESOURCE, description);
this.value = tabularResourceId;
this.tabularResourceId = tabularResourceId;
this.columns = columns;
}
public String getTabularResourceId() {
return value;
return tabularResourceId;
}
public void setTabularResourceId(String tabularResourceId) {
this.value = 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 [name=" + name + ", description="
+ description + ", typology=" + typology + ", value=" + value
+ "]";
return "TabularResourceParameter [tabularResourceId="
+ tabularResourceId + ", columns=" + columns + ", name=" + name
+ ", description=" + description + ", typology=" + typology
+ ", value=" + value + "]";
}
}

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='dataminermanagercl'>
<inherits name='com.google.gwt.user.User' />
<inherits name="com.google.gwt.http.HTTP" />
<!-- <inherits name='com.google.gwt.user.theme.clean.Clean' /> -->
<inherits name='com.sencha.gxt.ui.GXT' />
<!-- <inherits name="com.extjs.gxt.ui.GXT" /> -->
<!-- <inherits name="com.google.gwt.logging.Logging" /> -->
<inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" />
<!--
<entry-point
class='org.gcube.portlets.widgets.dataminermanagerwidget.client.DataMinerManager' />
-->
<!-- <set-property name="log_ConsoleLogger" value="ENABLED" /> <set-property
name="log_DivLogger" value="ENABLED" /> <set-property name="log_GWTLogger"
value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED"
/> -->
<set-property name="log_ConsoleLogger" value="DISABLED" />
<set-property name="log_DivLogger" value="DISABLED" />
<set-property name="log_GWTLogger" value="DISABLED" />
<set-property name="log_SystemLogger" value="DISABLED" />
<source path='client' />
<source path='shared' />
</module>

View File

@ -0,0 +1,190 @@
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);
}
}