diff --git a/.classpath b/.classpath
index 7b61c02..d83b25c 100644
--- a/.classpath
+++ b/.classpath
@@ -1,12 +1,12 @@
-
+
-
+
@@ -33,5 +33,5 @@
-
+
diff --git a/distro/changelog.xml b/distro/changelog.xml
index 543251f..47673c7 100644
--- a/distro/changelog.xml
+++ b/distro/changelog.xml
@@ -1,8 +1,13 @@
+
+ Added Excel Dataset Export support [ticket #9944]
+
Enable SDMX export operation for DataSet only for the tables
- already shared with the whole VRE [ticket #10586]
+ already shared with the whole VRE [ticket #10586]
+
diff --git a/pom.xml b/pom.xml
index 3081f37..2592888 100644
--- a/pom.xml
+++ b/pom.xml
@@ -14,7 +14,7 @@
4.0.0
org.gcube.portlets.user
tabular-data-gwt-service
- 2.19.0-SNAPSHOT
+ 2.20.0-SNAPSHOT
tabular-data-gwt-service
tabular-data-gwt-service allows communication between the GUI and services
diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java
index 2020d09..4866371 100644
--- a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java
+++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java
@@ -12,6 +12,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.csv.AvailableCharsetList;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CheckCSVSession;
+import org.gcube.portlets.user.td.gwtservice.shared.excel.ExcelExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
import org.gcube.portlets.user.td.gwtservice.shared.extract.ExtractCodelistSession;
import org.gcube.portlets.user.td.gwtservice.shared.file.FileUploadMonitor;
@@ -888,6 +889,18 @@ public interface TDGWTService extends RemoteService {
*/
public String startSDMXExport(SDMXExportSession exportSession) throws TDGWTServiceException;
+ // Export Excel
+ /**
+ * Start Excel Export and invokes the client library
+ *
+ * @param exportSession
+ * Session
+ * @return Operation
+ * @throws TDGWTServiceException
+ * Exception
+ */
+ public String startExcelExport(ExcelExportSession exportSession) throws TDGWTServiceException;
+
// Export Template SDMX
/**
*
diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java
index cc6dd0d..e40c0f2 100644
--- a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java
+++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java
@@ -12,6 +12,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.csv.AvailableCharsetList;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CheckCSVSession;
+import org.gcube.portlets.user.td.gwtservice.shared.excel.ExcelExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.extract.ExtractCodelistSession;
import org.gcube.portlets.user.td.gwtservice.shared.file.FileUploadMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.file.HeaderPresence;
@@ -260,6 +261,9 @@ public interface TDGWTServiceAsync {
// Export SDMX
void startSDMXExport(SDMXExportSession exportSession, AsyncCallback callback);
+
+ // Export EXCEL
+ void startExcelExport(ExcelExportSession exportSession, AsyncCallback callback);
// Export Template SDMX
void startSDMXTemplateExport(SDMXTemplateExportSession sdmxTemplateExportSession, AsyncCallback callback);
diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionConstants.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionConstants.java
index 7dd8e40..60090aa 100644
--- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionConstants.java
+++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionConstants.java
@@ -33,7 +33,6 @@ public class SessionConstants {
public static final String SDMX_CLIENT_ATTRIBUTE = "SDMX_CLIENT";
public static final String SDMX_IMPORT_SESSION = "SDMX_IMPORT";
public static final String SDMX_IMPORT_TABULAR_RESOURCE = "SDMX_IMPORT_TABULAR_RESOURCE";
-
public static final String SDMX_EXPORT_SESSION = "SDMX_EXPORT_SESSION";
public static final String SDMX_TEMPLATE_EXPORT_SESSION = "SDMX_TEMPLATE_EXPORT_SESSION";
@@ -47,6 +46,11 @@ public class SessionConstants {
public static final String JSON_EXPORT_SESSION = "JSON_EXPORT_SESSION";
public static final String JSON_EXPORT_END = "JSON_EXPORT_END";
+ public static final String EXCEL_IMPORT_SESSION = "EXCEL_IMPORT";
+ public static final String EXCEL_IMPORT_TABULAR_RESOURCE = "EXCEL_IMPORT_TABULAR_RESOURCE";
+ public static final String EXCEL_EXPORT_SESSION = "EXCEL_EXPORT_SESSION";
+ public static final String EXCEL_TEMPLATE_EXPORT_SESSION = "EXCEL_TEMPLATE_EXPORT_SESSION";
+
public static final String CLONE_TABULAR_RESOURCE_SESSION = "CLONE_TABULAR_RESOURCE_SESSION";
public static final String CHANGE_COLUMN_TYPE_SESSION = "CHANGE_COLUMN_TYPE_SESSION";
diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java
index 5b6660f..88448ce 100644
--- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java
+++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java
@@ -25,6 +25,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.chart.ChartTopRatingSession;
import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession;
+import org.gcube.portlets.user.td.gwtservice.shared.excel.ExcelExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
import org.gcube.portlets.user.td.gwtservice.shared.extract.ExtractCodelistSession;
import org.gcube.portlets.user.td.gwtservice.shared.file.FileUploadMonitor;
@@ -598,6 +599,21 @@ public class SessionUtil {
}
+ //
+ public static void setExcelExportSession(HttpServletRequest httpRequest, ServiceCredentials serviceCredentials,
+ ExcelExportSession excelExportSession) {
+ SessionOp sessionOp = new SessionOp<>();
+ sessionOp.set(httpRequest, serviceCredentials, SessionConstants.EXCEL_EXPORT_SESSION, excelExportSession);
+ }
+
+ public static ExcelExportSession getExcelExportSession(HttpServletRequest httpRequest,
+ ServiceCredentials serviceCredentials) {
+ SessionOp sessionOp = new SessionOp<>();
+ ExcelExportSession excelExportSession = sessionOp.get(httpRequest, serviceCredentials,
+ SessionConstants.EXCEL_EXPORT_SESSION);
+ return excelExportSession;
+ }
+
//
public static void setCSVFileUploadSession(HttpServletRequest httpRequest, ServiceCredentials serviceCredentials,
CSVFileUploadSession csvFileUploadSession) {
diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java
index af966f7..9b4bbd1 100644
--- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java
+++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java
@@ -127,6 +127,7 @@ import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4Dele
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4Denormalization;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4Duplicates;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4EditRow;
+import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4ExcelDatasetExport;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4ExtractCodelist;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4FilterColumn;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4GeometryCreatePoint;
@@ -175,6 +176,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVFileUtil;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVParserConfiguration;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CheckCSVSession;
+import org.gcube.portlets.user.td.gwtservice.shared.excel.ExcelExportSession;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsFinalException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsFlowException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException;
@@ -4524,6 +4526,89 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
}
}
+
+ @Override
+ public String startExcelExport(ExcelExportSession exportSession) throws TDGWTServiceException {
+ HttpServletRequest httpRequest = null;
+ try {
+ httpRequest = this.getThreadLocalRequest();
+ ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
+ logger.debug("Start Excel Export");
+
+ TRId trId = SessionUtil.getTRId(httpRequest, serviceCredentials);
+ if (trId == null) {
+ throw new TDGWTServiceException("Error no tabular resource in session");
+ }
+
+ if (trId.getTableId() == null) {
+ throw new TDGWTServiceException("Error no table present in session");
+ }
+
+ if (exportSession == null) {
+ logger.error("Error in Excel Export: exportSession is null!");
+ throw new TDGWTServiceException("Error in Excel Export: exportSession is null!!");
+
+ }
+
+ SessionUtil.setExcelExportSession(httpRequest, serviceCredentials, exportSession);
+
+ logger.debug("Tabular Data Service");
+
+ TabularDataService service = TabularDataServiceFactory.getService();
+
+ checkTRId(trId, httpRequest, serviceCredentials);
+
+ TabularResourceId tabularResourceId = new TabularResourceId(Long.valueOf(trId.getId()));
+ TabularResource tabularResource = service.getTabularResource(tabularResourceId);
+
+ checkTabularResourceIsFlow(tabularResource, httpRequest, serviceCredentials);
+ checkTabularResourceLocked(tabularResource, httpRequest, serviceCredentials);
+
+ OpExecutionDirector director = new OpExecutionDirector();
+ // /
+ switch (exportSession.getExportType()) {
+ case DATASET:
+ OpExecution4ExcelDatasetExport opExD = new OpExecution4ExcelDatasetExport(httpRequest, serviceCredentials,
+ service, exportSession);
+ director.setOperationExecutionBuilder(opExD);
+ break;
+ case GENERIC:
+ case CODELIST:
+ default:
+ logger.error("Error in Excel Export: Only Codelist and Dataset are supported!");
+ throw new TDGWTServiceException("Error in ExcelExport: Only Dataset are supported!");
+ }
+
+ director.constructOperationExecution();
+ OperationExecution invocation = director.getOperationExecution();
+
+ if (invocation == null) {
+ throw new TDGWTServiceException("Error in ExcelExport: Operation not supported for now!");
+ }
+ logger.debug("OperationInvocation: \n" + invocation.toString());
+
+ Task trTask = service.execute(invocation, new TabularResourceId(Long.valueOf(trId.getId())));
+ logger.debug("Start Task on service: TaskId " + trTask.getId());
+
+ TaskWrapper taskWrapper = new TaskWrapper(trTask, UIOperationsId.ExcelExport, trId);
+ SessionUtil.setStartedTask(httpRequest, serviceCredentials, taskWrapper);
+
+ return trTask.getId().getValue();
+
+ } catch (TDGWTServiceException e) {
+ throw e;
+ } catch (SecurityException e) {
+ e.printStackTrace();
+ ResourceBundle messages = getResourceBundle(httpRequest);
+ throw new TDGWTServiceException(messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights));
+ } catch (Throwable e) {
+ e.printStackTrace();
+ throw new TDGWTServiceException("Error in SDMXExport: " + e.getLocalizedMessage());
+ }
+
+ }
+
+
@Override
public String startSDMXTemplateExport(SDMXTemplateExportSession sdmxTemplateExportSession)
throws TDGWTServiceException {
diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/opexecution/OpExecution4ExcelDatasetExport.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/opexecution/OpExecution4ExcelDatasetExport.java
new file mode 100644
index 0000000..289613d
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/opexecution/OpExecution4ExcelDatasetExport.java
@@ -0,0 +1,63 @@
+package org.gcube.portlets.user.td.gwtservice.server.opexecution;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationDefinition;
+import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationExecution;
+import org.gcube.data.analysis.tabulardata.service.TabularDataService;
+import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationDefinitionMap;
+import org.gcube.portlets.user.td.gwtservice.server.util.ServiceCredentials;
+import org.gcube.portlets.user.td.gwtservice.shared.Constants;
+import org.gcube.portlets.user.td.gwtservice.shared.excel.ExcelExportSession;
+import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
+import org.gcube.portlets.user.td.widgetcommonevent.shared.operations.OperationsId;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Operation Execution for sdmx Dataset export
+ *
+ * @author Giancarlo Panichi
+ *
+ *
+ */
+public class OpExecution4ExcelDatasetExport extends OpExecutionBuilder {
+ private static Logger logger = LoggerFactory.getLogger(OpExecution4ExcelDatasetExport.class);
+
+ @SuppressWarnings("unused")
+ private HttpServletRequest httpRequest;
+ @SuppressWarnings("unused")
+ private ServiceCredentials serviceCredentials;
+ private TabularDataService service;
+ private ExcelExportSession excelExportSession;
+
+ public OpExecution4ExcelDatasetExport(HttpServletRequest httpRequest, ServiceCredentials serviceCredentials,
+ TabularDataService service, ExcelExportSession excelExportSession) {
+ this.service = service;
+ this.excelExportSession = excelExportSession;
+ this.httpRequest=httpRequest;
+ this.serviceCredentials=serviceCredentials;
+ }
+
+ @Override
+ public void buildOpEx() throws TDGWTServiceException {
+ logger.debug(excelExportSession.toString());
+
+
+ OperationDefinition operationDefinition = OperationDefinitionMap.map(OperationsId.ExcelDatasetExport.toString(),
+ service);
+
+ Map map = new HashMap();
+ map.put(Constants.PARAMETER_ID, excelExportSession.getId());
+ map.put(Constants.PARAMETER_AGENCY, excelExportSession.getAgencyId());
+ map.put(Constants.PARAMETER_VERSION, excelExportSession.getVersion());
+ map.put(Constants.PARAMETER_OBSVALUECOLUMN, excelExportSession.getObsValueColumn().getColumnId());
+ OperationExecution invocation = new OperationExecution(operationDefinition.getOperationId(), map);
+
+ operationExecutionSpec.setOp(invocation);
+ }
+
+}
diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/Constants.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/Constants.java
index aaa1fa4..74e321c 100644
--- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/Constants.java
+++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/Constants.java
@@ -40,6 +40,10 @@ public class Constants {
public static final String SDMX_TEMPLATE_EXPORT_DEFAULT_ID = "NEW_DSD_DIVISION_TEMPLATE";
public static final String SDMX_TEMPLATE_EXPORT_DEFAULT_AGENCY_ID = "SDMX";
public static final String SDMX_TEMPLATE_EXPORT_DEFAULT_VERSION = "1.0";
+
+ public static final String EXCEL_DATASET_EXPORT_DEFAULT_ID = "NEW_DS_DIVISION";
+ public static final String EXCEL_DATASET_EXPORT_DEFAULT_AGENCY_ID = "EXCEL";
+ public static final String EXCEL_DATASET_EXPORT_DEFAULT_VERSION = "1.0";
public static final String PARAMETER_ENCODING = "encoding";
public static final String PARAMETER_HASHEADER = "hasHeader";
diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/excel/ExcelExportSession.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/excel/ExcelExportSession.java
new file mode 100644
index 0000000..de2ece6
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/excel/ExcelExportSession.java
@@ -0,0 +1,88 @@
+/**
+ *
+ */
+package org.gcube.portlets.user.td.gwtservice.shared.excel;
+
+import java.io.Serializable;
+
+import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
+import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.TableType;
+import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnData;
+
+/**
+ *
+ * @author Giancarlo Panichi
+ *
+ *
+ */
+public class ExcelExportSession implements Serializable {
+
+ private static final long serialVersionUID = 4176034045408445284L;
+
+ private TabResource tabResource;
+ private TableType exportType;
+
+ private String id;
+ private String agencyId;
+ private String version;
+
+ private ColumnData obsValueColumn;
+
+ public TabResource getTabResource() {
+ return tabResource;
+
+ }
+
+ public void setTabResource(TabResource tabResource) {
+ this.tabResource = tabResource;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getAgencyId() {
+ return agencyId;
+ }
+
+ public void setAgencyId(String agencyId) {
+ this.agencyId = agencyId;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public TableType getExportType() {
+ return exportType;
+ }
+
+ public void setExportType(TableType exportType) {
+ this.exportType = exportType;
+ }
+
+ public ColumnData getObsValueColumn() {
+ return obsValueColumn;
+ }
+
+ public void setObsValueColumn(ColumnData obsValueColumn) {
+ this.obsValueColumn = obsValueColumn;
+ }
+
+ @Override
+ public String toString() {
+ return "ExcelExportSession [tabResource=" + tabResource + ", exportType=" + exportType + ", id=" + id
+ + ", agencyId=" + agencyId + ", version=" + version + ", obsValueColumn=" + obsValueColumn + "]";
+ }
+
+
+
+}