Fix equality check on custom EntityIdValues
This commit is contained in:
parent
45bc328675
commit
024c8cd6a5
@ -3,6 +3,7 @@ package org.openrefine.wikidata.qa;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.openrefine.wikidata.qa.scrutinizers.EditScrutinizer;
|
||||
import org.openrefine.wikidata.qa.scrutinizers.FormatConstraintScrutinizer;
|
||||
@ -15,6 +16,7 @@ import org.openrefine.wikidata.qa.scrutinizers.SelfReferentialScrutinizer;
|
||||
import org.openrefine.wikidata.qa.scrutinizers.SingleValueScrutinizer;
|
||||
import org.openrefine.wikidata.qa.scrutinizers.UnsourcedScrutinizer;
|
||||
import org.openrefine.wikidata.schema.ItemUpdate;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue;
|
||||
|
||||
/**
|
||||
* Runs a collection of edit scrutinizers on an edit batch
|
||||
@ -57,8 +59,10 @@ public class EditInspector {
|
||||
* @param editBatch
|
||||
*/
|
||||
public void inspect(List<ItemUpdate> editBatch) {
|
||||
Map<EntityIdValue, ItemUpdate> updates = ItemUpdate.groupBySubject(editBatch);
|
||||
List<ItemUpdate> mergedUpdates = updates.values().stream().collect(Collectors.toList());
|
||||
for(EditScrutinizer scrutinizer : scrutinizers.values()) {
|
||||
scrutinizer.scrutinize(editBatch);
|
||||
scrutinizer.scrutinize(mergedUpdates);
|
||||
}
|
||||
|
||||
if (warningStore.getNbWarnings() == 0) {
|
||||
|
@ -1,9 +1,5 @@
|
||||
package org.openrefine.wikidata.schema.entityvalues;
|
||||
|
||||
import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.ItemIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.ValueVisitor;
|
||||
|
||||
/**
|
||||
* A placeholder for the Qid of a new item, which
|
||||
* also remembers from which reconciled cell it was
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.openrefine.wikidata.schema.entityvalues;
|
||||
|
||||
import org.wikidata.wdtk.datamodel.interfaces.EntityIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.ItemIdValue;
|
||||
import org.wikidata.wdtk.datamodel.interfaces.ValueVisitor;
|
||||
|
||||
/**
|
||||
@ -54,4 +53,24 @@ public abstract class TermedEntityIdValue implements EntityIdValue {
|
||||
return valueVisitor.visit(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Equality check is important when we gather
|
||||
* all ItemUpdates related to an ItemId.
|
||||
*
|
||||
* The label is ignored in the equality check.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other == null ||
|
||||
!EntityIdValue.class.isInstance(other)) {
|
||||
return false;
|
||||
}
|
||||
final EntityIdValue otherNew = (EntityIdValue)other;
|
||||
return getIri().equals(otherNew.getIri());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getIri().hashCode();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user