Search in sources :

Example 1 with OAIDataList

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;
}
Also used : MCRException(org.mycore.common.MCRException) Element(org.jdom2.Element) OAIDataList(org.mycore.oai.pmh.OAIDataList) MCRSet(org.mycore.oai.set.MCRSet)

Example 2 with OAIDataList

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;
}
Also used : OAIDataList(org.mycore.oai.pmh.OAIDataList) CompletableFuture(java.util.concurrent.CompletableFuture) MetadataFormat(org.mycore.oai.pmh.MetadataFormat) MCRSession(org.mycore.common.MCRSession) Header(org.mycore.oai.pmh.Header) Record(org.mycore.oai.pmh.Record) MCRTransactionableRunnable(org.mycore.util.concurrent.MCRTransactionableRunnable)

Example 3 with OAIDataList

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;
}
Also used : OAIDataList(org.mycore.oai.pmh.OAIDataList) Record(org.mycore.oai.pmh.Record)

Aggregations

OAIDataList (org.mycore.oai.pmh.OAIDataList)3 Record (org.mycore.oai.pmh.Record)2 CompletableFuture (java.util.concurrent.CompletableFuture)1 Element (org.jdom2.Element)1 MCRException (org.mycore.common.MCRException)1 MCRSession (org.mycore.common.MCRSession)1 Header (org.mycore.oai.pmh.Header)1 MetadataFormat (org.mycore.oai.pmh.MetadataFormat)1 MCRSet (org.mycore.oai.set.MCRSet)1 MCRTransactionableRunnable (org.mycore.util.concurrent.MCRTransactionableRunnable)1