Updated Denormalize

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-table-widget@98400 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-07-03 16:12:39 +00:00 committed by Giancarlo Panichi
parent 31b30c69de
commit 15038c1fed
9 changed files with 1015 additions and 11 deletions

View File

@ -0,0 +1,71 @@
package org.gcube.portlets.user.td.tablewidget.client.normalize;
import org.gcube.portlets.user.td.columnwidget.client.resources.ResourceBundle;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.widget.core.client.Window;
import com.sencha.gxt.widget.core.client.event.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
/**
*
* @author "Giancarlo Panichi"
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class DenormalizeDialog extends Window {
protected String WIDTH = "650px";
protected String HEIGHT = "530px";
protected EventBus eventBus;
protected DenormalizePanel normalizationPanel;
protected TRId trId;
public DenormalizeDialog(TRId trId, EventBus eventBus) {
super();
Log.debug("AddColumnDialog");
this.eventBus = eventBus;
this.trId=trId;
initWindow();
normalizationPanel = new DenormalizePanel(this, trId,eventBus);
add(normalizationPanel);
}
protected void initWindow() {
setWidth(WIDTH);
setHeight(HEIGHT);
setBodyBorder(false);
setResizable(false);
setClosable(true);
setModal(true);
forceLayoutOnResize = true;
getHeader().setIcon(ResourceBundle.INSTANCE.columnValue());
setHeadingText("Denormalization");
}
/**
* {@inheritDoc}
*/
@Override
protected void initTools() {
super.initTools();
closeBtn.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
close();
}
});
}
public void close() {
hide();
}
}

View File

