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;
|
package org.gcube.portlets.user.td.expressionwidget.server;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
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.TaskStatus;
|
||||||
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationDefinition;
|
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.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.model.table.Table;
|
||||||
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
|
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
|
||||||
import org.gcube.data.analysis.tabulardata.service.impl.TabularDataServiceFactory;
|
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.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.client.rpc.ExpressionService;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.expression.ExpressionServiceException;
|
import org.gcube.portlets.user.td.expressionwidget.shared.expression.ExpressionServiceException;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.session.ColumnFilterMonitor;
|
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.OperationDefinitionMap;
|
||||||
import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationsId;
|
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.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.gwtservice.shared.tr.TabResource;
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -34,7 +39,6 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||||
public class ExpressionServiceImpl extends RemoteServiceServlet implements
|
public class ExpressionServiceImpl extends RemoteServiceServlet implements
|
||||||
ExpressionService {
|
ExpressionService {
|
||||||
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 4632292751581364137L;
|
private static final long serialVersionUID = 4632292751581364137L;
|
||||||
|
|
||||||
protected static Logger logger = LoggerFactory
|
protected static Logger logger = LoggerFactory
|
||||||
|
@ -43,6 +47,29 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
|
||||||
protected static SimpleDateFormat sdf = new SimpleDateFormat(
|
protected static SimpleDateFormat sdf = new SimpleDateFormat(
|
||||||
"yyyy/MM/dd HH:mm");
|
"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;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -54,34 +81,25 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
|
||||||
|
|
||||||
try {
|
try {
|
||||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||||
|
|
||||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||||
|
|
||||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||||
aslSession.getUsername()));
|
aslSession.getUsername()));
|
||||||
|
|
||||||
|
logger.debug(columnFilterSession.toString());
|
||||||
TabularDataService service = TabularDataServiceFactory.getService();
|
TabularDataService service = TabularDataServiceFactory.getService();
|
||||||
|
OperationExecution invocation = retrieveOperationExecution(service,
|
||||||
List<OperationDefinition> capabilities = service.getCapabilities();
|
columnFilterSession);
|
||||||
|
|
||||||
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());
|
logger.debug("OperationInvocation: \n" + invocation.toString());
|
||||||
//Task trTask = service.execute(invocation, serviceTR.getId());
|
TabularResourceId id=new TabularResourceId(Long.valueOf(columnFilterSession.getColumn().getTrId().getId()));
|
||||||
//logger.debug("Start Task on service: TaskId " + trTask.getId());
|
Task trTask = service.execute(invocation,id);
|
||||||
//SessionUtil.setSDMXImportTask(session, trTask);
|
logger.debug("Start Task on service: TaskId " + trTask.getId());
|
||||||
|
ExpressionSession.setColumnFilterTask(session, trTask);
|
||||||
return;
|
return;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new ExpressionServiceException("Error in Client Library Request: "
|
throw new ExpressionServiceException(
|
||||||
|
"Error in Client Library Request: "
|
||||||
+ e.getLocalizedMessage());
|
+ e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,8 +152,8 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
|
||||||
Table table = task.getResult().getPrimaryTable();
|
Table table = task.getResult().getPrimaryTable();
|
||||||
logger.debug("Table retrived: " + table.toString());
|
logger.debug("Table retrived: " + table.toString());
|
||||||
TRId trId = new TRId();
|
TRId trId = new TRId();
|
||||||
trId.setId(columnFilterSession.getColumn()
|
trId.setId(columnFilterSession.getColumn().getTrId()
|
||||||
.getTrId().getId());
|
.getId());
|
||||||
trId.setTableId(String
|
trId.setTableId(String
|
||||||
.valueOf(table.getId().getValue()));
|
.valueOf(table.getId().getValue()));
|
||||||
trId.setTableType(table.getTableType().getName());
|
trId.setTableType(table.getTableType().getName());
|
||||||
|
@ -171,14 +189,11 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
|
||||||
return columnFilterMonitor;
|
return columnFilterMonitor;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new ExpressionServiceException("Error applying column filter: "
|
throw new ExpressionServiceException(
|
||||||
+ e.getLocalizedMessage());
|
"Error applying column filter: " + e.getLocalizedMessage());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue