* {@link de.danet.an.workflow.api.Process <code>Processes</code>}
* @throws RemoteException if a system-level error occurs.
*/
public RangeAccess processes (FilterCriterion filter, SortCriterion order)
throws RemoteException {
RequestScope scope = RequestLog.enterScope
(this, "processes", new Object[] { filter, order });
ProcessDirectoryRangeAccess res = null;
try {
Criterion filterCriteria = HibernateUtil.convertFilterCriterion(filter);
List orderCriteria = new ArrayList();
while (order != null) {
String sortProp = order.getSortProperty();
if (sortProp.equals("key")) {
sortProp = "dbId";
}
if (order instanceof AscendingOrder) {
orderCriteria.add(Order.asc(sortProp));
} else {
orderCriteria.add(Order.desc(sortProp));
}
order = order.getSubCriterion();
}
// serialize (1) because criteria can only be used once and
// (2) to avoid hibernate classes on client side
byte[] filterData = null;
byte[] orderData = null;
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(filterCriteria);
oos.flush();
oos.close();
filterData = bos.toByteArray();
bos = new ByteArrayOutputStream();
oos = new ObjectOutputStream(bos);
oos.writeObject(orderCriteria);
oos.flush();
oos.close();
orderData = bos.toByteArray();
} catch (IOException e) {
throw (IllegalStateException)
(new IllegalStateException()).initCause(e);
}
res = new ProcessDirectoryRangeAccess
((ExtProcessDirectory)ctx.getEJBObject(),
filterData, orderData);
} finally {
scope.leave (res);
}
return res;
}