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();
}
@JsonProperty("columnName")
public String getColumnName() {
return columnName;
}

View File

@ -1,6 +1,7 @@
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.interfaces.ItemIdValue;
@ -25,16 +26,18 @@ public class WbItemConstant extends WbItemExpr {
@Override
public ItemIdValue evaluate(ExpressionContext ctxt) {
return new TermedItemIdValue(
return new SuggestedItemIdValue(
qid,
ctxt.getBaseIRI(),
label);
}
@JsonProperty("qid")
public String getQid() {
return qid;
}
@JsonProperty("label")
public String getLabel() {
return label;
}

View File

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

View File

@ -1,18 +1,14 @@
package org.openrefine.wikidata.schema;
import org.openrefine.wikidata.schema.entityvalues.NewEntityIdValue;
import org.openrefine.wikidata.schema.entityvalues.TermedItemIdValue;
import org.openrefine.wikidata.schema.entityvalues.ReconItemIdValue;
import org.openrefine.wikidata.schema.exceptions.SkipSchemaExpressionException;
import org.wikidata.wdtk.datamodel.helpers.Datamodel;
import org.wikidata.wdtk.datamodel.interfaces.ItemIdValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.refine.model.Cell;
import com.google.refine.model.Recon;
import com.google.refine.model.ReconCandidate;
public class WbItemVariable extends WbItemExpr {
/* 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 {
Cell cell = ctxt.getCellByName(getColumnName());
if (cell != null && cell.recon != null) {
Recon recon = cell.recon;
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);
}
return new ReconItemIdValue(cell.recon, cell.value.toString());
}
throw new SkipSchemaExpressionException();
}
@JsonProperty("columnName")
public String getColumnName() {
return columnName;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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