@ -0,0 +1,395 @@
package org.gcube.portlets.user.td.tablewidget.client.normalize;
import java.util.ArrayList;
import org.gcube.portlets.user.td.columnwidget.client.progress.ProgressDialogListener;
import org.gcube.portlets.user.td.columnwidget.client.properties.ColumnDataPropertiesCombo;
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.normalization.DenormalizationSession;
import org.gcube.portlets.user.td.tablewidget.client.progress.DenormalizationProgressDialog;
import org.gcube.portlets.user.td.tablewidget.client.resources.ResourceBundle;
import org.gcube.portlets.user.td.tablewidget.client.util.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 com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.data.client.loader.RpcProxy;
import com.sencha.gxt.data.shared.LabelProvider;
import com.sencha.gxt.data.shared.ListStore;
import com.sencha.gxt.data.shared.loader.ListLoadConfig;
import com.sencha.gxt.data.shared.loader.ListLoadConfigBean;
import com.sencha.gxt.data.shared.loader.ListLoadResult;
import com.sencha.gxt.data.shared.loader.ListLoadResultBean;
import com.sencha.gxt.data.shared.loader.ListLoader;
import com.sencha.gxt.data.shared.loader.LoadResultListStoreBinding;
import com.sencha.gxt.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
import com.sencha.gxt.widget.core.client.event.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
import com.sencha.gxt.widget.core.client.form.ComboBox;
import com.sencha.gxt.widget.core.client.form.FieldLabel;
import com.sencha.gxt.widget.core.client.info.Info;
public class DenormalizePanel extends FramedPanel implements
ProgressDialogListener {
protected String WIDTH = "640px";
protected String HEIGHT = "520px";
protected TRId trId;
protected EventBus eventBus;
protected ArrayList<String> rows;
protected DenormalizationSession denormalizationSession;
protected ComboBox<ColumnData> comboValueColumn = null;
protected ComboBox<ColumnData> comboAttributeColumn = null;
protected ListStore<ColumnData> storeComboAttributeColumn;
protected ListLoader<ListLoadConfig, ListLoadResult<ColumnData>> loader;
protected FieldLabel comboAttributeColumnLabel;
protected TextButton denormalizeButton;
protected DenormalizeDialog parent;
protected ArrayList<ColumnData> columnsRetrieved;
public DenormalizePanel(DenormalizeDialog parent, TRId trId,
EventBus eventBus) {
this.parent = parent;
this.trId = trId;
this.eventBus = eventBus;
create();
}
public DenormalizePanel(TRId trId, EventBus eventBus) {
this.trId = trId;
this.eventBus = eventBus;
this.parent = null;
create();
}
protected void create() {
setWidth(WIDTH);
setHeight(HEIGHT);
setHeaderVisible(false);
setBodyBorder(false);
Log.debug("Create DenormalizationPanel(): [" + trId.toString() + "]");
ColumnDataPropertiesCombo propsColumnData = GWT
.create(ColumnDataPropertiesCombo.class);
// Combo Value Column
ListStore<ColumnData> storeComboValueColumn = new ListStore<ColumnData>(
propsColumnData.id());
Log.trace("StoreComboValueColumn created");
RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>>() {
public void load(ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<ColumnData>> callback) {
loadData(loadConfig, callback);
}
};
loader = new ListLoader<ListLoadConfig, ListLoadResult<ColumnData>>(
proxy) {
@Override
protected ListLoadConfig newLoadConfig() {
return (ListLoadConfig) new ListLoadConfigBean();
}
};
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, ColumnData, ListLoadResult<ColumnData>>(
storeComboValueColumn));
Log.trace("LoaderCombo created");
comboValueColumn = new ComboBox<ColumnData>(storeComboValueColumn,
propsColumnData.label()) {
protected void onAfterFirstAttach() {
super.onAfterFirstAttach();
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute() {
loader.load();
}
});
}
};
Log.trace("Combo Value Column created");
addHandlersForComboColumn(propsColumnData.label());
comboValueColumn.setLoader(loader);
comboValueColumn.setEmptyText("Select a column...");
comboValueColumn.setWidth(191);
comboValueColumn.setTypeAhead(false);
comboValueColumn.setEditable(false);
comboValueColumn.setTriggerAction(TriggerAction.ALL);
// Combo Attribute Column
storeComboAttributeColumn = new ListStore<ColumnData>(
propsColumnData.id());
Log.trace("StoreComboAttributeColumn created");
// storeComboAttributeColumn.addAll(ColumnDataTypeStore.getAttributeType());
comboAttributeColumn = new ComboBox<ColumnData>(
storeComboAttributeColumn, propsColumnData.label());
Log.trace("ComboAttributeColumn created");
addHandlersForComboAttributeColumn(propsColumnData.label());
comboAttributeColumn.setEmptyText("Select a column...");
comboAttributeColumn.setWidth(191);
comboAttributeColumn.setTypeAhead(true);
comboAttributeColumn.setTriggerAction(TriggerAction.ALL);
comboAttributeColumnLabel = new FieldLabel(comboAttributeColumn,
"Attribute Column");
// Normalize Button
denormalizeButton = new TextButton("Denormalize");
denormalizeButton.setIcon(ResourceBundle.INSTANCE.tableDenormalize());
denormalizeButton.setIconAlign(IconAlign.RIGHT);
denormalizeButton.setTitle("Denormalize");
SelectHandler deleteHandler = new SelectHandler() {
public void onSelect(SelectEvent event) {
onDenormalize();
}
};
denormalizeButton.addSelectHandler(deleteHandler);
HBoxLayoutContainer hBox = new HBoxLayoutContainer();
hBox.add(denormalizeButton, new BoxLayoutData(new Margins(2, 5, 2, 5)));
VerticalLayoutContainer v = new VerticalLayoutContainer();
v.setScrollMode(ScrollMode.AUTO);
v.add(new FieldLabel(comboValueColumn, "Value Column"),
new VerticalLayoutData(1, -1, new Margins(1)));
v.add(comboAttributeColumnLabel, new VerticalLayoutData(1, -1,
new Margins(1)));
v.add(hBox, new VerticalLayoutData(-1, -1, new Margins(10, 0, 10, 0)));
add(v, new VerticalLayoutData(-1, -1, new Margins(0)));
comboAttributeColumnLabel.setVisible(false);
denormalizeButton.disable();
}
protected void addHandlersForComboColumn(
final LabelProvider<ColumnData> labelProvider) {
comboValueColumn
.addSelectionHandler(new SelectionHandler<ColumnData>() {
public void onSelection(SelectionEvent<ColumnData> event) {
Info.display(
"Value Column Selected",
"You selected "
+ (event.getSelectedItem() == null ? "nothing"
: labelProvider.getLabel(event
.getSelectedItem())
+ "!"));
Log.debug("ComboValueColumn selected: "
+ event.getSelectedItem());
ColumnData valueColumn = event.getSelectedItem();
updateComboValueColumn(valueColumn);
}
});
}
protected void addHandlersForComboAttributeColumn(
final LabelProvider<ColumnData> labelProvider) {
comboAttributeColumn
.addSelectionHandler(new SelectionHandler<ColumnData>() {
public void onSelection(SelectionEvent<ColumnData> event) {
Info.display(
"Attribute Column Selected",
"You selected "
+ (event.getSelectedItem() == null ? "nothing"
: labelProvider.getLabel(event
.getSelectedItem())
+ "!"));
Log.debug("ComboAttributeColumn selected: "
+ event.getSelectedItem());
ColumnData attributeColumn = event.getSelectedItem();
updateComboAttributeColumn(attributeColumn);
}
});
}
protected void updateComboValueColumn(ColumnData columnData) {
comboAttributeColumn.clear();
storeComboAttributeColumn.clear();
for(ColumnData c:columnsRetrieved){
if(c.getColumnId().compareTo(columnData.getColumnId())!=0){
storeComboAttributeColumn.add(c);
}
}
storeComboAttributeColumn.commitChanges();
comboAttributeColumnLabel.setVisible(true);
denormalizeButton.disable();
}
protected void updateComboAttributeColumn(ColumnData columnData) {
denormalizeButton.enable();
}
protected void resetComboStatus() {
comboAttributeColumn.clear();
storeComboAttributeColumn.clear();
storeComboAttributeColumn.commitChanges();
comboAttributeColumnLabel.setVisible(false);
denormalizeButton.disable();
}
protected void loadData(ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<ColumnData>> callback) {
TDGWTServiceAsync.INSTANCE.getColumns(trId,
new AsyncCallback<ArrayList<ColumnData>>() {
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error("load combo failure:"
+ caught.getLocalizedMessage());
UtilsGXT3.alert("Error",
"Error retrieving columns of tabular resource:"
+ trId.getId());
}
callback.onFailure(caught);
}
public void onSuccess(ArrayList<ColumnData> result) {
Log.trace("loaded " + result.size() + " ColumnData");
columnsRetrieved=result;
resetComboStatus();
callback.onSuccess(new ListLoadResultBean<ColumnData>(
result));
}
});
}
public void update(TRId trId) {
this.trId = trId;
loader.load();
}
protected void onDenormalize() {
ColumnData valueColumn = comboValueColumn.getCurrentValue();
if(valueColumn==null){
UtilsGXT3.alert("Attention", "Attention no value column selected!");
return;
}
ColumnData attributeColumn = comboAttributeColumn.getCurrentValue();
if(attributeColumn==null){
UtilsGXT3.alert("Attention", "Attention no attribute column selected!");
return;
}
denormalizationSession = new DenormalizationSession(trId, valueColumn,
attributeColumn);
TDGWTServiceAsync.INSTANCE.startDenormalization(denormalizationSession,
new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.debug("Denormalize Error: "
+ caught.getLocalizedMessage());
UtilsGXT3.alert("Error on Denormalize",
caught.getLocalizedMessage());
}
}
public void onSuccess(Void result) {
callDenormalizationProgressDialog();
}
});
}
public void close() {
if (parent != null) {
parent.close();
}
}
protected void callDenormalizationProgressDialog() {
DenormalizationProgressDialog denormalizeProgressDialog = new DenormalizationProgressDialog(
eventBus);
denormalizeProgressDialog.addProgressDialogListener(this);
denormalizeProgressDialog.show();
}
@Override
public void operationComplete(TRId trId) {
ChangeTableWhy why = ChangeTableWhy.TABLEUPDATED;
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.DENORMALIZE, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
close();
}
@Override
public void operationFailed(Throwable caught, String reason) {
UtilsGXT3.alert("Error in Denormalize", reason);
close();
}
@Override
public void operationStopped(TRId trId, String reason, String details) {
ChangeTableWhy why = ChangeTableWhy.TABLECURATION;
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.DENORMALIZE, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
close();
}
}

