Search in sources :

Example 11 with DedupRecord

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

the class SolrInputDocumentFactoryImpl method create.

public List<SolrInputDocument> create(DedupRecord dedupRecord, List<HarvestedRecord> records) {
    if (records.isEmpty()) {
        return null;
    }
    List<SolrInputDocument> childs = records.stream().map(rec -> create(rec)).collect(Collectors.toCollection(ArrayList::new));
    SolrUtils.sortByWeight(childs);
    HarvestedRecord record = records.get(0);
    SolrInputDocument mergedDocument = asSolrDocument(mapper.map(dedupRecord, records));
    mergedDocument.addField(SolrFieldConstants.ID_FIELD, dedupRecord.getId());
    mergedDocument.addField(SolrFieldConstants.MERGED_FIELD, 1);
    mergedDocument.addField(SolrFieldConstants.WEIGHT, record.getWeight());
    mergedDocument.addField(SolrFieldConstants.LOCAL_IDS_FIELD, getLocalIds(childs));
    if (childs.size() > 1)
        mergedDocument.addField(SolrFieldConstants.MERGED_RECORDS, 1);
    mergedDocument.addField(SolrFieldConstants.INSPIRATION, getInspirations(records));
    dedupRecordEnrichers.forEach(enricher -> enricher.enrich(dedupRecord, mergedDocument, childs));
    mergedDocument.addChildDocuments(childs);
    if (logger.isTraceEnabled()) {
        logger.info("Mapping of dedupRecord with id = {} finished", dedupRecord.getId());
    }
    return Collections.singletonList(mergedDocument);
}
Also used : Arrays(java.util.Arrays) Logger(org.slf4j.Logger) Inspiration(cz.mzk.recordmanager.server.model.Inspiration) SolrUtils(cz.mzk.recordmanager.server.util.SolrUtils) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) Collectors(java.util.stream.Collectors) InitializingBean(org.springframework.beans.factory.InitializingBean) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) IndexingUtils(cz.mzk.recordmanager.server.util.IndexingUtils) List(java.util.List) Component(org.springframework.stereotype.Component) HarvestedRecord(cz.mzk.recordmanager.server.model.HarvestedRecord) DedupRecord(cz.mzk.recordmanager.server.model.DedupRecord) Map(java.util.Map) Entry(java.util.Map.Entry) HarvestedRecordEnricher(cz.mzk.recordmanager.server.index.enrich.HarvestedRecordEnricher) Collections(java.util.Collections) DedupRecordEnricher(cz.mzk.recordmanager.server.index.enrich.DedupRecordEnricher) SolrInputDocument(org.apache.solr.common.SolrInputDocument) SolrInputDocument(org.apache.solr.common.SolrInputDocument) HarvestedRecord(cz.mzk.recordmanager.server.model.HarvestedRecord)

Example 12 with DedupRecord

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

the class DedupRecordRowMapper method mapRow.

@Override
public DedupRecord mapRow(ResultSet rs, int rowNum) throws SQLException {
    DedupRecord record = new DedupRecord();
    record.setId(rs.getLong(columnName));
    return record;
}
Also used : DedupRecord(cz.mzk.recordmanager.server.model.DedupRecord)

Example 13 with DedupRecord

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

the class DedupRecordDAOTest method test.

@Test
public void test() {
    DedupRecord record = new DedupRecord();
    dedupRecordDao.persist(record);
}
Also used : DedupRecord(cz.mzk.recordmanager.server.model.DedupRecord) Test(org.testng.annotations.Test) AbstractTest(cz.mzk.recordmanager.server.AbstractTest)

Example 14 with DedupRecord

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

the class KrameriusFulltextWriter method write.

@Override
public void write(List<? extends HarvestedRecord> items) throws Exception {
    try {
        for (HarvestedRecord hr : items) {
            DedupRecord dr = hr.getDedupRecord();
            if (dr != null) {
                dr.setUpdated(new Date());
                dedupDao.persist(dr);
            }
            recordDao.persist(hr);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : DedupRecord(cz.mzk.recordmanager.server.model.DedupRecord) Date(java.util.Date) HarvestedRecord(cz.mzk.recordmanager.server.model.HarvestedRecord)

Aggregations

DedupRecord (cz.mzk.recordmanager.server.model.DedupRecord)14 AbstractTest (cz.mzk.recordmanager.server.AbstractTest)7 ArrayList (java.util.ArrayList)7 SolrInputDocument (org.apache.solr.common.SolrInputDocument)7 Test (org.testng.annotations.Test)7 UrlDedupRecordEnricher (cz.mzk.recordmanager.server.index.enrich.UrlDedupRecordEnricher)5 HarvestedRecord (cz.mzk.recordmanager.server.model.HarvestedRecord)4 Date (java.util.Date)4 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 Component (org.springframework.stereotype.Component)2 HashMultiset (com.google.common.collect.HashMultiset)1 Multiset (com.google.common.collect.Multiset)1 DedupRecordEnricher (cz.mzk.recordmanager.server.index.enrich.DedupRecordEnricher)1