Skip to content
Permalink
Browse files

LDEV-3443: Improve performance by paging - load only 50 'threads' at …

…a time within a topic. The Edit and the Reply are also inlined for the standard interface.
  • Loading branch information
FionaMalikoff committed Apr 23, 2015
1 parent d5e416c commit 2ff38cdf504d51a2590b113023d885069d32645e
Showing with 2,134 additions and 302 deletions.
  1. +8 −0 lams_tool_forum/conf/language/lams/ApplicationResources.properties
  2. +8 −0 lams_tool_forum/conf/language/lams/ApplicationResources_en_AU.properties
  3. +33 −0 lams_tool_forum/conf/xdoclet/struts-actions.xml
  4. +23 −0 lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/dbupdates/patch20150224.sql
  5. +93 −0 lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/dbupdates/patch20150225.sql
  6. +34 −0 lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/dbupdates/patch20150226.sql
  7. +31 −0 lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/dbupdates/patch20150227.sql
  8. +23 −0 lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/dbupdates/patch20150228.sql
  9. +11 −0 lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/ForumUser.java
  10. +11 −3 lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/IMessageSeqDAO.java
  11. +11 −0 lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/MessageSeq.java
  12. +50 −4 lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/hibernate/MessageSeqDao.java
  13. +31 −2 lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/IForumService.java
  14. +234 −50 lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java
  15. +2 −0 lams_tool_forum/web/WEB-INF/tiles-defs.xml
  16. +10 −0 lams_tool_forum/web/WEB-INF/urlrewrite.xml
  17. +28 −0 lams_tool_forum/web/css/jquery.treetable.css
  18. +44 −0 lams_tool_forum/web/css/jquery.treetable.forum.css
  19. +209 −0 lams_tool_forum/web/includes/javascript/jquery.jscroll.js
  20. +634 −0 lams_tool_forum/web/includes/javascript/jquery.treetable.js
  21. +6 −0 lams_tool_forum/web/includes/javascript/message.js
  22. +63 −2 lams_tool_forum/web/jsps/learning/edit.jsp
  23. +188 −0 lams_tool_forum/web/jsps/learning/message/msgview.jsp
  24. +30 −0 lams_tool_forum/web/jsps/learning/message/msgviewwrapper.jsp
  25. +1 −7 lams_tool_forum/web/jsps/learning/message/topiceditform.jsp
  26. +4 −3 lams_tool_forum/web/jsps/learning/message/topiclist.jsp
  27. +3 −7 lams_tool_forum/web/jsps/learning/message/topicreplyform.jsp
  28. +112 −165 lams_tool_forum/web/jsps/learning/message/topicview.jsp
  29. +18 −0 lams_tool_forum/web/jsps/learning/message/topicviewwrapper.jsp
  30. +3 −1 lams_tool_forum/web/jsps/learning/mobile/message/topiclist.jsp
  31. +15 −0 lams_tool_forum/web/jsps/learning/mobile/message/topicview.jsp
  32. +17 −0 lams_tool_forum/web/jsps/learning/mobile/message/topicviewwrapper.jsp
  33. +15 −3 lams_tool_forum/web/jsps/learning/mobile/viewtopic.jsp
  34. +1 −1 lams_tool_forum/web/jsps/learning/ratingStars.jsp
  35. +86 −41 lams_tool_forum/web/jsps/learning/reply.jsp
  36. +2 −2 lams_tool_forum/web/jsps/learning/viewforum.jsp
  37. +42 −11 lams_tool_forum/web/jsps/learning/viewtopic.jsp
@@ -236,6 +236,14 @@ label.number.of.posts =Posts
label.latest.posting.date =Latest post on
label.number.of.replies =Replies
message.no.reflection.available =No notebook entry was added.
label.show.more.messages =More posts
label.loading.messages =Loading more posts
label.show.replies=Show Replies
label.hide.replies=Hide Replies
label.showhide.prompt=Show/Hide Replies
message.complete.or.cancel.reply=Please complete or cancel the current reply before starting a new reply.
message.complete.or.cancel.edit=Please complete or cancel the current edit before starting a new edit.
error.cannot.redisplay.please.refresh=Your changes have been saved but cannot be redisplayed. Please select refresh to reload the forum messages.


