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 {"DDLRecord", "recordId"}, {"DLFileEntry", "fileEntryId"},
069 {"DLFolder", "folderId"},
070 {"JournalArticle", "resourcePrimKey"},
071 {"JournalFolder", "folderId"},
072 {"MBDiscussion", "discussionId"},
073 {"MBMessage", "messageId"}, {"WikiPage", "pageId"}
074 }),
075 new TableUpdater(
076 "ResourceBlockPermission", "ResourceBlock", "resourceBlockId"),
077 new TableUpdater("TrashVersion", "TrashEntry", "entryId"),
078 new TableUpdater("UserGroupGroupRole", "UserGroup", "userGroupId"),
079 new TableUpdater("UserGroupRole", "User_", "userId"),
080 new TableUpdater("UserGroups_Teams", "UserGroup", "userGroupId"),
081 new TableUpdater("UserIdMapper", "User_", "userId"),
082 new TableUpdater("Users_Groups", "User_", "userId"),
083 new TableUpdater("Users_Orgs", "User_", "userId"),
084 new TableUpdater("Users_Roles", "User_", "userId"),
085 new TableUpdater("Users_Teams", "User_", "userId"),
086 new TableUpdater("Users_UserGroups", "User_", "userId"),
087 new TableUpdater("UserTrackerPath", "UserTracker", "userTrackerId")
088 };
089 }
090
091 protected class DLSyncEventTableUpdater extends TableUpdater {
092
093 public DLSyncEventTableUpdater(String tableName) {
094 super(tableName, "", "");
095 }
096
097 @Override
098 public void update() throws IOException, SQLException {
099
100
101
102 String selectSQL =
103 "select companyId from DLFileEntry where DLSyncEvent.type_ = " +
104 "'file' and DLFileEntry.fileEntryId = DLSyncEvent.typePK";
105
106 runSQL(getUpdateSQL(selectSQL));
107
108
109
110 selectSQL =
111 "select companyId from DLFolder where DLSyncEvent.type_ = " +
112 "'folder' and DLFolder.folderId = DLSyncEvent.typePK";
113
114 runSQL(getUpdateSQL(selectSQL));
115 }
116
117 }
118
119 protected class PortletPreferencesTableUpdater extends TableUpdater {
120
121 public PortletPreferencesTableUpdater(String tableName) {
122 super(tableName, "", "");
123 }
124
125 @Override
126 public void update() throws IOException, SQLException {
127
128
129
130 String selectSQL =
131 "select companyId from Company where Company.companyId = " +
132 "PortletPreferences.ownerId";
133
134 runSQL(getUpdateSQL(selectSQL));
135
136
137
138 selectSQL =
139 "select companyId from Group_ where Group_.groupId = " +
140 "PortletPreferences.ownerId";
141
142 runSQL(getUpdateSQL(selectSQL));
143
144
145
146 selectSQL =
147 "select companyId from Layout where Layout.plid = " +
148 "PortletPreferences.ownerId";
149
150 runSQL(getUpdateSQL(selectSQL));
151
152
153
154 selectSQL =
155 "select companyId from Organization_ where " +
156 "Organization_.organizationId = PortletPreferences.ownerId";
157
158 runSQL(getUpdateSQL(selectSQL));
159
160
161
162 selectSQL =
163 "select companyId from User_ where User_.userId = " +
164 "PortletPreferences.ownerId";
165
166 runSQL(getUpdateSQL(selectSQL));
167 }
168
169 }
170
171 }