Source:
private void populateDefaultEditorValues(Connection connection, String tablePrefix, Table table) throws SQLException { Statement statement = connection.createStatement(); if (Table.ROUTES.name.equals(table.name)) { String updateStatusSql = String.format( "update %sroutes set status = 2, publicly_visible = 1 where status is NULL AND publicly_visible is NULL", tablePrefix); int updatedRoutes = statement.executeUpdate(updateStatusSql); LOG.info("Updated status for routes", updatedRoutes); } if (Table.CALENDAR.name.equals(table.name)) { LOG.info("Updating calendar descriptions"); String[] daysOfWeek = new String[]{"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"}; String concatenatedDaysOfWeek = String.join(", ", Arrays.stream(daysOfWeek) .map(d -> String.format( "case %s when 1 then '%s' else '' end", d, d.substring(0, 1).toUpperCase() + d.substring(1, 2))).toArray(String[]::new)); String updateOtherSql = String.format( "update %scalendar set description = concat(%s) where description is NULL", tablePrefix, concatenatedDaysOfWeek); LOG.info(updateOtherSql); int calendarsUpdated = statement.executeUpdate(updateOtherSql); LOG.info("Updated description for calendars", calendarsUpdated); } if (Table.TRIPS.name.equals(table.name)) { String updatePatternsSql = String.format( "update %spatterns set use_frequency = 1 " + "from (select distinct %<strips.pattern_id from %<strips, %<sfrequencies where %<sfrequencies.trip_id = %<strips.trip_id) freq " + "where freq.pattern_id = %<spatterns.pattern_id", tablePrefix); LOG.info(updatePatternsSql); int patternsUpdated = statement.executeUpdate(updatePatternsSql); LOG.info("Updated use_frequency for patterns", patternsUpdated); } }

Target:
private void populateDefaultEditorValues(Connection connection, String tablePrefix, Table table) throws SQLException { Statement statement = connection.createStatement(); if (Table.ROUTES.name.equals(table.name)) { String updateStatusSql = String.format( "update %sroutes set status = 2, publicly_visible = 1 where status is NULL AND publicly_visible is NULL", tablePrefix); int updatedRoutes = statement.executeUpdate(updateStatusSql); LOG.info("Updated status for routes", updatedRoutes); } if (Table.CALENDAR.name.equals(table.name)) { LOG.info("Updating calendar descriptions"); String[] daysOfWeek = new String[]{"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"}; String concatenatedDaysOfWeek = String.join(", ", Arrays.stream(daysOfWeek) .map(d -> String.format( "case %s when 1 then '%s' else '' end", d, d.substring(0, 1).toUpperCase() + d.substring(1, 2))).toArray(String[]::new)); String updateOtherSql = String.format( "update %scalendar set description = concat(%s) where description is NULL", tablePrefix, concatenatedDaysOfWeek); LOG.info(updateOtherSql); int calendarsUpdated = statement.executeUpdate(updateOtherSql); LOG.info("Updated description for calendars", calendarsUpdated); } if (Table.TRIPS.name.equals(table.name)) { String updatePatternsSql = String.format( "update %1$spatterns set use_frequency = 1 " + "from (select distinct %1$strips.pattern_id from %1$strips, %1$sfrequencies where %1$sfrequencies.trip_id = %1$strips.trip_id) freq " + "where freq.pattern_id = %1$spatterns.pattern_id", tablePrefix); LOG.info(updatePatternsSql); int patternsUpdated = statement.executeUpdate(updatePatternsSql); LOG.info("Updated use_frequency for patterns", patternsUpdated); } }