#======= End labels: Exported 230 labels for en AU =====
@@ -236,6 +236,14 @@ label.number.of.posts =Posts
label.latest.posting.date =Latest post on
label.number.of.replies =Replies
message.no.reflection.available =No notebook entry was added.
label.show.more.messages =More posts
label.loading.messages =Loading more posts
label.show.replies=Show Replies
label.hide.replies=Hide Replies
label.showhide.prompt=Show/Hide Replies
message.complete.or.cancel.reply=Please complete or cancel the current reply before starting a new reply.
message.complete.or.cancel.edit=Please complete or cancel the current edit before starting a new edit.
error.cannot.redisplay.please.refresh=Your changes have been saved but cannot be redisplayed. Please select refresh to reload the forum messages.


#======= End labels: Exported 230 labels for en AU =====
@@ -177,6 +177,21 @@
parameter="viewTopic" scope="request">
<forward name="success" path="tiles:/learning/forum/viewTopic" />
</action>
<action path="/learning/viewTopicNext"
type="org.lamsfoundation.lams.tool.forum.web.actions.LearningAction"
parameter="viewTopicNext" scope="request">
<forward name="success" path="tiles:/learning/forum/viewTopicNext" />
</action>
<action path="/learning/viewTopicThread"
type="org.lamsfoundation.lams.tool.forum.web.actions.LearningAction"
parameter="viewTopicThread" scope="request">
<forward name="success" path="tiles:/learning/forum/viewTopicNext" />
</action>
<action path="/learning/viewMessage"
type="org.lamsfoundation.lams.tool.forum.web.actions.LearningAction"
parameter="viewMessage" scope="request">
<forward name="success" path="tiles:/learning/forum/viewMessage" />
</action>
<action path="/learning/newTopic"
type="org.lamsfoundation.lams.tool.forum.web.actions.LearningAction"
name="messageForm"
@@ -210,6 +225,15 @@
scope="request">
<forward name="success" path="tiles:/learning/forum/viewTopic" />
</action>
<action path="/learning/replyTopicInline"
type="org.lamsfoundation.lams.tool.forum.web.actions.LearningAction"
name="messageForm"
validate="true"
input="tiles:/learning/forum/replyTopic"
parameter="replyTopicInline"
scope="request">
<!-- JSON response on success -->
</action>
<action path="/learning/editTopic"
type="org.lamsfoundation.lams.tool.forum.web.actions.LearningAction"
name="messageForm"
@@ -227,6 +251,15 @@
scope="request">
<forward name="success" path="tiles:/learning/forum/viewTopic" />
</action>
<action path="/learning/updateTopicInline"
type="org.lamsfoundation.lams.tool.forum.web.actions.LearningAction"
name="messageForm"
validate="true"
input="tiles:/learning/forum/editTopic"
parameter="updateTopicInline"
scope="request">
<!-- JSON response on success -->
</action>

<action path="/learning/deleteAttachment"
type="org.lamsfoundation.lams.tool.forum.web.actions.LearningAction"
@@ -0,0 +1,23 @@
SET AUTOCOMMIT = 0;
SET FOREIGN_KEY_CHECKS = 0;

-- --------------------Put all sql statements below here-------------------------

-- Adding thread ids. 5 patch files needed for the change - patch20150224 thru patch20150228

ALTER TABLE `tl_lafrum11_message_seq`
ADD COLUMN `thread_message_uid` BIGINT(20) DEFAULT NULL,
ADD INDEX `fkfrum11mseqthread` (`thread_message_uid` ASC);
ALTER TABLE `tl_lafrum11_message_seq`
ADD CONSTRAINT `fkfrum11mseqthread`
FOREIGN KEY (`thread_message_uid`)
REFERENCES `tl_lafrum11_message` (`uid`)
ON DELETE RESTRICT
ON UPDATE RESTRICT;

-- --------------------Put all sql statements above here-------------------------
-- If there were no errors, commit and restore autocommit to on
COMMIT;
SET AUTOCOMMIT = 1;
SET FOREIGN_KEY_CHECKS = 1;

@@ -0,0 +1,93 @@
-- This stored proc is a generic stored proc that can be used to emulate
-- the WITH RECURSIVE feature not found in MySQL.
-- From http://guilhembichot.blogspot.co.uk/2013/11/with-recursive-and-mysql.html

