Merge r5980 from nihvivo-rel-1.1.-maint: custom sorting and collation.

This commit is contained in:
rjy7 2010-09-29 19:48:21 +00:00
parent 5bb2fe05b7
commit a83304b5b8

View file

@ -483,11 +483,17 @@ public class EntityMergedPropertyListController extends VitroHttpServlet {
}
Map<String,VClass> directClasses = getDirectClasses( getObjectsFromStmts( orgStmtList ) );
//don't do collateBySubclass if there is only one class
if( directClasses.size() < 2 ) {
prop.setCollateBySubclass(false); //this overrides the value from the model
}
else{
// rjy7 Removed this, so we still get the heading for the single populated subclass
//prop.setCollateBySubclass(false); //this overrides the value from the model
// Still need to apply custom sort. Since we no longer set collateBySubclass to false,
// we won't know in applyCustomSortToUncollatedProperty whether the statements have
// been sorted or not, so we must do that now.
applyCustomSortToUncollatedStatements(prop, orgStmtList);
} else {
log.debug("statements for object property: " + orgStmtList.size());
//get list of direct classes and sort them
List<VClass> vclasses = new LinkedList<VClass>(directClasses.values());
@ -624,18 +630,19 @@ public class EntityMergedPropertyListController extends VitroHttpServlet {
return false;
}
private void applyCustomSortToUncollatedProperty(ObjectProperty op, List<ObjectPropertyStatement> opStmts) {
if (!op.getCollateBySubclass()) {
applyCustomSortToUncollatedStatements(op, opStmts);
}
}
// Apply custom sorting to an uncollated property. If the property is collated, the custom sorting has already
// been applied to each subclass listing individually.
private void applyCustomSortToUncollatedProperty(ObjectProperty op, List<ObjectPropertyStatement> opStmts) {
// This includes the case where the ontology doesn't specify collating, as well as the case
// where we don't collate because only one subclass is populated, since then we've set
// the collation value to false.
if (!op.getCollateBySubclass()) {
private void applyCustomSortToUncollatedStatements(ObjectProperty op, List<ObjectPropertyStatement> opStmts) {
if (applyCustomSort(op, opStmts)) {
op.setObjectPropertyStatements(opStmts);
}
}
}
private void sortReverseChron(List<ObjectPropertyStatement> statements, String endYearPredicate, String startYearPredicate) {
// 1. Sort by end year descending, nulls first