Simply the scrutinizer architecture
This commit is contained in:
parent
132af25b4a
commit
1ea1377734
@ -1,5 +1,7 @@
|
||||
package org.openrefine.wikidata.qa;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.openrefine.wikidata.utils.JacksonJsonizable;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@ -30,17 +32,21 @@ public class QAWarning extends JacksonJsonizable implements Comparable<QAWarning
|
||||
private Severity severity;
|
||||
// The number of times this issue was found
|
||||
private int count;
|
||||
// Other details about the warning, that can be displayed to the user
|
||||
private Properties properties;
|
||||
|
||||
@JsonCreator
|
||||
public QAWarning(
|
||||
@JsonProperty("type") String type,
|
||||
@JsonProperty("bucket_id") String bucketId,
|
||||
@JsonProperty("severity") Severity severity,
|
||||
@JsonProperty("count") int count) {
|
||||
@JsonProperty("count") int count,
|
||||
@JsonProperty("properties") Properties properties) {
|
||||
this.type = type;
|
||||
this.bucketId = bucketId;
|
||||
this.severity = severity;
|
||||
this.count = count;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,6 +92,11 @@ public class QAWarning extends JacksonJsonizable implements Comparable<QAWarning
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
@JsonProperty("properties")
|
||||
public Properties getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Warnings are sorted by decreasing severity.
|
||||
|
@ -1,7 +1,9 @@
|
||||
package org.openrefine.wikidata.qa.scrutinizers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.openrefine.wikidata.qa.ConstraintFetcher;
|
||||
import org.openrefine.wikidata.qa.QAWarning;
|
||||
import org.openrefine.wikidata.qa.QAWarningStore;
|
||||
import org.openrefine.wikidata.schema.ItemUpdate;
|
||||
@ -13,10 +15,15 @@ import org.openrefine.wikidata.schema.ItemUpdate;
|
||||
*/
|
||||
public abstract class EditScrutinizer {
|
||||
|
||||
private QAWarningStore store;
|
||||
protected QAWarningStore _store;
|
||||
protected ConstraintFetcher _fetcher;
|
||||
|
||||
public EditScrutinizer() {
|
||||
_fetcher = new ConstraintFetcher();
|
||||
}
|
||||
|
||||
public void setStore(QAWarningStore store) {
|
||||
this.store = store;
|
||||
_store = store;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -30,7 +37,7 @@ public abstract class EditScrutinizer {
|
||||
* @param warning
|
||||
*/
|
||||
protected void info(String type) {
|
||||
store.addWarning(new QAWarning(type, null, QAWarning.Severity.INFO, 1));
|
||||
_store.addWarning(new QAWarning(type, null, QAWarning.Severity.INFO, 1, new Properties()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -38,7 +45,7 @@ public abstract class EditScrutinizer {
|
||||
* @param warning
|
||||
*/
|
||||
protected void warning(String type) {
|
||||
store.addWarning(new QAWarning(type, null, QAWarning.Severity.WARNING, 1));
|
||||
_store.addWarning(new QAWarning(type, null, QAWarning.Severity.WARNING, 1, new Properties()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -46,7 +53,7 @@ public abstract class EditScrutinizer {
|
||||
* @param warning
|
||||
*/
|
||||
protected void important(String type) {
|
||||
store.addWarning(new QAWarning(type, null, QAWarning.Severity.IMPORTANT, 1));
|
||||
_store.addWarning(new QAWarning(type, null, QAWarning.Severity.IMPORTANT, 1, new Properties()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -54,6 +61,6 @@ public abstract class EditScrutinizer {
|
||||
* @param warning
|
||||
*/
|
||||
protected void critical(String type) {
|
||||
store.addWarning(new QAWarning(type, null, QAWarning.Severity.CRITICAL, 1));
|
||||
_store.addWarning(new QAWarning(type, null, QAWarning.Severity.CRITICAL, 1, new Properties()));
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.openrefine.wikidata.qa.ConstraintFetcher;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Snak;
|
||||
@ -20,11 +19,9 @@ import org.wikidata.wdtk.datamodel.interfaces.StringValue;
|
||||
public class FormatConstraintScrutinizer extends SnakScrutinizer {
|
||||
|
||||
private Map<PropertyIdValue, Pattern> _patterns;
|
||||
private ConstraintFetcher _fetcher;
|
||||
|
||||
public FormatConstraintScrutinizer() {
|
||||
_patterns = new HashMap<>();
|
||||
_fetcher = new ConstraintFetcher();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6,7 +6,6 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openrefine.wikidata.qa.ConstraintFetcher;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.ItemIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue;
|
||||
@ -22,12 +21,10 @@ import org.wikidata.wdtk.datamodel.interfaces.Value;
|
||||
*/
|
||||
public class InverseConstraintScrutinizer extends StatementScrutinizer {
|
||||
|
||||
private ConstraintFetcher _fetcher;
|
||||
private Map<PropertyIdValue, PropertyIdValue> _inverse;
|
||||
private Map<PropertyIdValue, Map<EntityIdValue, Set<EntityIdValue> >> _statements;
|
||||
|
||||
public InverseConstraintScrutinizer() {
|
||||
_fetcher = new ConstraintFetcher();
|
||||
_inverse = new HashMap<>();
|
||||
_statements = new HashMap<>();
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.openrefine.wikidata.qa.ConstraintFetcher;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Statement;
|
||||
@ -19,12 +18,10 @@ import org.wikidata.wdtk.datamodel.interfaces.Statement;
|
||||
*/
|
||||
public class QualifierCompatibilityScrutinizer extends StatementScrutinizer {
|
||||
|
||||
private ConstraintFetcher _fetcher;
|
||||
private Map<PropertyIdValue, Set<PropertyIdValue>> _allowedQualifiers;
|
||||
private Map<PropertyIdValue, Set<PropertyIdValue>> _mandatoryQualifiers;
|
||||
|
||||
public QualifierCompatibilityScrutinizer() {
|
||||
_fetcher = new ConstraintFetcher();
|
||||
_allowedQualifiers = new HashMap<>();
|
||||
_mandatoryQualifiers = new HashMap<>();
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openrefine.wikidata.qa.ConstraintFetcher;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Reference;
|
||||
@ -24,12 +23,10 @@ public class RestrictedPositionScrutinizer extends StatementScrutinizer {
|
||||
|
||||
private Map<PropertyIdValue, SnakPosition> _restrictedPids;
|
||||
private Set<PropertyIdValue> _unrestrictedPids;
|
||||
private ConstraintFetcher _fetcher;
|
||||
|
||||
public RestrictedPositionScrutinizer() {
|
||||
_restrictedPids = new HashMap<>();
|
||||
_unrestrictedPids = new HashSet<>();
|
||||
_fetcher = new ConstraintFetcher();
|
||||
}
|
||||
|
||||
SnakPosition positionRestriction(PropertyIdValue pid) {
|
||||
|
@ -3,7 +3,6 @@ package org.openrefine.wikidata.qa.scrutinizers;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openrefine.wikidata.qa.ConstraintFetcher;
|
||||
import org.openrefine.wikidata.schema.ItemUpdate;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.Statement;
|
||||
@ -15,12 +14,6 @@ import org.wikidata.wdtk.datamodel.interfaces.Statement;
|
||||
*
|
||||
*/
|
||||
public class SingleValueScrutinizer extends ItemEditScrutinizer {
|
||||
|
||||
private ConstraintFetcher _fetcher;
|
||||
|
||||
public SingleValueScrutinizer() {
|
||||
_fetcher = new ConstraintFetcher();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scrutinize(ItemUpdate update) {
|
||||
|
Loading…
Reference in New Issue
Block a user