use of org.codice.ddf.commands.util.QueryResultIterable in project ddf by codice.
the class ExportCommand method doMetacardExport.
private List<ExportItem> doMetacardExport(/*Mutable,IO*/
ZipFile zipFile, Filter filter) {
Set<String> seenIds = new HashSet<>(1024);
List<ExportItem> exportedItems = new ArrayList<>();
for (Result result : new QueryResultIterable(catalogFramework, (i) -> getQuery(filter, i, PAGE_SIZE), PAGE_SIZE)) {
if (!seenIds.contains(result.getMetacard().getId())) {
writeToZip(zipFile, result);
exportedItems.add(new ExportItem(result.getMetacard().getId(), getTag(result), result.getMetacard().getResourceURI(), getDerivedResources(result)));
seenIds.add(result.getMetacard().getId());
}
// Fetch and export all history for each exported item
for (Result revision : new QueryResultIterable(catalogFramework, (i) -> getQuery(getHistoryFilter(result), i, PAGE_SIZE), PAGE_SIZE)) {
if (seenIds.contains(revision.getMetacard().getId())) {
continue;
}
writeToZip(zipFile, revision);
exportedItems.add(new ExportItem(revision.getMetacard().getId(), getTag(revision), revision.getMetacard().getResourceURI(), getDerivedResources(result)));
seenIds.add(revision.getMetacard().getId());
}
}
return exportedItems;
}
Aggregations