Skip to content
Snippets Groups Projects
Commit 4904e72c authored by cramakri's avatar cramakri
Browse files

BIS-122 SP-236 : Support passing parameters for the aggregation service as query parameters

SVN: 26315
parent 51d0c6dc
No related branches found
No related tags found
No related merge requests found
...@@ -23,7 +23,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.exception.UserFailureE ...@@ -23,7 +23,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.exception.UserFailureE
*/ */
public class AggregationServiceLocatorResolver extends AbstractViewLocatorResolver public class AggregationServiceLocatorResolver extends AbstractViewLocatorResolver
{ {
public final static String ACTION = "AGGREGATION_SERVICE"; final static String ACTION = "AGGREGATION_SERVICE";
private final IViewContext<ICommonClientServiceAsync> viewContext; private final IViewContext<ICommonClientServiceAsync> viewContext;
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.aggregation; package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.aggregation;
import java.util.HashMap; 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.ICommonClientServiceAsync;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.IViewContext; 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; ...@@ -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.ContentPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer; import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.layout.FitLayout; 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.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HTML;
/** /**
* A panel that shows the results of an aggregation service. * A panel that shows the results of an aggregation service.
...@@ -67,6 +71,10 @@ public class AggregationServicePanel extends ContentPanel ...@@ -67,6 +71,10 @@ public class AggregationServicePanel extends ContentPanel
private final ViewLocator viewLocator; private final ViewLocator viewLocator;
private final String serviceKey;
private final String dataStoreCode;
public AggregationServicePanel(IViewContext<ICommonClientServiceAsync> viewContext, public AggregationServicePanel(IViewContext<ICommonClientServiceAsync> viewContext,
String idPrefix, ViewLocator viewLocator) String idPrefix, ViewLocator viewLocator)
{ {
...@@ -74,15 +82,72 @@ public class AggregationServicePanel extends ContentPanel ...@@ -74,15 +82,72 @@ public class AggregationServicePanel extends ContentPanel
setId(idPrefix + "aggregation_service"); setId(idPrefix + "aggregation_service");
this.viewContext = viewContext; this.viewContext = viewContext;
this.viewLocator = viewLocator; 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>(); 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 description =
DatastoreServiceDescription.reporting(serviceKey, "", new String[0], dataStoreCode, DatastoreServiceDescription.reporting(serviceKey, "", new String[0], dataStoreCode,
ReportingPluginType.AGGREGATION_TABLE_MODEL); ReportingPluginType.AGGREGATION_TABLE_MODEL);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment