diff --git a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbDateVariable.java b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbDateVariable.java index 4edd57448..ec8c2a3eb 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbDateVariable.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbDateVariable.java @@ -35,6 +35,7 @@ public class WbDateVariable extends WbDateExpr { throw new SkipSchemaExpressionException(); } + @JsonProperty("columnName") public String getColumnName() { return columnName; } diff --git a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbItemConstant.java b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbItemConstant.java index abcbed58b..45c58c78e 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbItemConstant.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbItemConstant.java @@ -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; } diff --git a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbItemDocumentExpr.java b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbItemDocumentExpr.java index ed79d9f72..6362af3b1 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbItemDocumentExpr.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbItemDocumentExpr.java @@ -45,14 +45,17 @@ public class WbItemDocumentExpr extends JacksonJsonizable { return update; } + @JsonProperty("subject") public WbItemExpr getSubject() { return subject; } + @JsonProperty("nameDescs") public List getNameDescs() { return nameDescs; } + @JsonProperty("statementGroups") public List getStatementGroups() { return statementGroups; } diff --git a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbItemVariable.java b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbItemVariable.java index ae50ec320..9eebde938 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbItemVariable.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbItemVariable.java @@ -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; } diff --git a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbLanguageConstant.java b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbLanguageConstant.java index 2b3777d10..8fda71222 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbLanguageConstant.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbLanguageConstant.java @@ -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; } diff --git a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbLanguageVariable.java b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbLanguageVariable.java index be3b65492..e64e6917f 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbLanguageVariable.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbLanguageVariable.java @@ -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; } diff --git a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbLocationConstant.java b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbLocationConstant.java index e80867641..f45329a3f 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbLocationConstant.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbLocationConstant.java @@ -55,6 +55,7 @@ public class WbLocationConstant extends WbLocationExpr { return parsed; } + @JsonProperty("value") public String getValue() { return value; } diff --git a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbLocationVariable.java b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbLocationVariable.java index be4e8c15d..f1c7bdc7d 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbLocationVariable.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbLocationVariable.java @@ -35,6 +35,7 @@ public class WbLocationVariable extends WbLocationExpr { throw new SkipSchemaExpressionException(); } + @JsonProperty("columnName") public String getColumnName() { return columnName; } diff --git a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbNameDescExpr.java b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbNameDescExpr.java index 26eb196c8..10e689b43 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbNameDescExpr.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbNameDescExpr.java @@ -51,6 +51,7 @@ public class WbNameDescExpr extends JacksonJsonizable { return type; } + @JsonProperty("value") public WbMonolingualExpr getValue() { return value; } diff --git a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbPropConstant.java b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbPropConstant.java index 4da1cfa06..5fa3c530c 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbPropConstant.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbPropConstant.java @@ -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; } diff --git a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbReferenceExpr.java b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbReferenceExpr.java index 22e3fffc7..646da1b20 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbReferenceExpr.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbReferenceExpr.java @@ -41,6 +41,7 @@ public class WbReferenceExpr extends JacksonJsonizable { } } + @JsonProperty("snaks") public List getSnaks() { return snakExprs; } diff --git a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbSnakExpr.java b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbSnakExpr.java index 27ab015d3..f82cccffa 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbSnakExpr.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbSnakExpr.java @@ -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; } diff --git a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbStatementExpr.java b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbStatementExpr.java index 070e636a5..6e40130cc 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbStatementExpr.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbStatementExpr.java @@ -103,10 +103,12 @@ public class WbStatementExpr extends JacksonJsonizable { return mainSnakValueExpr; } + @JsonProperty("qualifiers") public List getQualifiers() { return qualifierExprs; } + @JsonProperty("references") public List getReferences() { return referenceExprs; } diff --git a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbStatementGroupExpr.java b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbStatementGroupExpr.java index 7f446ec90..d5d619c71 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbStatementGroupExpr.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbStatementGroupExpr.java @@ -45,10 +45,12 @@ public class WbStatementGroupExpr extends JacksonJsonizable { } } + @JsonProperty("property") public WbPropExpr getProperty() { return propertyExpr; } + @JsonProperty("statements") public List getStatements() { return statementExprs; } diff --git a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbStringConstant.java b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbStringConstant.java index 8c57ed308..e05f76adb 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbStringConstant.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbStringConstant.java @@ -21,6 +21,7 @@ public class WbStringConstant extends WbStringExpr { return Datamodel.makeStringValue(value); } + @JsonProperty("value") public String getValue() { return value; } diff --git a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbStringVariable.java b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbStringVariable.java index 5938a0017..6989189ad 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbStringVariable.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbStringVariable.java @@ -30,6 +30,7 @@ public class WbStringVariable extends WbStringExpr { throw new SkipSchemaExpressionException(); } + @JsonProperty("columnName") public String getColumnName() { return columnName; }