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
This commit is contained in:
Giancarlo Panichi 2013-11-19 14:17:31 +00:00
parent 6a7bec4949
commit 620976a5db
2 changed files with 39 additions and 34 deletions

View File

@ -8,6 +8,7 @@ import java.nio.charset.Charset;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; 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.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.data.analysis.tabulardata.metadata.NoSuchMetadataException; 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.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.Table;
import org.gcube.data.analysis.tabulardata.model.table.TableId; import org.gcube.data.analysis.tabulardata.model.table.TableId;
import org.gcube.data.analysis.tabulardata.operation.worker.ActivityStatus; import org.gcube.data.analysis.tabulardata.operation.worker.ActivityStatus;
@ -151,54 +153,50 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
+ e.getLocalizedMessage()); + e.getLocalizedMessage());
} }
} }
@Override @Override
public TableData getLastTable(TRId trId) throws TDGWTServiceException { public TableData getLastTable(TRId trId) throws TDGWTServiceException {
try { try {
session = this.getThreadLocalRequest().getSession(); session = this.getThreadLocalRequest().getSession();
aslSession = SessionUtil.getAslSession(session); aslSession = SessionUtil.getAslSession(session);
service = TabularDataServiceFactory.getService(aslSession service = TabularDataServiceFactory.getService(aslSession
.getUsername()); .getUsername());
long id=Long.valueOf(trId.getId()); Table table = service.getLastTable(new TabularResourceId(Long
.valueOf(trId.getId())));
TabularResourceId tabularResourceId=new TabularResourceId(id);
Table table = service.getLastTable(tabularResourceId); TableData tData = new TableData();
TableData tData=new TableData();
trId.setTableId(String.valueOf(table.getId().getValue())); trId.setTableId(String.valueOf(table.getId().getValue()));
tData.setTrId(trId); tData.setTrId(trId);
tData.setName(table.getName()); tData.setName(table.getName());
tData.setTypeName(table.getTableType().getName()); tData.setTypeName(table.getTableType().getName());
tData.setTypeCode(table.getTableType().getCode()); tData.setTypeCode(table.getTableType().getCode());
Collection<TableMetadata> cMeta=table.getAllMetadata();
ArrayList<ColumnData> lColumnData=new ArrayList<ColumnData>(); tData.setMetaData(cMeta.toString());
for(Column column:table.getColumns()){
ColumnData colData=new ColumnData();
ArrayList<ColumnData> lColumnData = new ArrayList<ColumnData>();
for (Column column : table.getColumns()) {
ColumnData colData = new ColumnData();
colData.setName(column.getName()); colData.setName(column.getName());
colData.setTypeName(column.getColumnType().getName()); colData.setTypeName(column.getColumnType().getName());
colData.setTypeCode(column.getColumnType().getCode()); colData.setTypeCode(column.getColumnType().getCode());
lColumnData.add(colData); lColumnData.add(colData);
}; }
tData.setListColumnData(lColumnData); tData.setListColumnData(lColumnData);
return tData; return tData;
} catch (Exception e) { } catch (Exception e) {
logger.error( logger.error("Error in getLastTable(): " + e.getLocalizedMessage(),
"Error in getLastTable(): " e);
+ e.getLocalizedMessage(), e); throw new TDGWTServiceException("Error in getLastTable(): "
throw new TDGWTServiceException( + e.getLocalizedMessage());
"Error in getLastTable(): "
+ e.getLocalizedMessage());
} }
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
@ -1070,17 +1068,16 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
"Error retrieving the item on workspace" "Error retrieving the item on workspace"
+ csvImportSession.getItemId()); + csvImportSession.getItemId());
} }
try { 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) { } catch (InternalErrorException e1) {
e1.printStackTrace(); e1.printStackTrace();
throw new TDGWTServiceException( throw new TDGWTServiceException(
"Error retrieving the item on workspace" "Error retrieving the item on workspace" + wi);
+ wi);
} }
FileUploadSession fileUploadSession = new FileUploadSession(); FileUploadSession fileUploadSession = new FileUploadSession();
CSVImportMonitor csvImportMonitor = new CSVImportMonitor(); CSVImportMonitor csvImportMonitor = new CSVImportMonitor();
FileUploadMonitor fileUploadMonitor = new FileUploadMonitor(); FileUploadMonitor fileUploadMonitor = new FileUploadMonitor();

View File

@ -17,6 +17,8 @@ public class TableData implements Serializable {
protected String name; protected String name;
protected String typeName; protected String typeName;
protected String typeCode; protected String typeCode;
protected String metaData;
protected ArrayList<ColumnData> listColumnData; protected ArrayList<ColumnData> listColumnData;
protected TRId trId; protected TRId trId;
@ -51,13 +53,19 @@ public class TableData implements Serializable {
public void setTrId(TRId trId) { public void setTrId(TRId trId) {
this.trId = trId; this.trId = trId;
} }
public String getMetaData() {
return metaData;
}
public void setMetaData(String metaData) {
this.metaData = metaData;
}
@Override @Override
public String toString() { public String toString() {
return "TableData [name=" + name + ", typeName=" return "TableData [name=" + name + ", typeName=" + typeName
+ typeName + ", typeCode=" + typeCode + ", lColumnData=" + ", typeCode=" + typeCode + ", metaData=" + metaData
+ listColumnData + ", trId=" + trId + "]"; + ", listColumnData=" + listColumnData + ", trId=" + trId + "]";
} }