From 620976a5db3d6a8ad502cf4f9690c2fbf928576f Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Tue, 19 Nov 2013 14:17:31 +0000 Subject: [PATCH] Minor updated git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@85694 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../gwtservice/server/TDGWTServiceImpl.java | 57 +++++++++---------- .../user/td/gwtservice/shared/TableData.java | 16 ++++-- 2 files changed, 39 insertions(+), 34 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 2a9dd8b..f087b3c 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 @@ -8,6 +8,7 @@ import java.nio.charset.Charset; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; +import java.util.Collection; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -25,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.metadata.table.TableMetadata; import org.gcube.data.analysis.tabulardata.model.table.Table; import org.gcube.data.analysis.tabulardata.model.table.TableId; import org.gcube.data.analysis.tabulardata.operation.worker.ActivityStatus; @@ -151,54 +153,50 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements + e.getLocalizedMessage()); } } - - - - + @Override public TableData getLastTable(TRId trId) throws TDGWTServiceException { try { session = this.getThreadLocalRequest().getSession(); aslSession = SessionUtil.getAslSession(session); - + service = TabularDataServiceFactory.getService(aslSession .getUsername()); - - long id=Long.valueOf(trId.getId()); - - TabularResourceId tabularResourceId=new TabularResourceId(id); - Table table = service.getLastTable(tabularResourceId); - - TableData tData=new TableData(); + + Table table = service.getLastTable(new TabularResourceId(Long + .valueOf(trId.getId()))); + + TableData tData = new TableData(); trId.setTableId(String.valueOf(table.getId().getValue())); tData.setTrId(trId); tData.setName(table.getName()); tData.setTypeName(table.getTableType().getName()); tData.setTypeCode(table.getTableType().getCode()); + Collection cMeta=table.getAllMetadata(); - ArrayList lColumnData=new ArrayList(); - for(Column column:table.getColumns()){ - ColumnData colData=new ColumnData(); + tData.setMetaData(cMeta.toString()); + + + ArrayList lColumnData = new ArrayList(); + for (Column column : table.getColumns()) { + ColumnData colData = new ColumnData(); colData.setName(column.getName()); colData.setTypeName(column.getColumnType().getName()); colData.setTypeCode(column.getColumnType().getCode()); lColumnData.add(colData); - }; - + } + tData.setListColumnData(lColumnData); return tData; } catch (Exception e) { - logger.error( - "Error in getLastTable(): " - + e.getLocalizedMessage(), e); - throw new TDGWTServiceException( - "Error in getLastTable(): " - + e.getLocalizedMessage()); + logger.error("Error in getLastTable(): " + e.getLocalizedMessage(), + e); + throw new TDGWTServiceException("Error in getLastTable(): " + + e.getLocalizedMessage()); } } - /** * {@inheritDoc} @@ -1070,17 +1068,16 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements "Error retrieving the item on workspace" + csvImportSession.getItemId()); } - + try { - logger.debug("WorkspaceItem [id:"+wi.getId()+" name:"+wi.getName()+" remotePath:"+wi.getRemotePath()+"]"); + logger.debug("WorkspaceItem [id:" + wi.getId() + " name:" + + wi.getName() + " remotePath:" + wi.getRemotePath() + "]"); } catch (InternalErrorException e1) { e1.printStackTrace(); throw new TDGWTServiceException( - "Error retrieving the item on workspace" - + wi); + "Error retrieving the item on workspace" + wi); } - - + FileUploadSession fileUploadSession = new FileUploadSession(); CSVImportMonitor csvImportMonitor = new CSVImportMonitor(); FileUploadMonitor fileUploadMonitor = new FileUploadMonitor(); diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/TableData.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/TableData.java index 993d50a..1e079fd 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/TableData.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/TableData.java @@ -17,6 +17,8 @@ public class TableData implements Serializable { protected String name; protected String typeName; protected String typeCode; + protected String metaData; + protected ArrayList listColumnData; protected TRId trId; @@ -51,13 +53,19 @@ public class TableData implements Serializable { public void setTrId(TRId trId) { this.trId = trId; } + public String getMetaData() { + return metaData; + } + public void setMetaData(String metaData) { + this.metaData = metaData; + } @Override public String toString() { - return "TableData [name=" + name + ", typeName=" - + typeName + ", typeCode=" + typeCode + ", lColumnData=" - + listColumnData + ", trId=" + trId + "]"; + return "TableData [name=" + name + ", typeName=" + typeName + + ", typeCode=" + typeCode + ", metaData=" + metaData + + ", listColumnData=" + listColumnData + ", trId=" + trId + "]"; } - +