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

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

Fixed Menu Event

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/data-miner-manager@128371 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2016-04-27 16:41:39 +00:00
parent 0eedb36822
commit 8b73acb942
12 changed files with 586 additions and 326 deletions

View File

@ -1,7 +1,9 @@
package org.gcube.portlets.user.dataminermanager.client; package org.gcube.portlets.user.dataminermanager.client;
import org.gcube.portlets.user.dataminermanager.client.common.EventBusProvider;
import org.gcube.portlets.user.dataminermanager.client.computations.ComputationsPanel; import org.gcube.portlets.user.dataminermanager.client.computations.ComputationsPanel;
import org.gcube.portlets.user.dataminermanager.client.dataspace.DataSpacePanel; import org.gcube.portlets.user.dataminermanager.client.dataspace.DataSpacePanel;
import org.gcube.portlets.user.dataminermanager.client.events.MenuSwitchEvent;
import org.gcube.portlets.user.dataminermanager.client.experiments.ExperimentPanel; import org.gcube.portlets.user.dataminermanager.client.experiments.ExperimentPanel;
import org.gcube.portlets.user.dataminermanager.client.resources.Resources; import org.gcube.portlets.user.dataminermanager.client.resources.Resources;
import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3; import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3;
@ -12,54 +14,39 @@ import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.event.dom.client.MouseDownEvent;
import com.google.gwt.event.dom.client.MouseDownHandler;
//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.Window.Location;
import com.google.gwt.user.client.rpc.AsyncCallback; 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.google.gwt.user.client.ui.RootPanel;
import com.sencha.gxt.core.client.util.Margins; import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer; 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.BorderLayoutContainer.BorderLayoutData;
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.MarginData;
import com.sencha.gxt.widget.core.client.container.SimpleContainer; 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.container.Viewport; import com.sencha.gxt.widget.core.client.container.Viewport;
//import com.google.gwt.event.logical.shared.ResizeEvent;
//import com.google.gwt.event.logical.shared.ResizeHandler;
/** /**
* Entry point classes define <code>onModuleLoad()</code>. * Entry point classes define <code>onModuleLoad()</code>.
*/ */
public class DataMinerManager implements EntryPoint { public class DataMinerManager implements EntryPoint {
public static final Resources resources = GWT.create(Resources.class); public static final Resources resources = GWT.create(Resources.class);
private static final String SM_DIV = "contentDiv"; private static final String SM_DIV = "contentDiv";
@SuppressWarnings("unused")
private DataMinerManagerController dataMinerManagerController; private DataMinerManagerController dataMinerManagerController;
private Header header;
private HomePanel homeMenu;
private DataSpacePanel dataSpacePanel; private DataSpacePanel dataSpacePanel;
private ExperimentPanel experimentPanel; private ExperimentPanel experimentPanel;
private ComputationsPanel computationsPanel; private ComputationsPanel computationsPanel;
private SimpleContainer previousPanel; private SimpleContainer previousPanel;
private SimpleContainer homeMenu;
private SimpleContainer centerPanel; private SimpleContainer centerPanel;
public enum MenuItem {
DATA_SPACE, EXPERIMENT, COMPUTATIONS
};
private Header header;
// Main Panel
private static BorderLayoutContainer mainPanelLayout;
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -106,84 +93,64 @@ public class DataMinerManager implements EntryPoint {
} }
private void loadMainPanel() { private void loadMainPanel() {
// AccountingManagerResources.INSTANCE.accountingManagerCSS().ensureInjected();
// ScriptInjector.fromString(AccountingManagerResources.INSTANCE.jqueryJs().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
dataMinerManagerController = new DataMinerManagerController(); dataMinerManagerController = new DataMinerManagerController();
homeMenu = createMenuPanel(); homeMenu = new HomePanel();
dataSpacePanel = new DataSpacePanel(); dataSpacePanel = new DataSpacePanel();
experimentPanel = new ExperimentPanel(); experimentPanel = new ExperimentPanel();
computationsPanel = new ComputationsPanel(); computationsPanel = new ComputationsPanel();
bind();
// Layout // Layout
mainPanelLayout = new BorderLayoutContainer(); BorderLayoutContainer mainPanelLayout = new BorderLayoutContainer();
mainPanelLayout.setId("mainPanelLayout"); mainPanelLayout.setId("mainPanelLayout");
mainPanelLayout.setBorders(false); mainPanelLayout.setBorders(false);
mainPanelLayout.setResize(true); mainPanelLayout.setResize(true);
mainPanelLayout.getElement().getStyle().setBackgroundColor("#FFFFFF"); mainPanelLayout.getElement().getStyle().setBackgroundColor("#FFFFFF");
// mainPanelLayout.getElement().getStyle().setBackgroundColor("rgb(3, 126, 207)"); // Center
centerPanel = new SimpleContainer(); centerPanel = new SimpleContainer();
MarginData mainData = new MarginData(new Margins(0)); MarginData mainData = new MarginData(new Margins(0));
mainPanelLayout.setCenterWidget(centerPanel, mainData); mainPanelLayout.setCenterWidget(centerPanel, mainData);
// Menu // Menu
header = new Header() { header = new Header();
@Override BorderLayoutData menuData = new BorderLayoutData(40);
public void select(MenuItem menuItem) {
if (menuItem == null)
switchTo(homeMenu);
else if (menuItem == MenuItem.EXPERIMENT)
switchTo(experimentPanel);
else if (menuItem == MenuItem.DATA_SPACE)
switchTo(dataSpacePanel);
else if (menuItem == MenuItem.COMPUTATIONS)
switchTo(computationsPanel);
/*
* else if (menuItem == MenuItem.COMPUTATIONS)
* switchTo(jobsPanel);
*/
}
};
BorderLayoutData menuData = new BorderLayoutData(58);
menuData.setMargins(new Margins(5)); menuData.setMargins(new Margins(5));
menuData.setCollapsible(false); menuData.setCollapsible(false);
menuData.setSplit(false); menuData.setSplit(false);
mainPanelLayout.setNorthWidget(header, menuData); mainPanelLayout.setNorthWidget(header, menuData);
// Filters //
/*
* FiltersPanel filtersPanel=new FiltersPanel(eventBus);
* BorderLayoutData westData = new BorderLayoutData(410);
* westData.setCollapsible(false); westData.setSplit(false);
* westData.setFloatable(false); westData.setCollapseMini(false);
* westData.setMargins(new Margins(2, 7, 2, 7));
* westData.setCollapseHidden(true); westData.setMaxSize(410);
* westData.setMinSize(410); mainPanelLayout.setWestWidget(filtersPanel,
* westData); filtersPanel.expand(); filtersPanel.enable();
*/
centerPanel.add(homeMenu); centerPanel.add(homeMenu);
previousPanel = homeMenu; previousPanel = homeMenu;
bind(mainPanelLayout); bindWindow(mainPanelLayout);
mainPanelLayout.forceLayout(); mainPanelLayout.forceLayout();
bindEvents(); }
/*
* dataMinerManagerController.setMainPanelLayout(mainPanelLayout); private void bind() {
* dataMinerManagerController.restoreUISession(); EventBusProvider.INSTANCE.addHandler(MenuSwitchEvent.TYPE,
*/ new MenuSwitchEvent.MenuSwitchEventHandler() {
@Override
public void onSelect(MenuSwitchEvent event) {
Log.debug("Catch MenuSwitchEvent");
menuSwitch(event);
}
});
} }
private void bind(BorderLayoutContainer mainWidget) { /**
*
* @param mainWidget
*/
private void bindWindow(BorderLayoutContainer mainWidget) {
try { try {
RootPanel root = RootPanel.get(SM_DIV); RootPanel root = RootPanel.get(SM_DIV);
Log.info("Root Panel: " + root); Log.info("Root Panel: " + root);
@ -214,149 +181,50 @@ public class DataMinerManager implements EntryPoint {
} }
} }
/*
* private void updateSize() { RootPanel smDiv = RootPanel.get(SM_DIV);
*
* int topBorder = smDiv.getAbsoluteTop(); int leftBorder =
* smDiv.getAbsoluteLeft();
*
* int rootHeight = Window.getClientHeight() - topBorder - 4;// - ((footer
* // == // null)?0:(footer.getOffsetHeight()-15)); int rootWidth =
* Window.getClientWidth() - 2 * leftBorder - 5; // - // rightScrollBar;
*
* //
* System.out.println("New Data Miner Manager dimension Width: "+rootWidth
* +"; Height: "+rootHeight);
*
* if (previousPanel == menu) dataMinerManagerLayout.setSize(rootWidth,
* 700); else dataMinerManagerLayout.setSize(rootWidth, rootHeight); }
*/
/** /**
* *
* @param event
*/ */
private void bindEvents() { private void menuSwitch(MenuSwitchEvent event){
/* if(event==null||event.getMenuType()==null){
* EventBusProvider.INSTANCE.addHandler(MaskEvent.getType(), new return;
* MaskEvent.MaskHandler() { }
*
* @Override public void onMask(MaskEvent event) { if (mainPanelLayout switch(event.getMenuType()){
* == null) return; case COMPUTATIONS:
* switchPanel(computationsPanel);
* String message = event.getMessage(); if (message == null) break;
* mainPanelLayout.unmask(); else mainPanelLayout.mask(message); case DATA_SPACE:
* switchPanel(dataSpacePanel);
* // Constants.maskLoadingStyle); } }); break;
*/ case EXPERIMENT:
/* switchPanel(experimentPanel);
* EventBusProvider.getInstance().addHandler( break;
* SessionExpiredEvent.getType(), new case HOME:
* SessionExpiredEvent.SessionExpiredHandler() { switchPanel(homeMenu);
* break;
* @Override public void onSessionExpired(SessionExpiredEvent event) { default:
* Window.alert("The session has expired. Please refresh the page."); } break;
* });
*/ }
} }
/**
* @return
*/
private SimpleContainer createMenuPanel() {
SimpleContainer topLc = new SimpleContainer();
topLc.setStylePrimaryName("smMenu");
topLc.addStyleName("smLayoutContainer");
VerticalLayoutContainer lc = new VerticalLayoutContainer();
VerticalLayoutData layoutTop = new VerticalLayoutData(-1, -1,
new Margins(20, 90, 10, 90));
VerticalLayoutData layoutNext = new VerticalLayoutData(-1, -1,
new Margins(10, 90, 10, 90));
SimpleContainer itemDataSpace = createMenuItem(
"Access to the Data Space",
"The data space contains the set of input and output data sets of the users. It is possible to upload and share tables. Data sources can be chosen from those hosted by the infrastructure. Outputs of the computations can be even saved in this space.",
resources.inputSpaceIcon(), new MouseDownHandler() {
@Override
public void onMouseDown(MouseDownEvent event) {
switchTo(dataSpacePanel);
header.setMenuSelected(MenuItem.DATA_SPACE);
}
});
lc.add(itemDataSpace, layoutTop);
SimpleContainer itemExperiment = createMenuItem(
"Execute an Experiment",
"This section allows to execute or prepare a Niche Modeling experiment. The section is endowed with a list of algorithms for training and executing statistical models for biological applications. Evaluation of the performances is possible by means of several kinds of measurement systems and processes.",
resources.executionIcon(), new MouseDownHandler() {
@Override
public void onMouseDown(MouseDownEvent event) {
switchTo(experimentPanel);
header.setMenuSelected(MenuItem.EXPERIMENT);
}
});
lc.add(itemExperiment, layoutNext);
SimpleContainer itemComputations = createMenuItem(
"Check the Computations",
"This section allows to check the status of the computation. A list of processes launched by the user is shown along with meta-information. By clicking on the completed jobs it is possible to visualize the data set contents.",
resources.computationsIcon(), new MouseDownHandler() {
@Override
public void onMouseDown(MouseDownEvent event) {
switchTo(computationsPanel);
header.setMenuSelected(MenuItem.COMPUTATIONS);
}
});
lc.add(itemComputations, layoutNext);
topLc.add(lc);
return topLc;
}
/** /**
* *
* @param panel
*/ */
private void switchTo(SimpleContainer lc) { private void switchPanel(SimpleContainer panel) {
centerPanel.remove(previousPanel); centerPanel.remove(previousPanel);
centerPanel.add(lc); centerPanel.add(panel);
centerPanel.forceLayout(); centerPanel.forceLayout();
previousPanel = lc; previousPanel = panel;
} }
private SimpleContainer createMenuItem(String title, String description,
ImageResource imgResource, MouseDownHandler handle) {
HorizontalLayoutContainer horiz = new HorizontalLayoutContainer();
Image img = new Image(imgResource);
HTML text = new HTML("<b>" + title + "</b><br>" + description);
text.addStyleName("smMenuItemText");
HorizontalLayoutData textLayoutData = new HorizontalLayoutData(400,
140, new Margins(10, 5, 10, 10));
HorizontalLayoutData imgLayoutData = new HorizontalLayoutData(140, 140,
new Margins(10, 10, 10, 5));
horiz.add(text, textLayoutData);
horiz.add(img, imgLayoutData);
SimpleContainer container = new SimpleContainer();
container.addDomHandler(handle, MouseDownEvent.getType());
container.setWidth(540);
container.setHeight(170);
container.addStyleName("smMenuItem");
container.addStyleOnOver(container.getElement(), "smMenuItem:HOVER");
container.add(horiz);
return container;
}

