Search in sources :

Example 41 with HarvestedRecord

use of cz.mzk.recordmanager.server.model.HarvestedRecord in project RecordManager2 by moravianlibrary.

the class HarvestedRecordLimitedRowMapper method mapRow.

@Override
public HarvestedRecord mapRow(ResultSet rs, int rowNum) throws SQLException {
    HarvestedRecordUniqueId id = new HarvestedRecordUniqueId(oaiHarvestConfigurationDao.load(rs.getLong("IMPORT_CONF_ID")), rs.getString("RECORD_ID"));
    HarvestedRecord harvestedRecord = new HarvestedRecord(id);
    harvestedRecord.setPublicationYear(rs.getLong("PUBLICATION_YEAR"));
    harvestedRecord.setFormat(rs.getString("FORMAT"));
    return harvestedRecord;
}
Also used : HarvestedRecordUniqueId(cz.mzk.recordmanager.server.model.HarvestedRecord.HarvestedRecordUniqueId) HarvestedRecord(cz.mzk.recordmanager.server.model.HarvestedRecord)

Example 42 with HarvestedRecord

use of cz.mzk.recordmanager.server.model.HarvestedRecord in project RecordManager2 by moravianlibrary.

the class DelegatingSolrRecordMapper method getMapper.

protected SolrRecordMapper getMapper(DedupRecord dedupRecord, List<HarvestedRecord> records) {
    HarvestedRecord leadingRecord = records.get(0);
    SolrRecordMapper mapper = mapperByFormat.get(leadingRecord.getFormat());
    return mapper;
}
Also used : HarvestedRecord(cz.mzk.recordmanager.server.model.HarvestedRecord)

Example 43 with HarvestedRecord

use of cz.mzk.recordmanager.server.model.HarvestedRecord in project RecordManager2 by moravianlibrary.

the class DeletedHarvestedRecordsWriter method write.

@Override
public void write(List<? extends HarvestedRecord> records) throws Exception {
    List<String> ids = new ArrayList<String>(records.size());
    for (HarvestedRecord record : records) {
        ids.add(IndexingUtils.getSolrId(record));
    }
    logger.trace("About to delete: {}", ids);
    server.deleteById(ids);
}
Also used : ArrayList(java.util.ArrayList) HarvestedRecord(cz.mzk.recordmanager.server.model.HarvestedRecord)

Example 44 with HarvestedRecord

use of cz.mzk.recordmanager.server.model.HarvestedRecord in project RecordManager2 by moravianlibrary.

the class IndexIndividualHarvestedRecordsTasklet method execute.

@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
    SolrServerFacade solrServer = solrServerFactory.create(solrUrl, null, LoggingSolrIndexingExceptionHandler.INSTANCE);
    List<SolrInputDocument> documents = new ArrayList<SolrInputDocument>(recordIds.size());
    for (String solrId : recordIds) {
        HarvestedRecord rec = harvestedRecordDao.findBySolrId(solrId);
        if (rec == null) {
            throw new IllegalArgumentException(String.format("Harvested record %s not found", solrId));
        }
        SolrInputDocument document = solrInputDocumentFactory.create(rec);
        documents.add(SolrUtils.removeHiddenFields(document));
    }
    solrServer.add(documents, commitWithinMs);
    solrServer.commit();
    return RepeatStatus.FINISHED;
}
Also used : SolrInputDocument(org.apache.solr.common.SolrInputDocument) ArrayList(java.util.ArrayList) SolrServerFacade(cz.mzk.recordmanager.server.solr.SolrServerFacade) HarvestedRecord(cz.mzk.recordmanager.server.model.HarvestedRecord)

Example 45 with HarvestedRecord

use of cz.mzk.recordmanager.server.model.HarvestedRecord in project RecordManager2 by moravianlibrary.

the class IndexIndividualRecordsTasklet method execute.

@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
    SolrServerFacade solrServer = solrServerFactory.create(solrUrl, null, LoggingSolrIndexingExceptionHandler.INSTANCE);
    for (String solrId : recordIds) {
        HarvestedRecord rec = harvestedRecordDao.findBySolrId(solrId);
        if (rec == null) {
            throw new IllegalArgumentException(String.format("Harvested record %s not found", solrId));
        }
        DedupRecord dedupRecord = rec.getDedupRecord();
        if (dedupRecord == null) {
            throw new IllegalArgumentException(String.format("Harvested record %s is not deduplicated, run dedup first.", solrId));
        }
        List<HarvestedRecord> records = harvestedRecordDao.getByDedupRecord(dedupRecord);
        List<SolrInputDocument> documents = solrInputDocumentFactory.create(dedupRecord, records);
        documents = SolrUtils.removeHiddenFields(documents);
        solrServer.add(documents, commitWithinMs);
    }
    solrServer.commit();
    return RepeatStatus.FINISHED;
}
Also used : SolrInputDocument(org.apache.solr.common.SolrInputDocument) DedupRecord(cz.mzk.recordmanager.server.model.DedupRecord) SolrServerFacade(cz.mzk.recordmanager.server.solr.SolrServerFacade) HarvestedRecord(cz.mzk.recordmanager.server.model.HarvestedRecord)

Aggregations

HarvestedRecord (cz.mzk.recordmanager.server.model.HarvestedRecord)60 Test (org.testng.annotations.Test)20 InputStream (java.io.InputStream)19 ByteArrayInputStream (java.io.ByteArrayInputStream)18 AbstractTest (cz.mzk.recordmanager.server.AbstractTest)16 HashMap (java.util.HashMap)16 MarcRecord (cz.mzk.recordmanager.server.marc.MarcRecord)15 Date (java.util.Date)14 JobParameters (org.springframework.batch.core.JobParameters)14 HarvestedRecordUniqueId (cz.mzk.recordmanager.server.model.HarvestedRecord.HarvestedRecordUniqueId)12 JobParameter (org.springframework.batch.core.JobParameter)12 MarcRecordImpl (cz.mzk.recordmanager.server.marc.MarcRecordImpl)9 Record (org.marc4j.marc.Record)9 JobExecution (org.springframework.batch.core.JobExecution)8 Job (org.springframework.batch.core.Job)6 OAIHarvestConfiguration (cz.mzk.recordmanager.server.model.OAIHarvestConfiguration)5 ArrayList (java.util.ArrayList)5 List (java.util.List)5 DedupRecord (cz.mzk.recordmanager.server.model.DedupRecord)4 FulltextKramerius (cz.mzk.recordmanager.server.model.FulltextKramerius)3