View File

@ -4,12 +4,10 @@ import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.user.td.columnwidget.client.progress.ProgressDialogListener;
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.normalization.NormalizationSession;
import org.gcube.portlets.user.td.tablewidget.client.progress.DuplicatesRowsProgressDialog;
import org.gcube.portlets.user.td.tablewidget.client.progress.NormalizationProgressDialog;
import org.gcube.portlets.user.td.tablewidget.client.properties.ColumnDataProperties;
import org.gcube.portlets.user.td.tablewidget.client.resources.ResourceBundle;
@ -63,7 +61,6 @@ public class NormalizePanel extends FramedPanel implements ProgressDialogListene
protected ArrayList<String> rows;
protected NormalizationSession normalizationSession;
protected DuplicatesRowsProgressDialog duplicatesRowsProgressDialog;
protected ListLoader<ListLoadConfig, ListLoadResult<ColumnData>> loader;
protected Grid<ColumnData> grid;

View File

@ -0,0 +1,103 @@
/**
*
*/
package org.gcube.portlets.user.td.tablewidget.client.progress;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
import com.sencha.gxt.widget.core.client.ProgressBar;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class DenormalizationProgressBarUpdater implements
DenormalizationProgressListener {
protected ProgressBar progressBar;
/**
* Creates a new {@link ProgressBar} updater.
*
* @param progressBar
* the {@link ProgressBar} to update.
*/
public DenormalizationProgressBarUpdater(ProgressBar progressBar) {
this.progressBar = progressBar;
}
/**
* {@inheritDoc}
*/
@Override
public void operationComplete(TRId trId) {
Log.info("Completed");
progressBar.updateProgress(1, "Completed");
}
/**
* {@inheritDoc}
*/
@Override
public void operationFailed(Throwable caught, String reason,
String failureDetails) {
Log.info("Failed");
progressBar.updateText("Failed");
}
@Override
public void operationInitializing() {
Log.info("Inizializing");
progressBar.updateProgress(0, "Initializing...");
}
@Override
public void operationUpdate(float elaborated) {
Log.info("Elaborated: " + elaborated);
if (elaborated == 0)
progressBar.updateProgress(0, "Initializing...");
if (elaborated > 0 && elaborated < 1) {
Log.trace("progress " + elaborated);
int elab = new Float(elaborated * 100).intValue();
progressBar.updateProgress(elaborated, elab + "% Progress...");
}
if (elaborated == 1)
progressBar.updateProgress(1, "Completing...");
}
@Override
public void operationValidate(float elaborated) {
Log.info("Validation Elaborated: " + elaborated);
if (elaborated == 0)
progressBar.updateProgress(0, "Start Validation...");
if (elaborated > 0 && elaborated < 1) {
Log.trace("Validation progress " + elaborated);
int elab = new Float(elaborated * 100).intValue();
progressBar.updateProgress(elaborated, elab
+ "% Validation Progress...");
}
if (elaborated == 1)
progressBar.updateProgress(1, "Validation...");
}
@Override
public void operationStopped(TRId trId, String reason, String details) {
Log.debug("Operation Stopped: [" + trId.toString() + ", " + reason
+ ", " + details + "]");
progressBar.updateText("Validations failed");
}
@Override
public void operationGeneratingView() {
Log.info("Generating View...");
progressBar.updateText("Generating View...");
}
}

