Updated OperationMonitor

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@99303 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-08-27 14:47:36 +00:00
parent 3047749c1b
commit 41f0b6194f
6 changed files with 229 additions and 20 deletions

View File

@ -40,6 +40,8 @@ public class SessionConstants {
protected static final String DELETE_COLUMN_SESSION = "DELETE_COLUMN_SESSION";
protected static final String FILTER_COLUMN_SESSION = "FILTER_COLUMN_SESSION";
protected static final String EDIT_ROW_SESSION = "EDIT_ROW_SESSION";
protected static final String TASK_RESUBMIT_SESSION = "TASK_RESUBMIT_SESSION";

View File

@ -36,6 +36,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceBatchColumnS
import org.gcube.portlets.user.td.gwtservice.shared.tr.clone.CloneTabularResourceSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.AddColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.FilterColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.MergeColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnSession;
@ -602,6 +603,34 @@ public class SessionUtil {
deleteColumnSession);
}
//
public static FilterColumnSession getFilterColumnSession(
HttpSession httpSession) {
FilterColumnSession filterColumnSession = (FilterColumnSession) httpSession
.getAttribute(SessionConstants.FILTER_COLUMN_SESSION);
if (filterColumnSession != null) {
return filterColumnSession;
} else {
filterColumnSession = new FilterColumnSession();
httpSession.setAttribute(SessionConstants.FILTER_COLUMN_SESSION,
filterColumnSession);
return filterColumnSession;
}
}
public static void setFilterColumnSession(HttpSession httpSession,
FilterColumnSession filterColumnSession) {
FilterColumnSession fc = (FilterColumnSession) httpSession
.getAttribute(SessionConstants.FILTER_COLUMN_SESSION);
if (fc != null) {
httpSession.removeAttribute(SessionConstants.FILTER_COLUMN_SESSION);
}
httpSession.setAttribute(SessionConstants.FILTER_COLUMN_SESSION,
filterColumnSession);
}
//
public static TaskResubmitSession getTaskResubmitSession(

View File

@ -22,6 +22,7 @@ import java.util.Set;
import javax.servlet.http.HttpSession;
import org.gcube.data.analysis.tabulardata.expression.Expression;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.common.homelibrary.home.Home;
import org.gcube.common.homelibrary.home.HomeLibrary;
@ -107,6 +108,7 @@ import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4Deno
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4Duplicates;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4EditRow;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4ExtractCodelist;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4FilterColumn;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4GroupBy;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4LabelColumn;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4MergeColumn;
@ -173,6 +175,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceBatchColumnS
import org.gcube.portlets.user.td.gwtservice.shared.tr.clone.CloneTabularResourceSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.AddColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.FilterColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.MergeColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnSession;
@ -2339,7 +2342,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
logger.debug("OperationInvocation: \n" + invocation.toString());
Task trTask = service.execute(invocation, serviceTR.getId());
logger.debug("Start Task on service: TaskId " + trTask.getId());
TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.SDMXImport, trId);
@ -2754,8 +2756,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
return trTask.getId().getValue();
}
/**
*
* {@inheritDoc}
@ -2970,7 +2970,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
.getTabularResource(new TabularResourceId(Long.valueOf(trId
.getId())));
Collection<TabularResourceMetadata<?>> trMetas = tr.getAllMetadata();
Collection<TabularResourceMetadata<?>> trMetas = tr
.getAllMetadata();
logger.debug("GetTRMetadata size: " + trMetas.size());
ArrayList<TRMetadata> listTRMetadata = new ArrayList<TRMetadata>();
@ -3609,6 +3610,75 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
/**
* Start Filter Column
*
* @param filterColumnSession
* @param expression
* @param session
* @return
* @throws TDGWTServiceException
*/
public String startFilterColumn(FilterColumnSession filterColumnSession,
Expression expression, HttpSession session)
throws TDGWTServiceException {
try {
// HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.setFilterColumnSession(session, filterColumnSession);
ASLSession aslSession = SessionUtil.getAslSession(session);
if (filterColumnSession == null) {
logger.error("FilterColumnSession is null");
throw new TDGWTServiceException(
"Error in filter column: FilterColumnSession is null");
}
logger.debug("StartFilterColumn: " + filterColumnSession);
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
OpExecution4FilterColumn opEx = new OpExecution4FilterColumn(service,
filterColumnSession, expression);
OpExecutionDirector director = new OpExecutionDirector();
director.setOperationExecutionBuilder(opEx);
director.constructOperationExecution();
ArrayList<OperationExecution> invocations = director
.getListOperationExecution();
if (invocations == null) {
throw new TDGWTServiceException(
"Error in invocation: Operation not supported");
}
Long id = Long.valueOf(
filterColumnSession.getColumn().getTrId().getId());
TabularResourceId serviceTR = new TabularResourceId(id);
logger.debug("OperationInvocation: \n" + invocations.toString());
Task trTask = service.executeBatch(invocations, serviceTR);
logger.debug("Filter Column on service: TaskId " + trTask.getId());
TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.FilterColumn, filterColumnSession
.getColumn().getTrId());
SessionUtil.setTaskStarted(session, taskWrapper);
return trTask.getId().getValue();
} catch (TDGWTSessionExpiredException e) {
throw e;
} catch (SecurityException e) {
e.printStackTrace();
throw new TDGWTServiceException(
"Security exception, you haven't rights!");
} catch (Throwable e) {
e.printStackTrace();
throw new TDGWTServiceException("Error in filter column: "
+ e.getLocalizedMessage());
}
}
/**
*
* {@inheritDoc}
@ -4359,9 +4429,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
UIOperationsId.ApplyTemplate,
templateApplySession.getTrId());
SessionUtil.setTaskStarted(session, taskWrapper);
return trTask.getId().getValue();
} catch (TDGWTSessionExpiredException e) {
throw e;
} catch (SecurityException e) {
@ -4836,7 +4906,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
String opDesc = null, opName = null;
OpHistory op = null;
RollBackSession rollBackSession = null;
String taskId=null;
String taskId = null;
if (history != null) {
if (history.size() > 1) {
HistoryStep step = history.get(history.size() - 2);
@ -4848,7 +4918,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
sdf.format(step.getExecutionDate().getTime()));
logger.debug("Discard :" + op);
rollBackSession = new RollBackSession(trId, historyId);
taskId=startRollBack(rollBackSession);
taskId = startRollBack(rollBackSession);
} else {
logger.debug("Discard : step null");
@ -4906,7 +4976,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
throw new TDGWTServiceException("Task not started");
}
logger.debug("Start Task on service: " + trTask.getId());
TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.RollBack, rollBackSession.getTrId());
SessionUtil.setTaskStarted(session, taskWrapper);
@ -5606,7 +5676,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
logger.debug("Session:" + session.getId());
ASLSession aslSession = SessionUtil.getAslSession(session);
String user = aslSession.getUsername();
logger.debug("Session User:" + user);
@ -5621,10 +5691,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
SessionUtil.setCodelistMappingSession(session,
codelistMappingSession);
String taskId=importCodelistMappingFileOnService(session, aslSession, user,
codelistMappingSession);
String taskId = importCodelistMappingFileOnService(session,
aslSession, user, codelistMappingSession);
return taskId;
} catch (TDGWTSessionExpiredException e) {
throw e;
} catch (SecurityException e) {
@ -5633,10 +5703,11 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
"Security exception, you haven't rights!");
} catch (Throwable e) {
e.printStackTrace();
throw new TDGWTServiceException("Error in Codelist Mapping import: "
+ e.getLocalizedMessage());
throw new TDGWTServiceException(
"Error in Codelist Mapping import: "
+ e.getLocalizedMessage());
}
}
/**
@ -5709,13 +5780,13 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
// TODO
public String startGroupBy(GroupBySession groupBySession, HttpSession session)
throws TDGWTServiceException {
public String startGroupBy(GroupBySession groupBySession,
HttpSession session) throws TDGWTServiceException {
try {
// HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.setGroupBySession(session, groupBySession);
ASLSession aslSession = SessionUtil.getAslSession(session);
logger.debug("StartGroupBy: " + groupBySession);
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));

View File

@ -0,0 +1,64 @@
package org.gcube.portlets.user.td.gwtservice.server.opexecution;
import java.util.HashMap;
import java.util.Map;
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.service.TabularDataService;
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.tr.column.FilterColumnSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Operation Execution for delete column
*
* @author "Giancarlo Panichi" email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class OpExecution4FilterColumn extends OpExecutionBuilder {
protected static Logger logger = LoggerFactory
.getLogger(OpExecution4FilterColumn.class);
private TabularDataService service;
private FilterColumnSession filterColumnSession;
private Expression expression;
public OpExecution4FilterColumn(TabularDataService service,
FilterColumnSession filterColumnSession, Expression expression) {
this.service = service;
this.filterColumnSession = filterColumnSession;
this.expression=expression;
}
@Override
public void buildOpEx() throws TDGWTServiceException {
logger.debug(filterColumnSession.toString());
if(filterColumnSession.getColumn().getTrId()==null){
logger.error("TRId is null");
new TDGWTServiceException("No valid tabular resource id present");
}
OperationDefinition operationDefinition;
operationDefinition = OperationDefinitionMap.map(
OperationsId.FilterByExpression.toString(), service);
Map<String, Object> map = new HashMap<String, Object>();
map.put(Constants.PARAMETER_EXPRESSION, expression);
OperationExecution invocation = new OperationExecution(
operationDefinition.getOperationId(), map);
operationExecutionSpec.setOp(invocation);
}
}

View File

@ -86,7 +86,7 @@ public enum UIOperationsId {
Normalize("Normalize"),
ReplaceValue("Replace Value"),
ReplaceBatch("Replace Batch"),
Filter("Filter"),
FilterColumn("Filter Column"),
Union("Union"),
DuplicateTuples("Duplicate Tuples"),
ExtractCodelist("Extract Codelist"),

View File

@ -0,0 +1,43 @@
package org.gcube.portlets.user.td.gwtservice.shared.tr.column;
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 + "]";
}
}