+ // Load the list of primary keys (sequence numbers) from the database
+ public void loadIds(Connection con, DbDriver driver) throws SQLException, TypeMismatchException
+ {
+ loadCategoryIds(con, driver);
+ loadBugPatternIds(con, driver);
+
+ }
+
+ void loadCategoryIds(Connection con, DbDriver driver) throws SQLException, TypeMismatchException
+ {
+ Column[] columns = { CfbSchema.CATEGORIES.getColumn(CfbSchema.CATEGORYID),
+ CfbSchema.CATEGORIES.getColumn(CfbSchema.CATEGORY) };
+ Table[] tables = { CfbSchema.CATEGORIES };
+ Condition[] conditions = { };
+ List<Row> rows = driver.select(con, columns, tables, conditions);
+
+ for (Row row : rows) {
+ long catId = row.getLong(0);
+ String catName = row.getString(1);
+
+ BugCategory cat = getColl().getCategory(catName);
+ if (null == cat) {
+ throw new SQLException("Database result (" + catId + ", \"" + catName + "\") not found in messages.xml. "
+ + "Perhaps your database and findbugs versions are out of sync?");
+ }
+
+ cat.setId(catId);
+ }
+ }
+
+ void loadBugPatternIds(Connection con, DbDriver driver) throws SQLException, TypeMismatchException
+ {
+ Column[] columns = { CfbSchema.BUGS.getColumn(CfbSchema.BUGID),
+ CfbSchema.BUGS.getColumn(CfbSchema.TYPE) };
+ Table[] tables = { CfbSchema.BUGS };
+ Condition[] conditions = { };
+ List<Row> rows = driver.select(con, columns, tables, conditions);
+
+ for (Row row: rows) {
+ long bugId = row.getLong(0);
+ String type = row.getString(1);
+
+ BugPattern bug = getColl().getPattern(type);
+ if (null == bug) {
+ throw new SQLException("Database result (" + bugId + ", \"" + type + "\") not found in messages.xml. "
+ + "Perhaps your database and findbugs versions are out of sync?");
+ }
+
+ bug.setId(bugId);
+ }
+ }
+
+ // Load the list of bug patterns and categories from the FindBugs messages.xml file.