private void registerFeed () {
    """
	Add a line to the list of loaded feeds showing that this feed has been loaded.
	We used to inspect feed_info here so we could make our table prefix based on feed ID and version.
	Now we just load feed_info like any other table.
	// Create a row in the table of loaded feeds for this feed
	Really this is not just making the table prefix - it's loading the feed_info and should also calculate hashes.
	
	Originally we were flattening all feed_info files into one root-level table, but that forces us to drop any
	custom fields in feed_info.
    """

        // FIXME is this extra CSV reader used anymore? Check comment below.
        // First, inspect feed_info.txt to extract the ID and version.
        // We could get this with SQL after loading, but feed_info, feed_id and feed_version are all optional.
        FeedInfo feedInfo = gtfsFeed.feedInfo.isEmpty() ? null : gtfsFeed.feedInfo.values().iterator().next();
        String feedId = "", feedVersion = "";
        if (feedInfo != null) {
            feedId = feedInfo.feed_id;
            feedVersion = feedInfo.feed_version;
        }

        try {
            Statement statement = connection.createStatement();
            // FIXME do the following only on databases that support schemas.
            // SQLite does not support them. Is there any advantage of schemas over flat tables?
            statement.execute("create schema " + tablePrefix);
            // current_timestamp seems to be the only standard way to get the current time across all common databases.
            // Record total load processing time?
            statement.execute("create table if not exists feeds (namespace varchar primary key, md5 varchar, " +
                    "sha1 varchar, feed_id varchar, feed_version varchar, filename varchar, loaded_date timestamp, " +
                    "snapshot_of varchar)");
            PreparedStatement insertStatement = connection.prepareStatement(
                    "insert into feeds values (?, ?, ?, ?, ?, ?, current_timestamp, null)");
            insertStatement.setString(1, tablePrefix);
            insertStatement.setString(2, null); // md5Hex
            insertStatement.setString(3, null); // shaHex
            // FIXME: will this throw an NPE if feedId or feedVersion are empty?
            insertStatement.setString(4, feedId.isEmpty() ? null : feedId);
            insertStatement.setString(5, feedVersion.isEmpty() ? null : feedVersion);
            insertStatement.setString(6, "mapdb_gtfs_feed"); // filename
            insertStatement.execute();
            connection.commit();
            LOG.info("Created new feed namespace: {}", insertStatement);
        } catch (Exception ex) {
            try {
                connection.rollback();
            } catch (SQLException e) {
                e.printStackTrace();
            }
            LOG.error("Exception while registering new feed namespace in feeds table: {}", ex.getMessage());
            DbUtils.closeQuietly(connection);
        }
    }
private void registerFeed () {

        // FIXME is this extra CSV reader used anymore? Check comment below.
        // First, inspect feed_info.txt to extract the ID and version.
        // We could get this with SQL after loading, but feed_info, feed_id and feed_version are all optional.
        FeedInfo feedInfo = gtfsFeed.feedInfo.isEmpty() ? null : gtfsFeed.feedInfo.values().iterator().next();
        String feedId = "", feedVersion = "";
        if (feedInfo != null) {
            feedId = feedInfo.feed_id;
            feedVersion = feedInfo.feed_version;
        }

        try {
            Statement statement = connection.createStatement();
            // FIXME do the following only on databases that support schemas.
            // SQLite does not support them. Is there any advantage of schemas over flat tables?
            statement.execute("create schema " + tablePrefix);
            // current_timestamp seems to be the only standard way to get the current time across all common databases.
            // Record total load processing time?
            statement.execute("create table if not exists feeds (namespace varchar primary key, md5 varchar, " +
                    "sha1 varchar, feed_id varchar, feed_version varchar, filename varchar, loaded_date timestamp, " +
                    "snapshot_of varchar)");
            PreparedStatement insertStatement = connection.prepareStatement(
                    "insert into feeds values (?, ?, ?, ?, ?, ?, current_timestamp, null)");
            insertStatement.setString(1, tablePrefix);
            insertStatement.setString(2, null); // md5Hex
            insertStatement.setString(3, null); // shaHex
            // FIXME: will this throw an NPE if feedId or feedVersion are empty?
            insertStatement.setString(4, feedId.isEmpty() ? null : feedId);
            insertStatement.setString(5, feedVersion.isEmpty() ? null : feedVersion);
            insertStatement.setString(6, "mapdb_gtfs_feed"); // filename
            insertStatement.execute();
            connection.commit();
            LOG.info("Created new feed namespace: {}", insertStatement);
        } catch (Exception ex) {
            try {
                connection.rollback();
            } catch (SQLException e) {
                e.printStackTrace();
            }
            LOG.error("Exception while registering new feed namespace in feeds table: {}", ex.getMessage());
            DbUtils.closeQuietly(connection);
        }
    }
