Initial import.

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/data-miner-executor@176720 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2019-01-21 17:40:17 +00:00
parent 6fd062f35f
commit 6071805018
1 changed files with 49 additions and 81 deletions

View File

@ -50,7 +50,8 @@ public class ComputationStatusPanel extends SimpleContainer {
/**
*
* @param operatorName operator name
* @param operatorName
* operator name
*/
public ComputationStatusPanel(String operatorName) {
super();
@ -66,8 +67,7 @@ public class ComputationStatusPanel extends SimpleContainer {
private void create() {
vert = new VerticalLayoutContainer();
HtmlLayoutContainer title = new HtmlLayoutContainer(
"<div class='computationStatusTitle'><p>Computation of <b>"
+ operatorName + "</b></p></div>");
"<div class='computationStatusTitle'><p>Computation of <b>" + operatorName + "</b></p></div>");
vert.add(title, new VerticalLayoutData(-1, -1, new Margins(0)));
add(vert);
forceLayout();
@ -86,8 +86,10 @@ public class ComputationStatusPanel extends SimpleContainer {
*/
// vert.add(date, new VerticalLayoutData(-1, -1, new Margins(0)));
vert.add(new HtmlLayoutContainer("<p>Created, the id is "
+ computationId.getId() + "</p>"));
vert.add(new HtmlLayoutContainer("<p>Created, the id is " + computationId.getId() + "</p>"));
vert.add(new HtmlLayoutContainer("<p>DataMiner&gt;Computations&gt;"
+ computationId.getOperatorName().toUpperCase() + "_ID_" + computationId.getId() + "</p>"));
TextButton equivalentRequestBtn = new TextButton();
equivalentRequestBtn.setText("Show");
@ -101,8 +103,7 @@ public class ComputationStatusPanel extends SimpleContainer {
});
FieldLabel equivalentRequestLabel = new FieldLabel(
equivalentRequestBtn, "Equivalent Get Request");
FieldLabel equivalentRequestLabel = new FieldLabel(equivalentRequestBtn, "Equivalent Get Request");
equivalentRequestLabel.setLabelWidth(140);
// vert.add(equivalentRequestLabel, new VerticalLayoutData(-1, -1,
// new Margins(0)));
@ -123,24 +124,20 @@ public class ComputationStatusPanel extends SimpleContainer {
}
});
cancelComputationBtn.getElement().getStyle()
.setMarginBottom(36, Unit.PX);
cancelComputationBtn.getElement().getStyle().setMarginBottom(36, Unit.PX);
vert.add(cancelComputationBtn, new VerticalLayoutData(-1, -1,
new Margins(0)));
vert.add(cancelComputationBtn, new VerticalLayoutData(-1, -1, new Margins(0)));
forceLayout();
timer.scheduleRepeating(Constants.TIME_UPDATE_COMPUTATION_STATUS_PANEL);
}
private void showEquivalentRequestDialog() {
EquivalentRequestDialog equivalentRequestDialog = new EquivalentRequestDialog(
computationId);
EquivalentRequestDialog equivalentRequestDialog = new EquivalentRequestDialog(computationId);
equivalentRequestDialog.show();
}
private void cancelComputation() {
CancelComputationExecutionRequestEvent event = new CancelComputationExecutionRequestEvent(
computationId);
CancelComputationExecutionRequestEvent event = new CancelComputationExecutionRequestEvent(computationId);
EventBusProvider.INSTANCE.fireEvent(event);
}
@ -149,8 +146,7 @@ public class ComputationStatusPanel extends SimpleContainer {
* @param operator
*
*/
private void computationTerminated(ComputationId computationId,
ComputationStatus computationStatus) {
private void computationTerminated(ComputationId computationId, ComputationStatus computationStatus) {
Log.debug("Computation Terminated");
Log.debug("Computation Status:" + computationStatus);
if (terminated == false) {
@ -158,17 +154,14 @@ public class ComputationStatusPanel extends SimpleContainer {
cancelComputationBtn.setVisible(false);
if (computationStatus.isComplete()) {
Log.debug("Computation is Complete");
Info.display("Terminated",
"The computation " + computationId.getId() + " of "
+ computationId.getOperatorName()
+ " is terminated correctly.");
Info.display("Terminated", "The computation " + computationId.getId() + " of "
+ computationId.getOperatorName() + " is terminated correctly.");
int index = vert.getWidgetIndex(progressBar);
vert.remove(index);
// TODO
progressBar = new GreenProgressBar();
progressBar.updateProgress(1, "Computation Complete");
vert.insert(progressBar, index, new VerticalLayoutData(1, -1,
new Margins(20)));
vert.insert(progressBar, index, new VerticalLayoutData(1, -1, new Margins(20)));
showComputationCompletedOutput();
} else if (computationStatus.isFailed()) {
Log.debug("Computation is Failed");
@ -176,49 +169,37 @@ public class ComputationStatusPanel extends SimpleContainer {
if (computationStatus.getError() == null) {
errorMessage = new String("Computation Failed!");
} else {
errorMessage = computationStatus.getError()
.getLocalizedMessage();
errorMessage = computationStatus.getError().getLocalizedMessage();
ElementsHighlights el = new ElementsHighlights();
errorMessage = el.createLinkFromText(errorMessage);
}
Info.display("Failed",
"The computation " + computationId.getId() + " of "
+ computationId.getOperatorName()
+ " is failed.");
UtilsGXT3.alert("Failed",
"The computation " + computationId.getId() + " of "
+ computationId.getOperatorName()
+ " has failed.</br>" + errorMessage);
Info.display("Failed", "The computation " + computationId.getId() + " of "
+ computationId.getOperatorName() + " is failed.");
UtilsGXT3.alert("Failed", "The computation " + computationId.getId() + " of "
+ computationId.getOperatorName() + " has failed.</br>" + errorMessage);
int index = vert.getWidgetIndex(progressBar);
vert.remove(index);
// TODO
progressBar = new RedProgressBar();
progressBar.updateProgress(1, "Computation Fail");
progressBar.getElement().getStyle()
.setMarginBottom(36, Unit.PX);
vert.insert(progressBar, index, new VerticalLayoutData(1, -1,
new Margins(20)));
progressBar.getElement().getStyle().setMarginBottom(36, Unit.PX);
vert.insert(progressBar, index, new VerticalLayoutData(1, -1, new Margins(20)));
} else if (computationStatus.isCancelled()) {
Log.debug("Computation Cancelled");
String errorMessage;
errorMessage = new String("Computation Cancelled!");
Info.display("Info", "The computation " + computationId.getId()
+ " of " + computationId.getOperatorName()
+ " has been cancelled.");
UtilsGXT3.info("Info",
"The computation " + computationId.getId() + " of "
+ computationId.getOperatorName()
+ " has been cancelled.</br>" + errorMessage);
Info.display("Info", "The computation " + computationId.getId() + " of "
+ computationId.getOperatorName() + " has been cancelled.");
UtilsGXT3.info("Info", "The computation " + computationId.getId() + " of "
+ computationId.getOperatorName() + " has been cancelled.</br>" + errorMessage);
int index = vert.getWidgetIndex(progressBar);
vert.remove(index);
// TODO
progressBar = new OrangeProgressBar();
progressBar.updateProgress(1, "Computation Cancelled");
progressBar.getElement().getStyle()
.setMarginBottom(36, Unit.PX);
vert.insert(progressBar, index, new VerticalLayoutData(1, -1,
new Margins(20)));
progressBar.getElement().getStyle().setMarginBottom(36, Unit.PX);
vert.insert(progressBar, index, new VerticalLayoutData(1, -1, new Margins(20)));
}
}
@ -231,16 +212,11 @@ public class ComputationStatusPanel extends SimpleContainer {
*/
private void showComputationCompletedOutput() {
HtmlLayoutContainer computationEndMessage = new HtmlLayoutContainer(
"<p>The computation <b>" + computationId.getOperatorName()
+ "</b> finished.</p>");
vert.add(computationEndMessage, new VerticalLayoutData(-1, -1,
new Margins(0)));
ComputationOutputPanel computationOutputPanel = new ComputationOutputPanel(
computationId);
computationOutputPanel.getElement().getStyle()
.setMarginBottom(36, Unit.PX);
vert.add(computationOutputPanel, new VerticalLayoutData(1, -1,
new Margins(0)));
"<p>The computation <b>" + computationId.getOperatorName() + "</b> finished.</p>");
vert.add(computationEndMessage, new VerticalLayoutData(-1, -1, new Margins(0)));
ComputationOutputPanel computationOutputPanel = new ComputationOutputPanel(computationId);
computationOutputPanel.getElement().getStyle().setMarginBottom(36, Unit.PX);
vert.add(computationOutputPanel, new VerticalLayoutData(1, -1, new Margins(0)));
}
@ -248,8 +224,7 @@ public class ComputationStatusPanel extends SimpleContainer {
* @param computationStatus
*/
private void updateStatus(ComputationStatus computationStatus) {
Log.debug("Conputation Status Panel ::Update Status "
+ computationStatus);
Log.debug("Conputation Status Panel ::Update Status " + computationStatus);
if (computationStatus.getStatus().compareTo(Status.ACCEPTED) == 0)
progressBar.updateText("Accepted...");
else {
@ -257,8 +232,7 @@ public class ComputationStatusPanel extends SimpleContainer {
if (percentage == 0) {
progressBar.updateText("Running, 0% Complete");
} else {
progressBar.updateProgress(percentage / 100, "Running, "
+ percentage + "% Complete");
progressBar.updateProgress(percentage / 100, "Running, " + percentage + "% Complete");
}
}
forceLayout();
@ -269,8 +243,8 @@ public class ComputationStatusPanel extends SimpleContainer {
@Override
public void run() {
Log.debug("Timer run .....");
DataMinerExecutorServiceAsync.INSTANCE.getComputationStatus(
computationId, new AsyncCallback<ComputationStatus>() {
DataMinerExecutorServiceAsync.INSTANCE.getComputationStatus(computationId,
new AsyncCallback<ComputationStatus>() {
@Override
public void onFailure(Throwable caught) {
@ -278,25 +252,19 @@ public class ComputationStatusPanel extends SimpleContainer {
vert.remove(index);
// TODO
progressBar = new RedProgressBar();
progressBar.updateProgress(1,
"Failed to get the status");
progressBar.getElement().getStyle()
.setMarginBottom(36, Unit.PX);
vert.insert(progressBar, index,
new VerticalLayoutData(1, -1, new Margins(
20)));
progressBar.updateProgress(1, "Failed to get the status");
progressBar.getElement().getStyle().setMarginBottom(36, Unit.PX);
vert.insert(progressBar, index, new VerticalLayoutData(1, -1, new Margins(20)));
}
@Override
public void onSuccess(
ComputationStatus computationStatus) {
public void onSuccess(ComputationStatus computationStatus) {
Log.debug("ComputationStatus: " + computationStatus);
if (computationStatus != null) {
if (computationStatus.isTerminated()) {
ComputationTimer.this.cancel();
computationTerminated(computationId,
computationStatus);
computationTerminated(computationId, computationStatus);
} else
updateStatus(computationStatus);
}