Skip to content

Commit 82de94e

Browse files
lfbesadabrianchandotcom
authored andcommitted
LPS-141924 SF inline
1 parent f245f4b commit 82de94e

File tree

1 file changed

+26
-36
lines changed

1 file changed

+26
-36
lines changed

modules/apps/layout/layout-page-template-service/src/main/java/com/liferay/layout/page/template/internal/upgrade/v1_1_1/LayoutPageTemplateEntryUpgradeProcess.java

Lines changed: 26 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -71,51 +71,41 @@ protected void doUpgrade() throws Exception {
7171
String name = resultSet.getString("name");
7272
long layoutPrototypeId = resultSet.getLong("layoutPrototypeId");
7373

74-
_updateLayoutPageTemplateEntry(
75-
layoutPageTemplateEntryId, companyId, name,
76-
layoutPrototypeId, countPreparedStatement,
77-
deletePreparedStatement, updatePreparedStatement);
78-
}
79-
}
80-
}
74+
Company company = _companyLocalService.getCompany(companyId);
8175

82-
private void _updateLayoutPageTemplateEntry(
83-
long layoutPageTemplateEntryId, long companyId, String name,
84-
long layoutPrototypeId, PreparedStatement countPreparedStatement,
85-
PreparedStatement deletePreparedStatement,
86-
PreparedStatement updatePreparedStatement)
87-
throws Exception {
76+
String newName = name;
8877

89-
Company company = _companyLocalService.getCompany(companyId);
78+
for (int i = 1;; i++) {
79+
countPreparedStatement.setLong(1, company.getGroupId());
80+
countPreparedStatement.setString(2, newName);
9081

91-
String newName = name;
82+
ResultSet countResultSet =
83+
countPreparedStatement.executeQuery();
9284

93-
for (int i = 1;; i++) {
94-
countPreparedStatement.setLong(1, company.getGroupId());
95-
countPreparedStatement.setString(2, newName);
85+
if (countResultSet.next() &&
86+
(countResultSet.getInt(1) > 0)) {
9687

97-
ResultSet resultSet = countPreparedStatement.executeQuery();
88+
newName = name + i;
89+
}
90+
else {
91+
break;
92+
}
93+
}
9894

99-
if (resultSet.next() && (resultSet.getInt(1) > 0)) {
100-
newName = name + i;
101-
}
102-
else {
103-
break;
104-
}
105-
}
106-
107-
updatePreparedStatement.setLong(1, company.getGroupId());
108-
updatePreparedStatement.setString(2, newName);
109-
updatePreparedStatement.setLong(3, layoutPageTemplateEntryId);
95+
updatePreparedStatement.setLong(1, company.getGroupId());
96+
updatePreparedStatement.setString(2, newName);
97+
updatePreparedStatement.setLong(3, layoutPageTemplateEntryId);
11098

111-
updatePreparedStatement.executeUpdate();
99+
updatePreparedStatement.executeUpdate();
112100

113-
deletePreparedStatement.setLong(1, company.getGroupId());
114-
deletePreparedStatement.setInt(
115-
2, LayoutPageTemplateEntryTypeConstants.TYPE_WIDGET_PAGE);
116-
deletePreparedStatement.setLong(3, layoutPrototypeId);
101+
deletePreparedStatement.setLong(1, company.getGroupId());
102+
deletePreparedStatement.setInt(
103+
2, LayoutPageTemplateEntryTypeConstants.TYPE_WIDGET_PAGE);
104+
deletePreparedStatement.setLong(3, layoutPrototypeId);
117105

118-
deletePreparedStatement.executeUpdate();
106+
deletePreparedStatement.executeUpdate();
107+
}
108+
}
119109
}
120110

121111
private final CompanyLocalService _companyLocalService;

0 commit comments

Comments
 (0)