private void insertBlankStopTimes(
        List<String> tripIds,
        List<PatternStop> newStops,
        int startingStopSequence,
        int stopTimesToAdd,
        Connection connection
    ) throws SQLException {
        if (tripIds.isEmpty()) {
            // There is no need to insert blank stop times if there are no trips for the pattern.
            return;
        }
        String insertSql = Table.STOP_TIMES.generateInsertSql(tablePrefix, true);
        PreparedStatement insertStatement = connection.prepareStatement(insertSql);
        int count = 0;
        int totalRowsUpdated = 0;
        // Create a new stop time for each sequence value (times each trip ID) that needs to be inserted.
        for (int i = startingStopSequence; i < stopTimesToAdd + startingStopSequence; i++) {
            PatternStop patternStop = newStops.get(i);
            StopTime stopTime = new StopTime();
            stopTime.stop_id = patternStop.stop_id;
            stopTime.drop_off_type = patternStop.drop_off_type;
            stopTime.pickup_type = patternStop.pickup_type;
            stopTime.timepoint = patternStop.timepoint;
            stopTime.shape_dist_traveled = patternStop.shape_dist_traveled;
            stopTime.stop_sequence = i;
            // Update stop time with each trip ID and add to batch.
            for (String tripId : tripIds) {
                stopTime.trip_id = tripId;
                stopTime.setStatementParameters(insertStatement, true);
                insertStatement.addBatch();
                if (count % INSERT_BATCH_SIZE == 0) {
                    int[] rowsUpdated = insertStatement.executeBatch();
                    totalRowsUpdated += rowsUpdated.length;
                }
            }
        }
        int[] rowsUpdated = insertStatement.executeBatch();
        totalRowsUpdated += rowsUpdated.length;
        LOG.info("{} blank stop times inserted", totalRowsUpdated);
    }
private void insertBlankStopTimes(
        List<String> tripIds,
        List<PatternStop> newStops,
        int startingStopSequence,
        int stopTimesToAdd,
        Connection connection
    ) throws SQLException {
        if (tripIds.isEmpty()) {
            
            return;
        }
        String insertSql = Table.STOP_TIMES.generateInsertSql(tablePrefix, true);
        PreparedStatement insertStatement = connection.prepareStatement(insertSql);
        int count = 0;
        int totalRowsUpdated = 0;
        
        for (int i = startingStopSequence; i < stopTimesToAdd + startingStopSequence; i++) {
            PatternStop patternStop = newStops.get(i);
            StopTime stopTime = new StopTime();
            stopTime.stop_id = patternStop.stop_id;
            stopTime.drop_off_type = patternStop.drop_off_type;
            stopTime.pickup_type = patternStop.pickup_type;
            stopTime.timepoint = patternStop.timepoint;
            stopTime.shape_dist_traveled = patternStop.shape_dist_traveled;
            stopTime.stop_sequence = i;
            
            for (String tripId : tripIds) {
                stopTime.trip_id = tripId;
                stopTime.setStatementParameters(insertStatement, true);
                insertStatement.addBatch();
                if (count % INSERT_BATCH_SIZE == 0) {
                    int[] rowsUpdated = insertStatement.executeBatch();
                    totalRowsUpdated += rowsUpdated.length;
                }
            }
        }
        int[] rowsUpdated = insertStatement.executeBatch();
        totalRowsUpdated += rowsUpdated.length;
        LOG.info("{} blank stop times inserted", totalRowsUpdated);
    }
private void insertBlankStopTimes ( List < String > tripIds , List < PatternStop > newStops , int startingStopSequence , int stopTimesToAdd , Connection connection ) throws SQLException { if ( tripIds . isEmpty ( ) ) { // There is no need to insert blank stop times if there are no trips for the pattern. return ; } String insertSql = Table . STOP_TIMES . generateInsertSql ( tablePrefix , true ) ; PreparedStatement insertStatement = connection . prepareStatement ( insertSql ) ; int count = 0 ; int totalRowsUpdated = 0 ; // Create a new stop time for each sequence value (times each trip ID) that needs to be inserted. for ( int i = startingStopSequence ; i < stopTimesToAdd + startingStopSequence ; i ++ ) { PatternStop patternStop = newStops . get ( i ) ; StopTime stopTime = new StopTime ( ) ; stopTime . stop_id = patternStop . stop_id ; stopTime . drop_off_type = patternStop . drop_off_type ; stopTime . pickup_type = patternStop . pickup_type ; stopTime . timepoint = patternStop . timepoint ; stopTime . shape_dist_traveled = patternStop . shape_dist_traveled ; stopTime . stop_sequence = i ; // Update stop time with each trip ID and add to batch. for ( String tripId : tripIds ) { stopTime . trip_id = tripId ; stopTime . setStatementParameters ( insertStatement , true ) ; insertStatement . addBatch ( ) ; if ( count % INSERT_BATCH_SIZE == 0 ) { int [ ] rowsUpdated = insertStatement . executeBatch ( ) ; totalRowsUpdated += rowsUpdated . length ; } } } int [ ] rowsUpdated = insertStatement . executeBatch ( ) ; totalRowsUpdated += rowsUpdated . length ; LOG . info ( "{} blank stop times inserted" , totalRowsUpdated ) ; }
You must call this method after updating sequences for any stop times following the starting stop sequence to
avoid overwriting these other stop times.
You must call this method after updating sequences for any stop times following the starting stop sequence to avoid overwriting these other stop times .