Fixed empty tabular resource

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@84973 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2013-11-05 14:37:54 +00:00
parent 21e1407a6d
commit 11883b48d9
1 changed files with 54 additions and 27 deletions

View File

@ -23,6 +23,8 @@ import org.gcube.data.analysis.tabulardata.operation.worker.EligibleOperation;
import org.gcube.data.analysis.tabulardata.operation.worker.JobResult;
import org.gcube.data.analysis.tabulardata.operation.worker.OperationInvocation;
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
import org.gcube.data.analysis.tabulardata.service.exception.InvalidTabularResourceException;
import org.gcube.data.analysis.tabulardata.service.exception.NoSuchTabularResourceException;
import org.gcube.data.analysis.tabulardata.service.impl.TabularDataServiceFactory;
import org.gcube.data.analysis.tabulardata.service.operation.OperationInterface;
import org.gcube.data.analysis.tabulardata.service.operation.Task;
@ -58,6 +60,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
/**
@ -79,10 +82,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
protected ASLSession aslSession;
/**
*
*
* {@inheritDoc}
*/
@Override
*/
@Override
public void setTabResource(TabResource tabResource)
throws TDGWTServiceException {
try {
@ -134,9 +137,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
+ e.getLocalizedMessage());
}
}
/**
* {@inheritDoc}
* {@inheritDoc}
*/
@Override
public void setTDOpenSession(TDOpenSession s) throws TDGWTServiceException {
@ -187,10 +190,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
/**
* Retrieves the informations for a specific Tabular Resource from service
*
* @param tr TabularResource on service
* @param i Index on Grid
* @return TabResource for Grid
* @throws TDGWTServiceException
* @param tr
* TabularResource on service
* @param i
* Index on Grid
* @return TabResource for Grid
* @throws TDGWTServiceException
*/
protected TabResource retriveTRMetadataFromService(TabularResource tr, int i)
throws TDGWTServiceException {
@ -237,10 +242,31 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
dateS = sdf.format(dateTR);
}
TableId tableId = tr.getHistory().get(tr.getHistory().size() - 1)
.getResultTable().getId();
TRId trId = new TRId(String.valueOf(tr.getId().getValue()),
String.valueOf(tableId.getValue()));
Table table = null;
try {
table = service.getLastTable(tr.getId());
} catch (NoSuchTabularResourceException e) {
e.printStackTrace();
} catch (InvalidTabularResourceException e) {
e.printStackTrace();
}
TableId tableId = null;
if (table == null) {
Log.info("Tabular resource "+tr.getId()+" has no table.");
} else {
tableId = table.getId();
}
TRId trId = null;
if (tableId == null) {
Log.info("Tabular Resource "+tr.getId()+" has last table with id null.");
} else {
trId = new TRId(String.valueOf(tr.getId().getValue()),
String.valueOf(tableId.getValue()));
}
TabResource t = new TabResource(i, nameTR, descriptionTR, agencyTR,
dateS, rightsTR, trId);
return t;
@ -268,7 +294,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
for (i = 0; i < trs.size(); i++) {
TabularResource tr = trs.get(i);
TabResource t = retriveTRMetadataFromService(tr, i);
ltr.add(t);
if (t.getTrId() != null) {
ltr.add(t);
}
}
logger.debug("Tabular Resources retrived: " + ltr);
@ -423,8 +451,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
* {@inheritDoc}
*/
@Override
public void startSDMXImport(
SDMXImportSession sdmxImportSession) throws TDGWTServiceException {
public void startSDMXImport(SDMXImportSession sdmxImportSession)
throws TDGWTServiceException {
try {
session = this.getThreadLocalRequest().getSession();
@ -572,9 +600,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
/**
* {@inheritDoc}
* {@inheritDoc}
*/
@Override
public void setSDMXSession(SDMXImportSession sdmxImportSession)
@ -596,7 +624,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
/**
* {@inheritDoc}
* {@inheritDoc}
*/
@Override
public void setCSVSession(CSVImportSession importSession)
@ -618,7 +646,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
/**
* {@inheritDoc}
* {@inheritDoc}
*/
@Override
public FileUploadMonitor getFileUploadMonitor()
@ -638,9 +666,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
return fileUploadSession.getFileUploadMonitor();
}
/**
* {@inheritDoc}
* {@inheritDoc}
*/
@Override
public AvailableCharsetList getAvailableCharset()
@ -730,9 +757,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
/**
* {@inheritDoc}
* {@inheritDoc}
*/
@Override
public void startCSVImport(CSVImportSession csvImportSession)
@ -762,7 +789,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
importCSVFileOnService(user, fileUploadSession, csvImportSession);
}
/**
*
* @param fileUrlOnStorage
@ -791,7 +818,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
parameterInstances.put(HASHEADER, hasHeader);// true
return parameterInstances;
}
/**
*
* @param user
@ -839,7 +866,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
SessionUtil.setCSVImportFileTask(session, trTask);
}
/**
* {@inheritDoc}
*/