Search in sources :

Example 1 with AtomIndexer

use of won.matcher.solr.index.AtomIndexer in project webofneeds by researchstudio-sat.

the class SolrAtomIndexer method main.

public static void main(String[] args) throws IOException, InterruptedException, JsonLdError {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(SolrTestAppConfiguration.class);
    AtomIndexer indexer = ctx.getBean(AtomIndexer.class);
    // set the options of the atom producer (e.g. if it should exhaust) in the
    // SolrAtomIndexerAppConfiguration file
    AtomProducer atomProducer = ctx.getBean(RoundRobinCompositeAtomProducer.class);
    Model atomModel = new AtomModelWrapper(atomProducer.create()).copyAtomModel(AtomGraphType.ATOM);
    int atoms = 0;
    while (!atomProducer.isExhausted()) {
        // indexer.indexAtomModel(atomModel, UUID.randomUUID().toString(), true);
        Dataset ds = DatasetFactory.createTxnMem();
        ds.addNamedModel("https://node.matchat.org/won/resource/atom/test#atom", atomModel);
        AtomModelWrapper atomModelWrapper = new AtomModelWrapper(atomModel, null);
        atomModel = atomModelWrapper.normalizeAtomModel();
        indexer.indexAtomModel(atomModel, SolrMatcherEvaluation.createAtomId(ds), true);
        atoms++;
        if (atoms % 100 == 0) {
            System.out.println("Indexed " + atoms + " atoms.");
        }
        atomModel = new AtomModelWrapper(atomProducer.create()).copyAtomModel(AtomGraphType.ATOM);
    }
    System.out.println("Indexed " + atoms + " atoms.");
    System.exit(0);
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Dataset(org.apache.jena.query.Dataset) Model(org.apache.jena.rdf.model.Model) AtomModelWrapper(won.protocol.util.AtomModelWrapper) AtomProducer(won.bot.framework.component.atomproducer.AtomProducer) RoundRobinCompositeAtomProducer(won.bot.framework.component.atomproducer.impl.RoundRobinCompositeAtomProducer) AtomIndexer(won.matcher.solr.index.AtomIndexer)

Aggregations

Dataset (org.apache.jena.query.Dataset)1 Model (org.apache.jena.rdf.model.Model)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1 AtomProducer (won.bot.framework.component.atomproducer.AtomProducer)1 RoundRobinCompositeAtomProducer (won.bot.framework.component.atomproducer.impl.RoundRobinCompositeAtomProducer)1 AtomIndexer (won.matcher.solr.index.AtomIndexer)1 AtomModelWrapper (won.protocol.util.AtomModelWrapper)1