View File

@ -0,0 +1,178 @@
package org.gcube.portlets.user.td.tablewidget.client.progress;
import java.util.ArrayList;
import org.gcube.portlets.user.td.columnwidget.client.progress.ProgressDialogListener;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
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 com.allen_sauer.gwt.log.client.Log;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.ProgressBar;
import com.sencha.gxt.widget.core.client.Window;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
import com.sencha.gxt.widget.core.client.event.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
/**
*
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class DenormalizationProgressDialog extends Window implements
DenormalizationProgressListener {
protected ArrayList<ProgressDialogListener> listeners = new ArrayList<ProgressDialogListener>();
public static final int STATUS_POLLING_DELAY = 1000;
protected String WIDTH = "400px";
protected String HEIGHT = "120px";
protected EventBus eventBus;
protected DenormalizationProgressUpdater progressUpdater;
protected TextButton ok;
protected TRId trId;
private String reason;
private String details;
public DenormalizationProgressDialog(EventBus eventBus) {
this.eventBus = eventBus;
setWidth(WIDTH);
setHeight(HEIGHT);
setBodyBorder(false);
setResizable(true);
setModal(true);
setHeadingText("Denormalization Progress");
trId = null;
FramedPanel panel = new FramedPanel();
panel.setHeaderVisible(false);
panel.setBodyBorder(false);
VerticalLayoutContainer v = new VerticalLayoutContainer();
ProgressBar progressBar = new ProgressBar();
ok = new TextButton("OK");
ok.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
updateInvocation();
}
});
v.add(progressBar,
new VerticalLayoutData(1, 1, new Margins(5, 5, 5, 5)));
panel.add(v);
panel.addButton(ok);
add(panel);
progressUpdater = new DenormalizationProgressUpdater();
progressUpdater
.addListener(new DenormalizationProgressBarUpdater(progressBar));
progressUpdater.addListener(this);
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
show();
ok.setVisible(false);
}
public void addProgressDialogListener(ProgressDialogListener listener) {
listeners.add(listener);
}
public void removeProgressDialogListener(ProgressDialogListener listener) {
listeners.remove(listener);
}
@Override
public void operationInitializing() {
// TODO Auto-generated method stub
}
@Override
public void operationUpdate(float elaborated) {
// TODO Auto-generated method stub
}
@Override
public void operationComplete(TRId trId) {
Log.debug("Operation Complete return: " + trId.toString());
this.trId = trId;
fireOperationComplete(trId);
hide();
}
@Override
public void operationFailed(Throwable caught, String reason,
String failureDetails) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
fireOperationFailed(caught, reason);
hide();
}
}
public void updateInvocation() {
if (trId != null) {
fireOperationStopped(trId, reason, details);
}
hide();
}
@Override
public void operationStopped(TRId trId, String reason, String details) {
Log.debug("Operation Stopped: [" + trId.toString() + ", " + reason
+ ", " + details + "]");
this.trId = trId;
this.reason = reason;
this.details = details;
ok.setVisible(true);
}
@Override
public void operationGeneratingView() {
// TODO Auto-generated method stub
}
@Override
public void operationValidate(float elaborated) {
// TODO Auto-generated method stub
}
protected void fireOperationComplete(TRId trId) {
for (ProgressDialogListener listener : listeners)
listener.operationComplete(trId);
}
protected void fireOperationFailed(Throwable caught, String reason) {
for (ProgressDialogListener listener : listeners)
listener.operationFailed(caught, reason);
}
protected void fireOperationStopped(TRId trId, String reason, String details) {
for (ProgressDialogListener listener : listeners)
listener.operationStopped(trId, reason, details);
}
}

View File

@ -0,0 +1,63 @@
/**
*
*/
package org.gcube.portlets.user.td.tablewidget.client.progress;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
/**
* Defines a listener for operation progress.
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public interface DenormalizationProgressListener {
/**
* Called when the operation is starting.
*/
public void operationInitializing();
/**
* Called when there is a progress for the operation.
* @param elaborated the elaborated part.
*/
public void operationUpdate(float elaborated);
/**
* Called when there is a validate for the operation.
* @param elaborated the elaborated part.
*/
public void operationValidate(float elaborated);
/**
* Called when the operation is complete.
*/
public void operationComplete(TRId trId);
/**
* Called when the operation is failed.
* @param caught the failure exception.
* @param reason the failure reason.
*/
public void operationFailed(Throwable caught, String reason, String failureDetails);
/**
* Called when the operation is stopped
*
* @param trId
* @param reason
* @param details
*/
public void operationStopped(TRId trId, String reason, String details);
/**
* Called when the operation is generating the view
*/
public void operationGeneratingView();
}

