mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-16 14:33:09 +00:00
119612: Fix limit not applying on export
This commit is contained in:
@@ -139,8 +139,6 @@ public class MetadataExportSearch extends DSpaceRunnable<MetadataExportSearchScr
|
|||||||
DiscoverQuery discoverQuery =
|
DiscoverQuery discoverQuery =
|
||||||
queryBuilder.buildQuery(context, dso, discoveryConfiguration, query, queryBuilderSearchFilters,
|
queryBuilder.buildQuery(context, dso, discoveryConfiguration, query, queryBuilderSearchFilters,
|
||||||
"Item", 10, Long.getLong("0"), null, SortOption.DESCENDING);
|
"Item", 10, Long.getLong("0"), null, SortOption.DESCENDING);
|
||||||
// add configured limit
|
|
||||||
discoverQuery.setMaxResults(metadataDSpaceCsvExportService.getCsvExportLimit());
|
|
||||||
handler.logDebug("creating iterator");
|
handler.logDebug("creating iterator");
|
||||||
|
|
||||||
Iterator<Item> itemIterator = searchService.iteratorSearch(context, dso, discoverQuery);
|
Iterator<Item> itemIterator = searchService.iteratorSearch(context, dso, discoverQuery);
|
||||||
|
@@ -90,9 +90,11 @@ public class MetadataDSpaceCsvExportServiceImpl implements MetadataDSpaceCsvExpo
|
|||||||
Context.Mode originalMode = context.getCurrentMode();
|
Context.Mode originalMode = context.getCurrentMode();
|
||||||
context.setMode(Context.Mode.READ_ONLY);
|
context.setMode(Context.Mode.READ_ONLY);
|
||||||
|
|
||||||
// Process each item
|
// Process each item until we reach the limit
|
||||||
|
int itemExportLimit = getCsvExportLimit();
|
||||||
DSpaceCSV csv = new DSpaceCSV(exportAll);
|
DSpaceCSV csv = new DSpaceCSV(exportAll);
|
||||||
while (toExport.hasNext()) {
|
|
||||||
|
for (int itemsAdded = 0; toExport.hasNext() && itemsAdded < itemExportLimit; itemsAdded++) {
|
||||||
Item item = toExport.next();
|
Item item = toExport.next();
|
||||||
csv.addItem(item);
|
csv.addItem(item);
|
||||||
context.uncacheEntity(item);
|
context.uncacheEntity(item);
|
||||||
@@ -121,16 +123,14 @@ public class MetadataDSpaceCsvExportServiceImpl implements MetadataDSpaceCsvExpo
|
|||||||
private Iterator<Item> buildFromCommunity(Context context, Community community)
|
private Iterator<Item> buildFromCommunity(Context context, Community community)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
Set<Item> result = new HashSet<>();
|
Set<Item> result = new HashSet<>();
|
||||||
int itemsAdded = 0;
|
|
||||||
|
|
||||||
// Add all the collections
|
// Add all the collections
|
||||||
List<Collection> collections = community.getCollections();
|
List<Collection> collections = community.getCollections();
|
||||||
for (Collection collection : collections) {
|
for (Collection collection : collections) {
|
||||||
// Never obtain more items than the configured limit
|
// Never obtain more items than the configured limit
|
||||||
Iterator<Item> items = itemService.findByCollection(context, collection, getCsvExportLimit(), 0);
|
Iterator<Item> items = itemService.findByCollection(context, collection, getCsvExportLimit(), 0);
|
||||||
while (itemsAdded <= getCsvExportLimit() && items.hasNext()) {
|
while (result.size() < getCsvExportLimit() && items.hasNext()) {
|
||||||
result.add(items.next());
|
result.add(items.next());
|
||||||
itemsAdded++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,9 +138,8 @@ public class MetadataDSpaceCsvExportServiceImpl implements MetadataDSpaceCsvExpo
|
|||||||
List<Community> communities = community.getSubcommunities();
|
List<Community> communities = community.getSubcommunities();
|
||||||
for (Community subCommunity : communities) {
|
for (Community subCommunity : communities) {
|
||||||
Iterator<Item> items = buildFromCommunity(context, subCommunity);
|
Iterator<Item> items = buildFromCommunity(context, subCommunity);
|
||||||
while (itemsAdded <= getCsvExportLimit() && items.hasNext()) {
|
while (result.size() < getCsvExportLimit() && items.hasNext()) {
|
||||||
result.add(items.next());
|
result.add(items.next());
|
||||||
itemsAdded++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user