use of com.google.security.zynamics.binnavi.disassembly.views.ImmutableNaviViewConfiguration 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);
}
}
use of com.google.security.zynamics.binnavi.disassembly.views.ImmutableNaviViewConfiguration in project binnavi by google.
the class PostgreSQLViewNotificationParser method informProjectNotification.
/**
* The inform function for notifications from the bn_project_views table. This function is used
* when a project view is created or deleted.
*
* @param projectNotificationContainer The {@link ViewNotificationContainer} to use as data
* source.
* @param provider The {@link SQLProvider} to access the database.
* @throws CouldntLoadDataException if the information could not be loaded from the database.
*/
private void informProjectNotification(final ViewNotificationContainer projectNotificationContainer, final SQLProvider provider) throws CouldntLoadDataException {
if (projectNotificationContainer.getDatabaseOperation().equals("INSERT")) {
final INaviProject project = projectNotificationContainer.getNotificationProject().get();
if (!project.isLoaded()) {
return;
}
final Integer viewId = projectNotificationContainer.getViewId();
final ImmutableNaviViewConfiguration databaseViewConfiguration = provider.loadFlowGraphInformation(project, viewId);
final CProjectViewGenerator generator = new CProjectViewGenerator(provider, project);
final INaviView view = generator.generate(databaseViewConfiguration);
project.getContent().addView(view);
}
if (projectNotificationContainer.getDatabaseOperation().equals("UPDATE")) {
// updates will not happen as this is only a mapping of id to id.
return;
}
if (projectNotificationContainer.getDatabaseOperation().equals("DELETE")) {
final INaviProject project = projectNotificationContainer.getNotificationProject().get();
if (!project.isLoaded()) {
return;
}
final Integer viewId = projectNotificationContainer.getViewId();
final INaviView view = ViewManager.get(provider).getView(viewId);
project.getContent().deleteViewInternal(view);
}
}
use of com.google.security.zynamics.binnavi.disassembly.views.ImmutableNaviViewConfiguration in project binnavi by google.
the class PostgreSQLViewNotificationParser method informModuleNotification.
/**
* The inform function for notifications from the bn_module_views table. This function is used
* when a module view is created or deleted.
*
* @param moduleViewNotificationContainer The {@link ViewNotificationContainer} to use as data
* source.
* @param provider The {@link SQLProvider} to access the database.
* @throws CouldntLoadDataException if the information could not be loaded from the database.
*/
private void informModuleNotification(final ViewNotificationContainer moduleViewNotificationContainer, final SQLProvider provider) throws CouldntLoadDataException {
if (moduleViewNotificationContainer.getDatabaseOperation().equals("INSERT")) {
final INaviModule module = moduleViewNotificationContainer.getNotificationModule().get();
if (!module.isLoaded()) {
return;
}
final Integer viewId = moduleViewNotificationContainer.getViewId();
final ImmutableNaviViewConfiguration databaseViewConfiguration = provider.loadFlowGraphInformation(module, viewId);
final CModuleViewGenerator generator = new CModuleViewGenerator(provider, module);
final INaviView view = generator.generate(databaseViewConfiguration, GraphType.FLOWGRAPH);
module.getContent().getViewContainer().addView(view);
}
if (moduleViewNotificationContainer.getDatabaseOperation().equals("UPDATE")) {
// updates will not happen as this is only a mapping of id to id.
return;
}
if (moduleViewNotificationContainer.getDatabaseOperation().equals("DELETE")) {
final INaviModule module = moduleViewNotificationContainer.getNotificationModule().get();
if (!module.isLoaded()) {
return;
}
final Integer viewId = moduleViewNotificationContainer.getViewId();
final INaviView view = ViewManager.get(provider).getView(viewId);
module.getContent().getViewContainer().deleteViewInternal(view);
}
}
use of com.google.security.zynamics.binnavi.disassembly.views.ImmutableNaviViewConfiguration in project binnavi by google.
the class PostgreSQLViewNotificationParser method informViewNotification.
/**
* The inform function for notifications from the bn_views table. This function is used when a
* view gets edited. But this function will not perform any action when a view is deleted or
* created.
*
* @param viewNotificationContainer The {@link ViewNotificationContainer} to use as data source.
* @param provider The {@link SQLProvider} to access the database with.
* @throws CouldntLoadDataException if the information could not be loaded from the database.
*/
private void informViewNotification(final ViewNotificationContainer viewNotificationContainer, final SQLProvider provider) throws CouldntLoadDataException {
if (viewNotificationContainer.getDatabaseOperation().equals("INSERT")) {
// we ignore inserts as we need to know if this was a module or project view.
return;
}
if (viewNotificationContainer.getDatabaseOperation().equals("UPDATE")) {
final Integer viewId = viewNotificationContainer.getViewId();
final INaviView view = viewNotificationContainer.getView().get();
final ImmutableNaviViewConfiguration databaseViewConfiguration = view.getConfiguration().getModule() == null ? provider.loadFlowGraphInformation(view.getConfiguration().getProject(), viewId) : provider.loadFlowGraphInformation(view.getConfiguration().getModule(), viewId);
if (databaseViewConfiguration == null) {
return;
}
if (!databaseViewConfiguration.getName().equals(view.getConfiguration().getName())) {
view.getConfiguration().setNameInternal(databaseViewConfiguration.getName());
}
if (databaseViewConfiguration.getDescription() != view.getConfiguration().getDescription() && !databaseViewConfiguration.getDescription().equals(view.getConfiguration().getDescription())) {
view.getConfiguration().setDescriptionInternal(databaseViewConfiguration.getDescription());
}
if (databaseViewConfiguration.getStarState() != view.getConfiguration().isStared()) {
view.getConfiguration().setStaredInternal(databaseViewConfiguration.getStarState());
}
view.getConfiguration().setModificationDateInternal(databaseViewConfiguration.getModificationDate());
}
if (viewNotificationContainer.getDatabaseOperation().equals("DELETE")) {
// we ignore deletes as we need to know if this was a module or project view.
return;
}
}
use of com.google.security.zynamics.binnavi.disassembly.views.ImmutableNaviViewConfiguration 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);
}
}
Aggregations