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