}
}
// Ordering
if (filter.getOrders() != null) {
ComparatorChain cchain = new ComparatorChain();
for (String key : filter.getOrders()) {
boolean ascending = true;
String orderKey = key;
if (key.startsWith("+") || key.startsWith("-")) {
orderKey = key.substring(1, key.length());
if (key.startsWith("-"))
ascending = false;
}
Comparator c;
if ("name".equals(orderKey))
c = new Comparator<ProcessConf>() {
public int compare(ProcessConf o1, ProcessConf o2) {
return o1.getProcessId().getLocalPart().compareTo(o2.getProcessId().getLocalPart());
}
};
else if ("namespace".equals(orderKey))
c = new Comparator<ProcessConf>() {
public int compare(ProcessConf o1, ProcessConf o2) {
String ns1 = o1.getProcessId().getNamespaceURI() == null ? "" : o1.getProcessId()
.getNamespaceURI();
String ns2 = o2.getProcessId().getNamespaceURI() == null ? "" : o2.getProcessId()
.getNamespaceURI();
return ns1.compareTo(ns2);
}
};
else if ("version".equals(orderKey))
c = new Comparator<ProcessConf>() {
public int compare(ProcessConf o1, ProcessConf o2) {
// TODO: implement version comparisons.
return 0;
}
};
else if ("deployed".equals(orderKey))
c = new Comparator<ProcessConf>() {
public int compare(ProcessConf o1, ProcessConf o2) {
return o1.getDeployDate().compareTo(o2.getDeployDate());
}
};
else {
// unrecognized
__log.debug("unrecognized order key" + orderKey);
continue;
}
cchain.addComparator(c, !ascending);
}
Collections.sort(confs, cchain);
}