use of org.mycore.oai.pmh.OAIDataList in project mycore by MyCoRe-Org.
the class MCROAISetManager method createSetList.
protected OAIDataList<MCRSet> createSetList() {
OAIDataList<MCRSet> setList = new OAIDataList<>();
synchronized (this.setConfigurationMap) {
for (MCROAISetConfiguration<?, ?, ?> conf : this.setConfigurationMap.values()) {
MCROAISetHandler<?, ?, ?> handler = conf.getHandler();
Map<String, MCRSet> setMap = handler.getSetMap();
synchronized (setMap) {
setMap.clear();
Element resolved = MCRURIResolver.instance().resolve(conf.getURI());
if (resolved == null) {
throw new MCRException("Could not resolve set URI " + conf.getURI() + " for set " + conf.getId() + ".");
}
for (Element setElement : resolved.getChildren("set", OAIConstants.NS_OAI)) {
MCRSet set = createSet(conf.getId(), setElement);
setMap.put(set.getSpec(), set);
if (!contains(set.getSpec(), setList)) {
if (!handler.filter(set)) {
setList.add(set);
}
}
}
}
}
}
return setList;
}
use of org.mycore.oai.pmh.OAIDataList in project mycore by MyCoRe-Org.
the class MCROAISearchManager method getRecordListParallel.
private OAIDataList<Record> getRecordListParallel(MCROAISearcher searcher, MCROAIResult result) {
List<Header> headerList = result.list();
int listSize = headerList.size();
Record[] records = new Record[listSize];
@SuppressWarnings("rawtypes") CompletableFuture[] futures = new CompletableFuture[listSize];
MetadataFormat metadataFormat = searcher.getMetadataFormat();
MCRSession mcrSession = MCRSessionMgr.getCurrentSession();
for (int i = 0; i < listSize; i++) {
Header header = headerList.get(i);
int resultIndex = i;
MCRTransactionableRunnable r = new MCRTransactionableRunnable(() -> records[resultIndex] = this.objManager.getRecord(header, metadataFormat), mcrSession);
CompletableFuture<Void> future = CompletableFuture.runAsync(r, executorService);
futures[i] = future;
}
CompletableFuture.allOf(futures).join();
OAIDataList<Record> recordList = new OAIDataList<>();
recordList.addAll(Arrays.asList(records));
return recordList;
}
use of org.mycore.oai.pmh.OAIDataList in project mycore by MyCoRe-Org.
the class MCROAISearchManager method getRecordListSequential.
private OAIDataList<Record> getRecordListSequential(MCROAISearcher searcher, MCROAIResult result) {
OAIDataList<Record> recordList = new OAIDataList<>();
result.list().forEach(header -> {
Record record = this.objManager.getRecord(header, searcher.getMetadataFormat());
recordList.add(record);
});
return recordList;
}
Aggregations