Search in sources :

Example 1 with QuestionItemDocumentFactory

use of org.olat.modules.qpool.manager.QuestionItemDocumentFactory in project openolat by klemens.

the class QuestionItemIndexer method deleteDocument.

@Override
public void deleteDocument(Long key, LifeFullIndexer indexWriter) {
    QuestionItemDocumentFactory docFactory = CoreSpringFactory.getImpl(QuestionItemDocumentFactory.class);
    String resourceUrl = docFactory.getResourceUrl(key);
    indexWriter.deleteDocument(resourceUrl);
}
Also used : QuestionItemDocumentFactory(org.olat.modules.qpool.manager.QuestionItemDocumentFactory)

Example 2 with QuestionItemDocumentFactory

use of org.olat.modules.qpool.manager.QuestionItemDocumentFactory in project OpenOLAT by OpenOLAT.

the class QuestionItemIndexer method deleteDocument.

@Override
public void deleteDocument(Long key, LifeFullIndexer indexWriter) {
    QuestionItemDocumentFactory docFactory = CoreSpringFactory.getImpl(QuestionItemDocumentFactory.class);
    String resourceUrl = docFactory.getResourceUrl(key);
    indexWriter.deleteDocument(resourceUrl);
}
Also used : QuestionItemDocumentFactory(org.olat.modules.qpool.manager.QuestionItemDocumentFactory)

Example 3 with QuestionItemDocumentFactory

use of org.olat.modules.qpool.manager.QuestionItemDocumentFactory in project OpenOLAT by OpenOLAT.

the class QuestionItemIndexer method fullIndex.

@Override
public void fullIndex(LifeFullIndexer indexWriter) {
    QPoolService qpoolService = CoreSpringFactory.getImpl(QPoolService.class);
    QuestionItemDocumentFactory docFactory = CoreSpringFactory.getImpl(QuestionItemDocumentFactory.class);
    SearchResourceContext ctxt = new SearchResourceContext();
    IndexWriter writer = null;
    try {
        writer = indexWriter.getAndLockWriter();
        int counter = 0;
        List<QuestionItemFull> items;
        do {
            items = qpoolService.getAllItems(counter, BATCH_SIZE);
            for (QuestionItemFull item : items) {
                Document doc = docFactory.createDocument(ctxt, item);
                indexWriter.addDocument(doc, writer);
            }
            counter += items.size();
        } while (items.size() == BATCH_SIZE);
    } catch (Exception e) {
        log.error("", e);
    } finally {
        indexWriter.releaseWriter(writer);
    }
}
Also used : QuestionItemDocumentFactory(org.olat.modules.qpool.manager.QuestionItemDocumentFactory) QuestionItemFull(org.olat.modules.qpool.QuestionItemFull) QPoolService(org.olat.modules.qpool.QPoolService) SearchResourceContext(org.olat.search.service.SearchResourceContext) IndexWriter(org.apache.lucene.index.IndexWriter) Document(org.apache.lucene.document.Document) QItemDocument(org.olat.modules.qpool.model.QItemDocument)

Example 4 with QuestionItemDocumentFactory

use of org.olat.modules.qpool.manager.QuestionItemDocumentFactory in project OpenOLAT by OpenOLAT.

the class QuestionItemIndexer method indexDocument.

@Override
public void indexDocument(List<Long> keyList, LifeFullIndexer indexWriter) {
    QuestionItemDocumentFactory docFactory = CoreSpringFactory.getImpl(QuestionItemDocumentFactory.class);
    List<Document> docs = new ArrayList<>(keyList.size());
    for (Long key : keyList) {
        SearchResourceContext ctxt = new SearchResourceContext();
        Document doc = docFactory.createDocument(ctxt, key);
        docs.add(doc);
    }
    indexWriter.addDocuments(docs);
}
Also used : QuestionItemDocumentFactory(org.olat.modules.qpool.manager.QuestionItemDocumentFactory) SearchResourceContext(org.olat.search.service.SearchResourceContext) ArrayList(java.util.ArrayList) Document(org.apache.lucene.document.Document) QItemDocument(org.olat.modules.qpool.model.QItemDocument)

Example 5 with QuestionItemDocumentFactory

use of org.olat.modules.qpool.manager.QuestionItemDocumentFactory in project openolat by klemens.

the class QuestionItemIndexer method indexDocument.

@Override
public void indexDocument(List<Long> keyList, LifeFullIndexer indexWriter) {
    QuestionItemDocumentFactory docFactory = CoreSpringFactory.getImpl(QuestionItemDocumentFactory.class);
    List<Document> docs = new ArrayList<>(keyList.size());
    for (Long key : keyList) {
        SearchResourceContext ctxt = new SearchResourceContext();
        Document doc = docFactory.createDocument(ctxt, key);
        docs.add(doc);
    }
    indexWriter.addDocuments(docs);
}
Also used : QuestionItemDocumentFactory(org.olat.modules.qpool.manager.QuestionItemDocumentFactory) SearchResourceContext(org.olat.search.service.SearchResourceContext) ArrayList(java.util.ArrayList) Document(org.apache.lucene.document.Document) QItemDocument(org.olat.modules.qpool.model.QItemDocument)

Aggregations

QuestionItemDocumentFactory (org.olat.modules.qpool.manager.QuestionItemDocumentFactory)6 Document (org.apache.lucene.document.Document)4 QItemDocument (org.olat.modules.qpool.model.QItemDocument)4 SearchResourceContext (org.olat.search.service.SearchResourceContext)4 ArrayList (java.util.ArrayList)2 IndexWriter (org.apache.lucene.index.IndexWriter)2 QPoolService (org.olat.modules.qpool.QPoolService)2 QuestionItemFull (org.olat.modules.qpool.QuestionItemFull)2