Search in sources :

Example 1 with ViewType

use of com.google.security.zynamics.zylib.disassembly.ViewType in project binnavi by google.

the class PostgreSQLProjectFlowgraphsLoader method loadFlowGraphInformation.

public static ImmutableNaviViewConfiguration loadFlowGraphInformation(final SQLProvider provider, final INaviProject project, final Integer viewId) throws CouldntLoadDataException {
    Preconditions.checkNotNull(provider, "IE02618: provider argument can not be null");
    Preconditions.checkNotNull(project, "IE02619: project argument can not be null");
    Preconditions.checkNotNull(viewId, "IE02620: viewId argument can not be null");
    final CConnection connection = provider.getConnection();
    final String query = " SELECT * FROM load_project_flowGraph(?,?) ";
    try {
        final PreparedStatement statement = connection.getConnection().prepareStatement(query);
        statement.setInt(1, project.getConfiguration().getId());
        statement.setInt(2, viewId);
        final ResultSet resultSet = statement.executeQuery();
        while (resultSet.next()) {
            final int databaseViewId = resultSet.getInt("view_id");
            final String name = PostgreSQLHelpers.readString(resultSet, "name");
            final String description = PostgreSQLHelpers.readString(resultSet, "description");
            final ViewType viewType = resultSet.getString("type").equalsIgnoreCase("native") ? ViewType.Native : ViewType.NonNative;
            final Timestamp creationDate = resultSet.getTimestamp("creation_date");
            final Timestamp modificationDate = resultSet.getTimestamp("modification_date");
            final boolean isStared = resultSet.getBoolean("stared");
            final int nodeCount = resultSet.getInt("bbcount");
            final int edgeCount = resultSet.getInt("edgecount");
            final ImmutableNaviViewConfiguration viewConfiguration = new ImmutableNaviViewConfiguration(databaseViewId, name, description, viewType, creationDate, modificationDate, isStared, nodeCount, edgeCount);
            return viewConfiguration;
        }
        return null;
    } catch (final SQLException exception) {
        throw new CouldntLoadDataException(exception);
    }
}
Also used : CConnection(com.google.security.zynamics.binnavi.Database.CConnection) ImmutableNaviViewConfiguration(com.google.security.zynamics.binnavi.disassembly.views.ImmutableNaviViewConfiguration) SQLException(java.sql.SQLException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) Timestamp(java.sql.Timestamp) ViewType(com.google.security.zynamics.zylib.disassembly.ViewType)

Example 2 with ViewType

use of com.google.security.zynamics.zylib.disassembly.ViewType in project binnavi by google.

the class PostgreSQLModuleFlowgraphsLoader method loadFlowGraphInformation.

public static ImmutableNaviViewConfiguration loadFlowGraphInformation(final SQLProvider provider, final INaviModule module, final Integer viewId) throws CouldntLoadDataException {
    Preconditions.checkNotNull(provider, "IE02275: provider argument can not be null");
    Preconditions.checkNotNull(module, "IE02394: module argument can not be null");
    Preconditions.checkNotNull(viewId, "IE02419: viewId argument can not be null");
    final CConnection connection = provider.getConnection();
    final String query = " SELECT * FROM load_module_flowgraph_information(?,?) ";
    try {
        final PreparedStatement statement = connection.getConnection().prepareStatement(query);
        statement.setInt(1, module.getConfiguration().getId());
        statement.setInt(2, viewId);
        final ResultSet resultSet = statement.executeQuery();
        while (resultSet.next()) {
            final int databaseViewId = resultSet.getInt("view_id");
            final String name = PostgreSQLHelpers.readString(resultSet, "name");
            final String description = PostgreSQLHelpers.readString(resultSet, "description");
            final ViewType viewType = resultSet.getString("type").equalsIgnoreCase("native") ? ViewType.Native : ViewType.NonNative;
            final Timestamp creationDate = resultSet.getTimestamp("creation_date");
            final Timestamp modificationDate = resultSet.getTimestamp("modification_date");
            final boolean isStared = resultSet.getBoolean("stared");
            final int nodeCount = resultSet.getInt("bbcount");
            final int edgeCount = resultSet.getInt("edgecount");
            final ImmutableNaviViewConfiguration viewConfiguration = new ImmutableNaviViewConfiguration(databaseViewId, name, description, viewType, creationDate, modificationDate, isStared, nodeCount, edgeCount);
            return viewConfiguration;
        }
        return null;
    } catch (final SQLException exception) {
        throw new CouldntLoadDataException(exception);
    }
}
Also used : CConnection(com.google.security.zynamics.binnavi.Database.CConnection) ImmutableNaviViewConfiguration(com.google.security.zynamics.binnavi.disassembly.views.ImmutableNaviViewConfiguration) SQLException(java.sql.SQLException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) Timestamp(java.sql.Timestamp) ViewType(com.google.security.zynamics.zylib.disassembly.ViewType)

Aggregations

CConnection (com.google.security.zynamics.binnavi.Database.CConnection)2 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)2 ImmutableNaviViewConfiguration (com.google.security.zynamics.binnavi.disassembly.views.ImmutableNaviViewConfiguration)2 ViewType (com.google.security.zynamics.zylib.disassembly.ViewType)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 Timestamp (java.sql.Timestamp)2