View File

@ -7,10 +7,12 @@ import org.gcube.portlets.user.dataminermanager.client.bean.OperatorsClassificat
import org.gcube.portlets.user.dataminermanager.client.common.EventBusProvider; import org.gcube.portlets.user.dataminermanager.client.common.EventBusProvider;
import org.gcube.portlets.user.dataminermanager.client.events.CancelComputationExecutionRequestEvent; import org.gcube.portlets.user.dataminermanager.client.events.CancelComputationExecutionRequestEvent;
import org.gcube.portlets.user.dataminermanager.client.events.DataMinerWorkAreaEvent; import org.gcube.portlets.user.dataminermanager.client.events.DataMinerWorkAreaEvent;
import org.gcube.portlets.user.dataminermanager.client.events.RefreshDataMinerWorkAreaEvent;
import org.gcube.portlets.user.dataminermanager.client.events.DeleteItemRequestEvent; import org.gcube.portlets.user.dataminermanager.client.events.DeleteItemRequestEvent;
import org.gcube.portlets.user.dataminermanager.client.events.MenuEvent;
import org.gcube.portlets.user.dataminermanager.client.events.MenuSwitchEvent;
import org.gcube.portlets.user.dataminermanager.client.events.OperatorsClassificationEvent; import org.gcube.portlets.user.dataminermanager.client.events.OperatorsClassificationEvent;
import org.gcube.portlets.user.dataminermanager.client.events.OperatorsClassificationRequestEvent; import org.gcube.portlets.user.dataminermanager.client.events.OperatorsClassificationRequestEvent;
import org.gcube.portlets.user.dataminermanager.client.events.RefreshDataMinerWorkAreaEvent;
import org.gcube.portlets.user.dataminermanager.client.events.ResubmitComputationExecutionEvent; import org.gcube.portlets.user.dataminermanager.client.events.ResubmitComputationExecutionEvent;
import org.gcube.portlets.user.dataminermanager.client.events.ResubmitComputationExecutionRequestEvent; import org.gcube.portlets.user.dataminermanager.client.events.ResubmitComputationExecutionRequestEvent;
import org.gcube.portlets.user.dataminermanager.client.events.SessionExpiredEvent; import org.gcube.portlets.user.dataminermanager.client.events.SessionExpiredEvent;
@ -19,6 +21,7 @@ import org.gcube.portlets.user.dataminermanager.client.events.StartComputationEx
import org.gcube.portlets.user.dataminermanager.client.rpc.DataMinerPortletServiceAsync; import org.gcube.portlets.user.dataminermanager.client.rpc.DataMinerPortletServiceAsync;
import org.gcube.portlets.user.dataminermanager.client.type.DataMinerWorkAreaElementType; import org.gcube.portlets.user.dataminermanager.client.type.DataMinerWorkAreaElementType;
import org.gcube.portlets.user.dataminermanager.client.type.DataMinerWorkAreaEventType; import org.gcube.portlets.user.dataminermanager.client.type.DataMinerWorkAreaEventType;
import org.gcube.portlets.user.dataminermanager.client.type.MenuType;
import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3; import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3;
import org.gcube.portlets.user.dataminermanager.shared.Constants; 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.ComputationId;
@ -41,6 +44,7 @@ public class DataMinerManagerController {
private UserInfo userInfo; private UserInfo userInfo;
private DataMinerWorkArea dataMinerWorkArea; private DataMinerWorkArea dataMinerWorkArea;
private List<OperatorsClassification> operatorsClassifications; private List<OperatorsClassification> operatorsClassifications;
private MenuType currentVisualization;
public DataMinerManagerController() { public DataMinerManagerController() {
init(); init();
@ -124,6 +128,17 @@ public class DataMinerManagerController {
} }
}); });
EventBusProvider.INSTANCE.addHandler(MenuEvent.TYPE,
new MenuEvent.MenuEventHandler() {
@Override
public void onSelect(MenuEvent event) {
Log.debug("Catch MenuEvent:");
manageMenuEvent(event);
}
});
EventBusProvider.INSTANCE EventBusProvider.INSTANCE
.addHandler( .addHandler(
StartComputationExecutionRequestEvent.TYPE, StartComputationExecutionRequestEvent.TYPE,
@ -210,6 +225,22 @@ public class DataMinerManagerController {
} }
private void manageMenuEvent(MenuEvent event) {
if (event == null
|| event.getMenuType() == null
|| (currentVisualization == null && event.getMenuType()
.compareTo(MenuType.HOME) == 0)
|| (currentVisualization != null && event.getMenuType()
.compareTo(currentVisualization) == 0)) {
return;
}
currentVisualization = event.getMenuType();
MenuSwitchEvent menuSwitchEvent = new MenuSwitchEvent(
event.getMenuType());
EventBusProvider.INSTANCE.fireEvent(menuSwitchEvent);
}
private void startComputationRequest( private void startComputationRequest(
final StartComputationExecutionRequestEvent event) { final StartComputationExecutionRequestEvent event) {
@ -441,39 +472,40 @@ public class DataMinerManagerController {
} }
private void deleteItemRequest(final DeleteItemRequestEvent event) { private void deleteItemRequest(final DeleteItemRequestEvent event) {
DataMinerPortletServiceAsync.INSTANCE DataMinerPortletServiceAsync.INSTANCE.deleteItem(
.deleteItem(event.getItemDescription(), new AsyncCallback<Void>() { event.getItemDescription(), new AsyncCallback<Void>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
Log.info("No valid user found: " + caught.getMessage()); Log.info("No valid user found: " + caught.getMessage());
if (caught instanceof ExpiredSessionServiceException) { if (caught instanceof ExpiredSessionServiceException) {
UtilsGXT3.alert("Error", "Expired Session"); UtilsGXT3.alert("Error", "Expired Session");
sessionExpiredShowDelayed(); sessionExpiredShowDelayed();
} else { } else {
UtilsGXT3.alert("Error", UtilsGXT3.alert("Error",
"Error deleting item on workspace: " "Error deleting item on workspace: "
+ caught.getLocalizedMessage()); + caught.getLocalizedMessage());
} }
} }
@Override @Override
public void onSuccess(Void result) { public void onSuccess(Void result) {
Log.debug("Deleted Item!"); Log.debug("Deleted Item!");
fireRefreshDataMinerWorkAreaEvent(event.getDataMinerWorkAreaElementType()); fireRefreshDataMinerWorkAreaEvent(event
.getDataMinerWorkAreaElementType());
} }
}); });
} }
private void fireRefreshDataMinerWorkAreaEvent( private void fireRefreshDataMinerWorkAreaEvent(
DataMinerWorkAreaElementType dataMinerWorkAreaElementType) { DataMinerWorkAreaElementType dataMinerWorkAreaElementType) {
RefreshDataMinerWorkAreaEvent refreshEvent=new RefreshDataMinerWorkAreaEvent(dataMinerWorkAreaElementType); RefreshDataMinerWorkAreaEvent refreshEvent = new RefreshDataMinerWorkAreaEvent(
dataMinerWorkAreaElementType);
EventBusProvider.INSTANCE.fireEvent(refreshEvent); EventBusProvider.INSTANCE.fireEvent(refreshEvent);
} }
} }

