Updated Statistical Widget

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-statistical-widget@100888 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-10-22 16:34:10 +00:00 committed by Giancarlo Panichi
parent 3f730950c4
commit 8d6178a2c6
7 changed files with 318 additions and 13 deletions

23
pom.xml
View File

@ -38,7 +38,7 @@
<properties>
<distroDirectory>${project.basedir}/distro</distroDirectory>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<release.date>2014-09-12</release.date>
<release.date>2014-10-31</release.date>
<wikiurl>https://gcube.wiki.gcube-system.org/gcube/index.php</wikiurl>
<templatesDirectory>templates</templatesDirectory>
<distroDirectory>distro</distroDirectory>
@ -111,12 +111,6 @@
<version>3.0.1</version>
</dependency>
<!--
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>home-library</artifactId>
<scope>provided</scope>
</dependency> -->
<!-- tabular-data-gwt-service -->
@ -134,8 +128,21 @@
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<!-- tabular-data-monitor-widget -->
<dependency>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>tabular-data-monitor-widget</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<!-- statistical-manager-algorithms -->
<dependency>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>statistical-manager-algorithms</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
</dependency>
<!-- LOGGING -->
<dependency>

View File

@ -18,7 +18,9 @@
<inherits name='com.sencha.gxt.ui.GXT' />
<inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" />
<inherits name='org.gcube.portlets.user.td.gwtservice.TDGWTService' />
<inherits name='org.gcube.portlets.user.td.monitorwidget.MonitorWidgetTD' />
<inherits name='org.gcube.portlets.widgets.StatisticalManagerAlgorithmsWidget.StatisticalManagerAlgorithmsWidget' />
<!-- Specify the app entry point class. -->
<!-- <entry-point class='org.gcube.portlets.user.td.statisticalwidget.client.StatisticalWidgetEntry' /> -->

View File

@ -1,8 +1,24 @@
package org.gcube.portlets.user.td.statisticalwidget.client;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
import org.gcube.portlets.user.td.statisticalwidget.client.stat.TDExternalTable;
import org.gcube.portlets.user.td.statisticalwidget.client.stat.TDSubmissionHandler;
import org.gcube.portlets.user.td.statisticalwidget.client.utils.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import org.gcube.portlets.widgets.StatisticalManagerAlgorithmsWidget.client.ExternalTable;
import org.gcube.portlets.widgets.StatisticalManagerAlgorithmsWidget.client.StatisticalManagerExperimentsWidget;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.web.bindery.event.shared.EventBus;
/**
@ -15,9 +31,14 @@ import com.google.web.bindery.event.shared.EventBus;
*
*/
public class StatisticalWidget {
private String id;
private String label;
private Map<String,String> columns;
protected EventBus eventBus;
protected TRId trId;
/**
*
* @param trId
@ -28,5 +49,91 @@ public class StatisticalWidget {
this.eventBus = eventBus;
Log.debug("Statistical Widget: " + trId);
}
protected void retrieveTabularResourceInfo() {
TDGWTServiceAsync.INSTANCE.getTabResourceInformation(trId,
new AsyncCallback<TabResource>() {
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error("Error retrieving tabular resource informations: "
+ caught.getLocalizedMessage());
UtilsGXT3.alert("Error", "Error retrieving tabular resource informations");
}
}
public void onSuccess(TabResource tabResource) {
Log.debug("TabResouce: " + tabResource);
createTableInfo(tabResource);
}
});
}
protected void createTableInfo(TabResource tabResource){
id=tabResource.getId();
label=tabResource.getName();
retrieveTabularResourceColumns();
}
protected void retrieveTabularResourceColumns() {
TDGWTServiceAsync.INSTANCE.getColumnWithViewColumnIncluded(trId, new AsyncCallback<ArrayList<ColumnData>>() {
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error("Error retrieving columns informations: "
+ caught.getLocalizedMessage());
UtilsGXT3.alert("Error", "Error retrieving columns informations");
}
}
public void onSuccess(ArrayList<ColumnData> columnsResult) {
Log.debug("Columns: " + columnsResult);
createColumnsMap(columnsResult);
}
});
}
protected void createColumnsMap(ArrayList<ColumnData> columnsList){
columns= new HashMap<String, String>();
for(ColumnData columnData:columnsList){
columns.put(columnData.getColumnId(), columnData.getLabel());
}
openStatisticalWidget();
}
protected void openStatisticalWidget(){
ArrayList<ExternalTable> tables = new ArrayList<ExternalTable>();
TDExternalTable tdExternalTable=new TDExternalTable(trId, eventBus, id, label,columns);
tables.add(tdExternalTable);
TDSubmissionHandler tdSubmissionHandler = new TDSubmissionHandler(trId,
eventBus);
@SuppressWarnings("unused")
StatisticalManagerExperimentsWidget st = new StatisticalManagerExperimentsWidget(
null, tables, "ExecutionComputationDefault",
tdSubmissionHandler);
}
}

View File

@ -0,0 +1,52 @@
package org.gcube.portlets.user.td.statisticalwidget.client.stat;
import java.util.Map;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import org.gcube.portlets.widgets.StatisticalManagerAlgorithmsWidget.client.ExternalTable;
import com.allen_sauer.gwt.log.client.Log;
import com.google.web.bindery.event.shared.EventBus;
/**
*
* @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class TDExternalTable implements ExternalTable {
protected EventBus eventBus;
protected TRId trId;
private String id;
private String label;
private Map<String,String> columns;
public TDExternalTable(TRId trId, EventBus eventBus,String id, String label, Map<String,String> columns) {
Log.debug("TDExternalTable: "+trId);
this.trId=trId;
this.eventBus=eventBus;
this.id=id;
this.label=label;
this.columns=columns;
}
@Override
public String getId() {
return id;
}
@Override
public String getLabel() {
return label;
}
@Override
public Map<String, String> getColumnsNameAndLabels() {
return columns;
}
}

View File

@ -0,0 +1,135 @@
package org.gcube.portlets.user.td.statisticalwidget.client.stat;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.statistical.StatisticalOperationSession;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener;
import org.gcube.portlets.user.td.monitorwidget.client.utils.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableWhy;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import org.gcube.portlets.widgets.StatisticalManagerAlgorithmsWidget.client.SubmissionHandler;
import org.gcube.portlets.widgets.StatisticalManagerAlgorithmsWidget.client.SubmissionParameters;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.web.bindery.event.shared.EventBus;
/**
*
* @author giancarlo email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class TDSubmissionHandler implements SubmissionHandler,
MonitorDialogListener {
protected EventBus eventBus;
protected TRId trId;
public TDSubmissionHandler(TRId trId, EventBus eventBus) {
this.trId = trId;
this.eventBus = eventBus;
}
@Override
public void onSubmit(SubmissionParameters params) {
Log.debug("SUBMITTED :" + params);
if (params == null) {
Log.error("Invalid params null");
UtilsGXT3.alert("Error", "Invalid params null");
return;
}
StatisticalOperationSession statisticalOperationSession = new StatisticalOperationSession(
trId, params.getParametersMap(), params.getDescription(),
params.getTitle(), params.getOp().getId(), params.getOp()
.getName(), params.getOp().getBriefDescription());
callStatisticalOperation(statisticalOperationSession);
}
protected void callStatisticalOperation(
StatisticalOperationSession statisticalOperationSession) {
TDGWTServiceAsync.INSTANCE.startStatisticalOperation(
statisticalOperationSession, new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
if (caught instanceof TDGWTIsLockedException) {
Log.error(caught.getLocalizedMessage());
UtilsGXT3.alert("Error Locked",
caught.getLocalizedMessage());
} else {
Log.error("Error in statistical operation: "
+ caught.getLocalizedMessage());
UtilsGXT3.alert(
"Error in statistical operation",
"Error: "
+ caught.getLocalizedMessage());
}
}
}
public void onSuccess(String taskId) {
Log.debug("Statistical Operation started");
openMonitorDialog(taskId);
}
});
}
// /
protected void openMonitorDialog(String taskId) {
MonitorDialog monitorDialog = new MonitorDialog(taskId, eventBus);
monitorDialog.addProgressDialogListener(this);
monitorDialog.show();
}
@Override
public void operationComplete(TRId trId) {
ChangeTableWhy why = ChangeTableWhy.TABLEUPDATED;
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.ROLLBACK, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
}
@Override
public void operationFailed(Throwable caught, String reason, String details) {
UtilsGXT3.alert(reason, details);
}
@Override
public void operationStopped(TRId trId, String reason, String details) {
ChangeTableWhy why = ChangeTableWhy.TABLECURATION;
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.ROLLBACK, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
}
@Override
public void operationAborted() {
}
@Override
public void operationPutInBackground() {
}
}

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='ResourcesWidget'>
<module rename-to='StatisticalWidget'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' />
@ -19,7 +19,9 @@
<inherits name='com.sencha.gxt.ui.GXT' />
<inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" />
<inherits name='org.gcube.portlets.user.td.gwtservice.TDGWTService' />
<inherits name='org.gcube.portlets.user.td.monitorwidget.MonitorWidgetTD' />
<inherits name='org.gcube.portlets.widgets.StatisticalManagerAlgorithmsWidget.StatisticalManagerAlgorithmsWidget' />
<!-- Specify the app entry point class. -->
<!-- <entry-point class='org.gcube.portlets.user.td.resourceswidget.client.ResourcesWidgetEntry' /> -->

View File

@ -1,6 +1,6 @@
<ReleaseNotes>
<Changeset component="${groupId}.${artifactId}.1-0-0"
date="next">
date="2014-10-31">
<Change>First Release</Change>
</Changeset>
</ReleaseNotes>