protected void updateLayouts( String oldRootPortletId, String newRootPortletId, boolean exactMatch) throws Exception { String sql1 = "select plid, typeSettings from Layout where " + getTypeSettingsCriteria(oldRootPortletId); String sql2 = "update Layout set typeSettings = ? where plid = ?"; try (PreparedStatement ps1 = connection.prepareStatement(sql1); PreparedStatement ps2 = AutoBatchPreparedStatementUtil.concurrentAutoBatch( connection, sql2); ResultSet rs = ps1.executeQuery()) { while (rs.next()) { long plid = rs.getLong("plid"); String typeSettings = rs.getString("typeSettings"); String newTypeSettings = getNewTypeSettings( typeSettings, oldRootPortletId, newRootPortletId, exactMatch); ps2.setString(1, newTypeSettings); ps2.setLong(2, plid); ps2.addBatch(); } ps2.executeBatch(); } }
protected void updateJournalArticleImagesInstanceId() throws Exception { try (LoggingTimer loggingTimer = new LoggingTimer(); PreparedStatement ps1 = connection.prepareStatement( "select articleId, elName from JournalArticleImage where " + "(elInstanceId = '' or elInstanceId is null) group by " + "articleId, elName"); ResultSet rs = ps1.executeQuery()) { try (PreparedStatement ps2 = AutoBatchPreparedStatementUtil.autoBatch( connection.prepareStatement( "update JournalArticleImage set elInstanceId = ? " + "where articleId = ? and elName = ?"))) { while (rs.next()) { String articleId = rs.getString(1); String elName = rs.getString(2); ps2.setString(1, StringUtil.randomString(4)); ps2.setString(2, articleId); ps2.setString(3, elName); ps2.addBatch(); } ps2.executeBatch(); } } }
protected void updateJournalArticleImagesName() throws Exception { try (LoggingTimer loggingTimer = new LoggingTimer(); PreparedStatement ps1 = connection.prepareStatement( "select articleImageId, elName from JournalArticleImage"); ResultSet rs = ps1.executeQuery()) { try (PreparedStatement ps2 = AutoBatchPreparedStatementUtil.autoBatch( connection.prepareStatement( "update JournalArticleImage set elName = ? where " + "articleImageId = ?"))) { while (rs.next()) { String elName = rs.getString(2); int lastIndexOf = elName.lastIndexOf(StringPool.UNDERLINE); if (lastIndexOf < 1) { continue; } String index = elName.substring(lastIndexOf + 1); if (!Validator.isNumber(index)) { continue; } ps2.setString(1, elName.substring(0, lastIndexOf)); ps2.setLong(2, rs.getLong(1)); ps2.addBatch(); } ps2.executeBatch(); } } }
protected void updateLayoutRevisions( String oldRootPortletId, String newRootPortletId, boolean exactMatch) throws Exception { String sql1 = "select layoutRevisionId, typeSettings from LayoutRevision where " + getTypeSettingsCriteria(oldRootPortletId); String sql2 = "update LayoutRevision set typeSettings = ? where " + "layoutRevisionId = ?"; try (PreparedStatement ps1 = connection.prepareStatement(sql1); PreparedStatement ps2 = AutoBatchPreparedStatementUtil.concurrentAutoBatch( connection, sql2); ResultSet rs = ps1.executeQuery()) { while (rs.next()) { long layoutRevisionId = rs.getLong("layoutRevisionId"); String typeSettings = rs.getString("typeSettings"); String newTypeSettings = getNewTypeSettings( typeSettings, oldRootPortletId, newRootPortletId, exactMatch); ps2.setString(1, newTypeSettings); ps2.setLong(2, layoutRevisionId); ps2.addBatch(); } ps2.executeBatch(); } }
protected void updateGroup(String oldRootPortletId, String newRootPortletId) throws Exception { String oldStagedPortletId = _getStagedPortletId(oldRootPortletId); String sql1 = StringBundler.concat( "select groupId, typeSettings from Group_ where typeSettings like ", "'%", oldStagedPortletId, "%'"); String sql2 = "update Group_ set typeSettings = ? where groupId = ?"; try (PreparedStatement ps1 = connection.prepareStatement(sql1); PreparedStatement ps2 = AutoBatchPreparedStatementUtil.concurrentAutoBatch( connection, sql2); ResultSet rs = ps1.executeQuery()) { while (rs.next()) { long groupId = rs.getLong("groupId"); String typeSettings = rs.getString("typeSettings"); String newTypeSettings = getNewTypeSettings( typeSettings, oldStagedPortletId, _getStagedPortletId(newRootPortletId)); ps2.setString(1, newTypeSettings); ps2.setLong(2, groupId); ps2.addBatch(); } ps2.executeBatch(); } }
private void _deleteConflictingPreferences(String orClauses) throws SQLException { StringBundler sb = new StringBundler(4); sb.append("select PP1.portletPreferencesId from PortletPreferences "); sb.append("PP1 inner join PortletPreferences PP2 on PP1.plid = "); sb.append("PP2.plid where "); sb.append(orClauses); try (PreparedStatement ps1 = connection.prepareStatement(sb.toString()); PreparedStatement ps2 = AutoBatchPreparedStatementUtil.concurrentAutoBatch( connection, "delete from PortletPreferences where " + "portletPreferencesId = ?")) { ResultSet rs = ps1.executeQuery(); int deleteCount = 0; while (rs.next()) { ps2.setLong(1, rs.getLong(1)); ps2.addBatch(); deleteCount++; } if (deleteCount > 0) { ps2.executeBatch(); } } }
sb.toString()); PreparedStatement ps2 = AutoBatchPreparedStatementUtil.concurrentAutoBatch( connection, "delete from ResourceAction where resourceActionId = " +
sb.toString()); PreparedStatement ps2 = AutoBatchPreparedStatementUtil.concurrentAutoBatch( connection, "update PortletPreferences set preferences = ? where " + "portletPreferencesId = ?"); PreparedStatement ps3 = AutoBatchPreparedStatementUtil.concurrentAutoBatch( connection, "delete from PortletPreferences where " +
try (PreparedStatement ps1 = connection.prepareStatement(sql); PreparedStatement ps2 = AutoBatchPreparedStatementUtil.concurrentAutoBatch( connection, "update PortletPreferences set preferences = ? where " +
@Override protected void doUpgrade() throws Exception { try (PreparedStatement ps1 = connection.prepareStatement( "select dataProviderInstanceId, definition, type_ from " + "DDMDataProviderInstance"); PreparedStatement ps2 = AutoBatchPreparedStatementUtil.concurrentAutoBatch( connection, "update DDMDataProviderInstance set definition = ? where " + "dataProviderInstanceId = ?"); ResultSet rs = ps1.executeQuery()) { while (rs.next()) { String dataProviderInstanceDefinition = rs.getString(2); String type = rs.getString(3); String newDefinition = upgradeDataProviderInstanceDefinition( dataProviderInstanceDefinition, type); ps2.setString(1, newDefinition); long dataProviderInstanceId = rs.getLong(1); ps2.setLong(2, dataProviderInstanceId); ps2.addBatch(); } ps2.executeBatch(); } }
@Override protected void doUpgrade() throws Exception { try (PreparedStatement ps = connection.prepareStatement( "select structureId, definition from DDMStructure where " + "classNameId = ?"); PreparedStatement ps2 = AutoBatchPreparedStatementUtil.concurrentAutoBatch( connection, "update DDMStructure set definition = ? where " + "structureId = ?")) { ps.setLong(1, PortalUtil.getClassNameId(DDMFormInstance.class)); try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { String definition = rs.getString("definition"); ps2.setString(1, updateFieldsToLocalizable(definition)); long structureId = rs.getLong("structureId"); ps2.setLong(2, structureId); ps2.addBatch(); } } ps2.executeBatch(); } }
protected void updateContent() throws Exception { try (LoggingTimer loggingTimer = new LoggingTimer(); PreparedStatement ps1 = connection.prepareStatement( "select content, id_ from JournalArticle where content like " + "?")) { ps1.setString(1, "%type=\"document_library\"%"); ResultSet rs1 = ps1.executeQuery(); while (rs1.next()) { String content = rs1.getString(1); long id = rs1.getLong(2); try (PreparedStatement ps2 = AutoBatchPreparedStatementUtil.concurrentAutoBatch( connection, "update JournalArticle set content = ? where id_ " + "= ?")) { ps2.setString(1, convertContent(content)); ps2.setLong(2, id); ps2.executeUpdate(); } } } }
protected void updateContentImages() throws Exception { try (LoggingTimer loggingTimer = new LoggingTimer(); PreparedStatement ps1 = connection.prepareStatement( "select content, id_ from JournalArticle where content like " + "?")) { ps1.setString(1, "%type=\"image\"%"); ResultSet rs = ps1.executeQuery(); while (rs.next()) { String content = rs.getString(1); long id = rs.getLong(2); String newContent = addImageContentAttributes(content); try (PreparedStatement ps = AutoBatchPreparedStatementUtil.concurrentAutoBatch( connection, "update JournalArticle set content = ? where id_ " + "= ?")) { ps.setString(1, newContent); ps.setLong(2, id); ps.executeUpdate(); } } } }
@Override protected void doUpgrade() throws Exception { try (PreparedStatement ps1 = connection.prepareStatement( StringBundler.concat( "select DDMContent.contentId, DDMContent.data_ from ", "DDMFormInstanceRecordVersion inner join DDMFormInstance ", "on DDMFormInstanceRecordVersion.formInstanceId = ", "DDMFormInstance.formInstanceId inner join DDMContent on ", "DDMFormInstanceRecordVersion.storageId = DDMContent.", "contentId")); PreparedStatement ps2 = AutoBatchPreparedStatementUtil.concurrentAutoBatch( connection, "update DDMContent set data_ = ? where contentId = ?"); ResultSet rs = ps1.executeQuery()) { while (rs.next()) { String data = rs.getString("data_"); ps2.setString(1, updateFieldValuesToLocalizable(data)); long contentId = rs.getLong("contentId"); ps2.setLong(2, contentId); ps2.addBatch(); } ps2.executeBatch(); } }
protected void upgradeDDMStructureReferences() throws Exception { try (PreparedStatement ps1 = connection.prepareStatement( "select DDMStructure.structureId from DDMStructure"); PreparedStatement ps2 = AutoBatchPreparedStatementUtil.concurrentAutoBatch( connection, "update DDMStructure set definition = ? where " + "structureId = ?"); ResultSet rs = ps1.executeQuery()) { while (rs.next()) { long ddmStructureId = rs.getLong("structureId"); DDMForm ddmForm = getDDMForm(ddmStructureId); updateDDMFormFields(ddmForm); ps2.setString(1, _ddmFormJSONSerializer.serialize(ddmForm)); ps2.setLong(2, ddmStructureId); ps2.addBatch(); } ps2.executeBatch(); } }
protected void updateContentImages() throws Exception { try (LoggingTimer loggingTimer = new LoggingTimer(); PreparedStatement ps1 = connection.prepareStatement( "select content, groupId, id_, resourcePrimKey, userId from " + "JournalArticle where content like ?")) { ps1.setString(1, "%type=\"image\"%"); ResultSet rs1 = ps1.executeQuery(); while (rs1.next()) { String content = rs1.getString(1); long groupId = rs1.getLong(2); long id = rs1.getLong(3); long resourcePrimKey = rs1.getLong(4); long userId = rs1.getLong(5); String newContent = convertTypeImageElements( userId, groupId, content, resourcePrimKey); try (PreparedStatement ps2 = AutoBatchPreparedStatementUtil.concurrentAutoBatch( connection, "update JournalArticle set content = ? where id_ " + "= ?")) { ps2.setString(1, newContent); ps2.setLong(2, id); ps2.executeUpdate(); } } } }
protected void upgradeDDMContentReferences(String query) throws Exception { try (PreparedStatement ps1 = connection.prepareStatement(query); PreparedStatement ps2 = AutoBatchPreparedStatementUtil.concurrentAutoBatch( connection, "update DDMContent set data_= ? where contentId = ?"); ResultSet rs = ps1.executeQuery()) { while (rs.next()) { String data = rs.getString("data_"); long ddmStructureId = rs.getLong("structureId"); DDMForm ddmForm = getFullHierarchyDDMForm(ddmStructureId); DDMFormValues ddmFormValues = _ddmFormValuesJSONDeserializer.deserialize(ddmForm, data); transformDDMFormFieldValues(ddmFormValues); ps2.setString( 1, _ddmFormValuesJSONSerializer.serialize(ddmFormValues)); long contentId = rs.getLong("contentId"); ps2.setLong(2, contentId); ps2.addBatch(); } ps2.executeBatch(); } }
"portletId = ? AND articleId = ?"); PreparedStatement ps3 = AutoBatchPreparedStatementUtil.concurrentAutoBatch( connection, "update JournalContentSearch set portletId = ? where " +
protected void upgradeDDMStructureDefinition() throws Exception { StringBundler sb = new StringBundler(2); sb.append("select DDMStructure.definition, DDMStructure.structureId "); sb.append("from DDMStructure"); try (PreparedStatement ps1 = connection.prepareStatement(sb.toString()); PreparedStatement ps2 = AutoBatchPreparedStatementUtil.concurrentAutoBatch( connection, "update DDMStructure set definition = ? where " + "structureId = ?")) { try (ResultSet rs = ps1.executeQuery()) { while (rs.next()) { String definition = rs.getString(1); long structureId = rs.getLong(2); String newDefinition = updateDefinition(definition); ps2.setString(1, newDefinition); ps2.setLong(2, structureId); ps2.addBatch(); } ps2.executeBatch(); } } }
"DDMStorageLink.structureId = TEMP_TABLE.structureId")); PreparedStatement ps2 = AutoBatchPreparedStatementUtil.concurrentAutoBatch( connection, "update DDMStorageLink set structureVersionId = ? where " +