2521: Explore the possibility to port the StatMan interface onto Dataminer

https://support.d4science.org/issues/2521

Updated shows results for computations

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/data-miner-manager@128562 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2016-05-11 16:04:50 +00:00
parent 8944d6dd0a
commit 7ab1d64685
4 changed files with 305 additions and 95 deletions

View File

@ -72,14 +72,15 @@ public class ComputationsExecutedPanel extends FramedPanel {
}
private void init() {
setId("ComputationsPanel");
setItemId("ComputationsExecutedPanel");
forceLayoutOnResize = true;
setBodyBorder(true);
setBodyBorder(false);
setBorders(false);
setBodyStyle("backgroundColor:white;");
setHeaderVisible(true);
setResize(true);
setAnimCollapse(false);
setHeadingText("Computations");
setHeadingText("Computations Executed");
}

View File

@ -3,10 +3,15 @@
*/
package org.gcube.portlets.user.dataminermanager.client.computations;
import org.gcube.portlets.user.dataminermanager.client.common.EventBusProvider;
import org.gcube.portlets.user.dataminermanager.client.events.ComputationDataEvent;
import com.allen_sauer.gwt.log.client.Log;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.FramedPanel;
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.container.BorderLayoutContainer;
import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer.BorderLayoutData;
import com.sencha.gxt.widget.core.client.container.MarginData;
/**
*
@ -15,11 +20,15 @@ import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.Verti
*
*/
public class ComputationsPanel extends FramedPanel {
private ComputationsExecutedPanel computationsExecutedPanel;
private ComputationsViewerPanel computationsViewerPanel;
public ComputationsPanel() {
super();
init();
create();
bind();
}
private void init() {
@ -28,14 +37,49 @@ public class ComputationsPanel extends FramedPanel {
setHeadingText("Computations");
setHeaderVisible(true);
}
private void bind(){
EventBusProvider.INSTANCE.addHandler(ComputationDataEvent.getType(),
new ComputationDataEvent.ComputationDataEventHandler() {
@Override
public void onComputationData(ComputationDataEvent event) {
Log.debug("Catch ComputationDataEvent: " + event);
showComputationsViewer(event);
}
});
}
private void showComputationsViewer(ComputationDataEvent event) {
if(computationsViewerPanel.isCollapsed()){
computationsViewerPanel.expand();
}
}
private void create() {
VerticalLayoutContainer v = new VerticalLayoutContainer();
ComputationsExecutedPanel importedDataPanel = new ComputationsExecutedPanel();
ComputationsViewerPanel computedDataPanel = new ComputationsViewerPanel();
v.add(importedDataPanel, new VerticalLayoutData(1, 0.5, new Margins(0)));
v.add(computedDataPanel, new VerticalLayoutData(1, 0.5, new Margins(0)));
add(v);
computationsExecutedPanel = new ComputationsExecutedPanel();
computationsViewerPanel = new ComputationsViewerPanel();
MarginData centerData = new MarginData(0);
BorderLayoutData southData = new BorderLayoutData(0.5);
southData.setMargins(new Margins(0));
southData.setCollapsible(true);
southData.setSplit(true);
southData.setCollapsed(true);
BorderLayoutContainer borderLayoutContainer = new BorderLayoutContainer();
borderLayoutContainer.setCenterWidget(computationsExecutedPanel, centerData);
borderLayoutContainer.setSouthWidget(computationsViewerPanel, southData);
add(borderLayoutContainer, new MarginData(new Margins(0)));
}
}

View File

@ -1,5 +1,6 @@
package org.gcube.portlets.user.dataminermanager.client.computations;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import org.gcube.portlets.user.dataminermanager.client.common.EventBusProvider;
@ -12,10 +13,17 @@ import org.gcube.portlets.user.dataminermanager.shared.data.ComputationData;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.RequestException;
import com.google.gwt.http.client.Response;
import com.google.gwt.http.client.URL;
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.container.HtmlLayoutContainer;
import com.sencha.gxt.widget.core.client.container.MarginData;
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
@ -34,6 +42,8 @@ public class ComputationsViewerPanel extends FramedPanel {
private VerticalLayoutContainer v;
private ComputationData computationData;
private ArrayList<String> urlList;
private LinkedHashMap<String, String> urlFileNameMap;
public ComputationsViewerPanel() {
super();
@ -47,9 +57,10 @@ public class ComputationsViewerPanel extends FramedPanel {
}
private void init() {
setId("ComputationsViewerPanel");
setItemId("ComputationsViewerPanel");
forceLayoutOnResize = true;
setBodyBorder(true);
setBodyBorder(false);
setBorders(false);
setBodyStyle("backgroundColor:white;");
setHeaderVisible(true);
setResize(true);
@ -162,12 +173,12 @@ public class ComputationsViewerPanel extends FramedPanel {
public void resetPanel() {
v.clear();
SimpleContainer sectionTitle=new SimpleContainer();
HtmlLayoutContainer title=new HtmlLayoutContainer(
SimpleContainer sectionTitle = new SimpleContainer();
HtmlLayoutContainer title = new HtmlLayoutContainer(
"<br><center>No computation selected.</center>");
sectionTitle.add(title);
v.add(sectionTitle, new VerticalLayoutData(-1, -1, new Margins(15)));
computationData=null;
v.add(sectionTitle, new VerticalLayoutData(-1, -1, new Margins(20)));
computationData = null;
forceLayout();
}
@ -177,133 +188,287 @@ public class ComputationsViewerPanel extends FramedPanel {
addComputationData();
}
/**
*
*/
private void addComputationData() {
if(computationData==null){
}
private void createView(){
if (computationData == null) {
Log.error("ComputationData is null!");
UtilsGXT3.alert("Error", "No information on computation is retrieved!");
UtilsGXT3.alert("Error",
"No information on computation is retrieved!");
return;
}
SimpleContainer sectionTitle=new SimpleContainer();
SimpleContainer sectionTitle = new SimpleContainer();
// title
HtmlLayoutContainer title = new HtmlLayoutContainer(
".: Computation Report of <b>" + computationData.getComputationId().getId() + "</b>");
sectionTitle.add(title);
//v.add(sectionTitle, new VerticalLayoutData(1, -1, new Margins(15)));
if(computationData.getOutputParameters()!=null&&!computationData.getOutputParameters().isEmpty()){
VerticalLayoutContainer outputVBox=new VerticalLayoutContainer();
LinkedHashMap<String,String> output=computationData.getOutputParameters();
for(String key:output.keySet()){
TextField textField=new TextField();
"<center>.: Computation Report of <b>"
+ computationData.getComputationId().getId()
+ "</b></center>");
sectionTitle.add(title, new MarginData());
sectionTitle.getElement().getStyle().setMarginRight(20, Unit.PX);
// v.add(sectionTitle, new VerticalLayoutData(1, -1, new Margins(0)));
v.add(sectionTitle, new VerticalLayoutData(-1, -1, new Margins(10)));
if (computationData.getOutputParameters() != null
&& !computationData.getOutputParameters().isEmpty()) {
VerticalLayoutContainer outputVBox = new VerticalLayoutContainer();
LinkedHashMap<String, String> output = computationData
.getOutputParameters();
for (String key : output.keySet()) {
TextField textField = new TextField();
textField.setValue(output.get(key));
textField.setReadOnly(true);
FieldLabel fieldLabel=new FieldLabel(textField, key);
FieldLabel fieldLabel = new FieldLabel(textField, key);
fieldLabel.setLabelWidth(200);
fieldLabel.setLabelWordWrap(true);
outputVBox.add(fieldLabel,new VerticalLayoutData(1, -1, new Margins(4)));
outputVBox.add(fieldLabel, new VerticalLayoutData(1, -1,
new Margins(4)));
}
FieldSet outputFieldSet=new FieldSet();
FieldSet outputFieldSet = new FieldSet();
outputFieldSet.setHeadingText("Output Result");
outputFieldSet.setCollapsible(true);
outputFieldSet.add(outputVBox);
outputFieldSet.getElement().getStyle().setMarginRight(15, Unit.PX);
v.add(outputFieldSet, new VerticalLayoutData(1, -1, new Margins(15)));
outputFieldSet.getElement().getStyle().setMarginRight(20, Unit.PX);
v.add(outputFieldSet, new VerticalLayoutData(-1, -1,
new Margins(10)));
}
if(computationData.getInputParameters()!=null&&!computationData.getInputParameters().isEmpty()){
VerticalLayoutContainer inputVBox=new VerticalLayoutContainer();
LinkedHashMap<String,String> input=computationData.getInputParameters();
for(String key:input.keySet()){
TextField textField=new TextField();
if (computationData.getInputParameters() != null
&& !computationData.getInputParameters().isEmpty()) {
VerticalLayoutContainer inputVBox = new VerticalLayoutContainer();
LinkedHashMap<String, String> input = computationData
.getInputParameters();
for (String key : input.keySet()) {
TextField textField = new TextField();
textField.setValue(input.get(key));
textField.setReadOnly(true);
FieldLabel fieldLabel=new FieldLabel(textField, key);
FieldLabel fieldLabel = new FieldLabel(textField, key);
fieldLabel.setLabelWidth(200);
fieldLabel.setLabelWordWrap(true);
inputVBox.add(fieldLabel,new VerticalLayoutData(1, -1, new Margins(4)));
inputVBox.add(fieldLabel, new VerticalLayoutData(1, -1,
new Margins(4)));
}
FieldSet inputFieldSet=new FieldSet();
FieldSet inputFieldSet = new FieldSet();
inputFieldSet.setHeadingText("Input Parameters");
inputFieldSet.setCollapsible(true);
inputFieldSet.add(inputVBox);
inputFieldSet.getElement().getStyle().setMarginRight(15, Unit.PX);
v.add(inputFieldSet, new VerticalLayoutData(1, -1, new Margins(15)));
inputFieldSet.getElement().getStyle().setMarginRight(20, Unit.PX);
v.add(inputFieldSet,
new VerticalLayoutData(-1, -1, new Margins(10)));
}
VerticalLayoutContainer detailsVBox=new VerticalLayoutContainer();
TextField startDateField=new TextField();
VerticalLayoutContainer detailsVBox = new VerticalLayoutContainer();
TextField startDateField = new TextField();
startDateField.setValue(computationData.getStartDate());
startDateField.setReadOnly(true);
FieldLabel startDateLabel=new FieldLabel(startDateField, "Start Date");
FieldLabel startDateLabel = new FieldLabel(startDateField, "Start Date");
startDateLabel.setLabelWidth(200);
startDateLabel.setLabelWordWrap(true);
detailsVBox.add(startDateLabel,new VerticalLayoutData(1, -1, new Margins(4)));
TextField endDateField=new TextField();
detailsVBox.add(startDateLabel, new VerticalLayoutData(1, -1,
new Margins(4)));
TextField endDateField = new TextField();
endDateField.setValue(computationData.getEndDate());
endDateField.setReadOnly(true);
FieldLabel endDateLabel=new FieldLabel(endDateField, "End Date");
FieldLabel endDateLabel = new FieldLabel(endDateField, "End Date");
endDateLabel.setLabelWidth(200);
endDateLabel.setLabelWordWrap(true);
detailsVBox.add(endDateLabel,new VerticalLayoutData(1, -1, new Margins(4)));
TextField statusField=new TextField();
detailsVBox.add(endDateLabel, new VerticalLayoutData(1, -1,
new Margins(4)));
TextField statusField = new TextField();
statusField.setValue(computationData.getStatus());
statusField.setReadOnly(true);
FieldLabel statusLabel=new FieldLabel(statusField, "Status");
FieldLabel statusLabel = new FieldLabel(statusField, "Status");
statusLabel.setLabelWidth(200);
statusLabel.setLabelWordWrap(true);
detailsVBox.add(statusLabel,new VerticalLayoutData(1, -1, new Margins(4)));
TextField vreField=new TextField();
detailsVBox.add(statusLabel, new VerticalLayoutData(1, -1, new Margins(
4)));
TextField vreField = new TextField();
vreField.setValue(computationData.getVre());
vreField.setReadOnly(true);
FieldLabel vreLabel=new FieldLabel(vreField, "VRE");
FieldLabel vreLabel = new FieldLabel(vreField, "VRE");
vreLabel.setLabelWidth(200);
vreLabel.setLabelWordWrap(true);
detailsVBox.add(vreLabel,new VerticalLayoutData(1, -1, new Margins(4)));
FieldSet detailsFieldSet=new FieldSet();
detailsVBox
.add(vreLabel, new VerticalLayoutData(1, -1, new Margins(4)));
FieldSet detailsFieldSet = new FieldSet();
detailsFieldSet.setHeadingText("Computation Details");
detailsFieldSet.setCollapsible(true);
detailsFieldSet.add(detailsVBox);
detailsFieldSet.getElement().getStyle().setMarginRight(15, Unit.PX);
v.add(detailsFieldSet, new VerticalLayoutData(1, -1, new Margins(15)));
VerticalLayoutContainer operatorVBox=new VerticalLayoutContainer();
TextField operatorNameField=new TextField();
operatorNameField.setValue(computationData.getComputationId().getOperatorName());
detailsFieldSet.getElement().getStyle().setMarginRight(20, Unit.PX);
v.add(detailsFieldSet, new VerticalLayoutData(-1, -1, new Margins(10)));
VerticalLayoutContainer operatorVBox = new VerticalLayoutContainer();
TextField operatorNameField = new TextField();
operatorNameField.setValue(computationData.getComputationId()
.getOperatorName());
operatorNameField.setReadOnly(true);
FieldLabel operatorNameLabel=new FieldLabel(operatorNameField, "Operator Name");
FieldLabel operatorNameLabel = new FieldLabel(operatorNameField,
"Operator Name");
operatorNameLabel.setLabelWidth(200);
operatorNameLabel.setLabelWordWrap(true);
operatorVBox.add(operatorNameLabel,new VerticalLayoutData(1, -1, new Margins(4)));
TextArea operatorDescriptionField=new TextArea();
operatorDescriptionField.setHeight("50px");
operatorDescriptionField.setValue(computationData.getOperatorDescription());
operatorVBox.add(operatorNameLabel, new VerticalLayoutData(1, -1,
new Margins(4)));
TextArea operatorDescriptionField = new TextArea();
operatorDescriptionField.setHeight(40);
operatorDescriptionField.setValue(computationData
.getOperatorDescription());
operatorDescriptionField.setReadOnly(true);
FieldLabel operatorDescriptionLabel=new FieldLabel(operatorDescriptionField, "Operator Description");
FieldLabel operatorDescriptionLabel = new FieldLabel(
operatorDescriptionField, "Operator Description");
operatorDescriptionLabel.setLabelWidth(200);
operatorDescriptionLabel.setLabelWordWrap(true);
operatorVBox.add(operatorDescriptionLabel,new VerticalLayoutData(1, -1, new Margins(5)));
FieldSet operatorFieldSet=new FieldSet();
operatorDescriptionLabel.setHeight(50);
operatorVBox.add(operatorDescriptionLabel, new VerticalLayoutData(1,
-1, new Margins(5)));
FieldSet operatorFieldSet = new FieldSet();
operatorFieldSet.setHeadingText("Operator Details");
operatorFieldSet.setCollapsible(true);
operatorFieldSet.setHeight(130);
operatorFieldSet.add(operatorVBox);
operatorFieldSet.getElement().getStyle().setMarginRight(15, Unit.PX);
v.add(operatorFieldSet, new VerticalLayoutData(1, -1, new Margins(15)));
operatorFieldSet.getElement().getStyle().setMarginBottom(120, Unit.PX);
operatorFieldSet.getElement().getStyle().setMarginRight(20, Unit.PX);
v.add(operatorFieldSet, new VerticalLayoutData(-1, -1, new Margins(10)));
forceLayout();
}
/**
*
*/
private void createUrlList() {
urlList = new ArrayList<String>();
urlFileNameMap = new LinkedHashMap<String, String>();
if (computationData.getOutputParameters() != null
&& !computationData.getOutputParameters().isEmpty()) {
LinkedHashMap<String, String> output = computationData
.getOutputParameters();
for (String key : output.keySet()) {
String value = output.get(key);
if (value != null && !value.isEmpty() && value.startsWith("http")) {
urlList.add(value);
}
}
}
if (computationData.getInputParameters() != null
&& !computationData.getInputParameters().isEmpty()) {
LinkedHashMap<String, String> input = computationData
.getInputParameters();
for (String key : input.keySet()) {
String value = input.get(key);
if (value != null && !value.isEmpty()&& value.startsWith("http")) {
urlList.add(value);
}
}
}
if (!urlList.isEmpty()) {
retrieveUrlInformation(null);
} else {
}
}
private void retrieveUrlInformation(String url) {
if (url == null) {
if (urlList != null && !urlList.isEmpty()) {
retrieveFileName(urlList.get(0));
} else {
}
} else {
int index=urlList.indexOf(url);
if(index==-1){
} else {
if(index==urlList.size()-1){
} else {
retrieveFileName(urlList.get(index++));
}
}
}
}
private void retrieveFileName(final String url) {
try {
RequestBuilder builder = new RequestBuilder(RequestBuilder.HEAD,
URL.encode(url));
builder.sendRequest(null, new RequestCallback() {
@Override
public void onResponseReceived(Request request,
Response response) {
if (200 == response.getStatusCode()) {
String contentDisposition = response
.getHeader("Content-Disposition");
// ContentDisposition = "attachment; filename=abc.jpg"
if (contentDisposition != null
&& contentDisposition.indexOf("=") != -1) {
String fileName = contentDisposition.split("=")[1]; // getting
// value
// after
// '='
urlFileNameMap.put(url, fileName);
retrieveUrlInformation(url);
} else {
urlFileNameMap.put(url, null);
retrieveUrlInformation(url);
}
} else {
urlFileNameMap.put(url, null);
retrieveUrlInformation(url);
}
}
@Override
public void onError(Request request, Throwable exception) {
Log.error(exception.getLocalizedMessage());
exception.printStackTrace();
urlFileNameMap.put(url, null);
retrieveUrlInformation(url);
}
});
} catch (RequestException e) {
Log.error(e.getLocalizedMessage());
e.printStackTrace();
UtilsGXT3.alert("Error", "Error retrieving file name from public url!");
}
/*
* URL url = new URL("http://somesite/getFile?id=12345");
* HttpURLConnection conn = (HttpURLConnection) url.openConnection();
* conn.setRequestMethod("GET"); conn.setAllowUserInteraction(false);
* conn.setDoInput(true); conn.setDoOutput(true); conn.connect();
*
* String raw = conn.getHeaderField("Content-Disposition"); // raw =
* "attachment; filename=abc.jpg" if (raw != null && raw.indexOf("=") !=
* -1) { String fileName = raw.split("=")[1]; // getting value after '='
* } else { // fall back to random generated file name? }
*/
}
}

View File

@ -1240,8 +1240,8 @@ public class SClient4WPS extends SClient {
String operatorDescritpion = computationProperties
.get("operator_description");
String vre = computationProperties.get("VRE");
String startDate = computationProperties.get("startDate");
String endDate = computationProperties.get("endDate");
String startDate = computationProperties.get("start_date");
String endDate = computationProperties.get("end_date");
String status = computationProperties.get("status");
String executionType = computationProperties.get("execution_type");