Fix serialization issues in Wikidata extension
This commit is contained in:
parent
f6fc47a8f9
commit
bd5a8f9ece
@ -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
|
||||
|
@ -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<String> getTypes();
|
||||
}
|
||||
|
@ -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<String> 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();
|
||||
}
|
||||
|
@ -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<String> getTypes() {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonProperty("iri")
|
||||
public String getIri() {
|
||||
return getSiteIri() + getId();
|
||||
}
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user