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;
}
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();
}
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;
}
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);
}
}
}
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);
}
}
Aggregations