In column addition and text transform operations, for expressions that evaluate to cells or wrapped cells, use the whole cells as the result cells. This effectively copies their recon objects as well.
git-svn-id: http://google-refine.googlecode.com/svn/trunk@568 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
c56a578166
commit
cf01dcd965
@ -15,6 +15,7 @@ import com.metaweb.gridworks.browsing.RowVisitor;
|
||||
import com.metaweb.gridworks.expr.Evaluable;
|
||||
import com.metaweb.gridworks.expr.ExpressionUtils;
|
||||
import com.metaweb.gridworks.expr.MetaParser;
|
||||
import com.metaweb.gridworks.expr.WrappedCell;
|
||||
import com.metaweb.gridworks.history.Change;
|
||||
import com.metaweb.gridworks.history.HistoryEntry;
|
||||
import com.metaweb.gridworks.model.AbstractOperation;
|
||||
@ -136,10 +137,18 @@ public class ColumnAdditionOperation extends EngineDependentOperation {
|
||||
|
||||
public boolean visit(Project project, int rowIndex, Row row, boolean includeContextual, boolean includeDependent) {
|
||||
Cell cell = row.getCell(cellIndex);
|
||||
Cell newCell = null;
|
||||
|
||||
ExpressionUtils.bind(bindings, row, rowIndex, _baseColumnName, cell);
|
||||
|
||||
Serializable v = ExpressionUtils.wrapStorable(eval.evaluate(bindings));
|
||||
Object o = eval.evaluate(bindings);
|
||||
if (o != null) {
|
||||
if (o instanceof Cell) {
|
||||
newCell = (Cell) o;
|
||||
} else if (o instanceof WrappedCell) {
|
||||
newCell = ((WrappedCell) o).cell;
|
||||
} else {
|
||||
Serializable v = ExpressionUtils.wrapStorable(o);
|
||||
if (ExpressionUtils.isError(v)) {
|
||||
if (_onError == OnError.SetToBlank) {
|
||||
return false;
|
||||
@ -149,8 +158,12 @@ public class ColumnAdditionOperation extends EngineDependentOperation {
|
||||
}
|
||||
|
||||
if (v != null) {
|
||||
Cell newCell = new Cell(v, null);
|
||||
newCell = new Cell(v, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (newCell != null) {
|
||||
cellsAtRows.add(new CellAtRow(rowIndex, newCell));
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ import com.metaweb.gridworks.browsing.RowVisitor;
|
||||
import com.metaweb.gridworks.expr.Evaluable;
|
||||
import com.metaweb.gridworks.expr.ExpressionUtils;
|
||||
import com.metaweb.gridworks.expr.MetaParser;
|
||||
import com.metaweb.gridworks.expr.WrappedCell;
|
||||
import com.metaweb.gridworks.model.AbstractOperation;
|
||||
import com.metaweb.gridworks.model.Cell;
|
||||
import com.metaweb.gridworks.model.Column;
|
||||
@ -120,11 +121,20 @@ public class TextTransformOperation extends EngineDependentMassCellOperation {
|
||||
|
||||
public boolean visit(Project project, int rowIndex, Row row, boolean includeContextual, boolean includeDependent) {
|
||||
Cell cell = row.getCell(cellIndex);
|
||||
Cell newCell = null;
|
||||
|
||||
Object oldValue = cell != null ? cell.value : null;
|
||||
|
||||
ExpressionUtils.bind(bindings, row, rowIndex, _columnName, cell);
|
||||
|
||||
Serializable newValue = ExpressionUtils.wrapStorable(eval.evaluate(bindings));
|
||||
Object o = eval.evaluate(bindings);
|
||||
if (o != null) {
|
||||
if (o instanceof Cell) {
|
||||
newCell = (Cell) o;
|
||||
} else if (o instanceof WrappedCell) {
|
||||
newCell = ((WrappedCell) o).cell;
|
||||
} else {
|
||||
Serializable newValue = ExpressionUtils.wrapStorable(o);
|
||||
if (ExpressionUtils.isError(newValue)) {
|
||||
if (_onError == OnError.KeepOriginal) {
|
||||
return false;
|
||||
@ -134,7 +144,7 @@ public class TextTransformOperation extends EngineDependentMassCellOperation {
|
||||
}
|
||||
|
||||
if (!ExpressionUtils.sameValue(oldValue, newValue)) {
|
||||
Cell newCell = new Cell(newValue, (cell != null) ? cell.recon : null);
|
||||
newCell = new Cell(newValue, (cell != null) ? cell.recon : null);
|
||||
|
||||
if (_repeat) {
|
||||
for (int i = 0; i < _repeatCount; i++) {
|
||||
@ -150,10 +160,14 @@ public class TextTransformOperation extends EngineDependentMassCellOperation {
|
||||
newCell = new Cell(newValue, newCell.recon);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (newCell != null) {
|
||||
CellChange cellChange = new CellChange(rowIndex, cellIndex, cell, newCell);
|
||||
cellChanges.add(cellChange);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user