NIHVIVO-2038 Improve performance of creating grouped property list by keeping a list of object property uris to check against, so a property doesn't have to be instantiated from the propertyUri in order to check whether it's on the list.
This commit is contained in:
parent
cbfa225c31
commit
b8fec2e96c
1 changed files with 23 additions and 12 deletions
|
@ -141,14 +141,23 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mergeAllPossibleObjectProperties(List<ObjectProperty> objectPropertyList, List<Property> propertyList) {
|
private void mergeAllPossibleObjectProperties(List<ObjectProperty> objectPropertyList, List<Property> propertyList) {
|
||||||
|
|
||||||
|
// Performance improvement: keep a list of uris on the propertyList to check against, rather than
|
||||||
|
// having to instantiate a property from propertyUri to check against the propertyList.
|
||||||
|
List<String> propertyListUris = new ArrayList<String>(propertyList.size());
|
||||||
|
for (Property p : propertyList) {
|
||||||
|
propertyListUris.add(p.getURI());
|
||||||
|
}
|
||||||
|
|
||||||
PropertyInstanceDao piDao = wdf.getPropertyInstanceDao();
|
PropertyInstanceDao piDao = wdf.getPropertyInstanceDao();
|
||||||
Collection<PropertyInstance> allPropInstColl = piDao.getAllPossiblePropInstForIndividual(subject.getURI());
|
Collection<PropertyInstance> allPropInstColl = piDao.getAllPossiblePropInstForIndividual(subject.getURI());
|
||||||
|
|
||||||
if (allPropInstColl != null) {
|
if (allPropInstColl != null) {
|
||||||
ObjectPropertyDao opDao = wdf.getObjectPropertyDao();
|
ObjectPropertyDao opDao = wdf.getObjectPropertyDao();
|
||||||
for (PropertyInstance pi : allPropInstColl) {
|
for (PropertyInstance pi : allPropInstColl) {
|
||||||
if (pi != null) {
|
if (pi != null) {
|
||||||
if (! alreadyOnObjectPropertyList(objectPropertyList, pi)) {
|
if (! alreadyOnObjectPropertyList(objectPropertyList, pi)) {
|
||||||
addIfNotAlreadyOnList(propertyList, pi.getPropertyURI(), opDao);
|
addIfNotAlreadyOnList(propertyList, propertyListUris, pi.getPropertyURI(), opDao);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.error("a property instance in the Collection created by PropertyInstanceDao.getAllPossiblePropInstForIndividual() is unexpectedly null");
|
log.error("a property instance in the Collection created by PropertyInstanceDao.getAllPossiblePropInstForIndividual() is unexpectedly null");
|
||||||
|
@ -158,23 +167,26 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
||||||
// In future, vitro ns props will be phased out. Vitro public properties should be changed so they do no
|
// In future, vitro ns props will be phased out. Vitro public properties should be changed so they do no
|
||||||
// constitute a special case.
|
// constitute a special case.
|
||||||
for (String propertyUri : VITRO_PROPS_TO_ADD_TO_LIST) {
|
for (String propertyUri : VITRO_PROPS_TO_ADD_TO_LIST) {
|
||||||
addIfNotAlreadyOnList(propertyList, propertyUri, opDao);
|
addIfNotAlreadyOnList(propertyList, propertyListUris, propertyUri, opDao);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.error("a null Collection is returned from PropertyInstanceDao.getAllPossiblePropInstForIndividual()");
|
log.error("a null Collection is returned from PropertyInstanceDao.getAllPossiblePropInstForIndividual()");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addIfNotAlreadyOnList(List<Property> propertyList, String propertyUri, ObjectPropertyDao opDao) {
|
private void addIfNotAlreadyOnList(List<Property> propertyList, List<String> propertyListUris, String propertyUri, ObjectPropertyDao opDao) {
|
||||||
|
|
||||||
ObjectProperty op = opDao.getObjectPropertyByURI(propertyUri);
|
if ( ! propertyListUris.contains(propertyUri)) {
|
||||||
if (op == null) {
|
ObjectProperty op = opDao.getObjectPropertyByURI(propertyUri);
|
||||||
log.error("ObjectProperty op returned null from opDao.getObjectPropertyByURI()");
|
if (op == null) {
|
||||||
} else if (op.getURI() == null) {
|
log.error("ObjectProperty op returned null from opDao.getObjectPropertyByURI()");
|
||||||
log.error("ObjectProperty op returned with null propertyURI from opDao.getObjectPropertyByURI()");
|
} else if (op.getURI() == null) {
|
||||||
} else if (! alreadyOnPropertyList(propertyList, op)) {
|
log.error("ObjectProperty op returned with null propertyURI from opDao.getObjectPropertyByURI()");
|
||||||
propertyList.add(op);
|
} else {
|
||||||
}
|
propertyList.add(op);
|
||||||
|
propertyListUris.add(propertyUri);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void mergeAllPossibleDataProperties(List<Property> propertyList) {
|
protected void mergeAllPossibleDataProperties(List<Property> propertyList) {
|
||||||
|
@ -186,7 +198,6 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
||||||
if (dp.getURI() == null) {
|
if (dp.getURI() == null) {
|
||||||
log.error("DataProperty dp returned with null propertyURI from dpDao.getAllPossibleDatapropsForIndividual()");
|
log.error("DataProperty dp returned with null propertyURI from dpDao.getAllPossibleDatapropsForIndividual()");
|
||||||
} else if (! alreadyOnPropertyList(propertyList, dp)) {
|
} else if (! alreadyOnPropertyList(propertyList, dp)) {
|
||||||
//dp.setLabel(dp.getPublicName());
|
|
||||||
propertyList.add(dp);
|
propertyList.add(dp);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue