use of org.olat.modules.fo.model.ForumThread in project OpenOLAT by OpenOLAT.
the class ForumManagerTest method getForumThreads.
@Test
public void getForumThreads() {
Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("fo-1");
Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("fo-2");
Forum forum = forumManager.addAForum();
dbInstance.commit();
Message thread1 = forumManager.createMessage(forum, id1, false);
thread1.setTitle("Get forum threads");
thread1.setBody("Get forum threads");
forumManager.addTopMessage(thread1);
dbInstance.commit();
Message reply = forumManager.createMessage(forum, id2, false);
reply.setTitle("Re: Get forum threads");
reply.setBody("Get forum threads");
forumManager.replyToMessage(reply, thread1);
dbInstance.commitAndCloseSession();
Message thread2 = forumManager.createMessage(forum, id1, false);
thread2.setTitle("More on get forum threads");
thread2.setBody("More on get forum threads");
forumManager.addTopMessage(thread2);
dbInstance.commit();
List<ForumThread> forumThreads = forumManager.getForumThreads(forum, id1);
Assert.assertNotNull(forumThreads);
Assert.assertEquals(2, forumThreads.size());
ForumThread forumThread1 = null;
ForumThread forumThread2 = null;
for (ForumThread forumThread : forumThreads) {
if (forumThread.getKey().equals(thread1.getKey())) {
forumThread1 = forumThread;
} else if (forumThread.getKey().equals(thread2.getKey())) {
forumThread2 = forumThread;
}
}
Assert.assertNotNull(forumThread1);
Assert.assertNotNull(forumThread2);
}
use of org.olat.modules.fo.model.ForumThread in project OpenOLAT by OpenOLAT.
the class ThreadListController method loadModel.
public void loadModel() {
Identity identity = guestOnly ? null : getIdentity();
List<ForumThread> threads = forumManager.getForumThreads(forum, identity);
if (!foCallback.mayEditMessageAsModerator()) {
for (Iterator<ForumThread> threadIt = threads.iterator(); threadIt.hasNext(); ) {
if (Status.getStatus(threadIt.next().getStatusCode()).isHidden()) {
threadIt.remove();
}
}
}
threadTableModel.setObjects(threads);
threadTableModel.sort(new SortKey(ThreadListCols.thread.name(), true));
threadTable.reloadData();
threadTable.reset();
if (archiveForumButton != null) {
archiveForumButton.setVisible(threads.size() > 0);
}
if (userListButton != null) {
userListButton.setVisible(threads.size() > 0);
}
}
use of org.olat.modules.fo.model.ForumThread in project OpenOLAT by OpenOLAT.
the class SelectThreadStepForm method displayAsNewThread.
private void displayAsNewThread(UserRequest ureq) {
Message messageToMove = (Message) getFromRunContext(SendMailStepForm.MESSAGE_TO_MOVE);
String creatorFullname = userManager.getUserDisplayName(messageToMove.getCreator());
Date lastModified = messageToMove.getLastModified();
int numOfPosts = forumManager.countMessageChildren(messageToMove.getKey()) + 1;
ForumThread row = new ForumThread(messageToMove, creatorFullname, lastModified, numOfPosts);
List<ForumThread> threads = threadTableModel.getObjects();
if (containsMessage(row)) {
showWarning("thread.already.exits");
} else {
threads.add(row);
addToRunContext(SendMailStepForm.NEW_THREAD, Boolean.TRUE);
threadTableModel.setObjects(threads);
threadTableModel.sort(new SortKey(ThreadListCols.thread.name(), true));
threadTable.reloadData();
threadTable.reset();
// move on to next wizard step directly
fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
}
}
use of org.olat.modules.fo.model.ForumThread in project OpenOLAT by OpenOLAT.
the class SelectThreadStepForm method containsMessage.
private boolean containsMessage(ForumThread row) {
Identity identity = guestOnly ? null : getIdentity();
List<ForumThread> threads = forumManager.getForumThreads(forum, identity);
for (ForumThread forumThread : threads) {
if (row.getKey().equals(forumThread.getKey())) {
return true;
}
}
List<ForumThread> tablethreads = threadTableModel.getObjects();
for (ForumThread forumThread : tablethreads) {
if (row.getKey().equals(forumThread.getKey())) {
return true;
}
}
return false;
}
use of org.olat.modules.fo.model.ForumThread in project openolat by klemens.
the class ForumManagerTest method getForumThreads.
@Test
public void getForumThreads() {
Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("fo-1");
Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("fo-2");
Forum forum = forumManager.addAForum();
dbInstance.commit();
Message thread1 = forumManager.createMessage(forum, id1, false);
thread1.setTitle("Get forum threads");
thread1.setBody("Get forum threads");
forumManager.addTopMessage(thread1);
dbInstance.commit();
Message reply = forumManager.createMessage(forum, id2, false);
reply.setTitle("Re: Get forum threads");
reply.setBody("Get forum threads");
forumManager.replyToMessage(reply, thread1);
dbInstance.commitAndCloseSession();
Message thread2 = forumManager.createMessage(forum, id1, false);
thread2.setTitle("More on get forum threads");
thread2.setBody("More on get forum threads");
forumManager.addTopMessage(thread2);
dbInstance.commit();
List<ForumThread> forumThreads = forumManager.getForumThreads(forum, id1);
Assert.assertNotNull(forumThreads);
Assert.assertEquals(2, forumThreads.size());
ForumThread forumThread1 = null;
ForumThread forumThread2 = null;
for (ForumThread forumThread : forumThreads) {
if (forumThread.getKey().equals(thread1.getKey())) {
forumThread1 = forumThread;
} else if (forumThread.getKey().equals(thread2.getKey())) {
forumThread2 = forumThread;
}
}
Assert.assertNotNull(forumThread1);
Assert.assertNotNull(forumThread2);
}
Aggregations