ref 8781:TDM - Integration excel generator-tabman portlet

https://support.d4science.org/issues/8781

Added excel to template

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@150509 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-06-23 16:58:01 +00:00
parent 296f8deb2c
commit 840e07ee3a
10 changed files with 185 additions and 72 deletions

View File

@ -102,6 +102,7 @@ public class OpExecution4SDMXDatasetExport extends OpExecutionBuilder {
map.put(Constants.PARAMETER_ID, sdmxExportSession.getId());
map.put(Constants.PARAMETER_VERSION, sdmxExportSession.getVersion());
map.put(Constants.PARAMETER_OBSVALUECOLUMN, sdmxExportSession.getObsValueColumn().getColumnId());
map.put(Constants.PARAMETER_EXCEL, sdmxExportSession.isExcel());
OperationExecution invocation = new OperationExecution(
operationDefinition.getOperationId(), map);

View File

@ -8,9 +8,11 @@ import org.gcube.data.analysis.tabulardata.commons.webservice.types.resources.Re
import org.gcube.data.analysis.tabulardata.model.resources.InternalURI;
import org.gcube.data.analysis.tabulardata.model.resources.Resource;
import org.gcube.data.analysis.tabulardata.model.resources.ResourceType;
import org.gcube.data.analysis.tabulardata.model.resources.SDMXResource;
import org.gcube.data.analysis.tabulardata.model.resources.StringResource;
import org.gcube.data.analysis.tabulardata.model.resources.TableResource;
import org.gcube.data.analysis.tabulardata.model.resources.Thumbnail;
import org.gcube.data.analysis.tabulardata.model.resources.WebResource;
import org.gcube.portlets.user.td.gwtservice.server.uriresolver.UriResolverTDClient;
import org.gcube.portlets.user.td.gwtservice.server.util.ServiceCredentials;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
@ -18,8 +20,10 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.InternalURITD;
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTD;
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDDescriptor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDType;
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.SDMXResourceTD;
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.StringResourceTD;
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.TableResourceTD;
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.WebResourceTD;
import org.gcube.portlets.user.td.gwtservice.shared.uriresolver.UriResolverSession;
import org.gcube.portlets.user.td.widgetcommonevent.shared.thumbnail.ThumbnailTD;
import org.gcube.portlets.user.td.widgetcommonevent.shared.uriresolver.ApplicationType;
@ -33,11 +37,9 @@ import org.slf4j.LoggerFactory;
*
*/
public class ResourceTDCreator {
private static Logger logger = LoggerFactory
.getLogger(ResourceTDCreator.class);
private static Logger logger = LoggerFactory.getLogger(ResourceTDCreator.class);
protected static SimpleDateFormat sdf = new SimpleDateFormat(
"yyyy-MM-dd HH:mm");
protected static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
private ServiceCredentials serviceCredentials;
@ -45,9 +47,8 @@ public class ResourceTDCreator {
this.serviceCredentials = serviceCredentials;
}
public ArrayList<ResourceTDDescriptor> createResourcesDescriptorTD(
List<ResourceDescriptor> resources) throws TDGWTServiceException {
public ArrayList<ResourceTDDescriptor> createResourcesDescriptorTD(List<ResourceDescriptor> resources)
throws TDGWTServiceException {
ArrayList<ResourceTDDescriptor> resourcesTD = new ArrayList<ResourceTDDescriptor>();
for (ResourceDescriptor resourceDescriptor : resources) {
@ -60,31 +61,24 @@ public class ResourceTDCreator {
Resource resource = resourceDescriptor.getResource();
if (resource != null) {
ResourceTD resourceTD = createResourceTD(resource);
ResourceType resourceType = resourceDescriptor
.getResourceType();
ResourceTDType resourceTDType = ResourceTypeMap
.getResourceTDType(resourceType);
ResourceType resourceType = resourceDescriptor.getResourceType();
ResourceTDType resourceTDType = ResourceTypeMap.getResourceTDType(resourceType);
String creationDate = null;
try {
creationDate = sdf.format(resourceDescriptor
.getCreationDate().getTime());
creationDate = sdf.format(resourceDescriptor.getCreationDate().getTime());
} catch (Throwable e) {
logger.error("ResourceDescription[id=" + id + ", name="
+ name + ", description=" + description
+ ", creatorId=" + creatorId
+ "] has invalid creation date!");
logger.error("ResourceDescription[id=" + id + ", name=" + name + ", description=" + description
+ ", creatorId=" + creatorId + "] has invalid creation date!");
}
resourceTDDescriptor = new ResourceTDDescriptor(id, name,
description, creationDate, creatorId, resourceTDType,
resourceTD);
resourceTDDescriptor = new ResourceTDDescriptor(id, name, description, creationDate, creatorId,
resourceTDType, resourceTD);
resourcesTD.add(resourceTDDescriptor);
} else {
logger.error("ResourceDescription[id=" + id + ", name=" + name
+ ", description=" + description + ", creatorId="
+ creatorId + "] has resource null!");
logger.error("ResourceDescription[id=" + id + ", name=" + name + ", description=" + description
+ ", creatorId=" + creatorId + "] has resource null!");
}
}
@ -93,9 +87,7 @@ public class ResourceTDCreator {
return resourcesTD;
}
protected ResourceTD createResourceTD(Resource resource)
throws TDGWTServiceException {
protected ResourceTD createResourceTD(Resource resource) throws TDGWTServiceException {
ResourceTD resourceTD = null;
Class<? extends Resource> resourceClass = resource.getResourceType();
@ -108,11 +100,9 @@ public class ResourceTDCreator {
ThumbnailTD thumbnailTD = null;
if (thumbnail != null && thumbnail.getUri() != null) {
UriResolverTDClient uriResolverTDClient = new UriResolverTDClient();
UriResolverSession uriResolverSession = new UriResolverSession(
thumbnail.getUri().toString(), ApplicationType.SMP_ID,
"resourcethumbnail.jpg", thumbnail.getMimeType());
String link = uriResolverTDClient.resolve(uriResolverSession,
serviceCredentials);
UriResolverSession uriResolverSession = new UriResolverSession(thumbnail.getUri().toString(),
ApplicationType.SMP_ID, "resourcethumbnail.jpg", thumbnail.getMimeType());
String link = uriResolverTDClient.resolve(uriResolverSession, serviceCredentials);
thumbnailTD = new ThumbnailTD(link, thumbnail.getMimeType());
}
@ -124,10 +114,24 @@ public class ResourceTDCreator {
} else {
if (resourceClass == TableResource.class) {
TableResource tableResource = (TableResource) resource;
return new TableResourceTD(tableResource.getTableId()
.getValue(), tableResource.getStringValue());
return new TableResourceTD(tableResource.getTableId().getValue(), tableResource.getStringValue());
} else {
if (resourceClass == SDMXResource.class) {
SDMXResource sdmxResource = (SDMXResource) resource;
SDMXResourceTD sdmxResourceTD = new SDMXResourceTD(sdmxResource.getName(),
sdmxResource.getAgency(), sdmxResource.getPrimaryMeasure(),
sdmxResource.getStringValue(), sdmxResource.getType().name(),
sdmxResource.getVersion());
return sdmxResourceTD;
} else {
if (resourceClass == WebResource.class) {
WebResource webResource = (WebResource) resource;
WebResourceTD webResourceTD = new WebResourceTD(webResource.getStringValue());
return webResourceTD;
} else {
}
}
}
}
}

View File

@ -10,9 +10,10 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDType;
*
*/
public class ResourceTypeMap {
//private static Logger logger = LoggerFactory.getLogger(ResourceTypeMap.class);
// private static Logger logger =
// LoggerFactory.getLogger(ResourceTypeMap.class);
public static ResourceType getResourceType(ResourceTDType resourceTDType){
public static ResourceType getResourceType(ResourceTDType resourceTDType) {
switch (resourceTDType) {
case CHART:
return ResourceType.CHART;
@ -28,6 +29,8 @@ public class ResourceTypeMap {
return ResourceType.MAP;
case SDMX:
return ResourceType.SDMX;
case WEB:
return ResourceType.WEB;
case GENERIC_FILE:
return ResourceType.GENERIC_FILE;
case GENERIC_TABLE:
@ -36,8 +39,8 @@ public class ResourceTypeMap {
return null;
}
}
public static ResourceTDType getResourceTDType(ResourceType resourceType){
public static ResourceTDType getResourceTDType(ResourceType resourceType) {
switch (resourceType) {
case CHART:
return ResourceTDType.CHART;
@ -53,17 +56,16 @@ public class ResourceTypeMap {
return ResourceTDType.MAP;
case SDMX:
return ResourceTDType.SDMX;
case WEB:
return ResourceTDType.WEB;
case GENERIC_FILE:
return ResourceTDType.GENERIC_FILE;
case GENERIC_TABLE:
return ResourceTDType.GENERIC_TABLE;
default:
return null;
}
}
}

View File

@ -32,6 +32,7 @@ public class SDMXExportSession implements Serializable {
private String registryBaseUrl;
private ColumnData obsValueColumn;
private boolean excel;
public TabResource getTabResource() {
return tabResource;
@ -106,14 +107,20 @@ public class SDMXExportSession implements Serializable {
this.obsValueColumn = obsValueColumn;
}
@Override
public String toString() {
return "SDMXExportSession [tabResource=" + tabResource + ", agency="
+ agency + ", source=" + source + ", exportType=" + exportType
+ ", id=" + id + ", agencyName=" + agencyId + ", version="
+ version + ", registryBaseUrl=" + registryBaseUrl
+ ", obsValueColumn=" + obsValueColumn + "]";
public boolean isExcel() {
return excel;
}
public void setExcel(boolean excel) {
this.excel = excel;
}
@Override
public String toString() {
return "SDMXExportSession [tabResource=" + tabResource + ", agency=" + agency + ", source=" + source
+ ", exportType=" + exportType + ", id=" + id + ", agencyId=" + agencyId + ", version=" + version
+ ", registryBaseUrl=" + registryBaseUrl + ", obsValueColumn=" + obsValueColumn + ", excel=" + excel
+ "]";
}
}

View File

@ -12,9 +12,7 @@ public class InternalURITD extends ResourceTD {
private static final long serialVersionUID = -3230438212164027113L;
private String id;
private String mimeType;
private ThumbnailTD thumbnailTD;
public InternalURITD() {
@ -28,11 +26,6 @@ public class InternalURITD extends ResourceTD {
this.thumbnailTD = thumbnailTD;
}
@Override
public String getStringValue() {
return id;
}
public String getId() {
return id;
}
@ -59,7 +52,8 @@ public class InternalURITD extends ResourceTD {
@Override
public String toString() {
return "InternalURITD [id=" + id + ", mimeType=" + mimeType + ", thumbnailTD=" + thumbnailTD + "]";
return "InternalURITD [id=" + id + ", mimeType=" + mimeType + ", thumbnailTD=" + thumbnailTD
+ ", getStringValue()=" + getStringValue() + "]";
}
}

View File

@ -8,7 +8,7 @@ package org.gcube.portlets.user.td.gwtservice.shared.tr.resources;
*/
public enum ResourceTDType {
CHART("Chart"), GUESSER("Guesser"), MAP("Map"), CODELIST("Codelist"), CSV("CSV"), SDMX("SDMX"), JSON(
CHART("Chart"), GUESSER("Guesser"), MAP("Map"), CODELIST("Codelist"), CSV("CSV"), SDMX("SDMX"), WEB("WEB"), JSON(
"JSON"), GENERIC_FILE("Generic File"), GENERIC_TABLE("Generic Table");
private ResourceTDType(final String id) {

View File

@ -0,0 +1,80 @@
package org.gcube.portlets.user.td.gwtservice.shared.tr.resources;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class SDMXResourceTD extends ResourceTD {
private static final long serialVersionUID = -3075957767979840537L;
private String name;
private String agency;
private String primaryMeasure;
private String type;
private String version;
public SDMXResourceTD() {
super();
}
public SDMXResourceTD(String name, String agency, String primaryMeasure, String stringValue, String type, String version) {
super(stringValue);
this.name =name;
this.agency = agency;
this.primaryMeasure = primaryMeasure;
this.type=type;
this.version=version;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAgency() {
return agency;
}
public void setAgency(String agency) {
this.agency = agency;
}
public String getPrimaryMeasure() {
return primaryMeasure;
}
public void setPrimaryMeasure(String primaryMeasure) {
this.primaryMeasure = primaryMeasure;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
@Override
public String toString() {
return "SDMXResourceTD [name=" + name + ", agency=" + agency + ", primaryMeasure=" + primaryMeasure + ", type="
+ type + ", version=" + version + ", getStringValue()=" + getStringValue() + "]";
}
}

View File

@ -22,11 +22,6 @@ public class StringResourceTD extends ResourceTD {
}
@Override
public String getStringValue() {
return value;
}
public String getValue() {
return value;
}
@ -37,7 +32,7 @@ public class StringResourceTD extends ResourceTD {
@Override
public String toString() {
return "StringResourceTD [value=" + value + "]";
return "StringResourceTD [value=" + value + ", getStringValue()=" + getStringValue() + "]";
}
}

View File

@ -10,7 +10,6 @@ public class TableResourceTD extends ResourceTD {
private static final long serialVersionUID = -3230438212164027113L;
private long tableId;
private String tableStringValue;
public TableResourceTD() {
super();
@ -19,15 +18,9 @@ public class TableResourceTD extends ResourceTD {
public TableResourceTD(long tableId, String tableStringValue) {
super(tableStringValue);
this.tableId = tableId;
this.tableStringValue = tableStringValue;
}
@Override
public String getStringValue() {
return tableStringValue;
}
public long getTableId() {
return tableId;
}
@ -38,7 +31,7 @@ public class TableResourceTD extends ResourceTD {
@Override
public String toString() {
return "TableResourceTD [tableId=" + tableId + ", tableStringValue=" + tableStringValue + "]";
return "TableResourceTD [tableId=" + tableId + ", getStringValue()=" + getStringValue() + "]";
}
}

View File

@ -0,0 +1,37 @@
package org.gcube.portlets.user.td.gwtservice.shared.tr.resources;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class WebResourceTD extends ResourceTD {
private static final long serialVersionUID = 8895032679636897620L;
private String value;
public WebResourceTD() {
super();
}
public WebResourceTD(String value) {
super(value);
this.value = value;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Override
public String toString() {
return "WebResourceTD [value=" + value + ", getStringValue()=" + getStringValue() + "]";
}
}