diff --git a/extensions/wikidata/lib-local-src/wdtk-datamodel-0.9.0-SNAPSHOT-sources.jar b/extensions/wikidata/lib-local-src/wdtk-datamodel-0.9.0-SNAPSHOT-sources.jar
deleted file mode 100644
index 975097035..000000000
Binary files a/extensions/wikidata/lib-local-src/wdtk-datamodel-0.9.0-SNAPSHOT-sources.jar and /dev/null differ
diff --git a/extensions/wikidata/lib-local-src/wdtk-wikibaseapi-0.9.0-SNAPSHOT-sources.jar b/extensions/wikidata/lib-local-src/wdtk-wikibaseapi-0.9.0-SNAPSHOT-sources.jar
deleted file mode 100644
index bfb4c41f8..000000000
Binary files a/extensions/wikidata/lib-local-src/wdtk-wikibaseapi-0.9.0-SNAPSHOT-sources.jar and /dev/null differ
diff --git a/extensions/wikidata/lib-local/wdtk-datamodel-0.9.0-SNAPSHOT-jar-with-dependencies.jar b/extensions/wikidata/lib-local/wdtk-datamodel-0.9.0-SNAPSHOT-jar-with-dependencies.jar
deleted file mode 100644
index 4cefe5a59..000000000
Binary files a/extensions/wikidata/lib-local/wdtk-datamodel-0.9.0-SNAPSHOT-jar-with-dependencies.jar and /dev/null differ
diff --git a/extensions/wikidata/lib-local/wdtk-wikibaseapi-0.9.0-SNAPSHOT.jar b/extensions/wikidata/lib-local/wdtk-wikibaseapi-0.9.0-SNAPSHOT.jar
deleted file mode 100644
index fb099272b..000000000
Binary files a/extensions/wikidata/lib-local/wdtk-wikibaseapi-0.9.0-SNAPSHOT.jar and /dev/null differ
diff --git a/extensions/wikidata/pom.xml b/extensions/wikidata/pom.xml
index 06c82b595..b630aa2d0 100644
--- a/extensions/wikidata/pom.xml
+++ b/extensions/wikidata/pom.xml
@@ -95,45 +95,6 @@
-
- org.apache.maven.plugins
- maven-install-plugin
- 2.5.2
-
-
- install-wdtk-datamodel
- process-resources
-
- ${basedir}/lib-local/wdtk-datamodel-0.9.0-SNAPSHOT-jar-with-dependencies.jar
- default
- org.wikidata.wdtk
- wdtk-datamodel
- 0.9.0-SNAPSHOT
- jar
- true
-
-
- install-file
-
-
-
- install-wdtk-wikibaseapi
- process-resources
-
- ${basedir}/lib-local/wdtk-wikibaseapi-0.9.0-SNAPSHOT.jar
- default
- org.wikidata.wdtk
- wdtk-wikibaseapi
- 0.9.0-SNAPSHOT
- jar
- true
-
-
- install-file
-
-
-
-
org.apache.maven.plugins
maven-clean-plugin
@@ -165,12 +126,12 @@
org.wikidata.wdtk
wdtk-wikibaseapi
- 0.9.0-SNAPSHOT
+ 0.9.0
org.wikidata.wdtk
wdtk-datamodel
- 0.9.0-SNAPSHOT
+ 0.9.0
diff --git a/extensions/wikidata/src/org/openrefine/wikidata/commands/PreviewWikibaseSchemaCommand.java b/extensions/wikidata/src/org/openrefine/wikidata/commands/PreviewWikibaseSchemaCommand.java
index 28ed72400..eb3749133 100644
--- a/extensions/wikidata/src/org/openrefine/wikidata/commands/PreviewWikibaseSchemaCommand.java
+++ b/extensions/wikidata/src/org/openrefine/wikidata/commands/PreviewWikibaseSchemaCommand.java
@@ -24,6 +24,8 @@
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;
@@ -36,7 +38,6 @@ 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;
@@ -45,10 +46,7 @@ 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;
diff --git a/extensions/wikidata/src/org/openrefine/wikidata/editing/ConnectionManager.java b/extensions/wikidata/src/org/openrefine/wikidata/editing/ConnectionManager.java
index f631be707..203b9e5c3 100644
--- a/extensions/wikidata/src/org/openrefine/wikidata/editing/ConnectionManager.java
+++ b/extensions/wikidata/src/org/openrefine/wikidata/editing/ConnectionManager.java
@@ -31,6 +31,7 @@ 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;
diff --git a/extensions/wikidata/src/org/openrefine/wikidata/exporters/QSValuePrinter.java b/extensions/wikidata/src/org/openrefine/wikidata/exporters/QSValuePrinter.java
index 4a4153f57..eb8ed04cd 100644
--- a/extensions/wikidata/src/org/openrefine/wikidata/exporters/QSValuePrinter.java
+++ b/extensions/wikidata/src/org/openrefine/wikidata/exporters/QSValuePrinter.java
@@ -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,12 +50,6 @@ import org.wikidata.wdtk.datamodel.interfaces.ValueVisitor;
*/
public class QSValuePrinter implements ValueVisitor {
- @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()) {
@@ -76,12 +70,10 @@ public class QSValuePrinter implements ValueVisitor {
@Override
public String visit(QuantityValue value) {
- String unitPrefix = "http://www.wikidata.org/entity/Q";
- String unitIri = value.getUnit();
+ ItemIdValue unit = value.getUnitItemId();
String unitRepresentation = "", boundsRepresentation = "";
- if (!unitIri.isEmpty()) {
- if (!unitIri.startsWith(unitPrefix)) return null; // QuickStatements only accepts Qids as units
- unitRepresentation = "U" + unitIri.substring(unitPrefix.length());
+ if (unit != null) {
+ unitRepresentation = "U" + unit.getId().substring(1);
}
if (value.getLowerBound() != null) {
// bounds are always null at the same time so we know they are both not null
diff --git a/extensions/wikidata/src/org/openrefine/wikidata/exporters/QuickStatementsExporter.java b/extensions/wikidata/src/org/openrefine/wikidata/exporters/QuickStatementsExporter.java
index 6bc650bf8..0b1e9b291 100644
--- a/extensions/wikidata/src/org/openrefine/wikidata/exporters/QuickStatementsExporter.java
+++ b/extensions/wikidata/src/org/openrefine/wikidata/exporters/QuickStatementsExporter.java
@@ -38,11 +38,14 @@ 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;
@@ -180,9 +183,16 @@ public class QuickStatementsExporter implements WriterExporter {
if (reference) {
pid = pid.replace('P', 'S');
}
- Value val = s.getValue();
- ValueVisitor vv = new QSValuePrinter();
- String valStr = val.accept(vv);
+ String valStr = "";
+ if (s instanceof ValueSnak) {
+ Value val = ((ValueSnak)s).getValue();
+ ValueVisitor vv = new QSValuePrinter();
+ valStr = val.accept(vv);
+ } else if (s instanceof NoValueSnak) {
+ valStr = "novalue";
+ } else if (s instanceof SomeValueSnak) {
+ valStr = "somevalue";
+ }
if (valStr != null) {
writer.write("\t" + pid + "\t" + valStr);
}
diff --git a/extensions/wikidata/src/org/openrefine/wikidata/qa/WikidataConstraintFetcher.java b/extensions/wikidata/src/org/openrefine/wikidata/qa/WikidataConstraintFetcher.java
index 61f4222d0..4ce09f968 100644
--- a/extensions/wikidata/src/org/openrefine/wikidata/qa/WikidataConstraintFetcher.java
+++ b/extensions/wikidata/src/org/openrefine/wikidata/qa/WikidataConstraintFetcher.java
@@ -41,6 +41,7 @@ import org.wikidata.wdtk.datamodel.interfaces.Statement;
import org.wikidata.wdtk.datamodel.interfaces.StatementGroup;
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
@@ -327,7 +328,11 @@ public class WikidataConstraintFetcher implements ConstraintFetcher {
for (SnakGroup group : groups) {
if (group.getProperty().getId().equals(pid)) {
for (Snak snak : group.getSnaks())
- results.add(snak.getValue());
+ if (snak instanceof ValueSnak) {
+ results.add(((ValueSnak)snak).getValue());
+ } else {
+ results.add(null);
+ }
}
}
return results;
diff --git a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/DistinctValuesScrutinizer.java b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/DistinctValuesScrutinizer.java
index 03a5761d1..6a6aabba3 100644
--- a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/DistinctValuesScrutinizer.java
+++ b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/DistinctValuesScrutinizer.java
@@ -29,8 +29,10 @@ 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
@@ -53,7 +55,11 @@ public class DistinctValuesScrutinizer extends StatementScrutinizer {
public void scrutinize(Statement statement, EntityIdValue entityId, boolean added) {
PropertyIdValue pid = statement.getClaim().getMainSnak().getPropertyId();
if (_fetcher.hasDistinctValues(pid)) {
- Value mainSnakValue = statement.getClaim().getMainSnak().getValue();
+ Snak mainSnak = statement.getClaim().getMainSnak();
+ if(!(mainSnak instanceof ValueSnak)) {
+ return;
+ }
+ Value mainSnakValue = ((ValueSnak)mainSnak).getValue();
Map seen = _seenValues.get(pid);
if (seen == null) {
seen = new HashMap();
diff --git a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/EntityTypeScrutinizer.java b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/EntityTypeScrutinizer.java
index af822dc28..fbcfd8d82 100644
--- a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/EntityTypeScrutinizer.java
+++ b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/EntityTypeScrutinizer.java
@@ -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.Snak;
+import org.wikidata.wdtk.datamodel.interfaces.ValueSnak;
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(Snak snak, EntityIdValue entityId, boolean added) {
+ public void scrutinize(ValueSnak snak, EntityIdValue entityId, boolean added) {
PropertyIdValue pid = snak.getPropertyId();
if(!_fetcher.usableOnItems(pid)) {
QAWarning issue = new QAWarning(type, null, QAWarning.Severity.WARNING, 1);
diff --git a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/FormatScrutinizer.java b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/FormatScrutinizer.java
index c61b90a06..05997d227 100644
--- a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/FormatScrutinizer.java
+++ b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/FormatScrutinizer.java
@@ -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(Snak snak, EntityIdValue entityId, boolean added) {
+ public void scrutinize(ValueSnak snak, EntityIdValue entityId, boolean added) {
if (StringValue.class.isInstance(snak.getValue())) {
String value = ((StringValue) snak.getValue()).getString();
PropertyIdValue pid = snak.getPropertyId();
diff --git a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/InverseConstraintScrutinizer.java b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/InverseConstraintScrutinizer.java
index 88bc2c3ae..87aab1d67 100644
--- a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/InverseConstraintScrutinizer.java
+++ b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/InverseConstraintScrutinizer.java
@@ -33,8 +33,10 @@ 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.
@@ -81,7 +83,11 @@ public class InverseConstraintScrutinizer extends StatementScrutinizer {
return; // TODO support for deleted statements
}
- Value mainSnakValue = statement.getClaim().getMainSnak().getValue();
+ Snak mainSnak = statement.getClaim().getMainSnak();
+ if(! (mainSnak instanceof ValueSnak)) {
+ return;
+ }
+ Value mainSnakValue = ((ValueSnak)mainSnak).getValue();
if (ItemIdValue.class.isInstance(mainSnakValue)) {
PropertyIdValue pid = statement.getClaim().getMainSnak().getPropertyId();
PropertyIdValue inversePid = getInverseConstraint(pid);
diff --git a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/QuantityScrutinizer.java b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/QuantityScrutinizer.java
index ea711fe56..a2d9cf866 100644
--- a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/QuantityScrutinizer.java
+++ b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/QuantityScrutinizer.java
@@ -1,15 +1,13 @@
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.Snak;
+import org.wikidata.wdtk.datamodel.interfaces.ValueSnak;
/**
* Scrutinizer checking for units and bounds in quantities.
@@ -25,7 +23,7 @@ public class QuantityScrutinizer extends SnakScrutinizer {
public static final String noUnitProvidedType = "no-unit-provided";
@Override
- public void scrutinize(Snak snak, EntityIdValue entityId, boolean added) {
+ public void scrutinize(ValueSnak snak, EntityIdValue entityId, boolean added) {
if (QuantityValue.class.isInstance(snak.getValue()) && added) {
PropertyIdValue pid = snak.getPropertyId();
QuantityValue value = (QuantityValue)snak.getValue();
@@ -45,22 +43,19 @@ public class QuantityScrutinizer extends SnakScrutinizer {
addIssue(issue);
}
Set allowedUnits = _fetcher.allowedUnits(pid);
- String currentUnit = null;
- if (value.getUnit() != null && !value.getUnit().equals("")) {
- currentUnit = value.getUnit();
+ ItemIdValue currentUnit = null;
+ if (value.getUnit() != null) {
+ currentUnit = value.getUnitItemId();
}
if(allowedUnits != null &&
- !allowedUnits.stream().map(u -> u != null ? u.getIri() : null)
- .collect(Collectors.toSet()).contains(currentUnit)) {
+ !allowedUnits.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",
- // 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"))));
+ issue.setProperty("unit_entity", currentUnit);
}
addIssue(issue);
}
diff --git a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/RestrictedValuesScrutinizer.java b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/RestrictedValuesScrutinizer.java
index 5aed7b8b4..2726d6ca5 100644
--- a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/RestrictedValuesScrutinizer.java
+++ b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/RestrictedValuesScrutinizer.java
@@ -4,9 +4,11 @@ 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.Snak;
+import org.wikidata.wdtk.datamodel.interfaces.SomeValueSnak;
import org.wikidata.wdtk.datamodel.interfaces.Value;
+import org.wikidata.wdtk.datamodel.interfaces.ValueSnak;
public class RestrictedValuesScrutinizer extends SnakScrutinizer {
@@ -14,10 +16,23 @@ public class RestrictedValuesScrutinizer extends SnakScrutinizer {
public static String type = "forbidden-value";
@Override
- public void scrutinize(Snak snak, EntityIdValue entityId, boolean added) {
+ public void scrutinize(ValueSnak 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 allowedValues = _fetcher.allowedValues(pid);
Set disallowedValues = _fetcher.disallowedValues(pid);
if((allowedValues != null && !allowedValues.contains(value)) ||
diff --git a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/SelfReferentialScrutinizer.java b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/SelfReferentialScrutinizer.java
index c23f0606e..c130fd239 100644
--- a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/SelfReferentialScrutinizer.java
+++ b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/SelfReferentialScrutinizer.java
@@ -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.Snak;
+import org.wikidata.wdtk.datamodel.interfaces.ValueSnak;
/**
* 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(Snak snak, EntityIdValue entityId, boolean added) {
+ public void scrutinize(ValueSnak 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);
diff --git a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/SnakScrutinizer.java b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/SnakScrutinizer.java
index 7e7e3afe7..42f08e2c6 100644
--- a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/SnakScrutinizer.java
+++ b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/SnakScrutinizer.java
@@ -26,9 +26,12 @@ 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
@@ -49,8 +52,46 @@ public abstract class SnakScrutinizer extends StatementScrutinizer {
* @param added:
* whether this snak is going to be added or deleted
*/
- public abstract void scrutinize(Snak snak, EntityIdValue entityId, boolean added);
+ public abstract void scrutinize(ValueSnak 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
diff --git a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/ValueScrutinizer.java b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/ValueScrutinizer.java
index 1a70302a9..2d10b065f 100644
--- a/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/ValueScrutinizer.java
+++ b/extensions/wikidata/src/org/openrefine/wikidata/qa/scrutinizers/ValueScrutinizer.java
@@ -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(Snak snak, EntityIdValue entityId, boolean added) {
+ public void scrutinize(ValueSnak snak, EntityIdValue entityId, boolean added) {
scrutinize(snak.getValue());
}
diff --git a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbSnakExpr.java b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbSnakExpr.java
index a9b33b952..61d8c4ac4 100644
--- a/extensions/wikidata/src/org/openrefine/wikidata/schema/WbSnakExpr.java
+++ b/extensions/wikidata/src/org/openrefine/wikidata/schema/WbSnakExpr.java
@@ -26,7 +26,6 @@ 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;
diff --git a/extensions/wikidata/src/org/openrefine/wikidata/updates/scheduler/PointerExtractor.java b/extensions/wikidata/src/org/openrefine/wikidata/updates/scheduler/PointerExtractor.java
index 7fac7b09e..2b66150a6 100644
--- a/extensions/wikidata/src/org/openrefine/wikidata/updates/scheduler/PointerExtractor.java
+++ b/extensions/wikidata/src/org/openrefine/wikidata/updates/scheduler/PointerExtractor.java
@@ -29,7 +29,6 @@ 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;
@@ -40,6 +39,7 @@ 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,7 +101,9 @@ public class PointerExtractor implements ValueVisitor> {
public Set extractPointers(Snak snak) {
Set result = new HashSet<>();
result.addAll(extractPointers(snak.getPropertyId()));
- result.addAll(extractPointers(snak.getValue()));
+ if (snak instanceof ValueSnak) {
+ result.addAll(extractPointers(((ValueSnak)snak).getValue()));
+ }
return result;
}
@@ -122,11 +124,6 @@ public class PointerExtractor implements ValueVisitor> {
return pointers;
}
- @Override
- public Set visit(DatatypeIdValue value) {
- return null;
- }
-
@Override
public Set visit(EntityIdValue value) {
if (ReconItemIdValue.class.isInstance(value)) {
diff --git a/extensions/wikidata/tests/src/org/openrefine/wikidata/schema/WbQuantityExprTest.java b/extensions/wikidata/tests/src/org/openrefine/wikidata/schema/WbQuantityExprTest.java
index 79485cbc3..97676504c 100644
--- a/extensions/wikidata/tests/src/org/openrefine/wikidata/schema/WbQuantityExprTest.java
+++ b/extensions/wikidata/tests/src/org/openrefine/wikidata/schema/WbQuantityExprTest.java
@@ -33,7 +33,6 @@ 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 {
diff --git a/extensions/wikidata/tests/src/org/openrefine/wikidata/schema/WikibaseSchemaTest.java b/extensions/wikidata/tests/src/org/openrefine/wikidata/schema/WikibaseSchemaTest.java
index 72bd2d941..fb0839699 100644
--- a/extensions/wikidata/tests/src/org/openrefine/wikidata/schema/WikibaseSchemaTest.java
+++ b/extensions/wikidata/tests/src/org/openrefine/wikidata/schema/WikibaseSchemaTest.java
@@ -52,8 +52,6 @@ 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;
diff --git a/extensions/wikidata/tests/src/org/openrefine/wikidata/testing/TestingData.java b/extensions/wikidata/tests/src/org/openrefine/wikidata/testing/TestingData.java
index efa25756f..7e58362dd 100644
--- a/extensions/wikidata/tests/src/org/openrefine/wikidata/testing/TestingData.java
+++ b/extensions/wikidata/tests/src/org/openrefine/wikidata/testing/TestingData.java
@@ -25,8 +25,6 @@ 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;
diff --git a/extensions/wikidata/tests/src/org/openrefine/wikidata/updates/scheduler/PointerExtractorTest.java b/extensions/wikidata/tests/src/org/openrefine/wikidata/updates/scheduler/PointerExtractorTest.java
index 6bab3955a..5671c173e 100644
--- a/extensions/wikidata/tests/src/org/openrefine/wikidata/updates/scheduler/PointerExtractorTest.java
+++ b/extensions/wikidata/tests/src/org/openrefine/wikidata/updates/scheduler/PointerExtractorTest.java
@@ -66,7 +66,6 @@ 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"));