Make WbItemDocumentExpr extend EntityIdValue instead of ItemIdValue (#4305)
For #4268 Co-authored-by: Antonin Delpeuch <antonin@delpeuch.eu>
This commit is contained in:
parent
b0432e5397
commit
cbbad4273b
@ -30,6 +30,7 @@ import org.jsoup.helper.Validate;
|
||||
import org.openrefine.wikidata.schema.exceptions.SkipSchemaExpressionException;
|
||||
import org.openrefine.wikidata.updates.TermedStatementEntityUpdate;
|
||||
import org.openrefine.wikidata.updates.ItemUpdateBuilder;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.ItemIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Statement;
|
||||
|
||||
@ -49,12 +50,12 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NONE)
|
||||
public class WbItemDocumentExpr implements WbExpression<TermedStatementEntityUpdate> {
|
||||
|
||||
private WbExpression<? extends ItemIdValue> subject;
|
||||
private WbExpression<? extends EntityIdValue> subject;
|
||||
private List<WbNameDescExpr> nameDescs;
|
||||
private List<WbStatementGroupExpr> statementGroups;
|
||||
|
||||
@JsonCreator
|
||||
public WbItemDocumentExpr(@JsonProperty("subject") WbExpression<? extends ItemIdValue> subjectExpr,
|
||||
public WbItemDocumentExpr(@JsonProperty("subject") WbExpression<? extends EntityIdValue> subjectExpr,
|
||||
@JsonProperty("nameDescs") List<WbNameDescExpr> nameDescExprs,
|
||||
@JsonProperty("statementGroups") List<WbStatementGroupExpr> statementGroupExprs) {
|
||||
Validate.notNull(subjectExpr);
|
||||
@ -72,7 +73,7 @@ public class WbItemDocumentExpr implements WbExpression<TermedStatementEntityUpd
|
||||
@Override
|
||||
public TermedStatementEntityUpdate evaluate(ExpressionContext ctxt)
|
||||
throws SkipSchemaExpressionException {
|
||||
ItemIdValue subjectId = getSubject().evaluate(ctxt);
|
||||
EntityIdValue subjectId = getSubject().evaluate(ctxt);
|
||||
ItemUpdateBuilder update = new ItemUpdateBuilder(subjectId);
|
||||
for (WbStatementGroupExpr expr : getStatementGroups()) {
|
||||
try {
|
||||
@ -90,7 +91,7 @@ public class WbItemDocumentExpr implements WbExpression<TermedStatementEntityUpd
|
||||
}
|
||||
|
||||
@JsonProperty("subject")
|
||||
public WbExpression<? extends ItemIdValue> getSubject() {
|
||||
public WbExpression<? extends EntityIdValue> getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,7 @@ import org.openrefine.wikidata.qa.QAWarning;
|
||||
import org.openrefine.wikidata.schema.exceptions.SkipSchemaExpressionException;
|
||||
import org.wikidata.wdtk.datamodel.helpers.Datamodel;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Claim;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.ItemIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Reference;
|
||||
@ -90,7 +91,7 @@ public class WbStatementExpr {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public Statement evaluate(ExpressionContext ctxt, ItemIdValue subject, PropertyIdValue propertyId)
|
||||
public Statement evaluate(ExpressionContext ctxt, EntityIdValue subject, PropertyIdValue propertyId)
|
||||
throws SkipSchemaExpressionException {
|
||||
Value mainSnakValue = getMainsnak().evaluate(ctxt);
|
||||
Snak mainSnak = Datamodel.makeValueSnak(propertyId, mainSnakValue);
|
||||
|
@ -30,7 +30,7 @@ import java.util.List;
|
||||
import org.jsoup.helper.Validate;
|
||||
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.EntityIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Statement;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.StatementGroup;
|
||||
@ -55,7 +55,7 @@ public class WbStatementGroupExpr {
|
||||
this.statementExprs = claimExprs;
|
||||
}
|
||||
|
||||
public StatementGroup evaluate(ExpressionContext ctxt, ItemIdValue subject)
|
||||
public StatementGroup evaluate(ExpressionContext ctxt, EntityIdValue subject)
|
||||
throws SkipSchemaExpressionException {
|
||||
PropertyIdValue propertyId = propertyExpr.evaluate(ctxt);
|
||||
List<Statement> statements = new ArrayList<Statement>(statementExprs.size());
|
||||
|
@ -32,6 +32,7 @@ import org.openrefine.wikidata.updates.ItemUpdateBuilder;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
import org.wikidata.wdtk.datamodel.helpers.Datamodel;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.ItemIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Statement;
|
||||
@ -39,7 +40,7 @@ import org.wikidata.wdtk.datamodel.interfaces.Statement;
|
||||
public class WbItemDocumentExprTest extends WbExpressionTest<TermedStatementEntityUpdate> {
|
||||
|
||||
public WbItemDocumentExpr expr;
|
||||
ItemIdValue subject = Datamodel.makeWikidataItemIdValue("Q23");
|
||||
EntityIdValue subject = Datamodel.makeWikidataItemIdValue("Q23");
|
||||
MonolingualTextValue alias = Datamodel.makeMonolingualTextValue("my alias", "en");
|
||||
Statement fullStatement;
|
||||
|
||||
|
@ -36,8 +36,8 @@ import org.openrefine.wikidata.testing.JacksonSerializationTest;
|
||||
import org.testng.annotations.Test;
|
||||
import org.wikidata.wdtk.datamodel.helpers.Datamodel;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Claim;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.GlobeCoordinatesValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.ItemIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Reference;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Snak;
|
||||
@ -63,7 +63,7 @@ public class WbStatementExprTest extends WbExpressionTest<Statement> {
|
||||
Arrays.asList(qualifierExpr, constantQualifierExpr),
|
||||
Collections.singletonList(refExpr));
|
||||
|
||||
public ItemIdValue subject = Datamodel.makeWikidataItemIdValue("Q23");
|
||||
public EntityIdValue subject = Datamodel.makeWikidataItemIdValue("Q23");
|
||||
private PropertyIdValue property = Datamodel.makeWikidataPropertyIdValue("P908");
|
||||
private Reference reference = Datamodel.makeReference(Collections.singletonList(Datamodel.makeSnakGroup(
|
||||
Collections.singletonList(Datamodel.makeValueSnak(Datamodel.makeWikidataPropertyIdValue("P43"),
|
||||
|
@ -31,7 +31,7 @@ import org.openrefine.wikidata.testing.JacksonSerializationTest;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
import org.wikidata.wdtk.datamodel.helpers.Datamodel;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.ItemIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.StatementGroup;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
@ -41,7 +41,7 @@ public class WbStatementGroupExprTest extends WbExpressionTest<StatementGroup> {
|
||||
private WbPropConstant propertyExpr = new WbPropConstant("P908", "myprop", "time");
|
||||
public WbStatementGroupExpr expr;
|
||||
|
||||
private ItemIdValue subject;
|
||||
private EntityIdValue subject;
|
||||
public StatementGroup statementGroup;
|
||||
|
||||
public String jsonRepresentation;
|
||||
|
Loading…
Reference in New Issue
Block a user