Ignore unknown fields in schema JSON deserialization

This commit is contained in:
Antonin Delpeuch 2018-01-31 11:48:30 +00:00
parent 8b1869414d
commit fffd31382e
5 changed files with 12 additions and 9 deletions

View File

@ -4,9 +4,10 @@ import org.openrefine.wikidata.schema.exceptions.SkipSchemaExpressionException;
import org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue; import org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
public class WbNameDescExpr { public class WbNameDescExpr {
enum NameDescrType { enum NameDescrType {

View File

@ -10,10 +10,11 @@ import org.wikidata.wdtk.datamodel.interfaces.Snak;
import org.wikidata.wdtk.datamodel.interfaces.SnakGroup; import org.wikidata.wdtk.datamodel.interfaces.SnakGroup;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
public class WbReferenceExpr implements WbExpression<Reference> { public class WbReferenceExpr {
private List<WbSnakExpr> snakExprs; private List<WbSnakExpr> snakExprs;
@JsonCreator @JsonCreator
@ -22,7 +23,6 @@ public class WbReferenceExpr implements WbExpression<Reference> {
this.snakExprs = snakExprs; this.snakExprs = snakExprs;
} }
@Override
public Reference evaluate(ExpressionContext ctxt) throws SkipSchemaExpressionException { public Reference evaluate(ExpressionContext ctxt) throws SkipSchemaExpressionException {
List<SnakGroup> snakGroups = new ArrayList<SnakGroup>(); List<SnakGroup> snakGroups = new ArrayList<SnakGroup>();
for (WbSnakExpr expr : getSnaks()) { for (WbSnakExpr expr : getSnaks()) {

View File

@ -7,10 +7,11 @@ import org.wikidata.wdtk.datamodel.interfaces.Snak;
import org.wikidata.wdtk.datamodel.interfaces.Value; import org.wikidata.wdtk.datamodel.interfaces.Value;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
public class WbSnakExpr implements WbExpression<Snak> { public class WbSnakExpr {
private WbExpression<? extends PropertyIdValue> prop; private WbExpression<? extends PropertyIdValue> prop;
private WbExpression<? extends Value> value; private WbExpression<? extends Value> value;
@ -23,7 +24,6 @@ public class WbSnakExpr implements WbExpression<Snak> {
this.value = valueExpr; this.value = valueExpr;
} }
@Override
public Snak evaluate(ExpressionContext ctxt) throws SkipSchemaExpressionException { public Snak evaluate(ExpressionContext ctxt) throws SkipSchemaExpressionException {
PropertyIdValue propertyId = getProp().evaluate(ctxt); PropertyIdValue propertyId = getProp().evaluate(ctxt);
Value evaluatedValue = value.evaluate(ctxt); Value evaluatedValue = value.evaluate(ctxt);

View File

@ -17,9 +17,10 @@ import org.wikidata.wdtk.datamodel.interfaces.StatementRank;
import org.wikidata.wdtk.datamodel.interfaces.Value; import org.wikidata.wdtk.datamodel.interfaces.Value;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
public class WbStatementExpr { public class WbStatementExpr {
private WbExpression<? extends Value> mainSnakValueExpr; private WbExpression<? extends Value> mainSnakValueExpr;

View File

@ -11,9 +11,10 @@ import org.wikidata.wdtk.datamodel.interfaces.Statement;
import org.wikidata.wdtk.datamodel.interfaces.StatementGroup; import org.wikidata.wdtk.datamodel.interfaces.StatementGroup;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties(ignoreUnknown = true)
public class WbStatementGroupExpr { public class WbStatementGroupExpr {
private WbExpression<? extends PropertyIdValue> propertyExpr; private WbExpression<? extends PropertyIdValue> propertyExpr;