From d3345caa7aada2f368d66108586795f311b42b9d Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Fri, 29 Nov 2013 14:10:00 +0000 Subject: [PATCH] Minor updated git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@86364 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../gwtservice/server/TDGWTServiceImpl.java | 85 +++++++++++++------ 1 file changed, 59 insertions(+), 26 deletions(-) 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 d546c05..d18571d 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 @@ -26,6 +26,7 @@ import org.gcube.common.homelibrary.home.workspace.Workspace; import org.gcube.common.homelibrary.home.workspace.WorkspaceItem; import org.gcube.data.analysis.tabulardata.metadata.NoSuchMetadataException; import org.gcube.data.analysis.tabulardata.model.column.Column; +import org.gcube.data.analysis.tabulardata.model.column.type.IdColumnType; import org.gcube.data.analysis.tabulardata.model.metadata.common.DescriptionsMetadata; import org.gcube.data.analysis.tabulardata.model.metadata.common.LocalizedText; import org.gcube.data.analysis.tabulardata.model.metadata.common.NamesMetadata; @@ -55,6 +56,7 @@ import org.gcube.data.analysis.tabulardata.service.tabular.metadata.CreationDate import org.gcube.data.analysis.tabulardata.service.tabular.metadata.DescriptionMetadata; import org.gcube.data.analysis.tabulardata.service.tabular.metadata.NameMetadata; import org.gcube.data.analysis.tabulardata.service.tabular.metadata.RightsMetadata; +import org.gcube.data.analysis.tabulardata.service.tabular.metadata.TabularResourceMetadata; import org.gcube.datapublishing.sdmx.api.model.SDMXRegistryDescriptor; import org.gcube.datapublishing.sdmx.api.model.SDMXRegistryInterfaceType; import org.gcube.datapublishing.sdmx.impl.model.GCubeSDMXRegistryDescriptor; @@ -95,6 +97,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.open.TDOpenSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Agencies; import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Codelist; import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Dataset; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -177,7 +180,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements } /** - * + * * {@inheritDoc} */ @Override @@ -192,29 +195,33 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements throw new TDGWTServiceException( "CURRENT_TABULAR_RESOURCE is null"); } - TRId trId=currentTR.getTrId(); + TRId trId = currentTR.getTrId(); service = TabularDataServiceFactory.getService(aslSession .getUsername()); Table table = service.getLastTable(new TabularResourceId(Long .valueOf(trId.getId()))); - - ArrayList columns=new ArrayList(); - - List cols=table.getColumns(); - int i=0; - for(Column c: cols){ - ColumnData cData=new ColumnData(); - cData.setId(i); - cData.setName(c.getName()); - cData.setTypeCode(c.getColumnType().getCode()); - cData.setTypeName(c.getColumnType().getName()); - cData.setTrId(trId); - columns.add(cData); - i++; + + ArrayList columns = new ArrayList(); + + List cols = table.getColumns(); + int i = 0; + for (Column c : cols) { + if (c.getColumnType() instanceof IdColumnType ) { + + } else { + ColumnData cData = new ColumnData(); + cData.setId(i); + cData.setName(c.getName()); + cData.setTypeCode(c.getColumnType().getCode()); + cData.setTypeName(c.getColumnType().getName()); + cData.setTrId(trId); + columns.add(cData); + i++; + } } - + return columns; } catch (Exception e) { @@ -226,10 +233,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements + e.getLocalizedMessage()); } } - - + /** - * + * * {@inheritDoc} */ @Override @@ -1084,8 +1090,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements if (task.getResult() != null) { logger.debug("Task exception:" + task.getErrorCause()); - importMonitor.setError(task - .getErrorCause()); + importMonitor.setError(task.getErrorCause()); } else { logger.debug("Task exception: Error In Import"); importMonitor.setError(new Throwable( @@ -1220,6 +1225,37 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements SessionUtil.setFileUploadSession(session, fileUploadSession); } + /** + * + * {@inheritDoc} + */ + // TODO + public ArrayList getTRMetadata(TRId trId) + throws TDGWTServiceException { + try { + session = this.getThreadLocalRequest().getSession(); + aslSession = SessionUtil.getAslSession(session); + + service = TabularDataServiceFactory.getService(aslSession + .getUsername()); + TabularResource tr = service + .getTabularResource(new TabularResourceId(Long.valueOf(trId + .getId()))); + + Collection cMeta = tr.getAllMetadata(); + + ArrayList listTRMetadata = new ArrayList(); + + return listTRMetadata; + + } catch (Exception e) { + logger.error( + "Error in getTRMetadata(): " + e.getLocalizedMessage(), e); + throw new TDGWTServiceException("Error in getTableMetadata(): " + + e.getLocalizedMessage()); + } + } + /** * * {@inheritDoc} @@ -1233,7 +1269,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements service = TabularDataServiceFactory.getService(aslSession .getUsername()); - Table table = service.getTable(new TableId(Long.valueOf(trId .getTableId()))); @@ -1465,8 +1500,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements if (task.getResult() != null) { logger.debug("Task exception:" + task.getErrorCause()); - exportMonitor.setError(task - .getErrorCause()); + exportMonitor.setError(task.getErrorCause()); } else { logger.debug("Task exception: Error In Export"); exportMonitor.setError(new Throwable( @@ -1509,7 +1543,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements SessionUtil.setCSVExportFileTask(session, task); } - logger.info("getExportMonitor(): " + exportMonitor); return exportMonitor; } catch (Exception e) {