Fix EntityIdValue generation from Recon: discard nones

This commit is contained in:
Antonin Delpeuch 2018-01-14 14:53:37 +00:00
parent 22c1d5dd9b
commit 54acac491d
2 changed files with 6 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.refine.model.Cell; import com.google.refine.model.Cell;
import com.google.refine.model.Recon.Judgment;
public class WbItemVariable extends WbItemExpr { public class WbItemVariable extends WbItemExpr {
/* An item that depends on a reconciled value in a column */ /* An item that depends on a reconciled value in a column */
@ -24,7 +25,9 @@ public class WbItemVariable extends WbItemExpr {
@Override @Override
public ItemIdValue evaluate(ExpressionContext ctxt) throws SkipSchemaExpressionException { public ItemIdValue evaluate(ExpressionContext ctxt) throws SkipSchemaExpressionException {
Cell cell = ctxt.getCellByName(getColumnName()); Cell cell = ctxt.getCellByName(getColumnName());
if (cell != null && cell.recon != null) { if (cell != null && cell.recon != null
&& (Judgment.Matched.equals(cell.recon.judgment) ||
Judgment.New.equals(cell.recon.judgment))) {
return new ReconItemIdValue(cell.recon, cell.value.toString()); return new ReconItemIdValue(cell.recon, cell.value.toString());
} }
throw new SkipSchemaExpressionException(); throw new SkipSchemaExpressionException();

View File

@ -33,6 +33,8 @@ public abstract class ReconEntityIdValue implements PrefetchedEntityIdValue {
public ReconEntityIdValue(Recon match, String cellValue) { public ReconEntityIdValue(Recon match, String cellValue) {
_recon = match; _recon = match;
_cellValue = cellValue; _cellValue = cellValue;
assert (Recon.Judgment.Matched.equals(_recon.judgment) ||
Recon.Judgment.New.equals(_recon.judgment));
} }
protected boolean isMatched() { protected boolean isMatched() {