use of it.vige.rubia.model.Post in project rubia-forums by flashboss.
the class OperationPollTest method setUp.
@BeforeClass
public static void setUp() {
driver.get(HOME_URL);
String message = createCategory(driver, new Category("First Test Category"));
assertTrue(message.equals(CREATED_CATEGORY_1_MESSAGE));
message = createCategory(driver, new Category("Second Test Category"));
assertTrue(message.equals(CREATED_CATEGORY_2_MESSAGE));
message = createForum(driver, new Forum("First Test Forum", "First Test Description", new Category("First Test Category")));
assertTrue(message.equals(CREATED_FORUM_0_MESSAGE));
message = createTopic(driver, new Topic(new Forum("First Test Forum"), "First Test Topic", asList(new Post[] { new Post("First Test Body", asList(new Attachment("first", "First Test File"), new Attachment("second", "Second Test File"), new Attachment("third", "Third Test File"))) }), NORMAL, new Poll("First Test Question", asList(new PollOption[] { new PollOption("First Test Answer"), new PollOption("Second Test Answer") }), 4)));
assertTrue(message.equals("First Test Topic"));
message = createTopic(driver, new Topic(new Forum("First Test Forum"), "Second Test Topic", asList(new Post[] { new Post("Second Test Body", asList(new Attachment("first", "First Test File"), new Attachment("second", "Second Test File"), new Attachment("third", "Third Test File"))) }), IMPORTANT, new Poll("Second Test Question", asList(new PollOption[] { new PollOption("Third Test Answer"), new PollOption("Fourth Test Answer") }), 8)));
assertTrue(message.equals("Second Test Topic"));
message = createForum(driver, new Forum("Second Test Forum", "Second Test Description", new Category("First Test Category")));
assertTrue(message.equals(CREATED_FORUM_1_MESSAGE));
message = createTopic(driver, new Topic(new Forum("Second Test Forum"), "Third Test Topic", asList(new Post[] { new Post("Third Test Body", asList(new Attachment("first", "First Test File"), new Attachment("second", "Second Test File"), new Attachment("third", "Third Test File"))) }), ADVICE, new Poll("Third Test Question", asList(new PollOption[] { new PollOption("Fifth Test with Truncation over 25 characters Answer"), new PollOption("Sixth Test Answer") }), 9)));
assertTrue(message.equals("Third Test Topic"));
message = createTopic(driver, new Topic(new Forum("Second Test Forum"), "Fourth Test Topic", asList(new Post[] { new Post("Fourth Test Body", asList(new Attachment("fourth", "Fourth Test File"), new Attachment("fifth", "Fifth Test with Truncation over 25 characters File"), new Attachment("sixth", "Sixth Test File"))) }), IMPORTANT, new Poll("Fourth Test Question", asList(new PollOption[] { new PollOption("Seventh Test Answer"), new PollOption("Eight Test Answer") }), 0)));
assertTrue(message.equals("Fourth Test Topic"));
}
use of it.vige.rubia.model.Post in project rubia-forums by flashboss.
the class OperationTopicTest method setUp.
@BeforeClass
public static void setUp() {
driver.get(HOME_URL);
String message = createCategory(driver, new Category("First Test Category"));
assertTrue(message.equals(CREATED_CATEGORY_1_MESSAGE));
message = createCategory(driver, new Category("Second Test Category"));
assertTrue(message.equals(CREATED_CATEGORY_2_MESSAGE));
message = createForum(driver, new Forum("First Test Forum", "First Test Description", new Category("First Test Category")));
assertTrue(message.equals(CREATED_FORUM_0_MESSAGE));
message = createTopic(driver, new Topic(new Forum("First Test Forum"), "First Test Topic", asList(new Post[] { new Post("First Test Body", asList(new Attachment("first", "First Test File"), new Attachment("second", "Second Test File"), new Attachment("third", "Third Test File"))) }), NORMAL, new Poll("First Test Question", asList(new PollOption[] { new PollOption("First Test Answer"), new PollOption("Second Test Answer") }), 4)));
assertTrue(message.equals("First Test Topic"));
message = createTopic(driver, new Topic(new Forum("First Test Forum"), "Second Test Topic", asList(new Post[] { new Post("Second Test Body", asList(new Attachment("first", "First Test File"), new Attachment("second", "Second Test File"), new Attachment("third", "Third Test File"))) }), IMPORTANT, new Poll("Second Test Question", asList(new PollOption[] { new PollOption("Third Test Answer"), new PollOption("Fourth Test Answer") }), 8)));
assertTrue(message.equals("Second Test Topic"));
message = createForum(driver, new Forum("Second Test Forum", "Second Test Description", new Category("First Test Category")));
assertTrue(message.equals(CREATED_FORUM_1_MESSAGE));
message = createTopic(driver, new Topic(new Forum("Second Test Forum"), "Third Test Topic", asList(new Post[] { new Post("Third Test Body", asList(new Attachment("first", "First Test File"), new Attachment("second", "Second Test File"), new Attachment("third", "Third Test File"))) }), ADVICE, new Poll("Third Test Question", asList(new PollOption[] { new PollOption("Fifth Test with Truncation over 25 characters Answer"), new PollOption("Sixth Test Answer") }), 9)));
assertTrue(message.equals("Third Test Topic"));
message = createTopic(driver, new Topic(new Forum("Second Test Forum"), "Fourth Test Topic", asList(new Post[] { new Post("Fourth Test Body", asList(new Attachment("fourth", "Fourth Test File"), new Attachment("fifth", "Fifth Test with Truncation over 25 characters File"), new Attachment("sixth", "Sixth Test File"))) }), IMPORTANT, new Poll("Fourth Test Question", asList(new PollOption[] { new PollOption("Seventh Test Answer"), new PollOption("Eight Test Answer") }), 0)));
assertTrue(message.equals("Fourth Test Topic"));
message = createTopic(driver, new Topic(new Forum("Second Test Forum"), "Fifth Test with Truncation over 25 characters Topic", asList(new Post[] { new Post("Fifth Test with Truncation over 25 characters Body", null) }), IMPORTANT, null));
assertTrue(message.equals("Fifth Test with Truncation over 25 characters Topic"));
}
use of it.vige.rubia.model.Post in project rubia-forums by flashboss.
the class ModeratorAction method execute.
@PostConstruct
public void execute() {
try {
// trying to get forumId from request parameter
int forumId = -1;
String f = getParameter(p_forumId);
if (f != null && f.trim().length() > 0) {
forumId = parseInt(f);
}
checkboxes = new HashMap<Integer, Boolean>();
// grab the data to be displayed for this page
if (forumId != -1) {
// setup the business objects like the forum, topics etc that
// will
// be displayed
forum = forumsModule.findForumById(forumId);
} else {
// trying to get forumId from topicId read from request
String t = getParameter(p_topicId);
if (t != null && t.trim().length() > 0) {
Topic topic = forumsModule.findTopicById(new Integer(t));
forum = topic.getForum();
} else {
String p = getParameter(p_postId);
if (p != null && p.trim().length() > 0) {
Post post = forumsModule.findPostById(new Integer(p));
Topic topic = post.getTopic();
forum = topic.getForum();
}
}
}
if (forum != null) {
topics = forumsModule.findTopics(forum);
topicsDataModel = new ListDataModel<Topic>(topics);
}
} catch (ModuleException e) {
log.error(e);
}
}
use of it.vige.rubia.model.Post in project rubia-forums by flashboss.
the class ReplyTopic method start.
public String start() {
String navState = null;
try {
int forumId = -1;
int topicId = -1;
int postId = -1;
String f = getParameter(p_forumId);
String t = getParameter(p_topicId);
String p = getParameter(p_postId);
if (f != null && f.trim().length() > 0) {
forumId = parseInt(f);
}
if (t != null && t.trim().length() > 0) {
topicId = parseInt(t);
}
if (p != null && p.trim().length() > 0) {
postId = parseInt(p);
}
Topic topic = null;
if (topicId == -1 && postId != -1) {
// If topicId was not given and postId is available we get
// topicId from Post
Post post = forumsModule.findPostById((postId));
if (post != null) {
topic = post.getTopic();
topicId = topic.getId().intValue();
}
} else {
topic = forumsModule.findTopicById(topicId);
}
if (forumId == -1 && topic != null) {
forumId = topic.getForum().getId().intValue();
}
// re-initialize this controller to add a reply post in a topic
// to the specified forum
cleanup();
// set the selected forum's id and topic's id
this.forumId = forumId;
this.topicId = topicId;
// set the subject information
subject = RE + topic.getSubject();
navState = START_REPLY;
} catch (Exception e) {
handleException(e);
}
return navState;
}
use of it.vige.rubia.model.Post in project rubia-forums by flashboss.
the class ReplyTopic method startQuote.
/**
* @return the navigation state of the application
*/
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String startQuote() {
String navState = start();
try {
String p = getParameter(p_postId);
if (p != null && p.trim().length() > 0) {
postId = parseInt(p);
}
// setup the quote information
Post post = forumsModule.findPostById(postId);
Poster poster = getPoster(forumsModule, userModule);
String userName = userModule.findUserById(poster.getUserId()).getUserName();
message = userName + "<" + QUOTE + ">" + post.getMessage().getText() + "</" + QUOTE + "></br>";
} catch (Exception e) {
handleException(e);
}
return navState;
}
Aggregations