ref 11711: SAI - Add a simple text viewer so that log files created by Data Miner algorithms can be directly viewed in the browser
https://support.d4science.org/issues/11711 Added service info[ticket #12594] Added support to show log information [ticket #11711] Added support to show files html, json, pdf, txt [ticket #17106] Updated information show to the user when a computation is submitted [ticket #17030] git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/data-miner-executor@181884 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
692ed57df6
commit
47608e80de
|
@ -1,4 +1,15 @@
|
|||
<ReleaseNotes>
|
||||
<Changeset component="${groupId}.${artifactId}.1-2-0" date="2019-10-02">
|
||||
<Change>Added service info [ticket #12594]</Change>
|
||||
<Change>Added support to show log information [ticket #11711]</Change>
|
||||
<Change>Added support to show files html, json, pdf, txt [ticket
|
||||
#17106]
|
||||
</Change>
|
||||
<Change>Updated information show to the user when a computation is
|
||||
submitted [ticket #17030]
|
||||
</Change>
|
||||
<Change>Added Item Id support [ticket #16503]</Change>
|
||||
</Changeset>
|
||||
<Changeset component="${groupId}.${artifactId}.1-1-0" date="2019-03-13">
|
||||
<Change>Added automatic run [ticket #16155]</Change>
|
||||
</Changeset>
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.gcube.portlets.user.dataminerexecutor.client;
|
|||
import org.gcube.data.analysis.dataminermanagercl.shared.data.OutputData;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationData;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationId;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.service.ServiceInfo;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.workspace.ItemDescription;
|
||||
import org.gcube.portlets.user.dataminerexecutor.client.common.EventBusProvider;
|
||||
import org.gcube.portlets.user.dataminerexecutor.client.events.CancelComputationExecutionRequestEvent;
|
||||
|
@ -18,6 +19,8 @@ import org.gcube.portlets.user.dataminerexecutor.client.events.OutputDataEvent;
|
|||
import org.gcube.portlets.user.dataminerexecutor.client.events.OutputDataRequestEvent;
|
||||
import org.gcube.portlets.user.dataminerexecutor.client.events.ResubmitComputationExecutionEvent;
|
||||
import org.gcube.portlets.user.dataminerexecutor.client.events.ResubmitComputationExecutionRequestEvent;
|
||||
import org.gcube.portlets.user.dataminerexecutor.client.events.ServiceInfoEvent;
|
||||
import org.gcube.portlets.user.dataminerexecutor.client.events.ServiceInfoRequestEvent;
|
||||
import org.gcube.portlets.user.dataminerexecutor.client.events.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.dataminerexecutor.client.events.StartComputationExecutionEvent;
|
||||
import org.gcube.portlets.user.dataminerexecutor.client.events.StartComputationExecutionRequestEvent;
|
||||
|
@ -198,6 +201,17 @@ public class DataMinerExecutorController {
|
|||
|
||||
});
|
||||
|
||||
EventBusProvider.INSTANCE.addHandler(ServiceInfoRequestEvent.TYPE,
|
||||
new ServiceInfoRequestEvent.ServiceInfoRequestEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onRequest(ServiceInfoRequestEvent event) {
|
||||
Log.debug("Catch EnvironmentRequestEvent: " + event);
|
||||
retrieveEnvironment(event);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void restoreUISession() {
|
||||
|
@ -371,7 +385,8 @@ public class DataMinerExecutorController {
|
|||
|
||||
private void getDataMinerInvocationModelRequest() {
|
||||
if (invocationModelFileUrl == null || invocationModelFileUrl.isEmpty()) {
|
||||
Log.error("Invalid request, the invocation model has not been specified correctly: " + invocationModelFileUrl);
|
||||
Log.error("Invalid request, the invocation model has not been specified correctly: "
|
||||
+ invocationModelFileUrl);
|
||||
UtilsGXT3.alert("Error", "Invalid request, the invocation model has not been specified correctly!");
|
||||
} else {
|
||||
final AutoProgressMessageBox messageBox = new AutoProgressMessageBox("Retrieve Info",
|
||||
|
@ -394,7 +409,8 @@ public class DataMinerExecutorController {
|
|||
"The VRE currently has problems loading the required operator using the invocation model specified!");
|
||||
Log.error(
|
||||
"The VRE currently has problems loading the required operator using the invocation model specified: "
|
||||
+ caught.getLocalizedMessage(),caught);
|
||||
+ caught.getLocalizedMessage(),
|
||||
caught);
|
||||
|
||||
}
|
||||
|
||||
|
@ -487,4 +503,31 @@ public class DataMinerExecutorController {
|
|||
|
||||
}
|
||||
|
||||
private void retrieveEnvironment(final ServiceInfoRequestEvent event) {
|
||||
DataMinerExecutorServiceAsync.INSTANCE.getServiceInfo(new AsyncCallback<ServiceInfo>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof SessionExpiredServiceException) {
|
||||
UtilsGXT3.alert("Error", "Expired Session");
|
||||
EventBusProvider.INSTANCE.fireEvent(new SessionExpiredEvent());
|
||||
} else {
|
||||
UtilsGXT3.alert("Error",
|
||||
"Error retrieving DataMiner service info: " + caught.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(ServiceInfo serviceInfo) {
|
||||
Log.debug("DataMiner Service Info: " + serviceInfo);
|
||||
|
||||
ServiceInfoEvent serviceInfoEvent = new ServiceInfoEvent(serviceInfo);
|
||||
EventBusProvider.INSTANCE.fireEvent(serviceInfoEvent);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package org.gcube.portlets.user.dataminerexecutor.client.events;
|
||||
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.service.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<ServiceInfoEvent.ServiceInfoEventHandler> {
|
||||
|
||||
public static Type<ServiceInfoEventHandler> TYPE = new Type<ServiceInfoEventHandler>();
|
||||
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<ServiceInfoEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static Type<ServiceInfoEventHandler> 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 + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package org.gcube.portlets.user.dataminerexecutor.client.events;
|
||||
|
||||
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<ServiceInfoRequestEvent.ServiceInfoRequestEventHandler> {
|
||||
|
||||
public static Type<ServiceInfoRequestEventHandler> TYPE = new Type<ServiceInfoRequestEventHandler>();
|
||||
|
||||
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<ServiceInfoRequestEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static Type<ServiceInfoRequestEventHandler> getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static void fire(HasHandlers source, ServiceInfoRequestEvent event) {
|
||||
source.fireEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ServiceInfoRequestEvent []";
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -86,13 +86,8 @@ public class ComputationStatusPanel extends SimpleContainer {
|
|||
*/
|
||||
// vert.add(date, new VerticalLayoutData(-1, -1, new Margins(0)));
|
||||
|
||||
vert.add(new HtmlLayoutContainer("<p>Created, the id is " + computationId.getId() + "</p>"));
|
||||
|
||||
String opName=computationId.getOperatorName();
|
||||
opName=opName.replaceAll("\\s+", "_");
|
||||
|
||||
vert.add(new HtmlLayoutContainer("<p>DataMiner>Computations>"
|
||||
+ opName.toUpperCase() + "_ID_" + computationId.getId() + "</p>"));
|
||||
vert.add(new HtmlLayoutContainer(
|
||||
"<p><span style='margin-right:165px;'>Id:</span> " + computationId.getId() + "</p>"));
|
||||
|
||||
TextButton equivalentRequestBtn = new TextButton();
|
||||
equivalentRequestBtn.setText("Show");
|
||||
|
@ -103,13 +98,27 @@ public class ComputationStatusPanel extends SimpleContainer {
|
|||
showEquivalentRequestDialog();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
FieldLabel equivalentRequestLabel = new FieldLabel(equivalentRequestBtn, "Equivalent Get Request");
|
||||
equivalentRequestLabel.setLabelWidth(140);
|
||||
// vert.add(equivalentRequestLabel, new VerticalLayoutData(-1, -1,
|
||||
// new Margins(0)));
|
||||
FieldLabel equivalentRequestLabel = new FieldLabel(equivalentRequestBtn, "WPS Request");
|
||||
equivalentRequestLabel.setLabelWidth(180);
|
||||
vert.add(equivalentRequestLabel, new VerticalLayoutData(-1, -1, new Margins(0)));
|
||||
|
||||
TextButton monitorComputationBtn = new TextButton();
|
||||
monitorComputationBtn.setText("Show");
|
||||
monitorComputationBtn.addSelectHandler(new SelectHandler() {
|
||||
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
showLinkToMonitorComputationDialog();
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
FieldLabel monitorComputationLabel = new FieldLabel(monitorComputationBtn, "Link to monitor the computation");
|
||||
monitorComputationLabel.setLabelWidth(180);
|
||||
vert.add(monitorComputationLabel, new VerticalLayoutData(-1, -1, new Margins(0)));
|
||||
|
||||
progressBar = new ProgressBar();
|
||||
progressBar.updateProgress(0, "Starting...");
|
||||
|
@ -139,6 +148,12 @@ public class ComputationStatusPanel extends SimpleContainer {
|
|||
equivalentRequestDialog.show();
|
||||
}
|
||||
|
||||
private void showLinkToMonitorComputationDialog() {
|
||||
LinkToMonitorComputationDialog linkToMonitorComputDialogDialog = new LinkToMonitorComputationDialog(
|
||||
computationId);
|
||||
linkToMonitorComputDialogDialog.show();
|
||||
}
|
||||
|
||||
private void cancelComputation() {
|
||||
CancelComputationExecutionRequestEvent event = new CancelComputationExecutionRequestEvent(computationId);
|
||||
EventBusProvider.INSTANCE.fireEvent(event);
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
package org.gcube.portlets.user.dataminerexecutor.client.experiments;
|
||||
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationId;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
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.form.TextArea;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class LinkToMonitorComputationDialog extends Dialog {
|
||||
private ComputationId computationId;
|
||||
|
||||
public LinkToMonitorComputationDialog(ComputationId computationId) {
|
||||
super();
|
||||
Log.debug("LinkToMonitorComputationDialog: " + computationId);
|
||||
this.computationId = computationId;
|
||||
init();
|
||||
create();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setModal(true);
|
||||
setClosable(true);
|
||||
setHeadingText("Link To Monitor The Computation");
|
||||
setBodyBorder(true);
|
||||
setHideOnButtonClick(true);
|
||||
setPredefinedButtons(PredefinedButton.CLOSE);
|
||||
getButtonBar().setPack(BoxLayoutPack.CENTER);
|
||||
}
|
||||
|
||||
private void create() {
|
||||
TextArea infoArea = new TextArea();
|
||||
infoArea.setHeight(200);
|
||||
infoArea.setWidth(640);
|
||||
infoArea.setValue(computationId.getUrlId());
|
||||
infoArea.setReadOnly(true);
|
||||
add(infoArea);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -8,6 +8,7 @@ import org.gcube.portlets.user.dataminerexecutor.client.DataMinerExecutor;
|
|||
import org.gcube.portlets.user.dataminerexecutor.client.common.EventBusProvider;
|
||||
import org.gcube.portlets.user.dataminerexecutor.client.events.ComputationReadyEvent;
|
||||
import org.gcube.portlets.user.dataminerexecutor.client.events.ResubmitComputationExecutionEvent;
|
||||
import org.gcube.portlets.user.dataminerexecutor.client.info.ServiceInfoPanel;
|
||||
import org.gcube.portlets.user.dataminerexecutor.shared.process.InvocationModel;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
|
@ -21,11 +22,13 @@ import com.sencha.gxt.widget.core.client.TabPanel;
|
|||
*
|
||||
*/
|
||||
public class WorkflowPanel extends TabPanel {
|
||||
|
||||
public static final String DEFAULT_OPERATOR = "AQUAMAPS_SUITABLE";
|
||||
private static final String OPERATOR = "Operator";
|
||||
private static final String COMPUTATIONS_EXECUTION = "Computations Execution";
|
||||
private static final String SERVICE_INFO = "Service Profile";
|
||||
|
||||
private ComputationExecutionPanel computationExecutionPanel;
|
||||
private ComputationPanel computationPanel;
|
||||
private ServiceInfoPanel environmentPanel;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -44,13 +47,10 @@ public class WorkflowPanel extends TabPanel {
|
|||
|
||||
private void create() {
|
||||
|
||||
TabItemConfig tabWorkFlowLcItemConf = new TabItemConfig("Operator",
|
||||
false);
|
||||
tabWorkFlowLcItemConf.setIcon(DataMinerExecutor.resources
|
||||
.folderExplore());
|
||||
TabItemConfig tabWorkFlowLcItemConf = new TabItemConfig(OPERATOR, false);
|
||||
tabWorkFlowLcItemConf.setIcon(DataMinerExecutor.resources.folderExplore());
|
||||
computationPanel = new ComputationPanel();
|
||||
computationPanel
|
||||
.addComputationReadyEventHandler(new ComputationReadyEvent.ComputationReadyEventHandler() {
|
||||
computationPanel.addComputationReadyEventHandler(new ComputationReadyEvent.ComputationReadyEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onReady(ComputationReadyEvent event) {
|
||||
|
@ -61,13 +61,16 @@ public class WorkflowPanel extends TabPanel {
|
|||
});
|
||||
add(computationPanel, tabWorkFlowLcItemConf);
|
||||
|
||||
TabItemConfig tabComputationPanelItemConf = new TabItemConfig(
|
||||
"Computations Execution", false);
|
||||
tabComputationPanelItemConf.setIcon(DataMinerExecutor.resources
|
||||
.folderExplore());
|
||||
TabItemConfig tabComputationPanelItemConf = new TabItemConfig(COMPUTATIONS_EXECUTION, false);
|
||||
tabComputationPanelItemConf.setIcon(DataMinerExecutor.resources.folderExplore());
|
||||
computationExecutionPanel = new ComputationExecutionPanel();
|
||||
add(computationExecutionPanel, tabComputationPanelItemConf);
|
||||
|
||||
TabItemConfig tabEnvironmentPanelItemConf = new TabItemConfig(SERVICE_INFO, false);
|
||||
tabEnvironmentPanelItemConf.setIcon(DataMinerExecutor.resources.folderExplore());
|
||||
environmentPanel = new ServiceInfoPanel();
|
||||
add(environmentPanel, tabEnvironmentPanelItemConf);
|
||||
|
||||
setActiveWidget(computationPanel);
|
||||
}
|
||||
|
||||
|
@ -75,13 +78,10 @@ public class WorkflowPanel extends TabPanel {
|
|||
*
|
||||
*/
|
||||
private void bind() {
|
||||
EventBusProvider.INSTANCE
|
||||
.addHandler(
|
||||
ResubmitComputationExecutionEvent.getType(),
|
||||
EventBusProvider.INSTANCE.addHandler(ResubmitComputationExecutionEvent.getType(),
|
||||
new ResubmitComputationExecutionEvent.ResubmitComputationExecutionEventHandler() {
|
||||
@Override
|
||||
public void onResubmit(
|
||||
ResubmitComputationExecutionEvent event) {
|
||||
public void onResubmit(ResubmitComputationExecutionEvent event) {
|
||||
resubmitComputation();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package org.gcube.portlets.user.dataminerexecutor.client.info;
|
||||
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.service.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<ServiceInfoData> {
|
||||
@Path("key")
|
||||
ModelKeyProvider<ServiceInfoData> id();
|
||||
|
||||
ValueProvider<ServiceInfoData, String> key();
|
||||
ValueProvider<ServiceInfoData, String> value();
|
||||
ValueProvider<ServiceInfoData, String> category();
|
||||
}
|
||||
|
|
@ -0,0 +1,227 @@
|
|||
package org.gcube.portlets.user.dataminerexecutor.client.info;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.service.ServiceInfo;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.service.ServiceInfoData;
|
||||
import org.gcube.portlets.user.dataminerexecutor.client.common.EventBusProvider;
|
||||
import org.gcube.portlets.user.dataminerexecutor.client.events.ServiceInfoEvent;
|
||||
import org.gcube.portlets.user.dataminerexecutor.client.events.ServiceInfoRequestEvent;
|
||||
|
||||
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.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 String RUNTIME_FEATURE = "Runtime features";
|
||||
private static final String SERVICE_INFO_TITLE = "Service Profile";
|
||||
private static final ServiceInfoDataProperties props = GWT.create(ServiceInfoDataProperties.class);
|
||||
private VerticalLayoutContainer v;
|
||||
private VerticalLayoutContainer environmentVBox;
|
||||
|
||||
public ServiceInfoPanel() {
|
||||
super();
|
||||
Log.debug("ServiceInfoPanel");
|
||||
init();
|
||||
create();
|
||||
bind();
|
||||
EventBusProvider.INSTANCE.fireEvent(new ServiceInfoRequestEvent());
|
||||
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setItemId("ServiceInfoPanel");
|
||||
forceLayoutOnResize = true;
|
||||
setBodyBorder(false);
|
||||
setBorders(false);
|
||||
setBodyStyle("backgroundColor:white;");
|
||||
setHeaderVisible(false);
|
||||
setResize(true);
|
||||
setHeadingText(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() {
|
||||
|
||||
EventBusProvider.INSTANCE.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(
|
||||
"<center style='font-size:16px;font-weight:bold;'>" + SERVICE_INFO_TITLE + "</center>");
|
||||
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(
|
||||
"<p style='font-size:12px;'>This page reports information on the DataMiner "
|
||||
+ "service instance serving this working environment giving an up to date "
|
||||
+ "picture of its capacities and capabilities.</p>");
|
||||
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(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(
|
||||
"<p style='font-size:12px;'>The base url of the service instance is: " + "<a href='" + address + "'>"
|
||||
+ address + "</a></p>");
|
||||
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<ServiceInfoData> properties=serviceInfo.getServiceProperties();
|
||||
if (properties!=null&&!properties.isEmpty()) {
|
||||
Grid<ServiceInfoData> grid = createInfoGrid(properties);
|
||||
environmentVBox.add(grid, new VerticalLayoutData(1, -1, new Margins(0, 4, 0, 4)));
|
||||
} else {
|
||||
HtmlLayoutContainer emptyInfoContainer = new HtmlLayoutContainer(
|
||||
"<div class='service-property'><p>No Info Available.</p></div>");
|
||||
|
||||
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(
|
||||
"<div class='service-property'><p>No Info Available.</p></div>");
|
||||
|
||||
environmentVBox.add(emptyInfoContainer, new VerticalLayoutData(1, -1, new Margins(0, 4, 0, 4)));
|
||||
}
|
||||
|
||||
forceLayout();
|
||||
|
||||
}
|
||||
|
||||
private Grid<ServiceInfoData> createInfoGrid(ArrayList<ServiceInfoData> properties) {
|
||||
|
||||
ColumnConfig<ServiceInfoData, String> keyCol = new ColumnConfig<ServiceInfoData, String>(props.key(), 100,
|
||||
"Key");
|
||||
ColumnConfig<ServiceInfoData, String> valueCol = new ColumnConfig<ServiceInfoData, String>(props.value(), 100,
|
||||
"Value");
|
||||
ColumnConfig<ServiceInfoData, String> categoryCol = new ColumnConfig<ServiceInfoData, String>(props.category(),
|
||||
100,"Category");
|
||||
|
||||
List<ColumnConfig<ServiceInfoData, ?>> columns = new ArrayList<ColumnConfig<ServiceInfoData, ?>>();
|
||||
columns.add(keyCol);
|
||||
columns.add(valueCol);
|
||||
columns.add(categoryCol);
|
||||
|
||||
ColumnModel<ServiceInfoData> cm = new ColumnModel<ServiceInfoData>(columns);
|
||||
|
||||
ListStore<ServiceInfoData> store = new ListStore<ServiceInfoData>(props.id());
|
||||
store.addAll(properties);
|
||||
|
||||
final GroupingView<ServiceInfoData> groupingView = new GroupingView<ServiceInfoData>();
|
||||
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<ServiceInfoData> grid = new Grid<ServiceInfoData>(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;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -87,6 +87,9 @@ public interface Resources extends ClientBundle {
|
|||
@Source("download.png")
|
||||
ImageResource download();
|
||||
|
||||
@Source("page-white.png")
|
||||
ImageResource pageWhite();
|
||||
|
||||
@Source("show.png")
|
||||
ImageResource netcdf();
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 293 B |
|
@ -10,6 +10,7 @@ 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.data.analysis.dataminermanagercl.shared.service.ServiceInfo;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.workspace.DataMinerWorkArea;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.workspace.ItemDescription;
|
||||
import org.gcube.portlets.user.dataminerexecutor.shared.exception.ServiceException;
|
||||
|
@ -57,4 +58,5 @@ public interface DataMinerExecutorService extends RemoteService {
|
|||
|
||||
public InvocationModel getInvocationModel(String invocationModelFileUrl) throws ServiceException;
|
||||
|
||||
public ServiceInfo getServiceInfo() throws ServiceException;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ 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.data.analysis.dataminermanagercl.shared.service.ServiceInfo;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.workspace.DataMinerWorkArea;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.workspace.ItemDescription;
|
||||
import org.gcube.portlets.user.dataminerexecutor.shared.process.InvocationModel;
|
||||
|
@ -61,4 +62,5 @@ public interface DataMinerExecutorServiceAsync {
|
|||
|
||||
void getInvocationModel(String invocationModelFileUrl, AsyncCallback<InvocationModel> callback);
|
||||
|
||||
void getServiceInfo(AsyncCallback<ServiceInfo> asyncCallback);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,9 @@ import com.google.gwt.user.client.Window;
|
|||
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.BoxLayoutContainer.BoxLayoutData;
|
||||
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
|
||||
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer.HBoxLayoutAlign;
|
||||
import com.sencha.gxt.widget.core.client.container.HtmlLayoutContainer;
|
||||
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
|
||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
||||
|
@ -38,7 +41,7 @@ public class FileViewer extends SimpleContainer {
|
|||
*/
|
||||
public FileViewer(ComputationId computationId, FileResource fileResource) {
|
||||
super();
|
||||
GWT.log("FileViewer: [computationId="+computationId+", fileResource="+fileResource+"]");
|
||||
GWT.log("FileViewer: [computationId=" + computationId + ", fileResource=" + fileResource + "]");
|
||||
this.fileResource = fileResource;
|
||||
// this.computationId = computationId;
|
||||
init();
|
||||
|
@ -52,16 +55,32 @@ public class FileViewer extends SimpleContainer {
|
|||
private void create() {
|
||||
VerticalLayoutContainer lc = new VerticalLayoutContainer();
|
||||
final String fileName = fileResource.getName();
|
||||
String fileDescription = fileResource.getDescription();
|
||||
final String fileUrl = fileResource.getUrl();
|
||||
|
||||
if(fileDescription==null||fileDescription.isEmpty()){
|
||||
fileDescription="Unknow";
|
||||
}
|
||||
HtmlLayoutContainer fileNameHtml = new HtmlLayoutContainer("<div class='computation-output-fileName'><p>"
|
||||
+ new SafeHtmlBuilder().appendEscaped(fileName).toSafeHtml().asString() + "</p></div>");
|
||||
+ new SafeHtmlBuilder().appendEscaped(fileDescription).toSafeHtml().asString() + "</p></div>");
|
||||
lc.add(fileNameHtml, new VerticalLayoutData(-1, -1, new Margins(0)));
|
||||
TextButton downloadBtn = new TextButton("Download File");
|
||||
downloadBtn.setIcon(DataMinerExecutor.resources.download());
|
||||
downloadBtn.addSelectHandler(new SelectEvent.SelectHandler() {
|
||||
|
||||
TextButton showFileButton = new TextButton("Show");
|
||||
showFileButton.setIcon(DataMinerExecutor.resources.pageWhite());
|
||||
showFileButton.addSelectHandler(new SelectEvent.SelectHandler() {
|
||||
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
GWT.log("Download File url: "+fileUrl);
|
||||
showFileCreate();
|
||||
}
|
||||
});
|
||||
|
||||
TextButton downloadButton = new TextButton("Download");
|
||||
downloadButton.setIcon(DataMinerExecutor.resources.download());
|
||||
downloadButton.addSelectHandler(new SelectEvent.SelectHandler() {
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
GWT.log("Download File url: " + fileUrl);
|
||||
Window.open(fileUrl, fileName, "");
|
||||
|
||||
}
|
||||
|
@ -77,13 +96,41 @@ public class FileViewer extends SimpleContainer {
|
|||
}
|
||||
});
|
||||
|
||||
lc.add(downloadBtn, new VerticalLayoutData(-1, -1, new Margins(0)));
|
||||
if (fileResource.isNetcdf()) {
|
||||
lc.add(netcdfButton, new VerticalLayoutData(-1, -1, new Margins(0)));
|
||||
HBoxLayoutContainer buttonsContainer = new HBoxLayoutContainer();
|
||||
buttonsContainer.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
|
||||
BoxLayoutData buttonBoxLayoutData = new BoxLayoutData(new Margins(2, 2, 2, 2));
|
||||
// HorizontalLayoutData buttonBoxLayoutData = new
|
||||
// HorizontalLayoutData(-1, -1, new Margins(2));
|
||||
|
||||
if (fileName != null && !fileName.isEmpty()) {
|
||||
String fileNameLowerCase = fileName.toLowerCase();
|
||||
if (fileNameLowerCase.endsWith(".html") || fileNameLowerCase.endsWith(".htm")
|
||||
|| fileNameLowerCase.endsWith(".pdf")|| fileNameLowerCase.endsWith(".log") || fileNameLowerCase.endsWith(".json")
|
||||
|| fileNameLowerCase.endsWith(".txt")) {
|
||||
buttonsContainer.add(showFileButton, buttonBoxLayoutData);
|
||||
}
|
||||
}
|
||||
buttonsContainer.add(downloadButton, buttonBoxLayoutData);
|
||||
if (fileResource.isNetcdf()) {
|
||||
buttonsContainer.add(netcdfButton, buttonBoxLayoutData);
|
||||
}
|
||||
|
||||
lc.add(buttonsContainer);
|
||||
|
||||
add(lc);
|
||||
}
|
||||
|
||||
private void showFileCreate() {
|
||||
if (fileResource != null && fileResource.getUrl() != null && !fileResource.getUrl().isEmpty()) {
|
||||
GWT.log("ShowFileCreate");
|
||||
|
||||
ShowFileDialog showFileDialog = new ShowFileDialog(fileResource.getUrl());
|
||||
showFileDialog.setZIndex(XDOM.getTopZIndex());
|
||||
showFileDialog.show();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void showNetCDFFile() {
|
||||
if (fileResource != null && fileResource.getUrl() != null && !fileResource.getUrl().isEmpty()
|
||||
&& fileResource.isNetcdf()) {
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
package org.gcube.portlets.user.dataminerexecutor.client.widgets;
|
||||
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.event.logical.shared.ResizeEvent;
|
||||
import com.google.gwt.event.logical.shared.ResizeHandler;
|
||||
import com.google.gwt.user.client.ui.Frame;
|
||||
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 ShowFileDialog extends Dialog {
|
||||
|
||||
private String url;
|
||||
private Frame frame;
|
||||
|
||||
public ShowFileDialog(String url) {
|
||||
super();
|
||||
this.url = url;
|
||||
init();
|
||||
create();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setWidth("640px");
|
||||
setHeight("480px");
|
||||
setResizable(true);
|
||||
setHeadingText("View");
|
||||
setModal(true);
|
||||
setMaximizable(true);
|
||||
setPredefinedButtons(PredefinedButton.CLOSE);
|
||||
setButtonAlign(BoxLayoutPack.CENTER);
|
||||
getButtonBar();
|
||||
|
||||
}
|
||||
|
||||
private void create() {
|
||||
/*
|
||||
* VerticalLayoutContainer vc = new VerticalLayoutContainer();
|
||||
*
|
||||
* HtmlLayoutContainer propertyHtmlContainer = new HtmlLayoutContainer(
|
||||
* "<div><p><object type='text/html' width='640' height='480' data='" +
|
||||
* url + "'></object></p></div>");
|
||||
*
|
||||
* vc.add(propertyHtmlContainer, new VerticalLayoutData(-1, -1, new
|
||||
* Margins(0)));
|
||||
*
|
||||
* add(vc);
|
||||
*/
|
||||
|
||||
VerticalLayoutContainer vc = new VerticalLayoutContainer();
|
||||
vc.addResizeHandler(new ResizeHandler() {
|
||||
|
||||
@Override
|
||||
public void onResize(ResizeEvent event) {
|
||||
manageResize(event);
|
||||
}
|
||||
});
|
||||
frame = new Frame(url+"?content-disposition=inline");
|
||||
|
||||
frame.getElement().setAttribute("style", "margin:auto;");
|
||||
frame.getElement().getStyle().setBorderWidth(0, Unit.PX);
|
||||
frame.getElement().getStyle().setBackgroundColor("white");
|
||||
vc.add(frame, new VerticalLayoutData(-1,-1));
|
||||
add(vc);
|
||||
}
|
||||
|
||||
private void manageResize(ResizeEvent event){
|
||||
frame.setHeight(String.valueOf(event.getHeight())+"px");
|
||||
frame.setWidth(String.valueOf(event.getWidth())+"px");
|
||||
forceLayout();
|
||||
}
|
||||
|
||||
}
|
|
@ -17,6 +17,7 @@ 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.data.analysis.dataminermanagercl.shared.service.ServiceInfo;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.workspace.DataMinerWorkArea;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.workspace.ItemDescription;
|
||||
import org.gcube.data.analysis.dminvocation.ActionType;
|
||||
|
@ -31,6 +32,7 @@ import org.gcube.portlets.user.dataminerexecutor.shared.exception.ServiceExcepti
|
|||
import org.gcube.portlets.user.dataminerexecutor.shared.process.InvocationAction;
|
||||
import org.gcube.portlets.user.dataminerexecutor.shared.process.InvocationModel;
|
||||
import org.gcube.portlets.user.dataminerexecutor.shared.session.UserInfo;
|
||||
import org.gcube.portlets.user.dataminerexecutor.server.SessionUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -466,4 +468,24 @@ public class DataMinerExecutorServiceImpl extends RemoteServiceServlet implement
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceInfo getServiceInfo() throws ServiceException {
|
||||
try {
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
|
||||
|
||||
SClient smClient = SessionUtil.getSClient(httpRequest, serviceCredentials);
|
||||
logger.debug("GetServiceInfo()");
|
||||
|
||||
ServiceInfo serviceInfo = smClient.getServiceInfo();
|
||||
return serviceInfo;
|
||||
} catch (ServiceException e) {
|
||||
logger.error(e.getLocalizedMessage(),e);
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error retrieving Service Info: " + e.getLocalizedMessage(), e);
|
||||
throw new ServiceException(e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,8 +16,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.gcube.common.authorization.library.provider.UserInfo;
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.is.InformationSystemUtils;
|
||||
|
@ -26,6 +24,8 @@ import org.gcube.portlets.user.dataminerexecutor.shared.Constants;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
|
@ -34,8 +34,7 @@ import org.slf4j.LoggerFactory;
|
|||
*/
|
||||
public class TestDataMinerService extends TestCase {
|
||||
|
||||
private static Logger logger = LoggerFactory
|
||||
.getLogger(TestDataMinerService.class);
|
||||
private static Logger logger = LoggerFactory.getLogger(TestDataMinerService.class);
|
||||
|
||||
private String wpsToken;
|
||||
private String wpsUser;
|
||||
|
@ -50,7 +49,7 @@ public class TestDataMinerService extends TestCase {
|
|||
wpsUser = Constants.DEFAULT_USER;
|
||||
scope = Constants.DEFAULT_SCOPE;
|
||||
|
||||
ServiceCredentials serviceCredentials=new ServiceCredentials();
|
||||
ServiceCredentials serviceCredentials = new ServiceCredentials();
|
||||
serviceCredentials.setUserName(wpsUser);
|
||||
serviceCredentials.setScope(scope);
|
||||
|
||||
|
@ -63,36 +62,30 @@ public class TestDataMinerService extends TestCase {
|
|||
|
||||
try {
|
||||
wpsToken = authorizationService().generateUserToken(
|
||||
new UserInfo(serviceCredentials.getUserName(), userRoles),
|
||||
serviceCredentials.getScope());
|
||||
new UserInfo(serviceCredentials.getUserName(), userRoles), serviceCredentials.getScope());
|
||||
} catch (Exception e) {
|
||||
logger.error("Error generating the token for test: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new Exception("Error generating the token for test: "
|
||||
+ e.getLocalizedMessage());
|
||||
logger.error("Error generating the token for test: " + e.getLocalizedMessage(), e);
|
||||
|
||||
throw new Exception("Error generating the token for test: " + e.getLocalizedMessage(), e);
|
||||
}
|
||||
serviceCredentials.setToken(wpsToken);
|
||||
|
||||
List<String> serviceAddress = InformationSystemUtils
|
||||
.retrieveServiceAddress(
|
||||
Constants.DATAMINER_SERVICE_CATEGORY,
|
||||
String serviceAddress = InformationSystemUtils.retrieveServiceAddress(Constants.DATAMINER_SERVICE_CATEGORY,
|
||||
Constants.DATA_MINER_SERVICE_NAME, serviceCredentials.getScope());
|
||||
logger.debug("Service Address retrieved:" + serviceAddress);
|
||||
if (serviceAddress == null || serviceAddress.size() < 1) {
|
||||
if (serviceAddress == null || serviceAddress.isEmpty()) {
|
||||
logger.error("No DataMiner service address available!");
|
||||
throw new Exception("No DataMiner service address available!");
|
||||
} else {
|
||||
logger.info("DataMiner service address found: "
|
||||
+ serviceAddress.get(0));
|
||||
wpsProcessingServlet = serviceAddress.get(0);
|
||||
logger.info("DataMiner service address found: " + serviceAddress);
|
||||
wpsProcessingServlet = serviceAddress;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void testExecuteProcess() {
|
||||
if(Constants.TEST_ENABLE){
|
||||
if (Constants.TEST_ENABLE) {
|
||||
executeProcess();
|
||||
} else {
|
||||
assertTrue(true);
|
||||
|
@ -100,13 +93,13 @@ public class TestDataMinerService extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
private void executeProcess(){
|
||||
private void executeProcess() {
|
||||
|
||||
try {
|
||||
|
||||
retrieveServicesInfo();
|
||||
|
||||
String urlString=wpsProcessingServlet;
|
||||
String urlString = wpsProcessingServlet;
|
||||
|
||||
logger.debug("RetrieveDataViaPost(): " + urlString);
|
||||
String authString = wpsUser + ":" + wpsToken;
|
||||
|
@ -123,8 +116,8 @@ public class TestDataMinerService extends TestCase {
|
|||
conn.setRequestProperty("Content-Type", "text/xml");
|
||||
conn.setDoOutput(true);
|
||||
OutputStream output = conn.getOutputStream();
|
||||
Path currentPath=Paths.get(".");
|
||||
logger.info("CurrentPath:"+currentPath.toAbsolutePath().toString());
|
||||
Path currentPath = Paths.get(".");
|
||||
logger.info("CurrentPath:" + currentPath.toAbsolutePath().toString());
|
||||
|
||||
Files.copy(Paths.get("TestDataMinerServiceDBSCAN.xml"), output);
|
||||
|
||||
|
@ -136,8 +129,7 @@ public class TestDataMinerService extends TestCase {
|
|||
input = conn.getInputStream();
|
||||
}
|
||||
|
||||
BufferedReader r = new BufferedReader(new InputStreamReader(input,
|
||||
StandardCharsets.UTF_8));
|
||||
BufferedReader r = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8));
|
||||
|
||||
logger.info("Response:");
|
||||
String str = null;
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
package org.gcube.portlets.user.dataminerexecutor;
|
||||
|
||||
import static org.gcube.common.authorization.client.Constants.authorizationService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.UserInfo;
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.is.InformationSystemUtils;
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.util.ServiceCredentials;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.service.ServiceInfo;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.service.ServiceInfoData;
|
||||
import org.gcube.portlets.user.dataminerexecutor.shared.Constants;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class TestInformationSystemRequests extends TestCase {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(TestInformationSystemRequests.class);
|
||||
|
||||
private String wpsToken;
|
||||
private String wpsUser;
|
||||
private String scope;
|
||||
|
||||
private void retrieveServicesInfo() throws Exception {
|
||||
|
||||
logger.info("Use test user");
|
||||
|
||||
wpsUser = Constants.DEFAULT_USER;
|
||||
scope = Constants.DEFAULT_SCOPE;
|
||||
|
||||
ServiceCredentials serviceCredentials = new ServiceCredentials();
|
||||
serviceCredentials.setUserName(wpsUser);
|
||||
serviceCredentials.setScope(scope);
|
||||
|
||||
List<String> userRoles = new ArrayList<>();
|
||||
userRoles.add(Constants.DEFAULT_ROLE);
|
||||
|
||||
try {
|
||||
wpsToken = authorizationService().generateUserToken(
|
||||
new UserInfo(serviceCredentials.getUserName(), userRoles), serviceCredentials.getScope());
|
||||
} catch (Exception e) {
|
||||
logger.error("Error generating the token for test: " + e.getLocalizedMessage(), e);
|
||||
|
||||
throw new Exception("Error generating the token for test: " + e.getLocalizedMessage(), e);
|
||||
}
|
||||
serviceCredentials.setToken(wpsToken);
|
||||
|
||||
String serviceAddress = InformationSystemUtils.retrieveServiceAddress(Constants.DATAMINER_SERVICE_CATEGORY,
|
||||
Constants.DATA_MINER_SERVICE_NAME, serviceCredentials.getScope());
|
||||
logger.debug("Service Address retrieved:" + serviceAddress);
|
||||
if (serviceAddress == null || serviceAddress.isEmpty()) {
|
||||
logger.error("No DataMiner service address available!");
|
||||
throw new Exception("No DataMiner service address available!");
|
||||
} else {
|
||||
logger.info("DataMiner service address found: " + serviceAddress);
|
||||
|
||||
}
|
||||
|
||||
ServiceInfo serviceInfo = InformationSystemUtils.retrieveServiceInfo(
|
||||
Constants.DATAMINER_SERVICE_CATEGORY, Constants.DATA_MINER_SERVICE_NAME, serviceCredentials.getScope());
|
||||
logger.debug("Service Properties retrieved:" + serviceInfo);
|
||||
if (serviceInfo == null) {
|
||||
logger.error("No DataMiner service properties available!");
|
||||
throw new Exception("No DataMiner service properties available!");
|
||||
} else {
|
||||
logger.info("DataMiner service properties found");
|
||||
logger.debug("Service Address: "+serviceInfo.getServiceAddress());
|
||||
for (ServiceInfoData serviceInfoData : serviceInfo.getServiceProperties()) {
|
||||
logger.debug("Property: " + serviceInfoData);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void testExecuteProcess() {
|
||||
if (Constants.TEST_ENABLE) {
|
||||
try {
|
||||
retrieveServicesInfo();
|
||||
assertTrue(true);
|
||||
} catch (Throwable e) {
|
||||
logger.error(e.getLocalizedMessage(), e);
|
||||
assertTrue(false);
|
||||
}
|
||||
} else {
|
||||
assertTrue(true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue