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:
parent
00fb558156
commit
fcd3b8f9f8
|
@ -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}
|
||||
|
@ -488,10 +527,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
* @param tabResource
|
||||
* @throws TDGWTServiceException
|
||||
*/
|
||||
|
||||
|
||||
@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,32 +1316,41 @@ 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)
|
||||
.getValue());
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1492,8 +1538,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
if (trId.getTableId() == null) {
|
||||
throw new TDGWTServiceException("Error no table present in session");
|
||||
}
|
||||
|
||||
SessionUtil.setCSVExportSession(session,exportSession);
|
||||
|
||||
SessionUtil.setCSVExportSession(session, exportSession);
|
||||
|
||||
Map<String, Object> parameterInstance = csvExportFileParameter(exportSession);
|
||||
|
||||
|
@ -1538,10 +1584,11 @@ 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();
|
||||
|
||||
|
||||
if (task == null) {
|
||||
logger.debug("Task null");
|
||||
throw new TDGWTServiceException("Error in exportCSV task null");
|
||||
|
@ -1585,11 +1632,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
trExportMetadata.setExportDate(sdf
|
||||
.format(exportMetadata.getExportDate()));
|
||||
exportMonitor.setTrExportMetadata(trExportMetadata);
|
||||
|
||||
saveInDestination(aslSession.getUsername(),exportMetadata,exportSession);
|
||||
|
||||
|
||||
|
||||
|
||||
saveInDestination(aslSession.getUsername(),
|
||||
exportMetadata, exportSession);
|
||||
|
||||
break;
|
||||
case IN_PROGRESS:
|
||||
exportMonitor.setProgress(task.getProgress());
|
||||
|
@ -1618,16 +1664,18 @@ 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 {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue