diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ColumnFilterDialog.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ColumnFilterDialog.java index 2f7622e..e52630d 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ColumnFilterDialog.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ColumnFilterDialog.java @@ -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.rpc.ExpressionServiceAsync; 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.shared.exception.TDGWTSessionExpiredException; 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.MonitorDialogListener; 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.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.expression.C_Expression; 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 String columnName = null; protected EventBus eventBus; - private FilterColumnSession columnFilterSession; + private FilterColumnSession filterColumnSession; public ColumnFilterDialog(String columnId, ColumnTypeCode columnTypeCode, ColumnDataType dataTypeName, EventBus eventBus) { @@ -158,10 +161,10 @@ public class ColumnFilterDialog extends Window implements MonitorDialogListener } protected void callApplyFilter() { - columnFilterSession = new FilterColumnSession(column, exp); - Log.debug(columnFilterSession.toString()); + filterColumnSession = new FilterColumnSession(column, exp); + Log.debug(filterColumnSession.toString()); - ExpressionServiceAsync.INSTANCE.startColumnFilter(columnFilterSession, + ExpressionServiceAsync.INSTANCE.startFilterColumn(filterColumnSession, new AsyncCallback() { @Override @@ -173,11 +176,17 @@ public class ColumnFilterDialog extends Window implements MonitorDialogListener @Override public void onFailure(Throwable caught) { - Log.error("Error submitting the column filter: " - + caught.getMessage() + " " + caught.getCause()); - caught.printStackTrace(); - UtilsGXT3.alert("Error submitting the column filter", - caught.getMessage()); + if (caught instanceof TDGWTSessionExpiredException) { + eventBus.fireEvent(new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + Log.error("Error submitting the column filter: " + + caught.getLocalizedMessage()); + caught.printStackTrace(); + UtilsGXT3.alert( + "Error submitting the column filter", + caught.getLocalizedMessage()); + } } }); diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/rpc/ExpressionService.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/rpc/ExpressionService.java index 1adca86..231dc65 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/rpc/ExpressionService.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/rpc/ExpressionService.java @@ -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.expressionwidget.shared.session.FilterColumnSession; +import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException; +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.RemoteServiceRelativePath; @@ -35,7 +35,7 @@ public interface ExpressionService extends RemoteService { * @param columnFilterSession * @throws ExpressionServiceException */ - public String startColumnFilter(FilterColumnSession columnFilterSession) throws ExpressionServiceException; + public String startFilterColumn(FilterColumnSession filterColumnSession) throws TDGWTServiceException; diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/rpc/ExpressionServiceAsync.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/rpc/ExpressionServiceAsync.java index 4ecf351..bde5a10 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/rpc/ExpressionServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/rpc/ExpressionServiceAsync.java @@ -3,7 +3,7 @@ */ 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.user.client.rpc.AsyncCallback; @@ -20,7 +20,7 @@ public interface ExpressionServiceAsync { public static ExpressionServiceAsync INSTANCE = (ExpressionServiceAsync) GWT .create(ExpressionService.class); - void startColumnFilter(FilterColumnSession columnFilterSession,AsyncCallback callback); + void startFilterColumn(FilterColumnSession filterColumnSession,AsyncCallback callback); } diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/server/ExpressionServiceImpl.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/server/ExpressionServiceImpl.java index 957fef8..6779cb6 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/server/ExpressionServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/server/ExpressionServiceImpl.java @@ -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.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.session.FilterColumnSession; 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.shared.Constants; 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.TDGWTSessionExpiredException; +import org.gcube.portlets.user.td.gwtservice.shared.tr.column.FilterColumnSession; import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,63 +46,43 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements protected static SimpleDateFormat sdf = new SimpleDateFormat( "yyyy/MM/dd HH:mm"); - protected OperationExecution retrieveOperationExecution( - TabularDataService service, FilterColumnSession columnFilterSession) - throws TDGWTServiceException { - - OperationExecution invocation = null; - - OperationDefinition operationDefinition; - Map map = new HashMap(); - - 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} */ @Override - public String startColumnFilter(FilterColumnSession columnFilterSession) - throws ExpressionServiceException { + public String startFilterColumn(FilterColumnSession filterColumnSession) + throws TDGWTServiceException { try { logger.debug("ExpressionService submitColumnFilter"); HttpSession session = this.getThreadLocalRequest().getSession(); logger.debug("Session: "+session); - ASLSession aslSession = SessionUtil.getAslSession(session); - AuthorizationProvider.instance.set(new AuthorizationToken( - aslSession.getUsername())); - logger.debug(columnFilterSession.toString()); - ExpressionSession.setColumnFilterSession(session, columnFilterSession); + if(filterColumnSession==null){ + logger.error("FilterColumnSession is null"); + new ExpressionServiceException("FilterColumnSession is null"); + } + ExpressionSession.setColumnFilterSession(session, filterColumnSession); - TabularDataService service = TabularDataServiceFactory.getService(); - OperationExecution invocation = retrieveOperationExecution(service, - columnFilterSession); - - 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; + C_ExpressionParser parser=new C_ExpressionParser(); + Expression expression=parser.parse(filterColumnSession.getCexpression()); + logger.debug("Service Expression:"+expression); + + + TDGWTServiceImpl gwtService = new TDGWTServiceImpl(); + + String taskId= gwtService.startFilterColumn(filterColumnSession, expression, session); + + return taskId; + } catch (TDGWTSessionExpiredException e){ - throw new ExpressionServiceException(e.getLocalizedMessage()); + throw e; } catch (Throwable e) { e.printStackTrace(); - throw new ExpressionServiceException( + throw new TDGWTServiceException( "Error in Client Library Request: " + e.getLocalizedMessage()); } diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/server/ExpressionSession.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/server/ExpressionSession.java index be164d1..de0796e 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/server/ExpressionSession.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/server/ExpressionSession.java @@ -6,8 +6,7 @@ package org.gcube.portlets.user.td.expressionwidget.server; import javax.servlet.http.HttpSession; 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.expressionwidget.shared.session.FilterColumnSession; +import org.gcube.portlets.user.td.gwtservice.shared.tr.column.FilterColumnSession; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -22,8 +21,7 @@ public class ExpressionSession { 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_MONITOR = "COLUMN_FILTER_SESSION_MONITOR"; - + 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) { Task monitor = (Task) httpSession.getAttribute(COLUMN_FILTER_SESSION_TASK); diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/shared/session/ColumnFilterMonitor.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/shared/session/ColumnFilterMonitor.java deleted file mode 100644 index f2d7921..0000000 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/shared/session/ColumnFilterMonitor.java +++ /dev/null @@ -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" - * g.panichi@isti.cnr.it - * - */ -public class ColumnFilterMonitor extends OperationMonitor implements Serializable { - - - private static final long serialVersionUID = 4722919347946633238L; - - -} diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/shared/session/FilterColumnSession.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/shared/session/FilterColumnSession.java deleted file mode 100644 index 42f0903..0000000 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/shared/session/FilterColumnSession.java +++ /dev/null @@ -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 + "]"; - } - -}