View File

@ -0,0 +1,195 @@
/**
*
*/
package org.gcube.portlets.user.td.tablewidget.client.progress;
import java.util.ArrayList;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.tr.normalization.DenormalizationMonitor;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class DenormalizationProgressUpdater extends Timer {
protected ArrayList<DenormalizationProgressListener> listeners = new ArrayList<DenormalizationProgressListener>();
/**
* {@inheritDoc}
*/
@Override
public void run() {
Log.debug("requesting operation progress");
TDGWTServiceAsync.INSTANCE
.getDenormalizationMonitor(new AsyncCallback<DenormalizationMonitor>() {
public void onFailure(Throwable caught) {
cancel();
Log.error("Error retrieving the operation state",
caught);
String message = getStack(caught);
fireOperationFailed(caught,
"Failed getting operation updates", message);
}
public void onSuccess(DenormalizationMonitor result) {
Log.info("retrieved DenormalizationMonitor: "
+ result.getStatus());
switch (result.getStatus()) {
case INITIALIZING:
Log.info("Initializing...");
fireOperationInitializing();
break;
case ABORTED:
cancel();
Log.info("Aborted");
break;
case IN_PROGRESS:
fireOperationUpdate(result.getProgress());
break;
case VALIDATING_RULES:
fireOperationValidate(result.getProgress());
break;
case GENERATING_VIEW:
Log.info("Generating View...");
fireOperationGeneratingView();
break;
case STOPPED:
cancel();
stopMessage(result);
break;
case FAILED:
cancel();
errorMessage(result);
break;
case SUCCEDED:
cancel();
Log.info("Fisnish :"
+ result.getTrId());
fireOperationComplete(result.getTrId());
break;
default:
Log.info("Unknow State");
break;
}
}
});
}
protected void errorMessage(DenormalizationMonitor result) {
Log.info("Denormalize Failed");
Throwable th = null;
String failure = null;
String details = null;
if (result.getError() != null) {
th = result.getError();
failure = "Failed Client Library Denormalize";
details = result.getError().getLocalizedMessage();
} else {
th = new Throwable("Failed");
failure = "Failed Client Library Denormalize";
details = "Denormalize failed";
}
fireOperationFailed(th, failure, details);
}
protected void stopMessage(DenormalizationMonitor result) {
Log.info("Denormalize Stopped");
String failure = null;
String details = null;
if (result.getError() != null) {
failure = "Stopped denormalize";
details = result.getError().getLocalizedMessage();
} else {
failure = "Stopped denormalize";
details = "Denormalize stopped";
}
fireOperationStopped(result.getTrId(),failure, details);
}
protected String getStack(Throwable e) {
String message = e.getLocalizedMessage() + " -> <br>";
Throwable c = e.getCause();
if (c != null)
message += getStack(c);
return message;
}
protected void fireOperationInitializing() {
for (DenormalizationProgressListener listener : listeners)
listener.operationInitializing();
}
protected void fireOperationGeneratingView() {
for (DenormalizationProgressListener listener : listeners)
listener.operationGeneratingView();
}
protected void fireOperationUpdate(float elaborated) {
for (DenormalizationProgressListener listener : listeners)
listener.operationUpdate(elaborated);
}
protected void fireOperationValidate(float elaborated) {
for (DenormalizationProgressListener listener : listeners)
listener.operationValidate(elaborated);
}
protected void fireOperationComplete(TRId trId) {
for (DenormalizationProgressListener listener : listeners)
listener.operationComplete(trId);
}
protected void fireOperationFailed(Throwable caught, String failure,
String failureDetails) {
for (DenormalizationProgressListener listener : listeners)
listener.operationFailed(caught, failure, failureDetails);
}
protected void fireOperationStopped(TRId trId, String reason, String details) {
for (DenormalizationProgressListener listener : listeners)
listener.operationStopped(trId,reason, details);
}
/**
* Add a new {@link DenormalizationProgressListener} to this
* {@link DenormalizationProgressUpdater}.
*
* @param listener
* the listener to add.
*/
public void addListener(DenormalizationProgressListener listener) {
listeners.add(listener);
}
/**
* Removes the specified {@link DenormalizationProgressListener} from this
* {@link DenormalizationProgressUpdater}.
*
* @param listener
* the listener to remove.
*/
public void removeListener(DenormalizationProgressListener listener) {
listeners.remove(listener);
}
}

