From 7a7c8ca651a94d5f06fa7ade4ed734dda22712ea Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Thu, 2 Feb 2017 10:13:54 +0000 Subject: [PATCH] refs 5870: TDM - adding new functionalities to portlets Task-Url: https://support.d4science.org/issues/5870 Updated to support SDMX Dataset export git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-csv-import-widget@142045 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/csvgrid/CSVGrid.java | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/csvgrid/CSVGrid.java b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/csvgrid/CSVGrid.java index d3e38cd..0f7bcd7 100644 --- a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/csvgrid/CSVGrid.java +++ b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/csvgrid/CSVGrid.java @@ -37,13 +37,12 @@ import com.sencha.gxt.widget.core.client.grid.RowNumberer; */ public class CSVGrid extends Grid { - //private static final String csvImportFileServlet = "CSVImportFileServlet"; + // private static final String csvImportFileServlet = + // "CSVImportFileServlet"; private CSVGridView gridViewSample; private CSVGridMessages msgs; private CommonMessages msgsCommon; - - public CSVGrid() { super(new ListStore(new CSVRowKeyProvider()), new ColumnModel( @@ -62,13 +61,11 @@ public class CSVGrid extends Grid { setBorders(true); } - protected void initMessages() { msgs = GWT.create(CSVGridMessages.class); msgsCommon = GWT.create(CommonMessages.class); } - - + public void configureColumns(ArrayList columnNames) { ColumnModel columnModel = createColumnModel(columnNames); ListStore store = createStore(columnNames); @@ -77,18 +74,21 @@ public class CSVGrid extends Grid { } protected ListStore createStore(ArrayList columnNames) { - ListStore store=null; - + ListStore store = null; + try { - String path = GWT.getModuleBaseURL() + Constants.CSV_IMPORT_FILE_SERVLET; + String path = GWT.getModuleBaseURL() + + Constants.CSV_IMPORT_FILE_SERVLET + "?" + + Constants.CURR_GROUP_ID + "=" + + GCubeClientContext.getCurrentContextId(); Log.info("CSVImportFileServlet path:" + path); // use a http proxy to get the data RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, path); - + builder.setHeader(Constants.CURR_GROUP_ID, GCubeClientContext.getCurrentContextId()); - + HttpProxy proxy = new HttpProxy( builder); @@ -98,21 +98,20 @@ public class CSVGrid extends Grid { final ListLoader> loader = new ListLoader>( proxy, reader); - store = new ListStore( - new CSVRowKeyProvider()); + store = new ListStore(new CSVRowKeyProvider()); loader.addLoadHandler(new LoadResultListStoreBinding>( store)); loader.load(); - } catch (Exception e) { - UtilsGXT3.alert(msgsCommon.error(),msgs.errorCreatingTheStore(e.getLocalizedMessage())); - Log.error("Error in creating the store: "+e.getLocalizedMessage()); + UtilsGXT3.alert(msgsCommon.error(), + msgs.errorCreatingTheStore(e.getLocalizedMessage())); + Log.error("Error in creating the store: " + e.getLocalizedMessage()); e.printStackTrace(); - + } - + return store; }