NIHVIVO-646 Sort author list on add author form by authorship rank
This commit is contained in:
parent
c461d2d387
commit
09473b4531
4 changed files with 56 additions and 3 deletions
|
@ -0,0 +1,43 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.beans;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import com.hp.hpl.jena.vocabulary.XSD;
|
||||
|
||||
public class DataPropertyComparator implements Comparator<Individual> {
|
||||
|
||||
private String dataPropertyUri = null;
|
||||
|
||||
public DataPropertyComparator(String dataPropertyUri) {
|
||||
this.dataPropertyUri = dataPropertyUri;
|
||||
}
|
||||
|
||||
public int compare(Individual ind1, Individual ind2) {
|
||||
DataPropertyStatement s1 = ind1.getDataPropertyStatement(dataPropertyUri);
|
||||
DataPropertyStatement s2 = ind2.getDataPropertyStatement(dataPropertyUri);
|
||||
|
||||
String datatype = s1.getDatatypeURI();
|
||||
|
||||
int result;
|
||||
|
||||
if (datatype.equals(XSD.xint.toString())) {
|
||||
int i1 = Integer.valueOf(s1.getData());
|
||||
int i2 = Integer.valueOf(s2.getData());
|
||||
result = ((Integer) i1).compareTo(i2);
|
||||
}
|
||||
else if (datatype.equals(XSD.xstring.toString())) {
|
||||
result = s1.getData().compareTo(s2.getData());
|
||||
}
|
||||
// Fill in other types here
|
||||
else {
|
||||
throw new ClassCastException("Unsupported datatype");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -49,6 +49,7 @@ public interface Individual extends ResourceBean, VitroTimeWindowedResource, Com
|
|||
void setDataPropertyStatements(List<DataPropertyStatement> list);
|
||||
List<DataPropertyStatement> getDataPropertyStatements();
|
||||
List<DataPropertyStatement> getDataPropertyStatements(String propertyUri);
|
||||
DataPropertyStatement getDataPropertyStatement(String propertyUri);
|
||||
|
||||
List<String> getDataValues(String propertyUri);
|
||||
String getDataValue(String propertyUri);
|
||||
|
|
|
@ -140,6 +140,11 @@ public class IndividualImpl extends BaseResourceBean implements Individual, Comp
|
|||
return stmtsForProp;
|
||||
}
|
||||
|
||||
public DataPropertyStatement getDataPropertyStatement(String propertyUri) {
|
||||
List<DataPropertyStatement> stmts = getDataPropertyStatements(propertyUri);
|
||||
return stmts.isEmpty() ? null : stmts.get(0);
|
||||
}
|
||||
|
||||
public List<String> getDataValues(String propertyUri) {
|
||||
List<DataPropertyStatement> stmts = getDataPropertyStatements(propertyUri);
|
||||
List<String> dataValues = new ArrayList<String>(stmts.size());
|
||||
|
|
|
@ -86,8 +86,6 @@ public class IndividualFiltering implements Individual {
|
|||
return outDstmts;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Map<String, DataProperty> getDataPropertyMap() {
|
||||
Map<String,DataProperty> innerMap = _innerIndividual.getDataPropertyMap();
|
||||
if( innerMap == null )
|
||||
|
@ -600,6 +598,12 @@ public class IndividualFiltering implements Individual {
|
|||
return stmts.isEmpty() ? null : stmts.get(0).getData();
|
||||
}
|
||||
|
||||
public DataPropertyStatement getDataPropertyStatement(String propertyUri) {
|
||||
List<DataPropertyStatement> stmts = getDataPropertyStatements(propertyUri);
|
||||
// Since the statements have been filtered, we can just take the first data value without filtering.
|
||||
return stmts.isEmpty() ? null : stmts.get(0);
|
||||
}
|
||||
|
||||
public List<Individual> getRelatedIndividuals(String propertyUri) {
|
||||
List<ObjectPropertyStatement> stmts = getObjectPropertyStatements(propertyUri);
|
||||
// Since the statements have been filtered, we can just take the individuals without filtering.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue