Merge r5849 from nihvivo-rel-1.1-maint

This commit is contained in:
rjy7 2010-09-13 16:08:03 +00:00
parent a85ff29b1b
commit b605b9ca89

View file

@ -10,6 +10,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@ -506,6 +507,11 @@ public class EntityMergedPropertyListController extends VitroHttpServlet {
//types? For now we just show them in whichever type shows up first. related to NIHVIVO-876
orgStmtList.removeAll(stmtsForClass);
// rjy7 Fix for NIHVIVO-426 Sort people in organization listing by name, rather than by the position name.
// This is an ugly hack and we should not refer to ontology properties here. Need a better fix in the long term.
if (prop.getURI().equals("http://vivoweb.org/ontology/core#organizationForPosition")) {
sortByRelatedIndividualNames(stmtsForClass, "http://vivoweb.org/ontology/core#positionForPerson");
} else {
Collections.sort(stmtsForClass,
new Comparator<ObjectPropertyStatement>() {
public int compare(ObjectPropertyStatement o1,
@ -514,6 +520,8 @@ public class EntityMergedPropertyListController extends VitroHttpServlet {
o2.getObject().getName());
}
});
}
System.out.println("stmtsForclass size after sort: "
+ stmtsForClass.size());
System.out.println("sortedStmtList size before add: "
@ -527,7 +535,21 @@ public class EntityMergedPropertyListController extends VitroHttpServlet {
}
private void sortByRelatedIndividualNames(List<ObjectPropertyStatement> opStmts, String predicateUri) {
final LinkedHashMap<ObjectPropertyStatement, String> stmtsToNames = new LinkedHashMap<ObjectPropertyStatement, String>(opStmts.size());
for (ObjectPropertyStatement stmt : opStmts) {
Individual relatedIndividual = stmt.getObject().getRelatedIndividual(predicateUri);
String relatedIndividualName = relatedIndividual != null ? relatedIndividual.getName() : "";
stmtsToNames.put(stmt, relatedIndividualName);
}
// Sort the object property statements by the names
Collections.sort(opStmts, new Comparator<ObjectPropertyStatement>() {
public int compare(ObjectPropertyStatement left, ObjectPropertyStatement right) {
return stmtsToNames.get(left).compareTo(stmtsToNames.get(right));
}
});
}
private List<Individual> getObjectsFromStmts(List<ObjectPropertyStatement> orgStmtList) {
List<Individual> individuals = new LinkedList<Individual>();