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
This commit is contained in:
Giancarlo Panichi 2013-11-29 14:10:00 +00:00
parent 6bb10a74c8
commit d3345caa7a
1 changed files with 59 additions and 26 deletions

View File

@ -26,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.column.type.IdColumnType;
import org.gcube.data.analysis.tabulardata.model.metadata.common.DescriptionsMetadata; 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.LocalizedText;
import org.gcube.data.analysis.tabulardata.model.metadata.common.NamesMetadata; 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.DescriptionMetadata;
import org.gcube.data.analysis.tabulardata.service.tabular.metadata.NameMetadata; 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.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.SDMXRegistryDescriptor;
import org.gcube.datapublishing.sdmx.api.model.SDMXRegistryInterfaceType; import org.gcube.datapublishing.sdmx.api.model.SDMXRegistryInterfaceType;
import org.gcube.datapublishing.sdmx.impl.model.GCubeSDMXRegistryDescriptor; 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.Agencies;
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Codelist; import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Codelist;
import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Dataset; import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Dataset;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -192,7 +195,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throw new TDGWTServiceException( throw new TDGWTServiceException(
"CURRENT_TABULAR_RESOURCE is null"); "CURRENT_TABULAR_RESOURCE is null");
} }
TRId trId=currentTR.getTrId(); TRId trId = currentTR.getTrId();
service = TabularDataServiceFactory.getService(aslSession service = TabularDataServiceFactory.getService(aslSession
.getUsername()); .getUsername());
@ -200,19 +203,23 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Table table = service.getLastTable(new TabularResourceId(Long Table table = service.getLastTable(new TabularResourceId(Long
.valueOf(trId.getId()))); .valueOf(trId.getId())));
ArrayList<ColumnData> columns=new ArrayList<ColumnData>(); ArrayList<ColumnData> columns = new ArrayList<ColumnData>();
List<Column> cols=table.getColumns(); List<Column> cols = table.getColumns();
int i=0; int i = 0;
for(Column c: cols){ for (Column c : cols) {
ColumnData cData=new ColumnData(); if (c.getColumnType() instanceof IdColumnType ) {
cData.setId(i);
cData.setName(c.getName()); } else {
cData.setTypeCode(c.getColumnType().getCode()); ColumnData cData = new ColumnData();
cData.setTypeName(c.getColumnType().getName()); cData.setId(i);
cData.setTrId(trId); cData.setName(c.getName());
columns.add(cData); cData.setTypeCode(c.getColumnType().getCode());
i++; cData.setTypeName(c.getColumnType().getName());
cData.setTrId(trId);
columns.add(cData);
i++;
}
} }
return columns; return columns;
@ -227,7 +234,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
} }
} }
/** /**
* *
* {@inheritDoc} * {@inheritDoc}
@ -1084,8 +1090,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
if (task.getResult() != null) { if (task.getResult() != null) {
logger.debug("Task exception:" logger.debug("Task exception:"
+ task.getErrorCause()); + task.getErrorCause());
importMonitor.setError(task importMonitor.setError(task.getErrorCause());
.getErrorCause());
} else { } else {
logger.debug("Task exception: Error In Import"); logger.debug("Task exception: Error In Import");
importMonitor.setError(new Throwable( importMonitor.setError(new Throwable(
@ -1220,6 +1225,37 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
SessionUtil.setFileUploadSession(session, fileUploadSession); SessionUtil.setFileUploadSession(session, fileUploadSession);
} }
/**
*
* {@inheritDoc}
*/
// TODO
public ArrayList<TRMetadata> 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<TabularResourceMetadata> cMeta = tr.getAllMetadata();
ArrayList<TRMetadata> listTRMetadata = new ArrayList<TRMetadata>();
return listTRMetadata;
} catch (Exception e) {
logger.error(
"Error in getTRMetadata(): " + e.getLocalizedMessage(), e);
throw new TDGWTServiceException("Error in getTableMetadata(): "
+ e.getLocalizedMessage());
}
}
/** /**
* *
* {@inheritDoc} * {@inheritDoc}
@ -1233,7 +1269,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
service = TabularDataServiceFactory.getService(aslSession service = TabularDataServiceFactory.getService(aslSession
.getUsername()); .getUsername());
Table table = service.getTable(new TableId(Long.valueOf(trId Table table = service.getTable(new TableId(Long.valueOf(trId
.getTableId()))); .getTableId())));
@ -1465,8 +1500,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
if (task.getResult() != null) { if (task.getResult() != null) {
logger.debug("Task exception:" logger.debug("Task exception:"
+ task.getErrorCause()); + task.getErrorCause());
exportMonitor.setError(task exportMonitor.setError(task.getErrorCause());
.getErrorCause());
} else { } else {
logger.debug("Task exception: Error In Export"); logger.debug("Task exception: Error In Export");
exportMonitor.setError(new Throwable( exportMonitor.setError(new Throwable(
@ -1509,7 +1543,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
SessionUtil.setCSVExportFileTask(session, task); SessionUtil.setCSVExportFileTask(session, task);
} }
logger.info("getExportMonitor(): " + exportMonitor); logger.info("getExportMonitor(): " + exportMonitor);
return exportMonitor; return exportMonitor;
} catch (Exception e) { } catch (Exception e) {