Updated AddColumn

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@113838 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-03-31 16:06:16 +00:00
parent adf762d5ad
commit b40d1ace03
5 changed files with 108 additions and 49 deletions

View File

@ -17,7 +17,6 @@ import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.portlets.user.td.gwtservice.server.file.CSVFileUploadSession;
import org.gcube.portlets.user.td.gwtservice.server.file.CodelistMappingFileUploadSession;
import org.gcube.portlets.user.td.gwtservice.server.trservice.TRTasksManager;
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
import org.gcube.portlets.user.td.gwtservice.shared.chart.ChartTopRatingSession;
import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
@ -88,10 +87,10 @@ public class SessionUtil {
ASLSession session;
if (username == null) {
logger.warn("no user found in session, using test one");
/*throw new TDGWTSessionExpiredException("Session Expired!"); */
throw new TDGWTSessionExpiredException("Session Expired!");
// Remove comment for Test
/*
username = Constants.DEFAULT_USER;
String scope = Constants.DEFAULT_SCOPE;
@ -99,7 +98,7 @@ public class SessionUtil {
session = SessionManager.getInstance().getASLSession(
httpSession.getId(), username);
session.setScope(scope);
*/
} else {
session = SessionManager.getInstance().getASLSession(
httpSession.getId(), username);

View File

@ -5256,14 +5256,10 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
/**
*
* {@inheritDoc}
*/
public String startAddColumn(AddColumnSession addColumnSession)
public String startAddColumn(AddColumnSession addColumnSession,
Expression expression, HttpSession session)
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.setAddColumnSession(session, addColumnSession);
ASLSession aslSession = SessionUtil.getAslSession(session);
@ -5282,7 +5278,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
checkTabularResourceIsFinal(tabularResource);
OpExecution4AddColumn opEx = new OpExecution4AddColumn(service,
addColumnSession);
addColumnSession,expression);
OpExecutionDirector director = new OpExecutionDirector();
director.setOperationExecutionBuilder(opEx);
director.constructOperationExecution();
@ -5300,9 +5296,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
TaskWrapper taskWrapper = new TaskWrapper(trTask,
UIOperationsId.AddColumn, addColumnSession.getTrId());
SessionUtil.setStartedTask(session, taskWrapper);
return trTask.getId().getValue();
} catch (TDGWTServiceException e) {
throw e;
} catch (SecurityException e) {
@ -5316,6 +5310,17 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
/**
*
* {@inheritDoc}
*/
@Override
public String startAddColumn(AddColumnSession addColumnSession)
throws TDGWTServiceException {
HttpSession session = this.getThreadLocalRequest().getSession();
return startAddColumn(addColumnSession,null,session);
}
/**
*
* {@inheritDoc}

View File

@ -5,6 +5,7 @@ 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.model.metadata.common.ImmutableLocalizedText;
import org.gcube.data.analysis.tabulardata.service.TabularDataService;
import org.gcube.portlets.user.td.gwtservice.server.trservice.ColumnDataTypeMap;
@ -34,11 +35,13 @@ public class OpExecution4AddColumn extends OpExecutionBuilder {
private TabularDataService service;
private AddColumnSession addColumnSession;
private Expression expression;
public OpExecution4AddColumn(TabularDataService service,
AddColumnSession addColumnSession) {
AddColumnSession addColumnSession, Expression expression) {
this.service = service;
this.addColumnSession = addColumnSession;
this.expression = expression;
}
@Override
@ -52,12 +55,10 @@ public class OpExecution4AddColumn extends OpExecutionBuilder {
Map<String, Object> map = new HashMap<String, Object>();
ColumnMockUp defNewColumn = addColumnSession.getColumn();
ColumnMockUp defNewColumn = addColumnSession.getColumnMockUp();
ColumnTypeCode type = defNewColumn.getColumnType();
switch (type) {
case ANNOTATION:
map.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE,
@ -67,9 +68,19 @@ public class OpExecution4AddColumn extends OpExecutionBuilder {
ColumnDataTypeMap.map(ColumnDataType.Text));
map.put(Constants.PARAMETER_ADD_COLUMN_LABEL,
new ImmutableLocalizedText(defNewColumn.getLabel()));
map.put(Constants.PARAMETER_ADD_COLUMN_VALUE,
TDTypeValueMap.map(ColumnDataType.Text,
defNewColumn.getDefaultValue()));
if (defNewColumn.hasExpression()) {
map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, expression);
} else {
if (defNewColumn.getDefaultValue() != null
&& !defNewColumn.getDefaultValue().isEmpty()) {
map.put(Constants.PARAMETER_ADD_COLUMN_VALUE,
TDTypeValueMap.map(ColumnDataType.Text,
defNewColumn.getDefaultValue()));
}
}
invocation = new OperationExecution(
operationDefinition.getOperationId(), map);
break;
@ -77,13 +88,21 @@ public class OpExecution4AddColumn extends OpExecutionBuilder {
map.put(Constants.PARAMETER_ADD_COLUMN_COLUMN_TYPE,
ColumnTypeCodeMap.getColumnType(defNewColumn
.getColumnType()));
map.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE,
map.put(Constants.PARAMETER_ADD_COLUMN_DATA_TYPE,
ColumnDataTypeMap.map(defNewColumn.getColumnDataType()));
map.put(Constants.PARAMETER_ADD_COLUMN_LABEL,
new ImmutableLocalizedText(defNewColumn.getLabel()));
map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, TDTypeValueMap.map(
defNewColumn.getColumnDataType(),
defNewColumn.getDefaultValue()));
if (defNewColumn.hasExpression()) {
map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, expression);
} else {
if (defNewColumn.getDefaultValue() != null
&& !defNewColumn.getDefaultValue().isEmpty()) {
map.put(Constants.PARAMETER_ADD_COLUMN_VALUE,
TDTypeValueMap.map(
defNewColumn.getColumnDataType(),
defNewColumn.getDefaultValue()));
}
}
invocation = new OperationExecution(
operationDefinition.getOperationId(), map);
break;
@ -95,9 +114,16 @@ public class OpExecution4AddColumn extends OpExecutionBuilder {
ColumnDataTypeMap.map(ColumnDataType.Text));
map.put(Constants.PARAMETER_ADD_COLUMN_LABEL,
new ImmutableLocalizedText(defNewColumn.getLabel()));
map.put(Constants.PARAMETER_ADD_COLUMN_VALUE,
TDTypeValueMap.map(ColumnDataType.Text,
defNewColumn.getDefaultValue()));
if (defNewColumn.hasExpression()) {
map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, expression);
} else {
if (defNewColumn.getDefaultValue() != null
&& !defNewColumn.getDefaultValue().isEmpty()) {
map.put(Constants.PARAMETER_ADD_COLUMN_VALUE,
TDTypeValueMap.map(ColumnDataType.Text,
defNewColumn.getDefaultValue()));
}
}
invocation = new OperationExecution(
operationDefinition.getOperationId(), map);
break;
@ -109,9 +135,16 @@ public class OpExecution4AddColumn extends OpExecutionBuilder {
ColumnDataTypeMap.map(ColumnDataType.Text));
map.put(Constants.PARAMETER_ADD_COLUMN_LABEL,
new ImmutableLocalizedText(defNewColumn.getLabel()));
map.put(Constants.PARAMETER_ADD_COLUMN_VALUE,
TDTypeValueMap.map(ColumnDataType.Text,
defNewColumn.getDefaultValue()));
if (defNewColumn.hasExpression()) {
map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, expression);
} else {
if (defNewColumn.getDefaultValue() != null
&& !defNewColumn.getDefaultValue().isEmpty()) {
map.put(Constants.PARAMETER_ADD_COLUMN_VALUE,
TDTypeValueMap.map(ColumnDataType.Text,
defNewColumn.getDefaultValue()));
}
}
invocation = new OperationExecution(
operationDefinition.getOperationId(), map);
break;
@ -123,9 +156,13 @@ public class OpExecution4AddColumn extends OpExecutionBuilder {
ColumnDataTypeMap.map(ColumnDataType.Text));
map.put(Constants.PARAMETER_ADD_COLUMN_LABEL,
new ImmutableLocalizedText(defNewColumn.getLabel()));
map.put(Constants.PARAMETER_ADD_COLUMN_VALUE,
TDTypeValueMap.map(ColumnDataType.Text,
defNewColumn.getDefaultValue()));
if (defNewColumn.hasExpression()) {
map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, expression);
} else {
map.put(Constants.PARAMETER_ADD_COLUMN_VALUE,
TDTypeValueMap.map(ColumnDataType.Text,
defNewColumn.getDefaultValue()));
}
invocation = new OperationExecution(
operationDefinition.getOperationId(), map);
break;
@ -139,9 +176,18 @@ public class OpExecution4AddColumn extends OpExecutionBuilder {
ColumnDataTypeMap.map(defNewColumn.getColumnDataType()));
map.put(Constants.PARAMETER_ADD_COLUMN_LABEL,
new ImmutableLocalizedText(defNewColumn.getLabel()));
map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, TDTypeValueMap.map(
defNewColumn.getColumnDataType(),
defNewColumn.getDefaultValue()));
if (defNewColumn.hasExpression()) {
map.put(Constants.PARAMETER_ADD_COLUMN_VALUE, expression);
} else {
if (defNewColumn.getDefaultValue() != null
&& !defNewColumn.getDefaultValue().isEmpty()) {
map.put(Constants.PARAMETER_ADD_COLUMN_VALUE,
TDTypeValueMap.map(
defNewColumn.getColumnDataType(),
defNewColumn.getDefaultValue()));
}
}
invocation = new OperationExecution(
operationDefinition.getOperationId(), map);
break;
@ -152,7 +198,6 @@ public class OpExecution4AddColumn extends OpExecutionBuilder {
}
operationExecutionSpec.setOp(invocation);
}

View File

@ -298,7 +298,7 @@ public class ColumnMockUp implements Serializable {
this.id = id;
}
public boolean isHasExpression() {
public boolean hasExpression() {
return hasExpression;
}

View File

@ -16,38 +16,48 @@ public class AddColumnSession implements Serializable {
private static final long serialVersionUID = -1896235499708614266L;
private TRId trId;
private ColumnMockUp column;
private ColumnMockUp columnMockUp;
public AddColumnSession(){
super();
}
public AddColumnSession(TRId trId,ColumnMockUp column){
this.trId=trId;
this.column=column;
public AddColumnSession(TRId trId, ColumnMockUp columnMockUp) {
super();
this.trId = trId;
this.columnMockUp = columnMockUp;
}
public TRId getTrId() {
return trId;
}
public void setTrId(TRId trId) {
this.trId = trId;
}
public ColumnMockUp getColumn() {
return column;
public ColumnMockUp getColumnMockUp() {
return columnMockUp;
}
public void setColumn(ColumnMockUp column) {
this.column = column;
public void setColumnMockUp(ColumnMockUp columnMockUp) {
this.columnMockUp = columnMockUp;
}
@Override
public String toString() {
return "AddColumnSession [trId=" + trId + ", column=" + column + "]";
return "AddColumnSession [trId=" + trId + ", columnMockUp="
+ columnMockUp + "]";
}
}