List<HistoryProcessInstanceRef> refs = new ArrayList<HistoryProcessInstanceRef>();
for (String theInstanceID : historyInstanceIds) {
List<Event> theEvents = ds.getPastActivities(theInstanceID);
HistoryProcessInstanceRef ref = new HistoryProcessInstanceRef();
for (Event e : theEvents) {
ref.setProcessInstanceId(e.getProcessInstanceID());
ref.setState(status);
ref.setProcessDefinitionId(e.getProcessDefinitionID());
for (Tuple tuple : e.getDataElement()) {
if ("correlation-key".equals(tuple.getName())) {
ref.setKey(tuple.getValue());
}
if ("process-start-time".equals(tuple.getName())) {
ref.setStartTime(new Date(new Long(tuple.getValue())));
}
if ("process-end-time".equals(tuple.getName())) {
ref.setEndTime(new Date(new Long(tuple.getValue())));
}
}
}
refs.add(ref);
}