Updated OperationMonitor
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-monitor-widget@99251 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
80b1f97e7d
commit
b0b60bb661
|
@ -89,6 +89,7 @@ public class MonitorDialog extends Window implements MonitorUpdaterListener {
|
|||
|
||||
progressUpdater.addListener(this);
|
||||
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
|
||||
progressUpdater.
|
||||
show();
|
||||
ok.setVisible(false);
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ public class MonitorUpdater extends Timer implements MonitorDialogEventUIListene
|
|||
|
||||
public MonitorUpdater(OperationMonitorSession operationMonitorSession){
|
||||
this.operationMonitorSession=operationMonitorSession;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,34 +40,41 @@ public class MonitorUpdater extends Timer implements MonitorDialogEventUIListene
|
|||
|
||||
public void onFailure(Throwable caught) {
|
||||
cancel();
|
||||
|
||||
Log.error("Error retrieving the operation state",
|
||||
caught);
|
||||
String message = getStack(caught);
|
||||
fireOperationFailed(caught,
|
||||
fireMonitorFailed(caught,
|
||||
"Failed getting operation updates", message);
|
||||
}
|
||||
|
||||
public void onSuccess(OperationMonitor result) {
|
||||
Log.info("retrieved OperationMonitor: "
|
||||
+ result.getTask().getState());
|
||||
|
||||
if(result.isAbort()){
|
||||
cancel();
|
||||
|
||||
}
|
||||
|
||||
switch (result.getTask().getState()) {
|
||||
case INITIALIZING:
|
||||
Log.info("Initializing...");
|
||||
fireOperationInitializing();
|
||||
fireMonitorInitializing();
|
||||
break;
|
||||
case ABORTED:
|
||||
cancel();
|
||||
Log.info("Aborted");
|
||||
break;
|
||||
case IN_PROGRESS:
|
||||
fireOperationUpdate(result.getTask().getProgress());
|
||||
fireMonitorUpdate(result.getTask().getProgress());
|
||||
break;
|
||||
case VALIDATING_RULES:
|
||||
fireOperationValidate(result.getTask().getProgress());
|
||||
fireMonitorValidate(result.getTask().getProgress());
|
||||
break;
|
||||
case GENERATING_VIEW:
|
||||
Log.info("Generating View...");
|
||||
fireOperationGeneratingView();
|
||||
fireMonitorGeneratingView();
|
||||
break;
|
||||
case STOPPED:
|
||||
cancel();
|
||||
|
@ -80,7 +88,7 @@ public class MonitorUpdater extends Timer implements MonitorDialogEventUIListene
|
|||
cancel();
|
||||
Log.info("Fisnish :"
|
||||
+ result.getTrId());
|
||||
fireOperationComplete(result.getTrId());
|
||||
fireMonitorComplete(result.getTrId());
|
||||
break;
|
||||
default:
|
||||
Log.info("Unknow State");
|
||||
|
@ -98,34 +106,34 @@ public class MonitorUpdater extends Timer implements MonitorDialogEventUIListene
|
|||
protected void errorMessage(OperationMonitor result) {
|
||||
Log.info("Opration Failed");
|
||||
Throwable th;
|
||||
String failure = null;
|
||||
String reason = null;
|
||||
String details = null;
|
||||
if (result.getTask().getErrorCause() != null) {
|
||||
th = result.getTask().getErrorCause();
|
||||
failure = "Failed Client Library";
|
||||
reason = "Failed Client Library";
|
||||
details = result.getTask().getErrorCause().getLocalizedMessage();
|
||||
} else {
|
||||
th = new Throwable("Failed");
|
||||
failure = "Failed Client Library";
|
||||
th = new Throwable("Operation failed");
|
||||
reason = "Failed Client Library";
|
||||
details = "Operation failed";
|
||||
}
|
||||
|
||||
fireOperationFailed(th, failure, details);
|
||||
fireMonitorFailed(th, reason, details);
|
||||
}
|
||||
|
||||
protected void stopMessage(OperationMonitor result) {
|
||||
Log.info("Operation Stopped");
|
||||
String failure = null;
|
||||
String reason = null;
|
||||
String details = null;
|
||||
if (result.getTask().getErrorCause() != null) {
|
||||
failure = "Stopped Operation";
|
||||
reason = "Stopped Operation";
|
||||
details = result.getTask().getErrorCause().getLocalizedMessage();
|
||||
} else {
|
||||
failure = "Stopped Operation";
|
||||
reason = "Stopped Operation";
|
||||
details = "Operation stopped";
|
||||
}
|
||||
|
||||
fireOperationStopped(result.getTrId(),failure, details);
|
||||
fireMonitorStopped(result.getTrId(),reason, details);
|
||||
}
|
||||
|
||||
|
||||
|
@ -137,38 +145,38 @@ public class MonitorUpdater extends Timer implements MonitorDialogEventUIListene
|
|||
return message;
|
||||
}
|
||||
|
||||
protected void fireOperationInitializing() {
|
||||
protected void fireMonitorInitializing() {
|
||||
for (MonitorUpdaterListener listener : listeners)
|
||||
listener.monitorInitializing();
|
||||
}
|
||||
|
||||
protected void fireOperationGeneratingView() {
|
||||
protected void fireMonitorGeneratingView() {
|
||||
for (MonitorUpdaterListener listener : listeners)
|
||||
listener.monitorGeneratingView();
|
||||
}
|
||||
|
||||
protected void fireOperationUpdate(float elaborated) {
|
||||
protected void fireMonitorUpdate(float elaborated) {
|
||||
for (MonitorUpdaterListener listener : listeners)
|
||||
listener.monitorUpdate(elaborated);
|
||||
}
|
||||
|
||||
protected void fireOperationValidate(float elaborated) {
|
||||
protected void fireMonitorValidate(float elaborated) {
|
||||
for (MonitorUpdaterListener listener : listeners)
|
||||
listener.monitorValidate(elaborated);
|
||||
}
|
||||
|
||||
protected void fireOperationComplete(TRId trId) {
|
||||
protected void fireMonitorComplete(TRId trId) {
|
||||
for (MonitorUpdaterListener listener : listeners)
|
||||
listener.monitorComplete(trId);
|
||||
}
|
||||
|
||||
protected void fireOperationFailed(Throwable caught, String failure,
|
||||
protected void fireMonitorFailed(Throwable caught, String failure,
|
||||
String failureDetails) {
|
||||
for (MonitorUpdaterListener listener : listeners)
|
||||
listener.monitorFailed(caught, failure, failureDetails);
|
||||
}
|
||||
|
||||
protected void fireOperationStopped(TRId trId, String reason, String details) {
|
||||
protected void fireMonitorStopped(TRId trId, String reason, String details) {
|
||||
for (MonitorUpdaterListener listener : listeners)
|
||||
listener.monitorStopped(trId,reason, details);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue