Add info issues for empty edits and no warnings
This commit is contained in:
parent
5891f8c270
commit
e920c0f421
@ -92,6 +92,14 @@
|
||||
"single-valued-property-added-more-than-once": {
|
||||
"title": "Single valued property added more than once.",
|
||||
"body": "A property that is expected to be used at most once on each item has been added multiple times on the same item."
|
||||
},
|
||||
"no-edit-generated": {
|
||||
"title": "No edit was generated.",
|
||||
"body": "There might be something wrong with your schema."
|
||||
},
|
||||
"no-issue-detected": {
|
||||
"title": "No issue was detected in your edits.",
|
||||
"body": "Note that OpenRefine cannot detect all the types of problems Wikidata edits can have."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import org.openrefine.wikidata.qa.scrutinizers.EditScrutinizer;
|
||||
import org.openrefine.wikidata.qa.scrutinizers.FormatConstraintScrutinizer;
|
||||
import org.openrefine.wikidata.qa.scrutinizers.InverseConstraintScrutinizer;
|
||||
import org.openrefine.wikidata.qa.scrutinizers.NewItemScrutinizer;
|
||||
import org.openrefine.wikidata.qa.scrutinizers.NoEditsMadeScrutinizer;
|
||||
import org.openrefine.wikidata.qa.scrutinizers.QualifierCompatibilityScrutinizer;
|
||||
import org.openrefine.wikidata.qa.scrutinizers.RestrictedPositionScrutinizer;
|
||||
import org.openrefine.wikidata.qa.scrutinizers.SelfReferentialScrutinizer;
|
||||
@ -37,6 +38,7 @@ public class EditInspector {
|
||||
register(new RestrictedPositionScrutinizer());
|
||||
register(new QualifierCompatibilityScrutinizer());
|
||||
register(new SingleValueScrutinizer());
|
||||
register(new NoEditsMadeScrutinizer());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,6 +60,11 @@ public class EditInspector {
|
||||
for(EditScrutinizer scrutinizer : scrutinizers.values()) {
|
||||
scrutinizer.scrutinize(editBatch);
|
||||
}
|
||||
|
||||
if (warningStore.getNbWarnings() == 0) {
|
||||
warningStore.addWarning(new QAWarning(
|
||||
"no-issue-detected", null, QAWarning.Severity.INFO, 0));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,6 +16,7 @@ public class QAWarningStore {
|
||||
|
||||
private Map<String, QAWarning> map;
|
||||
private QAWarning.Severity maxSeverity;
|
||||
private int totalWarnings;
|
||||
|
||||
public QAWarningStore() {
|
||||
this.map = new HashMap<>();
|
||||
@ -32,6 +33,7 @@ public class QAWarningStore {
|
||||
if (severity.compareTo(maxSeverity) > 0) {
|
||||
maxSeverity = severity;
|
||||
}
|
||||
totalWarnings += warning.getCount();
|
||||
if (map.containsKey(aggregationKey)) {
|
||||
QAWarning existing = map.get(aggregationKey);
|
||||
existing.aggregate(warning);
|
||||
@ -57,4 +59,12 @@ public class QAWarningStore {
|
||||
QAWarning.Severity getMaxSeverity() {
|
||||
return maxSeverity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total number of warnings
|
||||
*/
|
||||
@JsonProperty("nb_warnings")
|
||||
int getNbWarnings() {
|
||||
return totalWarnings;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
package org.openrefine.wikidata.qa.scrutinizers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.openrefine.wikidata.schema.ItemUpdate;
|
||||
|
||||
|
||||
public class NoEditsMadeScrutinizer extends EditScrutinizer {
|
||||
|
||||
@Override
|
||||
public void scrutinize(List<ItemUpdate> edit) {
|
||||
if(edit.stream().allMatch(e -> e.isNull())) {
|
||||
info("no-edit-generated");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user