Merge r5849 from nihvivo-rel-1.1-maint
This commit is contained in:
parent
a85ff29b1b
commit
b605b9ca89
1 changed files with 31 additions and 9 deletions
|
@ -10,6 +10,7 @@ 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;
|
||||||
|
@ -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
|
//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.
|
||||||
|
// 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,
|
Collections.sort(stmtsForClass,
|
||||||
new Comparator<ObjectPropertyStatement>() {
|
new Comparator<ObjectPropertyStatement>() {
|
||||||
public int compare(ObjectPropertyStatement o1,
|
public int compare(ObjectPropertyStatement o1,
|
||||||
|
@ -514,6 +520,8 @@ public class EntityMergedPropertyListController extends VitroHttpServlet {
|
||||||
o2.getObject().getName());
|
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: "
|
||||||
|
@ -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) {
|
private List<Individual> getObjectsFromStmts(List<ObjectPropertyStatement> orgStmtList) {
|
||||||
List<Individual> individuals = new LinkedList<Individual>();
|
List<Individual> individuals = new LinkedList<Individual>();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue