Search in sources :

Example 11 with OlatDocument

use of org.olat.search.model.OlatDocument in project openolat by klemens.

the class RepositoryEntryDocumentFactory method createDocument.

public Document createDocument(SearchResourceContext searchResourceContext, RepositoryEntry re) {
    OlatDocument oDocument = new OlatDocument();
    oDocument.setId(re.getKey());
    oDocument.setCreatedDate(re.getCreationDate());
    oDocument.setLastChange(re.getLastModified());
    oDocument.setTitle(re.getDisplayname());
    StringBuilder sb = new StringBuilder();
    String desc = re.getDescription();
    if (desc != null) {
        sb.append(desc).append(" ");
    }
    String objectives = re.getObjectives();
    if (objectives != null) {
        sb.append(objectives).append(" ");
    }
    String requirements = re.getRequirements();
    if (requirements != null) {
        sb.append(requirements);
    }
    oDocument.setDescription(sb.toString());
    oDocument.setResourceUrl(getResourceUrl(re.getKey()));
    String docType = RepositoryEntryDocument.TYPE + re.getOlatResource().getResourceableTypeName();
    oDocument.setDocumentType(docType);
    oDocument.setCssIcon(getIconCss(docType));
    oDocument.setParentContextType(searchResourceContext.getParentContextType());
    oDocument.setParentContextName(searchResourceContext.getParentContextName());
    oDocument.setAuthor(re.getAuthors());
    oDocument.setLocation(re.getLocation());
    if (licenseModule.isEnabled(licenseHandler)) {
        ResourceLicense license = licenseService.loadLicense(re.getOlatResource());
        if (license != null && license.getLicenseType() != null) {
            oDocument.setLicenseTypeKey(String.valueOf(license.getLicenseType().getKey()));
        }
    }
    // add specific fields
    Document document = oDocument.getLuceneDocument();
    return document;
}
Also used : OlatDocument(org.olat.search.model.OlatDocument) Document(org.apache.lucene.document.Document) OlatDocument(org.olat.search.model.OlatDocument) RepositoryEntryDocument(org.olat.search.service.document.RepositoryEntryDocument) ResourceLicense(org.olat.core.commons.services.license.ResourceLicense)

Example 12 with OlatDocument

use of org.olat.search.model.OlatDocument in project openolat by klemens.

the class GlossaryManagerImpl method getIndexerDocument.

/**
 * Creates a lucene index document for this glossary
 *
 * @param repositoryEntry
 * @param searchResourceContext
 * @return Document the index document
 */
@Override
public Document getIndexerDocument(RepositoryEntry repositoryEntry, SearchResourceContext searchResourceContext) {
    GlossaryItemManager gIMgr = GlossaryItemManager.getInstance();
    VFSContainer glossaryFolder = getGlossaryRootFolder(repositoryEntry.getOlatResource());
    VFSLeaf glossaryFile = gIMgr.getGlossaryFile(glossaryFolder);
    if (glossaryFile == null) {
        return null;
    }
    String glossaryContent = gIMgr.getGlossaryContent(glossaryFolder);
    // strip all html tags
    Filter htmlTagsFilter = FilterFactory.getHtmlTagsFilter();
    glossaryContent = htmlTagsFilter.filter(glossaryContent);
    // create standard olat index document with this data
    OlatDocument glossaryDocument = new OlatDocument();
    if (repositoryEntry.getInitialAuthor() != null) {
        glossaryDocument.setAuthor(repositoryEntry.getInitialAuthor());
    }
    if (repositoryEntry.getDisplayname() != null) {
        glossaryDocument.setTitle(repositoryEntry.getDisplayname());
    }
    if (repositoryEntry.getDescription() != null) {
        glossaryDocument.setDescription(htmlTagsFilter.filter(repositoryEntry.getDescription()));
    }
    glossaryDocument.setContent(glossaryContent);
    glossaryDocument.setCreatedDate(repositoryEntry.getCreationDate());
    glossaryDocument.setLastChange(new Date(glossaryFile.getLastModified()));
    glossaryDocument.setResourceUrl(searchResourceContext.getResourceUrl());
    glossaryDocument.setDocumentType(searchResourceContext.getDocumentType());
    glossaryDocument.setCssIcon("o_FileResource-GLOSSARY_icon");
    return glossaryDocument.getLuceneDocument();
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) OlatDocument(org.olat.search.model.OlatDocument) Filter(org.olat.core.util.filter.Filter) VFSContainer(org.olat.core.util.vfs.VFSContainer) GlossaryItemManager(org.olat.core.commons.modules.glossary.GlossaryItemManager) Date(java.util.Date)

Example 13 with OlatDocument

use of org.olat.search.model.OlatDocument in project OpenOLAT by OpenOLAT.

the class RepositoryEntryDocumentFactory method createDocument.

