ref 11720: TDM - Update to StorageHUB

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

Updated to StorageHub 

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/data-miner-manager-widget@169473 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2018-06-27 09:03:54 +00:00
parent 5801474f2a
commit 289d9b4276
21 changed files with 815 additions and 748 deletions

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/data-miner-manager-widget-1.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/data-miner-manager-widget-1.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/data-miner-manager-widget-1.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<classpathentry excluding="**" kind="src" output="target/data-miner-manager-widget-1.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
@ -33,5 +33,5 @@
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="target/data-miner-manager-widget-1.1.0-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/data-miner-manager-widget-1.2.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

View File

@ -1,4 +1,9 @@
<ReleaseNotes>
<Changeset component="org.gcube.portlets.widgets.data-miner-manager-widget.1-2-0"
date="2018-07-01">
<Change>Updated to support StorageHUB[ticket #11879]</Change>
<Change>Added support to netcdf files</Change>
</Changeset>
<Changeset component="org.gcube.portlets.widgets.data-miner-manager-widget.1-1-0"
date="2017-06-12">
<Change>Support Java 8 compatibility [ticket #8471]</Change>

34
pom.xml
View File

@ -12,7 +12,7 @@
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>data-miner-manager-widget</artifactId>
<version>1.1.0-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
<name>data-miner-manager-widget</name>
<description>data-miner-manager-widget offers a unique access to perform data mining and statistical operations on heterogeneous data</description>
@ -97,6 +97,14 @@
<scope>runtime</scope>
</dependency>
<!-- StorageHub -->
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>storagehub-client-library</artifactId>
<scope>runtime</scope>
</dependency>
<!-- Home Library -->
<dependency>
<groupId>org.gcube.common</groupId>
@ -221,6 +229,14 @@
<scope>provided</scope>
</dependency>
<!-- StorageHub -->
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>storagehub-client-library</artifactId>
<scope>compile</scope>
</dependency>
<!-- Home Library -->
<dependency>
<groupId>org.gcube.common</groupId>
@ -274,13 +290,11 @@
<version>[1.2.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
</dependency>
<!-- Workspace Explorer -->
<dependency>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>workspace-explorer</artifactId>
<version>[1.4.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
</dependency>
<!-- Workspace Uploader -->
@ -297,6 +311,14 @@
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
</dependency>
<!-- NetCDF Basic Widget -->
<dependency>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>netcdf-basic-widgets</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
</dependency>
<!-- DataMinerManagerCL -->
<dependency>
<groupId>org.gcube.data.analysis</groupId>
@ -316,13 +338,13 @@
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>

View File

@ -2,8 +2,13 @@ package org.gcube.portlets.widgets.dataminermanagerwidget.client.computations;
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationValueFile;
import org.gcube.portlets.widgets.dataminermanagerwidget.client.DataMinerManagerPanel;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.SelectVariableEvent;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.SelectVariableEvent.SelectVariableEventHandler;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.widgets.NetCDFPreviewDialog;
import com.google.gwt.core.client.GWT;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.sencha.gxt.core.client.dom.XDOM;
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;
@ -58,9 +63,47 @@ public class ComputationValueFilePanel extends SimpleContainer {
}
});
TextButton netcdfButton = new TextButton("");
netcdfButton.setIcon(DataMinerManagerPanel.resources.netcdf());
netcdfButton.addSelectHandler(new SelectEvent.SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
showNetCDFFile();
}
});
lc.add(downloadBtn, new VerticalLayoutData(-1, -1, new Margins(0)));
if (computationValueFile.isNetcdf()) {
lc.add(netcdfButton, new VerticalLayoutData(-1, -1, new Margins(0)));
}
add(lc);
}
private void showNetCDFFile() {
if (computationValueFile != null && computationValueFile.getValue() != null && !computationValueFile.getValue().isEmpty()
&& computationValueFile.isNetcdf()) {
GWT.log("NetcdfBasicWidgetsManager");
// Example
SelectVariableEventHandler handler = new SelectVariableEventHandler() {
@Override
public void onResponse(SelectVariableEvent event) {
GWT.log("SelectVariable Response: " + event);
}
};
NetCDFPreviewDialog netcdfDialog = new NetCDFPreviewDialog(computationValueFile.getValue());
netcdfDialog.addSelectVariableEventHandler(handler);
netcdfDialog.setZIndex(XDOM.getTopZIndex());
}
}
}

View File

