protected void updateJournalArticleLocalizedFields() throws Exception { StringBundler sb = new StringBundler(3); sb.append("insert into JournalArticleLocalization("); sb.append("articleLocalizationId, companyId, articlePK, title, "); sb.append("description, languageId) values(?, ?, ?, ?, ?, ?)"); try (LoggingTimer loggingTimer = new LoggingTimer(); PreparedStatement ps1 = connection.prepareStatement( "select id_, companyId, title, description from " + "JournalArticle"); PreparedStatement ps2 = AutoBatchPreparedStatementUtil.concurrentAutoBatch(connection, sb.toString()); ResultSet rs = ps1.executeQuery()) { while (rs.next()) { long articleId = rs.getLong(1); long companyId = rs.getLong(2); String title = rs.getString(3); String description = rs.getString(4); Map<Locale, String> titleMap = LocalizationUtil.getLocalizationMap(title); Map<Locale, String> descriptionMap = LocalizationUtil.getLocalizationMap(description); Set<Locale> localeSet = new HashSet<>(); localeSet.addAll(titleMap.keySet()); localeSet.addAll(descriptionMap.keySet()); for (Locale locale : localeSet) { ps2.setLong(1, _increment()); ps2.setLong(2, companyId); ps2.setLong(3, articleId); ps2.setString(4, titleMap.get(locale)); ps2.setString(5, descriptionMap.get(locale)); ps2.setString(6, LocaleUtil.toLanguageId(locale)); ps2.addBatch(); } } ps2.executeBatch(); } }
protected void updateJournalArticleDefaultLanguageId() throws Exception { try (LoggingTimer loggingTimer = new LoggingTimer(); PreparedStatement ps1 = connection.prepareStatement("select id_, title from JournalArticle"); PreparedStatement ps2 = AutoBatchPreparedStatementUtil.concurrentAutoBatch( connection, "update JournalArticle set defaultLanguageId = ? where " + "id_ = ?"); ResultSet rs = ps1.executeQuery()) { Locale defaultLocale = LocaleUtil.getSiteDefault(); while (rs.next()) { String defaultLanguageId = LocalizationUtil.getDefaultLanguageId(rs.getString(2), defaultLocale); ps2.setString(1, defaultLanguageId); ps2.setLong(2, rs.getLong(1)); ps2.addBatch(); } ps2.executeBatch(); } }