Add explicit @JsonProperty decorators in schema classes

This commit is contained in:
Antonin Delpeuch 2018-01-12 17:27:55 +00:00
parent 93883fd777
commit 42d9ca0393
16 changed files with 34 additions and 34 deletions

View File

@ -35,6 +35,7 @@ public class WbDateVariable extends WbDateExpr {
throw new SkipSchemaExpressionException(); throw new SkipSchemaExpressionException();
} }
@JsonProperty("columnName")
public String getColumnName() { public String getColumnName() {
return columnName; return columnName;
} }

View File

@ -1,6 +1,7 @@
package org.openrefine.wikidata.schema; package org.openrefine.wikidata.schema;
import org.openrefine.wikidata.schema.entityvalues.TermedItemIdValue; import org.openrefine.wikidata.schema.entityvalues.ReconItemIdValue;
import org.openrefine.wikidata.schema.entityvalues.SuggestedItemIdValue;
import org.wikidata.wdtk.datamodel.implementation.ItemIdValueImpl; import org.wikidata.wdtk.datamodel.implementation.ItemIdValueImpl;
import org.wikidata.wdtk.datamodel.interfaces.ItemIdValue; import org.wikidata.wdtk.datamodel.interfaces.ItemIdValue;
@ -25,16 +26,18 @@ public class WbItemConstant extends WbItemExpr {
@Override @Override
public ItemIdValue evaluate(ExpressionContext ctxt) { public ItemIdValue evaluate(ExpressionContext ctxt) {
return new TermedItemIdValue( return new SuggestedItemIdValue(
qid, qid,
ctxt.getBaseIRI(), ctxt.getBaseIRI(),
label); label);
} }
@JsonProperty("qid")
public String getQid() { public String getQid() {
return qid; return qid;
} }
@JsonProperty("label")
public String getLabel() { public String getLabel() {
return label; return label;
} }

View File

@ -45,14 +45,17 @@ public class WbItemDocumentExpr extends JacksonJsonizable {
return update; return update;
} }
@JsonProperty("subject")
public WbItemExpr getSubject() { public WbItemExpr getSubject() {
return subject; return subject;
} }
@JsonProperty("nameDescs")
public List<WbNameDescExpr> getNameDescs() { public List<WbNameDescExpr> getNameDescs() {
return nameDescs; return nameDescs;
} }
@JsonProperty("statementGroups")
public List<WbStatementGroupExpr> getStatementGroups() { public List<WbStatementGroupExpr> getStatementGroups() {
return statementGroups; return statementGroups;
} }

View File

@ -1,18 +1,14 @@
package org.openrefine.wikidata.schema; package org.openrefine.wikidata.schema;
import org.openrefine.wikidata.schema.entityvalues.NewEntityIdValue; import org.openrefine.wikidata.schema.entityvalues.ReconItemIdValue;
import org.openrefine.wikidata.schema.entityvalues.TermedItemIdValue;
import org.openrefine.wikidata.schema.exceptions.SkipSchemaExpressionException; import org.openrefine.wikidata.schema.exceptions.SkipSchemaExpressionException;
import org.wikidata.wdtk.datamodel.helpers.Datamodel;
import org.wikidata.wdtk.datamodel.interfaces.ItemIdValue; import org.wikidata.wdtk.datamodel.interfaces.ItemIdValue;
import com.fasterxml.jackson.annotation.JsonCreator; 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;
import com.google.refine.model.ReconCandidate;
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 */
@ -29,29 +25,12 @@ public class WbItemVariable extends WbItemExpr {
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) {
Recon recon = cell.recon; return new ReconItemIdValue(cell.recon, cell.value.toString());
if (recon.judgment == Recon.Judgment.Matched && cell.recon.match != null) {
ReconCandidate match = cell.recon.match;
String label = match.name;
return new TermedItemIdValue(
match.id,
ctxt.getBaseIRI(),
label);
} else if (recon.judgment == Recon.Judgment.New) {
int rowId = ctxt.getRowId();
int columnId = ctxt.getCellIndexByName(getColumnName());
String siteIRI = ctxt.getBaseIRI();
String label = cell.value.toString();
if (label.isEmpty()) {
}
return new NewEntityIdValue(
rowId, columnId, siteIRI, label);
}
} }
throw new SkipSchemaExpressionException(); throw new SkipSchemaExpressionException();
} }
@JsonProperty("columnName")
public String getColumnName() { public String getColumnName() {
return columnName; return columnName;
} }

View File

