Search in sources :

Example 1 with MetadataFormat

use of org.mycore.oai.pmh.MetadataFormat in project mycore by MyCoRe-Org.

the class MCROAIAdapter method getMetadataFormatMap.

protected Map<String, MetadataFormat> getMetadataFormatMap() {
    Map<String, MetadataFormat> metdataFormatMap = new HashMap<>();
    String formats = this.config.getString(getConfigPrefix() + "MetadataFormats", "");
    StringTokenizer st = new StringTokenizer(formats, ", ");
    while (st.hasMoreTokens()) {
        String format = st.nextToken();
        String namespaceURI = this.config.getString(PREFIX + "MetadataFormat." + format + ".Namespace");
        String schema = this.config.getString(PREFIX + "MetadataFormat." + format + ".Schema");
        metdataFormatMap.put(format, new MetadataFormat(format, namespaceURI, schema));
    }
    return metdataFormatMap;
}
Also used : StringTokenizer(java.util.StringTokenizer) MetadataFormat(org.mycore.oai.pmh.MetadataFormat) HashMap(java.util.HashMap)

Example 2 with MetadataFormat

use of org.mycore.oai.pmh.MetadataFormat 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)

Aggregations

MetadataFormat (org.mycore.oai.pmh.MetadataFormat)2 HashMap (java.util.HashMap)1 StringTokenizer (java.util.StringTokenizer)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 MCRSession (org.mycore.common.MCRSession)1 Header (org.mycore.oai.pmh.Header)1 OAIDataList (org.mycore.oai.pmh.OAIDataList)1 Record (org.mycore.oai.pmh.Record)1 MCRTransactionableRunnable (org.mycore.util.concurrent.MCRTransactionableRunnable)1