View File

@ -3,8 +3,12 @@
*/ */
package org.gcube.portlets.user.dataminermanager.client; package org.gcube.portlets.user.dataminermanager.client;
import org.gcube.portlets.user.dataminermanager.client.DataMinerManager.MenuItem; import org.gcube.portlets.user.dataminermanager.client.common.EventBusProvider;
import org.gcube.portlets.user.dataminermanager.client.events.MenuEvent;
import org.gcube.portlets.user.dataminermanager.client.events.MenuSwitchEvent;
import org.gcube.portlets.user.dataminermanager.client.type.MenuType;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.HorizontalPanel;
@ -16,18 +20,31 @@ import com.google.gwt.user.client.ui.Image;
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* *
*/ */
public abstract class Header extends HorizontalPanel { public class Header extends HorizontalPanel {
public abstract void select(MenuItem menuItem);
private Image menuGoBack, menuExperiment, menuDataSpace, menuComputations; private Image menuGoBack, menuExperiment, menuDataSpace, menuComputations;
private MenuItem currentSelection = null; private Enum<MenuType> currentSelection;
/**
*
*/
public Header() { public Header() {
super(); super();
create();
bind();
}
private void bind() {
EventBusProvider.INSTANCE.addHandler(MenuSwitchEvent.TYPE,
new MenuSwitchEvent.MenuSwitchEventHandler() {
@Override
public void onSelect(MenuSwitchEvent event) {
Log.debug("Catch MenuSwitchEvent");
menuSwitch(event);
}
});
}
private void create() {
// this.setStyleAttribute("background-color", "#FFFFFF"); // this.setStyleAttribute("background-color", "#FFFFFF");
Image logo = new Image(DataMinerManager.resources.logoLittle()); Image logo = new Image(DataMinerManager.resources.logoLittle());
logo.setAltText("Data Miner Manager"); logo.setAltText("Data Miner Manager");
@ -39,8 +56,9 @@ public abstract class Header extends HorizontalPanel {
menuGoBack.addClickHandler(new ClickHandler() { menuGoBack.addClickHandler(new ClickHandler() {
@Override @Override
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
if (setMenuSelected(null)) MenuEvent menuEvent = new MenuEvent(MenuType.HOME);
select(null); EventBusProvider.INSTANCE.fireEvent(menuEvent);
} }
}); });
@ -50,8 +68,8 @@ public abstract class Header extends HorizontalPanel {
menuDataSpace.addClickHandler(new ClickHandler() { menuDataSpace.addClickHandler(new ClickHandler() {
@Override @Override
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
if (setMenuSelected(MenuItem.DATA_SPACE)) MenuEvent menuEvent = new MenuEvent(MenuType.DATA_SPACE);
select(MenuItem.DATA_SPACE); EventBusProvider.INSTANCE.fireEvent(menuEvent);
} }
}); });
@ -61,8 +79,8 @@ public abstract class Header extends HorizontalPanel {
menuExperiment.addClickHandler(new ClickHandler() { menuExperiment.addClickHandler(new ClickHandler() {
@Override @Override
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
if (setMenuSelected(MenuItem.EXPERIMENT)) MenuEvent menuEvent = new MenuEvent(MenuType.EXPERIMENT);
select(MenuItem.EXPERIMENT); EventBusProvider.INSTANCE.fireEvent(menuEvent);
} }
}); });
@ -73,8 +91,8 @@ public abstract class Header extends HorizontalPanel {
@Override @Override
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
if (setMenuSelected(MenuItem.COMPUTATIONS)) MenuEvent menuEvent = new MenuEvent(MenuType.COMPUTATIONS);
select(MenuItem.COMPUTATIONS); EventBusProvider.INSTANCE.fireEvent(menuEvent);
} }
}); });
@ -99,57 +117,53 @@ public abstract class Header extends HorizontalPanel {
/** /**
* @param inputSpace * @param inputSpace
*/ */
public boolean setMenuSelected(MenuItem menuItem) { private void menuSwitch(MenuSwitchEvent event) {
// return true if the menu was changed Log.debug("MenuSwitch: " + event);
if (menuItem == currentSelection) if (event.getMenuType().compareTo(MenuType.HOME) == 0) {
return false; // nothing to change
if (menuItem == null) {
menuGoBack.setVisible(false); menuGoBack.setVisible(false);
menuDataSpace.setVisible(false); menuDataSpace.setVisible(false);
menuExperiment.setVisible(false); menuExperiment.setVisible(false);
menuComputations.setVisible(false); menuComputations.setVisible(false);
if (currentSelection == MenuItem.EXPERIMENT) if (currentSelection != null
&& currentSelection.compareTo(MenuType.EXPERIMENT) == 0)
menuExperiment.removeStyleName("menuItemImage-selected"); menuExperiment.removeStyleName("menuItemImage-selected");
else if (currentSelection == MenuItem.DATA_SPACE) else if (currentSelection != null
&& currentSelection.compareTo(MenuType.DATA_SPACE) == 0)
menuDataSpace.removeStyleName("menuItemImage-selected"); menuDataSpace.removeStyleName("menuItemImage-selected");
else if (currentSelection == MenuItem.COMPUTATIONS) else if (currentSelection != null
&& currentSelection.compareTo(MenuType.COMPUTATIONS) == 0)
menuComputations.removeStyleName("menuItemImage-selected"); menuComputations.removeStyleName("menuItemImage-selected");
} else { } else {
if (currentSelection == null) { if (currentSelection == null
|| (currentSelection != null && currentSelection
.compareTo(MenuType.HOME) == 0)) {
menuGoBack.setVisible(true); menuGoBack.setVisible(true);
menuDataSpace.setVisible(true); menuDataSpace.setVisible(true);
menuExperiment.setVisible(true); menuExperiment.setVisible(true);
menuComputations.setVisible(true); menuComputations.setVisible(true);
} }
if (currentSelection == MenuItem.EXPERIMENT) if (currentSelection != null
&& currentSelection.compareTo(MenuType.EXPERIMENT) == 0)
menuExperiment.removeStyleName("menuItemImage-selected"); menuExperiment.removeStyleName("menuItemImage-selected");
else if (currentSelection == MenuItem.DATA_SPACE) else if (currentSelection != null
&& currentSelection.compareTo(MenuType.DATA_SPACE) == 0)
menuDataSpace.removeStyleName("menuItemImage-selected"); menuDataSpace.removeStyleName("menuItemImage-selected");
else if (currentSelection == MenuItem.COMPUTATIONS) else if (currentSelection != null
&& currentSelection.compareTo(MenuType.COMPUTATIONS) == 0)
menuComputations.removeStyleName("menuItemImage-selected"); menuComputations.removeStyleName("menuItemImage-selected");
/* Image imgNew = (event.getMenuType().compareTo(MenuType.DATA_SPACE) == 0 ? menuDataSpace
* Image imgNew=menuExperiment; : (event.getMenuType().compareTo(MenuType.EXPERIMENT) == 0 ? menuExperiment
*/
/*
* Image imgNew = (menuItem == MenuItem.DATA_SPACE ? menuDataSpace :
* menuExperiment);
*/
Image imgNew = (menuItem == MenuItem.DATA_SPACE ? menuDataSpace
: (menuItem == MenuItem.EXPERIMENT ? menuExperiment
: menuComputations)); : menuComputations));
imgNew.addStyleName("menuItemImage-selected"); imgNew.addStyleName("menuItemImage-selected");
} }
currentSelection = menuItem; currentSelection = event.getMenuType();
return true; return;
} }
} }