@ -24,7 +24,7 @@ import org.gcube.portlets.widgets.dataminermanagerwidget.shared.workspace.ItemDe
import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploadNotification.WorskpaceUploadNotificationListener;
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.DialogUpload.UPLOAD_TYPE;
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload;
import org.gcube.portlets.widgets.wsexplorer.client.explore.WorkspaceResourcesExplorerPanel;
import org.gcube.portlets.widgets.wsexplorer.client.explore.WorkspaceResourcesExplorerPanelPaginated;
import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSelectNotification.WorskpaceExplorerSelectNotificationListener;
import org.gcube.portlets.widgets.wsexplorer.client.view.grid.ItemsTable.DISPLAY_FIELD;
import org.gcube.portlets.widgets.wsexplorer.shared.FilterCriteria;
@ -58,12 +58,13 @@ public class ComputationsExecutedPanel extends FramedPanel {
private Item selectedItem;
private MultipleDNDUpload dnd;
private WorkspaceResourcesExplorerPanel wsResourcesExplorerPanel;
private WorkspaceResourcesExplorerPanelPaginated wsResourcesExplorerPanel;
// private WorkspaceResourcesExplorerPanel wsResourcesExplorerPanel;
private TextButton btnShow;
private TextButton btnDownload;
private TextButton btnDelete;
private TextButton btnRefresh;
//private TextButton btnResubmit;
// private TextButton btnResubmit;
private TextButton btnCancel;
private VerticalLayoutContainer v;
@ -92,15 +93,14 @@ public class ComputationsExecutedPanel extends FramedPanel {
private void bindToEvents() {
EventBusProvider.INSTANCE.addHandler(UIStateEvent.TYPE,
new UIStateEvent.UIStateEventHandler() {
EventBusProvider.INSTANCE.addHandler(UIStateEvent.TYPE, new UIStateEvent.UIStateEventHandler() {
@Override
public void onChange(UIStateEvent event) {
manageStateEvents(event);
@Override
public void onChange(UIStateEvent event) {
manageStateEvents(event);
}
});
}
});
EventBusProvider.INSTANCE.addHandler(DataMinerWorkAreaEvent.TYPE,
new DataMinerWorkAreaEvent.DataMinerWorkAreaEventHandler() {
@ -113,19 +113,16 @@ public class ComputationsExecutedPanel extends FramedPanel {
});
EventBusProvider.INSTANCE
.addHandler(
RefreshDataMinerWorkAreaEvent.TYPE,
new RefreshDataMinerWorkAreaEvent.RefreshDataMinerWorkAreaEventHandler() {
EventBusProvider.INSTANCE.addHandler(RefreshDataMinerWorkAreaEvent.TYPE,
new RefreshDataMinerWorkAreaEvent.RefreshDataMinerWorkAreaEventHandler() {
@Override
public void onRefresh(
RefreshDataMinerWorkAreaEvent event) {
manageRefreshDataMinerWorkAreaEvents(event);
@Override
public void onRefresh(RefreshDataMinerWorkAreaEvent event) {
manageRefreshDataMinerWorkAreaEvents(event);
}
}
});
});
}
@ -150,8 +147,7 @@ public class ComputationsExecutedPanel extends FramedPanel {
private void manageDataMinerWorkAreaEvents(DataMinerWorkAreaEvent event) {
Log.debug("ComputationsExecutedPanel recieved DataMinerWorkAreaEvent: "
+ event);
Log.debug("ComputationsExecutedPanel recieved DataMinerWorkAreaEvent: " + event);
if (event == null) {
Log.error("DataMinerWorkAreaEvent null");
return;
@ -181,10 +177,8 @@ public class ComputationsExecutedPanel extends FramedPanel {
}
private void manageRefreshDataMinerWorkAreaEvents(
RefreshDataMinerWorkAreaEvent event) {
Log.debug("ComputationsExecutedPanel recieved RefreshDataMinerWorkAreaEvent: "
+ event);
private void manageRefreshDataMinerWorkAreaEvents(RefreshDataMinerWorkAreaEvent event) {
Log.debug("ComputationsExecutedPanel recieved RefreshDataMinerWorkAreaEvent: " + event);
if (event == null) {
Log.error("RefreshDataMinerWorkAreaEvent null");
return;
@ -204,17 +198,14 @@ public class ComputationsExecutedPanel extends FramedPanel {
}
private void create(DataMinerWorkAreaEvent event) {
Log.debug("Create ComputationsExecutedPanel");
try {
if (event == null
|| event.getDataMinerWorkArea() == null
if (event == null || event.getDataMinerWorkArea() == null
|| event.getDataMinerWorkArea().getComputations() == null
|| event.getDataMinerWorkArea().getComputations()
.getFolder() == null
|| event.getDataMinerWorkArea().getComputations()
.getFolder().getId() == null
|| event.getDataMinerWorkArea().getComputations()
.getFolder().getId().isEmpty()) {
|| event.getDataMinerWorkArea().getComputations().getFolder() == null
|| event.getDataMinerWorkArea().getComputations().getFolder().getId() == null
|| event.getDataMinerWorkArea().getComputations().getFolder().getId().isEmpty()) {
if (v != null) {
remove(v);
forceLayout();
@ -224,18 +215,27 @@ public class ComputationsExecutedPanel extends FramedPanel {
}
List<String> showProperties = new ArrayList<String>();
for (ComputationsPropertiesType computationsProperties : ComputationsPropertiesType
.values()) {
for (ComputationsPropertiesType computationsProperties : ComputationsPropertiesType.values()) {
showProperties.add(computationsProperties.getLabel());
}
FilterCriteria filterCriteria = new FilterCriteria();
Map<String, String> map = new HashMap<String, String>();
filterCriteria.setRequiredProperties(map);
wsResourcesExplorerPanel = new WorkspaceResourcesExplorerPanel(
event.getDataMinerWorkArea().getComputations().getFolder()
.getId(), false, showProperties, filterCriteria,
true, DISPLAY_FIELD.CREATION_DATE);
/*
* wsResourcesExplorerPanel = new WorkspaceResourcesExplorerPanel(
* event.getDataMinerWorkArea().getComputations().getFolder()
* .getId(), false, showProperties, filterCriteria, true,
* DISPLAY_FIELD.CREATION_DATE);
*/
Log.debug("Create wsResourcesExplorerPanel for Computations: ["
+ event.getDataMinerWorkArea().getComputations().getFolder().getId() + ", false, " + showProperties
+ ", " + filterCriteria + ", true, " + DISPLAY_FIELD.CREATION_DATE + "]");
wsResourcesExplorerPanel = new WorkspaceResourcesExplorerPanelPaginated(
event.getDataMinerWorkArea().getComputations().getFolder().getId(), false, showProperties,
filterCriteria, true, DISPLAY_FIELD.CREATION_DATE);
Log.debug("Created wsResourcesExplorerPanel");
WorskpaceExplorerSelectNotificationListener wsResourceExplorerListener = new WorskpaceExplorerSelectNotificationListener() {
@Override
public void onSelectedItem(Item item) {
@ -260,10 +260,10 @@ public class ComputationsExecutedPanel extends FramedPanel {
selectedItem = null;
}
};
wsResourcesExplorerPanel
.addWorkspaceExplorerSelectNotificationListener(wsResourceExplorerListener);
wsResourcesExplorerPanel.ensureDebugId("wsResourceExplorerPanel");
Log.debug("Add WorkspaceExplorerSelectNotificationListener");
wsResourcesExplorerPanel.addWorkspaceExplorerSelectNotificationListener(wsResourceExplorerListener);
wsResourcesExplorerPanel.ensureDebugId("wsResourceExplorerPanelComputaions");
Log.debug("Set Height to internal SCROLL 300");
wsResourcesExplorerPanel.setHeightToInternalScroll(300);
/*
@ -273,18 +273,17 @@ public class ComputationsExecutedPanel extends FramedPanel {
* vResourcesExplorerContainer.add(wsResourcesExplorerPanel, new
* VerticalLayoutData(1, -1, new Margins(0)));
*/
Log.debug("Define DND for Computations");
// DND
dnd = new MultipleDNDUpload();
dnd.setParameters(event.getDataMinerWorkArea().getComputations()
.getFolder().getId(), UPLOAD_TYPE.File);
dnd.setParameters(event.getDataMinerWorkArea().getComputations().getFolder().getId(), UPLOAD_TYPE.File);
dnd.addUniqueContainer(wsResourcesExplorerPanel);
WorskpaceUploadNotificationListener workspaceUploaderListener = new WorskpaceUploadNotificationListener() {
@Override
public void onUploadCompleted(String parentId, String itemId) {
Log.debug("Upload completed: [parentID: " + parentId
+ ", itemId: " + itemId + "]");
Log.debug("Upload completed: [parentID: " + parentId + ", itemId: " + itemId + "]");
wsResourcesExplorerPanel.refreshRootFolderView();
forceLayout();
@ -292,22 +291,18 @@ public class ComputationsExecutedPanel extends FramedPanel {
@Override
public void onUploadAborted(String parentId, String itemId) {
Log.debug("Upload Aborted: [parentID: " + parentId
+ ", itemId: " + itemId + "]");
Log.debug("Upload Aborted: [parentID: " + parentId + ", itemId: " + itemId + "]");
}
@Override
public void onError(String parentId, String itemId,
Throwable throwable) {
Log.debug("Upload Error: [parentID: " + parentId
+ ", itemId: " + itemId + "]");
public void onError(String parentId, String itemId, Throwable throwable) {
Log.debug("Upload Error: [parentID: " + parentId + ", itemId: " + itemId + "]");
throwable.printStackTrace();
}
@Override
public void onOverwriteCompleted(String parentId, String itemId) {
Log.debug("Upload Override Completed: [parentID: "
+ parentId + ", itemId: " + itemId + "]");
Log.debug("Upload Override Completed: [parentID: " + parentId + ", itemId: " + itemId + "]");
wsResourcesExplorerPanel.refreshRootFolderView();
forceLayout();
}
@ -372,19 +367,19 @@ public class ComputationsExecutedPanel extends FramedPanel {
});
/*btnResubmit = new TextButton("Resubmit");
btnResubmit.setIcon(DataMinerManagerPanel.resources.resubmit());
btnResubmit.setScale(ButtonScale.SMALL);
btnResubmit.setIconAlign(IconAlign.LEFT);
btnResubmit.setToolTip("Resubmit");
btnResubmit.addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
resubmitComputation();
}
});*/
/*
* btnResubmit = new TextButton("Resubmit");
* btnResubmit.setIcon(DataMinerManagerPanel.resources.resubmit());
* btnResubmit.setScale(ButtonScale.SMALL);
* btnResubmit.setIconAlign(IconAlign.LEFT);
* btnResubmit.setToolTip("Resubmit");
* btnResubmit.addSelectHandler(new SelectHandler() {
*
* @Override public void onSelect(SelectEvent event) {
* resubmitComputation(); }
*
* });
*/
btnCancel = new TextButton("Cancel");
btnCancel.setIcon(DataMinerManagerPanel.resources.cancelCircle());
@ -405,7 +400,7 @@ public class ComputationsExecutedPanel extends FramedPanel {
toolBar.add(btnDownload, new BoxLayoutData(new Margins(0)));
toolBar.add(btnDelete, new BoxLayoutData(new Margins(0)));
toolBar.add(btnRefresh, new BoxLayoutData(new Margins(0)));
//toolBar.add(btnResubmit, new BoxLayoutData(new Margins(0)));
// toolBar.add(btnResubmit, new BoxLayoutData(new Margins(0)));
toolBar.add(btnCancel, new BoxLayoutData(new Margins(0)));
v = new VerticalLayoutContainer();
@ -418,11 +413,9 @@ public class ComputationsExecutedPanel extends FramedPanel {
@Override
public void onResize(ResizeEvent event) {
int scrollBarHeight = event.getHeight()
- toolBar.getElement().getHeight(false);
int scrollBarHeight = event.getHeight() - toolBar.getElement().getHeight(false);
Log.debug("ScrollBarHeight: " + scrollBarHeight);
wsResourcesExplorerPanel
.setHeightToInternalScroll(scrollBarHeight);
wsResourcesExplorerPanel.setHeightToInternalScroll(scrollBarHeight);
forceLayout();
}
@ -437,7 +430,13 @@ public class ComputationsExecutedPanel extends FramedPanel {
private void refreshWSResourceExplorerPanel() {
if (wsResourcesExplorerPanel != null) {
wsResourcesExplorerPanel.refreshRootFolderView();
try {
// wsResourcesExplorerPanel.hardRefresh();
wsResourcesExplorerPanel.refreshRootFolderView();
} catch (Exception e) {
Log.error("Error retrieving data: " + e.getLocalizedMessage());
}
}
}
@ -458,12 +457,10 @@ public class ComputationsExecutedPanel extends FramedPanel {
}
private void deleteItem(SelectEvent event) {
ItemDescription itemDescription = new ItemDescription(
selectedItem.getId(), selectedItem.getName(),
selectedItem.getOwner(), selectedItem.getPath(), selectedItem
.getType().name());
DeleteItemRequestEvent deleteItemEvent = new DeleteItemRequestEvent(
DataMinerWorkAreaElementType.Computations, itemDescription);
ItemDescription itemDescription = new ItemDescription(selectedItem.getId(), selectedItem.getName(),
selectedItem.getOwner(), selectedItem.getPath(), selectedItem.getType().name());
DeleteItemRequestEvent deleteItemEvent = new DeleteItemRequestEvent(DataMinerWorkAreaElementType.Computations,
itemDescription);
EventBusProvider.INSTANCE.fireEvent(deleteItemEvent);
Log.debug("Fired: " + deleteItemEvent);
}
@ -471,13 +468,10 @@ public class ComputationsExecutedPanel extends FramedPanel {
private void showComputation() {
if (selectedItem != null) {
final ItemDescription itemDescription = new ItemDescription(
selectedItem.getId(), selectedItem.getName(),
selectedItem.getOwner(), selectedItem.getPath(),
selectedItem.getType().name());
final ItemDescription itemDescription = new ItemDescription(selectedItem.getId(), selectedItem.getName(),
selectedItem.getOwner(), selectedItem.getPath(), selectedItem.getType().name());
ComputationDataRequestEvent event = new ComputationDataRequestEvent(
itemDescription);
ComputationDataRequestEvent event = new ComputationDataRequestEvent(itemDescription);
EventBusProvider.INSTANCE.fireEvent(event);
} else {
@ -491,53 +485,41 @@ public class ComputationsExecutedPanel extends FramedPanel {
if (selectedItem.isFolder()) {
StringBuilder actionUrl = new StringBuilder();
actionUrl.append(GWT.getModuleBaseURL());
actionUrl
.append(Constants.DOWNLOAD_FOLDER_SERVLET
+ "?"
+ Constants.DOWNLOAD_FOLDER_SERVLET_ITEM_ID_PARAMETER
+ "="
+ selectedItem.getId()
+ "&"
+ Constants.DOWNLOAD_FOLDER_SERVLET_FOLDER_NAME_PARAMETER
+ "=" + selectedItem.getName() + "&"
+ Constants.CURR_GROUP_ID + "="
+ GCubeClientContext.getCurrentContextId());
actionUrl.append(Constants.DOWNLOAD_FOLDER_SERVLET + "?"
+ Constants.DOWNLOAD_FOLDER_SERVLET_ITEM_ID_PARAMETER + "=" + selectedItem.getId() + "&"
+ Constants.DOWNLOAD_FOLDER_SERVLET_FOLDER_NAME_PARAMETER + "=" + selectedItem.getName() + "&"
+ Constants.CURR_GROUP_ID + "=" + GCubeClientContext.getCurrentContextId());
Log.debug("Retrieved link: " + actionUrl);
Window.open(actionUrl.toString(), selectedItem.getName(), "");
} else {
final ItemDescription itemDescription = new ItemDescription(
selectedItem.getId(), selectedItem.getName(),
selectedItem.getOwner(), selectedItem.getPath(),
final ItemDescription itemDescription = new ItemDescription(selectedItem.getId(),
selectedItem.getName(), selectedItem.getOwner(), selectedItem.getPath(),
selectedItem.getType().name());
DataMinerPortletServiceAsync.INSTANCE.getPublicLink(
itemDescription, new AsyncCallback<String>() {
DataMinerPortletServiceAsync.INSTANCE.getPublicLink(itemDescription, new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
if (caught instanceof SessionExpiredServiceException) {
EventBusProvider.INSTANCE
.fireEvent(new SessionExpiredEvent());
} else {
Log.error("Error open file: "
+ caught.getLocalizedMessage());
UtilsGXT3.alert("Error",
caught.getLocalizedMessage());
}
caught.printStackTrace();
@Override
public void onFailure(Throwable caught) {
if (caught instanceof SessionExpiredServiceException) {
EventBusProvider.INSTANCE.fireEvent(new SessionExpiredEvent());
} else {
Log.error("Error open file: " + caught.getLocalizedMessage());
UtilsGXT3.alert("Error", caught.getLocalizedMessage());
}
caught.printStackTrace();
}
}
@Override
public void onSuccess(String link) {
Log.debug("Retrieved link: " + link);
Window.open(link, itemDescription.getName(), "");
}
@Override
public void onSuccess(String link) {
Log.debug("Retrieved link: " + link);
Window.open(link, itemDescription.getName(), "");
}
});
});
}
} else {
UtilsGXT3.info("Attention", "Select a file!");
@ -547,10 +529,8 @@ public class ComputationsExecutedPanel extends FramedPanel {
private void cancelComputation() {
if (selectedItem != null) {
ItemDescription itemDescription = new ItemDescription(
selectedItem.getId(), selectedItem.getName(),
selectedItem.getOwner(), selectedItem.getPath(),
selectedItem.getType().name());
ItemDescription itemDescription = new ItemDescription(selectedItem.getId(), selectedItem.getName(),
selectedItem.getOwner(), selectedItem.getPath(), selectedItem.getType().name());
CancelExecutionFromComputationsRequestEvent cancelComputationEvent = new CancelExecutionFromComputationsRequestEvent(
itemDescription);
EventBusProvider.INSTANCE.fireEvent(cancelComputationEvent);
@ -560,20 +540,18 @@ public class ComputationsExecutedPanel extends FramedPanel {
}
}
/*private void resubmitComputation() {
if (selectedItem != null) {
ItemDescription itemDescription = new ItemDescription(
selectedItem.getId(), selectedItem.getName(),
selectedItem.getOwner(), selectedItem.getPath(),
selectedItem.getType().name());
ResubmitComputationExecutionRequestEvent resubmitComputationEvent = new ResubmitComputationExecutionRequestEvent(
itemDescription);
EventBusProvider.INSTANCE.fireEvent(resubmitComputationEvent);
Log.debug("Fired: " + resubmitComputationEvent);
} else {
UtilsGXT3.info("Attention", "Select a computation!");
}
}*/
/*
* private void resubmitComputation() { if (selectedItem != null) {
* ItemDescription itemDescription = new ItemDescription(
* selectedItem.getId(), selectedItem.getName(), selectedItem.getOwner(),
* selectedItem.getPath(), selectedItem.getType().name());
* ResubmitComputationExecutionRequestEvent resubmitComputationEvent = new
* ResubmitComputationExecutionRequestEvent( itemDescription);
* EventBusProvider.INSTANCE.fireEvent(resubmitComputationEvent);
* Log.debug("Fired: " + resubmitComputationEvent); } else {
* UtilsGXT3.info("Attention", "Select a computation!"); }
*
* }
*/
}

View File

@ -22,7 +22,7 @@ import org.gcube.portlets.widgets.dataminermanagerwidget.shared.workspace.ItemDe
import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploadNotification.WorskpaceUploadNotificationListener;
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.DialogUpload.UPLOAD_TYPE;
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload;
import org.gcube.portlets.widgets.wsexplorer.client.explore.WorkspaceResourcesExplorerPanel;
import org.gcube.portlets.widgets.wsexplorer.client.explore.WorkspaceResourcesExplorerPanelPaginated;
import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSelectNotification.WorskpaceExplorerSelectNotificationListener;
import org.gcube.portlets.widgets.wsexplorer.client.view.grid.ItemsTable.DISPLAY_FIELD;
import org.gcube.portlets.widgets.wsexplorer.shared.FilterCriteria;
@ -56,7 +56,8 @@ public class InputDataSetsPanel extends FramedPanel {
private Item selectedItem;
private MultipleDNDUpload dnd;
private WorkspaceResourcesExplorerPanel wsResourcesExplorerPanel;
private WorkspaceResourcesExplorerPanelPaginated wsResourcesExplorerPanel;
// private WorkspaceResourcesExplorerPanel wsResourcesExplorerPanel;
private TextButton btnDownload;
private TextButton btnDelete;
private TextButton btnRefresh;
@ -87,15 +88,14 @@ public class InputDataSetsPanel extends FramedPanel {
private void bindToEvents() {
EventBusProvider.INSTANCE.addHandler(UIStateEvent.TYPE,
new UIStateEvent.UIStateEventHandler() {
EventBusProvider.INSTANCE.addHandler(UIStateEvent.TYPE, new UIStateEvent.UIStateEventHandler() {
@Override
public void onChange(UIStateEvent event) {
manageStateEvents(event);
@Override
public void onChange(UIStateEvent event) {
manageStateEvents(event);
}
});
}
});
EventBusProvider.INSTANCE.addHandler(DataMinerWorkAreaEvent.TYPE,
new DataMinerWorkAreaEvent.DataMinerWorkAreaEventHandler() {
@ -108,19 +108,16 @@ public class InputDataSetsPanel extends FramedPanel {
});
EventBusProvider.INSTANCE
.addHandler(
RefreshDataMinerWorkAreaEvent.TYPE,
new RefreshDataMinerWorkAreaEvent.RefreshDataMinerWorkAreaEventHandler() {
EventBusProvider.INSTANCE.addHandler(RefreshDataMinerWorkAreaEvent.TYPE,
new RefreshDataMinerWorkAreaEvent.RefreshDataMinerWorkAreaEventHandler() {
@Override
public void onRefresh(
RefreshDataMinerWorkAreaEvent event) {
manageRefreshDataMinerWorkAreaEvents(event);
@Override
public void onRefresh(RefreshDataMinerWorkAreaEvent event) {
manageRefreshDataMinerWorkAreaEvents(event);
}
}
});
});
}
@ -143,8 +140,7 @@ public class InputDataSetsPanel extends FramedPanel {
}
private void manageDataMinerWorkAreaEvents(DataMinerWorkAreaEvent event) {
Log.debug("InputDataSetsPanel recieved DataMinerWorkAreaEvent: "
+ event);
Log.debug("InputDataSetsPanel recieved DataMinerWorkAreaEvent: " + event);
if (event == null) {
Log.error("DataMinerWorkAreaEvent");
return;
@ -173,10 +169,8 @@ public class InputDataSetsPanel extends FramedPanel {
}
private void manageRefreshDataMinerWorkAreaEvents(
RefreshDataMinerWorkAreaEvent event) {
Log.debug("InputDataSetsPanel recieved RefreshDataMinerWorkAreaEvent: "
+ event);
private void manageRefreshDataMinerWorkAreaEvents(RefreshDataMinerWorkAreaEvent event) {
Log.debug("InputDataSetsPanel recieved RefreshDataMinerWorkAreaEvent: " + event);
if (event == null) {
Log.error("RefreshDataMinerWorkAreaEvent");
return;
@ -197,17 +191,14 @@ public class InputDataSetsPanel extends FramedPanel {
}
private void create(DataMinerWorkAreaEvent event) {
Log.debug("Create InputDataSetsPanel");
try {
if (event == null
|| event.getDataMinerWorkArea() == null
if (event == null || event.getDataMinerWorkArea() == null
|| event.getDataMinerWorkArea().getInputDataSets() == null
|| event.getDataMinerWorkArea().getInputDataSets()
.getFolder() == null
|| event.getDataMinerWorkArea().getInputDataSets()
.getFolder().getId() == null
|| event.getDataMinerWorkArea().getInputDataSets()
.getFolder().getId().isEmpty()) {
|| event.getDataMinerWorkArea().getInputDataSets().getFolder() == null
|| event.getDataMinerWorkArea().getInputDataSets().getFolder().getId() == null
|| event.getDataMinerWorkArea().getInputDataSets().getFolder().getId().isEmpty()) {
if (v != null) {
remove(v);
forceLayout();
@ -217,18 +208,20 @@ public class InputDataSetsPanel extends FramedPanel {
}
List<String> showProperties = new ArrayList<String>();
for (DataSpacePropertiesType dataSpaceProperties : DataSpacePropertiesType
.values()) {
for (DataSpacePropertiesType dataSpaceProperties : DataSpacePropertiesType.values()) {
showProperties.add(dataSpaceProperties.getLabel());
}
FilterCriteria filterCriteria = new FilterCriteria();
Map<String, String> map = new HashMap<String, String>();
filterCriteria.setRequiredProperties(map);
wsResourcesExplorerPanel = new WorkspaceResourcesExplorerPanel(
event.getDataMinerWorkArea().getInputDataSets().getFolder()
.getId(), false, showProperties, filterCriteria,
true, DISPLAY_FIELD.CREATION_DATE);
Log.debug("Create wsResourcesExplorerPanel for Input: ["
+ event.getDataMinerWorkArea().getInputDataSets().getFolder().getId() + ", false, " + showProperties
+ ", " + filterCriteria + ", true, " + DISPLAY_FIELD.CREATION_DATE + "]");
wsResourcesExplorerPanel = new WorkspaceResourcesExplorerPanelPaginated(
event.getDataMinerWorkArea().getInputDataSets().getFolder().getId(), false, showProperties,
filterCriteria, true, DISPLAY_FIELD.CREATION_DATE);
WorskpaceExplorerSelectNotificationListener wsResourceExplorerListener = new WorskpaceExplorerSelectNotificationListener() {
@Override
public void onSelectedItem(Item item) {
@ -254,23 +247,22 @@ public class InputDataSetsPanel extends FramedPanel {
}
};
wsResourcesExplorerPanel
.addWorkspaceExplorerSelectNotificationListener(wsResourceExplorerListener);
wsResourcesExplorerPanel.ensureDebugId("wsResourceExplorerPanel");
wsResourcesExplorerPanel.addWorkspaceExplorerSelectNotificationListener(wsResourceExplorerListener);
wsResourcesExplorerPanel.ensureDebugId("wsResourceExplorerPanelForInput");
wsResourcesExplorerPanel.setHeightToInternalScroll(300);
Log.debug("Define DND for InputDataSetsPanel");
// DND
dnd = new MultipleDNDUpload();
dnd.setParameters(event.getDataMinerWorkArea().getInputDataSets()
.getFolder().getId(), UPLOAD_TYPE.File);
dnd.setParameters(event.getDataMinerWorkArea().getInputDataSets().getFolder().getId(), UPLOAD_TYPE.File);
dnd.addUniqueContainer(wsResourcesExplorerPanel);
WorskpaceUploadNotificationListener workspaceUploaderListener = new WorskpaceUploadNotificationListener() {
@Override
public void onUploadCompleted(String parentId, String itemId) {
Log.debug("Upload completed: [parentID: " + parentId
+ ", itemId: " + itemId + "]");
Log.debug("Upload completed: [parentID: " + parentId + ", itemId: " + itemId + "]");
wsResourcesExplorerPanel.refreshRootFolderView();
forceLayout();
@ -278,22 +270,18 @@ public class InputDataSetsPanel extends FramedPanel {
@Override
public void onUploadAborted(String parentId, String itemId) {
Log.debug("Upload Aborted: [parentID: " + parentId
+ ", itemId: " + itemId + "]");
Log.debug("Upload Aborted: [parentID: " + parentId + ", itemId: " + itemId + "]");
}
@Override
public void onError(String parentId, String itemId,
Throwable throwable) {
Log.debug("Upload Error: [parentID: " + parentId
+ ", itemId: " + itemId + "]");
public void onError(String parentId, String itemId, Throwable throwable) {
Log.debug("Upload Error: [parentID: " + parentId + ", itemId: " + itemId + "]");
throwable.printStackTrace();
}
@Override
public void onOverwriteCompleted(String parentId, String itemId) {
Log.debug("Upload Override Completed: [parentID: "
+ parentId + ", itemId: " + itemId + "]");
Log.debug("Upload Override Completed: [parentID: " + parentId + ", itemId: " + itemId + "]");
wsResourcesExplorerPanel.refreshRootFolderView();
forceLayout();
}
@ -360,26 +348,30 @@ public class InputDataSetsPanel extends FramedPanel {
@Override
public void onResize(ResizeEvent event) {
int scrollBarHeight = event.getHeight()
- toolBar.getElement().getHeight(false);
int scrollBarHeight = event.getHeight() - toolBar.getElement().getHeight(false);
Log.debug("ScrollBarHeight: " + scrollBarHeight);
wsResourcesExplorerPanel
.setHeightToInternalScroll(scrollBarHeight);
wsResourcesExplorerPanel.setHeightToInternalScroll(scrollBarHeight);
forceLayout();
}
});
forceLayout();
} catch (Exception e) {
Log.error("Error opening wsResourceExplorerPanel");
} catch (Throwable e) {
Log.error("Error opening wsResourceExplorerPanel: " + e.getLocalizedMessage(), e);
e.printStackTrace();
}
}
private void refreshWSResourceExplorerPanel() {
if (wsResourcesExplorerPanel != null) {
wsResourcesExplorerPanel.refreshRootFolderView();
try {
// wsResourcesExplorerPanel.hardRefresh();
wsResourcesExplorerPanel.refreshRootFolderView();
} catch (Exception e) {
Log.error("Error retrieving data: " + e.getLocalizedMessage());
}
}
}
@ -400,14 +392,18 @@ public class InputDataSetsPanel extends FramedPanel {
}
private void deleteItem(SelectEvent event) {
ItemDescription itemDescription = new ItemDescription(
selectedItem.getId(), selectedItem.getName(),
selectedItem.getOwner(), selectedItem.getPath(), selectedItem
.getType().name());
DeleteItemRequestEvent deleteItemEvent = new DeleteItemRequestEvent(
DataMinerWorkAreaElementType.InputDataSets, itemDescription);
EventBusProvider.INSTANCE.fireEvent(deleteItemEvent);
Log.debug("Fired: " + deleteItemEvent);
Log.debug("Selected Item: " + selectedItem);
if (selectedItem != null) {
ItemDescription itemDescription = new ItemDescription(selectedItem.getId(), selectedItem.getName(),
selectedItem.getOwner(), selectedItem.getPath(), selectedItem.getType().name());
DeleteItemRequestEvent deleteItemEvent = new DeleteItemRequestEvent(
DataMinerWorkAreaElementType.InputDataSets, itemDescription);
EventBusProvider.INSTANCE.fireEvent(deleteItemEvent);
Log.debug("Fired: " + deleteItemEvent);
} else {
UtilsGXT3.info("Attention", "Select a item!");
}
}
private void downloadFile() {
@ -415,52 +411,40 @@ public class InputDataSetsPanel extends FramedPanel {
if (selectedItem.isFolder()) {
StringBuilder actionUrl = new StringBuilder();
actionUrl.append(GWT.getModuleBaseURL());
actionUrl
.append(Constants.DOWNLOAD_FOLDER_SERVLET
+ "?"
+ Constants.DOWNLOAD_FOLDER_SERVLET_ITEM_ID_PARAMETER
+ "="
+ selectedItem.getId()
+ "&"
+ Constants.DOWNLOAD_FOLDER_SERVLET_FOLDER_NAME_PARAMETER
+ "=" + selectedItem.getName() + "&"
+ Constants.CURR_GROUP_ID + "="
+ GCubeClientContext.getCurrentContextId());
actionUrl.append(Constants.DOWNLOAD_FOLDER_SERVLET + "?"
+ Constants.DOWNLOAD_FOLDER_SERVLET_ITEM_ID_PARAMETER + "=" + selectedItem.getId() + "&"
+ Constants.DOWNLOAD_FOLDER_SERVLET_FOLDER_NAME_PARAMETER + "=" + selectedItem.getName() + "&"
+ Constants.CURR_GROUP_ID + "=" + GCubeClientContext.getCurrentContextId());
Log.debug("Retrieved link: " + actionUrl);
Window.open(actionUrl.toString(), selectedItem.getName(), "");
} else {
final ItemDescription itemDescription = new ItemDescription(
selectedItem.getId(), selectedItem.getName(),
selectedItem.getOwner(), selectedItem.getPath(),
final ItemDescription itemDescription = new ItemDescription(selectedItem.getId(),
selectedItem.getName(), selectedItem.getOwner(), selectedItem.getPath(),
selectedItem.getType().name());
DataMinerPortletServiceAsync.INSTANCE.getPublicLink(
itemDescription, new AsyncCallback<String>() {
DataMinerPortletServiceAsync.INSTANCE.getPublicLink(itemDescription, new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
if (caught instanceof SessionExpiredServiceException) {
EventBusProvider.INSTANCE
.fireEvent(new SessionExpiredEvent());
} else {
Log.error("Error open file: "
+ caught.getLocalizedMessage());
UtilsGXT3.alert("Error",
caught.getLocalizedMessage());
}
caught.printStackTrace();
@Override
public void onFailure(Throwable caught) {
if (caught instanceof SessionExpiredServiceException) {
EventBusProvider.INSTANCE.fireEvent(new SessionExpiredEvent());
} else {
Log.error("Error open file: " + caught.getLocalizedMessage());
UtilsGXT3.alert("Error", caught.getLocalizedMessage());
}
caught.printStackTrace();
}
}
@Override
public void onSuccess(String link) {
Log.debug("Retrieved link: " + link);
Window.open(link, itemDescription.getName(), "");
}
@Override
public void onSuccess(String link) {
Log.debug("Retrieved link: " + link);
Window.open(link, itemDescription.getName(), "");
}
});
});
}
} else {
UtilsGXT3.info("Attention", "Select a file!");

View File

@ -22,7 +22,7 @@ import org.gcube.portlets.widgets.dataminermanagerwidget.shared.workspace.ItemDe
import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploadNotification.WorskpaceUploadNotificationListener;
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.DialogUpload.UPLOAD_TYPE;
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload;
import org.gcube.portlets.widgets.wsexplorer.client.explore.WorkspaceResourcesExplorerPanel;
import org.gcube.portlets.widgets.wsexplorer.client.explore.WorkspaceResourcesExplorerPanelPaginated;
import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSelectNotification.WorskpaceExplorerSelectNotificationListener;
import org.gcube.portlets.widgets.wsexplorer.client.view.grid.ItemsTable.DISPLAY_FIELD;
import org.gcube.portlets.widgets.wsexplorer.shared.FilterCriteria;
@ -56,7 +56,9 @@ public class OutputDataSetsPanel extends FramedPanel {
private Item selectedItem;
private MultipleDNDUpload dnd;
private WorkspaceResourcesExplorerPanel wsResourcesExplorerPanel;
private WorkspaceResourcesExplorerPanelPaginated wsResourcesExplorerPanel;
// private WorkspaceResourcesExplorerPanel wsResourcesExplorerPanel;
private TextButton btnDownload;
private TextButton btnDelete;
private TextButton btnRefresh;
@ -86,15 +88,14 @@ public class OutputDataSetsPanel extends FramedPanel {
private void bindToEvents() {
EventBusProvider.INSTANCE.addHandler(UIStateEvent.TYPE,
new UIStateEvent.UIStateEventHandler() {
EventBusProvider.INSTANCE.addHandler(UIStateEvent.TYPE, new UIStateEvent.UIStateEventHandler() {
@Override
public void onChange(UIStateEvent event) {
manageStateEvents(event);
@Override
public void onChange(UIStateEvent event) {
manageStateEvents(event);
}
});
}
});
EventBusProvider.INSTANCE.addHandler(DataMinerWorkAreaEvent.TYPE,
new DataMinerWorkAreaEvent.DataMinerWorkAreaEventHandler() {
@ -107,19 +108,16 @@ public class OutputDataSetsPanel extends FramedPanel {
});
EventBusProvider.INSTANCE
.addHandler(
RefreshDataMinerWorkAreaEvent.TYPE,
new RefreshDataMinerWorkAreaEvent.RefreshDataMinerWorkAreaEventHandler() {
EventBusProvider.INSTANCE.addHandler(RefreshDataMinerWorkAreaEvent.TYPE,
new RefreshDataMinerWorkAreaEvent.RefreshDataMinerWorkAreaEventHandler() {
@Override
public void onRefresh(
RefreshDataMinerWorkAreaEvent event) {
manageRefreshDataMinerWorkAreaEvents(event);
@Override
public void onRefresh(RefreshDataMinerWorkAreaEvent event) {
manageRefreshDataMinerWorkAreaEvents(event);
}
}
});
});
}
@ -142,8 +140,7 @@ public class OutputDataSetsPanel extends FramedPanel {
}
private void manageDataMinerWorkAreaEvents(DataMinerWorkAreaEvent event) {
Log.debug("OutputDataSetsPanel recieved DataMinerWorkAreaEvent: "
+ event);
Log.debug("OutputDataSetsPanel recieved DataMinerWorkAreaEvent: " + event);
if (event == null) {
Log.error("DataMinerWorkAreaEvent");
return;
@ -172,10 +169,8 @@ public class OutputDataSetsPanel extends FramedPanel {
}
private void manageRefreshDataMinerWorkAreaEvents(
RefreshDataMinerWorkAreaEvent event) {
Log.debug("OutputDataSetsPanel recieved RefreshDataMinerWorkAreaEvent: "
+ event);
private void manageRefreshDataMinerWorkAreaEvents(RefreshDataMinerWorkAreaEvent event) {
Log.debug("OutputDataSetsPanel recieved RefreshDataMinerWorkAreaEvent: " + event);
if (event == null) {
Log.error("RefreshDataMinerWorkAreaEvent");
return;
@ -195,17 +190,14 @@ public class OutputDataSetsPanel extends FramedPanel {
}
private void create(DataMinerWorkAreaEvent event) {
Log.debug("Create OutputDataSetsPanel");
try {
if (event == null
|| event.getDataMinerWorkArea() == null
if (event == null || event.getDataMinerWorkArea() == null
|| event.getDataMinerWorkArea().getOutputDataSets() == null
|| event.getDataMinerWorkArea().getOutputDataSets()
.getFolder() == null
|| event.getDataMinerWorkArea().getOutputDataSets()
.getFolder().getId() == null
|| event.getDataMinerWorkArea().getOutputDataSets()
.getFolder().getId().isEmpty()) {
|| event.getDataMinerWorkArea().getOutputDataSets().getFolder() == null
|| event.getDataMinerWorkArea().getOutputDataSets().getFolder().getId() == null
|| event.getDataMinerWorkArea().getOutputDataSets().getFolder().getId().isEmpty()) {
if (v != null) {
remove(v);
forceLayout();
@ -215,17 +207,18 @@ public class OutputDataSetsPanel extends FramedPanel {
}
List<String> showProperties = new ArrayList<String>();
for (DataSpacePropertiesType dataSpaceProperties : DataSpacePropertiesType
.values()) {
for (DataSpacePropertiesType dataSpaceProperties : DataSpacePropertiesType.values()) {
showProperties.add(dataSpaceProperties.getLabel());
}
FilterCriteria filterCriteria = new FilterCriteria();
Map<String, String> map = new HashMap<String, String>();
filterCriteria.setRequiredProperties(map);
wsResourcesExplorerPanel = new WorkspaceResourcesExplorerPanel(
event.getDataMinerWorkArea().getOutputDataSets()
.getFolder().getId(), false, showProperties,
Log.debug("Create wsResourcesExplorerPanel for Output: ["
+ event.getDataMinerWorkArea().getOutputDataSets().getFolder().getId() + ", false, "
+ showProperties + ", " + filterCriteria + ", true, " + DISPLAY_FIELD.CREATION_DATE + "]");
wsResourcesExplorerPanel = new WorkspaceResourcesExplorerPanelPaginated(
event.getDataMinerWorkArea().getOutputDataSets().getFolder().getId(), false, showProperties,
filterCriteria, true, DISPLAY_FIELD.CREATION_DATE);
WorskpaceExplorerSelectNotificationListener wsResourceExplorerListener = new WorskpaceExplorerSelectNotificationListener() {
@ -253,23 +246,22 @@ public class OutputDataSetsPanel extends FramedPanel {
}
};
wsResourcesExplorerPanel
.addWorkspaceExplorerSelectNotificationListener(wsResourceExplorerListener);
wsResourcesExplorerPanel.ensureDebugId("wsResourceExplorerPanel");
wsResourcesExplorerPanel.addWorkspaceExplorerSelectNotificationListener(wsResourceExplorerListener);
wsResourcesExplorerPanel.ensureDebugId("wsResourceExplorerPanelForOutput");
wsResourcesExplorerPanel.setHeightToInternalScroll(300);
Log.debug("Define DND for InputDataSetsPanel");
// DND
dnd = new MultipleDNDUpload();
dnd.setParameters(event.getDataMinerWorkArea().getOutputDataSets()
.getFolder().getId(), UPLOAD_TYPE.File);
dnd.setParameters(event.getDataMinerWorkArea().getOutputDataSets().getFolder().getId(), UPLOAD_TYPE.File);
dnd.addUniqueContainer(wsResourcesExplorerPanel);
WorskpaceUploadNotificationListener workspaceUploaderListener = new WorskpaceUploadNotificationListener() {
@Override
public void onUploadCompleted(String parentId, String itemId) {
Log.debug("Upload completed: [parentID: " + parentId
+ ", itemId: " + itemId + "]");
Log.debug("Upload completed: [parentID: " + parentId + ", itemId: " + itemId + "]");
wsResourcesExplorerPanel.refreshRootFolderView();
forceLayout();
@ -277,22 +269,18 @@ public class OutputDataSetsPanel extends FramedPanel {
@Override
public void onUploadAborted(String parentId, String itemId) {
Log.debug("Upload Aborted: [parentID: " + parentId
+ ", itemId: " + itemId + "]");
Log.debug("Upload Aborted: [parentID: " + parentId + ", itemId: " + itemId + "]");
}
@Override
public void onError(String parentId, String itemId,
Throwable throwable) {
Log.debug("Upload Error: [parentID: " + parentId
+ ", itemId: " + itemId + "]");
public void onError(String parentId, String itemId, Throwable throwable) {
Log.debug("Upload Error: [parentID: " + parentId + ", itemId: " + itemId + "]");
throwable.printStackTrace();
}
@Override
public void onOverwriteCompleted(String parentId, String itemId) {
Log.debug("Upload Override Completed: [parentID: "
+ parentId + ", itemId: " + itemId + "]");
Log.debug("Upload Override Completed: [parentID: " + parentId + ", itemId: " + itemId + "]");
wsResourcesExplorerPanel.refreshRootFolderView();
forceLayout();
}
@ -358,26 +346,31 @@ public class OutputDataSetsPanel extends FramedPanel {
@Override
public void onResize(ResizeEvent event) {
int scrollBarHeight = event.getHeight()
- toolBar.getElement().getHeight(false);
int scrollBarHeight = event.getHeight() - toolBar.getElement().getHeight(false);
Log.debug("ScrollBarHeight: " + scrollBarHeight);
wsResourcesExplorerPanel
.setHeightToInternalScroll(scrollBarHeight);
wsResourcesExplorerPanel.setHeightToInternalScroll(scrollBarHeight);
forceLayout();
}
});
forceLayout();
} catch (Exception e) {
Log.error("Error opening wsResourceExplorerPanel");
} catch (Throwable e) {
Log.error("Error opening wsResourceExplorerPanel: " + e.getLocalizedMessage(), e);
e.printStackTrace();
}
}
private void refreshWSResourceExplorerPanel() {
if (wsResourcesExplorerPanel != null) {
wsResourcesExplorerPanel.refreshRootFolderView();
try {
wsResourcesExplorerPanel.refreshRootFolderView();
// wsResourcesExplorerPanel.hardRefresh();
} catch (Exception e) {
Log.error("Error retrieving data: " + e.getLocalizedMessage());
}
}
}
@ -392,21 +385,24 @@ public class OutputDataSetsPanel extends FramedPanel {
}
} catch (Throwable e) {
Log.error("Error in OutputDataSetsPanel: "
+ e.getLocalizedMessage());
Log.error("Error in OutputDataSetsPanel: " + e.getLocalizedMessage());
e.printStackTrace();
}
}
private void deleteItem(SelectEvent event) {
ItemDescription itemDescription = new ItemDescription(
selectedItem.getId(), selectedItem.getName(),
selectedItem.getOwner(), selectedItem.getPath(), selectedItem
.getType().name());
DeleteItemRequestEvent deleteItemEvent = new DeleteItemRequestEvent(
DataMinerWorkAreaElementType.OutputDataSets, itemDescription);
EventBusProvider.INSTANCE.fireEvent(deleteItemEvent);
Log.debug("Fired: " + deleteItemEvent);
Log.debug("Selected Item: " + selectedItem);
if (selectedItem != null) {
ItemDescription itemDescription = new ItemDescription(selectedItem.getId(), selectedItem.getName(),
selectedItem.getOwner(), selectedItem.getPath(), selectedItem.getType().name());
DeleteItemRequestEvent deleteItemEvent = new DeleteItemRequestEvent(
DataMinerWorkAreaElementType.OutputDataSets, itemDescription);
EventBusProvider.INSTANCE.fireEvent(deleteItemEvent);
Log.debug("Fired: " + deleteItemEvent);
} else {
UtilsGXT3.info("Attention", "Select a item!");
}
}
private void downloadFile() {
@ -414,51 +410,39 @@ public class OutputDataSetsPanel extends FramedPanel {
if (selectedItem.isFolder()) {
StringBuilder actionUrl = new StringBuilder();
actionUrl.append(GWT.getModuleBaseURL());
actionUrl
.append(Constants.DOWNLOAD_FOLDER_SERVLET
+ "?"
+ Constants.DOWNLOAD_FOLDER_SERVLET_ITEM_ID_PARAMETER
+ "="
+ selectedItem.getId()
+ "&"
+ Constants.DOWNLOAD_FOLDER_SERVLET_FOLDER_NAME_PARAMETER
+ "=" + selectedItem.getName() + "&"
+ Constants.CURR_GROUP_ID + "="
+ GCubeClientContext.getCurrentContextId());
actionUrl.append(Constants.DOWNLOAD_FOLDER_SERVLET + "?"
+ Constants.DOWNLOAD_FOLDER_SERVLET_ITEM_ID_PARAMETER + "=" + selectedItem.getId() + "&"
+ Constants.DOWNLOAD_FOLDER_SERVLET_FOLDER_NAME_PARAMETER + "=" + selectedItem.getName() + "&"
+ Constants.CURR_GROUP_ID + "=" + GCubeClientContext.getCurrentContextId());
Log.debug("Retrieved link: " + actionUrl);
Window.open(actionUrl.toString(), selectedItem.getName(), "");
} else {
final ItemDescription itemDescription = new ItemDescription(
selectedItem.getId(), selectedItem.getName(),
selectedItem.getOwner(), selectedItem.getPath(),
final ItemDescription itemDescription = new ItemDescription(selectedItem.getId(),
selectedItem.getName(), selectedItem.getOwner(), selectedItem.getPath(),
selectedItem.getType().name());
DataMinerPortletServiceAsync.INSTANCE.getPublicLink(
itemDescription, new AsyncCallback<String>() {
DataMinerPortletServiceAsync.INSTANCE.getPublicLink(itemDescription, new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
if (caught instanceof SessionExpiredServiceException) {
EventBusProvider.INSTANCE
.fireEvent(new SessionExpiredEvent());
} else {
Log.error("Error open file: "
+ caught.getLocalizedMessage());
UtilsGXT3.alert("Error",
caught.getLocalizedMessage());
}
caught.printStackTrace();
@Override
public void onFailure(Throwable caught) {
if (caught instanceof SessionExpiredServiceException) {
EventBusProvider.INSTANCE.fireEvent(new SessionExpiredEvent());
} else {
Log.error("Error open file: " + caught.getLocalizedMessage());
UtilsGXT3.alert("Error", caught.getLocalizedMessage());
}
caught.printStackTrace();
}
}
@Override
public void onSuccess(String link) {
Log.debug("Retrieved link: " + link);
Window.open(link, itemDescription.getName(), "");
}
@Override
public void onSuccess(String link) {
Log.debug("Retrieved link: " + link);
Window.open(link, itemDescription.getName(), "");
}
});
});
}
} else {

View File

@ -104,59 +104,66 @@ public class OperatorsPanel extends FramedPanel {
}
private void manageOperatorsClassificationEvent(OperatorsClassificationEvent event) {
if (event.getOperatorsClassificationRequestType().compareTo(OperatorsClassificationRequestType.ByName) == 0) {
if (currentClassificationName.compareTo(event.getClassificationName()) == 0) {
waitMessage(false);
if (event.getOperatorsClassification() != null) {
operatorsClassification = event.getOperatorsClassification();
operators.clear();
operators.addAll(event.getOperatorsClassification().getOperators());
String operatorId = event.getOperatorId();
try {
Log.debug("ShowCategoriesList");
List<OperatorCategoryPanel> categoryPanels = mapCategoriesPanels.get(currentClassificationName);
if (categoryPanels == null) {
categoryPanels = new ArrayList<OperatorCategoryPanel>();
if (operatorsClassification != null) {
for (OperatorCategory cat : operatorsClassification.getOperatorCategories()) {
categoryPanels.add(new OperatorCategoryPanel(handler, cat));
if (event.getOperatorsClassificationRequestType()
.compareTo(OperatorsClassificationRequestType.ByName) == 0) {
if (currentClassificationName.compareTo(event.getClassificationName()) == 0) {
waitMessage(false);
if (event.getOperatorsClassification() != null) {
operatorsClassification = event.getOperatorsClassification();
operators.clear();
operators.addAll(event.getOperatorsClassification().getOperators());
String operatorId = event.getOperatorId();
Log.debug("ShowCategoriesList");
List<OperatorCategoryPanel> categoryPanels = mapCategoriesPanels.get(currentClassificationName);
if (categoryPanels == null) {
categoryPanels = new ArrayList<OperatorCategoryPanel>();
if (operatorsClassification != null) {
for (OperatorCategory cat : operatorsClassification.getOperatorCategories()) {
categoryPanels.add(new OperatorCategoryPanel(handler, cat));
}
}
mapCategoriesPanels.put(currentClassificationName, categoryPanels);
}
mapCategoriesPanels.put(currentClassificationName, categoryPanels);
}
v.clear();
for (OperatorCategoryPanel panel : categoryPanels) {
v.add(panel);
v.clear();
for (OperatorCategoryPanel panel : categoryPanels) {
v.add(panel);
}
view = View.CATEGORIES;
if (operatorId != null && !operatorId.isEmpty()) {
OperatorCategory operatorCategoryDefault = null;
Operator operatorDefault = null;
for (Operator op : operators) {
if (op.getId().compareTo(operatorId) == 0) {
operatorDefault = op;
operatorCategoryDefault = op.getCategory();
break;
}
}
if (operatorCategoryDefault != null) {
for (OperatorCategoryPanel opCategoryPanel : categoryPanels) {
if (opCategoryPanel.getCategory().compareTo(operatorCategoryDefault) == 0) {
opCategoryPanel.setOperatorDefault(operatorDefault);
view = View.CATEGORIES;
if (operatorId != null && !operatorId.isEmpty()) {
OperatorCategory operatorCategoryDefault = null;
Operator operatorDefault = null;
for (Operator op : operators) {
if (op.getId().compareTo(operatorId) == 0) {
operatorDefault = op;
operatorCategoryDefault = op.getCategory();
break;
}
}
if (operatorCategoryDefault != null) {
for (OperatorCategoryPanel opCategoryPanel : categoryPanels) {
if (opCategoryPanel.getCategory().compareTo(operatorCategoryDefault) == 0) {
opCategoryPanel.setOperatorDefault(operatorDefault);
break;
}
}
}
}
forceLayout();
}
forceLayout();
}
}
} catch (Throwable e) {
Log.error("Error in OperatorsPanel: " + e.getLocalizedMessage(), e);
e.printStackTrace();
}
}

View File

@ -19,12 +19,16 @@ import org.gcube.portlets.widgets.dataminermanagerwidget.client.tr.TabularResour
import org.gcube.portlets.widgets.dataminermanagerwidget.client.util.UtilsGXT3;
import org.gcube.portlets.widgets.dataminermanagerwidget.shared.exception.SessionExpiredServiceException;
import org.gcube.portlets.widgets.dataminermanagerwidget.shared.workspace.ItemDescription;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.SelectVariableEvent;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.SelectVariableEvent.SelectVariableEventHandler;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.widgets.NetCDFPreviewDialog;
import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSelectNotification.WorskpaceExplorerSelectNotificationListener;
import org.gcube.portlets.widgets.wsexplorer.client.select.WorkspaceExplorerSelectDialog;
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Widget;
@ -61,6 +65,7 @@ public class FileFld extends AbstractFld {
private TextButton selectTRButton2;
private TextButton cancelButton;
private TextButton downloadButton;
private TextButton netcdfButton;
private ItemDescription selectedFileItem = null;
private TabularResourceData tabularResourceData;
@ -120,14 +125,20 @@ public class FileFld extends AbstractFld {
HtmlLayoutContainer descr;
if (fileParameter.getDescription() == null) {
if (fileParameter.getDescription() == null || fileParameter.getDescription().isEmpty()) {
descr = new HtmlLayoutContainer("<p style='margin-left:5px !important;'></p>");
descr.addStyleName("workflow-fieldDescription");
} else {
descr = new HtmlLayoutContainer(
"<p style='margin-left:5px !important;'>" + fileParameter.getDescription() + "</p>");
descr.addStyleName("workflow-fieldDescription");
if (fileParameter.isNetcdf()) {
String des = fileParameter.getDescription().replaceFirst("\\[NETCDF\\]", "");
descr = new HtmlLayoutContainer("<p style='margin-left:5px !important;'>" + des + "</p>");
descr.addStyleName("workflow-fieldDescription");
} else {
descr = new HtmlLayoutContainer(
"<p style='margin-left:5px !important;'>" + fileParameter.getDescription() + "</p>");
descr.addStyleName("workflow-fieldDescription");
}
}
horiz.add(tabContainer, new BoxLayoutData(new Margins()));
@ -252,6 +263,16 @@ public class FileFld extends AbstractFld {
});
downloadButton.setToolTip("Download File");
netcdfButton = new TextButton("");
netcdfButton.setIcon(DataMinerManagerPanel.resources.netcdf());
netcdfButton.addSelectHandler(new SelectEvent.SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
showNetCDFFile();
}
});
}
private void useTabularResource() {
@ -261,7 +282,7 @@ public class FileFld extends AbstractFld {
selectedFileItem.setPublicLink(tabularResourceData.getTabularResourceId());
showFieldWithTRSelection();
}
private void retrieveFileInformation(final Item item) {
Log.debug("Retrieved: " + item);
final ItemDescription itemDescription = new ItemDescription(item.getId(), item.getName(), item.getOwner(),
@ -323,6 +344,27 @@ public class FileFld extends AbstractFld {
}
private void showNetCDFFile() {
if (selectedFileItem != null) {
GWT.log("NetcdfBasicWidgetsManager");
// Example
SelectVariableEventHandler handler = new SelectVariableEventHandler() {
@Override
public void onResponse(SelectVariableEvent event) {
GWT.log("SelectVariable Response: " + event);
}
};
NetCDFPreviewDialog netcdfDialog = new NetCDFPreviewDialog(selectedFileItem.getPublicLink());
netcdfDialog.addSelectVariableEventHandler(handler);
netcdfDialog.setZIndex(XDOM.getTopZIndex());
}
}
private void showNoSelectionField() {
vp.clear();
vp.add(selectTRButton);
@ -347,6 +389,9 @@ public class FileFld extends AbstractFld {
h.add(selectTRButton2, new BoxLayoutData(new Margins()));
h.add(selectButton2, new BoxLayoutData(new Margins()));
h.add(downloadButton, new BoxLayoutData(new Margins()));
if (fileParameter.isNetcdf()) {
h.add(netcdfButton, new BoxLayoutData(new Margins()));
}
h.add(cancelButton, new BoxLayoutData(new Margins()));
vp.clear();
vp.add(h);

View File

@ -89,6 +89,9 @@ public interface Resources extends ClientBundle {
@Source("download.png")
ImageResource download();
@Source("show.png")
ImageResource netcdf();
@Source("cancel_circle.png")
ImageResource cancelCircle();

View File

@ -3,8 +3,13 @@ package org.gcube.portlets.widgets.dataminermanagerwidget.client.widgets;
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationId;
import org.gcube.data.analysis.dataminermanagercl.shared.data.output.FileResource;
import org.gcube.portlets.widgets.dataminermanagerwidget.client.DataMinerManagerPanel;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.SelectVariableEvent;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.SelectVariableEvent.SelectVariableEventHandler;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.widgets.NetCDFPreviewDialog;
import com.google.gwt.core.client.GWT;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.sencha.gxt.core.client.dom.XDOM;
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;
@ -59,8 +64,43 @@ public class FileViewer extends SimpleContainer {
}
});
TextButton netcdfButton = new TextButton("");
netcdfButton.setIcon(DataMinerManagerPanel.resources.netcdf());
netcdfButton.addSelectHandler(new SelectEvent.SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
showNetCDFFile();
}
});
lc.add(downloadBtn, new VerticalLayoutData(-1, -1, new Margins(0)));
if (fileResource.isNetcdf()) {
lc.add(netcdfButton, new VerticalLayoutData(-1, -1, new Margins(0)));
}
add(lc);
}
private void showNetCDFFile() {
if (fileResource != null && fileResource.getUrl() != null && !fileResource.getUrl().isEmpty()
&& fileResource.isNetcdf()) {
GWT.log("NetcdfBasicWidgetsManager");
// Example
SelectVariableEventHandler handler = new SelectVariableEventHandler() {
@Override
public void onResponse(SelectVariableEvent event) {
GWT.log("SelectVariable Response: " + event);
}
};
NetCDFPreviewDialog netcdfDialog = new NetCDFPreviewDialog(fileResource.getUrl());
netcdfDialog.addSelectVariableEventHandler(handler);
netcdfDialog.setZIndex(XDOM.getTopZIndex());
}
}
}

View File

@ -21,6 +21,11 @@
<inherits
name='org.gcube.portlets.widgets.openlayerbasicwidgets.olbasicwidgets' />
<!-- NetCDF Basic Widgets -->
<inherits
name='org.gcube.portlets.widgets.netcdfbasicwidgets.netcdfbasicwidgets' />
<!-- DataMiner Manager CL -->
<inherits
name='org.gcube.data.analysis.dataminermanagercl.dataminermanagercl' />

View File

@ -17,8 +17,8 @@ import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
import org.gcube.data.analysis.dataminermanagercl.shared.process.ComputationStatus;
import org.gcube.data.analysis.dataminermanagercl.shared.process.Operator;
import org.gcube.data.analysis.dataminermanagercl.shared.process.OperatorsClassification;
import org.gcube.portlets.widgets.dataminermanagerwidget.server.storage.StorageUtil;
import org.gcube.portlets.widgets.dataminermanagerwidget.server.util.DataMinerWorkAreaManager;
import org.gcube.portlets.widgets.dataminermanagerwidget.server.util.StorageUtil;
import org.gcube.portlets.widgets.dataminermanagerwidget.server.util.TableReader;
import org.gcube.portlets.widgets.dataminermanagerwidget.shared.exception.ServiceException;
import org.gcube.portlets.widgets.dataminermanagerwidget.shared.session.UserInfo;
@ -167,7 +167,8 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
HttpServletRequest httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil
.getServiceCredentials(httpRequest);
Map<String, String> properties = StorageUtil.getProperties(
StorageUtil storageUtil = new StorageUtil();
Map<String, String> properties = storageUtil.getProperties(
serviceCredentials.getUserName(), itemDescription.getId());
logger.debug("Properties: " + properties);
@ -220,7 +221,8 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
ServiceCredentials serviceCredentials = SessionUtil
.getServiceCredentials(httpRequest);
logger.debug("DeleteItem(): " + itemDescription);
StorageUtil.deleteItem(serviceCredentials.getUserName(),
StorageUtil storageUtil = new StorageUtil();
storageUtil.deleteItem(serviceCredentials.getUserName(),
itemDescription.getId());
return;
@ -284,7 +286,8 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
ServiceCredentials serviceCredentials = SessionUtil
.getServiceCredentials(httpRequest);
logger.debug("GetPublicLink(): " + itemDescription);
String link = StorageUtil.getPublicLink(
StorageUtil storageUtil = new StorageUtil();
String link = storageUtil.getPublicLink(
serviceCredentials.getUserName(), itemDescription.getId());
return link;
@ -355,7 +358,8 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
ServiceCredentials serviceCredentials = SessionUtil
.getServiceCredentials(httpRequest);
logger.debug("OutputDataByComputationItemt(): " + itemDescription);
Map<String, String> properties = StorageUtil.getProperties(
StorageUtil storageUtil = new StorageUtil();
Map<String, String> properties = storageUtil.getProperties(
serviceCredentials.getUserName(), itemDescription.getId());
logger.debug("Properties: " + properties);

View File

@ -3,7 +3,11 @@ package org.gcube.portlets.widgets.dataminermanagerwidget.server;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
@ -13,7 +17,7 @@ import javax.servlet.http.HttpSession;
import org.apache.commons.io.IOUtils;
import org.gcube.data.analysis.dataminermanagercl.server.util.ServiceCredentials;
import org.gcube.portlets.widgets.dataminermanagerwidget.server.util.StorageUtil;
import org.gcube.portlets.widgets.dataminermanagerwidget.server.storage.StorageUtil;
import org.gcube.portlets.widgets.dataminermanagerwidget.shared.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -106,15 +110,21 @@ public class DownloadFolderServlet extends HttpServlet {
.getParameter(Constants.DOWNLOAD_FOLDER_SERVLET_FOLDER_NAME_PARAMETER);
logger.debug("Request: [itemId=" + itemId + ", folderName="
+ folderName + "]");
File tmpZip = StorageUtil.zipFolder(
StorageUtil storageUtil=new StorageUtil();
InputStream is = storageUtil.zipFolder(
serviceCredentials.getUserName(), itemId);
Path tempFile = Files.createTempFile("dataMinerWidgetDownload", ".zip");
Files.copy(is, tempFile, StandardCopyOption.REPLACE_EXISTING);
File tmpZip= tempFile.toFile();
response.setHeader("Content-Disposition", "attachment; filename=\""
+ folderName + ".zip\"");
response.setContentType("application/zip");
response.setHeader("Content-Length",
String.valueOf(tmpZip.length()));
OutputStream out = response.getOutputStream();
FileInputStream fileTmpZip = new FileInputStream(tmpZip);
@ -122,7 +132,7 @@ public class DownloadFolderServlet extends HttpServlet {
out.flush();
out.close();
fileTmpZip.close();
tmpZip.delete();
Files.delete(tempFile);
return;
} catch (Throwable e) {

View File

@ -0,0 +1,229 @@
package org.gcube.portlets.widgets.dataminermanagerwidget.server.storage;
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.gcube.common.storagehub.client.StreamDescriptor;
import org.gcube.common.storagehub.client.dsl.FileContainer;
import org.gcube.common.storagehub.client.dsl.ItemContainer;
import org.gcube.common.storagehub.client.dsl.ListResolver;
import org.gcube.common.storagehub.client.dsl.OpenResolver;
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
import org.gcube.common.storagehub.model.Metadata;
import org.gcube.common.storagehub.model.items.FolderItem;
import org.gcube.common.storagehub.model.items.Item;
import org.gcube.portlets.widgets.dataminermanagerwidget.shared.exception.ServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class StorageUtil {
private static Logger logger = LoggerFactory.getLogger(StorageUtil.class);
/**
*
* @param user
* user
* @param itemId
* item id
* @return map properties
* @throws ServiceException
* service exception
*/
public Map<String, String> getProperties(String user, String itemId) throws ServiceException {
try {
StorageHubClient shc = new StorageHubClient();
Item item = shc.open(itemId).asItem().get();
Metadata metadata = item.getPropertyMap();
Map<String, String> itemMap = new HashMap<String, String>();
Map<String, Object> metadataMap = metadata.getValues();
for (String key : metadataMap.keySet()) {
String s = String.valueOf(metadataMap.get(key));
itemMap.put(key, s);
}
return itemMap;
} catch (Throwable e) {
logger.error("Error retrieving properties: " + e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
/**
*
* @param user
* user
* @param itemId
* item id
* @return input stream
* @throws ServiceException
* service exception
*/
public InputStream getInputStreamForItemOnWorkspace(String user, String itemId) throws ServiceException {
try {
logger.debug("getInputStreamForItemOnWorkspace: [user=" + user + ", itemId=" + itemId + "]");
StorageHubClient shc = new StorageHubClient();
FileContainer fileContainer = shc.open(itemId).asFile();
StreamDescriptor streamDescriptor = fileContainer.download();
return streamDescriptor.getStream();
} catch (Throwable e) {
logger.error("Error retrieving InputStream for File: " + e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
/**
*
* @param user
* user
* @param itemId
* item id
* @return public link
* @throws ServiceException
* service exception
*/
public String getPublicLink(String user, String itemId) throws ServiceException {
try {
logger.debug("getPublicLink: [user=" + user + ", itemId=" + itemId + "]");
StorageHubClient shc = new StorageHubClient();
URL url = shc.open(itemId).asFile().getPublicLink();
return url.toString();
} catch (Throwable e) {
logger.error("Error retrieving public link: " + e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
/**
*
* @param user
* user
* @param folderId
* folder id
* @return input stream
* @throws ServiceException
* service exception
*/
public InputStream zipFolder(String user, String folderId) throws ServiceException {
try {
logger.debug("zipFolder: [user=" + user + ", folderId=" + folderId + "]");
StorageHubClient shc = new StorageHubClient();
OpenResolver openResolver = shc.open(folderId);
ItemContainer<Item> itemContainer = openResolver.asItem();
Item item = itemContainer.get();
if (item instanceof FolderItem) {
StreamDescriptor streamDescriptor = openResolver.asFolder().download();
InputStream is = streamDescriptor.getStream();
return is;
} else {
throw new ServiceException("Is not a valid folder!");
}
} catch (Throwable e) {
logger.error("Error in zip Folder: " + e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
/**
*
* @param user
* user
* @param itemName
* item name
* @return workspace item
* @throws ServiceException
* service exception
*/
public Item getItemInRootFolderOnWorkspace(String user, String itemName) throws ServiceException {
try {
logger.debug("GetItemInRootFolder: [user=" + user + ", itemName=" + itemName + "]");
StorageHubClient shc = new StorageHubClient();
ListResolver listResolver = shc.getWSRoot().findByName(itemName);
List<? extends Item> items = listResolver.getItems();
if (items != null && !items.isEmpty()) {
return items.get(0);
} else {
return null;
}
} catch (Throwable e) {
logger.error("Error in get Item in RootFolder: " + e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage());
}
}
/**
*
* @param user
* user
* @param folderId
* folder id
* @param itemName
* item name
* @return workspace item
* @throws ServiceException
* service exception
*/
public Item getItemInFolderOnWorkspace(String user, String folderId, String itemName) throws ServiceException {
try {
logger.debug("GetItemInFolder: [user=" + user + ", folderId=" + folderId + ", itemName=" + itemName + "]");
StorageHubClient shc = new StorageHubClient();
ListResolver listResolver = shc.open(folderId).asFolder().findByName(itemName);
List<? extends Item> items = listResolver.getItems();
if (items != null && !items.isEmpty()) {
return items.get(0);
} else {
return null;
}
} catch (Throwable e) {
logger.error("Error in get Item in Folder: " + e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage());
}
}
/**
*
* @param user
* user
* @param itemId
* item id
* @throws ServiceException
* service exception
*/
public void deleteItem(String user, String itemId) throws ServiceException {
try {
logger.debug("User: " + user + ", ItemId:" + itemId);
StorageHubClient shc = new StorageHubClient();
OpenResolver openResolver = shc.open(itemId);
ItemContainer<Item> itemContainer = openResolver.asItem();
itemContainer.delete();
return;
} catch (Throwable e) {
logger.error("Error deleting Item: " + e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage());
}
}
}

View File

@ -1,8 +1,8 @@
package org.gcube.portlets.widgets.dataminermanagerwidget.server.util;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.common.storagehub.model.items.Item;
import org.gcube.data.analysis.dataminermanagercl.server.util.ServiceCredentials;
import org.gcube.portlets.widgets.dataminermanagerwidget.server.storage.StorageUtil;
import org.gcube.portlets.widgets.dataminermanagerwidget.shared.exception.ServiceException;
import org.gcube.portlets.widgets.dataminermanagerwidget.shared.workspace.Computations;
import org.gcube.portlets.widgets.dataminermanagerwidget.shared.workspace.DataMinerWorkArea;
@ -24,8 +24,7 @@ public class DataMinerWorkAreaManager {
private static final String COMPUTED_DATA_FOLDER = "Output Data Sets";
private static final String COMPUTATIONS_FOLDER = "Computations";
public static final Logger logger = LoggerFactory
.getLogger(DataMinerWorkAreaManager.class);
public static final Logger logger = LoggerFactory.getLogger(DataMinerWorkAreaManager.class);
private ServiceCredentials serviceCredentials;
@ -35,10 +34,10 @@ public class DataMinerWorkAreaManager {
public DataMinerWorkArea getDataMinerWorkArea() throws ServiceException {
DataMinerWorkArea dataMinerWorkArea = null;
StorageUtil storageUtil = new StorageUtil();
try {
WorkspaceItem wiDataMinerFolder = StorageUtil
.getItemInRootFolderOnWorkspace(serviceCredentials.getUserName(),
DATA_MINER_FOLDER);
Item wiDataMinerFolder = storageUtil.getItemInRootFolderOnWorkspace(serviceCredentials.getUserName(),
DATA_MINER_FOLDER);
if (wiDataMinerFolder == null) {
dataMinerWorkArea = new DataMinerWorkArea(null);
@ -46,13 +45,9 @@ public class DataMinerWorkAreaManager {
} else {
ItemDescription dataMinerWorkAreaFolder = null;
dataMinerWorkAreaFolder = new ItemDescription(
wiDataMinerFolder.getId(), wiDataMinerFolder.getName(),
wiDataMinerFolder.getOwner().getPortalLogin(),
wiDataMinerFolder.getPath(), wiDataMinerFolder
.getType().name());
dataMinerWorkArea = new DataMinerWorkArea(
dataMinerWorkAreaFolder);
dataMinerWorkAreaFolder = new ItemDescription(wiDataMinerFolder.getId(), wiDataMinerFolder.getName(),
wiDataMinerFolder.getOwner(), wiDataMinerFolder.getPath(), null);
dataMinerWorkArea = new DataMinerWorkArea(dataMinerWorkAreaFolder);
}
@ -65,18 +60,12 @@ public class DataMinerWorkAreaManager {
InputDataSets inputDataSets = null;
try {
WorkspaceItem wiImportedDataFolder = StorageUtil
.getItemInFolderOnWorkspace(serviceCredentials.getUserName(),
dataMinerWorkArea.getDataMinerWorkAreaFolder()
.getId(), IMPORTED_DATA_FOLDER);
Item wiImportedDataFolder = storageUtil.getItemInFolderOnWorkspace(serviceCredentials.getUserName(),
dataMinerWorkArea.getDataMinerWorkAreaFolder().getId(), IMPORTED_DATA_FOLDER);
ItemDescription importedDataFolder = null;
importedDataFolder = new ItemDescription(
wiImportedDataFolder.getId(),
wiImportedDataFolder.getName(), wiImportedDataFolder
.getOwner().getPortalLogin(),
wiImportedDataFolder.getPath(), wiImportedDataFolder
.getType().name());
importedDataFolder = new ItemDescription(wiImportedDataFolder.getId(), wiImportedDataFolder.getName(),
wiImportedDataFolder.getOwner(), wiImportedDataFolder.getPath(), null);
inputDataSets = new InputDataSets(importedDataFolder);
@ -87,18 +76,12 @@ public class DataMinerWorkAreaManager {
OutputDataSets outputDataSets = null;
try {
WorkspaceItem wiComputedDataFolder = StorageUtil
.getItemInFolderOnWorkspace(serviceCredentials.getUserName(),
dataMinerWorkArea.getDataMinerWorkAreaFolder()
.getId(), COMPUTED_DATA_FOLDER);
Item wiComputedDataFolder = storageUtil.getItemInFolderOnWorkspace(serviceCredentials.getUserName(),
dataMinerWorkArea.getDataMinerWorkAreaFolder().getId(), COMPUTED_DATA_FOLDER);
ItemDescription computedDataFolder = null;
computedDataFolder = new ItemDescription(
wiComputedDataFolder.getId(),
wiComputedDataFolder.getName(), wiComputedDataFolder
.getOwner().getPortalLogin(),
wiComputedDataFolder.getPath(), wiComputedDataFolder
.getType().name());
computedDataFolder = new ItemDescription(wiComputedDataFolder.getId(), wiComputedDataFolder.getName(),
wiComputedDataFolder.getOwner(), wiComputedDataFolder.getPath(), null);
outputDataSets = new OutputDataSets(computedDataFolder);
} catch (Throwable e) {
@ -108,18 +91,14 @@ public class DataMinerWorkAreaManager {
Computations computations = null;
try {
WorkspaceItem wiComputationsDataFolder = StorageUtil
.getItemInFolderOnWorkspace(serviceCredentials.getUserName(),
dataMinerWorkArea.getDataMinerWorkAreaFolder()
.getId(), COMPUTATIONS_FOLDER);
Item wiComputationsDataFolder = storageUtil.getItemInFolderOnWorkspace(
serviceCredentials.getUserName(), dataMinerWorkArea.getDataMinerWorkAreaFolder().getId(),
COMPUTATIONS_FOLDER);
ItemDescription computationsDataFolder = null;
computationsDataFolder = new ItemDescription(
wiComputationsDataFolder.getId(),
wiComputationsDataFolder.getName(),
wiComputationsDataFolder.getOwner().getPortalLogin(),
wiComputationsDataFolder.getPath(),
wiComputationsDataFolder.getType().name());
computationsDataFolder = new ItemDescription(wiComputationsDataFolder.getId(),
wiComputationsDataFolder.getName(), wiComputationsDataFolder.getOwner(),
wiComputationsDataFolder.getPath(), null);
computations = new Computations(computationsDataFolder);
} catch (Throwable e) {

View File

@ -1,288 +0,0 @@
package org.gcube.portlets.widgets.dataminermanagerwidget.server.util;
import java.io.File;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import org.gcube.common.homelibrary.home.HomeLibrary;
import org.gcube.common.homelibrary.home.workspace.Properties;
import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.common.homelibrary.util.zip.ZipUtil;
import org.gcube.contentmanagement.blobstorage.service.IClient;
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
import org.gcube.portlets.widgets.dataminermanagerwidget.shared.exception.ServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class StorageUtil {
private static Logger logger = LoggerFactory.getLogger(StorageUtil.class);
/**
*
* @param user
* user
* @param itemId
* item id
* @return map
* @throws ServiceException
* service exception
*/
public static Map<String, String> getProperties(String user, String itemId) throws ServiceException {
try {
Workspace ws = HomeLibrary.getUserWorkspace(user);
WorkspaceItem workSpaceItem = ws.getItem(itemId);
Properties properties = workSpaceItem.getProperties();
return properties.getProperties();
} catch (Throwable e) {
logger.error(e.getLocalizedMessage());
e.printStackTrace();
throw new ServiceException(e.getLocalizedMessage());
}
}
/**
*
* @param user
* User
* @param itemId
* Item id
* @return InputStream
* @throws ServiceException
* service exception
*/
public static InputStream getInputStreamForItemOnWorkspace(String user, String itemId) throws ServiceException {
Workspace ws;
try {
ws = HomeLibrary.getUserWorkspace(user);
WorkspaceItem workSpaceItem = ws.getItem(itemId);
if (workSpaceItem.isFolder()) {
throw new ServiceException("Folder is not valid!");
}
return getInputStream(user, workSpaceItem);
} catch (Throwable e) {
logger.error(e.getLocalizedMessage());
e.printStackTrace();
throw new ServiceException(e.getLocalizedMessage());
}
}
/**
*
* @param user
* User
* @param wi
* WorkspaceItem
* @return InputStream
* @throws ServiceException
* service exception
*/
private static InputStream getInputStream(String user, WorkspaceItem wi) throws ServiceException {
InputStream is = null;
try {
org.gcube.common.homelibrary.home.workspace.folder.items.File gcubeItem = ((org.gcube.common.homelibrary.home.workspace.folder.items.File) wi);
is = gcubeItem.getData();
return is;
} catch (Throwable e) {
logger.error("Error retrieving InputStream from storage", e);
e.printStackTrace();
throw new ServiceException("Error retrieving file from storage: " + e.getLocalizedMessage(), e);
}
}
/**
*
* @param user
* User
* @param itemId
* Item id
* @return link
* @throws ServiceException
* service exception
*/
public static String getPublicLink(String user, String itemId) throws ServiceException {
Workspace ws;
try {
ws = HomeLibrary.getUserWorkspace(user);
WorkspaceItem workSpaceItem = ws.getItem(itemId);
if (workSpaceItem.isFolder()) {
throw new ServiceException("Attention this is a folder!");
}
return workSpaceItem.getPublicLink(false);
} catch (Throwable e) {
logger.error("Error retrieving public link: " + e.getLocalizedMessage());
e.printStackTrace();
throw new ServiceException(e.getLocalizedMessage());
}
}
/**
*
* @param user
* user
* @param folderId
* folder id
* @return File
* @throws ServiceException
* service exception
*/
public static File zipFolder(String user, String folderId) throws ServiceException {
Workspace ws;
try {
logger.debug("zipFolder: [user=" + user + ", folderId=" + folderId + "]");
ws = HomeLibrary.getUserWorkspace(user);
WorkspaceItem workSpaceItem = ws.getItem(folderId);
if (!workSpaceItem.isFolder()) {
throw new ServiceException("Item is not valid folder!");
}
WorkspaceFolder folder = (WorkspaceFolder) workSpaceItem;
File fileZip = ZipUtil.zipFolder(folder);
return fileZip;
} catch (Throwable e) {
e.printStackTrace();
throw new ServiceException(e.getLocalizedMessage());
}
}
/**
*
* @param user
* user
* @param itemName
* item name
* @return workspace item
* @throws ServiceException
* service exception
*/
public static WorkspaceItem getItemInRootFolderOnWorkspace(String user, String itemName) throws ServiceException {
Workspace ws;
try {
ws = HomeLibrary.getUserWorkspace(user);
WorkspaceItem item = ws.find(itemName, ws.getRoot().getId());
return item;
} catch (Throwable e) {
e.printStackTrace();
throw new ServiceException(e.getLocalizedMessage());
}
}
/**
*
* @param user
* user
* @param folderId
* folder id
* @param itemName
* item name
* @return workspace item
* @throws ServiceException
* service exception
*/
public static WorkspaceItem getItemInFolderOnWorkspace(String user, String folderId, String itemName)
throws ServiceException {
Workspace ws;
try {
ws = HomeLibrary.getUserWorkspace(user);
WorkspaceItem item = ws.find(itemName, folderId);
return item;
} catch (Throwable e) {
e.printStackTrace();
throw new ServiceException(e.getLocalizedMessage());
}
}
/**
*
* @param user
* user
* @param itemId
* item id
* @throws ServiceException
* service exception
*/
public static void deleteItem(String user, String itemId) throws ServiceException {
Workspace ws;
try {
logger.debug("User: " + user + ", ItemId:" + itemId);
ws = HomeLibrary.getUserWorkspace(user);
ws.removeItems(itemId);
return;
} catch (Throwable e) {
e.printStackTrace();
throw new ServiceException(e.getLocalizedMessage());
}
}
/**
*
* @param is
* input stream
* @return public link
* @throws ServiceException
* service exception
*/
public static String saveOnStorageInTemporalFile(InputStream is) throws ServiceException {
try {
logger.debug("SaveOnStorageInTemporalFile()");
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
Double v = Math.random() * 10000;
String tempFile = "P_" + sdf.format(new Date()) + "_" + v.intValue() + ".xml";
String remotePath = "/DataMiner/AlgoritmsParameters/" + tempFile;
IClient client = new StorageClient("DataAnalysis", "DataMiner", "DataMiner", AccessType.PUBLIC,
MemoryType.VOLATILE).getClient();
String storageId = client.put(true).LFile(is).RFile(remotePath);
logger.debug("Storage id: " + storageId);
String publicLink = client.getHttpUrl().RFile(remotePath);
logger.debug("Storage public link: " + publicLink);
return publicLink;
} catch (Throwable e) {
logger.error(e.getLocalizedMessage());
e.printStackTrace();
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
}

View File

@ -12,6 +12,7 @@ import net.sf.csv4j.CSVReader;
import org.gcube.data.analysis.dataminermanagercl.server.util.ServiceCredentials;
import org.gcube.data.analysis.dataminermanagercl.shared.data.ColumnItem;
import org.gcube.data.analysis.dataminermanagercl.shared.data.TableItemSimple;
import org.gcube.portlets.widgets.dataminermanagerwidget.server.storage.StorageUtil;
import org.gcube.portlets.widgets.dataminermanagerwidget.shared.exception.ServiceException;
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
import org.slf4j.Logger;
@ -35,15 +36,16 @@ public class TableReader {
}
public TableItemSimple getTableItemSimple() throws ServiceException {
InputStream is = StorageUtil.getInputStreamForItemOnWorkspace(
StorageUtil storageUtil = new StorageUtil();
InputStream is = storageUtil.getInputStreamForItemOnWorkspace(
serviceCredentials.getUserName(), item.getId());
Reader fileReader = new InputStreamReader(is);
CSVReader csvReader = new CSVReader(fileReader);
List<String> firstLine = getFirstLine(csvReader, false);
ArrayList<String> columns = new ArrayList<String>(firstLine);
String publicLink=StorageUtil.getPublicLink(serviceCredentials.getUserName(), item.getId());
String publicLink=storageUtil.getPublicLink(serviceCredentials.getUserName(), item.getId());
TableItemSimple tableItemSimple=new TableItemSimple(publicLink,item.getName(), item.getType().name());
ArrayList<ColumnItem> columnItemList=new ArrayList<ColumnItem>();

View File

@ -18,7 +18,7 @@ public class Constants {
public static final String DEFAULT_USER = "giancarlo.panichi";
public final static String DEFAULT_SCOPE = "/gcube/devNext/NextNext";
public final static String DEFAULT_TOKEN = "ae1208f0-210d-47c9-9b24-d3f2dfcce05f-98187548";
public final static String DEFAULT_TOKEN = "";
public static final String DEFAULT_ROLE = "OrganizationMember";
// public final static String DEFAULT_SCOPE = "/gcube/devNext";

View File

@ -20,7 +20,12 @@
<!-- OpenLayer Basic Widgets -->
<inherits
name='org.gcube.portlets.widgets.openlayerbasicwidgets.olbasicwidgets' />
<!-- NetCDF Basic Widgets -->
<inherits
name='org.gcube.portlets.widgets.netcdfbasicwidgets.netcdfbasicwidgets' />
<!-- DataMiner Manager CL -->
<inherits
name='org.gcube.data.analysis.dataminermanagercl.dataminermanagercl' />

View File

@ -28,6 +28,11 @@
<servlet-name>workspaceUploadServletStream</servlet-name>
<servlet-class>org.gcube.portlets.widgets.workspaceuploader.server.WorkspaceUploadServletStream</servlet-class>
</servlet>
<servlet>
<servlet-name>NetCDFBasicWidgetService</servlet-name>
<servlet-class>org.gcube.portlets.widgets.netcdfbasicwidgets.server.NetCDFBasicWidgetServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
@ -54,6 +59,11 @@
<servlet-name>workspaceUploadServletStream</servlet-name>
<url-pattern>/dataminermanagerwidget/workspaceUploadServletStream</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>NetCDFBasicWidgetService</servlet-name>
<url-pattern>/dataminermanagerwidget/netcdfservice</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>DataMinerManagerWidget.html</welcome-file>