VIVO-766 This comparator is invalid under Java 8.
Because subclass/superclass is only a partial ordering, this breaks the contract for Comparator, and throws an IllegalArgumentException under Java 8. In particular, for classes sub, super and other, we have sub=other, sub<super, which should imply other<super, but instead other=super. As far as I can determine, this sort is never used anyway, so there should be no impact in removing it. PropertyInstanceDaoJena sorts these results again before using them, as does GroupedPropertyList.
This commit is contained in:
parent
14d1cdb5bf
commit
d1b07bcffc
1 changed files with 30 additions and 19 deletions
|
@ -564,26 +564,36 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Removed: see VIVO-766.
|
||||||
* sorts VClasses so that subclasses come before superclasses
|
* sorts VClasses so that subclasses come before superclasses
|
||||||
|
*
|
||||||
|
* Because subclass/superclass is only a partial ordering, this breaks the
|
||||||
|
* contract for Comparator, and throws an IllegalArgumentException under Java 8.
|
||||||
|
* In particular, for classes sub, super and other, we have sub=other, sub<super,
|
||||||
|
* which should imply other<super, but that is not true.
|
||||||
|
*
|
||||||
|
* As far as I can determine, this sort is never relied on anyway, so there
|
||||||
|
* should be no impact in removing it. Note that PropertyInstanceDaoJena re-sorts
|
||||||
|
* thes results before using them, so this sort was irrelevant for any calls
|
||||||
|
* through that path.
|
||||||
*/
|
*/
|
||||||
private class VClassHierarchyRanker implements Comparator<VClass> {
|
// private class VClassHierarchyRanker implements Comparator<VClass> {
|
||||||
private VClassDao vcDao;
|
// private VClassDao vcDao;
|
||||||
public VClassHierarchyRanker(VClassDao vcDao) {
|
// public VClassHierarchyRanker(VClassDao vcDao) {
|
||||||
this.vcDao = vcDao;
|
// this.vcDao = vcDao;
|
||||||
}
|
// }
|
||||||
@Override
|
// @Override
|
||||||
public int compare(VClass vc1, VClass vc2) {
|
// public int compare(VClass vc1, VClass vc2) {
|
||||||
if (vcDao.isSubClassOf(vc1, vc2)) {
|
// if (vcDao.isSubClassOf(vc1, vc2)) {
|
||||||
return -1;
|
// return -1;
|
||||||
} else if (vcDao.isSubClassOf(vc2, vc1)) {
|
// } else if (vcDao.isSubClassOf(vc2, vc1)) {
|
||||||
return 1;
|
// return 1;
|
||||||
} else {
|
// } else {
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
|
||||||
public List<PropertyInstance> getAllPropInstByVClass(String classURI) {
|
public List<PropertyInstance> getAllPropInstByVClass(String classURI) {
|
||||||
if (classURI==null || classURI.length()<1) {
|
if (classURI==null || classURI.length()<1) {
|
||||||
|
@ -708,7 +718,8 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
||||||
return propInsts;
|
return propInsts;
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(vclasses, new VClassHierarchyRanker(this.getWebappDaoFactory().getVClassDao()));
|
// Removed: see VIVO-766.
|
||||||
|
// Collections.sort(vclasses, new VClassHierarchyRanker(this.getWebappDaoFactory().getVClassDao()));
|
||||||
|
|
||||||
OntModel ontModel = getOntModelSelector().getTBoxModel();
|
OntModel ontModel = getOntModelSelector().getTBoxModel();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue