Search in sources :

Example 1 with ParserException

use of com.google.security.zynamics.binnavi.Database.NodeParser.ParserException in project binnavi by google.

the class PostgreSQLCodeNodeLoader method load.

/**
 * Loads the code nodes of a view.
 *
 * @param provider The connection to the database.
 * @param view The view whose code nodes are loaded.
 * @param nodes The loaded nodes are stored here.
 * @param modules All modules of the database.
 *
 * @throws SQLException Thrown of loading the nodes failed.
 * @throws CPartialLoadException Thrown if loading the nodes failed because a necessary module was
 *         not loaded.
 */
public static void load(final AbstractSQLProvider provider, final INaviView view, final List<INaviViewNode> nodes, final List<? extends INaviModule> modules) throws SQLException, CPartialLoadException {
    Preconditions.checkNotNull(provider, "Error: provider argument can not be null");
    Preconditions.checkNotNull(view, "Error: view argument can not be null");
    Preconditions.checkNotNull(nodes, "Error: nodes argument can not be null");
    Preconditions.checkNotNull(modules, "Error: modules argument can not be null");
    final String query = " SELECT * FROM load_code_nodes(?) ";
    final PreparedStatement statement = provider.getConnection().getConnection().prepareStatement(query, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
    statement.setInt(1, view.getConfiguration().getId());
    final ResultSet resultSet = statement.executeQuery();
    try {
        final CCodeNodeParser parser = new CCodeNodeParser(new SqlCodeNodeProvider(resultSet), modules, provider);
        nodes.addAll(parser.parse());
    } catch (final ParserException e) {
        CUtilityFunctions.logException(e);
    } finally {
        resultSet.close();
    }
}
Also used : ParserException(com.google.security.zynamics.binnavi.Database.NodeParser.ParserException) SqlCodeNodeProvider(com.google.security.zynamics.binnavi.Database.NodeParser.SqlCodeNodeProvider) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) CCodeNodeParser(com.google.security.zynamics.binnavi.Database.NodeParser.CCodeNodeParser)

Aggregations

CCodeNodeParser (com.google.security.zynamics.binnavi.Database.NodeParser.CCodeNodeParser)1 ParserException (com.google.security.zynamics.binnavi.Database.NodeParser.ParserException)1 SqlCodeNodeProvider (com.google.security.zynamics.binnavi.Database.NodeParser.SqlCodeNodeProvider)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1