use of org.olat.search.service.SearchResourceContext in project openolat by klemens.
the class AbstractPortfolioMapIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext searchResourceContext, Object object, OlatFullIndexer indexerWriter) throws IOException, InterruptedException {
if (!portfolioModule.isEnabled())
return;
SearchResourceContext resourceContext = new SearchResourceContext();
int firstResult = 0;
List<PortfolioStructure> structures = null;
do {
structures = frontendManager.getStructureElements(firstResult, 500, getElementType());
for (PortfolioStructure structure : structures) {
if (structure instanceof PortfolioStructureMap) {
PortfolioStructureMap map = (PortfolioStructureMap) structure;
if (accept(map)) {
resourceContext.setDocumentType(getDocumentType());
resourceContext.setBusinessControlFor(map.getOlatResource());
Document document = PortfolioMapDocument.createDocument(resourceContext, map);
indexerWriter.addDocument(document);
}
}
}
firstResult += structures.size();
} while (structures != null && structures.size() == BATCH_SIZE);
}
use of org.olat.search.service.SearchResourceContext in project openolat by klemens.
the class FeedCourseNodeIndexer method doIndex.
/**
* @see org.olat.search.service.indexer.Indexer#doIndex(org.olat.search.service.SearchResourceContext,
* java.lang.Object, org.olat.search.service.indexer.OlatFullIndexer)
*/
@Override
public void doIndex(SearchResourceContext courseResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexer) throws IOException, InterruptedException {
SearchResourceContext courseNodeResourceContext = createSearchResourceContext(courseResourceContext, courseNode, getDocumentType());
Document document = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode);
indexer.addDocument(document);
RepositoryEntry repositoryEntry = courseNode.getReferencedRepositoryEntry();
if (repositoryEntry != null) {
// used for log messages
String repoEntryName = "*name not available*";
try {
repoEntryName = repositoryEntry.getDisplayname();
if (log.isDebug()) {
log.info("Indexing: " + repoEntryName);
}
Feed feed = FeedManager.getInstance().loadFeed(repositoryEntry.getOlatResource());
List<Item> publishedItems = FeedManager.getInstance().loadPublishedItems(feed);
// Create the olatDocument for the feed course node itself
OlatDocument feedNodeDoc = new FeedNodeDocument(feed, courseNodeResourceContext);
indexer.addDocument(feedNodeDoc.getLuceneDocument());
// Only index items. FeedImpl itself is indexed by RepositoryEntryIndexer.
for (Item item : publishedItems) {
OlatDocument itemDoc = new FeedItemDocument(item, courseNodeResourceContext);
indexer.addDocument(itemDoc.getLuceneDocument());
}
} catch (NullPointerException e) {
log.error("Error indexing feed:" + repoEntryName, e);
}
}
}
use of org.olat.search.service.SearchResourceContext in project openolat by klemens.
the class FeedRepositoryIndexer method doIndex.
/**
* @see org.olat.search.service.indexer.Indexer#doIndex(org.olat.search.service.SearchResourceContext,
* java.lang.Object, org.olat.search.service.indexer.OlatFullIndexer)
*/
@Override
public void doIndex(SearchResourceContext searchResourceContext, Object parentObject, OlatFullIndexer indexer) throws IOException, InterruptedException {
RepositoryEntry repositoryEntry = (RepositoryEntry) parentObject;
// used for log messages
String repoEntryName = "*name not available*";
try {
repoEntryName = repositoryEntry.getDisplayname();
if (isLogDebugEnabled()) {
logDebug("Indexing: " + repoEntryName);
}
Feed feed = FeedManager.getInstance().loadFeed(repositoryEntry.getOlatResource());
if (feed != null) {
// Only index items. Feed itself is indexed by RepositoryEntryIndexer.
List<Item> publishedItems = FeedManager.getInstance().loadPublishedItems(feed);
if (isLogDebugEnabled()) {
logDebug("PublishedItems size=" + publishedItems.size());
}
for (Item item : publishedItems) {
SearchResourceContext feedContext = new SearchResourceContext(searchResourceContext);
feedContext.setDocumentType(getDocumentType());
OlatDocument itemDoc = new FeedItemDocument(item, feedContext);
indexer.addDocument(itemDoc.getLuceneDocument());
}
}
} catch (NullPointerException e) {
logError("Error indexing feed:" + repoEntryName, e);
}
}
use of org.olat.search.service.SearchResourceContext in project openolat by klemens.
the class RepositoryEntryLifeIndexer method fullIndex.
@Override
public void fullIndex(LifeFullIndexer indexWriter) {
SearchResourceContext ctxt = new SearchResourceContext();
IndexWriter writer = null;
try {
writer = indexWriter.getAndLockWriter();
int counter = 0;
List<RepositoryEntry> items;
do {
items = repositoryEntryDAO.getAllRepositoryEntries(counter, BATCH_SIZE);
for (RepositoryEntry item : items) {
Document doc = documentFactory.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);
}
}
use of org.olat.search.service.SearchResourceContext in project openolat by klemens.
the class RepositoryEntryLifeIndexer method indexDocument.
@Override
public void indexDocument(List<Long> keyList, LifeFullIndexer indexWriter) {
SearchResourceContext ctxt = new SearchResourceContext();
List<Document> docs = new ArrayList<>(keyList.size());
for (Long key : keyList) {
Document doc = documentFactory.createDocument(ctxt, key);
docs.add(doc);
}
indexWriter.addDocuments(docs);
}
Aggregations