private void registerFeed ( ) { // FIXME is this extra CSV reader used anymore? Check comment below. // First, inspect feed_info.txt to extract the ID and version. // We could get this with SQL after loading, but feed_info, feed_id and feed_version are all optional. FeedInfo feedInfo = gtfsFeed . feedInfo . isEmpty ( ) ? null : gtfsFeed . feedInfo . values ( ) . iterator ( ) . next ( ) ; String feedId = "" , feedVersion = "" ; if ( feedInfo != null ) { feedId = feedInfo . feed_id ; feedVersion = feedInfo . feed_version ; } try { Statement statement = connection . createStatement ( ) ; // FIXME do the following only on databases that support schemas. // SQLite does not support them. Is there any advantage of schemas over flat tables? statement . execute ( "create schema " + tablePrefix ) ; // current_timestamp seems to be the only standard way to get the current time across all common databases. // Record total load processing time? statement . execute ( "create table if not exists feeds (namespace varchar primary key, md5 varchar, " + "sha1 varchar, feed_id varchar, feed_version varchar, filename varchar, loaded_date timestamp, " + "snapshot_of varchar)" ) ; PreparedStatement insertStatement = connection . prepareStatement ( "insert into feeds values (?, ?, ?, ?, ?, ?, current_timestamp, null)" ) ; insertStatement . setString ( 1 , tablePrefix ) ; insertStatement . setString ( 2 , null ) ; // md5Hex insertStatement . setString ( 3 , null ) ; // shaHex // FIXME: will this throw an NPE if feedId or feedVersion are empty? insertStatement . setString ( 4 , feedId . isEmpty ( ) ? null : feedId ) ; insertStatement . setString ( 5 , feedVersion . isEmpty ( ) ? null : feedVersion ) ; insertStatement . setString ( 6 , "mapdb_gtfs_feed" ) ; // filename insertStatement . execute ( ) ; connection . commit ( ) ; LOG . info ( "Created new feed namespace: {}" , insertStatement ) ; } catch ( Exception ex ) { try { connection . rollback ( ) ; } catch ( SQLException e ) { e . printStackTrace ( ) ; } LOG . error ( "Exception while registering new feed namespace in feeds table: {}" , ex . getMessage ( ) ) ; DbUtils . closeQuietly ( connection ) ; } }
Add a line to the list of loaded feeds showing that this feed has been loaded.
We used to inspect feed_info here so we could make our table prefix based on feed ID and version.
Now we just load feed_info like any other table.
// Create a row in the table of loaded feeds for this feed
Really this is not just making the table prefix - it's loading the feed_info and should also calculate hashes.

Originally we were flattening all feed_info files into one root-level table, but that forces us to drop any
custom fields in feed_info.
Add a line to the list of loaded feeds showing that this feed has been loaded . We used to inspect feed_info here so we could make our table prefix based on feed ID and version . Now we just load feed_info like any other table . // Create a row in the table of loaded feeds for this feed Really this is not just making the table prefix - it s loading the feed_info and should also calculate hashes .