@ -7,14 +7,12 @@ import com.fasterxml.jackson.annotation.JsonProperty;
public class WbLanguageConstant extends WbLanguageExpr { public class WbLanguageConstant extends WbLanguageExpr {
public static final String jsonType = "wblanguageconstant";
protected String _langId; protected String _langId;
protected String _langLabel; protected String _langLabel;
@JsonCreator @JsonCreator
public WbLanguageConstant( public WbLanguageConstant(
@JsonProperty("lang") String langId, @JsonProperty("id") String langId,
@JsonProperty("label") String langLabel) { @JsonProperty("label") String langLabel) {
_langId = langId; _langId = langId;
_langLabel = langLabel; _langLabel = langLabel;
@ -24,10 +22,12 @@ public class WbLanguageConstant extends WbLanguageExpr {
return _langId; return _langId;
} }
@JsonProperty("id")
public String getLang() { public String getLang() {
return _langId; return _langId;
} }
@JsonProperty("label")
public String getLabel() { public String getLabel() {
return _langLabel; return _langLabel;
} }

View File

@ -22,13 +22,14 @@ public class WbLanguageVariable extends WbLanguageExpr {
public String evaluate(ExpressionContext ctxt) public String evaluate(ExpressionContext ctxt)
throws SkipSchemaExpressionException { throws SkipSchemaExpressionException {
Cell cell = ctxt.getCellByName(getColumnName()); Cell cell = ctxt.getCellByName(getColumnName());
if (cell != null) { if (cell != null && cell.value != null && !cell.value.toString().isEmpty()) {
// TODO some validation here? // TODO some validation here?
return cell.value.toString(); return cell.value.toString();
} }
throw new SkipSchemaExpressionException(); throw new SkipSchemaExpressionException();
} }
@JsonProperty("columnName")
public String getColumnName() { public String getColumnName() {
return columnName; return columnName;
} }

View File

@ -55,6 +55,7 @@ public class WbLocationConstant extends WbLocationExpr {
return parsed; return parsed;
} }
@JsonProperty("value")
public String getValue() { public String getValue() {
return value; return value;
} }

View File

@ -35,6 +35,7 @@ public class WbLocationVariable extends WbLocationExpr {
throw new SkipSchemaExpressionException(); throw new SkipSchemaExpressionException();
} }
@JsonProperty("columnName")
public String getColumnName() { public String getColumnName() {
return columnName; return columnName;
} }

View File

@ -51,6 +51,7 @@ public class WbNameDescExpr extends JacksonJsonizable {
return type; return type;
} }
@JsonProperty("value")
public WbMonolingualExpr getValue() { public WbMonolingualExpr getValue() {
return value; return value;
} }

View File

@ -1,7 +1,6 @@
package org.openrefine.wikidata.schema; package org.openrefine.wikidata.schema;
import org.openrefine.wikidata.schema.entityvalues.TermedPropertyIdValue; import org.openrefine.wikidata.schema.entityvalues.SuggestedPropertyIdValue;
import org.wikidata.wdtk.datamodel.implementation.PropertyIdValueImpl;
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue; import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
@ -27,18 +26,20 @@ public class WbPropConstant extends WbPropExpr {
@Override @Override
public PropertyIdValue evaluate(ExpressionContext ctxt) { public PropertyIdValue evaluate(ExpressionContext ctxt) {
return new TermedPropertyIdValue(pid, ctxt.getBaseIRI(), label); return new SuggestedPropertyIdValue(pid, ctxt.getBaseIRI(), label);
} }
@JsonProperty("pid")
public String getPid() { public String getPid() {
return pid; return pid;
} }
@JsonProperty("label")
public String getLabel() { public String getLabel() {
return label; return label;
} }
@JsonProperty("datatype")
public String getDatatype() { public String getDatatype() {
return datatype; return datatype;
} }

View File

@ -41,6 +41,7 @@ public class WbReferenceExpr extends JacksonJsonizable {
} }
} }
@JsonProperty("snaks")
public List<WbSnakExpr> getSnaks() { public List<WbSnakExpr> getSnaks() {
return snakExprs; return snakExprs;
} }

View File

@ -30,10 +30,12 @@ public class WbSnakExpr extends JacksonJsonizable {
return Datamodel.makeValueSnak(propertyId, evaluatedValue); return Datamodel.makeValueSnak(propertyId, evaluatedValue);
} }
@JsonProperty("prop")
public WbPropExpr getProp() { public WbPropExpr getProp() {
return prop; return prop;
} }
@JsonProperty("value")
public WbValueExpr getValue() { public WbValueExpr getValue() {
return value; return value;
} }

View File

@ -103,10 +103,12 @@ public class WbStatementExpr extends JacksonJsonizable {
return mainSnakValueExpr; return mainSnakValueExpr;
} }
@JsonProperty("qualifiers")
public List<WbSnakExpr> getQualifiers() { public List<WbSnakExpr> getQualifiers() {
return qualifierExprs; return qualifierExprs;
} }
@JsonProperty("references")
public List<WbReferenceExpr> getReferences() { public List<WbReferenceExpr> getReferences() {
return referenceExprs; return referenceExprs;
} }

View File

@ -45,10 +45,12 @@ public class WbStatementGroupExpr extends JacksonJsonizable {
} }
} }
@JsonProperty("property")
public WbPropExpr getProperty() { public WbPropExpr getProperty() {
return propertyExpr; return propertyExpr;
} }
@JsonProperty("statements")
public List<WbStatementExpr> getStatements() { public List<WbStatementExpr> getStatements() {
return statementExprs; return statementExprs;
} }

View File

@ -21,6 +21,7 @@ public class WbStringConstant extends WbStringExpr {
return Datamodel.makeStringValue(value); return Datamodel.makeStringValue(value);
} }
@JsonProperty("value")
public String getValue() { public String getValue() {
return value; return value;
} }

View File

@ -30,6 +30,7 @@ public class WbStringVariable extends WbStringExpr {
throw new SkipSchemaExpressionException(); throw new SkipSchemaExpressionException();
} }
@JsonProperty("columnName")
public String getColumnName() { public String getColumnName() {
return columnName; return columnName;
} }