001
014
015 package com.liferay.portal.upgrade.v6_1_1;
016
017 import com.liferay.portal.kernel.upgrade.UpgradeProcess;
018 import com.liferay.portal.kernel.util.LoggingTimer;
019 import com.liferay.portal.kernel.util.StringBundler;
020
021 import java.sql.PreparedStatement;
022 import java.sql.ResultSet;
023
024
028 public class UpgradeLayoutSetBranch extends UpgradeProcess {
029
030 @Override
031 protected void doUpgrade() throws Exception {
032 updateLayoutSetBranches();
033 }
034
035 protected void updateLayoutSetBranch(
036 long layoutSetBranchId, String themeId, String colorSchemeId,
037 String wapThemeId, String wapColorSchemeId, String css,
038 String settings, String layoutSetPrototypeUuid,
039 boolean layoutSetPrototypeLinkEnabled)
040 throws Exception {
041
042 StringBundler sb = new StringBundler(5);
043
044 sb.append("update LayoutSetBranch set themeId = ?, colorSchemeId = ");
045 sb.append("?, wapThemeId = ?, wapColorSchemeId = ?, css = ?, ");
046 sb.append("settings_ = ?, layoutSetPrototypeUuid = ?, ");
047 sb.append("layoutSetPrototypeLinkEnabled = ? where layoutSetBranchId ");
048 sb.append("= ?");
049
050 try (PreparedStatement ps = connection.prepareStatement(
051 sb.toString())) {
052
053 ps.setString(1, themeId);
054 ps.setString(2, colorSchemeId);
055 ps.setString(3, wapThemeId);
056 ps.setString(4, wapColorSchemeId);
057 ps.setString(5, css);
058 ps.setString(6, settings);
059 ps.setString(7, layoutSetPrototypeUuid);
060 ps.setBoolean(8, layoutSetPrototypeLinkEnabled);
061 ps.setLong(9, layoutSetBranchId);
062
063 ps.executeUpdate();
064 }
065 }
066
067 protected void updateLayoutSetBranches() throws Exception {
068 try (LoggingTimer loggingTimer = new LoggingTimer();
069 PreparedStatement ps = connection.prepareStatement(
070 "select groupId, layoutSetBranchId, privateLayout from " +
071 "LayoutSetBranch");
072 ResultSet rs = ps.executeQuery()) {
073
074 while (rs.next()) {
075 long layoutSetBranchId = rs.getLong("layoutSetBranchId");
076 long groupId = rs.getLong("groupId");
077 boolean privateLayout = rs.getBoolean("privateLayout");
078
079 upgradeLayoutSetBranch(
080 layoutSetBranchId, groupId, privateLayout);
081 }
082 }
083 }
084
085 protected void upgradeLayoutSetBranch(
086 long layoutSetBranchId, long groupId, boolean privateLayout)
087 throws Exception {
088
089 StringBundler sb = new StringBundler(4);
090
091 sb.append("select themeId, colorSchemeId, wapThemeId, ");
092 sb.append("wapColorSchemeId, css, settings_, ");
093 sb.append("layoutSetPrototypeUuid, layoutSetPrototypeLinkEnabled ");
094 sb.append("from LayoutSet where groupId = ? and privateLayout = ?");
095
096 try (PreparedStatement ps = connection.prepareStatement(
097 sb.toString())) {
098
099 ps.setLong(1, groupId);
100 ps.setBoolean(2, privateLayout);
101
102 try (ResultSet rs = ps.executeQuery()) {
103 while (rs.next()) {
104 String themeId = rs.getString("themeId");
105 String colorSchemeId = rs.getString("colorSchemeId");
106 String wapThemeId = rs.getString("wapThemeId");
107 String wapColorSchemeId = rs.getString("wapColorSchemeId");
108 String css = rs.getString("css");
109 String settings = rs.getString("settings_");
110 String layoutSetPrototypeUuid = rs.getString(
111 "layoutSetPrototypeUuid");
112 boolean layoutSetPrototypeLinkEnabled = rs.getBoolean(
113 "layoutSetPrototypeLinkEnabled");
114
115 updateLayoutSetBranch(
116 layoutSetBranchId, themeId, colorSchemeId, wapThemeId,
117 wapColorSchemeId, css, settings, layoutSetPrototypeUuid,
118 layoutSetPrototypeLinkEnabled);
119 }
120 }
121 }
122 }
123
124 }