Rothamsted / knetbuilder

KnetBuilder data integration platform for building knowledge graphs. Previously known as ondex.
https://knetminer.com
MIT License
12 stars 11 forks source link

AbstractMetaData.equals() is wrong, it should check specific subclasses #16

Closed marco-brandizi closed 5 years ago

marco-brandizi commented 5 years ago

This already fixed. I'm reporting it to keep track of the issue and also to warn that we should keep in mind the changes this fix required, in case of other bugs or strange behaviours.

AbstractMetaData.equals( o ) is fine when the o.getClass() is MetaData. I've discovered that this wrong in a case where I had a ConceptClass with ID Chromosome and an AttributeName with the same ID = 'Chromosome'. If you compare them with the current implementation, they result equal, cause it's the same ID, however they are obviously two different entity types.

Exact match of this.getClass() and o.getClass() doesn't seem to be enough either, since, for instance, ConceptClassImplA and ConceptClassImplB should be considered the same if they don't differ conceptually. The solution is checking against the right interface in the right hierarchy level (e.g., o.getClass () instanceof AttributeName).