Added Position Column

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@112336 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-03-03 17:17:30 +00:00
parent 493187a0aa
commit a5b87c89a9
15 changed files with 254 additions and 38 deletions

View File

@ -50,6 +50,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.OccurrencesForRepla
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceBatchColumnSession;
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.ChangeColumnsPositionSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnSession;
@ -344,9 +345,8 @@ public interface TDGWTService extends RemoteService {
/**
* Set Current Tabular Resource that passed as parameter if not null
*
*
* @param activeTRId
* @return TODO
* @return
* @throws TDGWTServiceException
*/
public TRId setActiveTabularResource(TRId activeTRId)
@ -824,6 +824,17 @@ public interface TDGWTService extends RemoteService {
public String startLabelColumn(LabelColumnSession labelColumnSession)
throws TDGWTServiceException;
/**
* Start change columns position
*
*
* @param changeColumnsPositionSession
* @return
* @throws TDGWTServiceException
*/
public String startChangeColumnsPosition(ChangeColumnsPositionSession changeColumnsPositionSession)
throws TDGWTServiceException;
/**
* Start split column
*

View File

@ -49,6 +49,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.OccurrencesForRepla
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceBatchColumnSession;
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.ChangeColumnsPositionSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.LabelColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnSession;
@ -307,7 +308,11 @@ public interface TDGWTServiceAsync {
void startLabelColumn(LabelColumnSession labelColumnSession,
AsyncCallback<String> callback);
void startChangeColumnsPosition(ChangeColumnsPositionSession changeColumnsPositionSession,
AsyncCallback<String> callback);
/*
* void startSplitColumn(SplitColumnSession
* splitColumnSession,AsyncCallback<Void> callback);

View File

@ -68,6 +68,8 @@ public class SessionConstants {
public static final String UNION_SESSION = "UNION_SESSION";
public static final String CHANGE_COLUMNS_POSITION_SESSION = "CHANGE_COLUMNS_POSITION_SESSION";
public static final String REPLACE_BY_EXTERNAL_SESSION = "REPLACE_BY_EXTERNAL_SESSION";
public static final String STATISTICAL_OPERATION_SESSION = "STATISTICAL_OPERATION_SESSION";

View File

@ -41,6 +41,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceBatchColumnSession;
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.ChangeColumnsPositionSession;
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;
@ -1709,6 +1710,32 @@ public class SessionUtil {
httpSession.setAttribute(SessionConstants.UNION_SESSION, unionSession);
}
//
public static ChangeColumnsPositionSession getChangeColumnsPositionSession(HttpSession httpSession) {
ChangeColumnsPositionSession changeColumnsPositionSession = (ChangeColumnsPositionSession) httpSession
.getAttribute(SessionConstants.CHANGE_COLUMNS_POSITION_SESSION);
if (changeColumnsPositionSession != null) {
return changeColumnsPositionSession;
} else {
changeColumnsPositionSession = new ChangeColumnsPositionSession();
httpSession.setAttribute(SessionConstants.CHANGE_COLUMNS_POSITION_SESSION,
changeColumnsPositionSession);
return changeColumnsPositionSession;
}
}
public static void setChangeColumnsPositionSession(HttpSession httpSession,
ChangeColumnsPositionSession changeColumnsPositionSession) {
ChangeColumnsPositionSession ccps = (ChangeColumnsPositionSession) httpSession
.getAttribute(SessionConstants.CHANGE_COLUMNS_POSITION_SESSION);
if (ccps != null) {
httpSession.removeAttribute(SessionConstants.CHANGE_COLUMNS_POSITION_SESSION);
}
httpSession.setAttribute(SessionConstants.CHANGE_COLUMNS_POSITION_SESSION, changeColumnsPositionSession);
}
//
public static ReplaceByExternalSession getReplaceByExternalSession(

View File

@ -115,6 +115,7 @@ import org.gcube.portlets.user.td.gwtservice.server.file.FileUtil;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4AddColumn;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4CSVExport;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4ChangeColumnType;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4ChangeColumnsPosition;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4ChangeTableType;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4ChartTopRating;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4Clone;
@ -219,6 +220,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.OccurrencesForRepla
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceBatchColumnSession;
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.ChangeColumnsPositionSession;
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;
@ -7973,6 +7975,67 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
}
/**
*
* {@inheritDoc}
*/
@Override
public String startChangeColumnsPosition(ChangeColumnsPositionSession changeColumnsPositionSession)
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.setChangeColumnsPositionSession(session, changeColumnsPositionSession);
ASLSession aslSession = SessionUtil.getAslSession(session);
AuthorizationProvider.instance.set(new AuthorizationToken(
aslSession.getUsername(), aslSession.getScope()));
TabularDataService service = TabularDataServiceFactory.getService();
checkTRId(changeColumnsPositionSession.getTrId());
TabularResourceId tabularResourceId = new TabularResourceId(
Long.valueOf(changeColumnsPositionSession.getTrId().getId()));
TabularResource tabularResource = service
.getTabularResource(tabularResourceId);
checkTabularResourceIsFlow(tabularResource);
checkTabularResourceLocked(tabularResource);
checkTabularResourceIsFinal(tabularResource);
OpExecution4ChangeColumnsPosition opEx = new OpExecution4ChangeColumnsPosition(service,
changeColumnsPositionSession);
OpExecutionDirector director = new OpExecutionDirector();
director.setOperationExecutionBuilder(opEx);
director.constructOperationExecution();
OperationExecution invocation = director.getOperationExecution();
if (invocation == null) {
throw new TDGWTServiceException(
"Error in Change Columns Position invocation: Operation not supported");
}
logger.debug("OperationInvocation: \n" + invocation.toString());
Task trTask = service.execute(invocation, tabularResourceId);
logger.debug("Start Task on service: TaskId " + trTask.getId());
TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.ChangeColumnsPosition, changeColumnsPositionSession.getTrId());
SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue();
} catch (TDGWTServiceException e) {
throw e;
} catch (SecurityException e) {
e.printStackTrace();
throw new TDGWTServiceException(SECURITY_EXCEPTION_RIGHTS);
} catch (Throwable e) {
e.printStackTrace();
throw new TDGWTServiceException("Error in change columns position: "
+ e.getLocalizedMessage());
}
}
/**
*
@ -8574,6 +8637,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
.getApplicationType().toString());
params.put("smp-uri", uriResolverSession.getUuid());
params.put("fileName", uriResolverSession.getFileName());
params.put("contentType", "");
logger.debug("Uri Resolver params: " + params);
link = resolver.getLink(params, true); // true, link is shorted
// otherwise none

View File

@ -0,0 +1,54 @@
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.service.TabularDataService;
import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationDefinitionMap;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ChangeColumnsPositionSession;
import org.gcube.portlets.user.td.widgetcommonevent.shared.operations.OperationsId;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Operation Execution for change column position
*
* @author "Giancarlo Panichi" email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class OpExecution4ChangeColumnsPosition extends OpExecutionBuilder {
private static Logger logger = LoggerFactory
.getLogger(OpExecution4ChangeColumnsPosition.class);
private TabularDataService service;
private ChangeColumnsPositionSession changeColumnsPositionSession;
public OpExecution4ChangeColumnsPosition(TabularDataService service,
ChangeColumnsPositionSession changeColumnsPositionSession) {
this.service = service;
this.changeColumnsPositionSession = changeColumnsPositionSession;
}
@Override
public void buildOpEx() throws TDGWTServiceException {
logger.debug("Change Columns Position: "+changeColumnsPositionSession);
OperationDefinition operationDefinition;
operationDefinition = OperationDefinitionMap.map(
OperationsId.ChangeColumnPosition.toString(), service);
Map<String, Object> map = new HashMap<String, Object>();
map.put("listColumns", changeColumnsPositionSession.getColumns());
OperationExecution invocation = new OperationExecution(
operationDefinition.getOperationId(), map);
operationExecutionSpec.setOp(invocation);
}
}

View File

@ -15,8 +15,8 @@ public class AddColumnSession implements Serializable {
private static final long serialVersionUID = -1896235499708614266L;
protected TRId trId;
protected DefNewColumn column;
private TRId trId;
private DefNewColumn column;
public AddColumnSession(){

View File

@ -0,0 +1,53 @@
package org.gcube.portlets.user.td.gwtservice.shared.tr.column;
import java.io.Serializable;
import java.util.ArrayList;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ChangeColumnsPositionSession implements Serializable {
private static final long serialVersionUID = -1896235499708614266L;
private TRId trId;
private ArrayList<ColumnData> columns;
public ChangeColumnsPositionSession() {
}
public ChangeColumnsPositionSession(TRId trId, ArrayList<ColumnData> columns) {
this.trId = trId;
this.columns = columns;
}
public TRId getTrId() {
return trId;
}
public void setTrId(TRId trId) {
this.trId = trId;
}
public ArrayList<ColumnData> getColumns() {
return columns;
}
public void setColumns(ArrayList<ColumnData> columns) {
this.columns = columns;
}
@Override
public String toString() {
return "ReorderColumnsSession [trId=" + trId + ", columns=" + columns
+ "]";
}
}

View File

@ -16,8 +16,8 @@ public class DeleteColumnSession implements Serializable {
private static final long serialVersionUID = -1896235499708614266L;
protected TRId trId;
protected ArrayList<ColumnData> columns;
private TRId trId;
private ArrayList<ColumnData> columns;
public DeleteColumnSession(){

View File

@ -14,8 +14,8 @@ import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expressi
public class FilterColumnSession implements Serializable{
private static final long serialVersionUID = -5362632291599472352L;
protected ColumnData column;
protected C_Expression cexpression;
private ColumnData column;
private C_Expression cexpression;
public FilterColumnSession(){

View File

@ -16,8 +16,8 @@ public class LabelColumnSession implements Serializable {
private static final long serialVersionUID = -1896235499708614266L;
protected TRId trId;
protected HashMap<ColumnData, String> maps;
private TRId trId;
private HashMap<ColumnData, String> maps;
public LabelColumnSession() {

View File

@ -17,13 +17,13 @@ public class MergeColumnSession implements Serializable {
private static final long serialVersionUID = -1896235499708614266L;
protected ColumnData columnDataSource1;
protected ColumnData columnDataSource2;
protected String label;
protected Expression expression;
protected ColumnTypeCode mergeColumnType;
protected ColumnDataType mergeColumnDataType;
protected boolean deleteColumn;
private ColumnData columnDataSource1;
private ColumnData columnDataSource2;
private String label;
private Expression expression;
private ColumnTypeCode mergeColumnType;
private ColumnDataType mergeColumnDataType;
private boolean deleteColumn;
public MergeColumnSession() {

View File

@ -14,11 +14,11 @@ import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expressi
public class ReplaceColumnByExpressionSession implements Serializable{
private static final long serialVersionUID = -3940140817918362233L;
protected ColumnData column;
protected C_Expression cConditionExpression;
protected C_Expression cReplaceExpression;
protected String replaceValue;
protected boolean replaceByValue;
private ColumnData column;
private C_Expression cConditionExpression;
private C_Expression cReplaceExpression;
private String replaceValue;
private boolean replaceByValue;
public ReplaceColumnByExpressionSession(){

View File

@ -15,12 +15,12 @@ public class ReplaceColumnSession implements Serializable {
private static final long serialVersionUID = -1896235499708614266L;
protected String value; //Original value
protected String replaceValue; //New value
protected TRId trId;
protected ColumnData columnData;
protected String rowId;
protected boolean replaceDimension;
private String value; //Original value
private String replaceValue; //New value
private TRId trId;
private ColumnData columnData;
private String rowId;
private boolean replaceDimension;
public ReplaceColumnSession() {

View File

@ -18,15 +18,15 @@ public class SplitColumnSession implements Serializable {
private static final long serialVersionUID = -1896235499708614266L;
protected ColumnData columnData;
protected ArrayList<Expression> expressions;
protected String label1;
protected ColumnTypeCode firstSplitColumnType;
protected ColumnDataType firstSplitColumnDataType;
protected String label2;
protected ColumnTypeCode secondSplitColumnType;
protected ColumnDataType secondSplitColumnDataType;
protected boolean deleteColumn;
private ColumnData columnData;
private ArrayList<Expression> expressions;
private String label1;
private ColumnTypeCode firstSplitColumnType;
private ColumnDataType firstSplitColumnDataType;
private String label2;
private ColumnTypeCode secondSplitColumnType;
private ColumnDataType secondSplitColumnDataType;
private boolean deleteColumn;
public SplitColumnSession() {