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-gwt-service@142035 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ea37378b80
commit
cf0dc3ec40
3
pom.xml
3
pom.xml
|
@ -200,9 +200,6 @@
|
|||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Storage -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
|
|
|
@ -139,6 +139,7 @@ import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4Repl
|
|||
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4ReplaceColumnByExpression;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4SDMXCodelistExport;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4SDMXCodelistImport;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4SDMXDatasetExport;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4SplitColumn;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4StatisticalOperation;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4TimeAggregation;
|
||||
|
@ -5132,6 +5133,13 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
"Error no table present in session");
|
||||
}
|
||||
|
||||
if (exportSession == null) {
|
||||
logger.error("Error in SDMX Export: exportSession is null!");
|
||||
throw new TDGWTServiceException(
|
||||
"Error in SDMX Export: exportSession is null!!");
|
||||
|
||||
}
|
||||
|
||||
SessionUtil.setSDMXExportSession(httpRequest, serviceCredentials,
|
||||
exportSession);
|
||||
|
||||
|
@ -5151,11 +5159,26 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
checkTabularResourceLocked(tabularResource, httpRequest,
|
||||
serviceCredentials);
|
||||
|
||||
// /
|
||||
OpExecution4SDMXCodelistExport opEx = new OpExecution4SDMXCodelistExport(
|
||||
service, exportSession);
|
||||
OpExecutionDirector director = new OpExecutionDirector();
|
||||
director.setOperationExecutionBuilder(opEx);
|
||||
// /
|
||||
switch (exportSession.getExportType()) {
|
||||
case CODELIST:
|
||||
OpExecution4SDMXCodelistExport opExC = new OpExecution4SDMXCodelistExport(
|
||||
service, exportSession);
|
||||
director.setOperationExecutionBuilder(opExC);
|
||||
break;
|
||||
case DATASET:
|
||||
OpExecution4SDMXDatasetExport opExD = new OpExecution4SDMXDatasetExport(
|
||||
service, exportSession);
|
||||
director.setOperationExecutionBuilder(opExD);
|
||||
break;
|
||||
case GENERIC:
|
||||
default:
|
||||
logger.error("Error in SDMX Export: Only Codelist and Dataset are supported!");
|
||||
throw new TDGWTServiceException(
|
||||
"Error in SDMXExport: Only Codelist and Dataset are supported!");
|
||||
}
|
||||
|
||||
director.constructOperationExecution();
|
||||
OperationExecution invocation = director.getOperationExecution();
|
||||
|
||||
|
|
|
@ -98,9 +98,9 @@ public class OpExecution4SDMXCodelistExport extends OpExecutionBuilder {
|
|||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
map.put(Constants.PARAMETER_REGISTRYBASEURL, destination);
|
||||
map.put(Constants.PARAMETER_AGENCY, "SDMX");
|
||||
map.put(Constants.PARAMETER_ID, "NEW_CL_DIVISION");
|
||||
map.put(Constants.PARAMETER_VERSION, "2.0");
|
||||
map.put(Constants.PARAMETER_AGENCY, sdmxExportSession.getAgencyName());
|
||||
map.put(Constants.PARAMETER_ID, sdmxExportSession.getId());
|
||||
map.put(Constants.PARAMETER_VERSION, sdmxExportSession.getVersion());
|
||||
|
||||
OperationExecution invocation = new OperationExecution(
|
||||
operationDefinition.getOperationId(), map);
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
package org.gcube.portlets.user.td.gwtservice.server.opexecution;
|
||||
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint.Profile;
|
||||
import org.gcube.common.resources.gcore.utils.Group;
|
||||
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.shared.Constants;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.operations.OperationsId;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Operation Execution for sdmx Dataset export
|
||||
*
|
||||
* @author "Giancarlo Panichi" email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class OpExecution4SDMXDatasetExport extends OpExecutionBuilder {
|
||||
private static Logger logger = LoggerFactory
|
||||
.getLogger(OpExecution4SDMXDatasetExport.class);
|
||||
|
||||
private TabularDataService service;
|
||||
private SDMXExportSession sdmxExportSession;
|
||||
|
||||
public OpExecution4SDMXDatasetExport(TabularDataService service,
|
||||
SDMXExportSession sdmxExportSession) {
|
||||
this.service = service;
|
||||
this.sdmxExportSession = sdmxExportSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildOpEx() throws TDGWTServiceException {
|
||||
logger.debug(sdmxExportSession.toString());
|
||||
boolean internalRegistry = false;
|
||||
String destination = null;// Es:
|
||||
// http://pc-fortunati.isti.cnr.it:8080/FusionRegistry/ws/rest/
|
||||
|
||||
if (sdmxExportSession != null) {
|
||||
if (sdmxExportSession.getRegistryBaseUrl() != null
|
||||
&& !sdmxExportSession.getRegistryBaseUrl().isEmpty()) {
|
||||
destination = sdmxExportSession.getRegistryBaseUrl();
|
||||
} else {
|
||||
internalRegistry = true;
|
||||
}
|
||||
} else {
|
||||
internalRegistry = true;
|
||||
}
|
||||
|
||||
if (internalRegistry) {
|
||||
SimpleQuery query = queryFor(ServiceEndpoint.class);
|
||||
query.addCondition("$resource/Profile/Category/text() eq 'SDMX'")
|
||||
.addCondition(
|
||||
"$resource/Profile/Name/text() eq 'SDMXRegistry'");
|
||||
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
|
||||
List<ServiceEndpoint> listService = client.submit(query);
|
||||
if (listService.size() > 0) {
|
||||
ServiceEndpoint serviceEnd = listService.get(0);
|
||||
if (serviceEnd != null) {
|
||||
Profile prof = serviceEnd.profile();
|
||||
Group<AccessPoint> groupA = prof.accessPoints();
|
||||
for (AccessPoint acc : groupA) {
|
||||
if (acc.description().compareTo("REST Interface v2.1") == 0) {
|
||||
destination = acc.address();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
if (destination == null) {
|
||||
logger.debug("Destination: " + destination);
|
||||
throw new TDGWTServiceException("SDMX Service not discovered");
|
||||
}
|
||||
|
||||
OperationDefinition operationDefinition = OperationDefinitionMap.map(
|
||||
OperationsId.SDMXDatasetExport.toString(), service);
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
map.put(Constants.PARAMETER_REGISTRYBASEURL, destination);
|
||||
map.put(Constants.PARAMETER_AGENCY, sdmxExportSession.getAgencyName());
|
||||
map.put(Constants.PARAMETER_ID, sdmxExportSession.getId());
|
||||
map.put(Constants.PARAMETER_VERSION, sdmxExportSession.getVersion());
|
||||
map.put(Constants.PARAMETER_OBSVALUECOLUMN, sdmxExportSession.getObsValueColumn().getColumnId());
|
||||
OperationExecution invocation = new OperationExecution(
|
||||
operationDefinition.getOperationId(), map);
|
||||
|
||||
operationExecutionSpec.setOp(invocation);
|
||||
}
|
||||
|
||||
}
|
|
@ -29,7 +29,15 @@ public class Constants {
|
|||
|
||||
public final static String FILE_XML_MIMETYPE = "application/xml";
|
||||
public final static String FILE_CSV_MIMETYPE = "text/csv";
|
||||
|
||||
|
||||
public static final String SDMX_CODELIST_EXPORT_DEFAULT_ID = "NEW_CL_DIVISION";
|
||||
public static final String SDMX_CODELIST_EXPORT_DEFAULT_AGENCY = "SDMX";
|
||||
public static final String SDMX_CODELIST_EXPORT_DEFAULT_VERSION = "2.0";
|
||||
|
||||
public static final String SDMX_DATASET_EXPORT_DEFAULT_ID = "NEW_DS_DIVISION";
|
||||
public static final String SDMX_DATASET_EXPORT_DEFAULT_AGENCY = "SDMX";
|
||||
public static final String SDMX_DATASET_EXPORT_DEFAULT_VERSION = "1.0";
|
||||
|
||||
public static final String PARAMETER_ENCODING = "encoding";
|
||||
public static final String PARAMETER_HASHEADER = "hasHeader";
|
||||
public static final String PARAMETER_FIELDMASK = "fieldMask";
|
||||
|
@ -43,6 +51,7 @@ public class Constants {
|
|||
public static final String PARAMETER_REGISTRYBASEURL = "registryBaseUrl";
|
||||
public static final String PARAMETER_AGENCY = "agency";
|
||||
public static final String PARAMETER_VERSION = "version";
|
||||
public static final String PARAMETER_OBSVALUECOLUMN = "obsValueColumn";
|
||||
|
||||
public static final String PARAMETER_DATA_TYPE = "dataType";
|
||||
public static final String PARAMETER_TARGET_DATA_TYPE = "targetDataType";
|
||||
|
|
|
@ -8,79 +8,112 @@ import java.io.Serializable;
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.source.Source;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Agencies;
|
||||
|
||||
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.TableType;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnData;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class SDMXExportSession implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 4176034045408445284L;
|
||||
|
||||
protected TabResource tabResource;
|
||||
protected Agencies agency;
|
||||
protected Source source;
|
||||
|
||||
protected String id;
|
||||
protected String agencyName;
|
||||
protected String version;
|
||||
protected String registryBaseUrl;
|
||||
|
||||
private TabResource tabResource;
|
||||
private Agencies agency;
|
||||
private Source source;
|
||||
private TableType exportType;
|
||||
|
||||
private String id;
|
||||
private String agencyName;
|
||||
private String version;
|
||||
private String registryBaseUrl;
|
||||
|
||||
private ColumnData obsValueColumn;
|
||||
|
||||
public TabResource getTabResource() {
|
||||
return tabResource;
|
||||
|
||||
}
|
||||
|
||||
public void setTabResource(TabResource tabResource) {
|
||||
this.tabResource = tabResource;
|
||||
}
|
||||
|
||||
public Agencies getAgency() {
|
||||
return agency;
|
||||
}
|
||||
|
||||
public void setAgency(Agencies agency) {
|
||||
this.agency = agency;
|
||||
}
|
||||
|
||||
public Source getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public void setSource(Source source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAgencyName() {
|
||||
return agencyName;
|
||||
}
|
||||
|
||||
public void setAgencyName(String agencyName) {
|
||||
this.agencyName = agencyName;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getRegistryBaseUrl() {
|
||||
return registryBaseUrl;
|
||||
}
|
||||
|
||||
public void setRegistryBaseUrl(String registryBaseUrl) {
|
||||
this.registryBaseUrl = registryBaseUrl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
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 "SDMXExportSession [tabResource=" + tabResource + ", agency="
|
||||
+ agency + ", source=" + source + ", id=" + id
|
||||
+ ", agencyName=" + agencyName + ", version=" + version
|
||||
+ ", registryBaseUrl=" + registryBaseUrl + "]";
|
||||
+ agency + ", source=" + source + ", exportType=" + exportType
|
||||
+ ", id=" + id + ", agencyName=" + agencyName + ", version="
|
||||
+ version + ", registryBaseUrl=" + registryBaseUrl
|
||||
+ ", obsValueColumn=" + obsValueColumn + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -15,10 +15,10 @@ public class Agencies implements Serializable {
|
|||
|
||||
private static final long serialVersionUID = -8353499109124097114L;
|
||||
|
||||
protected String id;
|
||||
protected String name;
|
||||
protected String description;
|
||||
protected String nameLabel;
|
||||
private String id;
|
||||
private String name;
|
||||
private String description;
|
||||
private String nameLabel;
|
||||
|
||||
|
||||
public Agencies(){}
|
||||
|
|
Loading…
Reference in New Issue