From 8d6178a2c67faccc13492ae031fdeb57174f4c68 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Wed, 22 Oct 2014 16:34:10 +0000 Subject: [PATCH] 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 --- pom.xml | 23 +-- .../StatisticalWidget.gwt.xml | 4 +- .../client/StatisticalWidget.java | 109 +++++++++++++- .../client/stat/TDExternalTable.java | 52 +++++++ .../client/stat/TDSubmissionHandler.java | 135 ++++++++++++++++++ ...dget.gwt.xml => StatisticalWidget.gwt.xml} | 6 +- templates/changelog.xml | 2 +- 7 files changed, 318 insertions(+), 13 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/td/statisticalwidget/client/stat/TDExternalTable.java create mode 100644 src/main/java/org/gcube/portlets/user/td/statisticalwidget/client/stat/TDSubmissionHandler.java rename src/main/resources/org/gcube/portlets/user/td/statisticalwidget/{ResourcesWidget.gwt.xml => StatisticalWidget.gwt.xml} (84%) diff --git a/pom.xml b/pom.xml index 22414be..d2cabb2 100644 --- a/pom.xml +++ b/pom.xml @@ -38,7 +38,7 @@ ${project.basedir}/distro ${project.build.directory}/${project.build.finalName} - 2014-09-12 + 2014-10-31 https://gcube.wiki.gcube-system.org/gcube/index.php templates distro @@ -111,12 +111,6 @@ 3.0.1 - @@ -134,8 +128,21 @@ [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT) provided - + + + org.gcube.portlets.user + tabular-data-monitor-widget + [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT) + provided + + + + + org.gcube.portlets.widgets + statistical-manager-algorithms + [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT) + diff --git a/src/main/java/org/gcube/portlets/user/td/statisticalwidget/StatisticalWidget.gwt.xml b/src/main/java/org/gcube/portlets/user/td/statisticalwidget/StatisticalWidget.gwt.xml index 3627200..1263ebe 100644 --- a/src/main/java/org/gcube/portlets/user/td/statisticalwidget/StatisticalWidget.gwt.xml +++ b/src/main/java/org/gcube/portlets/user/td/statisticalwidget/StatisticalWidget.gwt.xml @@ -18,7 +18,9 @@ - + + + diff --git a/src/main/java/org/gcube/portlets/user/td/statisticalwidget/client/StatisticalWidget.java b/src/main/java/org/gcube/portlets/user/td/statisticalwidget/client/StatisticalWidget.java index b59486c..1d85c33 100644 --- a/src/main/java/org/gcube/portlets/user/td/statisticalwidget/client/StatisticalWidget.java +++ b/src/main/java/org/gcube/portlets/user/td/statisticalwidget/client/StatisticalWidget.java @@ -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 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() { + + 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>() { + + 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 columnsResult) { + Log.debug("Columns: " + columnsResult); + createColumnsMap(columnsResult); + } + + }); + } + + protected void createColumnsMap(ArrayList columnsList){ + columns= new HashMap(); + + for(ColumnData columnData:columnsList){ + columns.put(columnData.getColumnId(), columnData.getLabel()); + } + + openStatisticalWidget(); + + } + + protected void openStatisticalWidget(){ + ArrayList tables = new ArrayList(); + 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); + } } diff --git a/src/main/java/org/gcube/portlets/user/td/statisticalwidget/client/stat/TDExternalTable.java b/src/main/java/org/gcube/portlets/user/td/statisticalwidget/client/stat/TDExternalTable.java new file mode 100644 index 0000000..fa553b8 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/statisticalwidget/client/stat/TDExternalTable.java @@ -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: g.panichi@isti.cnr.it + * + */ +public class TDExternalTable implements ExternalTable { + protected EventBus eventBus; + protected TRId trId; + + private String id; + private String label; + private Map columns; + + + public TDExternalTable(TRId trId, EventBus eventBus,String id, String label, Map 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 getColumnsNameAndLabels() { + return columns; + } + +} + + diff --git a/src/main/java/org/gcube/portlets/user/td/statisticalwidget/client/stat/TDSubmissionHandler.java b/src/main/java/org/gcube/portlets/user/td/statisticalwidget/client/stat/TDSubmissionHandler.java new file mode 100644 index 0000000..aab48af --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/statisticalwidget/client/stat/TDSubmissionHandler.java @@ -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: g.panichi@isti.cnr.it + * + */ +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() { + + 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() { + + } + +} diff --git a/src/main/resources/org/gcube/portlets/user/td/statisticalwidget/ResourcesWidget.gwt.xml b/src/main/resources/org/gcube/portlets/user/td/statisticalwidget/StatisticalWidget.gwt.xml similarity index 84% rename from src/main/resources/org/gcube/portlets/user/td/statisticalwidget/ResourcesWidget.gwt.xml rename to src/main/resources/org/gcube/portlets/user/td/statisticalwidget/StatisticalWidget.gwt.xml index 89555c0..7090593 100644 --- a/src/main/resources/org/gcube/portlets/user/td/statisticalwidget/ResourcesWidget.gwt.xml +++ b/src/main/resources/org/gcube/portlets/user/td/statisticalwidget/StatisticalWidget.gwt.xml @@ -1,5 +1,5 @@ - + @@ -19,7 +19,9 @@ - + + + diff --git a/templates/changelog.xml b/templates/changelog.xml index 4d09efc..0ff1c39 100644 --- a/templates/changelog.xml +++ b/templates/changelog.xml @@ -1,6 +1,6 @@ + date="2014-10-31"> First Release \ No newline at end of file