001
014
015 package com.liferay.portal.upgrade.v7_0_0;
016
017 import com.liferay.portal.kernel.util.StringBundler;
018
019 import java.io.IOException;
020
021 import java.sql.SQLException;
022
023
026 public class UpgradeCompanyId
027 extends com.liferay.portal.upgrade.util.UpgradeCompanyId {
028
029 @Override
030 protected TableUpdater[] getTableUpdaters() {
031 return new TableUpdater[] {
032 new TableUpdater("AnnouncementsFlag", "User_", "userId"),
033 new TableUpdater(
034 "AssetEntries_AssetCategories", "AssetCategory", "categoryId"),
035 new TableUpdater("AssetEntries_AssetTags", "AssetTag", "tagId"),
036 new TableUpdater("AssetTagStats", "AssetTag", "tagId"),
037 new TableUpdater("BrowserTracker", "User_", "userId"),
038 new TableUpdater(
039 "DLFileEntryMetadata", "DLFileEntry", "fileEntryId"),
040 new TableUpdater(
041 "DLFileEntryTypes_DLFolders", "DLFolder", "folderId"),
042 new DLSyncEventTableUpdater("DLSyncEvent"),
043 new TableUpdater("Groups_Orgs", "Group_", "groupId"),
044 new TableUpdater("Groups_Roles", "Group_", "groupId"),
045 new TableUpdater("Groups_UserGroups", "Group_", "groupId"),
046 new TableUpdater(
047 "Image", "imageId",
048 new String[][] {
049 {"BlogsEntry", "smallImageId"}, {"Company", "logoId"},
050 {"DDMTemplate", "smallImageId"},
051 {"DLFileEntry", "largeImageId"},
052 {"JournalArticle", "smallImageId"},
053 {"Layout", "iconImageId"},
054 {"LayoutRevision", "iconImageId"},
055 {"LayoutSetBranch", "logoId"}, {"Organization_", "logoId"},
056 {"SCProductScreenshot", "fullImageId"},
057 {"SCProductScreenshot", "thumbnailId"},
058 {"User_", "portraitId"}
059 }),
060 new TableUpdater("MBStatsUser", "Group_", "groupId"),
061 new TableUpdater("OrgGroupRole", "Organization_", "organizationId"),
062 new TableUpdater("OrgLabor", "Organization_", "organizationId"),
063 new TableUpdater(
064 "PasswordPolicyRel", "PasswordPolicy", "passwordPolicyId"),
065 new TableUpdater("PasswordTracker", "User_", "userId"),
066 new PortletPreferencesTableUpdater("PortletPreferences"),
067 new TableUpdater(
068 "RatingsStats", "classPK",
069 new String[][] {
070 {"BookmarksEntry", "entryId"},
071 {"BookmarksFolder", "folderId"}, {"BlogsEntry", "entryId"},
072 {"CalendarBooking", "calendarBookingId"},
073 {"DDLRecord", "recordId"}, {"DLFileEntry", "fileEntryId"},
074 {"DLFolder", "folderId"},
075 {"JournalArticle", "resourcePrimKey"},
076 {"JournalFolder", "folderId"},
077 {"MBDiscussion", "discussionId"},
078 {"MBMessage", "messageId"}, {"WikiPage", "pageId"}
079 }),
080 new TableUpdater(
081 "ResourceBlockPermission", "ResourceBlock", "resourceBlockId"),
082 new TableUpdater(
083 "SCFrameworkVersi_SCProductVers", "SCFrameworkVersion",
084 "frameworkVersionId"),
085 new SCLicenseTableUpdater("SCLicense"),
086 new TableUpdater(
087 "SCLicenses_SCProductEntries", "SCProductEntry",
088 "productEntryId"),
089 new TableUpdater("TrashVersion", "TrashEntry", "entryId"),
090 new TableUpdater("UserGroupGroupRole", "UserGroup", "userGroupId"),
091 new TableUpdater("UserGroupRole", "User_", "userId"),
092 new TableUpdater("UserGroups_Teams", "UserGroup", "userGroupId"),
093 new TableUpdater("UserIdMapper", "User_", "userId"),
094 new TableUpdater("Users_Groups", "User_", "userId"),
095 new TableUpdater("Users_Orgs", "User_", "userId"),
096 new TableUpdater("Users_Roles", "User_", "userId"),
097 new TableUpdater("Users_Teams", "User_", "userId"),
098 new TableUpdater("Users_UserGroups", "User_", "userId"),
099 new TableUpdater("UserTrackerPath", "UserTracker", "userTrackerId")
100 };
101 }
102
103 protected class DLSyncEventTableUpdater extends TableUpdater {
104
105 public DLSyncEventTableUpdater(String tableName) {
106 super(tableName, "", "");
107 }
108
109 @Override
110 public void update() throws IOException, SQLException {
111
112
113
114 String selectSQL =
115 "select companyId from DLFileEntry where DLSyncEvent.type_ = " +
116 "'file' and DLFileEntry.fileEntryId = DLSyncEvent.typePK";
117
118 runSQL(getUpdateSQL(selectSQL));
119
120
121
122 selectSQL =
123 "select companyId from DLFolder where DLSyncEvent.type_ = " +
124 "'folder' and DLFolder.folderId = DLSyncEvent.typePK";
125
126 runSQL(getUpdateSQL(selectSQL));
127 }
128
129 }
130
131 protected class PortletPreferencesTableUpdater extends TableUpdater {
132
133 public PortletPreferencesTableUpdater(String tableName) {
134 super(tableName, "", "");
135 }
136
137 @Override
138 public void update() throws IOException, SQLException {
139
140
141
142 String selectSQL =
143 "select companyId from Company where Company.companyId = " +
144 "PortletPreferences.ownerId";
145
146 runSQL(getUpdateSQL(selectSQL));
147
148
149
150 selectSQL =
151 "select companyId from Group_ where Group_.groupId = " +
152 "PortletPreferences.ownerId";
153
154 runSQL(getUpdateSQL(selectSQL));
155
156
157
158 selectSQL =
159 "select companyId from Layout where Layout.plid = " +
160 "PortletPreferences.ownerId";
161
162 runSQL(getUpdateSQL(selectSQL));
163
164
165
166 selectSQL =
167 "select companyId from Organization_ where " +
168 "Organization_.organizationId = PortletPreferences.ownerId";
169
170 runSQL(getUpdateSQL(selectSQL));
171
172
173
174 selectSQL =
175 "select companyId from User_ where User_.userId = " +
176 "PortletPreferences.ownerId";
177
178 runSQL(getUpdateSQL(selectSQL));
179 }
180
181 }
182
183 protected class SCLicenseTableUpdater extends TableUpdater {
184
185 public SCLicenseTableUpdater(String tableName) {
186 super(tableName, "", "");
187 }
188
189 @Override
190 protected String getSelectSQL(
191 String foreignTableName, String foreignColumnName) {
192
193 StringBundler sb = new StringBundler(6);
194
195 sb.append("select SCProductEntry.companyId from ");
196 sb.append("SCLicenses_SCProductEntries, SCProductEntry where ");
197 sb.append("SCLicenses_SCProductEntries.licenseId = ");
198 sb.append("SCLicense.licenseId and ");
199 sb.append("SCLicenses_SCProductEntries.productEntryId = ");
200 sb.append("SCProductEntry.productEntryId");
201
202 return sb.toString();
203 }
204
205 }
206
207 }