View File

@ -93,33 +93,33 @@ public class NormalizationProgressUpdater extends Timer {
}
protected void errorMessage(NormalizationMonitor result) {
Log.info("Normalization Failed");
Log.info("Normalize Failed");
Throwable th = null;
String failure = null;
String details = null;
if (result.getError() != null) {
th = result.getError();
failure = "Failed Client Library Normalization";
failure = "Failed Client Library Normalize";
details = result.getError().getLocalizedMessage();
} else {
th = new Throwable("Failed");
failure = "Failed Client Library Normalization";
details = "Normalization failed";
failure = "Failed Client Library Normalize";
details = "Normalize failed";
}
fireOperationFailed(th, failure, details);
}
protected void stopMessage(NormalizationMonitor result) {
Log.info("Normalization Stopped");
Log.info("Normalize Stopped");
String failure = null;
String details = null;
if (result.getError() != null) {
failure = "Stopped normalization";
failure = "Stopped normalize";
details = result.getError().getLocalizedMessage();
} else {
failure = "Stopped normalization";
details = "Normalization stopped";
failure = "Stopped normalize";
details = "Normalize stopped";
}
fireOperationStopped(result.getTrId(),failure, details);

View File

@ -394,6 +394,7 @@ public class ValidationsTasksPanel extends FramedPanel implements
ValidationDto v = (ValidationDto) d;
Log.debug("ValidationDto: [" + v.getId() + ", "
+ v.getDescription() + ", " + v.getValid() + ", "
+ v.getConditionCode() + ", " + v.getValidationColumnColumnId() + ", "
+ v.getInvocation() + "]");
if (v.getValid()) {
@ -511,6 +512,7 @@ public class ValidationsTasksPanel extends FramedPanel implements
ValidationDto v = (ValidationDto) selected;
Log.debug("ValidationDto: [" + v.getId() + ", "
+ v.getDescription() + ", " + v.getValid() + ", "
+ v.getConditionCode() + ", " + v.getValidationColumnColumnId() + ", "
+ v.getInvocation() + "]");
if (v.getInvocation() != null) {
if (v.getValid()) {