View File

@ -0,0 +1,130 @@
package org.gcube.portlets.user.dataminermanager.client;
import org.gcube.portlets.user.dataminermanager.client.common.EventBusProvider;
import org.gcube.portlets.user.dataminermanager.client.events.MenuEvent;
import org.gcube.portlets.user.dataminermanager.client.type.MenuType;
import com.google.gwt.event.dom.client.MouseDownEvent;
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.util.Margins;
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.SimpleContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
/**
*
* @author Giancarlo Panichi email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class HomePanel extends SimpleContainer {
public HomePanel() {
super();
init();
create();
}
private void init() {
setStylePrimaryName("smMenu");
//setBodyStyle("backgroundColor:white;");
addStyleName("smLayoutContainer");
//setHeaderVisible(false);
setBorders(false);
//setBodyBorder(false);
}
private void create() {
VerticalLayoutContainer lc = new VerticalLayoutContainer();
VerticalLayoutData layoutTop = new VerticalLayoutData(-1, -1,
new Margins(20, 90, 10, 90));
VerticalLayoutData layoutNext = new VerticalLayoutData(-1, -1,
new Margins(10, 90, 10, 90));
SimpleContainer itemDataSpace = createMenuItem(
"Access to the Data Space",
"The data space contains the set of input and output data sets of the users. It is possible to upload and share tables. Data sources can be chosen from those hosted by the infrastructure. Outputs of the computations can be even saved in this space.",
DataMinerManager.resources.inputSpaceIcon(), new MouseDownHandler() {
@Override
public void onMouseDown(MouseDownEvent event) {
MenuEvent menuEvent=new MenuEvent(MenuType.DATA_SPACE);
EventBusProvider.INSTANCE.fireEvent(menuEvent);
}
});
lc.add(itemDataSpace, layoutTop);
SimpleContainer itemExperiment = createMenuItem(
"Execute an Experiment",
"This section allows to execute or prepare a Niche Modeling experiment. The section is endowed with a list of algorithms for training and executing statistical models for biological applications. Evaluation of the performances is possible by means of several kinds of measurement systems and processes.",
DataMinerManager.resources.executionIcon(), new MouseDownHandler() {
@Override
public void onMouseDown(MouseDownEvent event) {
MenuEvent menuEvent=new MenuEvent(MenuType.EXPERIMENT);
EventBusProvider.INSTANCE.fireEvent(menuEvent);
}
});
lc.add(itemExperiment, layoutNext);
SimpleContainer itemComputations = createMenuItem(
"Check the Computations",
"This section allows to check the status of the computation. A list of processes launched by the user is shown along with meta-information. By clicking on the completed jobs it is possible to visualize the data set contents.",
DataMinerManager.resources.computationsIcon(), new MouseDownHandler() {
@Override
public void onMouseDown(MouseDownEvent event) {
MenuEvent menuEvent=new MenuEvent(MenuType.COMPUTATIONS);
EventBusProvider.INSTANCE.fireEvent(menuEvent);
}
});
lc.add(itemComputations, layoutNext);
add(lc);
}
private SimpleContainer createMenuItem(String title, String description,
ImageResource imgResource, MouseDownHandler handle) {
HorizontalLayoutContainer horiz = new HorizontalLayoutContainer();
Image img = new Image(imgResource);
HTML text = new HTML("<b>" + title + "</b><br>" + description);
text.addStyleName("smMenuItemText");
HorizontalLayoutData textLayoutData = new HorizontalLayoutData(400,
140, new Margins(10, 5, 10, 10));
HorizontalLayoutData imgLayoutData = new HorizontalLayoutData(140, 140,
new Margins(10, 10, 10, 5));
horiz.add(text, textLayoutData);
horiz.add(img, imgLayoutData);
SimpleContainer container = new SimpleContainer();
container.addDomHandler(handle, MouseDownEvent.getType());
container.setWidth(540);
container.setHeight(160);
container.addStyleName("smMenuItem");
container.addStyleOnOver(container.getElement(), "smMenuItem:HOVER");
container.add(horiz);
return container;
}
}

View File

@ -0,0 +1,67 @@
package org.gcube.portlets.user.dataminermanager.client.events;
import org.gcube.portlets.user.dataminermanager.client.type.MenuType;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.event.shared.HasHandlers;
/**
* Menu Event
*
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class MenuEvent extends
GwtEvent<MenuEvent.MenuEventHandler> {
public static Type<MenuEventHandler> TYPE = new Type<MenuEventHandler>();
private MenuType menuType;
public interface MenuEventHandler extends EventHandler {
void onSelect(MenuEvent event);
}
public interface HasMenuEventHandler extends HasHandlers {
public HandlerRegistration addMenuEventHandler(
MenuEventHandler handler);
}
public MenuEvent(
MenuType menuType) {
this.menuType = menuType;
}
@Override
protected void dispatch(MenuEventHandler handler) {
handler.onSelect(this);
}
@Override
public Type<MenuEventHandler> getAssociatedType() {
return TYPE;
}
public static Type<MenuEventHandler> getType() {
return TYPE;
}
public static void fire(HasHandlers source, MenuEvent event) {
source.fireEvent(event);
}
public MenuType getMenuType() {
return menuType;
}
@Override
public String toString() {
return "MenuEvent []";
}
}

View File

@ -0,0 +1,64 @@
package org.gcube.portlets.user.dataminermanager.client.events;
import org.gcube.portlets.user.dataminermanager.client.type.MenuType;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.event.shared.HasHandlers;
/**
* Menu Event
*
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class MenuSwitchEvent extends
GwtEvent<MenuSwitchEvent.MenuSwitchEventHandler> {
public static Type<MenuSwitchEventHandler> TYPE = new Type<MenuSwitchEventHandler>();
private MenuType menuType;
public interface MenuSwitchEventHandler extends EventHandler {
void onSelect(MenuSwitchEvent event);
}
public interface HasMenuSwitchEventHandler extends HasHandlers {
public HandlerRegistration addMenuSwitchEventHandler(
MenuSwitchEventHandler handler);
}
public MenuSwitchEvent(MenuType menuType) {
this.menuType = menuType;
}
@Override
protected void dispatch(MenuSwitchEventHandler handler) {
handler.onSelect(this);
}
@Override
public Type<MenuSwitchEventHandler> getAssociatedType() {
return TYPE;
}
public static Type<MenuSwitchEventHandler> getType() {
return TYPE;
}
public static void fire(HasHandlers source, MenuSwitchEvent event) {
source.fireEvent(event);
}
public MenuType getMenuType() {
return menuType;
}
@Override
public String toString() {
return "MenuSwitchEvent [menuType=" + menuType + "]";
}
}

View File

@ -138,7 +138,7 @@ public class ComputationStatusPanel extends SimpleContainer {
progressBar =new ProgressBar(cell); progressBar =new ProgressBar(cell);
progressBar.updateProgress(1, "Computation Complete"); progressBar.updateProgress(1, "Computation Complete");
progressBar.addStyleName("progressBar-complete"); progressBar.addStyleName("progressBar-complete");
vert.insert(progressBar, index); vert.insert(progressBar, index, new VerticalLayoutData(1, -1, new Margins(20)));
showOutput(); showOutput();
} else if (computationStatus.isFailed()) { } else if (computationStatus.isFailed()) {
@ -160,7 +160,7 @@ public class ComputationStatusPanel extends SimpleContainer {
progressBar.updateProgress(1, "Computation Fail"); progressBar.updateProgress(1, "Computation Fail");
progressBar.getElement().getStyle().setMarginBottom(36, Unit.PX); progressBar.getElement().getStyle().setMarginBottom(36, Unit.PX);
progressBar.addStyleName("progressBar-failed"); progressBar.addStyleName("progressBar-failed");
vert.insert(progressBar, index); vert.insert(progressBar, index, new VerticalLayoutData(1, -1, new Margins(20)));
} }
} }
@ -212,7 +212,7 @@ public class ComputationStatusPanel extends SimpleContainer {
progressBar.updateProgress(1, "Failed to get the status"); progressBar.updateProgress(1, "Failed to get the status");
progressBar.getElement().getStyle().setMarginBottom(36, Unit.PX); progressBar.getElement().getStyle().setMarginBottom(36, Unit.PX);
progressBar.addStyleName("progressBar-failed"); progressBar.addStyleName("progressBar-failed");
vert.insert(progressBar, index); vert.insert(progressBar, index, new VerticalLayoutData(1, -1, new Margins(20)));
} }

View File

@ -0,0 +1,11 @@
package org.gcube.portlets.user.dataminermanager.client.type;
/**
*
* @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public enum MenuType {
HOME, DATA_SPACE, EXPERIMENT, COMPUTATIONS;
}

View File

@ -5,6 +5,7 @@ import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -26,7 +27,6 @@ import net.opengis.wps.x100.SupportedComplexDataInputType;
import net.opengis.wps.x100.impl.ExecuteResponseDocumentImpl; import net.opengis.wps.x100.impl.ExecuteResponseDocumentImpl;
import org.apache.xmlbeans.XmlString; import org.apache.xmlbeans.XmlString;
import org.gcube.portlets.user.dataminermanager.client.bean.ComputationItem;
import org.gcube.portlets.user.dataminermanager.client.bean.ComputationStatus; import org.gcube.portlets.user.dataminermanager.client.bean.ComputationStatus;
import org.gcube.portlets.user.dataminermanager.client.bean.ComputationStatus.Status; import org.gcube.portlets.user.dataminermanager.client.bean.ComputationStatus.Status;
import org.gcube.portlets.user.dataminermanager.client.bean.Operator; import org.gcube.portlets.user.dataminermanager.client.bean.Operator;
@ -40,6 +40,7 @@ import org.gcube.portlets.user.dataminermanager.client.bean.output.Resource;
import org.gcube.portlets.user.dataminermanager.client.bean.parameters.ObjectParameter; import org.gcube.portlets.user.dataminermanager.client.bean.parameters.ObjectParameter;
import org.gcube.portlets.user.dataminermanager.client.bean.parameters.Parameter; import org.gcube.portlets.user.dataminermanager.client.bean.parameters.Parameter;
import org.gcube.portlets.user.dataminermanager.server.is.InformationSystemUtils; import org.gcube.portlets.user.dataminermanager.server.is.InformationSystemUtils;
import org.gcube.portlets.user.dataminermanager.server.smservice.wps.ProcessInformations;
import org.gcube.portlets.user.dataminermanager.server.smservice.wps.ResponseWPS; 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.StatWPSClientSession;
import org.gcube.portlets.user.dataminermanager.server.smservice.wps.WPS2SM; import org.gcube.portlets.user.dataminermanager.server.smservice.wps.WPS2SM;
@ -65,7 +66,7 @@ import org.w3c.dom.NodeList;
public class SClient4WPS extends SClient { public class SClient4WPS extends SClient {
private static Logger logger = LoggerFactory.getLogger(SClient4WPS.class); private static Logger logger = LoggerFactory.getLogger(SClient4WPS.class);
//private static final int OPERATOR_BRIEF_DESCRIPTION_MAX_LENGHT = 170; // private static final int OPERATOR_BRIEF_DESCRIPTION_MAX_LENGHT = 170;
private static final String OTHERS = "OTHERS"; private static final String OTHERS = "OTHERS";
private String wpsToken; private String wpsToken;
@ -75,16 +76,17 @@ public class SClient4WPS extends SClient {
private String wpsCancelComputationServlet; private String wpsCancelComputationServlet;
private ProcessDescriptionType[] processesDescriptionType; private ProcessDescriptionType[] processesDescriptionType;
private ProcessBriefType[] processBriefs; private ProcessBriefType[] processesBriefs;
private ProcessDescriptionType currentProcessDescription; private HashMap<String, ProcessInformations> process;
private InputDescriptionType[] currentInputs; private HashMap<ComputationId, ProcessInformations> runningProcess;
private OutputDescriptionType[] currentOutputs;
private StatWPSClientSession wpsClient; private StatWPSClientSession wpsClient;
public SClient4WPS(ServiceCredential serviceCredential) throws Exception { public SClient4WPS(ServiceCredential serviceCredential) throws Exception {
super(); super();
process = new HashMap<>();
runningProcess = new HashMap<>();
if (serviceCredential == null) { if (serviceCredential == null) {
logger.error("Error credetials are null!"); logger.error("Error credetials are null!");
throw new Exception("Error credetials are null!"); throw new Exception("Error credetials are null!");
@ -157,12 +159,12 @@ public class SClient4WPS extends SClient {
LinkedHashMap<String, String> operatorsToCategoriesMap = new LinkedHashMap<>(); LinkedHashMap<String, String> operatorsToCategoriesMap = new LinkedHashMap<>();
LinkedHashMap<String, List<Operator>> categoriesToOperatorsMap = new LinkedHashMap<>(); LinkedHashMap<String, List<Operator>> categoriesToOperatorsMap = new LinkedHashMap<>();
connect(); requestCapability();
if (processBriefs == null || processesDescriptionType == null) { if (processesBriefs == null || processesDescriptionType == null) {
throw new ServiceException("Algorithms WPS not available!"); throw new ServiceException("Algorithms WPS not available!");
} }
for (ProcessBriefType processBrief : processBriefs) { for (ProcessBriefType processBrief : processesBriefs) {
String categoryTitle = processBrief.getTitle().getStringValue(); String categoryTitle = processBrief.getTitle().getStringValue();
String categoryName; String categoryName;
if (categoryTitle == null || categoryTitle.isEmpty()) { if (categoryTitle == null || categoryTitle.isEmpty()) {
@ -251,12 +253,17 @@ public class SClient4WPS extends SClient {
return operatorsClass; return operatorsClass;
} }
private void describeProcess(String processID) throws Exception { private ProcessInformations describeProcess(String processId)
describeProcess(processID, null); throws Exception {
return describeProcess(processId, null);
} }
private void describeProcess(String processID, URL processDescriptionURL) private ProcessInformations describeProcess(String processId,
throws Exception { URL processDescriptionURL) throws Exception {
if (process.containsKey(processId)) {
return process.get(processId);
}
StatWPSClientSession wpsClient = null; StatWPSClientSession wpsClient = null;
try { try {
wpsClient = createWPSClientSession(); wpsClient = createWPSClientSession();
@ -266,7 +273,7 @@ public class SClient4WPS extends SClient {
for (int k = 0; k <= 3; k++) { for (int k = 0; k <= 3; k++) {
try { try {
processDescription = wpsClient.getProcessDescription( processDescription = wpsClient.getProcessDescription(
wpsProcessingServlet, processID); wpsProcessingServlet, processId);
} catch (Exception e) { } catch (Exception e) {
logger.debug("Retrying with WPS URL: " logger.debug("Retrying with WPS URL: "
+ wpsProcessingServlet); + wpsProcessingServlet);
@ -276,7 +283,9 @@ public class SClient4WPS extends SClient {
if (processDescription != null) if (processDescription != null)
break; break;
} }
this.currentProcessDescription = processDescription;
ProcessInformations processInformations = new ProcessInformations(
processDescription);
if (processDescriptionURL != null) if (processDescriptionURL != null)
processDescription.set(XmlString.Factory processDescription.set(XmlString.Factory
@ -298,9 +307,12 @@ public class SClient4WPS extends SClient {
logger.debug("WPSClient->Output: " + output); logger.debug("WPSClient->Output: " + output);
} }
currentInputs = inputList; processInformations.setInputs(inputList);
currentOutputs = outputList; processInformations.setOutputs(outputList);
process.put(processId, processInformations);
return processInformations;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
throw e; throw e;
@ -309,10 +321,10 @@ public class SClient4WPS extends SClient {
} }
} }
private void connect() throws ServiceException { private void requestCapability() throws ServiceException {
StatWPSClientSession wpsClient = null; StatWPSClientSession wpsClient = null;
processesDescriptionType = null; processesDescriptionType = null;
processBriefs = null; processesBriefs = null;
try { try {
wpsClient = createWPSClientSession(); wpsClient = createWPSClientSession();
@ -325,7 +337,7 @@ public class SClient4WPS extends SClient {
CapabilitiesDocument capabilitiesDocument = wpsClient CapabilitiesDocument capabilitiesDocument = wpsClient
.getWPSCaps(wpsProcessingServlet); .getWPSCaps(wpsProcessingServlet);
processBriefs = capabilitiesDocument.getCapabilities() processesBriefs = capabilitiesDocument.getCapabilities()
.getProcessOfferings().getProcessArray(); .getProcessOfferings().getProcessArray();
return; return;
@ -340,14 +352,7 @@ public class SClient4WPS extends SClient {
} }
private ProcessDescriptionType getProcessDescription() {
return currentProcessDescription;
}
private void setProcessDescription(ProcessDescriptionType processDescription) {
this.currentProcessDescription = processDescription;
}
private String executeProcessAsync(ExecuteRequestBuilder executeBuilder, private String executeProcessAsync(ExecuteRequestBuilder executeBuilder,
ProcessDescriptionType processDescription) throws Exception { ProcessDescriptionType processDescription) throws Exception {
try { try {
@ -629,9 +634,11 @@ public class SClient4WPS extends SClient {
throws Exception { throws Exception {
try { try {
logger.info("Parameters of algorithm " + operator.getId()); logger.info("Parameters of algorithm " + operator.getId());
ProcessInformations processInformations;
try { try {
describeProcess(operator.getId()); processInformations = describeProcess(operator
.getId());
} catch (Throwable e) { } catch (Throwable e) {
logger.error("GetParameters: " + e.getLocalizedMessage()); logger.error("GetParameters: " + e.getLocalizedMessage());
e.printStackTrace(); e.printStackTrace();
@ -641,7 +648,7 @@ public class SClient4WPS extends SClient {
List<Parameter> parameters = new ArrayList<>(); List<Parameter> parameters = new ArrayList<>();
Parameter inputParameter; Parameter inputParameter;
for (InputDescriptionType inputDesc : currentInputs) { for (InputDescriptionType inputDesc : processInformations.getInputs()) {
inputParameter = WPS2SM.convert2SMType(inputDesc); inputParameter = WPS2SM.convert2SMType(inputDesc);
logger.debug("InputParameter: " + inputParameter); logger.debug("InputParameter: " + inputParameter);
parameters.add(inputParameter); parameters.add(inputParameter);
@ -663,10 +670,10 @@ public class SClient4WPS extends SClient {
public ComputationId startComputation(Operator operator, public ComputationId startComputation(Operator operator,
String computationTitle, String computationDescription) String computationTitle, String computationDescription)
throws Exception { throws Exception {
// TODO Auto-generated method stub ProcessInformations processInformations;
try { try {
describeProcess(operator.getId()); processInformations = describeProcess(operator
.getId());
} catch (Throwable e) { } catch (Throwable e) {
logger.error("GetParameters: " + e.getLocalizedMessage()); logger.error("GetParameters: " + e.getLocalizedMessage());
e.printStackTrace(); e.printStackTrace();
@ -676,7 +683,7 @@ public class SClient4WPS extends SClient {
LinkedHashMap<String, Parameter> inputParameters = new LinkedHashMap<>(); LinkedHashMap<String, Parameter> inputParameters = new LinkedHashMap<>();
Parameter inputParameter; Parameter inputParameter;
for (InputDescriptionType inputDesc : currentInputs) { for (InputDescriptionType inputDesc : processInformations.getInputs()) {
inputParameter = WPS2SM.convert2SMType(inputDesc); inputParameter = WPS2SM.convert2SMType(inputDesc);
logger.debug("InputParameter: " + inputParameter); logger.debug("InputParameter: " + inputParameter);
inputParameters.put(inputParameter.getName(), inputParameter); inputParameters.put(inputParameter.getName(), inputParameter);
@ -690,7 +697,7 @@ public class SClient4WPS extends SClient {
+ parm.getValue()); + parm.getValue());
} }
String processUrl = compute(userInputs, inputParameters, String processUrl = compute(processInformations, userInputs, inputParameters,
computationTitle, computationDescription); computationTitle, computationDescription);
logger.debug("Stated Computation ProcessLocation:" + processUrl); logger.debug("Stated Computation ProcessLocation:" + processUrl);
@ -704,19 +711,21 @@ public class SClient4WPS extends SClient {
} }
ComputationId computationId = new ComputationId(id, processUrl); ComputationId computationId = new ComputationId(id, processUrl);
logger.debug("ComputationId: " + computationId); logger.debug("ComputationId: " + computationId);
runningProcess.put(computationId, processInformations);
return computationId; return computationId;
} }
private String compute(Map<String, String> userInputs, private String compute(ProcessInformations processInformations, Map<String, String> userInputs,
Map<String, Parameter> inputParameters, String computationTitle, Map<String, Parameter> inputParameters, String computationTitle,
String computationDescription) throws Exception { String computationDescription) throws Exception {
try { try {
// setup the inputs // setup the inputs
org.n52.wps.client.ExecuteRequestBuilder executeBuilder = new org.n52.wps.client.ExecuteRequestBuilder( org.n52.wps.client.ExecuteRequestBuilder executeBuilder = new org.n52.wps.client.ExecuteRequestBuilder(
currentProcessDescription); processInformations.getProcessDescription());
// for each input // for each input
for (InputDescriptionType input : currentInputs) { for (InputDescriptionType input : processInformations.getInputs()) {
// retrieve the input from the sm config // retrieve the input from the sm config
String value = userInputs.get(input.getIdentifier() String value = userInputs.get(input.getIdentifier()
.getStringValue()); .getStringValue());
@ -764,7 +773,7 @@ public class SClient4WPS extends SClient {
// Submit the execution // Submit the execution
String statusLocation = executeProcessAsync(executeBuilder, String statusLocation = executeProcessAsync(executeBuilder,
currentProcessDescription); processInformations.getProcessDescription());
logger.debug("Starting Process: " + statusLocation); logger.debug("Starting Process: " + statusLocation);
return statusLocation; return statusLocation;
@ -913,27 +922,27 @@ public class SClient4WPS extends SClient {
@Override @Override
public Resource getResourceByComputationId(ComputationId computationId) public Resource getResourceByComputationId(ComputationId computationId)
throws Exception { throws Exception {
Map<String, Resource> resources = retrieveOutput(computationId Map<String, Resource> resources = retrieveOutput(computationId);
.getUrlId());
MapResource mapResource = new MapResource("mapResource", "Resources", MapResource mapResource = new MapResource("mapResource", "Resources",
"Resources", resources); "Resources", resources);
return mapResource; return mapResource;
} }
private Map<String, Resource> retrieveOutput(String processLocation) private Map<String, Resource> retrieveOutput(ComputationId computationId)
throws Exception { throws Exception {
Map<String, Resource> outputResource = new LinkedHashMap<>(); Map<String, Resource> outputResource = new LinkedHashMap<>();
Map<String, Parameter> outputParameters = new LinkedHashMap<>(); Map<String, Parameter> outputParameters = new LinkedHashMap<>();
ProcessInformations processInformations=runningProcess.get(computationId);
Parameter outputParameter; Parameter outputParameter;
for (OutputDescriptionType outputDesc : currentOutputs) { for (OutputDescriptionType outputDesc : processInformations.getOutputs()) {
outputParameter = WPS2SM.convert2SMType(outputDesc); outputParameter = WPS2SM.convert2SMType(outputDesc);
logger.debug("OutputParameter: " + outputParameter); logger.debug("OutputParameter: " + outputParameter);
outputParameters.put(outputParameter.getName(), outputParameter); outputParameters.put(outputParameter.getName(), outputParameter);
} }
retrieveProcessOutput(processLocation, outputParameters, outputResource); retrieveProcessOutput(computationId.getUrlId(), outputParameters, outputResource);
return outputResource; return outputResource;
@ -1121,7 +1130,7 @@ public class SClient4WPS extends SClient {
@Override @Override
public ComputationId resubmitComputation(ComputationId computationId) public ComputationId resubmitComputation(ComputationId computationId)
throws Exception { throws Exception {
//TODO // TODO
return null; return null;
} }

View File

@ -0,0 +1,65 @@
package org.gcube.portlets.user.dataminermanager.server.smservice.wps;
import java.io.Serializable;
import java.util.Arrays;
import net.opengis.wps.x100.InputDescriptionType;
import net.opengis.wps.x100.OutputDescriptionType;
import net.opengis.wps.x100.ProcessDescriptionType;
public class ProcessInformations implements Serializable {
private static final long serialVersionUID = 4729933672312944832L;
private ProcessDescriptionType processDescription;
private InputDescriptionType[] inputs;
private OutputDescriptionType[] outputs;
public ProcessInformations(ProcessDescriptionType processDescription) {
super();
this.processDescription = processDescription;
this.inputs = new InputDescriptionType[0];
this.outputs = new OutputDescriptionType[0];
}
public ProcessInformations(ProcessDescriptionType processDescription,
InputDescriptionType[] inputs, OutputDescriptionType[] outputs) {
super();
this.processDescription = processDescription;
this.inputs = inputs;
this.outputs = outputs;
}
public ProcessDescriptionType getProcessDescription() {
return processDescription;
}
public void setProcessDescription(
ProcessDescriptionType processDescription) {
this.processDescription = processDescription;
}
public InputDescriptionType[] getInputs() {
return inputs;
}
public void setInputs(InputDescriptionType[] inputs) {
this.inputs = inputs;
}
public OutputDescriptionType[] getOutputs() {
return outputs;
}
public void setOutputs(OutputDescriptionType[] outputs) {
this.outputs = outputs;
}
@Override
public String toString() {
return "ProcessInformations [processDescription="
+ processDescription + ", inputs="
+ Arrays.toString(inputs) + ", outputs="
+ Arrays.toString(outputs) + "]";
}
}

View File

@ -48,7 +48,7 @@
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" 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_ConsoleLogger" value="DISABLED" />
<set-property name="log_DivLogger" value="DISABLED" /> <set-property name="log_DivLogger" value="DISABLED" />
<set-property name="log_GWTLogger" value="DISABLED" /> <set-property name="log_GWTLogger" value="DISABLED" />

View File

@ -32,7 +32,7 @@
.smMenu { .smMenu {
width: 720px !important; width: 720px !important;
height: 600px !important; height: 570px !important;
margin: auto; margin: auto;
margin-bottom: 20px; margin-bottom: 20px;
} }