public Document createDocument(SearchResourceContext searchResourceContext, RepositoryEntry re) {
    OlatDocument oDocument = new OlatDocument();
    oDocument.setId(re.getKey());
    oDocument.setCreatedDate(re.getCreationDate());
    oDocument.setLastChange(re.getLastModified());
    oDocument.setTitle(re.getDisplayname());
    StringBuilder sb = new StringBuilder();
    String desc = re.getDescription();
    if (desc != null) {
        sb.append(desc).append(" ");
    }
    String objectives = re.getObjectives();
    if (objectives != null) {
        sb.append(objectives).append(" ");
    }
    String requirements = re.getRequirements();
    if (requirements != null) {
        sb.append(requirements);
    }
    oDocument.setDescription(sb.toString());
    oDocument.setResourceUrl(getResourceUrl(re.getKey()));
    String docType = RepositoryEntryDocument.TYPE + re.getOlatResource().getResourceableTypeName();
    oDocument.setDocumentType(docType);
    oDocument.setCssIcon(getIconCss(docType));
    oDocument.setParentContextType(searchResourceContext.getParentContextType());
    oDocument.setParentContextName(searchResourceContext.getParentContextName());
    oDocument.setAuthor(re.getAuthors());
    oDocument.setLocation(re.getLocation());
    if (licenseModule.isEnabled(licenseHandler)) {
        ResourceLicense license = licenseService.loadLicense(re.getOlatResource());
        if (license != null && license.getLicenseType() != null) {
            oDocument.setLicenseTypeKey(String.valueOf(license.getLicenseType().getKey()));
        }
    }
    // add specific fields
    Document document = oDocument.getLuceneDocument();
    return document;
}
Also used : OlatDocument(org.olat.search.model.OlatDocument) Document(org.apache.lucene.document.Document) OlatDocument(org.olat.search.model.OlatDocument) RepositoryEntryDocument(org.olat.search.service.document.RepositoryEntryDocument) ResourceLicense(org.olat.core.commons.services.license.ResourceLicense)

Example 14 with OlatDocument

use of org.olat.search.model.OlatDocument in project OpenOLAT by OpenOLAT.

the class LiveBlogArtefactHandler method getContent.

@Override
protected void getContent(AbstractArtefact artefact, StringBuilder sb, SearchResourceContext context, EPFrontendManager ePFManager) {
    String businessPath = artefact.getBusinessPath();
    if (StringHelper.containsNonWhitespace(businessPath)) {
        manager = FeedManager.getInstance();
        String oresId = businessPath.substring(LIVEBLOG.length(), businessPath.length() - 1);
        OLATResourceable ores = OresHelper.createOLATResourceableInstance(BlogFileResource.TYPE_NAME, Long.parseLong(oresId));
        Feed feed = manager.loadFeed(ores);
        List<Item> publishedItems = manager.loadPublishedItems(feed);
        for (Item item : publishedItems) {
            OlatDocument itemDoc = new FeedItemDocument(item, context);
            String content = itemDoc.getContent();
            sb.append(content);
        }
    }
}
Also used : Item(org.olat.modules.webFeed.Item) OlatDocument(org.olat.search.model.OlatDocument) FeedItemDocument(org.olat.modules.webFeed.search.document.FeedItemDocument) OLATResourceable(org.olat.core.id.OLATResourceable) Feed(org.olat.modules.webFeed.Feed)

Example 15 with OlatDocument

use of org.olat.search.model.OlatDocument in project OpenOLAT by OpenOLAT.

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);
    }
}
Also used : Item(org.olat.modules.webFeed.Item) OlatDocument(org.olat.search.model.OlatDocument) FeedItemDocument(org.olat.modules.webFeed.search.document.FeedItemDocument) SearchResourceContext(org.olat.search.service.SearchResourceContext) RepositoryEntry(org.olat.repository.RepositoryEntry) Feed(org.olat.modules.webFeed.Feed)

Aggregations

OlatDocument (org.olat.search.model.OlatDocument)20 Document (org.apache.lucene.document.Document)8 SearchResourceContext (org.olat.search.service.SearchResourceContext)8 Identity (org.olat.core.id.Identity)6 OLATResourceable (org.olat.core.id.OLATResourceable)6 Feed (org.olat.modules.webFeed.Feed)6 Item (org.olat.modules.webFeed.Item)6 FeedItemDocument (org.olat.modules.webFeed.search.document.FeedItemDocument)6 Date (java.util.Date)4 ResourceLicense (org.olat.core.commons.services.license.ResourceLicense)4 Filter (org.olat.core.util.filter.Filter)4 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 AbstractOlatDocument (org.olat.search.model.AbstractOlatDocument)4 StringTokenizer (java.util.StringTokenizer)2 StringField (org.apache.lucene.document.StringField)2 TextField (org.apache.lucene.document.TextField)2 ParseException (org.apache.lucene.queryparser.classic.ParseException)2 MetaInfo (org.olat.core.commons.modules.bc.meta.MetaInfo)2 MetaTagged (org.olat.core.commons.modules.bc.meta.tagged.MetaTagged)2