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 UpgradeLayoutSet extends UpgradeProcess {
029
030 @Override
031 protected void doUpgrade() throws Exception {
032 updateLayoutSets();
033 }
034
035 protected void updateLayoutSets() throws Exception {
036 try (LoggingTimer loggingTimer = new LoggingTimer()) {
037 StringBundler sb = new StringBundler(4);
038
039 sb.append("select Group_.groupId, Group_.liveGroupId, ");
040 sb.append(
041 "LayoutSet.layoutSetId from LayoutSet inner join Group_ ");
042 sb.append("on (LayoutSet.groupId = Group_.groupId and ");
043 sb.append("Group_.liveGroupId > 0 and LayoutSet.logo = ?)");
044
045 try (PreparedStatement ps = connection.prepareStatement(
046 sb.toString())) {
047
048 ps.setBoolean(1, true);
049
050 try (ResultSet rs = ps.executeQuery()) {
051 while (rs.next()) {
052 long groupId = rs.getLong("Group_.groupId");
053 long layoutSetId = rs.getLong("LayoutSet.layoutSetId");
054
055 runSQL(
056 "update LayoutSet set logoId = 0 where groupId = " +
057 groupId + " and layoutSetId = " + layoutSetId);
058 }
059 }
060 }
061 }
062 }
063
064 }