1
22
23 package com.liferay.portal.upgrade.v5_1_5;
24
25 import com.liferay.portal.upgrade.UpgradeProcess;
26
27
32 public class UpgradeMessageBoards extends UpgradeProcess {
33
34 protected void doUpgrade() throws Exception {
35 updateGroupId();
36 updateMessageClassNameId();
37 updateMessageFlagThreadId();
38 updateMessagePriority();
39 }
40
41 protected void updateGroupId() throws Exception {
42 StringBuilder sb = new StringBuilder();
43
44 sb.append("update MBCategory set threadCount = (select count(*) from ");
45 sb.append("MBThread where MBThread.categoryId = ");
46 sb.append("MBCategory.categoryId)");
47
48 runSQL(sb.toString());
49
50 sb = new StringBuilder();
51
52 sb.append("update MBCategory set messageCount = (select count(*) ");
53 sb.append("from MBMessage where MBMessage.categoryId = ");
54 sb.append("MBCategory.categoryId)");
55
56 runSQL(sb.toString());
57
58 sb = new StringBuilder();
59
60 sb.append("update MBMessage set groupId = (select groupId from ");
61 sb.append("MBCategory where MBCategory.categoryId = ");
62 sb.append("MBMessage.categoryId)");
63
64 runSQL(sb.toString());
65
66 sb = new StringBuilder();
67
68 sb.append("update MBThread set groupId = (select groupId from ");
69 sb.append("MBCategory where MBCategory.categoryId = ");
70 sb.append("MBThread.categoryId)");
71
72 runSQL(sb.toString());
73 }
74
75 protected void updateMessageClassNameId() throws Exception {
76 StringBuilder sb = new StringBuilder();
77
78 sb.append("update MBMessage set classNameId = (select classNameId ");
79 sb.append("from MBDiscussion where MBDiscussion.threadId = ");
80 sb.append("MBMessage.threadId), classPK = (select classPK from ");
81 sb.append("MBDiscussion where MBDiscussion.threadId = ");
82 sb.append("MBMessage.threadId)");
83
84 runSQL(sb.toString());
85 }
86
87 protected void updateMessageFlagThreadId() throws Exception {
88 StringBuilder sb = new StringBuilder();
89
90 sb.append("update MBMessageFlag set threadId = (select threadId from ");
91 sb.append("MBMessage where MBMessage.messageId = ");
92 sb.append("MBMessageFlag.messageId)");
93
94 runSQL(sb.toString());
95 }
96
97 protected void updateMessagePriority() throws Exception {
98 StringBuilder sb = new StringBuilder();
99
100 sb.append("update MBMessage set priority = (select priority from ");
101 sb.append("MBThread where MBThread.threadId = MBMessage.threadId)");
102
103 runSQL(sb.toString());
104 }
105
106 }