use of org.olat.modules.fo.manager.ForumManager in project OpenOLAT by OpenOLAT.
the class FOCourseNodeIndexer method doIndexForum.
/**
* Index a forum in a course.
* @param parentResourceContext
* @param course
* @param courseNode
* @param indexWriter
* @throws IOException
*/
private void doIndexForum(SearchResourceContext parentResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
if (log.isDebug())
log.debug("Index Course Forum...");
ForumManager fom = ForumManager.getInstance();
CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
Property forumKeyProperty = cpm.findCourseNodeProperty(courseNode, null, null, FOCourseNode.FORUM_KEY);
// Check if forum-property exist
if (forumKeyProperty != null) {
Long forumKey = forumKeyProperty.getLongValue();
Forum forum = fom.loadForum(forumKey);
parentResourceContext.setDocumentType(TYPE);
doIndexAllMessages(parentResourceContext, forum, indexWriter);
}
}
use of org.olat.modules.fo.manager.ForumManager in project OpenOLAT by OpenOLAT.
the class NotificationsTest method createMessage.
private Message createMessage(Identity id, Forum fo) {
ForumManager fm = ForumManager.getInstance();
Message m1 = fm.createMessage(fo, id, false);
m1.setTitle("Thread-1");
m1.setBody("Body of Thread-1");
fm.addTopMessage(m1);
return m1;
}
use of org.olat.modules.fo.manager.ForumManager in project OpenOLAT by OpenOLAT.
the class ForumArtefactHandler method prefillArtefactAccordingToSource.
/**
* @see org.olat.portfolio.EPAbstractHandler#prefillArtefactAccordingToSource(org.olat.portfolio.model.artefacts.AbstractArtefact, java.lang.Object)
*/
@Override
public void prefillArtefactAccordingToSource(AbstractArtefact artefact, Object source) {
super.prefillArtefactAccordingToSource(artefact, source);
if (source instanceof OLATResourceable) {
OLATResourceable ores = (OLATResourceable) source;
ForumManager fMgr = ForumManager.getInstance();
Message fm = fMgr.loadMessage(ores.getResourceableId());
String thread = fm.getThreadtop() != null ? fm.getThreadtop().getTitle() + " - " : "";
artefact.setTitle(thread + fm.getTitle());
VFSContainer msgContainer = fMgr.getMessageContainer(fm.getForum().getKey(), fm.getKey());
if (msgContainer != null) {
List<VFSItem> foAttach = msgContainer.getItems();
if (foAttach.size() != 0) {
artefact.setFileSourceContainer(msgContainer);
}
}
artefact.setSignature(70);
artefact.setFulltextContent(fm.getBody());
}
}
use of org.olat.modules.fo.manager.ForumManager in project OpenOLAT by OpenOLAT.
the class ForumImportWebService method getForumWebservice.
/**
* Web service to manage a forum
* @param forumKey The key of the forum
* @return
*/
@Path("{forumKey}")
public ForumWebService getForumWebservice(@PathParam("forumKey") Long forumKey) {
ForumManager fom = ForumManager.getInstance();
Forum forum = fom.loadForum(forumKey);
return new ForumWebService(forum);
}
use of org.olat.modules.fo.manager.ForumManager in project OpenOLAT by OpenOLAT.
the class ForumArchiveManager method convertToThreadTrees.
/**
* If the forumCallback is null no filtering is executed,
* else if a thread is hidden and the user doesn't have moderator rights the
* hidden thread is not included into the archive.
* @param forumId
* @param metaInfo
* @return all top message nodes together with their children in a list
*/
private List<MessageNode> convertToThreadTrees(Long forumId, ForumCallback forumCallback) {
List<MessageNode> topNodeList = new ArrayList<>();
ForumManager fm = ForumManager.getInstance();
Forum f = fm.loadForum(forumId);
List<Message> messages = fm.getMessagesByForum(f);
for (Iterator<Message> iterTop = messages.iterator(); iterTop.hasNext(); ) {
Message msg = iterTop.next();
if (msg.getParent() == null) {
iterTop.remove();
MessageNode topNode = new MessageNode(msg);
if (topNode.isHidden() && (forumCallback == null || (forumCallback != null && forumCallback.mayEditMessageAsModerator()))) {
addChildren(messages, topNode);
topNodeList.add(topNode);
} else if (!topNode.isHidden()) {
addChildren(messages, topNode);
topNodeList.add(topNode);
}
}
}
Collections.sort(topNodeList, new MessageNodeComparator());
return topNodeList;
}
Aggregations