Minor Update

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@98898 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-07-23 11:02:42 +00:00
parent 12d0370514
commit 2ca920e938
1 changed files with 85 additions and 6 deletions

View File

@ -13,10 +13,12 @@ import org.gcube.data.analysis.tabulardata.commons.webservice.types.TaskStatus;
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationDefinition;
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationExecution;
import org.gcube.data.analysis.tabulardata.expression.Expression;
import org.gcube.data.analysis.tabulardata.model.metadata.table.DatasetViewTableMetadata;
import org.gcube.data.analysis.tabulardata.model.table.Table;
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
import org.gcube.data.analysis.tabulardata.service.impl.TabularDataServiceFactory;
import org.gcube.data.analysis.tabulardata.service.operation.Task;
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource;
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResourceId;
import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionService;
import org.gcube.portlets.user.td.expressionwidget.shared.exception.ExpressionServiceException;
@ -142,6 +144,7 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
if (task.getResult() != null) {
logger.debug("Task exception:"
+ task.getErrorCause());
task.getErrorCause().printStackTrace();
columnFilterMonitor.setError(new Throwable(task
.getErrorCause()));
} else {
@ -157,12 +160,11 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
Table table = task.getResult().getPrimaryTable();
logger.debug("Table retrived: " + table.toString());
TRId trId = new TRId();
logger.debug("ColumnFilterSession TRId: "+columnFilterSession.getColumn().getTrId());
trId.setId(columnFilterSession.getColumn().getTrId()
.getId());
trId.setTableId(String
.valueOf(table.getId().getValue()));
trId.setTableType(table.getTableType().getName());
trId = retrieveTabularResourceBasicData(trId);
columnFilterMonitor.setTrId(trId);
TabResource tabResource = SessionUtil
.getTabResource(session);
@ -181,8 +183,18 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
case ABORTED:
break;
case STOPPED:
columnFilterMonitor.setError(new Throwable(
"Operation Stopped on service"));
logger.debug("Task Result:" + task.getResult());
columnFilterMonitor.setProgress(task.getProgress());
trId = new TRId();
trId.setId(columnFilterSession.getColumn().getTrId()
.getId());
trId = retrieveTabularResourceBasicData(trId);
columnFilterMonitor.setTrId(trId);
tabResource = SessionUtil.getTabResource(session);
tabResource.setTrId(trId);
SessionUtil.setTabResource(session, tabResource);
SessionUtil.setTRId(session, trId);
break;
case INITIALIZING:
break;
@ -205,5 +217,72 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
}
}
/**
* Retrieve and set Tabular Resource Type
*
* @param trId
* @return
* @throws TDGWTServiceException
*/
protected TRId retrieveTabularResourceBasicData(TRId trId)
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session);
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
TabularResourceId tabularResourceId = new TabularResourceId(
new Long(trId.getId()));
TabularResource tr = service.getTabularResource(tabularResourceId);
Table table = service.getLastTable(tabularResourceId);
Table viewTable = null;
if (table.contains(DatasetViewTableMetadata.class)) {
DatasetViewTableMetadata dwm = table
.getMetadata(DatasetViewTableMetadata.class);
try {
viewTable = service.getTable(dwm
.getTargetDatasetViewTableId());
} catch (Exception e) {
logger.error("view table not found");
}
}
TRId newTRId;
if (viewTable == null) {
newTRId = new TRId(String.valueOf(tr.getId().getValue()),
tr.getTableType(), String.valueOf(table.getId()
.getValue()), table.getTableType().getName());
} else {
newTRId = new TRId(String.valueOf(tr.getId().getValue()),
tr.getTableType(), String.valueOf(viewTable.getId()
.getValue()), viewTable.getTableType()
.getName(), String.valueOf(table.getId()
.getValue()), true);
}
logger.debug("Retrieved TRId basic info:" + newTRId.toString());
return newTRId;
} catch (TDGWTSessionExpiredException e) {
throw e;
} catch (SecurityException e) {
e.printStackTrace();
throw new TDGWTServiceException(
"Security exception, you haven't rights!");
} catch (Throwable e) {
e.printStackTrace();
throw new TDGWTServiceException("Error in Client Library Request: "
+ e.getLocalizedMessage());
}
}
}