ref #9944: TabMan - Enable Excel export operation for DataSet only
https://support.d4science.org/issues/#9944 Added operation git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@162129 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
4067beae1b
commit
0320dd2597
|
@ -1,12 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/tabular-data-gwt-service-2.19.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<classpathentry kind="src" output="target/tabular-data-gwt-service-2.20.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/tabular-data-gwt-service-2.19.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||
<classpathentry excluding="**" kind="src" output="target/tabular-data-gwt-service-2.20.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
|
@ -33,5 +33,5 @@
|
|||
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/tabular-data-gwt-service-2.19.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
<classpathentry kind="output" path="target/tabular-data-gwt-service-2.20.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
<ReleaseNotes>
|
||||
<Changeset component="org.gcube.portlets-user.tabular-data-gwt-service.2-20-0"
|
||||
date="2018-01-12">
|
||||
<Change>Added Excel Dataset Export support [ticket #9944]</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.portlets-user.tabular-data-gwt-service.2-19-0"
|
||||
date="2017-12-13">
|
||||
<Change>Enable SDMX export operation for DataSet only for the tables
|
||||
already shared with the whole VRE [ticket #10586]</Change>
|
||||
already shared with the whole VRE [ticket #10586]
|
||||
</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.portlets-user.tabular-data-gwt-service.2-18-0"
|
||||
date="2017-07-01">
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -14,7 +14,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>tabular-data-gwt-service</artifactId>
|
||||
<version>2.19.0-SNAPSHOT</version>
|
||||
<version>2.20.0-SNAPSHOT</version>
|
||||
|
||||
<name>tabular-data-gwt-service</name>
|
||||
<description>tabular-data-gwt-service allows communication between the GUI and services</description>
|
||||
|
|
|
@ -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
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -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<String> callback);
|
||||
|
||||
// Export EXCEL
|
||||
void startExcelExport(ExcelExportSession exportSession, AsyncCallback<String> callback);
|
||||
|
||||
// Export Template SDMX
|
||||
void startSDMXTemplateExport(SDMXTemplateExportSession sdmxTemplateExportSession, AsyncCallback<String> callback);
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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<ExcelExportSession> sessionOp = new SessionOp<>();
|
||||
sessionOp.set(httpRequest, serviceCredentials, SessionConstants.EXCEL_EXPORT_SESSION, excelExportSession);
|
||||
}
|
||||
|
||||
public static ExcelExportSession getExcelExportSession(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials) {
|
||||
SessionOp<ExcelExportSession> 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) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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<String, Object> map = new HashMap<String, Object>();
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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";
|
||||
|
|
|
@ -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 + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue