Revert "Bump Wikidata-Toolkit to 0.9.0"
This reverts commit 44bbdcc83d
.
This commit is contained in:
parent
922a9e7c43
commit
04ed08c2c5
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -95,6 +95,45 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-install-plugin</artifactId>
|
||||
<version>2.5.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>install-wdtk-datamodel</id>
|
||||
<phase>process-resources</phase>
|
||||
<configuration>
|
||||
<file>${basedir}/lib-local/wdtk-datamodel-0.9.0-SNAPSHOT-jar-with-dependencies.jar</file>
|
||||
<repositoryLayout>default</repositoryLayout>
|
||||
<groupId>org.wikidata.wdtk</groupId>
|
||||
<artifactId>wdtk-datamodel</artifactId>
|
||||
<version>0.9.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<generatePom>true</generatePom>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>install-file</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>install-wdtk-wikibaseapi</id>
|
||||
<phase>process-resources</phase>
|
||||
<configuration>
|
||||
<file>${basedir}/lib-local/wdtk-wikibaseapi-0.9.0-SNAPSHOT.jar</file>
|
||||
<repositoryLayout>default</repositoryLayout>
|
||||
<groupId>org.wikidata.wdtk</groupId>
|
||||
<artifactId>wdtk-wikibaseapi</artifactId>
|
||||
<version>0.9.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<generatePom>true</generatePom>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>install-file</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
@ -126,12 +165,12 @@
|
||||
<dependency>
|
||||
<groupId>org.wikidata.wdtk</groupId>
|
||||
<artifactId>wdtk-wikibaseapi</artifactId>
|
||||
<version>0.9.0</version>
|
||||
<version>0.9.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wikidata.wdtk</groupId>
|
||||
<artifactId>wdtk-datamodel</artifactId>
|
||||
<version>0.9.0</version>
|
||||
<version>0.9.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
|
@ -24,8 +24,6 @@
|
||||
|
||||
package org.openrefine.wikidata.commands;
|
||||
|
||||
import static org.openrefine.wikidata.commands.CommandUtilities.respondError;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.util.List;
|
||||
@ -38,6 +36,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.json.JSONWriter;
|
||||
import org.openrefine.wikidata.qa.EditInspector;
|
||||
import org.openrefine.wikidata.qa.QAWarning;
|
||||
@ -46,7 +45,10 @@ import org.openrefine.wikidata.schema.WikibaseSchema;
|
||||
import org.openrefine.wikidata.updates.ItemUpdate;
|
||||
import org.openrefine.wikidata.updates.scheduler.WikibaseAPIUpdateScheduler;
|
||||
|
||||
import static org.openrefine.wikidata.commands.CommandUtilities.respondError;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import com.google.refine.browsing.Engine;
|
||||
import com.google.refine.commands.Command;
|
||||
import com.google.refine.model.Project;
|
||||
|
@ -31,7 +31,6 @@ import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.wikidata.wdtk.wikibaseapi.ApiConnection;
|
||||
import org.wikidata.wdtk.wikibaseapi.BasicApiConnection;
|
||||
import org.wikidata.wdtk.wikibaseapi.LoginFailedException;
|
||||
|
||||
import com.google.refine.ProjectManager;
|
||||
|
@ -28,9 +28,9 @@ import java.util.Locale;
|
||||
|
||||
import org.openrefine.wikidata.schema.entityvalues.ReconEntityIdValue;
|
||||
import org.openrefine.wikidata.updates.scheduler.QuickStatementsUpdateScheduler;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.DatatypeIdValue;
|
||||
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.MonolingualTextValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.QuantityValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.StringValue;
|
||||
@ -50,6 +50,12 @@ import org.wikidata.wdtk.datamodel.interfaces.ValueVisitor;
|
||||
*/
|
||||
public class QSValuePrinter implements ValueVisitor<String> {
|
||||
|
||||
@Override
|
||||
public String visit(DatatypeIdValue value) {
|
||||
// impossible case (this is actually a bug in WDTK, DatatypeIdValue should not subclass Value)
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visit(EntityIdValue value) {
|
||||
if (ReconEntityIdValue.class.isInstance(value) && ((ReconEntityIdValue) value).isNew()) {
|
||||
@ -70,10 +76,12 @@ public class QSValuePrinter implements ValueVisitor<String> {
|
||||
|
||||
@Override
|
||||
public String visit(QuantityValue value) {
|
||||
ItemIdValue unit = value.getUnitItemId();
|
||||
String unitPrefix = "http://www.wikidata.org/entity/Q";
|
||||
String unitIri = value.getUnit();
|
||||
String unitRepresentation = "", boundsRepresentation = "";
|
||||
if (unit != null) {
|
||||
unitRepresentation = "U" + unit.getId().substring(1);
|
||||
if (!unitIri.isEmpty()) {
|
||||
if (!unitIri.startsWith(unitPrefix)) return null; // QuickStatements only accepts Qids as units
|
||||
unitRepresentation = "U" + unitIri.substring(unitPrefix.length());
|
||||
}
|
||||
if (value.getLowerBound() != null) {
|
||||
// bounds are always null at the same time so we know they are both not null
|
||||
|
@ -38,14 +38,11 @@ import org.slf4j.LoggerFactory;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Claim;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.ItemIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.NoValueSnak;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Reference;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Snak;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.SnakGroup;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.SomeValueSnak;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Statement;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Value;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.ValueSnak;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.ValueVisitor;
|
||||
|
||||
import com.google.refine.browsing.Engine;
|
||||
@ -183,16 +180,9 @@ public class QuickStatementsExporter implements WriterExporter {
|
||||
if (reference) {
|
||||
pid = pid.replace('P', 'S');
|
||||
}
|
||||
String valStr = "";
|
||||
if (s instanceof ValueSnak) {
|
||||
Value val = ((ValueSnak)s).getValue();
|
||||
ValueVisitor<String> vv = new QSValuePrinter();
|
||||
valStr = val.accept(vv);
|
||||
} else if (s instanceof NoValueSnak) {
|
||||
valStr = "novalue";
|
||||
} else if (s instanceof SomeValueSnak) {
|
||||
valStr = "somevalue";
|
||||
}
|
||||
Value val = s.getValue();
|
||||
ValueVisitor<String> vv = new QSValuePrinter();
|
||||
String valStr = val.accept(vv);
|
||||
if (valStr != null) {
|
||||
writer.write("\t" + pid + "\t" + valStr);
|
||||
}
|
||||
|
@ -42,7 +42,6 @@ import org.wikidata.wdtk.datamodel.interfaces.StatementGroup;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.StatementRank;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.StringValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Value;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.ValueSnak;
|
||||
|
||||
/**
|
||||
* This class provides an abstraction over the way constraint definitions are
|
||||
@ -330,11 +329,7 @@ public class WikidataConstraintFetcher implements ConstraintFetcher {
|
||||
for (SnakGroup group : groups) {
|
||||
if (group.getProperty().getId().equals(pid)) {
|
||||
for (Snak snak : group.getSnaks())
|
||||
if (snak instanceof ValueSnak) {
|
||||
results.add(((ValueSnak)snak).getValue());
|
||||
} else {
|
||||
results.add(null);
|
||||
}
|
||||
results.add(snak.getValue());
|
||||
}
|
||||
}
|
||||
return results;
|
||||
|
@ -29,10 +29,8 @@ import java.util.Map;
|
||||
import org.openrefine.wikidata.qa.QAWarning;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Snak;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Statement;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Value;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.ValueSnak;
|
||||
|
||||
/**
|
||||
* A scrutinizer that checks for properties using the same value on different
|
||||
@ -55,11 +53,7 @@ public class DistinctValuesScrutinizer extends StatementScrutinizer {
|
||||
public void scrutinize(Statement statement, EntityIdValue entityId, boolean added) {
|
||||
PropertyIdValue pid = statement.getClaim().getMainSnak().getPropertyId();
|
||||
if (_fetcher.hasDistinctValues(pid)) {
|
||||
Snak mainSnak = statement.getClaim().getMainSnak();
|
||||
if(!(mainSnak instanceof ValueSnak)) {
|
||||
return;
|
||||
}
|
||||
Value mainSnakValue = ((ValueSnak)mainSnak).getValue();
|
||||
Value mainSnakValue = statement.getClaim().getMainSnak().getValue();
|
||||
Map<Value, EntityIdValue> seen = _seenValues.get(pid);
|
||||
if (seen == null) {
|
||||
seen = new HashMap<Value, EntityIdValue>();
|
||||
|
@ -3,7 +3,7 @@ package org.openrefine.wikidata.qa.scrutinizers;
|
||||
import org.openrefine.wikidata.qa.QAWarning;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.ValueSnak;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Snak;
|
||||
|
||||
|
||||
public class EntityTypeScrutinizer extends SnakScrutinizer {
|
||||
@ -11,7 +11,7 @@ public class EntityTypeScrutinizer extends SnakScrutinizer {
|
||||
public final static String type = "invalid-entity-type";
|
||||
|
||||
@Override
|
||||
public void scrutinize(ValueSnak snak, EntityIdValue entityId, boolean added) {
|
||||
public void scrutinize(Snak snak, EntityIdValue entityId, boolean added) {
|
||||
PropertyIdValue pid = snak.getPropertyId();
|
||||
if(!_fetcher.usableOnItems(pid)) {
|
||||
QAWarning issue = new QAWarning(type, null, QAWarning.Severity.WARNING, 1);
|
||||
|
@ -30,8 +30,8 @@ import java.util.regex.Pattern;
|
||||
import org.openrefine.wikidata.qa.QAWarning;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Snak;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.StringValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.ValueSnak;
|
||||
|
||||
/**
|
||||
* A scrutinizer that detects incorrect formats in text values (mostly
|
||||
@ -73,7 +73,7 @@ public class FormatScrutinizer extends SnakScrutinizer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scrutinize(ValueSnak snak, EntityIdValue entityId, boolean added) {
|
||||
public void scrutinize(Snak snak, EntityIdValue entityId, boolean added) {
|
||||
if (StringValue.class.isInstance(snak.getValue())) {
|
||||
String value = ((StringValue) snak.getValue()).getString();
|
||||
PropertyIdValue pid = snak.getPropertyId();
|
||||
|
@ -33,10 +33,8 @@ import org.openrefine.wikidata.qa.QAWarning;
|
||||
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.Snak;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Statement;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Value;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.ValueSnak;
|
||||
|
||||
/**
|
||||
* A scrutinizer that checks for missing inverse statements in edit batches.
|
||||
@ -83,11 +81,7 @@ public class InverseConstraintScrutinizer extends StatementScrutinizer {
|
||||
return; // TODO support for deleted statements
|
||||
}
|
||||
|
||||
Snak mainSnak = statement.getClaim().getMainSnak();
|
||||
if(! (mainSnak instanceof ValueSnak)) {
|
||||
return;
|
||||
}
|
||||
Value mainSnakValue = ((ValueSnak)mainSnak).getValue();
|
||||
Value mainSnakValue = statement.getClaim().getMainSnak().getValue();
|
||||
if (ItemIdValue.class.isInstance(mainSnakValue)) {
|
||||
PropertyIdValue pid = statement.getClaim().getMainSnak().getPropertyId();
|
||||
PropertyIdValue inversePid = getInverseConstraint(pid);
|
||||
|
@ -1,13 +1,15 @@
|
||||
package org.openrefine.wikidata.qa.scrutinizers;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.openrefine.wikidata.qa.QAWarning;
|
||||
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.PropertyIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.QuantityValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.ValueSnak;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Snak;
|
||||
|
||||
/**
|
||||
* Scrutinizer checking for units and bounds in quantities.
|
||||
@ -23,7 +25,7 @@ public class QuantityScrutinizer extends SnakScrutinizer {
|
||||
public static final String noUnitProvidedType = "no-unit-provided";
|
||||
|
||||
@Override
|
||||
public void scrutinize(ValueSnak snak, EntityIdValue entityId, boolean added) {
|
||||
public void scrutinize(Snak snak, EntityIdValue entityId, boolean added) {
|
||||
if (QuantityValue.class.isInstance(snak.getValue()) && added) {
|
||||
PropertyIdValue pid = snak.getPropertyId();
|
||||
QuantityValue value = (QuantityValue)snak.getValue();
|
||||
@ -43,19 +45,22 @@ public class QuantityScrutinizer extends SnakScrutinizer {
|
||||
addIssue(issue);
|
||||
}
|
||||
Set<ItemIdValue> allowedUnits = _fetcher.allowedUnits(pid);
|
||||
ItemIdValue currentUnit = null;
|
||||
if (value.getUnit() != null) {
|
||||
currentUnit = value.getUnitItemId();
|
||||
String currentUnit = null;
|
||||
if (value.getUnit() != null && !value.getUnit().equals("")) {
|
||||
currentUnit = value.getUnit();
|
||||
}
|
||||
if(allowedUnits != null &&
|
||||
!allowedUnits.contains(currentUnit)) {
|
||||
!allowedUnits.stream().map(u -> u != null ? u.getIri() : null)
|
||||
.collect(Collectors.toSet()).contains(currentUnit)) {
|
||||
String issueType = currentUnit == null ? noUnitProvidedType : invalidUnitType;
|
||||
QAWarning issue = new QAWarning(issueType, pid.getId(), QAWarning.Severity.IMPORTANT, 1);
|
||||
issue.setProperty("property_entity", pid);
|
||||
issue.setProperty("example_value", value.getNumericValue().toString());
|
||||
issue.setProperty("example_item_entity", entityId);
|
||||
if (currentUnit != null) {
|
||||
issue.setProperty("unit_entity", currentUnit);
|
||||
issue.setProperty("unit_entity",
|
||||
// this is a hack but it will not be needed anymore in the upcoming version of Wikidata-Toolkit
|
||||
Datamodel.makeWikidataItemIdValue(currentUnit.substring(currentUnit.indexOf("Q"))));
|
||||
}
|
||||
addIssue(issue);
|
||||
}
|
||||
|
@ -4,11 +4,9 @@ import java.util.Set;
|
||||
|
||||
import org.openrefine.wikidata.qa.QAWarning;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.NoValueSnak;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.SomeValueSnak;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Snak;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Value;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.ValueSnak;
|
||||
|
||||
|
||||
public class RestrictedValuesScrutinizer extends SnakScrutinizer {
|
||||
@ -16,23 +14,10 @@ public class RestrictedValuesScrutinizer extends SnakScrutinizer {
|
||||
public static String type = "forbidden-value";
|
||||
|
||||
@Override
|
||||
public void scrutinize(ValueSnak snak, EntityIdValue entityId, boolean added) {
|
||||
public void scrutinize(Snak snak, EntityIdValue entityId, boolean added) {
|
||||
PropertyIdValue pid = snak.getPropertyId();
|
||||
Value value = snak.getValue();
|
||||
scrutinizeValue(value, pid, entityId, added);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scrutinize(SomeValueSnak snak, EntityIdValue entityId, boolean added) {
|
||||
scrutinizeValue(null, snak.getPropertyId(), entityId, added);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scrutinize(NoValueSnak snak, EntityIdValue entityId, boolean added) {
|
||||
scrutinizeValue(null, snak.getPropertyId(), entityId, added);
|
||||
}
|
||||
|
||||
public void scrutinizeValue(Value value, PropertyIdValue pid, EntityIdValue entityId, boolean added) {
|
||||
|
||||
Set<Value> allowedValues = _fetcher.allowedValues(pid);
|
||||
Set<Value> disallowedValues = _fetcher.disallowedValues(pid);
|
||||
if((allowedValues != null && !allowedValues.contains(value)) ||
|
||||
|
@ -25,7 +25,7 @@ package org.openrefine.wikidata.qa.scrutinizers;
|
||||
|
||||
import org.openrefine.wikidata.qa.QAWarning;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.ValueSnak;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Snak;
|
||||
|
||||
/**
|
||||
* A scrutinizer that checks for self-referential statements. These statements
|
||||
@ -39,7 +39,7 @@ public class SelfReferentialScrutinizer extends SnakScrutinizer {
|
||||
public static final String type = "self-referential-statements";
|
||||
|
||||
@Override
|
||||
public void scrutinize(ValueSnak snak, EntityIdValue entityId, boolean added) {
|
||||
public void scrutinize(Snak snak, EntityIdValue entityId, boolean added) {
|
||||
if (entityId.equals(snak.getValue())) {
|
||||
QAWarning issue = new QAWarning(type, null, QAWarning.Severity.WARNING, 1);
|
||||
issue.setProperty("example_entity", entityId);
|
||||
|
@ -26,12 +26,9 @@ package org.openrefine.wikidata.qa.scrutinizers;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.NoValueSnak;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Reference;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Snak;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.SomeValueSnak;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Statement;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.ValueSnak;
|
||||
|
||||
/**
|
||||
* A scrutinizer that inspects snaks individually, no matter whether they appear
|
||||
@ -52,46 +49,8 @@ public abstract class SnakScrutinizer extends StatementScrutinizer {
|
||||
* @param added:
|
||||
* whether this snak is going to be added or deleted
|
||||
*/
|
||||
public abstract void scrutinize(ValueSnak snak, EntityIdValue entityId, boolean added);
|
||||
public abstract void scrutinize(Snak snak, EntityIdValue entityId, boolean added);
|
||||
|
||||
/**
|
||||
* Scrutinizes a novalue snak
|
||||
*
|
||||
* @param snak:
|
||||
* the snak to inspect
|
||||
* @param entityId:
|
||||
* the item on which it is going to (dis)appear
|
||||
* @param added:
|
||||
* whether this snak is going to be added or deleted
|
||||
*/
|
||||
public void scrutinize(NoValueSnak snak, EntityIdValue entityId, boolean added) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrutinizes a somevalue snak
|
||||
*
|
||||
* @param snak:
|
||||
* the snak to inspect
|
||||
* @param entityId:
|
||||
* the item on which it is going to (dis)appear
|
||||
* @param added:
|
||||
* whether this snak is going to be added or deleted
|
||||
*/
|
||||
public void scrutinize(SomeValueSnak snak, EntityIdValue entityId, boolean added) {
|
||||
|
||||
}
|
||||
|
||||
public void scrutinize(Snak snak, EntityIdValue entityId, boolean added) {
|
||||
if(snak instanceof ValueSnak) {
|
||||
scrutinize((ValueSnak)snak, entityId, added);
|
||||
} else if(snak instanceof NoValueSnak) {
|
||||
scrutinize((NoValueSnak)snak, entityId, added);
|
||||
} else if(snak instanceof SomeValueSnak) {
|
||||
scrutinize((SomeValueSnak)snak, entityId, added);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scrutinize(Statement statement, EntityIdValue entityId, boolean added) {
|
||||
// Main snak
|
||||
|
@ -26,8 +26,8 @@ package org.openrefine.wikidata.qa.scrutinizers;
|
||||
import org.openrefine.wikidata.updates.ItemUpdate;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Snak;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Value;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.ValueSnak;
|
||||
|
||||
/**
|
||||
* A scrutinizer that inspects the values of snaks and terms
|
||||
@ -55,7 +55,7 @@ public abstract class ValueScrutinizer extends SnakScrutinizer {
|
||||
public abstract void scrutinize(Value value);
|
||||
|
||||
@Override
|
||||
public void scrutinize(ValueSnak snak, EntityIdValue entityId, boolean added) {
|
||||
public void scrutinize(Snak snak, EntityIdValue entityId, boolean added) {
|
||||
scrutinize(snak.getValue());
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ package org.openrefine.wikidata.schema;
|
||||
import org.jsoup.helper.Validate;
|
||||
import org.openrefine.wikidata.schema.entityvalues.FullyPropertySerializingValueSnak;
|
||||
import org.openrefine.wikidata.schema.exceptions.SkipSchemaExpressionException;
|
||||
import org.wikidata.wdtk.datamodel.helpers.Datamodel;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Snak;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Value;
|
||||
|
@ -29,6 +29,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openrefine.wikidata.schema.entityvalues.ReconItemIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.DatatypeIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.GlobeCoordinatesValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue;
|
||||
@ -39,7 +40,6 @@ import org.wikidata.wdtk.datamodel.interfaces.Statement;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.StringValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.TimeValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Value;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.ValueSnak;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.ValueVisitor;
|
||||
|
||||
/**
|
||||
@ -101,9 +101,7 @@ public class PointerExtractor implements ValueVisitor<Set<ReconItemIdValue>> {
|
||||
public Set<ReconItemIdValue> extractPointers(Snak snak) {
|
||||
Set<ReconItemIdValue> result = new HashSet<>();
|
||||
result.addAll(extractPointers(snak.getPropertyId()));
|
||||
if (snak instanceof ValueSnak) {
|
||||
result.addAll(extractPointers(((ValueSnak)snak).getValue()));
|
||||
}
|
||||
result.addAll(extractPointers(snak.getValue()));
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -124,6 +122,11 @@ public class PointerExtractor implements ValueVisitor<Set<ReconItemIdValue>> {
|
||||
return pointers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ReconItemIdValue> visit(DatatypeIdValue value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ReconItemIdValue> visit(EntityIdValue value) {
|
||||
if (ReconItemIdValue.class.isInstance(value)) {
|
||||
|
@ -33,6 +33,7 @@ import org.wikidata.wdtk.datamodel.helpers.Datamodel;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.QuantityValue;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
public class WbQuantityExprTest extends WbExpressionTest<QuantityValue> {
|
||||
|
||||
|
@ -52,6 +52,8 @@ import org.wikidata.wdtk.datamodel.interfaces.StatementRank;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.StringValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.TimeValue;
|
||||
|
||||
import com.fasterxml.jackson.databind.exc.InvalidDefinitionException;
|
||||
|
||||
import com.google.refine.browsing.Engine;
|
||||
import com.google.refine.browsing.EngineConfig;
|
||||
import com.google.refine.model.Project;
|
||||
|
@ -25,6 +25,8 @@ package org.openrefine.wikidata.testing;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
@ -66,6 +66,7 @@ public class PointerExtractorTest {
|
||||
|
||||
@Test
|
||||
public void testExtractDatavalues() {
|
||||
assertEmpty(Datamodel.makeDatatypeIdValue("string"));
|
||||
assertEmpty(Datamodel.makeGlobeCoordinatesValue(1.34, 2.354, 0.1, GlobeCoordinatesValue.GLOBE_EARTH));
|
||||
assertEmpty(Datamodel.makeStringValue("est"));
|
||||
assertEmpty(Datamodel.makeMonolingualTextValue("srtu", "en"));
|
||||
|
Loading…
Reference in New Issue
Block a user