Merge r5930 from nihvivo-rel-1.1-maint

This commit is contained in:
rjy7 2010-09-24 14:01:01 +00:00
parent 0ed41e7203
commit 715fad38f4

View file

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