diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/aggregation/AggregationServiceLocatorResolver.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/aggregation/AggregationServiceLocatorResolver.java index 1673fa5bdf1a2ccb1abc5d8e1ac8badc2a10711c..1597bd3c36e7693e65269076c15f4eb7a5874317 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/aggregation/AggregationServiceLocatorResolver.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/aggregation/AggregationServiceLocatorResolver.java @@ -23,7 +23,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.exception.UserFailureE */ public class AggregationServiceLocatorResolver extends AbstractViewLocatorResolver { - public final static String ACTION = "AGGREGATION_SERVICE"; + final static String ACTION = "AGGREGATION_SERVICE"; private final IViewContext<ICommonClientServiceAsync> viewContext; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/aggregation/AggregationServicePanel.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/aggregation/AggregationServicePanel.java index 92f316057a5aafe1d9a7b3809068c67165363b5f..b896e0faa60f5c22d80efda08d3e58f5be3b60aa 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/aggregation/AggregationServicePanel.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/aggregation/AggregationServicePanel.java @@ -17,6 +17,8 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.aggregation; import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; import ch.systemsx.cisd.openbis.generic.client.web.client.ICommonClientServiceAsync; import ch.systemsx.cisd.openbis.generic.client.web.client.application.IViewContext; @@ -31,7 +33,9 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ReportingPluginType; import com.extjs.gxt.ui.client.widget.ContentPanel; import com.extjs.gxt.ui.client.widget.LayoutContainer; import com.extjs.gxt.ui.client.widget.layout.FitLayout; +import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.ui.HTML; /** * A panel that shows the results of an aggregation service. @@ -67,6 +71,10 @@ public class AggregationServicePanel extends ContentPanel private final ViewLocator viewLocator; + private final String serviceKey; + + private final String dataStoreCode; + public AggregationServicePanel(IViewContext<ICommonClientServiceAsync> viewContext, String idPrefix, ViewLocator viewLocator) { @@ -74,15 +82,72 @@ public class AggregationServicePanel extends ContentPanel setId(idPrefix + "aggregation_service"); this.viewContext = viewContext; this.viewLocator = viewLocator; - callAggregationService(); + serviceKey = viewLocator.getParameters().get(SERVICE_KEY_PARAM); + dataStoreCode = viewLocator.getParameters().get(DSS_CODE_PARAM); + + if (areRequiredParametersSpecified()) + { + // All ivars must be initialized before the aggregation service is called + callAggregationService(); + } else + { + showErrorPage(); + } + } + + private void showErrorPage() + { + StringBuilder sb = new StringBuilder(); + sb.append("<h1>Missing Required Parameters</h1>\n"); + sb.append("<p>"); + if (null == serviceKey && null == dataStoreCode) + { + sb.append("The aggregation service and data store code must be specified in the URL query parameters. E.g:"); + + } else if (null == serviceKey) + { + sb.append("The aggregation service must be specified in the URL query parameters. E.g:"); + } else + { + sb.append("The data store code must be specified in the URL query parameters. E.g:"); + } + + sb.append("<blockquote>"); + // Append the inital part of the URL to this openBIS instance + sb.append(Window.Location.getProtocol()); + sb.append("//"); + sb.append(Window.Location.getHost()); + sb.append("?viewMode=EMBEDDED#action="); + sb.append(AggregationServiceLocatorResolver.ACTION); + sb.append("serviceKey=[service key]&dss=[dss code]</blockquote>"); + sb.append("</p>"); + HTML content = new HTML(sb.toString()); + add(content); + layout(); } - protected void callAggregationService() + private boolean areRequiredParametersSpecified() + { + return serviceKey != null && dataStoreCode != null; + } + + private void callAggregationService() { - String serviceKey = viewLocator.getParameters().get(SERVICE_KEY_PARAM); - String dataStoreCode = viewLocator.getParameters().get(DSS_CODE_PARAM); HashMap<String, Object> parameterMap = new HashMap<String, Object>(); - parameterMap.put("name", "foo"); + // Add all the remaining parameters to the parameter map + Map<String, String> urlParameters = viewLocator.getParameters(); + for (Entry<String, String> entry : urlParameters.entrySet()) + { + if (SERVICE_KEY_PARAM.equals(entry.getKey())) + { + continue; + } + if (DSS_CODE_PARAM.equals(entry.getKey())) + { + continue; + } + parameterMap.put(entry.getKey(), entry.getValue()); + } DatastoreServiceDescription description = DatastoreServiceDescription.reporting(serviceKey, "", new String[0], dataStoreCode, ReportingPluginType.AGGREGATION_TABLE_MODEL);