diff --git a/extensions/wikidata/src/org/openrefine/wikidata/operations/PerformWikibaseEditsOperation.java b/extensions/wikidata/src/org/openrefine/wikidata/operations/PerformWikibaseEditsOperation.java index 86f0129e1..c92433489 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/operations/PerformWikibaseEditsOperation.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/operations/PerformWikibaseEditsOperation.java @@ -88,7 +88,7 @@ public class PerformWikibaseEditsOperation extends EngineDependentOperation { @Override protected String getBriefDescription(Project project) { - return "Peform edits on Wikidata"; + return "Peform Wikibase edits"; } @Override diff --git a/extensions/wikidata/src/org/openrefine/wikidata/schema/entityvalues/PrefetchedEntityIdValue.java b/extensions/wikidata/src/org/openrefine/wikidata/schema/entityvalues/PrefetchedEntityIdValue.java index ee98c58ab..abe75df96 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/schema/entityvalues/PrefetchedEntityIdValue.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/schema/entityvalues/PrefetchedEntityIdValue.java @@ -27,6 +27,8 @@ import java.util.List; import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue; +import com.fasterxml.jackson.annotation.JsonProperty; + /** * An entity id value that also comes with a label and possibly types. * @@ -47,6 +49,7 @@ public interface PrefetchedEntityIdValue extends EntityIdValue { * * @return the preferred label of the entity */ + @JsonProperty("label") public String getLabel(); /** @@ -56,5 +59,6 @@ public interface PrefetchedEntityIdValue extends EntityIdValue { * * Empty lists should be returned for */ + @JsonProperty("types") public List getTypes(); } diff --git a/extensions/wikidata/src/org/openrefine/wikidata/schema/entityvalues/ReconEntityIdValue.java b/extensions/wikidata/src/org/openrefine/wikidata/schema/entityvalues/ReconEntityIdValue.java index f55bc3c8c..56703e9ed 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/schema/entityvalues/ReconEntityIdValue.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/schema/entityvalues/ReconEntityIdValue.java @@ -33,6 +33,7 @@ import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue; import org.wikidata.wdtk.datamodel.interfaces.ValueVisitor; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; import com.google.refine.model.Recon; @@ -72,6 +73,7 @@ public abstract class ReconEntityIdValue implements PrefetchedEntityIdValue { return !isMatched(); } + @JsonProperty("label") public String getLabel() { if (isMatched()) { return _recon.match.name; @@ -80,6 +82,7 @@ public abstract class ReconEntityIdValue implements PrefetchedEntityIdValue { } } + @JsonProperty("types") public List getTypes() { if (isMatched()) { return Arrays.asList(_recon.match.types); @@ -89,6 +92,7 @@ public abstract class ReconEntityIdValue implements PrefetchedEntityIdValue { } @Override + @JsonProperty("entityType") public abstract String getEntityType(); /** @@ -96,6 +100,7 @@ public abstract class ReconEntityIdValue implements PrefetchedEntityIdValue { * * @return the reconciliation id of the reconciled cell */ + @JsonProperty("reconInternalId") public long getReconInternalId() { return getRecon().id; } @@ -114,6 +119,7 @@ public abstract class ReconEntityIdValue implements PrefetchedEntityIdValue { * Returns the id of the reconciled item */ @Override + @JsonProperty("id") public String getId() { if (isMatched()) { return _recon.match.id; @@ -126,6 +132,7 @@ public abstract class ReconEntityIdValue implements PrefetchedEntityIdValue { } @Override + @JsonProperty("siteIri") public String getSiteIri() { if (isMatched()) { return _recon.identifierSpace; @@ -135,6 +142,7 @@ public abstract class ReconEntityIdValue implements PrefetchedEntityIdValue { } @Override + @JsonProperty("iri") public String getIri() { return getSiteIri() + getId(); } diff --git a/extensions/wikidata/src/org/openrefine/wikidata/schema/entityvalues/SuggestedEntityIdValue.java b/extensions/wikidata/src/org/openrefine/wikidata/schema/entityvalues/SuggestedEntityIdValue.java index d2b97edea..9898ec3c1 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/schema/entityvalues/SuggestedEntityIdValue.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/schema/entityvalues/SuggestedEntityIdValue.java @@ -30,6 +30,8 @@ import org.wikidata.wdtk.datamodel.helpers.Hash; import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue; import org.wikidata.wdtk.datamodel.interfaces.ValueVisitor; +import com.fasterxml.jackson.annotation.JsonProperty; + /** * An EntityIdValue that we have obtained from a suggest widget in the schema * alignment dialog. @@ -50,26 +52,31 @@ public abstract class SuggestedEntityIdValue implements PrefetchedEntityIdValue } @Override + @JsonProperty("id") public String getId() { return _id; } @Override + @JsonProperty("siteIri") public String getSiteIri() { return _siteIRI; } @Override + @JsonProperty("label") public String getLabel() { return _label; } @Override + @JsonProperty("types") public List getTypes() { return new ArrayList<>(); } @Override + @JsonProperty("iri") public String getIri() { return getSiteIri() + getId(); } diff --git a/extensions/wikidata/tests/src/org/openrefine/wikidata/testing/JacksonSerializationTest.java b/extensions/wikidata/tests/src/org/openrefine/wikidata/testing/JacksonSerializationTest.java index 9f608547a..ab61ee7cc 100644 --- a/extensions/wikidata/tests/src/org/openrefine/wikidata/testing/JacksonSerializationTest.java +++ b/extensions/wikidata/tests/src/org/openrefine/wikidata/testing/JacksonSerializationTest.java @@ -33,15 +33,17 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.refine.util.ParsingUtilities; + public class JacksonSerializationTest { - private static ObjectMapper mapper = new ObjectMapper(); + private static ObjectMapper mapper = ParsingUtilities.mapper; public static void testSerialize(Object pojo, String expectedJson) { // Test that the pojo is correctly serialized try { - String actualJson = mapper.writeValueAsString(pojo); + String actualJson = ParsingUtilities.defaultWriter.writeValueAsString(pojo); assertJsonEquals(expectedJson, actualJson); } catch (JsonProcessingException e) { e.printStackTrace();