diff --git a/distro/changelog.xml b/distro/changelog.xml index 6717c8c..b665789 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -1,5 +1,7 @@ - + + Added service info [ticket #12594] + Added Item Id support [ticket #16503] Updated the resources check on IS [ticket #17569] diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/StatAlgoImporterController.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/StatAlgoImporterController.java index 837aba6..46c0cbf 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/StatAlgoImporterController.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/StatAlgoImporterController.java @@ -2,6 +2,7 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client; import java.util.Date; +import org.gcube.portlets.user.statisticalalgorithmsimporter.client.dminfo.ServiceInfoDialog; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.BinaryCodeSetEvent; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.DeleteItemEvent; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.InputReadyEvent; @@ -10,6 +11,8 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.MainCo import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.NewCodeEvent; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.SessionExpiredEvent; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.StatAlgoImporterRibbonEvent; +import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.dminfo.ServiceInfoEvent; +import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.dminfo.ServiceInfoRequestEvent; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.monitor.StatAlgoImporterMonitor; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.project.ProjectManager; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.resource.StatAlgoImporterResources; @@ -20,6 +23,7 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.client.upload.CodeU import org.gcube.portlets.user.statisticalalgorithmsimporter.client.utils.BrowserWindowSupport; import org.gcube.portlets.user.statisticalalgorithmsimporter.client.utils.UtilsGXT3; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.Constants; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.dminfo.ServiceInfo; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterSessionExpiredException; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.session.UserInfo; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.workspace.ItemDescription; @@ -251,6 +255,16 @@ public class StatAlgoImporterController { }); + eventBus.addHandler(ServiceInfoRequestEvent.TYPE, new ServiceInfoRequestEvent.ServiceInfoRequestEventHandler() { + + @Override + public void onRequest(ServiceInfoRequestEvent event) { + Log.debug("Catch ServiceInfoRequestEvent: " + event); + retrieveServiceInfoRequestEvent(event); + + } + }); + } private void doMenuCommand(StatAlgoImporterRibbonEvent event) { @@ -282,6 +296,9 @@ public class StatAlgoImporterController { case SOFTWARE_REPACKAGE: softwareRepackage(); break; + case SERVICE_PROFILE: + showServiceProfile(); + break; case HELP: showHelp(); break; @@ -291,6 +308,8 @@ public class StatAlgoImporterController { } } + + private void showHelp() { try { @@ -382,7 +401,7 @@ public class StatAlgoImporterController { @Override public void onDialogHide(DialogHideEvent event) { - Log.debug("DialogHideEvent: "+event); + Log.debug("DialogHideEvent: " + event); switch (event.getHideButton()) { case NO: break; @@ -392,10 +411,9 @@ public class StatAlgoImporterController { default: break; } - + } - }); mb.setWidth(300); mb.show(); @@ -408,7 +426,7 @@ public class StatAlgoImporterController { Log.debug("SoftwareCreateRequest fire: " + inputRequestEvent); eventBus.fireEvent(inputRequestEvent); } - + private void softwareRepackage() { pm.softwareRepackage(); @@ -433,7 +451,7 @@ public class StatAlgoImporterController { } private void doMainCodeSetCommand(MainCodeSetEvent event) { - Log.debug("MainCodeSetEvent: "+event); + Log.debug("MainCodeSetEvent: " + event); ItemDescription mainCodeItemDesc = event.getItemDescription(); if (mainCodeItemDesc != null && mainCodeItemDesc.getId() != null) { mainCodeItemDescription = mainCodeItemDesc; @@ -447,7 +465,7 @@ public class StatAlgoImporterController { } private void doBinaryCodeSetCommand(BinaryCodeSetEvent event) { - Log.debug("BinaryCodeSetEvent: "+event); + Log.debug("BinaryCodeSetEvent: " + event); ItemDescription binaryCodeItemDesc = event.getItemDescription(); if (binaryCodeItemDesc != null && binaryCodeItemDesc.getId() != null) { binaryCodeItemDescription = binaryCodeItemDesc; @@ -460,7 +478,7 @@ public class StatAlgoImporterController { } private void doSetNewMainCodeEvent(NewCodeEvent event) { - Log.debug("NewCodeEvent "+event); + Log.debug("NewCodeEvent " + event); monitor = new StatAlgoImporterMonitor(); newCodeEvent = event; inputRequestType = InputRequestType.NewMainCodeSet; @@ -497,4 +515,37 @@ public class StatAlgoImporterController { } + private void showServiceProfile() { + ServiceInfoDialog serviceInfoDialog=new ServiceInfoDialog(eventBus); + serviceInfoDialog.show(); + } + + private void retrieveServiceInfoRequestEvent(final ServiceInfoRequestEvent event) { + StatAlgoImporterServiceAsync.INSTANCE.getServiceInfo(new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + if (caught instanceof StatAlgoImporterSessionExpiredException) { + eventBus.fireEvent(new SessionExpiredEvent(SessionExpiredType.EXPIREDONSERVER)); + } else { + Log.error("Error retrieving DataMiner service info: " + caught.getLocalizedMessage(), caught); + UtilsGXT3.alert("Error", + "Error retrieving DataMiner service info: " + caught.getLocalizedMessage()); + } + caught.printStackTrace(); + } + + @Override + public void onSuccess(ServiceInfo serviceInfo) { + Log.debug("DataMiner Service Info: " + serviceInfo); + + ServiceInfoEvent serviceInfoEvent = new ServiceInfoEvent(serviceInfo); + eventBus.fireEvent(serviceInfoEvent); + + } + + }); + + } + } diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/dminfo/ServiceInfoDataProperties.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/dminfo/ServiceInfoDataProperties.java new file mode 100644 index 0000000..6130575 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/dminfo/ServiceInfoDataProperties.java @@ -0,0 +1,25 @@ +package org.gcube.portlets.user.statisticalalgorithmsimporter.client.dminfo; + + +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.dminfo.ServiceInfoData; + +import com.google.gwt.editor.client.Editor.Path; +import com.sencha.gxt.core.client.ValueProvider; +import com.sencha.gxt.data.shared.ModelKeyProvider; +import com.sencha.gxt.data.shared.PropertyAccess; + +/** + * + * @author Giancarlo Panichi + * + * + */ +public interface ServiceInfoDataProperties extends PropertyAccess { + @Path("key") + ModelKeyProvider id(); + + ValueProvider key(); + ValueProvider value(); + ValueProvider category(); +} + diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/dminfo/ServiceInfoDialog.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/dminfo/ServiceInfoDialog.java new file mode 100644 index 0000000..e23b99d --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/dminfo/ServiceInfoDialog.java @@ -0,0 +1,63 @@ +package org.gcube.portlets.user.statisticalalgorithmsimporter.client.dminfo; + +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.Constants; + +import com.google.gwt.event.logical.shared.ResizeEvent; +import com.google.gwt.event.logical.shared.ResizeHandler; +import com.google.gwt.event.shared.EventBus; +import com.sencha.gxt.widget.core.client.Dialog; +import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack; +import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer; +import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData; + +/** + * + * Simple file show dialog + * + * @author Giancarlo Panichi + * + * + */ +public class ServiceInfoDialog extends Dialog { + private EventBus eventBus; + private ServiceInfoPanel serviceInfoPanel; + + public ServiceInfoDialog(EventBus eventBus) { + super(); + this.eventBus=eventBus; + init(); + create(); + } + + private void init() { + setWidth("640px"); + setHeight("480px"); + setResizable(true); + setHeadingText(Constants.DATA_MINER_SERVICE_INFO_TITLE); + setModal(true); + setMaximizable(true); + setPredefinedButtons(PredefinedButton.CLOSE); + setButtonAlign(BoxLayoutPack.CENTER); + } + + private void create() { + VerticalLayoutContainer vc = new VerticalLayoutContainer(); + vc.addResizeHandler(new ResizeHandler() { + + @Override + public void onResize(ResizeEvent event) { + manageResize(event); + } + }); + serviceInfoPanel=new ServiceInfoPanel(eventBus); + vc.add(serviceInfoPanel, new VerticalLayoutData(-1,-1)); + add(vc); + } + + private void manageResize(ResizeEvent event){ + serviceInfoPanel.setHeight(String.valueOf(event.getHeight())+"px"); + serviceInfoPanel.setWidth(String.valueOf(event.getWidth())+"px"); + forceLayout(); + } + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/dminfo/ServiceInfoPanel.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/dminfo/ServiceInfoPanel.java new file mode 100644 index 0000000..8ad8672 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/dminfo/ServiceInfoPanel.java @@ -0,0 +1,230 @@ +package org.gcube.portlets.user.statisticalalgorithmsimporter.client.dminfo; + +import java.util.ArrayList; +import java.util.List; + +import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.dminfo.ServiceInfoEvent; +import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.dminfo.ServiceInfoRequestEvent; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.Constants; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.dminfo.ServiceInfo; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.dminfo.ServiceInfoData; + +import com.allen_sauer.gwt.log.client.Log; +import com.google.gwt.core.client.GWT; +import com.google.gwt.dom.client.Style.Unit; +import com.google.gwt.event.shared.EventBus; +import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode; +import com.sencha.gxt.core.client.util.Margins; +import com.sencha.gxt.data.shared.ListStore; +import com.sencha.gxt.widget.core.client.FramedPanel; +import com.sencha.gxt.widget.core.client.container.HtmlLayoutContainer; +import com.sencha.gxt.widget.core.client.container.MarginData; +import com.sencha.gxt.widget.core.client.container.SimpleContainer; +import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer; +import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData; +import com.sencha.gxt.widget.core.client.form.FieldSet; +import com.sencha.gxt.widget.core.client.grid.ColumnConfig; +import com.sencha.gxt.widget.core.client.grid.ColumnModel; +import com.sencha.gxt.widget.core.client.grid.Grid; +import com.sencha.gxt.widget.core.client.grid.GroupingView; + +/** + * + * @author Giancarlo Panichi + * + * + */ +public class ServiceInfoPanel extends FramedPanel { + + + + private static final ServiceInfoDataProperties props = GWT.create(ServiceInfoDataProperties.class); + private VerticalLayoutContainer v; + private VerticalLayoutContainer environmentVBox; + private EventBus eventBus; + + public ServiceInfoPanel(EventBus eventBus) { + super(); + this.eventBus = eventBus; + Log.debug("ServiceInfoPanel"); + init(); + create(); + bind(); + eventBus.fireEvent(new ServiceInfoRequestEvent()); + + } + + private void init() { + setItemId("ServiceInfoPanel"); + forceLayoutOnResize = true; + setBodyBorder(false); + setBorders(false); + setBodyStyle("backgroundColor:white;"); + setHeaderVisible(false); + setResize(true); + setHeadingText(Constants.DATA_MINER_SERVICE_INFO_TITLE); + setBodyStyle("backgroundColor:white;"); + + } + + private void create() { + try { + v = new VerticalLayoutContainer(); + v.setScrollMode(ScrollMode.AUTO); + add(v); + createView(); + forceLayout(); + } catch (Throwable e) { + Log.error("Error creating ServiceInfoPanel: " + e.getLocalizedMessage(), e); + } + } + + private void bind() { + + eventBus.addHandler(ServiceInfoEvent.TYPE, new ServiceInfoEvent.ServiceInfoEventHandler() { + + @Override + public void onRequest(ServiceInfoEvent event) { + Log.debug("Catch ServiceInfoEvent"); + showServiceInfo(event.getServiceInfo()); + + } + + }); + + } + + private void createView() { + + SimpleContainer sectionTitle = new SimpleContainer(); + SimpleContainer sectionSubTitle = new SimpleContainer(); + + // title + HtmlLayoutContainer title = new HtmlLayoutContainer( + "
" + Constants.DATA_MINER_SERVICE_INFO_TITLE + "
"); + sectionTitle.add(title, new MarginData()); + sectionTitle.getElement().getStyle().setMarginRight(20, Unit.PX); + v.add(sectionTitle, new VerticalLayoutData(-1, -1, new Margins(10))); + + // subtitle + HtmlLayoutContainer subtitle = new HtmlLayoutContainer( + "

This page reports information on the DataMiner " + + "service instance serving this working environment giving an up to date " + + "picture of its capacities and capabilities.

"); + sectionSubTitle.add(subtitle, new MarginData()); + sectionSubTitle.getElement().getStyle().setMarginRight(20, Unit.PX); + v.add(sectionSubTitle, new VerticalLayoutData(-1, -1, new Margins(10))); + + } + + private FieldSet environmentView() { + try { + environmentVBox = new VerticalLayoutContainer(); + + FieldSet configurationFieldSet = new FieldSet(); + configurationFieldSet.setHeadingText(Constants.DATA_MINER_RUNTIME_FEATURE); + configurationFieldSet.setCollapsible(true); + configurationFieldSet.add(environmentVBox); + configurationFieldSet.getElement().getStyle().setMarginRight(20, Unit.PX); + return configurationFieldSet; + } catch (Throwable e) { + Log.error("Error in ServiceInfoPanel in environment: " + e.getLocalizedMessage(), e); + throw e; + } + } + + private void showAddress(String address) { + // Service address + SimpleContainer sectionServerAddress = new SimpleContainer(); + + HtmlLayoutContainer addressHtml = new HtmlLayoutContainer( + "

The base url of the service instance is: " + "" + + address + "

"); + sectionServerAddress.add(addressHtml, new MarginData()); + sectionServerAddress.getElement().getStyle().setMarginRight(20, Unit.PX); + v.add(sectionServerAddress, new VerticalLayoutData(-1, -1, new Margins(10))); + + } + + private void showServiceInfo(ServiceInfo serviceInfo) { + + if (serviceInfo != null) { + + String address = serviceInfo.getServiceAddress(); + if (address != null && !address.isEmpty()) { + showAddress(address); + } + + FieldSet environmentFieldSet = environmentView(); + v.add(environmentFieldSet, new VerticalLayoutData(-1, -1, new Margins(10))); + + ArrayList properties = serviceInfo.getServiceProperties(); + if (properties != null && !properties.isEmpty()) { + Grid grid = createInfoGrid(properties); + environmentVBox.add(grid, new VerticalLayoutData(1, -1, new Margins(0, 4, 0, 4))); + } else { + HtmlLayoutContainer emptyInfoContainer = new HtmlLayoutContainer( + "

No Info Available.

"); + + environmentVBox.add(emptyInfoContainer, new VerticalLayoutData(1, -1, new Margins(0, 4, 0, 4))); + } + } else { + FieldSet environmentFieldSet = environmentView(); + v.add(environmentFieldSet, new VerticalLayoutData(-1, -1, new Margins(10))); + + HtmlLayoutContainer emptyInfoContainer = new HtmlLayoutContainer( + "

No Info Available.

"); + + environmentVBox.add(emptyInfoContainer, new VerticalLayoutData(1, -1, new Margins(0, 4, 0, 4))); + } + + forceLayout(); + + } + + private Grid createInfoGrid(ArrayList properties) { + + ColumnConfig keyCol = new ColumnConfig(props.key(), 100, + "Key"); + ColumnConfig valueCol = new ColumnConfig(props.value(), 100, + "Value"); + ColumnConfig categoryCol = new ColumnConfig(props.category(), + 100, "Category"); + + List> columns = new ArrayList>(); + columns.add(keyCol); + columns.add(valueCol); + columns.add(categoryCol); + + ColumnModel cm = new ColumnModel(columns); + + ListStore store = new ListStore(props.id()); + store.addAll(properties); + + final GroupingView groupingView = new GroupingView(); + groupingView.setShowGroupedColumn(false); + groupingView.groupBy(categoryCol); + groupingView.setForceFit(true); + groupingView.setAutoExpandColumn(valueCol); + groupingView.setEmptyText("No info retrieved"); + + // grid.getView().setAutoFill(true); + // groupingView.setStripeRows(true); + // groupingView.setColumnLines(true); + + Grid grid = new Grid(store, cm, groupingView); + + grid.setAllowTextSelection(false); + grid.setAllowTextSelection(true); + grid.setBorders(false); + grid.setColumnReordering(false); + + // Stage manager, turn on state management + grid.setStateful(true); + grid.setStateId("gridServiceInfoData"); + + return grid; + + } + +} diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/event/dminfo/ServiceInfoEvent.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/event/dminfo/ServiceInfoEvent.java new file mode 100644 index 0000000..bd618c6 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/event/dminfo/ServiceInfoEvent.java @@ -0,0 +1,63 @@ +package org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.dminfo; + + +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.dminfo.ServiceInfo; + +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; + +/** + * Service Info Event + * + * + * @author Giancarlo Panichi + * + * + */ +public class ServiceInfoEvent extends GwtEvent { + + public static Type TYPE = new Type(); + private ServiceInfo serviceInfo; + + public interface ServiceInfoEventHandler extends EventHandler { + void onRequest(ServiceInfoEvent event); + } + + public interface HasServiceInfoEventHandler extends HasHandlers { + public HandlerRegistration addServiceInfoEventHandler(ServiceInfoEventHandler handler); + } + + public ServiceInfoEvent(ServiceInfo serviceInfo) { + this.serviceInfo = serviceInfo; + } + + @Override + protected void dispatch(ServiceInfoEventHandler handler) { + handler.onRequest(this); + } + + @Override + public Type getAssociatedType() { + return TYPE; + } + + public static Type getType() { + return TYPE; + } + + public static void fire(HasHandlers source, ServiceInfoEvent event) { + source.fireEvent(event); + } + + public ServiceInfo getServiceInfo() { + return serviceInfo; + } + + @Override + public String toString() { + return "ServiceInfoEvent [serviceInfo=" + serviceInfo + "]"; + } + +} diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/event/dminfo/ServiceInfoRequestEvent.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/event/dminfo/ServiceInfoRequestEvent.java new file mode 100644 index 0000000..7d2e516 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/event/dminfo/ServiceInfoRequestEvent.java @@ -0,0 +1,56 @@ +package org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.dminfo; + +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; + +/** + * Service Info Request Event + * + * + * @author Giancarlo Panichi + * + * + */ +public class ServiceInfoRequestEvent extends GwtEvent { + + public static Type TYPE = new Type(); + + public interface ServiceInfoRequestEventHandler extends EventHandler { + void onRequest(ServiceInfoRequestEvent event); + } + + public interface HasServiceInfoRequestEventHandler extends HasHandlers { + public HandlerRegistration addServiceInfoRequestEventHandler(ServiceInfoRequestEventHandler handler); + } + + public ServiceInfoRequestEvent() { + + } + + @Override + protected void dispatch(ServiceInfoRequestEventHandler handler) { + handler.onRequest(this); + } + + @Override + public Type getAssociatedType() { + return TYPE; + } + + public static Type getType() { + return TYPE; + } + + public static void fire(HasHandlers source, ServiceInfoRequestEvent event) { + source.fireEvent(event); + } + + @Override + public String toString() { + return "ServiceInfoRequestEvent []"; + } + + +} diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/resource/StatAlgoImporterResources.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/resource/StatAlgoImporterResources.java index 5c753d9..4223794 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/resource/StatAlgoImporterResources.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/resource/StatAlgoImporterResources.java @@ -34,6 +34,13 @@ public interface StatAlgoImporterResources extends ClientBundle { @Source("help_24.png") ImageResource help24(); + @Source("service_profile_32.png") + ImageResource serviceProfile32(); + + @Source("service_profile_24.png") + ImageResource serviceProfile24(); + + @Source("download_32.png") ImageResource download32(); diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/resource/service_profile_24.png b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/resource/service_profile_24.png new file mode 100644 index 0000000..29442d9 Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/resource/service_profile_24.png differ diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/resource/service_profile_32.png b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/resource/service_profile_32.png new file mode 100644 index 0000000..791561f Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/resource/service_profile_32.png differ diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/ribbon/HomeToolBar.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/ribbon/HomeToolBar.java index 8789da0..d26820c 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/ribbon/HomeToolBar.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/ribbon/HomeToolBar.java @@ -37,26 +37,25 @@ public class HomeToolBar { private HomeToolBarMessages msgs; private EventBus eventBus; private ToolBar toolBar; - - //Home + + // Home private TextButton btnCreateProject; private TextButton btnOpenProject; private TextButton btnSaveProject; - - //Resources + + // Resources private TextButton btnGitHubResource; private TextButton btnAddResource; - - - //Software - //private TextButton btnCreateSoftware; + + // Software + // private TextButton btnCreateSoftware; private TextButton btnPublishSoftware; private TextButton btnRepackageSoftware; - + // Help + private TextButton btnServiceProfile; private TextButton btnHelp; - - + // private TextButton languageButton; // private TextButton logsButton; // private TextButton testButton; @@ -91,7 +90,7 @@ public class HomeToolBar { FlexTable homeLayout = new FlexTable(); projectGroup.add(homeLayout); - + btnCreateProject = new TextButton(msgs.btnCreateProject(), StatAlgoImporterResources.INSTANCE.projectCreate24()); btnCreateProject.setId("btnCreateProject"); @@ -103,16 +102,14 @@ public class HomeToolBar { btnCreateProject.addSelectHandler(new SelectHandler() { public void onSelect(SelectEvent event) { - eventBus.fireEvent(new StatAlgoImporterRibbonEvent( - StatAlgoImporterRibbonType.PROJECT_CREATE)); + eventBus.fireEvent(new StatAlgoImporterRibbonEvent(StatAlgoImporterRibbonType.PROJECT_CREATE)); } }); - + homeLayout.setWidget(0, 0, btnCreateProject); homeLayout.getFlexCellFormatter().setRowSpan(0, 0, 2); - - btnOpenProject = new TextButton(msgs.btnOpenProject(), - StatAlgoImporterResources.INSTANCE.projectOpen24()); + + btnOpenProject = new TextButton(msgs.btnOpenProject(), StatAlgoImporterResources.INSTANCE.projectOpen24()); btnOpenProject.setId("btnOpenProject"); btnOpenProject.setScale(ButtonScale.SMALL); btnOpenProject.setIconAlign(IconAlign.LEFT); @@ -122,17 +119,14 @@ public class HomeToolBar { btnOpenProject.addSelectHandler(new SelectHandler() { public void onSelect(SelectEvent event) { - eventBus.fireEvent(new StatAlgoImporterRibbonEvent( - StatAlgoImporterRibbonType.PROJECT_OPEN)); + eventBus.fireEvent(new StatAlgoImporterRibbonEvent(StatAlgoImporterRibbonType.PROJECT_OPEN)); } }); homeLayout.setWidget(0, 1, btnOpenProject); homeLayout.getFlexCellFormatter().setRowSpan(0, 1, 2); - - - btnSaveProject = new TextButton(msgs.btnSaveProject(), - StatAlgoImporterResources.INSTANCE.projectSave24()); + + btnSaveProject = new TextButton(msgs.btnSaveProject(), StatAlgoImporterResources.INSTANCE.projectSave24()); btnSaveProject.setId("btnSaveProject"); btnSaveProject.setScale(ButtonScale.SMALL); btnSaveProject.setIconAlign(IconAlign.LEFT); @@ -142,15 +136,13 @@ public class HomeToolBar { btnSaveProject.addSelectHandler(new SelectHandler() { public void onSelect(SelectEvent event) { - eventBus.fireEvent(new StatAlgoImporterRibbonEvent( - StatAlgoImporterRibbonType.PROJECT_SAVE)); + eventBus.fireEvent(new StatAlgoImporterRibbonEvent(StatAlgoImporterRibbonType.PROJECT_SAVE)); } }); homeLayout.setWidget(0, 2, btnSaveProject); homeLayout.getFlexCellFormatter().setRowSpan(0, 2, 2); - - + // Resources ButtonGroup resourcesGroup = new ButtonGroup(); resourcesGroup.setId("Resource"); @@ -158,11 +150,10 @@ public class HomeToolBar { resourcesGroup.setHeight(GROUP_HEIGHT); toolBar.add(resourcesGroup); - FlexTable resourcesLayout = new FlexTable(); + FlexTable resourcesLayout = new FlexTable(); resourcesGroup.add(resourcesLayout); - btnAddResource = new TextButton(msgs.btnAddResourceText(), - StatAlgoImporterResources.INSTANCE.upload24()); + btnAddResource = new TextButton(msgs.btnAddResourceText(), StatAlgoImporterResources.INSTANCE.upload24()); btnAddResource.setId("btnAddResource"); btnAddResource.setScale(ButtonScale.SMALL); btnAddResource.setIconAlign(IconAlign.LEFT); @@ -170,37 +161,32 @@ public class HomeToolBar { btnAddResource.setToolTip(msgs.btnAddResourceToolTip()); btnAddResource.disable(); btnAddResource.addSelectHandler(new SelectHandler() { - + public void onSelect(SelectEvent event) { - eventBus.fireEvent(new StatAlgoImporterRibbonEvent( - StatAlgoImporterRibbonType.RESOURCE_ADD)); + eventBus.fireEvent(new StatAlgoImporterRibbonEvent(StatAlgoImporterRibbonType.RESOURCE_ADD)); } }); resourcesLayout.setWidget(0, 0, btnAddResource); resourcesLayout.getFlexCellFormatter().setRowSpan(0, 0, 2); - - - btnGitHubResource = new TextButton(msgs.btnGitHubResourceText(), - StatAlgoImporterResources.INSTANCE.gitHub24()); + + btnGitHubResource = new TextButton(msgs.btnGitHubResourceText(), StatAlgoImporterResources.INSTANCE.gitHub24()); btnGitHubResource.setId("btnGitHubResource"); btnGitHubResource.setScale(ButtonScale.SMALL); btnGitHubResource.setIconAlign(IconAlign.LEFT); btnGitHubResource.setArrowAlign(ButtonArrowAlign.BOTTOM); - //btnGitHubResource.setToolTip(msgs.btnGitHubResourceToolTip()); + // btnGitHubResource.setToolTip(msgs.btnGitHubResourceToolTip()); btnGitHubResource.disable(); btnGitHubResource.addSelectHandler(new SelectHandler() { - + public void onSelect(SelectEvent event) { - eventBus.fireEvent(new StatAlgoImporterRibbonEvent( - StatAlgoImporterRibbonType.RESOURCE_GITHUB)); + eventBus.fireEvent(new StatAlgoImporterRibbonEvent(StatAlgoImporterRibbonType.RESOURCE_GITHUB)); } }); resourcesLayout.setWidget(0, 1, btnGitHubResource); resourcesLayout.getFlexCellFormatter().setRowSpan(0, 1, 2); - - + // Software ButtonGroup softwareGroup = new ButtonGroup(); softwareGroup.setId("SoftwareGroup"); @@ -208,9 +194,9 @@ public class HomeToolBar { softwareGroup.setHeight(GROUP_HEIGHT); toolBar.add(softwareGroup); - FlexTable softwareLayout = new FlexTable(); + FlexTable softwareLayout = new FlexTable(); softwareGroup.add(softwareLayout); - + btnPublishSoftware = new TextButton(msgs.btnPublishSoftwareText(), StatAlgoImporterResources.INSTANCE.publish24()); btnPublishSoftware.setId("publishSofwareButton"); @@ -223,15 +209,13 @@ public class HomeToolBar { btnPublishSoftware.addSelectHandler(new SelectHandler() { public void onSelect(SelectEvent event) { - eventBus.fireEvent(new StatAlgoImporterRibbonEvent( - StatAlgoImporterRibbonType.SOFTWARE_PUBLISH)); + eventBus.fireEvent(new StatAlgoImporterRibbonEvent(StatAlgoImporterRibbonType.SOFTWARE_PUBLISH)); } }); softwareLayout.setWidget(0, 0, btnPublishSoftware); softwareLayout.getFlexCellFormatter().setRowSpan(0, 0, 2); - - + btnRepackageSoftware = new TextButton(msgs.btnRepackageSoftwareText(), StatAlgoImporterResources.INSTANCE.zip24()); btnRepackageSoftware.setId("publishSofwareButton"); @@ -243,15 +227,12 @@ public class HomeToolBar { btnRepackageSoftware.addSelectHandler(new SelectHandler() { public void onSelect(SelectEvent event) { - eventBus.fireEvent(new StatAlgoImporterRibbonEvent( - StatAlgoImporterRibbonType.SOFTWARE_REPACKAGE)); + eventBus.fireEvent(new StatAlgoImporterRibbonEvent(StatAlgoImporterRibbonType.SOFTWARE_REPACKAGE)); } }); softwareLayout.setWidget(0, 1, btnRepackageSoftware); softwareLayout.getFlexCellFormatter().setRowSpan(0, 1, 2); - - // Help ButtonGroup helpGroup = new ButtonGroup(); @@ -275,9 +256,23 @@ public class HomeToolBar { * helpLayout.setWidget(0, 0, languageButton); * helpLayout.getFlexCellFormatter().setRowSpan(0, 0, 2); */ + btnServiceProfile = new TextButton(msgs.serviceProfileButton(), StatAlgoImporterResources.INSTANCE.serviceProfile24()); + btnServiceProfile.enable(); + btnServiceProfile.setToolTip(msgs.serviceProfileButtonToolTip()); + btnServiceProfile.setScale(ButtonScale.SMALL); + btnServiceProfile.setIconAlign(IconAlign.LEFT); + btnServiceProfile.setArrowAlign(ButtonArrowAlign.BOTTOM); + btnServiceProfile.addSelectHandler(new SelectHandler() { - btnHelp = new TextButton(msgs.helpButton(), - StatAlgoImporterResources.INSTANCE.help24()); + public void onSelect(SelectEvent event) { + eventBus.fireEvent(new StatAlgoImporterRibbonEvent(StatAlgoImporterRibbonType.SERVICE_PROFILE)); + } + }); + + helpLayout.setWidget(0, 0, btnServiceProfile); + helpLayout.getFlexCellFormatter().setRowSpan(0, 0, 2); + + btnHelp = new TextButton(msgs.helpButton(), StatAlgoImporterResources.INSTANCE.help24()); btnHelp.enable(); btnHelp.setToolTip(msgs.helpButtonToolTip()); btnHelp.setScale(ButtonScale.SMALL); @@ -286,8 +281,7 @@ public class HomeToolBar { btnHelp.addSelectHandler(new SelectHandler() { public void onSelect(SelectEvent event) { - eventBus.fireEvent(new StatAlgoImporterRibbonEvent( - StatAlgoImporterRibbonType.HELP)); + eventBus.fireEvent(new StatAlgoImporterRibbonEvent(StatAlgoImporterRibbonType.HELP)); } }); @@ -328,20 +322,19 @@ public class HomeToolBar { cleanCells(helpLayout.getElement()); - eventBus.addHandler(ProjectStatusEvent.TYPE, - new ProjectStatusEvent.ProjectStatusEventHandler() { - - @Override - public void onProjectStatus(ProjectStatusEvent event) { - setUI(event); - - } - }); + eventBus.addHandler(ProjectStatusEvent.TYPE, new ProjectStatusEvent.ProjectStatusEventHandler() { + + @Override + public void onProjectStatus(ProjectStatusEvent event) { + setUI(event); + + } + }); } private void cleanCells(Element elem) { - NodeList tds = elem. cast().select("td"); + NodeList tds = elem.cast().select("td"); for (int i = 0; i < tds.getLength(); i++) { Element td = tds.getItem(i); @@ -385,10 +378,10 @@ public class HomeToolBar { public void setUI(ProjectStatusEvent event) { ProjectStatusEventType projectStatusEventType = event.getProjectStatusEventType(); - if(projectStatusEventType==null){ + if (projectStatusEventType == null) { return; } - + try { switch (projectStatusEventType) { case START: @@ -399,6 +392,7 @@ public class HomeToolBar { btnGitHubResource.disable(); btnPublishSoftware.disable(); btnRepackageSoftware.disable(); + btnServiceProfile.enable(); btnHelp.enable(); break; case OPEN: @@ -406,7 +400,7 @@ public class HomeToolBar { case ADD_RESOURCE: case DELETE_RESOURCE: case SAVE: - case MAIN_CODE_SET: + case MAIN_CODE_SET: btnCreateProject.enable(); btnOpenProject.enable(); btnSaveProject.enable(); @@ -414,13 +408,14 @@ public class HomeToolBar { btnGitHubResource.enable(); btnPublishSoftware.enable(); btnRepackageSoftware.enable(); + btnServiceProfile.enable(); btnHelp.enable(); - break; + break; default: break; } } catch (Exception e) { - Log.error("setUI Error : " + e.getLocalizedMessage(),e); + Log.error("setUI Error : " + e.getLocalizedMessage(), e); } } } diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/ribbon/HomeToolBarMessages.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/ribbon/HomeToolBarMessages.java index e631973..1523a98 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/ribbon/HomeToolBarMessages.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/ribbon/HomeToolBarMessages.java @@ -92,6 +92,12 @@ public interface HomeToolBarMessages extends Messages { @DefaultMessage("Help") String helpGroupHeadingText(); + @DefaultMessage("Service Profile") + String serviceProfileButton(); + + @DefaultMessage("Service Profile") + String serviceProfileButtonToolTip(); + @DefaultMessage("Help") String helpButton(); diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/rpc/StatAlgoImporterService.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/rpc/StatAlgoImporterService.java index 85e62d6..d39bcc8 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/rpc/StatAlgoImporterService.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/rpc/StatAlgoImporterService.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.code.CodeData; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.descriptor.SAIDescriptor; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.dminfo.ServiceInfo; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.file.FileUploadMonitor; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.InputData; @@ -90,5 +91,6 @@ public interface StatAlgoImporterService extends RemoteService { public void repackageSoftware() throws StatAlgoImporterServiceException; public ItemDescription getItemDescription(String itemId) throws StatAlgoImporterServiceException; - + + public ServiceInfo getServiceInfo() throws StatAlgoImporterServiceException; } diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/rpc/StatAlgoImporterServiceAsync.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/rpc/StatAlgoImporterServiceAsync.java index 4b9b1ee..bba44a1 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/rpc/StatAlgoImporterServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/rpc/StatAlgoImporterServiceAsync.java @@ -7,6 +7,7 @@ import java.util.ArrayList; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.code.CodeData; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.descriptor.SAIDescriptor; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.dminfo.ServiceInfo; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.file.FileUploadMonitor; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.InputData; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project; @@ -70,6 +71,6 @@ public interface StatAlgoImporterServiceAsync { void getItemDescription(String itemId, AsyncCallback asyncCallback); - + void getServiceInfo(AsyncCallback callback); } diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/type/StatAlgoImporterRibbonType.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/type/StatAlgoImporterRibbonType.java index 8496d41..f66ee90 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/type/StatAlgoImporterRibbonType.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/type/StatAlgoImporterRibbonType.java @@ -14,5 +14,6 @@ public enum StatAlgoImporterRibbonType { RESOURCE_GITHUB, SOFTWARE_PUBLISH, SOFTWARE_REPACKAGE, + SERVICE_PROFILE, HELP; } diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/StatAlgoImporterServiceImpl.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/StatAlgoImporterServiceImpl.java index 43d567f..943c5c6 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/StatAlgoImporterServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/StatAlgoImporterServiceImpl.java @@ -9,6 +9,7 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import org.apache.commons.io.IOUtils; + import org.gcube.portlets.user.statisticalalgorithmsimporter.client.rpc.StatAlgoImporterService; import org.gcube.portlets.user.statisticalalgorithmsimporter.server.annotation.WPS4RParser; import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.CodeReader; @@ -16,6 +17,7 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.server.generator.Pr import org.gcube.portlets.user.statisticalalgorithmsimporter.server.generator.ProjectDeploy; import org.gcube.portlets.user.statisticalalgorithmsimporter.server.generator.ProjectShareInfoBuilder; import org.gcube.portlets.user.statisticalalgorithmsimporter.server.is.BuildSAIDescriptor; +import org.gcube.portlets.user.statisticalalgorithmsimporter.server.is.InformationSystemUtils; import org.gcube.portlets.user.statisticalalgorithmsimporter.server.poolmanager.DataMinerPoolManager; import org.gcube.portlets.user.statisticalalgorithmsimporter.server.social.Recipient; import org.gcube.portlets.user.statisticalalgorithmsimporter.server.storage.CodeSave; @@ -23,9 +25,11 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.server.storage.Depl import org.gcube.portlets.user.statisticalalgorithmsimporter.server.storage.FilesStorage; import org.gcube.portlets.user.statisticalalgorithmsimporter.server.storage.ProjectArchiver; import org.gcube.portlets.user.statisticalalgorithmsimporter.server.util.ServiceCredentials; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.Constants; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.code.CodeData; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.descriptor.ProjectLanguageType; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.descriptor.SAIDescriptor; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.dminfo.ServiceInfo; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterSessionExpiredException; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.file.FileUploadMonitor; @@ -837,4 +841,23 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements } } + @Override + public ServiceInfo getServiceInfo() throws StatAlgoImporterServiceException { + try { + HttpServletRequest httpRequest = this.getThreadLocalRequest(); + ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest); + logger.info("GetServiceInfo()"); + logger.info("DataMiner Service discovered by IS"); + ServiceInfo serviceInfo = InformationSystemUtils.retrieveServiceInfo(Constants.DATA_MINER_SERVICE_CATEGORY, + Constants.DATA_MINER_SERVICE_NAME, serviceCredentials.getScope()); + + logger.info("Service Info retrieved: " + serviceInfo); + return serviceInfo; + + } catch (Throwable e) { + logger.error("Error retrieving Service Info: " + e.getLocalizedMessage(), e); + throw new StatAlgoImporterServiceException("Error retrieving Service Info: " + e.getLocalizedMessage(), e); + } + } + } diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/is/InformationSystemUtils.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/is/InformationSystemUtils.java index 6e28264..4dd4f0c 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/is/InformationSystemUtils.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/server/is/InformationSystemUtils.java @@ -1,15 +1,21 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.server.is; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; import org.gcube.common.resources.gcore.GCoreEndpoint; import org.gcube.common.resources.gcore.GCoreEndpoint.Profile.Endpoint; +import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint; +import org.gcube.common.resources.gcore.ServiceEndpoint.Property; import org.gcube.common.resources.gcore.GenericResource; import org.gcube.common.resources.gcore.ScopeGroup; +import org.gcube.common.resources.gcore.ServiceEndpoint; import org.gcube.common.scope.api.ScopeProvider; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.Constants; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.dminfo.ServiceInfo; +import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.dminfo.ServiceInfoData; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException; import org.gcube.resources.discovery.client.api.DiscoveryClient; import org.gcube.resources.discovery.client.impl.JAXBParser; @@ -264,4 +270,69 @@ public class InformationSystemUtils { } } + + public static ServiceInfo retrieveServiceInfo(String category, String name, String scope) + throws Exception { + try { + logger.debug("Retrieve DataMiner Service Properties"); + + if (scope == null || scope.length() == 0){ + logger.error("Invalid request scope: "+scope); + return null; + } + + ScopeProvider.instance.set(scope); + + SimpleQuery query = ICFactory.queryFor(ServiceEndpoint.class); + query.addCondition("$resource/Profile/Category/text() eq '" + category + "'") + .addCondition("$resource/Profile/Name/text() eq '" + name + "'") + .setResult("$resource/Profile/AccessPoint"); + DiscoveryClient client = ICFactory.clientFor(AccessPoint.class); + List accessPointList = client.submit(query); + + String serviceAddress=null; + ArrayList serviceProperties = new ArrayList<>(); + + if (accessPointList != null && !accessPointList.isEmpty()) { + AccessPoint accessPoint = accessPointList.get(0); + if (accessPoint.address() != null && !accessPoint.address().isEmpty()) { + String accessPointAddress = accessPoint.address(); + int wpsWebProcessingServiceIndex = accessPointAddress.indexOf(Constants.WPSWebProcessingService); + if (wpsWebProcessingServiceIndex > 0) { + serviceAddress = accessPointAddress.substring(0, wpsWebProcessingServiceIndex); + } + } + + if (accessPoint.properties() != null && !accessPoint.propertyMap().isEmpty()) { + for (String key : accessPoint.propertyMap().keySet()) { + Property property = accessPoint.propertyMap().get(key); + if (property != null&&property.name() != null && !property.name().isEmpty()){ + if(property.name().contains(":")) { + String[] propertyWithCategory=property.name().split(":"); + if(propertyWithCategory.length>=2){ + serviceProperties.add(new ServiceInfoData(propertyWithCategory[1],property.value(),propertyWithCategory[0])); + } else { + serviceProperties.add(new ServiceInfoData(property.name(), property.value(), Constants.DATA_MINER_DEFAULT_SERVICE_INFO_CATEGORY)); + } + } else { + serviceProperties.add(new ServiceInfoData(property.name(), property.value(), Constants.DATA_MINER_DEFAULT_SERVICE_INFO_CATEGORY)); + } + } + + + } + } + + } + ServiceInfo serviceInfo=new ServiceInfo(serviceAddress,serviceProperties); + + logger.debug("DataMiner Service Info: " + serviceInfo); + return serviceInfo; + + } catch (Throwable e) { + logger.error("Error in discovery DataMiner Service Endpoint Info in scope: " + scope); + logger.error(e.getLocalizedMessage(), e); + throw e; + } + } } diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/Constants.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/Constants.java index 4412300..d5d1138 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/Constants.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/Constants.java @@ -34,7 +34,7 @@ public class Constants { // Download public static final String DOWNLOAD_SERVLET = "DownloadServlet"; - + // Upload public static final String LOCAL_UPLOAD_SERVLET = "LocalUploadServlet"; @@ -42,24 +42,34 @@ public class Constants { public static final String SAI_NAME = "SAIProfile"; public static final String SAI_CATEGORY = "SAI"; + public static final String DATA_MINER_SERVICE_CATEGORY = "DataAnalysis"; + public static final String DATA_MINER_SERVICE_NAME = "DataMiner"; + public static final String SOCIAL_NETWORKING_NAME = "SocialNetworking"; public static final String SOCIAL_NETWORKING_CLASS = "Portal"; public static final String POOL_MANAGER_SERVICE_NAME = "dataminer-pool-manager"; public static final String POOL_MANAGER_SERVICE_CLASS = "DataAnalysis"; + // DM Service Info + public static final String DATA_MINER_SERVICE_INFO_TITLE = "Service Profile"; + public static final String DATA_MINER_RUNTIME_FEATURE = "Runtime features"; + public static final String DATA_MINER_DEFAULT_SERVICE_INFO_CATEGORY = "Generic"; + // Main Generator public static final String PRE_INSTALLED = "Pre-Installed"; public static final String REMOTE_TEMPLATE_FILE = "http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-analysis/RConfiguration/RD4SFunctions/SAITemplateForExternalInvocation.R"; public static final String ECOLOGICAL_ENGINE_JAR_URL = "http://maven.research-infrastructures.eu/nexus/content/repositories/gcube-staging/org/gcube/dataanalysis/ecological-engine/1.12.0-4.13.1-154785/ecological-engine-1.12.0-4.13.1-154785.jar"; public static final String ECOLOGICAL_ENGINE_SMART_EXECUTOR_JAR_URL = "http://maven.research-infrastructures.eu/nexus/content/repositories/gcube-staging/org/gcube/dataanalysis/ecological-engine-smart-executor/1.6.2-4.13.1-167535/ecological-engine-smart-executor-1.6.2-4.13.1-167535.jar"; - + // DataMiner Pool Manager public static final int CLIENT_MONITOR_PERIODMILLIS = 2000; - + // public static final Project TEST_PROJECT = new Project(null, new ProjectConfig("", new ProjectSupportBashEdit())); - - - + + // WPS Data Miner + public static final String WPSWebProcessingService = "WebProcessingService"; + public static final String WPSCancelComputationServlet = "CancelComputationServlet"; + } diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/dminfo/ServiceInfo.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/dminfo/ServiceInfo.java new file mode 100644 index 0000000..e96d8c5 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/dminfo/ServiceInfo.java @@ -0,0 +1,49 @@ +package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.dminfo; + +import java.io.Serializable; +import java.util.ArrayList; + +/** + * + * @author Giancarlo Panichi + * + * + */ +public class ServiceInfo implements Serializable { + + private static final long serialVersionUID = 9046784925213335261L; + private String serviceAddress; + private ArrayList serviceProperties; + + public ServiceInfo() { + super(); + } + + public ServiceInfo(String serviceAddress, ArrayList serviceProperties) { + super(); + this.serviceAddress = serviceAddress; + this.serviceProperties = serviceProperties; + } + + public String getServiceAddress() { + return serviceAddress; + } + + public void setServiceAddress(String serviceAddress) { + this.serviceAddress = serviceAddress; + } + + public ArrayList getServiceProperties() { + return serviceProperties; + } + + public void setServiceProperties(ArrayList serviceProperties) { + this.serviceProperties = serviceProperties; + } + + @Override + public String toString() { + return "ServiceInfo [serviceAddress=" + serviceAddress + ", serviceProperties=" + serviceProperties + "]"; + } + +} diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/dminfo/ServiceInfoData.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/dminfo/ServiceInfoData.java new file mode 100644 index 0000000..b8ef136 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/shared/dminfo/ServiceInfoData.java @@ -0,0 +1,58 @@ +package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.dminfo; + +import java.io.Serializable; + +/** + * + * @author Giancarlo Panichi + * + * + */ +public class ServiceInfoData implements Serializable { + + private static final long serialVersionUID = 4732143678328978038L; + private String key; + private String value; + private String category; + + public ServiceInfoData() { + super(); + } + + public ServiceInfoData(String key, String value, String category) { + super(); + this.key = key; + this.value = value; + this.category = category; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + @Override + public String toString() { + return "ServiceInfoData [key=" + key + ", value=" + value + ", category=" + category + "]"; + } + +} diff --git a/src/main/resources/org/gcube/portlets/user/statisticalalgorithmsimporter/client/resource/service_profile_24.png b/src/main/resources/org/gcube/portlets/user/statisticalalgorithmsimporter/client/resource/service_profile_24.png new file mode 100644 index 0000000..29442d9 Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/statisticalalgorithmsimporter/client/resource/service_profile_24.png differ diff --git a/src/main/resources/org/gcube/portlets/user/statisticalalgorithmsimporter/client/resource/service_profile_32.png b/src/main/resources/org/gcube/portlets/user/statisticalalgorithmsimporter/client/resource/service_profile_32.png new file mode 100644 index 0000000..791561f Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/statisticalalgorithmsimporter/client/resource/service_profile_32.png differ