Minor Updated
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@91831 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
8a0f365d8d
commit
d56bc3f6f3
|
@ -0,0 +1,67 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.expressionwidget.client.progress;
|
||||
|
||||
|
||||
|
||||
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.sencha.gxt.widget.core.client.ProgressBar;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ColumnFilterProgressBarUpdater implements ColumnFilterProgressListener {
|
||||
|
||||
protected ProgressBar progressBar;
|
||||
|
||||
/**
|
||||
* Creates a new {@link ProgressBar} updater.
|
||||
* @param progressBar the {@link ProgressBar} to update.
|
||||
*/
|
||||
public ColumnFilterProgressBarUpdater(ProgressBar progressBar) {
|
||||
this.progressBar = progressBar;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void operationComplete(TRId trId) {
|
||||
Log.info("Completed");
|
||||
progressBar.updateProgress(1, "Completed");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void operationFailed(Throwable caught, String reason, String failureDetails) {
|
||||
Log.info("Failed");
|
||||
progressBar.updateText("Failed");
|
||||
}
|
||||
|
||||
public void operationInitializing() {
|
||||
Log.info("Inizializing");
|
||||
progressBar.updateProgress(0, "Initializing...");
|
||||
}
|
||||
|
||||
public void operationUpdate(float elaborated) {
|
||||
Log.info("Import elaborated: "+elaborated);
|
||||
if (elaborated == 0) progressBar.updateProgress(0, "Initializing...");
|
||||
if (elaborated>0 && elaborated<1) {
|
||||
Log.trace("progress "+elaborated);
|
||||
int elab=new Float(elaborated*100).intValue();
|
||||
progressBar.updateProgress(elaborated,elab+"% Progress...");
|
||||
}
|
||||
if (elaborated == 1) progressBar.updateProgress(1, "Completing...");
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
package org.gcube.portlets.user.td.expressionwidget.client.progress;
|
||||
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
import com.sencha.gxt.core.client.util.Margins;
|
||||
import com.sencha.gxt.widget.core.client.FramedPanel;
|
||||
import com.sencha.gxt.widget.core.client.ProgressBar;
|
||||
import com.sencha.gxt.widget.core.client.Window;
|
||||
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
|
||||
import com.sencha.gxt.widget.core.client.button.TextButton;
|
||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||
import com.sencha.gxt.widget.core.client.event.HideEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
|
||||
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* ColumnFilterProgressDialog is a Dialog that show progress of change the column label
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ColumnFilterProgressDialog extends Window implements ColumnFilterProgressListener {
|
||||
public static final int STATUS_POLLING_DELAY = 1000;
|
||||
protected String WIDTH = "400px";
|
||||
protected String HEIGHT = "120px";
|
||||
protected EventBus eventBus;
|
||||
protected ColumnFilterProgressUpdater progressUpdater;
|
||||
protected TextButton ok;
|
||||
protected TRId trId;
|
||||
|
||||
public ColumnFilterProgressDialog(EventBus eventBus) {
|
||||
this.eventBus=eventBus;
|
||||
setWidth(WIDTH);
|
||||
setHeight(HEIGHT);
|
||||
setBodyBorder(false);
|
||||
setResizable(true);
|
||||
setModal(true);
|
||||
setHeadingText("Change The Column Label Progress");
|
||||
|
||||
trId=null;
|
||||
|
||||
FramedPanel panel=new FramedPanel();
|
||||
panel.setHeaderVisible(false);
|
||||
panel.setBodyBorder(false);
|
||||
|
||||
VerticalLayoutContainer v = new VerticalLayoutContainer();
|
||||
|
||||
|
||||
ProgressBar progressBar = new ProgressBar();
|
||||
|
||||
ok=new TextButton("OK");
|
||||
ok.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
updateInvocation();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
v.add(progressBar, new VerticalLayoutData(1,
|
||||
1, new Margins(5, 5, 5, 5)));
|
||||
|
||||
panel.add(v);
|
||||
panel.addButton(ok);
|
||||
add(panel);
|
||||
|
||||
|
||||
progressUpdater = new ColumnFilterProgressUpdater();
|
||||
progressUpdater.addListener(new ColumnFilterProgressBarUpdater(progressBar));
|
||||
|
||||
progressUpdater.addListener(this);
|
||||
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
|
||||
show();
|
||||
ok.setVisible(false);
|
||||
|
||||
}
|
||||
|
||||
public void operationInitializing() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void operationUpdate(float elaborated) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void operationComplete(TRId trId) {
|
||||
Log.debug("Operation Complete return: "+trId.toString());
|
||||
ok.setVisible(true);
|
||||
this.trId=trId;
|
||||
}
|
||||
|
||||
public void operationFailed(Throwable caught, String reason,
|
||||
String failureDetails) {
|
||||
ok.setVisible(true);
|
||||
this.trId=null;
|
||||
AlertMessageBox d = new AlertMessageBox("Error Applying Column Filter", reason);
|
||||
d.addHideHandler(new HideHandler() {
|
||||
public void onHide(HideEvent event) {
|
||||
}
|
||||
});
|
||||
d.show();
|
||||
}
|
||||
|
||||
public void updateInvocation(){
|
||||
if(trId!=null){
|
||||
ChangeTableRequestEvent changeTableRequestEvent=
|
||||
new ChangeTableRequestEvent(ChangeTableRequestType.COLUMNFILTER, trId);
|
||||
eventBus.fireEvent(changeTableRequestEvent);
|
||||
}
|
||||
hide();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.expressionwidget.client.progress;
|
||||
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Defines a listener for operation progress.
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public interface ColumnFilterProgressListener {
|
||||
|
||||
/**
|
||||
* Called when the operation is starting.
|
||||
*/
|
||||
public void operationInitializing();
|
||||
|
||||
/**
|
||||
* Called when there is a progress for the operation.
|
||||
* @param elaborated the elaborated part.
|
||||
*/
|
||||
public void operationUpdate(float elaborated);
|
||||
|
||||
|
||||
/**
|
||||
* Called when the operation is complete.
|
||||
*/
|
||||
public void operationComplete(TRId trId);
|
||||
|
||||
/**
|
||||
* Called when the operation is failed.
|
||||
* @param caught the failure exception.
|
||||
* @param reason the failure reason.
|
||||
*/
|
||||
public void operationFailed(Throwable caught, String reason, String failureDetails);
|
||||
}
|
|
@ -0,0 +1,160 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.expressionwidget.client.progress;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.session.ColumnFilterMonitor;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.user.client.Timer;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ColumnFilterProgressUpdater extends Timer {
|
||||
|
||||
protected ArrayList<ColumnFilterProgressListener> listeners = new ArrayList<ColumnFilterProgressListener>();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
Log.debug("requesting operation progress");
|
||||
ExpressionServiceAsync.INSTANCE
|
||||
.getColumnFilterMonitor(new AsyncCallback<ColumnFilterMonitor>() {
|
||||
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
cancel();
|
||||
Log.error("Error retrieving the operation state",
|
||||
caught);
|
||||
String message = getStack(caught);
|
||||
fireOperationFailed(caught,
|
||||
"Failed getting operation updates", message);
|
||||
}
|
||||
|
||||
public void onSuccess(ColumnFilterMonitor result) {
|
||||
Log.info("retrieved ColumnFilterMonitor: "
|
||||
+ result.getStatus());
|
||||
switch (result.getStatus()) {
|
||||
case INITIALIZING:
|
||||
Log.info("Column Filter Initializing...");
|
||||
fireOperationInitializing();
|
||||
break;
|
||||
case ABORTED:
|
||||
cancel();
|
||||
Log.info("Column Filter Operation Aborted");
|
||||
break;
|
||||
case IN_PROGRESS:
|
||||
fireOperationUpdate(result.getProgress());
|
||||
break;
|
||||
case VALIDATING_RULES:
|
||||
fireOperationUpdate(result.getProgress());
|
||||
break;
|
||||
case STOPPED:
|
||||
cancel();
|
||||
errorMessage(result);
|
||||
break;
|
||||
case FAILED:
|
||||
cancel();
|
||||
errorMessage(result);
|
||||
break;
|
||||
case SUCCEDED:
|
||||
cancel();
|
||||
Log.info("Column Filter fisnish TableId :"
|
||||
+ result.getTrId());
|
||||
fireOperationComplete(result.getTrId());
|
||||
break;
|
||||
default:
|
||||
Log.info("Unknow State");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void errorMessage(ColumnFilterMonitor result) {
|
||||
Log.info("Apply column filter failed");
|
||||
Throwable th = null;
|
||||
String failure = null;
|
||||
String details = null;
|
||||
if (result.getError() != null) {
|
||||
th = result.getError();
|
||||
failure = "Failed Client Library applying column filter";
|
||||
details = result.getError().getLocalizedMessage();
|
||||
} else {
|
||||
th = new Throwable("Failed");
|
||||
failure = "Failed Client Library applying column filter";
|
||||
details = "Apply column filter failed";
|
||||
}
|
||||
|
||||
|
||||
fireOperationFailed(th, failure, details);
|
||||
}
|
||||
|
||||
protected String getStack(Throwable e) {
|
||||
String message = e.getLocalizedMessage() + " -> <br>";
|
||||
Throwable c = e.getCause();
|
||||
if (c != null)
|
||||
message += getStack(c);
|
||||
return message;
|
||||
}
|
||||
|
||||
protected void fireOperationInitializing() {
|
||||
for (ColumnFilterProgressListener listener : listeners)
|
||||
listener.operationInitializing();
|
||||
}
|
||||
|
||||
protected void fireOperationUpdate(float elaborated) {
|
||||
for (ColumnFilterProgressListener listener : listeners)
|
||||
listener.operationUpdate(elaborated);
|
||||
}
|
||||
|
||||
protected void fireOperationComplete(TRId trId) {
|
||||
for (ColumnFilterProgressListener listener : listeners)
|
||||
listener.operationComplete(trId);
|
||||
}
|
||||
|
||||
protected void fireOperationFailed(Throwable caught, String failure,
|
||||
String failureDetails) {
|
||||
for (ColumnFilterProgressListener listener : listeners)
|
||||
listener.operationFailed(caught, failure, failureDetails);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new {@link ColumnFilterProgressListener} to this
|
||||
* {@link ColumnFilterProgressUpdater}.
|
||||
*
|
||||
* @param listener
|
||||
* the listener to add.
|
||||
*/
|
||||
public void addListener(ColumnFilterProgressListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified {@link ColumnFilterProgressListener} from this
|
||||
* {@link ColumnFilterProgressUpdater}.
|
||||
*
|
||||
* @param listener
|
||||
* the listener to remove.
|
||||
*/
|
||||
public void removeListener(ColumnFilterProgressListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
}
|
|
@ -6,8 +6,9 @@ package org.gcube.portlets.user.td.expressionwidget.client.rpc;
|
|||
|
||||
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.expression.ExpressionServiceException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.session.ColumnFilterMonitor;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.session.ColumnFilterSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
||||
|
||||
import com.google.gwt.user.client.rpc.RemoteService;
|
||||
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
||||
|
@ -30,7 +31,23 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
|||
@RemoteServiceRelativePath("ExpressionService")
|
||||
public interface ExpressionService extends RemoteService {
|
||||
|
||||
public void submitColumnFilter(ColumnData column, C_Expression expression) throws ExpressionServiceException;
|
||||
/**
|
||||
* Submit Column Filter Operation
|
||||
*
|
||||
* @param columnFilterSession
|
||||
* @throws ExpressionServiceException
|
||||
*/
|
||||
public void submitColumnFilter(ColumnFilterSession columnFilterSession) throws ExpressionServiceException;
|
||||
|
||||
/**
|
||||
* Get Operation Monitor during the applying Column Filter operation
|
||||
*
|
||||
*
|
||||
* @return
|
||||
* @throws ExpressionServiceException
|
||||
*/
|
||||
public ColumnFilterMonitor getColumnFilterMonitor()
|
||||
throws ExpressionServiceException;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
*/
|
||||
package org.gcube.portlets.user.td.expressionwidget.client.rpc;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.session.ColumnFilterMonitor;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.session.ColumnFilterSession;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
@ -21,6 +21,7 @@ public interface ExpressionServiceAsync {
|
|||
public static ExpressionServiceAsync INSTANCE = (ExpressionServiceAsync) GWT
|
||||
.create(ExpressionService.class);
|
||||
|
||||
void submitColumnFilter(ColumnData column, C_Expression expression,AsyncCallback<Void> callback);
|
||||
void submitColumnFilter(ColumnFilterSession columnFilterSession,AsyncCallback<Void> callback);
|
||||
void getColumnFilterMonitor(AsyncCallback<ColumnFilterMonitor> callback);
|
||||
|
||||
}
|
||||
|
|
|
@ -9,17 +9,23 @@ import javax.servlet.http.HttpSession;
|
|||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationProvider;
|
||||
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.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.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;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.session.ColumnFilterSession;
|
||||
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.shared.tr.ColumnData;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.trservice.TaskStateMap;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -28,7 +34,9 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
|||
public class ExpressionServiceImpl extends RemoteServiceServlet implements
|
||||
ExpressionService {
|
||||
|
||||
private static final long serialVersionUID = -5707400086333186368L;
|
||||
|
||||
private static final long serialVersionUID = 4632292751581364137L;
|
||||
|
||||
protected static Logger logger = LoggerFactory
|
||||
.getLogger(ExpressionServiceImpl.class);
|
||||
|
||||
|
@ -41,7 +49,7 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void submitColumnFilter(ColumnData column, C_Expression expression)
|
||||
public void submitColumnFilter(ColumnFilterSession columnFilterSession)
|
||||
throws ExpressionServiceException {
|
||||
|
||||
try {
|
||||
|
@ -78,7 +86,97 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public ColumnFilterMonitor getColumnFilterMonitor()
|
||||
throws ExpressionServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ColumnFilterSession columnFilterSession = ExpressionSession
|
||||
.getColumnFilterSession(session);
|
||||
|
||||
Task task = ExpressionSession.getColumnFilterTask(session);
|
||||
ColumnFilterMonitor columnFilterMonitor = new ColumnFilterMonitor();
|
||||
|
||||
if (task == null) {
|
||||
logger.debug("Task null");
|
||||
throw new ExpressionServiceException(
|
||||
"Error in ColumnFilter task null");
|
||||
} else {
|
||||
TaskStatus status = task.getStatus();
|
||||
if (status == null) {
|
||||
logger.debug("Services TaskStatus : null");
|
||||
throw new ExpressionServiceException(
|
||||
"Error in ColumnFilter Status null");
|
||||
} else {
|
||||
logger.debug("Services TaskStatus: " + task.getStatus());
|
||||
|
||||
columnFilterMonitor.setStatus(TaskStateMap.map(task
|
||||
.getStatus()));
|
||||
switch (columnFilterMonitor.getStatus()) {
|
||||
case FAILED:
|
||||
if (task.getResult() != null) {
|
||||
logger.debug("Task exception:"
|
||||
+ task.getErrorCause());
|
||||
columnFilterMonitor.setError(new Throwable(task
|
||||
.getErrorCause()));
|
||||
} else {
|
||||
logger.debug("Task exception: Error In Column Filter");
|
||||
columnFilterMonitor.setError(new Throwable(
|
||||
"Error In Column Filter"));
|
||||
}
|
||||
columnFilterMonitor.setProgress(task.getProgress());
|
||||
break;
|
||||
case SUCCEDED:
|
||||
logger.debug("Task Result:" + task.getResult());
|
||||
columnFilterMonitor.setProgress(task.getProgress());
|
||||
Table table = task.getResult().getPrimaryTable();
|
||||
logger.debug("Table retrived: " + table.toString());
|
||||
TRId trId = new TRId();
|
||||
trId.setId(columnFilterSession.getColumn()
|
||||
.getTrId().getId());
|
||||
trId.setTableId(String
|
||||
.valueOf(table.getId().getValue()));
|
||||
trId.setTableType(table.getTableType().getName());
|
||||
columnFilterMonitor.setTrId(trId);
|
||||
TabResource tabResource = SessionUtil
|
||||
.getTabResource(session);
|
||||
tabResource.setTrId(trId);
|
||||
SessionUtil.setTabResource(session, tabResource);
|
||||
SessionUtil.setTRId(session, trId);
|
||||
break;
|
||||
case IN_PROGRESS:
|
||||
columnFilterMonitor.setProgress(task.getProgress());
|
||||
break;
|
||||
case VALIDATING_RULES:
|
||||
columnFilterMonitor.setProgress(task.getProgress());
|
||||
break;
|
||||
case ABORTED:
|
||||
break;
|
||||
case STOPPED:
|
||||
columnFilterMonitor.setError(new Throwable(
|
||||
"Operation Stopped on service"));
|
||||
break;
|
||||
case INITIALIZING:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
ExpressionSession.setColumnFilterTask(session, task);
|
||||
}
|
||||
|
||||
logger.info("ColumnFilterMonitor(): " + columnFilterMonitor);
|
||||
return columnFilterMonitor;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ExpressionServiceException("Error applying column filter: "
|
||||
+ e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
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.ColumnFilterSession;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
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);
|
||||
|
||||
|
||||
public static ColumnFilterSession getColumnFilterSession(
|
||||
HttpSession httpSession) {
|
||||
ColumnFilterSession columnFilterSession = (ColumnFilterSession) httpSession
|
||||
.getAttribute(COLUMN_FILTER_SESSION);
|
||||
if (columnFilterSession != null) {
|
||||
return columnFilterSession;
|
||||
} else {
|
||||
columnFilterSession = new ColumnFilterSession();
|
||||
httpSession.setAttribute(COLUMN_FILTER_SESSION,
|
||||
columnFilterSession);
|
||||
return columnFilterSession;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setColumnFilterSession(HttpSession httpSession,
|
||||
ColumnFilterSession columnFilterSession) {
|
||||
ColumnFilterSession cf = (ColumnFilterSession) httpSession
|
||||
.getAttribute(COLUMN_FILTER_SESSION);
|
||||
if (cf != null) {
|
||||
httpSession.removeAttribute(COLUMN_FILTER_SESSION);
|
||||
}
|
||||
httpSession.setAttribute(COLUMN_FILTER_SESSION,
|
||||
columnFilterSession);
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
if (monitor == null) {
|
||||
logger.error("CHANGE_THE_COLUMN_LABEL_TASK was not acquired");
|
||||
}
|
||||
return monitor;
|
||||
}
|
||||
|
||||
public static void setColumnFilterTask(HttpSession httpSession,
|
||||
Task task) {
|
||||
Task monitor = (Task) httpSession.getAttribute(COLUMN_FILTER_SESSION_TASK);
|
||||
if (monitor != null)
|
||||
httpSession.removeAttribute(COLUMN_FILTER_SESSION_TASK);
|
||||
httpSession.setAttribute(COLUMN_FILTER_SESSION_TASK, task);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.expressionwidget.shared.session;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.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;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
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 ColumnFilterSession implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = -5362632291599472352L;
|
||||
protected ColumnData column;
|
||||
protected C_Expression 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