CREATE PROCEDURE `with_emulator`(
recursive_table varchar(100),
initial_SELECT varchar(21845),
recursive_SELECT varchar(21845),
final_SELECT varchar(21845),
max_recursion int unsigned,
create_table_options varchar(21845)
)
BEGIN
declare new_rows int unsigned;
declare show_progress int default 0;
declare recursive_table_next varchar(120);
declare recursive_table_union varchar(120);
declare recursive_table_tmp varchar(120);
set recursive_table_next = concat(recursive_table, "_next");
set recursive_table_union = concat(recursive_table, "_union");
set recursive_table_tmp = concat(recursive_table, "_tmp");
SET @str =
CONCAT("CREATE TEMPORARY TABLE ", recursive_table, " ",
create_table_options, " AS ", initial_SELECT);
PREPARE stmt FROM @str;
EXECUTE stmt;
SET @str =
CONCAT("CREATE TEMPORARY TABLE ", recursive_table_union, " LIKE ", recursive_table);
PREPARE stmt FROM @str;
EXECUTE stmt;
SET @str =
CONCAT("CREATE TEMPORARY TABLE ", recursive_table_next, " LIKE ", recursive_table);
PREPARE stmt FROM @str;
EXECUTE stmt;
if max_recursion = 0 then
set max_recursion = 100;
end if;
recursion: repeat
SET @str =
CONCAT("INSERT INTO ", recursive_table_union, " SELECT * FROM ", recursive_table);
PREPARE stmt FROM @str;
EXECUTE stmt;
set max_recursion = max_recursion - 1;
if not max_recursion then
if show_progress then
select concat("max recursion exceeded");
end if;
leave recursion;
end if;
SET @str =
CONCAT("INSERT INTO ", recursive_table_next, " ", recursive_SELECT);
PREPARE stmt FROM @str;
EXECUTE stmt;
select row_count() into new_rows;
if show_progress then
select concat(new_rows, " new rows found");
end if;
if not new_rows then
leave recursion;
end if;
SET @str =
CONCAT("ALTER TABLE ", recursive_table, " RENAME ", recursive_table_tmp);
PREPARE stmt FROM @str;
EXECUTE stmt;
SET @str =
CONCAT("ALTER TABLE ", recursive_table_next, " RENAME ", recursive_table);
PREPARE stmt FROM @str;
EXECUTE stmt;
SET @str =
CONCAT("ALTER TABLE ", recursive_table_tmp, " RENAME ", recursive_table_next);
PREPARE stmt FROM @str;
EXECUTE stmt;
SET @str =
CONCAT("TRUNCATE TABLE ", recursive_table_next);
PREPARE stmt FROM @str;
EXECUTE stmt;
until 0 end repeat;
SET @str =
CONCAT("DROP TEMPORARY TABLE ", recursive_table_next, ", ", recursive_table);
PREPARE stmt FROM @str;
EXECUTE stmt;
SET @str =
CONCAT("ALTER TABLE ", recursive_table_union, " RENAME ", recursive_table);
PREPARE stmt FROM @str;
EXECUTE stmt;
SET @str = final_SELECT;
PREPARE stmt FROM @str;
EXECUTE stmt;
SET @str =
CONCAT("DROP TEMPORARY TABLE ", recursive_table);
PREPARE stmt FROM @str;
EXECUTE stmt;
END;
@@ -0,0 +1,34 @@
CREATE PROCEDURE `tl_lafrum11_get_all_thread_message_uids_tmp`()
BEGIN

PREPARE stmt FROM "drop temporary table if exists tl_lafrum11_thread_message_uid_tmp";
EXECUTE stmt;

CALL with_emulator(

"tl_lafrum11_recursive_tmp",

"select seq.uid as seq_uid, seq.root_message_uid as topic_uid,
seq.message_uid as msg_uid, seq.message_level as message_level, m.body as body,
m.parent_uid as parent_uid, m.uid as thread_uid
from tl_lafrum11_message_seq seq join tl_lafrum11_message m
where seq.message_level = 1 and seq.message_uid = m.uid; ",

"select chdseq.uid as seq_uid, chdseq.root_message_uid as topic_uid,
chdseq.message_uid as msg_uid, chdseq.message_level as message_level, chdm.body as body,
chdm.parent_uid as parent_uid, tm.thread_uid as thread_uid
from tl_lafrum11_recursive_tmp tm
join tl_lafrum11_message_seq chdseq
join tl_lafrum11_message chdm
where tm.msg_uid = chdm.parent_uid and chdseq.message_uid = chdm.uid;",

"create temporary table tl_lafrum11_thread_message_uid_tmp as
(select thread_uid, seq_uid from tl_lafrum11_recursive_tmp order by thread_uid)",

1000,

""
);

