Minor Updated
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@91838 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
d56bc3f6f3
commit
e7ce4065f3
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.portlets.user.td.expressionwidget.server;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -12,10 +13,12 @@ import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationToken;
|
|||
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.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.TabularResourceId;
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionService;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.expression.ExpressionServiceException;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.session.ColumnFilterMonitor;
|
||||
|
@ -24,6 +27,8 @@ import org.gcube.portlets.user.td.gwtservice.server.SessionUtil;
|
|||
import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationDefinitionMap;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationsId;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.trservice.TaskStateMap;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -34,7 +39,6 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
|||
public class ExpressionServiceImpl extends RemoteServiceServlet implements
|
||||
ExpressionService {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 4632292751581364137L;
|
||||
|
||||
protected static Logger logger = LoggerFactory
|
||||
|
@ -42,8 +46,31 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
protected static SimpleDateFormat sdf = new SimpleDateFormat(
|
||||
"yyyy/MM/dd HH:mm");
|
||||
|
||||
|
||||
|
||||
protected OperationExecution retrieveOperationExecution(
|
||||
TabularDataService service, ColumnFilterSession columnFilterSession)
|
||||
throws TDGWTServiceException {
|
||||
|
||||
OperationExecution invocation = null;
|
||||
List<OperationDefinition> capabilities = service.getCapabilities();
|
||||
|
||||
OperationDefinition operationDefinition;
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
C_ExpressionParser parser=new C_ExpressionParser();
|
||||
Expression exp=parser.parse(columnFilterSession.getCexpression());
|
||||
|
||||
map.put(Constants.PARAMETER_EXPRESSION, exp);
|
||||
|
||||
operationDefinition = OperationDefinitionMap.map(
|
||||
OperationsId.FilterByExpression.toString(), capabilities);
|
||||
|
||||
invocation = new OperationExecution(columnFilterSession.getColumn()
|
||||
.getColumnId(), operationDefinition.getOperationId(), map);
|
||||
|
||||
return invocation;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
|
@ -51,38 +78,29 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
|
|||
@Override
|
||||
public void submitColumnFilter(ColumnFilterSession columnFilterSession)
|
||||
throws ExpressionServiceException {
|
||||
|
||||
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername()));
|
||||
|
||||
logger.debug(columnFilterSession.toString());
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
OperationExecution invocation = retrieveOperationExecution(service,
|
||||
columnFilterSession);
|
||||
|
||||
List<OperationDefinition> capabilities = service.getCapabilities();
|
||||
|
||||
OperationDefinition operation = OperationDefinitionMap.map(
|
||||
OperationsId.FilterByExpression.toString(), capabilities);
|
||||
|
||||
|
||||
Map<String, Object> parameterInstance = null;//retrieveOperationParameters(sdmxImportSession);
|
||||
|
||||
OperationExecution invocation = new OperationExecution(
|
||||
operation.getOperationId(),
|
||||
parameterInstance);
|
||||
|
||||
|
||||
logger.debug("OperationInvocation: \n" + invocation.toString());
|
||||
//Task trTask = service.execute(invocation, serviceTR.getId());
|
||||
//logger.debug("Start Task on service: TaskId " + trTask.getId());
|
||||
//SessionUtil.setSDMXImportTask(session, trTask);
|
||||
TabularResourceId id=new TabularResourceId(Long.valueOf(columnFilterSession.getColumn().getTrId().getId()));
|
||||
Task trTask = service.execute(invocation,id);
|
||||
logger.debug("Start Task on service: TaskId " + trTask.getId());
|
||||
ExpressionSession.setColumnFilterTask(session, trTask);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ExpressionServiceException("Error in Client Library Request: "
|
||||
+ e.getLocalizedMessage());
|
||||
throw new ExpressionServiceException(
|
||||
"Error in Client Library Request: "
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,8 +152,8 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
|
|||
Table table = task.getResult().getPrimaryTable();
|
||||
logger.debug("Table retrived: " + table.toString());
|
||||
TRId trId = new TRId();
|
||||
trId.setId(columnFilterSession.getColumn()
|
||||
.getTrId().getId());
|
||||
trId.setId(columnFilterSession.getColumn().getTrId()
|
||||
.getId());
|
||||
trId.setTableId(String
|
||||
.valueOf(table.getId().getValue()));
|
||||
trId.setTableType(table.getTableType().getName());
|
||||
|
@ -171,14 +189,11 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
|
|||
return columnFilterMonitor;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ExpressionServiceException("Error applying column filter: "
|
||||
+ e.getLocalizedMessage());
|
||||
throw new ExpressionServiceException(
|
||||
"Error applying column filter: " + e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue