Minor updated

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@86488 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2013-12-03 12:03:44 +00:00
parent 00fb558156
commit fcd3b8f9f8
1 changed files with 83 additions and 35 deletions

View File

@ -172,6 +172,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
"CURRENT_TABULAR_RESOURCE is null");
}
ArrayList<TRMetadata> trMetadatas = getTRMetadata(currentTR
.getTrId());
updateTabResourceInformation(currentTR, trMetadatas);
SessionUtil.setTabResource(session, currentTR);
return currentTR;
} catch (Exception e) {
@ -184,6 +188,41 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
protected void updateTabResourceInformation(TabResource tabResource,
ArrayList<TRMetadata> trMetadatas) {
for (TRMetadata trMetadata : trMetadatas) {
if (trMetadata instanceof TRDescriptionMetadata) {
tabResource.setDescription(((TRDescriptionMetadata) trMetadata)
.getValue());
} else {
if (trMetadata instanceof TRNameMetadata) {
tabResource.setName(((TRNameMetadata) trMetadata)
.getValue());
} else {
if (trMetadata instanceof TRAgencyMetadata) {
tabResource.setAgency(((TRAgencyMetadata) trMetadata)
.getValue());
} else {
if (trMetadata instanceof TRCreationDateMetadata) {
tabResource
.setDate(((TRCreationDateMetadata) trMetadata)
.getDate());
} else {
if (trMetadata instanceof TRRightsMetadata) {
tabResource
.setDate(((TRRightsMetadata) trMetadata)
.getValue());
} else {
}
}
}
}
}
}
}
/**
*
* {@inheritDoc}
@ -490,8 +529,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
*/
@Override
public void removeTabularResource(TRId trId)
throws TDGWTServiceException {
public void removeTabularResource(TRId trId) throws TDGWTServiceException {
try {
session = this.getThreadLocalRequest().getSession();
aslSession = SessionUtil.getAslSession(session);
@ -503,8 +541,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
service = TabularDataServiceFactory.getService(aslSession
.getUsername());
TabularResourceId id = new TabularResourceId(
Long.valueOf(trId.getId()));
TabularResourceId id = new TabularResourceId(Long.valueOf(trId
.getId()));
service.removeTabularResource(id);
return;
} catch (Exception e) {
@ -772,8 +810,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(
@ -1120,8 +1157,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(
@ -1280,29 +1316,38 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
for (TabularResourceMetadata trMetadata : trMetas) {
if (trMetadata instanceof org.gcube.data.analysis.tabulardata.service.tabular.metadata.DescriptionMetadata) {
TRDescriptionMetadata trDescriptionMetadata = new TRDescriptionMetadata();
trDescriptionMetadata.setValue(((org.gcube.data.analysis.tabulardata.service.tabular.metadata.DescriptionMetadata) trMetadata)
trDescriptionMetadata
.setValue(((org.gcube.data.analysis.tabulardata.service.tabular.metadata.DescriptionMetadata) trMetadata)
.getValue());
listTRMetadata.add(trDescriptionMetadata);
} else {
if (trMetadata instanceof org.gcube.data.analysis.tabulardata.service.tabular.metadata.NameMetadata) {
TRNameMetadata trNameMetadata = new TRNameMetadata();
trNameMetadata.setValue(((org.gcube.data.analysis.tabulardata.service.tabular.metadata.NameMetadata)trMetadata).getValue());
trNameMetadata
.setValue(((org.gcube.data.analysis.tabulardata.service.tabular.metadata.NameMetadata) trMetadata)
.getValue());
listTRMetadata.add(trNameMetadata);
} else {
if (trMetadata instanceof AgencyMetadata) {
TRAgencyMetadata trAgencyMetadata = new TRAgencyMetadata();
trAgencyMetadata.setValue(((AgencyMetadata)trMetadata).getValue());
trAgencyMetadata
.setValue(((AgencyMetadata) trMetadata)
.getValue());
listTRMetadata.add(trAgencyMetadata);
} else {
if (trMetadata instanceof CreationDateMetadata) {
TRCreationDateMetadata trCreationDateMetadata = new TRCreationDateMetadata();
trCreationDateMetadata.setDate(sdf
.format(((CreationDateMetadata)trMetadata).getValue()));
trCreationDateMetadata
.setDate(sdf
.format(((CreationDateMetadata) trMetadata)
.getValue()));
listTRMetadata.add(trCreationDateMetadata);
} else {
if (trMetadata instanceof RightsMetadata) {
TRRightsMetadata trRightsMetadata = new TRRightsMetadata();
trRightsMetadata.setValue(((RightsMetadata)trMetadata).getValue());
trRightsMetadata
.setValue(((RightsMetadata) trMetadata)
.getValue());
listTRMetadata.add(trRightsMetadata);
} else {
@ -1456,7 +1501,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
parameterInstances.put(Constants.ENCODING, exportSession.getEncoding());
parameterInstances.put(Constants.SEPARATOR,
exportSession.getSeparator());
parameterInstances.put(Constants.COLUMNS, exportSession.getColumnsAsString());
parameterInstances.put(Constants.COLUMNS,
exportSession.getColumnsAsString());
return parameterInstances;
}
@ -1493,7 +1539,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throw new TDGWTServiceException("Error no table present in session");
}
SessionUtil.setCSVExportSession(session,exportSession);
SessionUtil.setCSVExportSession(session, exportSession);
Map<String, Object> parameterInstance = csvExportFileParameter(exportSession);
@ -1538,7 +1584,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
try {
session = this.getThreadLocalRequest().getSession();
aslSession = SessionUtil.getAslSession(session);
CSVExportSession exportSession= SessionUtil.getCSVExportSession(session);
CSVExportSession exportSession = SessionUtil
.getCSVExportSession(session);
Task task = SessionUtil.getCSVExportTask(session);
CSVExportMonitor exportMonitor = new CSVExportMonitor();
@ -1586,9 +1633,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
.format(exportMetadata.getExportDate()));
exportMonitor.setTrExportMetadata(trExportMetadata);
saveInDestination(aslSession.getUsername(),exportMetadata,exportSession);
saveInDestination(aslSession.getUsername(),
exportMetadata, exportSession);
break;
case IN_PROGRESS:
@ -1619,13 +1665,15 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
protected void saveInDestination(String user, ExportMetadata exportMetadata,CSVExportSession exportSession)
protected void saveInDestination(String user,
ExportMetadata exportMetadata, CSVExportSession exportSession)
throws TDGWTServiceException {
if(exportSession.getDestination().getId().compareTo("Workspace")==0){
FilesStorage storage=new FilesStorage();
storage.createItemOnWorkspace(exportMetadata.getUri(),user,
exportSession.getFileName(), exportSession.getFileDescription(),
"text/csv", exportSession.getItemId());
if (exportSession.getDestination().getId().compareTo("Workspace") == 0) {
FilesStorage storage = new FilesStorage();
storage.createItemOnWorkspace(exportMetadata.getUri(), user,
exportSession.getFileName(),
exportSession.getFileDescription(), "text/csv",
exportSession.getItemId());
} else {
}