NIHVIVO-746 Handle unranked authorships in add authors to publication form.

This commit is contained in:
rjy7 2010-07-05 16:58:43 +00:00
parent d3737502c9
commit 36f0714549

View file

@ -15,26 +15,33 @@ public class DataPropertyComparator implements Comparator<Individual> {
} }
public int compare(Individual ind1, Individual ind2) { public int compare(Individual ind1, Individual ind2) {
DataPropertyStatement s1 = ind1.getDataPropertyStatement(dataPropertyUri); DataPropertyStatement dps1 = ind1.getDataPropertyStatement(dataPropertyUri);
DataPropertyStatement s2 = ind2.getDataPropertyStatement(dataPropertyUri); DataPropertyStatement dps2 = ind2.getDataPropertyStatement(dataPropertyUri);
String datatype = s1.getDatatypeURI();
int result; int result;
if (datatype.equals(XSD.xint.toString())) { // This pushes null values to the end of the list
int i1 = Integer.valueOf(s1.getData()); if (dps1 == null) {
int i2 = Integer.valueOf(s2.getData()); result = (dps2 == null) ? 0 : 1;
result = ((Integer) i1).compareTo(i2); } else if (dps2 == null) {
} result = -1;
else if (datatype.equals(XSD.xstring.toString())) { } else {
result = s1.getData().compareTo(s2.getData());
}
// Fill in other types here
else {
throw new ClassCastException("Unsupported datatype");
}
String datatype = dps1.getDatatypeURI();
if (datatype.equals(XSD.xint.toString())) {
int i1 = Integer.valueOf(dps1.getData());
int i2 = Integer.valueOf(dps2.getData());
result = ((Integer) i1).compareTo(i2);
}
else if (datatype.equals(XSD.xstring.toString())) {
result = dps1.getData().compareTo(dps2.getData());
}
// Fill in other types here
else {
throw new ClassCastException("Unsupported datatype");
}
}
return result; return result;
} }