Updated OperationMonitor
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@99304 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
b414284db7
commit
aa0c20b898
|
@ -3,14 +3,17 @@ package org.gcube.portlets.user.td.expressionwidget.client;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources;
|
import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync;
|
import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.client.utils.UtilsGXT3;
|
import org.gcube.portlets.user.td.expressionwidget.client.utils.UtilsGXT3;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.session.FilterColumnSession;
|
|
||||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.FilterColumnSession;
|
||||||
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog;
|
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog;
|
||||||
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener;
|
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener;
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent;
|
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType;
|
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType;
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableWhy;
|
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableWhy;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
|
||||||
|
@ -39,7 +42,7 @@ public class ColumnFilterDialog extends Window implements MonitorDialogListener
|
||||||
protected TRId trId;
|
protected TRId trId;
|
||||||
protected String columnName = null;
|
protected String columnName = null;
|
||||||
protected EventBus eventBus;
|
protected EventBus eventBus;
|
||||||
private FilterColumnSession columnFilterSession;
|
private FilterColumnSession filterColumnSession;
|
||||||
|
|
||||||
public ColumnFilterDialog(String columnId, ColumnTypeCode columnTypeCode,
|
public ColumnFilterDialog(String columnId, ColumnTypeCode columnTypeCode,
|
||||||
ColumnDataType dataTypeName, EventBus eventBus) {
|
ColumnDataType dataTypeName, EventBus eventBus) {
|
||||||
|
@ -158,10 +161,10 @@ public class ColumnFilterDialog extends Window implements MonitorDialogListener
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void callApplyFilter() {
|
protected void callApplyFilter() {
|
||||||
columnFilterSession = new FilterColumnSession(column, exp);
|
filterColumnSession = new FilterColumnSession(column, exp);
|
||||||
Log.debug(columnFilterSession.toString());
|
Log.debug(filterColumnSession.toString());
|
||||||
|
|
||||||
ExpressionServiceAsync.INSTANCE.startColumnFilter(columnFilterSession,
|
ExpressionServiceAsync.INSTANCE.startFilterColumn(filterColumnSession,
|
||||||
new AsyncCallback<String>() {
|
new AsyncCallback<String>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -173,11 +176,17 @@ public class ColumnFilterDialog extends Window implements MonitorDialogListener
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
Log.error("Error submitting the column filter: "
|
if (caught instanceof TDGWTSessionExpiredException) {
|
||||||
+ caught.getMessage() + " " + caught.getCause());
|
eventBus.fireEvent(new SessionExpiredEvent(
|
||||||
caught.printStackTrace();
|
SessionExpiredType.EXPIREDONSERVER));
|
||||||
UtilsGXT3.alert("Error submitting the column filter",
|
} else {
|
||||||
caught.getMessage());
|
Log.error("Error submitting the column filter: "
|
||||||
|
+ caught.getLocalizedMessage());
|
||||||
|
caught.printStackTrace();
|
||||||
|
UtilsGXT3.alert(
|
||||||
|
"Error submitting the column filter",
|
||||||
|
caught.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,8 +5,8 @@ package org.gcube.portlets.user.td.expressionwidget.client.rpc;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.exception.ExpressionServiceException;
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.session.FilterColumnSession;
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.FilterColumnSession;
|
||||||
|
|
||||||
import com.google.gwt.user.client.rpc.RemoteService;
|
import com.google.gwt.user.client.rpc.RemoteService;
|
||||||
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
||||||
|
@ -35,7 +35,7 @@ public interface ExpressionService extends RemoteService {
|
||||||
* @param columnFilterSession
|
* @param columnFilterSession
|
||||||
* @throws ExpressionServiceException
|
* @throws ExpressionServiceException
|
||||||
*/
|
*/
|
||||||
public String startColumnFilter(FilterColumnSession columnFilterSession) throws ExpressionServiceException;
|
public String startFilterColumn(FilterColumnSession filterColumnSession) throws TDGWTServiceException;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.user.td.expressionwidget.client.rpc;
|
package org.gcube.portlets.user.td.expressionwidget.client.rpc;
|
||||||
|
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.session.FilterColumnSession;
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.FilterColumnSession;
|
||||||
|
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
@ -20,7 +20,7 @@ public interface ExpressionServiceAsync {
|
||||||
public static ExpressionServiceAsync INSTANCE = (ExpressionServiceAsync) GWT
|
public static ExpressionServiceAsync INSTANCE = (ExpressionServiceAsync) GWT
|
||||||
.create(ExpressionService.class);
|
.create(ExpressionService.class);
|
||||||
|
|
||||||
void startColumnFilter(FilterColumnSession columnFilterSession,AsyncCallback<String> callback);
|
void startFilterColumn(FilterColumnSession filterColumnSession,AsyncCallback<String> callback);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,13 +21,14 @@ import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource;
|
||||||
import org.gcube.data.analysis.tabulardata.service.tabular.TabularResourceId;
|
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.exception.ExpressionServiceException;
|
import org.gcube.portlets.user.td.expressionwidget.shared.exception.ExpressionServiceException;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.session.FilterColumnSession;
|
|
||||||
import org.gcube.portlets.user.td.gwtservice.server.SessionUtil;
|
import org.gcube.portlets.user.td.gwtservice.server.SessionUtil;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.server.TDGWTServiceImpl;
|
||||||
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.shared.Constants;
|
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.OperationsId;
|
import org.gcube.portlets.user.td.gwtservice.shared.OperationsId;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.FilterColumnSession;
|
||||||
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;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -45,63 +46,43 @@ 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, FilterColumnSession columnFilterSession)
|
|
||||||
throws TDGWTServiceException {
|
|
||||||
|
|
||||||
OperationExecution invocation = null;
|
|
||||||
|
|
||||||
OperationDefinition operationDefinition;
|
|
||||||
Map<String, Object> map = new HashMap<String, Object>();
|
|
||||||
|
|
||||||
C_ExpressionParser parser=new C_ExpressionParser();
|
|
||||||
Expression exp=parser.parse(columnFilterSession.getCexpression());
|
|
||||||
logger.debug("Service Expression:"+exp);
|
|
||||||
|
|
||||||
map.put(Constants.PARAMETER_EXPRESSION, exp);
|
|
||||||
|
|
||||||
operationDefinition = OperationDefinitionMap.map(
|
|
||||||
OperationsId.FilterByExpression.toString(), service);
|
|
||||||
|
|
||||||
invocation = new OperationExecution(operationDefinition.getOperationId(), map);
|
|
||||||
|
|
||||||
return invocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String startColumnFilter(FilterColumnSession columnFilterSession)
|
public String startFilterColumn(FilterColumnSession filterColumnSession)
|
||||||
throws ExpressionServiceException {
|
throws TDGWTServiceException {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logger.debug("ExpressionService submitColumnFilter");
|
logger.debug("ExpressionService submitColumnFilter");
|
||||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||||
logger.debug("Session: "+session);
|
logger.debug("Session: "+session);
|
||||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
|
||||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
|
||||||
aslSession.getUsername()));
|
|
||||||
|
|
||||||
logger.debug(columnFilterSession.toString());
|
if(filterColumnSession==null){
|
||||||
ExpressionSession.setColumnFilterSession(session, columnFilterSession);
|
logger.error("FilterColumnSession is null");
|
||||||
|
new ExpressionServiceException("FilterColumnSession is null");
|
||||||
|
}
|
||||||
|
ExpressionSession.setColumnFilterSession(session, filterColumnSession);
|
||||||
|
|
||||||
TabularDataService service = TabularDataServiceFactory.getService();
|
C_ExpressionParser parser=new C_ExpressionParser();
|
||||||
OperationExecution invocation = retrieveOperationExecution(service,
|
Expression expression=parser.parse(filterColumnSession.getCexpression());
|
||||||
columnFilterSession);
|
logger.debug("Service Expression:"+expression);
|
||||||
|
|
||||||
|
|
||||||
|
TDGWTServiceImpl gwtService = new TDGWTServiceImpl();
|
||||||
|
|
||||||
|
String taskId= gwtService.startFilterColumn(filterColumnSession, expression, session);
|
||||||
|
|
||||||
|
return taskId;
|
||||||
|
|
||||||
logger.debug("OperationInvocation: \n" + invocation.toString());
|
|
||||||
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 null;
|
|
||||||
} catch (TDGWTSessionExpiredException e){
|
} catch (TDGWTSessionExpiredException e){
|
||||||
throw new ExpressionServiceException(e.getLocalizedMessage());
|
throw e;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new ExpressionServiceException(
|
throw new TDGWTServiceException(
|
||||||
"Error in Client Library Request: "
|
"Error in Client Library Request: "
|
||||||
+ e.getLocalizedMessage());
|
+ e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,7 @@ package org.gcube.portlets.user.td.expressionwidget.server;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.gcube.data.analysis.tabulardata.service.operation.Task;
|
import org.gcube.data.analysis.tabulardata.service.operation.Task;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.session.ColumnFilterMonitor;
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.FilterColumnSession;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.session.FilterColumnSession;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -22,7 +21,6 @@ public class ExpressionSession {
|
||||||
|
|
||||||
protected static final String COLUMN_FILTER_SESSION = "COLUMN_FILTER_SESSION";
|
protected static final String COLUMN_FILTER_SESSION = "COLUMN_FILTER_SESSION";
|
||||||
protected static final String COLUMN_FILTER_SESSION_TASK = "COLUMN_FILTER_SESSION_TASK";
|
protected static final String COLUMN_FILTER_SESSION_TASK = "COLUMN_FILTER_SESSION_TASK";
|
||||||
protected static final String COLUMN_FILTER_SESSION_MONITOR = "COLUMN_FILTER_SESSION_MONITOR";
|
|
||||||
|
|
||||||
|
|
||||||
protected static Logger logger = LoggerFactory.getLogger(ExpressionSession.class);
|
protected static Logger logger = LoggerFactory.getLogger(ExpressionSession.class);
|
||||||
|
@ -54,31 +52,7 @@ public class ExpressionSession {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ColumnFilterMonitor getColumnFilterMonitor(
|
|
||||||
HttpSession httpSession) {
|
|
||||||
ColumnFilterMonitor columnFilterMonitor = (ColumnFilterMonitor) httpSession
|
|
||||||
.getAttribute(COLUMN_FILTER_SESSION_MONITOR);
|
|
||||||
if (columnFilterMonitor != null) {
|
|
||||||
return columnFilterMonitor;
|
|
||||||
} else {
|
|
||||||
columnFilterMonitor = new ColumnFilterMonitor();
|
|
||||||
httpSession.setAttribute(COLUMN_FILTER_SESSION_MONITOR,
|
|
||||||
columnFilterMonitor);
|
|
||||||
return columnFilterMonitor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setColumnFilterMonitor(HttpSession httpSession,
|
|
||||||
ColumnFilterMonitor columnFilterMonitor) {
|
|
||||||
ColumnFilterMonitor cf = (ColumnFilterMonitor) httpSession
|
|
||||||
.getAttribute(COLUMN_FILTER_SESSION_MONITOR);
|
|
||||||
if (cf != null) {
|
|
||||||
httpSession.removeAttribute(COLUMN_FILTER_SESSION_MONITOR);
|
|
||||||
}
|
|
||||||
httpSession.setAttribute(COLUMN_FILTER_SESSION_MONITOR,
|
|
||||||
columnFilterMonitor);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Task getColumnFilterTask(HttpSession httpSession) {
|
public static Task getColumnFilterTask(HttpSession httpSession) {
|
||||||
Task monitor = (Task) httpSession.getAttribute(COLUMN_FILTER_SESSION_TASK);
|
Task monitor = (Task) httpSession.getAttribute(COLUMN_FILTER_SESSION_TASK);
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.gcube.portlets.user.td.expressionwidget.shared.session;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.monitor.OperationMonitor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author "Giancarlo Panichi"
|
|
||||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ColumnFilterMonitor extends OperationMonitor implements Serializable {
|
|
||||||
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 4722919347946633238L;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
package org.gcube.portlets.user.td.expressionwidget.shared.session;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
|
|
||||||
|
|
||||||
public class FilterColumnSession implements Serializable{
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -5362632291599472352L;
|
|
||||||
protected ColumnData column;
|
|
||||||
protected C_Expression cexpression;
|
|
||||||
|
|
||||||
public FilterColumnSession(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public FilterColumnSession(ColumnData column, C_Expression cexpression){
|
|
||||||
this.column=column;
|
|
||||||
this.cexpression=cexpression;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public ColumnData getColumn() {
|
|
||||||
return column;
|
|
||||||
}
|
|
||||||
public void setColumn(ColumnData column) {
|
|
||||||
this.column = column;
|
|
||||||
}
|
|
||||||
public C_Expression getCexpression() {
|
|
||||||
return cexpression;
|
|
||||||
}
|
|
||||||
public void setCexpression(C_Expression cexpression) {
|
|
||||||
this.cexpression = cexpression;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "ColumnFilterSession [column=" + column + ", cexpression="
|
|
||||||
+ cexpression + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue