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

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

Added Show Image to Computations Viewer

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/data-miner-manager@128580 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2016-05-12 17:20:39 +00:00
parent 7ab1d64685
commit 112931f5a9
40 changed files with 807 additions and 549717 deletions

View File

@ -39,7 +39,7 @@ public class DataMinerManager implements EntryPoint {
private DataMinerManagerController dataMinerManagerController;
private Header header;
private HomePanel homeMenu;
private HomePanel homePanel;
private DataSpacePanel dataSpacePanel;
private ExperimentPanel experimentPanel;
private ComputationsPanel computationsPanel;
@ -95,7 +95,7 @@ public class DataMinerManager implements EntryPoint {
private void loadMainPanel() {
dataMinerManagerController = new DataMinerManagerController();
homeMenu = new HomePanel();
homePanel = new HomePanel();
dataSpacePanel = new DataSpacePanel();
experimentPanel = new ExperimentPanel();
computationsPanel = new ComputationsPanel();
@ -126,8 +126,8 @@ public class DataMinerManager implements EntryPoint {
mainPanelLayout.setNorthWidget(header, menuData);
//
centerPanel.add(homeMenu);
previousPanel = homeMenu;
centerPanel.add(homePanel);
previousPanel = homePanel;
bindWindow(mainPanelLayout);
mainPanelLayout.forceLayout();
@ -207,7 +207,7 @@ public class DataMinerManager implements EntryPoint {
switchPanel(experimentPanel);
break;
case HOME:
switchPanel(homeMenu);
switchPanel(homePanel);
break;
default:
break;

View File

@ -29,9 +29,9 @@ import org.gcube.portlets.user.dataminermanager.client.type.DataMinerWorkAreaEve
import org.gcube.portlets.user.dataminermanager.client.type.MenuType;
import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3;
import org.gcube.portlets.user.dataminermanager.shared.Constants;
import org.gcube.portlets.user.dataminermanager.shared.data.ComputationData;
import org.gcube.portlets.user.dataminermanager.shared.data.ComputationId;
import org.gcube.portlets.user.dataminermanager.shared.data.OutputData;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationData;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationId;
import org.gcube.portlets.user.dataminermanager.shared.exception.ExpiredSessionServiceException;
import org.gcube.portlets.user.dataminermanager.shared.session.UserInfo;
import org.gcube.portlets.user.dataminermanager.shared.workspace.DataMinerWorkArea;
@ -644,6 +644,7 @@ public class DataMinerManagerController {
monitor.hide();
Log.error("Error in getComputationData: "
+ caught.getLocalizedMessage());
caught.printStackTrace();
UtilsGXT3
.alert("Error",
"Impossible to retrieve computation info. "

View File

@ -9,6 +9,7 @@ import com.google.gwt.event.dom.client.MouseDownHandler;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Image;
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.container.HorizontalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.HorizontalLayoutContainer.HorizontalLayoutData;
@ -31,6 +32,7 @@ public class HomePanel extends SimpleContainer {
}
private void init() {
setItemId("HomePanel");
setStylePrimaryName("smMenu");
//setBodyStyle("backgroundColor:white;");
addStyleName("smLayoutContainer");
@ -42,6 +44,7 @@ public class HomePanel extends SimpleContainer {
private void create() {
VerticalLayoutContainer lc = new VerticalLayoutContainer();
lc.setScrollMode(ScrollMode.AUTO);
VerticalLayoutData layoutTop = new VerticalLayoutData(-1, -1,
new Margins(20, 90, 10, 90));
VerticalLayoutData layoutNext = new VerticalLayoutData(-1, -1,

View File

@ -0,0 +1,66 @@
package org.gcube.portlets.user.dataminermanager.client.computations;
import org.gcube.portlets.user.dataminermanager.client.DataMinerManager;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationValueFile;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.container.HtmlLayoutContainer;
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;
import com.sencha.gxt.widget.core.client.event.SelectEvent;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ComputationValueFilePanel extends SimpleContainer {
private ComputationValueFile computationValueFile;
public ComputationValueFilePanel(ComputationValueFile computationValueFile) {
this.computationValueFile = computationValueFile;
init();
create();
}
private void init(){
setBorders(false);
}
private void create() {
VerticalLayoutContainer lc = new VerticalLayoutContainer();
final String fileName = computationValueFile.getFileName();
final String fileUrl = computationValueFile.getValue();
HtmlLayoutContainer fileNameHtml;
if (fileName != null) {
fileNameHtml = new HtmlLayoutContainer(
"<div class='computation-output-fileName'><p>"
+ new SafeHtmlBuilder().appendEscaped(fileName)
.toSafeHtml().asString() + "</p></div>");
} else {
fileNameHtml = new HtmlLayoutContainer(
"<div class='computation-output-fileName'><p>"
+ new SafeHtmlBuilder().appendEscaped("NoName")
.toSafeHtml().asString() + "</p></div>");
}
lc.add(fileNameHtml, new VerticalLayoutData(-1, -1, new Margins(0)));
TextButton downloadBtn = new TextButton("Download File");
downloadBtn.setIcon(DataMinerManager.resources.fileDownload());
downloadBtn.addSelectHandler(new SelectEvent.SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
com.google.gwt.user.client.Window.open(fileUrl, fileName, "");
}
});
lc.add(downloadBtn, new VerticalLayoutData(-1, -1, new Margins(0)));
add(lc);
}
}

View File

@ -0,0 +1,75 @@
package org.gcube.portlets.user.dataminermanager.client.computations;
import org.gcube.portlets.user.dataminermanager.client.DataMinerManager;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationValueImage;
import com.google.gwt.user.client.ui.Image;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.container.HtmlLayoutContainer;
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;
import com.sencha.gxt.widget.core.client.event.SelectEvent;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ComputationValueImagePanel extends SimpleContainer {
private ComputationValueImage computationValueImage;
public ComputationValueImagePanel(
ComputationValueImage computationValueImage) {
this.computationValueImage = computationValueImage;
init();
create();
}
private void init() {
setBorders(false);
}
private void create() {
VerticalLayoutContainer v = new VerticalLayoutContainer();
add(v);
if (computationValueImage == null
|| computationValueImage.getValue() == null
|| computationValueImage.getValue().isEmpty())
v.add(new HtmlLayoutContainer("<i>No image found.</i>"),
new VerticalLayoutData(-1, -1, new Margins(0)));
else {
HtmlLayoutContainer imageName;
if (computationValueImage.getFileName() == null
|| computationValueImage.getFileName().isEmpty()) {
imageName = new HtmlLayoutContainer("");
} else {
imageName = new HtmlLayoutContainer(
computationValueImage.getFileName());
}
v.add(imageName, new VerticalLayoutData(-1, -1, new Margins(0)));
TextButton saveImageBtn = new TextButton("Download Image");
saveImageBtn.setIcon(DataMinerManager.resources.save());
saveImageBtn.addSelectHandler(new SelectEvent.SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
com.google.gwt.user.client.Window.open(
computationValueImage.getValue(),
computationValueImage.getFileName(), "");
}
});
v.add(saveImageBtn, new VerticalLayoutData(-1, -1, new Margins(0)));
final Image img = new Image(computationValueImage.getValue());
v.add(img, new VerticalLayoutData(1, -1, new Margins(0)));
}
forceLayout();
}
}

View File

@ -5,6 +5,7 @@ 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 org.gcube.portlets.user.dataminermanager.client.events.RefreshDataMinerWorkAreaEvent;
import com.allen_sauer.gwt.log.client.Log;
import com.sencha.gxt.core.client.util.Margins;
@ -45,19 +46,57 @@ public class ComputationsPanel extends FramedPanel {
@Override
public void onComputationData(ComputationDataEvent event) {
Log.debug("Catch ComputationDataEvent: " + event);
showComputationsViewer(event);
expandsComputationsViewer();
}
});
EventBusProvider.INSTANCE
.addHandler(
RefreshDataMinerWorkAreaEvent.TYPE,
new RefreshDataMinerWorkAreaEvent.RefreshDataMinerWorkAreaEventHandler() {
@Override
public void onRefresh(
RefreshDataMinerWorkAreaEvent event) {
Log.debug("Catch RefreshDataMinerWorkAreaEvent: "
+ event);
manageRefreshDataMinerWorkAreaEvents(event);
}
});
}
private void manageRefreshDataMinerWorkAreaEvents(
RefreshDataMinerWorkAreaEvent event) {
switch (event.getDataMinerWorkAreaElementType()) {
case Computations:
collapseComputationsViewer();
break;
case InputDataSets:
break;
case OutputDataSets:
break;
default:
break;
}
private void showComputationsViewer(ComputationDataEvent event) {
}
private void collapseComputationsViewer() {
if(computationsViewerPanel.isExpanded()){
computationsViewerPanel.collapse();
}
forceLayout();
}
private void expandsComputationsViewer() {
if(computationsViewerPanel.isCollapsed()){
computationsViewerPanel.expand();
}
forceLayout();
}
private void create() {
@ -78,7 +117,7 @@ public class ComputationsPanel extends FramedPanel {
add(borderLayoutContainer, new MarginData(new Margins(0)));
forceLayout();
}

View File

@ -8,7 +8,7 @@ package org.gcube.portlets.user.dataminermanager.client.computations;
*/
public enum ComputationsProperties {
OPERATOR_DESCRIPTION("operator_description"), OPERATOR_NAME(
"operator_name:"), END_DATE("end_date"), ERROR("error"), COMPUTATION_ID(
"operator_name"), END_DATE("end_date"), ERROR("error"), COMPUTATION_ID(
"computation_id"), STATUS("status"), VRE("VRE"), EXECUTION_TYPE(
"execution_type"), START_DATE("start_date");

View File

@ -1,6 +1,5 @@
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;
@ -9,16 +8,13 @@ import org.gcube.portlets.user.dataminermanager.client.events.DataMinerWorkAreaE
import org.gcube.portlets.user.dataminermanager.client.events.RefreshDataMinerWorkAreaEvent;
import org.gcube.portlets.user.dataminermanager.client.events.UIStateEvent;
import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3;
import org.gcube.portlets.user.dataminermanager.shared.data.ComputationData;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationData;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationValue;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationValueFile;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationValueImage;
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;
@ -42,8 +38,6 @@ public class ComputationsViewerPanel extends FramedPanel {
private VerticalLayoutContainer v;
private ComputationData computationData;
private ArrayList<String> urlList;
private LinkedHashMap<String, String> urlFileNameMap;
public ComputationsViewerPanel() {
super();
@ -179,26 +173,19 @@ public class ComputationsViewerPanel extends FramedPanel {
sectionTitle.add(title);
v.add(sectionTitle, new VerticalLayoutData(-1, -1, new Margins(20)));
computationData = null;
v.forceLayout();
forceLayout();
}
private void showOutput(ComputationDataEvent event) {
v.clear();
computationData = event.getComputationData();
addComputationData();
createView();
v.forceLayout();
forceLayout();
}
private void addComputationData() {
}
private void createView(){
private void createView() {
if (computationData == null) {
Log.error("ComputationData is null!");
UtilsGXT3.alert("Error",
@ -209,7 +196,7 @@ public class ComputationsViewerPanel extends FramedPanel {
SimpleContainer sectionTitle = new SimpleContainer();
// title
HtmlLayoutContainer title = new HtmlLayoutContainer(
"<center>.: Computation Report of <b>"
"<center>Computation Report of <b>"
+ computationData.getComputationId().getId()
+ "</b></center>");
sectionTitle.add(title, new MarginData());
@ -219,98 +206,29 @@ public class ComputationsViewerPanel extends FramedPanel {
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.setLabelWidth(200);
fieldLabel.setLabelWordWrap(true);
outputVBox.add(fieldLabel, new VerticalLayoutData(1, -1,
new Margins(4)));
}
FieldSet outputFieldSet = new FieldSet();
outputFieldSet.setHeadingText("Output Result");
outputFieldSet.setCollapsible(true);
outputFieldSet.add(outputVBox);
outputFieldSet.getElement().getStyle().setMarginRight(20, Unit.PX);
FieldSet outputFieldSet = outputView();
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();
textField.setValue(input.get(key));
textField.setReadOnly(true);
FieldLabel fieldLabel = new FieldLabel(textField, key);
fieldLabel.setLabelWidth(200);
fieldLabel.setLabelWordWrap(true);
inputVBox.add(fieldLabel, new VerticalLayoutData(1, -1,
new Margins(4)));
}
FieldSet inputFieldSet = new FieldSet();
inputFieldSet.setHeadingText("Input Parameters");
inputFieldSet.setCollapsible(true);
inputFieldSet.add(inputVBox);
inputFieldSet.getElement().getStyle().setMarginRight(20, Unit.PX);
FieldSet inputFieldSet = inputView();
v.add(inputFieldSet,
new VerticalLayoutData(-1, -1, new Margins(10)));
}
VerticalLayoutContainer detailsVBox = new VerticalLayoutContainer();
TextField startDateField = new TextField();
startDateField.setValue(computationData.getStartDate());
startDateField.setReadOnly(true);
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();
endDateField.setValue(computationData.getEndDate());
endDateField.setReadOnly(true);
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();
statusField.setValue(computationData.getStatus());
statusField.setReadOnly(true);
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();
vreField.setValue(computationData.getVre());
vreField.setReadOnly(true);
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();
detailsFieldSet.setHeadingText("Computation Details");
detailsFieldSet.setCollapsible(true);
detailsFieldSet.add(detailsVBox);
detailsFieldSet.getElement().getStyle().setMarginRight(20, Unit.PX);
FieldSet detailsFieldSet = detailsView();
v.add(detailsFieldSet, new VerticalLayoutData(-1, -1, new Margins(10)));
FieldSet operatorFieldSet = operatorView();
v.add(operatorFieldSet, new VerticalLayoutData(-1, -1, new Margins(10)));
}
private FieldSet operatorView() {
VerticalLayoutContainer operatorVBox = new VerticalLayoutContainer();
TextField operatorNameField = new TextField();
operatorNameField.setValue(computationData.getComputationId()
@ -321,7 +239,7 @@ public class ComputationsViewerPanel extends FramedPanel {
operatorNameLabel.setLabelWidth(200);
operatorNameLabel.setLabelWordWrap(true);
operatorVBox.add(operatorNameLabel, new VerticalLayoutData(1, -1,
new Margins(4)));
new Margins(0,4,0,4)));
TextArea operatorDescriptionField = new TextArea();
operatorDescriptionField.setHeight(40);
@ -332,9 +250,9 @@ public class ComputationsViewerPanel extends FramedPanel {
operatorDescriptionField, "Operator Description");
operatorDescriptionLabel.setLabelWidth(200);
operatorDescriptionLabel.setLabelWordWrap(true);
operatorDescriptionLabel.setHeight(50);
operatorDescriptionLabel.setHeight(65);
operatorVBox.add(operatorDescriptionLabel, new VerticalLayoutData(1,
-1, new Margins(5)));
-1, new Margins(0,5,0,5)));
FieldSet operatorFieldSet = new FieldSet();
operatorFieldSet.setHeadingText("Operator Details");
@ -343,132 +261,145 @@ public class ComputationsViewerPanel extends FramedPanel {
operatorFieldSet.add(operatorVBox);
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 {
}
return operatorFieldSet;
}
private void retrieveUrlInformation(String url) {
if (url == null) {
if (urlList != null && !urlList.isEmpty()) {
retrieveFileName(urlList.get(0));
} else {
private FieldSet detailsView() {
VerticalLayoutContainer detailsVBox = new VerticalLayoutContainer();
TextField startDateField = new TextField();
startDateField.setValue(computationData.getStartDate());
startDateField.setReadOnly(true);
FieldLabel startDateLabel = new FieldLabel(startDateField, "Start Date");
startDateLabel.setLabelWidth(200);
startDateLabel.setLabelWordWrap(true);
detailsVBox.add(startDateLabel, new VerticalLayoutData(1, -1,
new Margins(0,4,0,4)));
TextField endDateField = new TextField();
endDateField.setValue(computationData.getEndDate());
endDateField.setReadOnly(true);
FieldLabel endDateLabel = new FieldLabel(endDateField, "End Date");
endDateLabel.setLabelWidth(200);
endDateLabel.setLabelWordWrap(true);
detailsVBox.add(endDateLabel, new VerticalLayoutData(1, -1,
new Margins(0,4,0,4)));
TextField statusField = new TextField();
statusField.setValue(computationData.getStatus());
statusField.setReadOnly(true);
FieldLabel statusLabel = new FieldLabel(statusField, "Status");
statusLabel.setLabelWidth(200);
statusLabel.setLabelWordWrap(true);
detailsVBox.add(statusLabel, new VerticalLayoutData(1, -1, new Margins(
0,4,0,4)));
TextField vreField = new TextField();
vreField.setValue(computationData.getVre());
vreField.setReadOnly(true);
FieldLabel vreLabel = new FieldLabel(vreField, "VRE");
vreLabel.setLabelWidth(200);
vreLabel.setLabelWordWrap(true);
detailsVBox
.add(vreLabel, new VerticalLayoutData(1, -1, new Margins(0,4,0,4)));
FieldSet detailsFieldSet = new FieldSet();
detailsFieldSet.setHeadingText("Computation Details");
detailsFieldSet.setCollapsible(true);
detailsFieldSet.add(detailsVBox);
detailsFieldSet.getElement().getStyle().setMarginRight(20, Unit.PX);
return detailsFieldSet;
}
private FieldSet inputView() {
VerticalLayoutContainer inputVBox = new VerticalLayoutContainer();
LinkedHashMap<String, ComputationValue> input = computationData
.getInputParameters();
for (String key : input.keySet()) {
ComputationValue computationValue = input.get(key);
FieldLabel fieldLabel = null;
SimpleContainer simpleContainer;
switch (computationValue.getType()) {
case File:
ComputationValueFile computationValueFile=(ComputationValueFile) computationValue;
simpleContainer=new ComputationValueFilePanel(computationValueFile);
fieldLabel = new FieldLabel(simpleContainer, key);
fieldLabel.setLabelWidth(200);
fieldLabel.setLabelWordWrap(true);
break;
case Image:
ComputationValueImage computationValueImage=(ComputationValueImage) computationValue;
simpleContainer=new ComputationValueImagePanel(computationValueImage);
fieldLabel = new FieldLabel(simpleContainer, key);
fieldLabel.setLabelWidth(200);
fieldLabel.setLabelWordWrap(true);
break;
case String:
default:
TextField textField = new TextField();
textField.setValue(computationValue.getValue());
textField.setReadOnly(true);
fieldLabel = new FieldLabel(textField, key);
fieldLabel.setLabelWidth(200);
fieldLabel.setLabelWordWrap(true);
break;
}
} else {
int index=urlList.indexOf(url);
if(index==-1){
} else {
if(index==urlList.size()-1){
} else {
retrieveFileName(urlList.get(index++));
}
}
inputVBox.add(fieldLabel, new VerticalLayoutData(1, -1,
new Margins(0,4,0,4)));
}
FieldSet inputFieldSet = new FieldSet();
inputFieldSet.setHeadingText("Input Parameters");
inputFieldSet.setCollapsible(true);
inputFieldSet.add(inputVBox);
inputFieldSet.getElement().getStyle().setMarginRight(20, Unit.PX);
return inputFieldSet;
}
private void retrieveFileName(final String url) {
private FieldSet outputView() {
VerticalLayoutContainer outputVBox = new VerticalLayoutContainer();
LinkedHashMap<String, ComputationValue> output = computationData
.getOutputParameters();
for (String key : output.keySet()) {
ComputationValue computationValue = output.get(key);
FieldLabel fieldLabel = null;
SimpleContainer simpleContainer;
switch (computationValue.getType()) {
case File:
ComputationValueFile computationValueFile=(ComputationValueFile) computationValue;
simpleContainer=new ComputationValueFilePanel(computationValueFile);
fieldLabel = new FieldLabel(simpleContainer, key);
fieldLabel.setLabelWidth(200);
fieldLabel.setLabelWordWrap(true);
break;
case Image:
ComputationValueImage computationValueImage=(ComputationValueImage) computationValue;
simpleContainer=new ComputationValueImagePanel(computationValueImage);
fieldLabel = new FieldLabel(simpleContainer, key);
fieldLabel.setLabelWidth(200);
fieldLabel.setLabelWordWrap(true);
break;
case String:
default:
TextField textField = new TextField();
textField.setValue(computationValue.getValue());
textField.setReadOnly(true);
fieldLabel = new FieldLabel(textField, key);
fieldLabel.setLabelWidth(200);
fieldLabel.setLabelWordWrap(true);
break;
try {
RequestBuilder builder = new RequestBuilder(RequestBuilder.HEAD,
URL.encode(url));
}
outputVBox.add(fieldLabel, new VerticalLayoutData(1, -1,
new Margins(0,4,0,4)));
}
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? }
*/
FieldSet outputFieldSet = new FieldSet();
outputFieldSet.setHeadingText("Output Result");
outputFieldSet.setCollapsible(true);
outputFieldSet.add(outputVBox);
outputFieldSet.getElement().getStyle().setMarginRight(20, Unit.PX);
return outputFieldSet;
}
}

View File

@ -1,6 +1,6 @@
package org.gcube.portlets.user.dataminermanager.client.events;
import org.gcube.portlets.user.dataminermanager.shared.data.ComputationId;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationId;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;

View File

@ -1,6 +1,6 @@
package org.gcube.portlets.user.dataminermanager.client.events;
import org.gcube.portlets.user.dataminermanager.shared.data.ComputationData;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationData;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;

View File

@ -1,6 +1,6 @@
package org.gcube.portlets.user.dataminermanager.client.events;
import org.gcube.portlets.user.dataminermanager.shared.data.ComputationId;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationId;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;

View File

@ -1,6 +1,6 @@
package org.gcube.portlets.user.dataminermanager.client.events;
import org.gcube.portlets.user.dataminermanager.shared.data.ComputationId;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationId;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;

View File

@ -1,6 +1,6 @@
package org.gcube.portlets.user.dataminermanager.client.events;
import org.gcube.portlets.user.dataminermanager.shared.data.ComputationId;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationId;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;

View File

@ -6,16 +6,16 @@ package org.gcube.portlets.user.dataminermanager.client.experiments;
import java.util.LinkedHashMap;
import java.util.Map;
import org.gcube.portlets.user.dataminermanager.client.DataMinerManager;
import org.gcube.portlets.user.dataminermanager.client.common.EventBusProvider;
import org.gcube.portlets.user.dataminermanager.client.events.OutputDataEvent;
import org.gcube.portlets.user.dataminermanager.client.events.OutputDataRequestEvent;
import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3;
import org.gcube.portlets.user.dataminermanager.client.widgets.ImagesViewer;
import org.gcube.portlets.user.dataminermanager.client.widgets.FileViewer;
import org.gcube.portlets.user.dataminermanager.client.widgets.ImageViewer;
import org.gcube.portlets.user.dataminermanager.client.widgets.ResourceViewer;
import org.gcube.portlets.user.dataminermanager.shared.data.ComputationId;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationId;
import org.gcube.portlets.user.dataminermanager.shared.data.output.FileResource;
import org.gcube.portlets.user.dataminermanager.shared.data.output.ImagesResource;
import org.gcube.portlets.user.dataminermanager.shared.data.output.ImageResource;
import org.gcube.portlets.user.dataminermanager.shared.data.output.MapResource;
import org.gcube.portlets.user.dataminermanager.shared.data.output.ObjectResource;
import org.gcube.portlets.user.dataminermanager.shared.data.output.Resource;
@ -25,15 +25,12 @@ import org.gcube.portlets.user.dataminermanager.shared.data.output.TableResource
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.sencha.gxt.core.client.XTemplates;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.container.HtmlLayoutContainer;
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;
import com.sencha.gxt.widget.core.client.event.SelectEvent;
/**
*
@ -128,10 +125,10 @@ public class ComputationOutputPanel extends SimpleContainer {
// new VerticalLayoutData(1, -1, new Margins(0)));
break;
case IMAGES:
case IMAGE:
v.add(getHtmlTitle("The algorithm produced an", "Set of Images"),
new VerticalLayoutData(1, -1, new Margins(0)));
final ImagesResource imagesResource = (ImagesResource) resource;
final ImageResource imagesResource = (ImageResource) resource;
v.add(getImagesResourceOutput(imagesResource),
new VerticalLayoutData(1, -1, new Margins(0)));
break;
@ -184,8 +181,8 @@ public class ComputationOutputPanel extends SimpleContainer {
* @return
*/
private SimpleContainer getImagesResourceOutput(
ImagesResource imagesResource) {
return new ImagesViewer(computationId, imagesResource);
ImageResource imagesResource) {
return new ImageViewer(computationId, imagesResource);
}
/**
@ -194,28 +191,7 @@ public class ComputationOutputPanel extends SimpleContainer {
* @return
*/
private SimpleContainer getFileResourceOutput(FileResource fileResource) {
VerticalLayoutContainer lc = new VerticalLayoutContainer();
SimpleContainer container = new SimpleContainer();
final String fileName = fileResource.getName();
final String fileUrl = fileResource.getUrl();
HtmlLayoutContainer fileNameHtml = new HtmlLayoutContainer(
"<div class='computation-output-fileName'><p>"
+ new SafeHtmlBuilder().appendEscaped(fileName)
.toSafeHtml().asString() + "</p></div>");
lc.add(fileNameHtml, new VerticalLayoutData(-1, -1, new Margins(0)));
TextButton downloadBtn = new TextButton("Download File");
downloadBtn.setIcon(DataMinerManager.resources.fileDownload());
downloadBtn.addSelectHandler(new SelectEvent.SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
com.google.gwt.user.client.Window.open(fileUrl, fileName, "");
}
});
lc.add(downloadBtn, new VerticalLayoutData(-1, -1, new Margins(0)));
container.add(lc);
return container;
return new FileViewer(computationId, fileResource);
}
/**
@ -230,7 +206,7 @@ public class ComputationOutputPanel extends SimpleContainer {
Map<String, ObjectResource> mapValues = new LinkedHashMap<>();
Map<String, FileResource> mapFiles = new LinkedHashMap<>();
Map<String, TableResource> mapTabs = new LinkedHashMap<>();
Map<String, ImagesResource> mapImages = new LinkedHashMap<>();
Map<String, ImageResource> mapImages = new LinkedHashMap<>();
for (String key : map.keySet()) {
Resource resource = map.get(key);
@ -246,8 +222,8 @@ public class ComputationOutputPanel extends SimpleContainer {
case TABULAR:
mapTabs.put(key, (TableResource) resource);
break;
case IMAGES:
mapImages.put(key, (ImagesResource) resource);
case IMAGE:
mapImages.put(key, (ImageResource) resource);
break;
case MAP:
break;

View File

@ -12,7 +12,7 @@ import org.gcube.portlets.user.dataminermanager.client.events.CancelComputationE
import org.gcube.portlets.user.dataminermanager.client.rpc.DataMinerPortletServiceAsync;
import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3;
import org.gcube.portlets.user.dataminermanager.shared.Constants;
import org.gcube.portlets.user.dataminermanager.shared.data.ComputationId;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationId;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.dom.client.Style.Unit;

View File

@ -84,7 +84,7 @@ public class OperatorsPanel extends FramedPanel {
}
private void init() {
setHeadingText(".: Operators");
setHeadingText("Operators");
setBodyStyle("backgroundColor:white;");
}

View File

@ -43,7 +43,7 @@ public class WorkflowPanel extends TabPanel {
private void create() {
TabItemConfig tabWorkFlowLcItemConf = new TabItemConfig(".: Operator",
TabItemConfig tabWorkFlowLcItemConf = new TabItemConfig("Operator",
false);
tabWorkFlowLcItemConf.setIcon(DataMinerManager.resources
.folderExplore());
@ -61,7 +61,7 @@ public class WorkflowPanel extends TabPanel {
add(computationPanel, tabWorkFlowLcItemConf);
TabItemConfig tabComputationPanelItemConf = new TabItemConfig(
".: Computations Execution", false);
"Computations Execution", false);
tabComputationPanelItemConf.setIcon(DataMinerManager.resources
.folderExplore());
computationExecutionPanel = new ComputationExecutionPanel();

View File

@ -5,10 +5,10 @@ import java.util.List;
import org.gcube.portlets.user.dataminermanager.client.bean.ComputationStatus;
import org.gcube.portlets.user.dataminermanager.client.bean.Operator;
import org.gcube.portlets.user.dataminermanager.client.bean.OperatorsClassification;
import org.gcube.portlets.user.dataminermanager.shared.data.ComputationData;
import org.gcube.portlets.user.dataminermanager.shared.data.ComputationId;
import org.gcube.portlets.user.dataminermanager.shared.data.OutputData;
import org.gcube.portlets.user.dataminermanager.shared.data.TableItemSimple;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationData;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationId;
import org.gcube.portlets.user.dataminermanager.shared.exception.ServiceException;
import org.gcube.portlets.user.dataminermanager.shared.parameters.Parameter;
import org.gcube.portlets.user.dataminermanager.shared.session.UserInfo;

View File

@ -5,10 +5,10 @@ import java.util.List;
import org.gcube.portlets.user.dataminermanager.client.bean.ComputationStatus;
import org.gcube.portlets.user.dataminermanager.client.bean.Operator;
import org.gcube.portlets.user.dataminermanager.client.bean.OperatorsClassification;
import org.gcube.portlets.user.dataminermanager.shared.data.ComputationData;
import org.gcube.portlets.user.dataminermanager.shared.data.ComputationId;
import org.gcube.portlets.user.dataminermanager.shared.data.OutputData;
import org.gcube.portlets.user.dataminermanager.shared.data.TableItemSimple;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationData;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationId;
import org.gcube.portlets.user.dataminermanager.shared.parameters.Parameter;
import org.gcube.portlets.user.dataminermanager.shared.session.UserInfo;
import org.gcube.portlets.user.dataminermanager.shared.workspace.DataMinerWorkArea;

View File

@ -0,0 +1,67 @@
package org.gcube.portlets.user.dataminermanager.client.widgets;
import org.gcube.portlets.user.dataminermanager.client.DataMinerManager;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationId;
import org.gcube.portlets.user.dataminermanager.shared.data.output.FileResource;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.container.HtmlLayoutContainer;
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;
import com.sencha.gxt.widget.core.client.event.SelectEvent;
/**
*
* @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class FileViewer extends SimpleContainer {
private FileResource fileResource;
/**
* @param mapImages
*/
public FileViewer(ComputationId computationId,
FileResource fileResource) {
super();
this.fileResource = fileResource;
//this.computationId = computationId;
init();
create();
}
private void init(){
setHeight(56);
}
private void create() {
VerticalLayoutContainer lc = new VerticalLayoutContainer();
final String fileName = fileResource.getName();
final String fileUrl = fileResource.getUrl();
HtmlLayoutContainer fileNameHtml = new HtmlLayoutContainer(
"<div class='computation-output-fileName'><p>"
+ new SafeHtmlBuilder().appendEscaped(fileName)
.toSafeHtml().asString() + "</p></div>");
lc.add(fileNameHtml, new VerticalLayoutData(-1, -1, new Margins(0)));
TextButton downloadBtn = new TextButton("Download File");
downloadBtn.setIcon(DataMinerManager.resources.fileDownload());
downloadBtn.addSelectHandler(new SelectEvent.SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
com.google.gwt.user.client.Window.open(fileUrl, fileName, "");
}
});
lc.add(downloadBtn, new VerticalLayoutData(-1, -1, new Margins(0)));
add(lc);
}
}

View File

@ -1,8 +1,8 @@
package org.gcube.portlets.user.dataminermanager.client.widgets;
import org.gcube.portlets.user.dataminermanager.client.DataMinerManager;
import org.gcube.portlets.user.dataminermanager.shared.data.ComputationId;
import org.gcube.portlets.user.dataminermanager.shared.data.output.ImagesResource;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationId;
import org.gcube.portlets.user.dataminermanager.shared.data.output.ImageResource;
import com.google.gwt.user.client.ui.Image;
import com.sencha.gxt.core.client.util.Margins;
@ -19,28 +19,28 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent;
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ImagesViewer extends SimpleContainer {
public class ImageViewer extends SimpleContainer {
protected static final String SAVE_OK_MESSAGE = "The images have been saved on the Workspace in the folder ";
protected static final String SAVE_OK_TITLE = "Saving operation was successful";
protected static final String SAVE_FAIL_TITLE = "Error";
protected static final String SAVE_FAIL_MESSAGE = "Error in saving images.";
private ImagesResource imagesResource;
private ImageResource imagesResource;
//private ComputationId computationId;
/**
* @param mapImages
*/
public ImagesViewer(ComputationId computationId,
ImagesResource imagesResource) {
public ImageViewer(ComputationId computationId,
ImageResource imagesResource) {
super();
this.imagesResource = imagesResource;
//this.computationId = computationId;
init();
create();
}
private void init() {
private void create() {
VerticalLayoutContainer v = new VerticalLayoutContainer();
add(v);
if (imagesResource == null || imagesResource.getLink() == null

View File

@ -15,12 +15,11 @@ import org.gcube.portlets.user.dataminermanager.client.rpc.DataMinerPortletServi
import org.gcube.portlets.user.dataminermanager.server.smservice.SClient;
import org.gcube.portlets.user.dataminermanager.server.storage.StorageUtil;
import org.gcube.portlets.user.dataminermanager.server.util.DataMinerWorkAreaManager;
import org.gcube.portlets.user.dataminermanager.server.util.SessionUtil;
import org.gcube.portlets.user.dataminermanager.server.util.TableReader;
import org.gcube.portlets.user.dataminermanager.shared.data.ComputationData;
import org.gcube.portlets.user.dataminermanager.shared.data.ComputationId;
import org.gcube.portlets.user.dataminermanager.shared.data.OutputData;
import org.gcube.portlets.user.dataminermanager.shared.data.TableItemSimple;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationData;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationId;
import org.gcube.portlets.user.dataminermanager.shared.exception.ServiceException;
import org.gcube.portlets.user.dataminermanager.shared.parameters.Parameter;
import org.gcube.portlets.user.dataminermanager.shared.session.UserInfo;

View File

@ -1,14 +1,13 @@
/**
*
*/
package org.gcube.portlets.user.dataminermanager.server.util;
package org.gcube.portlets.user.dataminermanager.server;
import static org.gcube.common.authorization.client.Constants.authorizationService;
import java.util.ArrayList;
import java.util.List;
import javax.activation.DataSource;
import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
@ -19,6 +18,7 @@ import org.gcube.portlets.user.dataminermanager.server.smservice.SClient;
import org.gcube.portlets.user.dataminermanager.server.smservice.SClient4WPSBuilder;
import org.gcube.portlets.user.dataminermanager.server.smservice.SClientBuilder;
import org.gcube.portlets.user.dataminermanager.server.smservice.SClientDirector;
import org.gcube.portlets.user.dataminermanager.server.util.ServiceCredential;
import org.gcube.portlets.user.dataminermanager.shared.Constants;
import org.gcube.portlets.user.dataminermanager.shared.exception.ExpiredSessionServiceException;
import org.gcube.portlets.user.dataminermanager.shared.exception.ServiceException;
@ -32,13 +32,7 @@ import org.gcube.portlets.user.dataminermanager.shared.exception.ServiceExceptio
public class SessionUtil {
private static final Logger logger = Logger.getLogger(SessionUtil.class);
// private final static String hostUrl =
// "http://pc-angela.isti.cnr.it:9090";
// private static URI host = URI.create(hostUrl);
// private final static String SCOPE = "/gcube";
public static final String DATASOURCE_ATTRIBUTE_NAME = "TDW.DATASOURCE";
public static ASLSession getASLSession(HttpSession httpSession)
throws ServiceException {
String username = (String) httpSession
@ -61,7 +55,7 @@ public class SessionUtil {
httpSession.getId(), username);
aslSession.setScope(scope);
} else {
logger.info("no user found in session, use test user");
logger.info("no user found in session!");
throw new ExpiredSessionServiceException("Session Expired!");
}
@ -96,12 +90,6 @@ public class SessionUtil {
}
public static DataSource getDataSource(HttpSession httpSession)
throws ServiceException {
ASLSession session = getASLSession(httpSession);
return (DataSource) session.getAttribute(DATASOURCE_ATTRIBUTE_NAME);
}
public static SClient getSClient(HttpSession session, ASLSession aslSession)
throws Exception {

View File

@ -29,7 +29,7 @@ import org.gcube.informationsystem.publisher.ScopedPublisher;
import org.gcube.portlets.user.dataminermanager.client.bean.Operator;
import org.gcube.portlets.user.dataminermanager.client.bean.OperatorCategory;
import org.gcube.portlets.user.dataminermanager.server.DescriptionRepository;
import org.gcube.portlets.user.dataminermanager.server.util.SessionUtil;
import org.gcube.portlets.user.dataminermanager.server.SessionUtil;
import org.gcube.portlets.user.dataminermanager.shared.Constants;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.Query;

View File

@ -6,9 +6,9 @@ import java.util.Map;
import org.gcube.portlets.user.dataminermanager.client.bean.ComputationStatus;
import org.gcube.portlets.user.dataminermanager.client.bean.Operator;
import org.gcube.portlets.user.dataminermanager.client.bean.OperatorsClassification;
import org.gcube.portlets.user.dataminermanager.shared.data.ComputationData;
import org.gcube.portlets.user.dataminermanager.shared.data.ComputationId;
import org.gcube.portlets.user.dataminermanager.shared.data.OutputData;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationData;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationId;
import org.gcube.portlets.user.dataminermanager.shared.parameters.Parameter;
/**

View File

@ -40,14 +40,16 @@ import org.gcube.portlets.user.dataminermanager.server.smservice.wps.ProcessInfo
import org.gcube.portlets.user.dataminermanager.server.smservice.wps.ResponseWPS;
import org.gcube.portlets.user.dataminermanager.server.smservice.wps.StatWPSClientSession;
import org.gcube.portlets.user.dataminermanager.server.smservice.wps.WPS2SM;
import org.gcube.portlets.user.dataminermanager.server.smservice.wps.computationsvalue.ComputationValueBuilder;
import org.gcube.portlets.user.dataminermanager.server.storage.StorageUtil;
import org.gcube.portlets.user.dataminermanager.server.util.ServiceCredential;
import org.gcube.portlets.user.dataminermanager.shared.Constants;
import org.gcube.portlets.user.dataminermanager.shared.data.ComputationData;
import org.gcube.portlets.user.dataminermanager.shared.data.ComputationId;
import org.gcube.portlets.user.dataminermanager.shared.data.OutputData;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationData;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationId;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationValue;
import org.gcube.portlets.user.dataminermanager.shared.data.output.FileResource;
import org.gcube.portlets.user.dataminermanager.shared.data.output.ImagesResource;
import org.gcube.portlets.user.dataminermanager.shared.data.output.ImageResource;
import org.gcube.portlets.user.dataminermanager.shared.data.output.MapResource;
import org.gcube.portlets.user.dataminermanager.shared.data.output.ObjectResource;
import org.gcube.portlets.user.dataminermanager.shared.data.output.Resource;
@ -1043,7 +1045,7 @@ public class SClient4WPS extends SClient {
case "image/gif":
case "image/jpeg":
case "image/png":
resource = new ImagesResource(key,
resource = new ImageResource(key,
responseWPS.getDescription(),
responseWPS.getDescription(),
responseWPS.getData(),
@ -1250,8 +1252,8 @@ public class SClient4WPS extends SClient {
computationId.setOperatorId(operatorId);
computationId.setOperatorName(operatorName);
LinkedHashMap<String, String> inputParameters = new LinkedHashMap<>();
LinkedHashMap<String, String> outputParameters = new LinkedHashMap<>();
LinkedHashMap<String, String> inputValueParameters = new LinkedHashMap<>();
LinkedHashMap<String, String> outputValueParameters = new LinkedHashMap<>();
for (String key : computationProperties.keySet()) {
if (key != null) {
@ -1260,7 +1262,7 @@ public class SClient4WPS extends SClient {
String inputKey = key.substring(inputSeparatorIndex + 1);
if (inputKey.compareToIgnoreCase("user.name") != 0
&& inputKey.compareToIgnoreCase("scope") != 0) {
inputParameters.put(inputKey,
inputValueParameters.put(inputKey,
computationProperties.get(key));
}
@ -1270,7 +1272,7 @@ public class SClient4WPS extends SClient {
int outputSeparatorIndex = key.indexOf("_");
String outputKey = key
.substring(outputSeparatorIndex + 1);
outputParameters.put(outputKey,
outputValueParameters.put(outputKey,
computationProperties.get(key));
}
@ -1279,12 +1281,18 @@ public class SClient4WPS extends SClient {
}
}
ComputationValueBuilder computationValueBuilder=new ComputationValueBuilder(inputValueParameters);
LinkedHashMap<String, ComputationValue> inputParameters = computationValueBuilder.create();
computationValueBuilder=new ComputationValueBuilder(outputValueParameters);
LinkedHashMap<String, ComputationValue> outputParameters = computationValueBuilder.create();
ComputationData computationData = new ComputationData(computationId,
inputParameters, outputParameters, operatorDescritpion,
startDate, endDate, status, executionType, vre);
logger.debug("ComputationData: "+computationData);
return computationData;
}
}
}

View File

@ -0,0 +1,143 @@
package org.gcube.portlets.user.dataminermanager.server.smservice.wps.computationsvalue;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationValue;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationValueFile;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationValueImage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ComputationValueBuilder {
private static Logger logger = LoggerFactory
.getLogger(ComputationValueBuilder.class);
private LinkedHashMap<String, String> valueParameters;
private LinkedHashMap<String, ComputationValue> computationsValueParameters;
public ComputationValueBuilder(LinkedHashMap<String, String> valueParameters) {
this.valueParameters = valueParameters;
}
/**
*
*/
public LinkedHashMap<String, ComputationValue> create() {
computationsValueParameters = new LinkedHashMap<String, ComputationValue>();
if (valueParameters != null && !valueParameters.isEmpty()) {
for (String key : valueParameters.keySet()) {
String value = valueParameters.get(key);
if (value != null && !value.isEmpty()
&& value.startsWith("http")) {
ComputationValue computationValue = retrieveFileName(value);
computationsValueParameters.put(key, computationValue);
} else {
ComputationValue valueString = new ComputationValue(value);
computationsValueParameters.put(key, valueString);
}
}
}
logger.debug("CompuatationsValues: " + computationsValueParameters);
return computationsValueParameters;
}
private ComputationValue retrieveFileName(final String value) {
HttpURLConnection conn = null;
try {
URL url = new URL(value);
int attempts = 0;
do {
conn = (HttpURLConnection) url.openConnection();
conn.setConnectTimeout(30000);
conn.setReadTimeout(30000);
conn.setRequestMethod("HEAD");
conn.setAllowUserInteraction(false);
conn.setDoInput(true);
conn.setDoOutput(true);
conn.connect();
if (conn.getResponseCode() != 200) {
logger.error("Response Code: "+conn.getResponseCode());
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
}
}
attempts++;
} while (attempts <= 5 || conn.getResponseCode() != 200);
if (conn.getResponseCode() == 200) {
return extractFileName(conn, value);
} else {
return new ComputationValueFile(value, null, null);
}
} catch (IOException e) {
logger.error(e.getLocalizedMessage());
e.printStackTrace();
return new ComputationValueFile(value, null, null);
}
}
private ComputationValue extractFileName(HttpURLConnection conn,
String value) {
ComputationValue computationValue = null;
String fileName = null;
String mimeType = null;
logger.debug("Connection-Header: " + conn.getHeaderFields());
String contentDisposition = conn.getHeaderField("Content-Disposition");
if (contentDisposition == null) {
Map<String, List<String>> headerFields = conn.getHeaderFields();
boolean found = false;
for (String key : headerFields.keySet()) {
List<String> headerField = headerFields.get(key);
for (String fieldValue : headerField) {
if (fieldValue.toLowerCase().contains("filename=")) {
contentDisposition = fieldValue;
found = true;
break;
}
}
if (found) {
break;
}
}
}
logger.debug("Content-Disposition: " + contentDisposition);
// Content-Disposition="attachment; filename=abc.png"
if (contentDisposition != null && contentDisposition.indexOf("=") != -1) {
fileName = contentDisposition.split("=")[1]; // getting value
// after '='
if (fileName != null && !fileName.isEmpty()) {
if (fileName.startsWith("\"")) {
fileName = fileName.substring(1);
}
if (fileName.endsWith("\"")) {
fileName = fileName.substring(0, fileName.length() - 1);
}
}
} else { // fall back to random generated file name? }
}
mimeType = conn.getContentType();
if ((mimeType != null && mimeType.compareToIgnoreCase("image/png") == 0)
|| fileName != null && fileName.endsWith(".png")) {
computationValue = new ComputationValueImage(value, fileName,
mimeType);
} else {
computationValue = new ComputationValueFile(value, fileName,
mimeType);
}
return computationValue;
}
}

View File

@ -12,7 +12,7 @@ public class Constants {
public static final String DEFAULT_USER = "giancarlo.panichi";
//public static final String DEFAULT_USER = "statistical.manager@gmail.com";
public static final String DEFAULT_ROLE = "OrganizationMember";
public final static String DEFAULT_SCOPE = "/gcube/devsec/devVRE";
public static final String DEFAULT_SCOPE = "/gcube/devsec/devVRE";
// public final static String DEFAULT_USER = "test.user";
// public final static String DEFAULT_SCOPE = "/gcube/devNext";
// public final static String DEFAULT_SCOPE = "/gcube/devNext/NextNext";

View File

@ -2,6 +2,7 @@ package org.gcube.portlets.user.dataminermanager.shared.data;
import java.io.Serializable;
import org.gcube.portlets.user.dataminermanager.shared.data.computations.ComputationId;
import org.gcube.portlets.user.dataminermanager.shared.data.output.Resource;
/**

View File

@ -1,4 +1,4 @@
package org.gcube.portlets.user.dataminermanager.shared.data;
package org.gcube.portlets.user.dataminermanager.shared.data.computations;
import java.io.Serializable;
import java.util.LinkedHashMap;
@ -13,8 +13,8 @@ public class ComputationData implements Serializable {
private static final long serialVersionUID = -3039151542008171640L;
private ComputationId computationId;
private LinkedHashMap<String, String> inputParameters;
private LinkedHashMap<String, String> outputParameters;
private LinkedHashMap<String, ComputationValue> inputParameters;
private LinkedHashMap<String, ComputationValue> outputParameters;
private String operatorDescription;
private String startDate;
private String endDate;
@ -27,8 +27,8 @@ public class ComputationData implements Serializable {
}
public ComputationData(ComputationId computationId,
LinkedHashMap<String, String> inputParameters,
LinkedHashMap<String, String> outputParameters,
LinkedHashMap<String, ComputationValue> inputParameters,
LinkedHashMap<String, ComputationValue> outputParameters,
String operatorDescription, String startDate, String endDate,
String status, String executionType, String vre) {
super();
@ -51,20 +51,20 @@ public class ComputationData implements Serializable {
this.computationId = computationId;
}
public LinkedHashMap<String, String> getInputParameters() {
public LinkedHashMap<String, ComputationValue> getInputParameters() {
return inputParameters;
}
public void setInputParameters(LinkedHashMap<String, String> inputParameters) {
public void setInputParameters(LinkedHashMap<String, ComputationValue> inputParameters) {
this.inputParameters = inputParameters;
}
public LinkedHashMap<String, String> getOutputParameters() {
public LinkedHashMap<String, ComputationValue> getOutputParameters() {
return outputParameters;
}
public void setOutputParameters(
LinkedHashMap<String, String> outputParameters) {
LinkedHashMap<String, ComputationValue> outputParameters) {
this.outputParameters = outputParameters;
}

View File

@ -1,4 +1,4 @@
package org.gcube.portlets.user.dataminermanager.shared.data;
package org.gcube.portlets.user.dataminermanager.shared.data.computations;
import java.io.Serializable;

View File

@ -0,0 +1,56 @@
package org.gcube.portlets.user.dataminermanager.shared.data.computations;
import java.io.Serializable;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ComputationValue implements Serializable {
private static final long serialVersionUID = -2047623108851748745L;
protected ComputationValueType type;
protected String value;
public ComputationValue() {
super();
}
public ComputationValue(String value) {
super();
this.type = ComputationValueType.String;
this.value = value;
}
public ComputationValue(ComputationValueType type, String value) {
super();
this.type = type;
this.value = value;
}
public ComputationValueType getType() {
return type;
}
public void setType(ComputationValueType type) {
this.type = type;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Override
public String toString() {
return "ComputationValue [type=" + type + ", value=" + value + "]";
}
}

View File

@ -0,0 +1,49 @@
package org.gcube.portlets.user.dataminermanager.shared.data.computations;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ComputationValueFile extends ComputationValue {
private static final long serialVersionUID = -5845606225432949795L;
private String fileName;
private String mimeType;
public ComputationValueFile() {
super();
}
public ComputationValueFile(String url, String fileName, String mimeType) {
super(ComputationValueType.File, url);
this.fileName = fileName;
this.mimeType = mimeType;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getMimeType() {
return mimeType;
}
public void setMimeType(String mimeType) {
this.mimeType = mimeType;
}
@Override
public String toString() {
return "ComputationValueFile [fileName=" + fileName + ", mimeType="
+ mimeType + ", type=" + type + ", value=" + value + "]";
}
}

View File

@ -0,0 +1,47 @@
package org.gcube.portlets.user.dataminermanager.shared.data.computations;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ComputationValueImage extends ComputationValue {
private static final long serialVersionUID = -5845606225432949795L;
private String fileName;
private String mimeType;
public ComputationValueImage(){
super();
}
public ComputationValueImage(String url, String fileName, String mimeType) {
super(ComputationValueType.Image, url);
this.fileName = fileName;
this.mimeType = mimeType;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getMimeType() {
return mimeType;
}
public void setMimeType(String mimeType) {
this.mimeType = mimeType;
}
@Override
public String toString() {
return "ComputationValueImage [fileName=" + fileName + ", mimeType="
+ mimeType + "]";
}
}

View File

@ -0,0 +1,11 @@
package org.gcube.portlets.user.dataminermanager.shared.data.computations;
/**
*
* @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public enum ComputationValueType {
File, Image, String;
}

View File

@ -11,7 +11,7 @@ import java.io.Serializable;
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ImagesResource extends Resource implements Serializable {
public class ImageResource extends Resource implements Serializable {
/**
*
@ -23,9 +23,9 @@ public class ImagesResource extends Resource implements Serializable {
/**
*
*/
public ImagesResource() {
public ImageResource() {
super();
this.setResourceType(ResourceType.IMAGES);
this.setResourceType(ResourceType.IMAGE);
}
/**
@ -35,9 +35,9 @@ public class ImagesResource extends Resource implements Serializable {
* @param description
* @param link
*/
public ImagesResource(String resourceId, String name, String description,
public ImageResource(String resourceId, String name, String description,
String link, String mimeType) {
super(resourceId, name, description, ResourceType.IMAGES);
super(resourceId, name, description, ResourceType.IMAGE);
this.link = link;
this.mimeType = mimeType;
}

View File

@ -19,7 +19,7 @@ public class Resource implements Serializable {
private static final long serialVersionUID = 1417885805472591661L;
public enum ResourceType {
OBJECT, FILE, TABULAR, MAP, IMAGES, ERROR
OBJECT, FILE, TABULAR, MAP, IMAGE, ERROR
};
private String resourceId, name, description;
@ -125,7 +125,7 @@ public class Resource implements Serializable {
}
public boolean isImages() {
return this.resourceType == ResourceType.IMAGES;
return this.resourceType == ResourceType.IMAGE;
}
public boolean isError() {

View File

@ -40,19 +40,20 @@
<entry-point
class='org.gcube.portlets.user.dataminermanager.client.DataMinerManager' />
<!--
<set-property name="log_ConsoleLogger" value="ENABLED" /> <set-property
name="log_DivLogger" value="ENABLED" /> <set-property name="log_GWTLogger"
value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED"
/>
/> -->
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="ENABLED"
/> -->
<!--
<set-property name="log_ConsoleLogger" value="DISABLED" />
<set-property name="log_DivLogger" value="DISABLED" />
<set-property name="log_GWTLogger" value="DISABLED" />
<set-property name="log_SystemLogger" value="DISABLED" /> -->
<set-property name="log_SystemLogger" value="DISABLED" />
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="DISABLED"
/> -->

317663
test.log.1

File diff suppressed because one or more lines are too long

231708
test.log.2

File diff suppressed because one or more lines are too long