END;

@@ -0,0 +1,31 @@
CREATE PROCEDURE `tl_lafrum11_set_all_thread_message_uids_tmp`()
BEGIN

declare v_finished int default 0;
declare v_thread_uid bigint(20);
declare v_seq_uid bigint(20);

DECLARE thread_cursor CURSOR FOR
SELECT thread_uid, seq_uid FROM tl_lafrum11_thread_message_uid_tmp;

DECLARE CONTINUE HANDLER
FOR NOT FOUND SET v_finished = 1;

OPEN thread_cursor;

get_thread: LOOP

FETCH thread_cursor INTO v_thread_uid, v_seq_uid ;

IF v_finished = 1 THEN
LEAVE get_thread;
END IF;

update tl_lafrum11_message_seq set thread_message_uid = v_thread_uid where uid = v_seq_uid;

END LOOP get_thread;

CLOSE thread_cursor;

END;

@@ -0,0 +1,23 @@
SET AUTOCOMMIT = 0;
SET FOREIGN_KEY_CHECKS = 0;

-- --------------------Put all sql statements below here-------------------------

call tl_lafrum11_get_all_thread_message_uids_tmp();
call tl_lafrum11_set_all_thread_message_uids_tmp();

drop procedure if exists with_emulator;
drop procedure if exists tl_lafrum11_set_all_thread_message_uids_tmp;
drop procedure if exists tl_lafrum11_get_all_thread_message_uids_tmp;

drop temporary table if exists tl_lafrum11_thread_message_uid_tmp;
drop temporary table if exists tl_lafrum11_recursive_tmp;

-- End of thread id addition patches.

-- --------------------Put all sql statements above here-------------------------
-- If there were no errors, commit and restore autocommit to on
COMMIT;
SET AUTOCOMMIT = 1;
SET FOREIGN_KEY_CHECKS = 1;

@@ -58,6 +58,7 @@
public ForumUser() {
}

/** Create the user based on the DTO in the session */
public ForumUser(UserDTO user, ForumToolSession session) {
this.userId = new Long(user.getUserID().intValue());
this.firstName = user.getFirstName();
@@ -66,6 +67,16 @@ public ForumUser(UserDTO user, ForumToolSession session) {
this.session = session;
this.sessionFinished = false;
}

/** Create the user based on the details in the JSON call - used for authoring so no session exists. */
public ForumUser(Long userId, String firstName, String lastName, String loginName) {
this.userId = userId;
this.firstName = firstName;
this.lastName = lastName;
this.loginName = loginName;
this.session = null;
this.sessionFinished = false;
}

// **********************************************************
// Function method for ForumUser
@@ -8,9 +8,17 @@
public interface IMessageSeqDAO extends IBaseDAO {


List getTopicThread(Long rootTopicId);

MessageSeq getByTopicId(Long messageId);
MessageSeq getById(Long messageSeqId);

MessageSeq getByMessageId(Long messageId);

List getThreadByThreadId(final Long threadMessageId);

List getNextThreadByThreadId(final Long rootTopicId, final Long previousThreadMessageId);

List getCompleteTopic(Long rootTopicId);

MessageSeq getByTopicId(Long messageId);

void save(MessageSeq msgSeq);

@@ -37,6 +37,7 @@
private Long uid;
private Message rootMessage;
private Message message;
private Message threadMessage;
private short messageLevel;

/**
@@ -68,6 +69,16 @@ public Message getMessage() {
public void setMessage(Message topicUid) {
this.message = topicUid;
}
/**
* @hibernate.many-to-one column="thread_message_uid" outer-join="true"
* cascade="none"
*/
public Message getThreadMessage() {
return threadMessage;
}
public void setThreadMessage(Message threadTopMessageUid) {
this.threadMessage = threadTopMessageUid;
}
/**
* @hibernate.property column="message_level"
*/

0 comments on commit 2ff38cd

Please sign in to comment.
You can’t perform that action at this time.