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

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

Fixed Files Outputs

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/data-miner-manager@128088 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2016-04-14 13:19:46 +00:00
parent 201fcbc59c
commit 01d0bcc05e
8 changed files with 414 additions and 410 deletions

View File

@ -11,37 +11,32 @@ import org.gcube.portlets.user.dataminermanager.client.experimentArea.Experiment
import org.gcube.portlets.user.dataminermanager.client.resources.Resources;
import org.gcube.portlets.user.dataminermanager.client.rpc.DataMinerPortletService;
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.gcubewidgets.client.ClientScopeHelper;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Style.Cursor;
import com.google.gwt.event.dom.client.MouseDownEvent;
import com.google.gwt.event.dom.client.MouseDownHandler;
import com.google.gwt.event.dom.client.MouseOverEvent;
import com.google.gwt.event.dom.client.MouseOverHandler;
//import com.google.gwt.event.logical.shared.ResizeEvent;
//import com.google.gwt.event.logical.shared.ResizeHandler;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.user.client.Window.Location;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.RootPanel;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.core.client.util.Padding;
import com.sencha.gxt.widget.core.client.ContentPanel;
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.BoxLayoutContainer.BoxLayoutData;
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
import com.sencha.gxt.widget.core.client.container.HorizontalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.HorizontalLayoutContainer.HorizontalLayoutData;
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.VBoxLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VBoxLayoutContainer.VBoxLayoutAlign;
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.Viewport;
@ -100,13 +95,34 @@ public class DataMinerManager implements EntryPoint {
// onModuleLoad2
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute() {
loadMainPanel();
loadScope();
}
});
}
protected void loadMainPanel() {
private void loadScope() {
ClientScopeHelper.getService().setScope(Location.getHref(),
new AsyncCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
if(result){
loadMainPanel();
} else {
UtilsGXT3.info("Attention", "ClientScopeHelper has returned a false value!");
}
}
@Override
public void onFailure(Throwable caught) {
UtilsGXT3.alert("Error", "Error setting scope: "+caught.getLocalizedMessage());
caught.printStackTrace();
}
});
}
private void loadMainPanel() {
// AccountingManagerResources.INSTANCE.accountingManagerCSS().ensureInjected();
// ScriptInjector.fromString(AccountingManagerResources.INSTANCE.jqueryJs().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
@ -180,7 +196,7 @@ public class DataMinerManager implements EntryPoint {
}
protected void bind(BorderLayoutContainer mainWidget) {
private void bind(BorderLayoutContainer mainWidget) {
try {
RootPanel root = RootPanel.get(SM_DIV);
Log.info("Root Panel: " + root);
@ -280,9 +296,9 @@ public class DataMinerManager implements EntryPoint {
topLc.setStylePrimaryName("smMenu");
topLc.addStyleName("smLayoutContainer");
VerticalLayoutContainer lc = new VerticalLayoutContainer();
VerticalLayoutData layoutTop=new VerticalLayoutData(-1, -1,
VerticalLayoutData layoutTop = new VerticalLayoutData(-1, -1,
new Margins(20, 90, 10, 90));
VerticalLayoutData layoutNext=new VerticalLayoutData(-1, -1,
VerticalLayoutData layoutNext = new VerticalLayoutData(-1, -1,
new Margins(10, 90, 10, 90));
SimpleContainer itemDataSpace = createMenuItem(

View File

@ -0,0 +1,302 @@
/**
*
*/
package org.gcube.portlets.user.dataminermanager.client.experimentArea;
import java.util.LinkedHashMap;
import java.util.Map;
import org.gcube.portlets.user.dataminermanager.client.DataMinerManager;
import org.gcube.portlets.user.dataminermanager.client.bean.output.FileResource;
import org.gcube.portlets.user.dataminermanager.client.bean.output.ImagesResource;
import org.gcube.portlets.user.dataminermanager.client.bean.output.MapResource;
import org.gcube.portlets.user.dataminermanager.client.bean.output.ObjectResource;
import org.gcube.portlets.user.dataminermanager.client.bean.output.Resource;
import org.gcube.portlets.user.dataminermanager.client.bean.output.Resource.ResourceType;
import org.gcube.portlets.user.dataminermanager.client.bean.output.TableResource;
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.ResourceViewer;
import org.gcube.portlets.user.dataminermanager.shared.data.ComputationId;
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.google.gwt.user.client.rpc.AsyncCallback;
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;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ComputationOutputPanel extends SimpleContainer {
private ComputationId computationId;
private VerticalLayoutContainer v;
public ComputationOutputPanel(ComputationId computationId) {
super();
this.computationId = computationId;
Log.debug("ComputationOutputPanel");
init();
}
private void init() {
v = new VerticalLayoutContainer();
add(v);
// request for a jobItem linked with the computationId (or jobId)
DataMinerManager.getService().getResourceByComputationId(computationId,
new AsyncCallback<Resource>() {
@Override
public void onSuccess(Resource result) {
// unmask();
showOutputInfo(result);
}
@Override
public void onFailure(Throwable caught) {
Log.error("Error in getResourceByComputationId: "
+ caught.getLocalizedMessage());
UtilsGXT3.alert(
"Error",
"Impossible to retrieve output info. "
+ caught.getLocalizedMessage());
}
});
// this.mask("Loading Result Info...");
}
/**
* @param jobOutput
*/
private void showOutputInfo(Resource resource) {
try {
Log.info("Show Output Info on: " + resource);
if (resource == null)
return;
ResourceType resourceType = resource.getResourceType();
switch (resourceType) {
case FILE:
FileResource fileResource = (FileResource) resource;
v.add(getHtmlTitle("The algorithm produced a", "File"), new VerticalLayoutData(1, -1,
new Margins(0)));
v.add(getFileResourceOutput(fileResource), new VerticalLayoutData(1, -1,
new Margins(0)));
break;
case TABULAR:
TableResource tabResource = (TableResource) resource;
v.add(getHtmlTitle("The algorithm produced a", "Table"), new VerticalLayoutData(1, -1,
new Margins(0)));
// v.add(getTabResourceOutput(tabResource));
break;
case IMAGES:
v.add(getHtmlTitle("The algorithm produced an", "Set of Images"), new VerticalLayoutData(1, -1,
new Margins(0)));
final ImagesResource imagesResource = (ImagesResource) resource;
v.add(getImagesResourceOutput(imagesResource), new VerticalLayoutData(1, -1,
new Margins(0)));
break;
case MAP:
v.add(getHtmlTitle("The algorithm produced ",
"Multiple Results"), new VerticalLayoutData(1, -1,
new Margins(0)));
final MapResource mapResource = (MapResource) resource;
v.add(getMultipleOutput(mapResource), new VerticalLayoutData(1,
-1, new Margins(0)));
break;
case ERROR:
break;
case OBJECT:
break;
default:
break;
}
forceLayout();
} catch (Throwable e) {
Log.error("Error in show output info: " + e.getLocalizedMessage());
e.printStackTrace();
}
}
public interface TitleTemplate extends XTemplates {
@XTemplate("<div class='computation-output-outputType'><p>{intro} <b>{produced}<b>.</p></div>")
SafeHtml getTemplate(String intro, String produced);
}
/**
* @param string
* @return
*/
private HtmlLayoutContainer getHtmlTitle(String intro, String produced) {
TitleTemplate templates = GWT.create(TitleTemplate.class);
HtmlLayoutContainer c = new HtmlLayoutContainer(templates.getTemplate(
intro, produced));
return c;
}
/**
* @param imagesResource
* @return
*/
private SimpleContainer getImagesResourceOutput(
ImagesResource imagesResource) {
SimpleContainer container = new SimpleContainer();
container.add(new ImagesViewer(computationId, imagesResource));
return container;
}
/**
*
* @param fileResource
* @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;
}
/**
* @param map
* @return
*/
private SimpleContainer getMultipleOutput(MapResource mapResource) {
Map<String, Resource> map = mapResource.getMap();
VerticalLayoutContainer vp = new VerticalLayoutContainer();
SimpleContainer container = new 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<>();
for (String key : map.keySet()) {
Resource resource = map.get(key);
ResourceType resourceType = resource.getResourceType();
switch (resourceType) {
case OBJECT:
mapValues.put(key, (ObjectResource) resource);
break;
case FILE:
mapFiles.put(key, (FileResource) resource);
break;
case TABULAR:
mapTabs.put(key, (TableResource) resource);
break;
case IMAGES:
mapImages.put(key, (ImagesResource) resource);
break;
case MAP:
break;
case ERROR:
break;
default:
break;
}
}
if (mapValues.size() > 0) {
HtmlLayoutContainer html = new HtmlLayoutContainer("Output Values");
html.setStyleName("computation-output-groupTitle");
vp.add(html, new VerticalLayoutData(-1, -1, new Margins(0)));
vp.add((new ResourceViewer(mapValues)).getHtml(),
new VerticalLayoutData(-1, -1, new Margins(0)));
html = new HtmlLayoutContainer(
"<div class='computation-output-separator'></div>");
vp.add(html);
}
if (mapFiles.size() > 0) {
HtmlLayoutContainer html = new HtmlLayoutContainer("Files");
html.setStyleName("computation-output-groupTitle");
vp.add(html, new VerticalLayoutData(-1, -1, new Margins(0)));
for (String fileKey : mapFiles.keySet()) {
// vp.add(new Html("<i>"+fileKey+"</i>"));
vp.add(getFileResourceOutput(mapFiles.get(fileKey)),
new VerticalLayoutData(-1, -1, new Margins(0)));
}
html = new HtmlLayoutContainer(
"<div class='computation-output-separator'></div>");
vp.add(html, new VerticalLayoutData(-1, -1, new Margins(0)));
}
if (mapTabs.size() > 0) {
HtmlLayoutContainer html = new HtmlLayoutContainer("Tables");
html.setStyleName("computation-output-groupTitle");
vp.add(html,new VerticalLayoutData(-1, -1, new Margins(0)));
for (String tabKey : mapTabs.keySet()) {
// vp.add(new Html("<i>"+tabKey+"</i>"));
// vp.add(getTabResourceOutput(mapTabs.get(tabKey)));
}
html = new HtmlLayoutContainer("<div class='computation-output-separator'></div>");
vp.add(html,new VerticalLayoutData(-1, -1, new Margins(0)));
}
if (mapImages.size() > 0) {
HtmlLayoutContainer html = new HtmlLayoutContainer("Images");
html.setStyleName("computation-output-groupTitle");
vp.add(html,new VerticalLayoutData(-1, -1, new Margins(0)));
for (String imagesKey : mapImages.keySet()) {
// vp.add(new Html("<i>"+imagesKey+"</i>"));
vp.add(getImagesResourceOutput(mapImages.get(imagesKey)));
}
html = new HtmlLayoutContainer("<div class='computation-output-separator'></div>");
vp.add(html,new VerticalLayoutData(-1, -1, new Margins(0)));
}
container.add(vp);
return container;
}
}

View File

@ -12,32 +12,16 @@ import org.gcube.portlets.user.dataminermanager.client.bean.Operator;
import org.gcube.portlets.user.dataminermanager.client.common.EventBusProvider;
import org.gcube.portlets.user.dataminermanager.client.events.SessionExpiredEvent;
import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3;
import org.gcube.portlets.user.dataminermanager.client.widgets.ComputationOutputPanel;
import org.gcube.portlets.user.dataminermanager.shared.Constants;
import org.gcube.portlets.user.dataminermanager.shared.data.ComputationId;
import org.gcube.portlets.user.dataminermanager.shared.exception.ExpiredSessionServiceException;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.resources.client.ClientBundle.Source;
import com.google.gwt.resources.client.ImageResource.ImageOptions;
import com.google.gwt.resources.client.ImageResource.RepeatStyle;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HTML;
import com.sencha.gxt.cell.core.client.ProgressBarCell;
import com.sencha.gxt.cell.core.client.ProgressBarCell.ProgressBarAppearanceOptions;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.theme.base.client.progress.ProgressBarDefaultAppearance;
import com.sencha.gxt.theme.base.client.progress.ProgressBarDefaultAppearance.ProgressBarResources;
import com.sencha.gxt.theme.base.client.progress.ProgressBarDefaultAppearance.ProgressBarStyle;
import com.sencha.gxt.theme.base.client.progress.ProgressBarDefaultAppearance.ProgressBarTemplate;
import com.sencha.gxt.theme.blue.client.progress.BlueProgressBarAppearance.BlueProgressBarResources;
import com.sencha.gxt.widget.core.client.ProgressBar;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.container.HtmlLayoutContainer;
@ -56,19 +40,6 @@ import com.sencha.gxt.widget.core.client.info.Info;
*/
public class ComputationStatusPanel extends SimpleContainer {
/*
private class ProgressBarColoredAppearance extends ProgressBarDefaultAppearance {
public ProgressBarColoredAppearance(ProgressBarResources resources,
ProgressBarTemplate template) {
super(resources, template);
// TODO Auto-generated constructor stub
}
}*/
private ProgressBar progressBar;
private ComputationId computationId;
private Operator operator;
@ -141,7 +112,6 @@ public class ComputationStatusPanel extends SimpleContainer {
public void computationStarted(ComputationId computationId) {
this.computationId = computationId;
vert.add(new HtmlLayoutContainer("<p>Created, the id is "+computationId.getId()+" [<a href='"+computationId.getUrlId()+"' >link</a>]</p>"));
//progressBar.getElement().getStyle().setMargin(20, Unit.PX);
progressBar = new ProgressBar();
progressBar.updateProgress(0, "Starting...");
vert.add(progressBar,new VerticalLayoutData(1, -1, new Margins(20)));
@ -212,9 +182,6 @@ public class ComputationStatusPanel extends SimpleContainer {
} else if (computationStatus.isFailed()) {
Log.debug("Computation is Failed");
// Info.display("Failed", "The computation of "+operator.getName()+" has failed.");
// MessageBox.alert("Failed", "The computation "+computationId+" of "+operator.getName()+" has failed.</br>"
// +"Message: "+computationStatus.getMessage(), null);
String errorMessage;
if(computationStatus.getErrResource()==null||computationStatus.getErrResource().getDescription()==null ){
errorMessage=new String("Computation Failed!");
@ -223,11 +190,11 @@ public class ComputationStatusPanel extends SimpleContainer {
}
UtilsGXT3.alert("Failed", "The computation "+computationId.getId()+" of "+operator.getName()+" has failed.</br>"
+"Message: "+errorMessage, null);
+"Message: "+errorMessage);
progressBar.updateProgress(1, "Computation Fail");
progressBar.getElement().getStyle().setMarginBottom(36, Unit.PX);
progressBar.addStyleName("progressBar-failed");
//
}
}
@ -239,11 +206,11 @@ public class ComputationStatusPanel extends SimpleContainer {
*
*/
private void showOutput() {
HtmlLayoutContainer computationEndMessage=new HtmlLayoutContainer("<p>The computation "+operator.getName()+" finished.</p>");
HtmlLayoutContainer computationEndMessage=new HtmlLayoutContainer("<p>The computation <b>"+operator.getName()+"</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)));
vert.add(computationOutputPanel, new VerticalLayoutData(1, -1, new Margins(0)));
}
@ -264,13 +231,9 @@ public class ComputationStatusPanel extends SimpleContainer {
private class ComputationTimer extends Timer {
/* (non-Javadoc)
* @see com.google.gwt.user.client.Timer#run()
*/
@Override
public void run() {
Log.debug("Timer run .....");
// final ComputationStatusPanel cp = ComputationStatusPanel.this;
DataMinerManager.getService().getComputationStatus(computationId, new AsyncCallback<ComputationStatus>() {
@Override
@ -278,9 +241,6 @@ public class ComputationStatusPanel extends SimpleContainer {
progressBar.updateProgress(1, "Failed to get the status");
progressBar.getElement().getStyle().setMarginBottom(36, Unit.PX);
progressBar.addStyleName("progressBar-failed");
// MessageBox.alert("Error", ""+caught.getLocalizedMessage()+"\nCause: "+caught.getCause()+"\nStackTrace: "+caught.getStackTrace().toString(), null);
// computationTerminated(computationId, operator, TerminationMode.FAILED2);
// ComputationTimer.this.cancel();
}
@Override

View File

@ -1,283 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.dataminermanager.client.widgets;
import java.util.LinkedHashMap;
import java.util.Map;
import org.gcube.portlets.user.dataminermanager.client.DataMinerManager;
import org.gcube.portlets.user.dataminermanager.client.bean.output.FileResource;
import org.gcube.portlets.user.dataminermanager.client.bean.output.ImagesResource;
import org.gcube.portlets.user.dataminermanager.client.bean.output.MapResource;
import org.gcube.portlets.user.dataminermanager.client.bean.output.ObjectResource;
import org.gcube.portlets.user.dataminermanager.client.bean.output.Resource;
import org.gcube.portlets.user.dataminermanager.client.bean.output.Resource.ResourceType;
import org.gcube.portlets.user.dataminermanager.client.bean.output.TableResource;
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.data.ComputationId;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HTML;
import com.sencha.gxt.widget.core.client.button.TextButton;
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.event.SelectEvent;
/**
* @author ceras
*
*/
public class ComputationOutputPanel extends SimpleContainer {
private ComputationId computationId;
private final DataMinerPortletServiceAsync service = DataMinerManager.getService();
private VerticalLayoutContainer v;
public ComputationOutputPanel(ComputationId computationId) {
super();
this.computationId = computationId;
init();
}
private void init() {
v = new VerticalLayoutContainer();
add(v);
// request for a jobItem linked with the computationId (or jobId)
service.getResourceByComputationId(computationId,
new AsyncCallback<Resource>() {
@Override
public void onSuccess(Resource result) {
unmask();
showOutputInfo(result);
}
@Override
public void onFailure(Throwable caught) {
unmask();
UtilsGXT3.alert("Error",
"Impossible to retrieve output info.", null);
}
});
this.mask("Loading Result Info...");
}
/**
* @param jobOutput
*/
protected void showOutputInfo(Resource resource) {
if (resource == null)
return;
ResourceType resourceType = resource.getResourceType();
switch (resourceType) {
case FILE:
FileResource fileResource = (FileResource) resource;
v.add(getHtmlTitle("The algorithm produced a <b>File</b>."));
v.add(getFileResourceOutput(fileResource));
break;
case TABULAR:
TableResource tabResource = (TableResource) resource;
v.add(getHtmlTitle("The algorithm produced a <b>Table</b>."));
// v.add(getTabResourceOutput(tabResource));
break;
case IMAGES:
v.add(getHtmlTitle("The algorithm produced an <b>Set of Images</b>."));
final ImagesResource imagesResource = (ImagesResource) resource;
v.add(getImagesResourceOutput(imagesResource));
break;
case MAP:
v.add(getHtmlTitle("The algorithm produced <b>Multiple Results</b>."));
final MapResource mapResource = (MapResource) resource;
v.add(getMultipleOutput(mapResource));
break;
case ERROR:
break;
case OBJECT:
break;
default:
break;
}
this.add(new HTML("<br/>"));
forceLayout();
}
/**
* @param string
* @return
*/
private HTML getHtmlTitle(String title) {
HTML html = new HTML(title);
html.setStyleName("jobViewer-output-outputType");
return html;
}
/**
* @param imagesResource
* @return
*/
private SimpleContainer getImagesResourceOutput(
ImagesResource imagesResource) {
SimpleContainer container = new SimpleContainer();
container.add(new ImagesViewer(computationId, imagesResource));
return container;
}
/**
* @param tabResource
*
* private LayoutContainer getTabResourceOutput(TableResource
* tabResource) { final String tableName = tabResource.getName();
* final String tableId = tabResource.getResourceId();
* LayoutContainer lc = new LayoutContainer(); lc.add(new
* Html("Data Set Created: <b>" + tableName + "</b><br/>
* <br/>
* "));
*
* lc.add(new Button("<b>Show Data Set</b>", Images.table(), new
* SelectionListener<ButtonEvent>() {
* @Override public void componentSelected(ButtonEvent ce) { final
* TabularData tabularData = DataMinerManager .getTabularData();
* TabularDataGridPanel grid = tabularData.getGridPanel();
* grid.setHeaderVisible(false); Window window = new Window();
* window.setMaximizable(true); window.setHeadingText("Data Set "
* + tableName); window.setModal(true); window.add(grid);
* window.setWidth(900); window.setHeight(500);
* tabularData.openTable(tableId); window.show(); } })); return
* lc; }
*/
/**
* @param fileResource
* @return
*/
private SimpleContainer getFileResourceOutput(FileResource fileResource) {
VerticalLayoutContainer lc = new VerticalLayoutContainer();
SimpleContainer container = new SimpleContainer();
final String fileName = fileResource.getName();
final String fileUrl = fileResource.getUrl();
lc.add(new HTML(fileName));
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);
container.add(lc);
return container;
}
/**
* @param map
* @return
*/
private SimpleContainer getMultipleOutput(MapResource mapResource) {
Map<String, Resource> map = mapResource.getMap();
VerticalLayoutContainer vp = new VerticalLayoutContainer();
SimpleContainer container = new 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<>();
for (String key : map.keySet()) {
Resource resource = map.get(key);
ResourceType resourceType = resource.getResourceType();
switch (resourceType) {
case OBJECT:
mapValues.put(key, (ObjectResource) resource);
break;
case FILE:
mapFiles.put(key, (FileResource) resource);
break;
case TABULAR:
mapTabs.put(key, (TableResource) resource);
break;
case IMAGES:
mapImages.put(key, (ImagesResource) resource);
break;
case MAP:
break;
case ERROR:
break;
default:
break;
}
}
if (mapValues.size() > 0) {
HTML html = new HTML("Output Values");
html.setStyleName("jobViewer-output-groupTitle");
vp.add(html);
vp.add((new ResourceViewer(mapValues)).getHtml());
html = new HTML("<div class='jobViewer-output-separator'></div>");
vp.add(html);
}
if (mapFiles.size() > 0) {
HTML html = new HTML("Files");
html.setStyleName("jobViewer-output-groupTitle");
vp.add(html);
for (String fileKey : mapFiles.keySet()) {
// vp.add(new Html("<i>"+fileKey+"</i>"));
vp.add(getFileResourceOutput(mapFiles.get(fileKey)));
}
html = new HTML("<div class='jobViewer-output-separator'></div>");
vp.add(html);
}
if (mapTabs.size() > 0) {
HTML html = new HTML("Tables");
html.setStyleName("jobViewer-output-groupTitle");
vp.add(html);
for (String tabKey : mapTabs.keySet()) {
// vp.add(new Html("<i>"+tabKey+"</i>"));
// vp.add(getTabResourceOutput(mapTabs.get(tabKey)));
}
html = new HTML("<div class='jobViewer-output-separator'></div>");
vp.add(html);
}
if (mapImages.size() > 0) {
HTML html = new HTML("Images");
html.setStyleName("jobViewer-output-groupTitle");
vp.add(html);
for (String imagesKey : mapImages.keySet()) {
// vp.add(new Html("<i>"+imagesKey+"</i>"));
vp.add(getImagesResourceOutput(mapImages.get(imagesKey)));
}
html = new HTML("<div class='jobViewer-output-separator'></div>");
vp.add(html);
}
container.add(vp);
return container;
}
}

View File

@ -8,11 +8,13 @@ import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3;
import org.gcube.portlets.user.dataminermanager.shared.data.ComputationId;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HTML;
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;
/**
@ -47,9 +49,10 @@ public class ImagesViewer extends SimpleContainer {
add(v);
if (imagesResource == null || imagesResource.getLink() == null
|| imagesResource.getLink().isEmpty())
v.add(new HTML("<i>No image found.</i>"));
v.add(new HtmlLayoutContainer("<i>No image found.</i>"), new VerticalLayoutData(-1, -1,
new Margins(0)));
else {
v.add(new HTML(imagesResource.getName()));
v.add(new HtmlLayoutContainer(imagesResource.getName()),new VerticalLayoutData(-1, -1, new Margins(0)));
TextButton saveImageBtn = new TextButton(
"Save image on the Workspace");
saveImageBtn.setIcon(DataMinerManager.resources.save());
@ -62,9 +65,9 @@ public class ImagesViewer extends SimpleContainer {
}
});
v.add(saveImageBtn);
v.add(saveImageBtn,new VerticalLayoutData(-1, -1, new Margins(0)));
final Image img = new Image(imagesResource.getLink());
v.add(img);
v.add(img,new VerticalLayoutData(-1, -1, new Margins(0)));
}
forceLayout();

View File

@ -44,6 +44,7 @@ import org.gcube.portlets.widgets.wsexplorer.shared.Item;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
/**
@ -236,41 +237,19 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
@Override
public Resource getResourceByComputationId(ComputationId computationId) {
try {
Log.debug("getResourceByComputationId: "+computationId);
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getASLSession(session);
SClient smClient = SessionUtil.getSClient(session, aslSession);
return smClient.getResourceByComputationId(computationId);
// SMComputation computation = factory.getComputation(jobId);
// JobItem jobItem = convertSMComputationToJobItem(computation,
// true);
//
// // try to add map data (if resource is an object)
//
// Resource res = jobItem.getResource();
// if (res.isMap()) {
// MapResource mapResource = (MapResource) res;
// Map<String, Resource> map = getMapFromMapResource(mapResource);
// mapResource.setMap(map);
// // jobItem.setMapData(map);
// logger.info("getResourceByJobId: " + mapResource);
//
// } else if (res.isImages()) {
// ImagesResource imgsRes = (ImagesResource) res;
// Map<String, String> map =
// getImagesInfoFromImagesResource(imgsRes);
// imgsRes.setMapImages(map);
// logger.info("getResourceByJobId: " + imgsRes);
// } else {
// logger.info("getResourceByJobId: " + res);
// }
// return res;
Resource resource= smClient.getResourceByComputationId(computationId);
Log.debug("Resoure: "+resource);
return resource;
} catch (Exception e) {
logger.error("Error in getResourceByComputationId: "
+ e.getLocalizedMessage());// in this case the resource
// doesn't exist, nothing to do
+ e.getLocalizedMessage());
e.printStackTrace();
return null;
}

View File

@ -12,8 +12,6 @@
-o-box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.11), 0 0 0
rgba(255, 255, 255, 1), 0 0 5px rgba(0, 28, 121, 1), 71px 0 27px
rgba(0, 28, 121, 0.15);*/
box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.11), 0 0 0
rgba(255, 255, 255, 1), 0 0 5px rgba(196, 196, 196, 1), 0px 0 27px
rgba(0, 0, 0, 0.15);
@ -238,9 +236,6 @@
margin-right: 5px;*/
}
.workflow-icon {
border: 1px solid black;
float: left;
@ -256,13 +251,11 @@
color: #000077;
}
.workflow-description {
font-size: 13px;
color: #505050;
}
.workflow-fieldDescription {
font-size: 12px;
color: #505050;
@ -280,8 +273,6 @@
margin-top: 4px;
}
.workflow-parameters-tableDescription {
font-size: 12px;
/* border: 1px solid gray;*/
@ -332,7 +323,6 @@
vertical-align: middle;
}
.menuImgLogo:HOVER {
/* cursor: pointer;*/
@ -355,17 +345,15 @@
cursor: auto;
}
/*
* Computation Execution
*/
.computationExcecutionPanel {
font-size: 13px;
font-size: 12px;
color: black;
}
.computationStatusPanel{
.computationStatusPanel {
border: 1px solid black;
padding: 10px;
}
@ -378,12 +366,9 @@
}
/**
* ProgressBar
*/
.progressBar-pending {
border: 1px solid #AAAAAA;
}
@ -402,26 +387,25 @@
background-image: url("images/progress-red.gif");
}
.progressBar-complete .progressWrap {
border-color:#00AA00;
border-color: #00AA00;
}
.progressBar-complete .progressInner {
background-color:#bdefbd;
background-image: url("images/bg-progress.gif");
height: auto;
background-color: #bdefbd;
background-image: url("images/bg-progress.gif");
height: auto;
}
.progressBar-complete .progressBar {
background-color:#4ec14e;
background-image: url("images/green-progress.gif");
background-repeat: repeat-x;
background-position: left center;
height: 18px;
border-top-color:#d1fdda;
border-bottom-color:#7fe48a;
border-right-color:#7fe48a;
background-color: #4ec14e;
background-image: url("images/green-progress.gif");
background-repeat: repeat-x;
background-position: left center;
height: 18px;
border-top-color: #d1fdda;
border-bottom-color: #7fe48a;
border-right-color: #7fe48a;
}
/*
@ -435,7 +419,39 @@
* background-image: url("images/progress-green.gif");
*}
*/
/**
* Computation Output
*/
.computation-output-outputType {
background-color: #EEEEEE;
border: 1px solid #BDBDBD;
/*font-weight: bold;*/
padding: 5px;
text-align: center;
margin-top: 20px;
margin-bottom: 10px;
}
.computation-output-groupTitle {
font-style: italic;
font-weight: bold;
margin-top: 5px;
margin-bottom: 5px;
}
.computation-output-separator {
border-top: 2px solid #AAAAAA;
margin-top: 8px;
margin-bootm: 8px;
/* height: 30px;
margin: 8px auto auto;
width: 400px;
*/
}
.computation-output-fileName{
margin-top:2px;
margin-bottom:2px;
}

View File

@ -68,6 +68,17 @@
</servlet-mapping>
<servlet>
<servlet-name>scopeService</servlet-name>
<servlet-class>org.gcube.portlets.user.gcubewidgets.server.ScopeServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>scopeService</servlet-name>
<url-pattern>/dataminermanager/scopeService</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>DataMinerManager.html</welcome-file>
</welcome-file-list>