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