diff --git a/.classpath b/.classpath index 1806408..6c7f01c 100644 --- a/.classpath +++ b/.classpath @@ -1,12 +1,12 @@ - + - + @@ -42,8 +42,7 @@ - - + diff --git a/pom.xml b/pom.xml index d8aaf04..8e5547e 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ 4.0.0 org.gcube.portlets.user tabular-data-statistical-widget - 1.4.0-SNAPSHOT + 1.5.0-SNAPSHOT tabular-data-statistical-widget @@ -122,10 +122,10 @@ provided - + org.gcube.portlets.widgets - statistical-manager-algorithms + data-miner-manager-widget [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT) diff --git a/src/main/java/org/gcube/portlets/user/td/statisticalwidget/client/DataMinerWidget.java b/src/main/java/org/gcube/portlets/user/td/statisticalwidget/client/DataMinerWidget.java new file mode 100644 index 0000000..b79b717 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/statisticalwidget/client/DataMinerWidget.java @@ -0,0 +1,150 @@ +package org.gcube.portlets.user.td.statisticalwidget.client; + +import java.util.ArrayList; + +import org.gcube.data.analysis.dataminermanagercl.shared.data.ColumnItem; +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.TabResource; +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.user.td.widgetcommonevent.shared.tr.column.ColumnData; +import org.gcube.portlets.widgets.dataminermanagerwidget.client.DataMinerManagerDialog; +import org.gcube.portlets.widgets.dataminermanagerwidget.client.tr.TabularResourceData; + +import com.allen_sauer.gwt.log.client.Log; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.web.bindery.event.shared.EventBus; + +/** + * + * DataMiner Widget + * + * + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it + * + */ +public class DataMinerWidget { + private String id; + private String name; + private String description; + private String type; + private ArrayList columns; + + protected EventBus eventBus; + protected TRId trId; + protected DataMinerManagerDialog dataMinerManagerDialog; + + /** + * + * @param trId + * @param eventBus + */ + public DataMinerWidget(TRId trId, EventBus eventBus) { + this.trId = trId; + this.eventBus = eventBus; + Log.debug("DataMinerWidget: " + trId); + + retrieveTabularResourceInfo(); + + } + + 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.getTrId().getTableId(); + name = tabResource.getName(); + description = tabResource.getDescription(); + type = tabResource.getTableTypeName(); + + retrieveTabularResourceColumns(); + + } + + protected void retrieveTabularResourceColumns() { + TDGWTServiceAsync.INSTANCE.getColumnsForStatistical(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); + createColumnsInfo(columnsResult); + } + + }); + } + + protected void createColumnsInfo(ArrayList columnsList) { + columns = new ArrayList<>(); + + for (ColumnData columnData : columnsList) { + ColumnItem columnItem = new ColumnItem(columnData.getColumnId(), + columnData.getLabel()); + columns.add(columnItem); + } + + openDataMinerWidget(); + + } + + protected void openDataMinerWidget() { + TabularResourceData tabularResourceData = new TabularResourceData(id, + name, description, type, columns); + + dataMinerManagerDialog = new DataMinerManagerDialog(); + dataMinerManagerDialog.setTabularResourceData(tabularResourceData); + + TDSubmissionHandler tdSubmissionHandler = new TDSubmissionHandler(this, + trId, eventBus); + + dataMinerManagerDialog + .addExternalExecutionEventHandler(tdSubmissionHandler); + + } + + public void closeDataMinerWidget() { + dataMinerManagerDialog.hide(); + } +} 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 deleted file mode 100644 index 190a72a..0000000 --- a/src/main/java/org/gcube/portlets/user/td/statisticalwidget/client/StatisticalWidget.java +++ /dev/null @@ -1,145 +0,0 @@ -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.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.user.td.widgetcommonevent.shared.tr.column.ColumnData; -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; - -/** - * - * Statistical Widget - * - * - * @author "Giancarlo Panichi" g.panichi@isti.cnr.it - * - */ -public class StatisticalWidget { - private String id; - private String label; - private Map columns; - - protected EventBus eventBus; - protected TRId trId; - protected StatisticalManagerExperimentsWidget statisticalManagerExperimentsWidget; - - - /** - * - * @param trId - * @param eventBus - */ - public StatisticalWidget(TRId trId, EventBus eventBus) { - this.trId = trId; - this.eventBus = eventBus; - Log.debug("Statistical Widget: " + trId); - - retrieveTabularResourceInfo(); - - } - - 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.getTrId().getTableId(); - label=tabResource.getName(); - - retrieveTabularResourceColumns(); - - } - - - protected void retrieveTabularResourceColumns() { - TDGWTServiceAsync.INSTANCE.getColumnsForStatistical(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(this, trId, - eventBus); - - - statisticalManagerExperimentsWidget = new StatisticalManagerExperimentsWidget( - null, tables, "ExecutionComputationDefault", - tdSubmissionHandler); - - } - - - public void closeStatisticalWidget(){ - statisticalManagerExperimentsWidget.hide(); - } -} diff --git a/src/main/java/org/gcube/portlets/user/td/statisticalwidget/client/StatisticalWidgetEntry.java b/src/main/java/org/gcube/portlets/user/td/statisticalwidget/client/StatisticalWidgetEntry.java index fcbae3f..bf4ec07 100644 --- a/src/main/java/org/gcube/portlets/user/td/statisticalwidget/client/StatisticalWidgetEntry.java +++ b/src/main/java/org/gcube/portlets/user/td/statisticalwidget/client/StatisticalWidgetEntry.java @@ -27,7 +27,7 @@ public class StatisticalWidgetEntry implements EntryPoint { trId.setId("7"); trId.setTableId("402"); - new StatisticalWidget(trId,eventBus); + new DataMinerWidget(trId,eventBus); Log.info("Hello!"); 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 deleted file mode 100644 index 8eb51b4..0000000 --- a/src/main/java/org/gcube/portlets/user/td/statisticalwidget/client/stat/TDExternalTable.java +++ /dev/null @@ -1,67 +0,0 @@ -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; - - /** - * - * @param trId - * @param eventBus - * @param id - * @param label - * @param 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 "TableId [value="+id+"]"; - } - @Override - public String getLabel() { - return label; - } - @Override - public Map getColumnsNameAndLabels() { - return columns; - } - - @Override - public String toString() { - return "TDExternalTable [trId=" + trId + ", id=" + id + ", label=" - + label + ", columns=" + 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 index 06e2ba5..018ba8f 100644 --- 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 @@ -3,11 +3,11 @@ 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.gwtservice.shared.statistical.DataMinerOperationSession; 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.statisticalwidget.client.StatisticalWidget; +import org.gcube.portlets.user.td.statisticalwidget.client.DataMinerWidget; 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; @@ -15,8 +15,8 @@ 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.OperationResult; 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 org.gcube.portlets.widgets.dataminermanagerwidget.client.events.ExternalExecutionEvent; +import org.gcube.portlets.widgets.dataminermanagerwidget.client.events.ExternalExecutionEvent.ExternalExecutionEventHandler; import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -28,43 +28,42 @@ import com.google.web.bindery.event.shared.EventBus; * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it * */ -public class TDSubmissionHandler implements SubmissionHandler, +public class TDSubmissionHandler implements ExternalExecutionEventHandler, MonitorDialogListener { protected EventBus eventBus; protected TRId trId; - protected StatisticalWidget statisticalWidget; - - public TDSubmissionHandler(StatisticalWidget statisticalWidget, TRId trId, EventBus eventBus) { - this.statisticalWidget=statisticalWidget; + protected DataMinerWidget dataMinerWidget; + + public TDSubmissionHandler(DataMinerWidget dataMinerWidget, TRId trId, + EventBus eventBus) { + this.dataMinerWidget = dataMinerWidget; this.trId = trId; this.eventBus = eventBus; } @Override - public void onSubmit(SubmissionParameters params) { - Log.debug("SUBMITTED :" + params); - if (params == null) { + public void onSubmit(ExternalExecutionEvent event) { + Log.debug("SUBMITTED :" + event); + if (event == null || event.getOp() == null) { Log.error("Invalid params null"); UtilsGXT3.alert("Error", "Invalid params null"); return; } - statisticalWidget.closeStatisticalWidget(); - - StatisticalOperationSession statisticalOperationSession = new StatisticalOperationSession( - trId, params.getParametersMap(), params.getDescription(), - params.getTitle(), params.getOp().getId(), params.getOp() - .getName(), params.getOp().getBriefDescription()); - - callStatisticalOperation(statisticalOperationSession); - + dataMinerWidget.closeDataMinerWidget(); + + DataMinerOperationSession statisticalOperationSession = new DataMinerOperationSession( + trId, event.getOp()); + + callDataMinerOperation(statisticalOperationSession); + } - protected void callStatisticalOperation( - StatisticalOperationSession statisticalOperationSession) { + protected void callDataMinerOperation( + DataMinerOperationSession dataMinerOperationSession) { - TDGWTServiceAsync.INSTANCE.startStatisticalOperation( - statisticalOperationSession, new AsyncCallback() { + TDGWTServiceAsync.INSTANCE.startDataMinerOperation( + dataMinerOperationSession, new AsyncCallback() { public void onFailure(Throwable caught) { if (caught instanceof TDGWTSessionExpiredException) { @@ -76,10 +75,10 @@ public class TDSubmissionHandler implements SubmissionHandler, UtilsGXT3.alert("Error Locked", caught.getLocalizedMessage()); } else { - Log.error("Error in statistical operation: " + Log.error("Error in DataMiner operation: " + caught.getLocalizedMessage()); UtilsGXT3.alert( - "Error in statistical operation", + "Error in DataMiner operation", "Error: " + caught.getLocalizedMessage()); } @@ -107,7 +106,8 @@ public class TDSubmissionHandler implements SubmissionHandler, public void operationComplete(OperationResult operationResult) { ChangeTableWhy why = ChangeTableWhy.TABLEUPDATED; ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent( - ChangeTableRequestType.STATISTICALOPERATION, operationResult.getTrId(), why); + ChangeTableRequestType.STATISTICALOPERATION, + operationResult.getTrId(), why); eventBus.fireEvent(changeTableRequestEvent); } @@ -119,10 +119,12 @@ public class TDSubmissionHandler implements SubmissionHandler, } @Override - public void operationStopped(OperationResult operationResult, String reason, String details) { + public void operationStopped(OperationResult operationResult, + String reason, String details) { ChangeTableWhy why = ChangeTableWhy.TABLECURATION; ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent( - ChangeTableRequestType.STATISTICALOPERATION, operationResult.getTrId(), why); + ChangeTableRequestType.STATISTICALOPERATION, + operationResult.getTrId(), why); eventBus.fireEvent(changeTableRequestEvent); }