Minor Update

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@93793 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-03-28 17:42:35 +00:00
parent c4284e6506
commit 43d260194a
4 changed files with 88 additions and 21 deletions

View File

@ -40,6 +40,7 @@ import org.gcube.data.analysis.tabulardata.commons.webservice.types.TaskStatus;
import org.gcube.data.analysis.tabulardata.commons.webservice.types.TemplateDescription;
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.metadata.NoSuchMetadataException;
import org.gcube.data.analysis.tabulardata.model.column.Column;
import org.gcube.data.analysis.tabulardata.model.column.ColumnLocalId;
@ -53,8 +54,6 @@ import org.gcube.data.analysis.tabulardata.model.column.type.DimensionColumnType
import org.gcube.data.analysis.tabulardata.model.column.type.IdColumnType;
import org.gcube.data.analysis.tabulardata.model.column.type.TimeDimensionColumnType;
import org.gcube.data.analysis.tabulardata.model.column.type.ValidationColumnType;
import org.gcube.data.analysis.tabulardata.model.datatype.value.TDInteger;
import org.gcube.data.analysis.tabulardata.model.datatype.value.TDTypeValue;
import org.gcube.data.analysis.tabulardata.model.metadata.column.ViewColumnMetadata;
import org.gcube.data.analysis.tabulardata.model.metadata.common.DescriptionsMetadata;
import org.gcube.data.analysis.tabulardata.model.metadata.common.ImmutableLocalizedText;
@ -88,10 +87,10 @@ import org.gcube.portlets.user.td.gwtservice.server.file.FileUploadSession;
import org.gcube.portlets.user.td.gwtservice.server.file.FileUtil;
import org.gcube.portlets.user.td.gwtservice.server.storage.FilesStorage;
import org.gcube.portlets.user.td.gwtservice.server.trservice.ColumnDataTypeMap;
import org.gcube.portlets.user.td.gwtservice.server.trservice.ExpressionGenerator;
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.server.trservice.QueryService;
import org.gcube.portlets.user.td.gwtservice.server.trservice.TDTypeValueMap;
import org.gcube.portlets.user.td.gwtservice.server.trservice.TaskStateMap;
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
import org.gcube.portlets.user.td.gwtservice.shared.csv.AvailableCharsetList;
@ -3000,20 +2999,19 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
OperationDefinition operationDefinition;
Map<String, Object> map = new HashMap<String, Object>();
if(replaceColumnSession.isReplaceDimension()){
logger.debug("Is a Replace of view column");
operationDefinition = OperationDefinitionMap.map(
OperationsId.ReplaceById.toString(),
OperationsId.ReplaceColumnByExpression.toString(),
capabilities);
Integer rowId=new Integer(replaceColumnSession.getRowId());
String replaceValue=replaceColumnSession.getReplaceValue();
Integer in = new Integer(replaceValue);
TDTypeValue tdValue = new TDInteger(in);
map.put(Constants.PARAMETER_REPLACE_COLUMN_VALUE, tdValue);
map.put(Constants.PARAMETER_REPLACE_COLUMN_ID, rowId);
Expression condition=ExpressionGenerator.genReplaceValueParameterCondition(replaceColumnSession);
Expression value=ExpressionGenerator.genReplaceValueParameterValue(replaceColumnSession);
map.put(Constants.PARAMETER_REPLACE_BY_EXPRESSION_COLUMN_CONDITION, condition);
map.put(Constants.PARAMETER_REPLACE_BY_EXPRESSION_COLUMN_VALUE, value);
invocation = new OperationExecution(replaceColumnSession
.getColumnData().getColumnViewData().getSourceTableDimensionColumnId(),
@ -3027,13 +3025,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
OperationsId.ReplaceById.toString(),
capabilities);
Integer rowId=new Integer(replaceColumnSession.getRowId());
String dataTypeName=replaceColumnSession.getColumnData().getDataTypeName();
String replaceValue=replaceColumnSession.getReplaceValue();
Expression condition=ExpressionGenerator.genReplaceValueParameterCondition(replaceColumnSession);
Expression value=ExpressionGenerator.genReplaceValueParameterValue(replaceColumnSession);
TDTypeValue tdValue=TDTypeValueMap.map(dataTypeName, replaceValue);
map.put(Constants.PARAMETER_REPLACE_COLUMN_VALUE, tdValue);
map.put(Constants.PARAMETER_REPLACE_COLUMN_ID, rowId);
map.put(Constants.PARAMETER_REPLACE_BY_EXPRESSION_COLUMN_CONDITION, condition);
map.put(Constants.PARAMETER_REPLACE_BY_EXPRESSION_COLUMN_VALUE, value);
invocation = new OperationExecution(replaceColumnSession
.getColumnData().getColumnId(),

View File

@ -0,0 +1,66 @@
package org.gcube.portlets.user.td.gwtservice.server.trservice;
import org.gcube.data.analysis.tabulardata.expression.Expression;
import org.gcube.data.analysis.tabulardata.expression.composite.comparable.Equals;
import org.gcube.data.analysis.tabulardata.model.column.ColumnLocalId;
import org.gcube.data.analysis.tabulardata.model.column.ColumnReference;
import org.gcube.data.analysis.tabulardata.model.datatype.value.TDInteger;
import org.gcube.data.analysis.tabulardata.model.datatype.value.TDTypeValue;
import org.gcube.data.analysis.tabulardata.model.table.TableId;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnSession;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ExpressionGenerator {
public static Expression genReplaceValueParameterCondition(
ReplaceColumnSession replaceColumnSession) throws TDGWTServiceException {
if (replaceColumnSession.isReplaceDimension()) {
// Dimension
TableId tableId = new TableId(Long.valueOf(replaceColumnSession
.getColumnData().getTrId().getTableId()));
ColumnReference cr = new ColumnReference(tableId,
new ColumnLocalId(replaceColumnSession.getColumnData()
.getColumnViewData()
.getSourceTableDimensionColumnId()));
Equals eq = new Equals(cr, new TDInteger(
Integer.parseInt(replaceColumnSession.getRowId())));
return eq;
} else {
// Simple
TableId tableId = new TableId(Long.valueOf(replaceColumnSession
.getColumnData().getTrId().getTableId()));
ColumnReference cr = new ColumnReference(tableId,
new ColumnLocalId(replaceColumnSession.getColumnData()
.getColumnId()));
TDTypeValue td=TDTypeValueMap.map(replaceColumnSession.getColumnData()
.getDataTypeName(), replaceColumnSession.getValue());
Equals eq = new Equals(cr, td);
return eq;
}
}
public static Expression genReplaceValueParameterValue(
ReplaceColumnSession replaceColumnSession) throws TDGWTServiceException {
if (replaceColumnSession.isReplaceDimension()) {
TDInteger value = new TDInteger(Integer.parseInt(replaceColumnSession
.getReplaceValue()));
return value;
} else {
TDTypeValue td=TDTypeValueMap.map(replaceColumnSession.getColumnData()
.getDataTypeName(), replaceColumnSession.getValue());
return td;
}
}
}

View File

@ -30,8 +30,12 @@ public class Constants {
public static final String PARAMETER_DATA_TYPE="dataType";
public static final String PARAMETER_TARGET_DATA_TYPE="targetDataType";
public static final String PARAMETER_REPLACE_COLUMN_VALUE="value";
public static final String PARAMETER_REPLACE_COLUMN_ID="id";
public static final String PARAMETER_REPLACE_ID_COLUMN_VALUE="value";
public static final String PARAMETER_REPLACE_ID_COLUMN_ID="id";
public static final String PARAMETER_REPLACE_BY_EXPRESSION_COLUMN_CONDITION="condition";
public static final String PARAMETER_REPLACE_BY_EXPRESSION_COLUMN_VALUE="value";
public static final String NAME_PARAMETER_ID="NAME_PARAMETER_ID";
public static final String PARAMETER_KEY="key";

View File

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