Search in sources :

Example 1 with ListItemIdentifiersResult

use of com.lyncode.xoai.dataprovider.handlers.results.ListItemIdentifiersResult in project dataverse by IQSS.

the class XitemRepository method getItemIdentifiers.

@Override
public ListItemIdentifiersResult getItemIdentifiers(List<ScopedFilter> filters, int offset, int length, String setSpec, Date from, Date until) throws OAIException {
    logger.fine("calling getItemIdentifiers; offset=" + offset + ", length=" + length + ", setSpec=" + setSpec + ", from=" + from + ", until=" + until);
    List<OAIRecord> oaiRecords = recordService.findOaiRecordsBySetName(setSpec, from, until);
    logger.fine("total " + oaiRecords.size() + " returned");
    List<ItemIdentifier> xoaiItems = new ArrayList<>();
    if (oaiRecords != null && !oaiRecords.isEmpty()) {
        for (int i = offset; i < offset + length && i < oaiRecords.size(); i++) {
            OAIRecord record = oaiRecords.get(i);
            xoaiItems.add(new Xitem(record));
        }
        // formatted output in the header:
        if (!StringUtil.isEmpty(setSpec)) {
            addExtraSets(xoaiItems, setSpec, from, until);
        }
        boolean hasMore = offset + length < oaiRecords.size();
        ListItemIdentifiersResult result = new ListItemIdentifiersResult(hasMore, xoaiItems);
        logger.fine("returning result with " + xoaiItems.size() + " items.");
        return result;
    }
    return new ListItemIdentifiersResult(false, xoaiItems);
}
Also used : ItemIdentifier(com.lyncode.xoai.dataprovider.model.ItemIdentifier) OAIRecord(edu.harvard.iq.dataverse.harvest.server.OAIRecord) ArrayList(java.util.ArrayList) ListItemIdentifiersResult(com.lyncode.xoai.dataprovider.handlers.results.ListItemIdentifiersResult)

Aggregations

ListItemIdentifiersResult (com.lyncode.xoai.dataprovider.handlers.results.ListItemIdentifiersResult)1 ItemIdentifier (com.lyncode.xoai.dataprovider.model.ItemIdentifier)1 OAIRecord (edu.harvard.iq.dataverse.harvest.server.OAIRecord)1 ArrayList (java.util.ArrayList)1