use of com.google.security.zynamics.binnavi.disassembly.views.CView in project binnavi by google.
the class PostgreSQLModuleFlowgraphsLoader method loadModuleFlowgraphs.
/**
* Loads the flow graphs of a module.
*
* @param provider The connection to the database.
* @param module The module whose flow graph views are loaded.
* @param viewTagManager The tag manager responsible for tagging the views.
* @param nodeTagManager The tag manager responsible for tagging view nodes.
* @param viewType The type of the views to load.
*
* @return The loaded views.
*
* @throws CouldntLoadDataException Thrown if the views could not be loaded.
*/
private static ImmutableList<IFlowgraphView> loadModuleFlowgraphs(final AbstractSQLProvider provider, final CModule module, final CTagManager viewTagManager, final CTagManager nodeTagManager, final ViewType viewType) throws CouldntLoadDataException {
checkArguments(provider, module, viewTagManager);
final String query = " SELECT * FROM load_module_flow_graphs(?, ?) ";
final CConnection connection = provider.getConnection();
try {
final PreparedStatement statement = connection.getConnection().prepareStatement(query);
statement.setInt(1, module.getConfiguration().getId());
statement.setObject(2, viewType == ViewType.Native ? "native" : "non-native", Types.OTHER);
final ResultSet resultSet = statement.executeQuery();
final Map<Integer, Set<CTag>> tags = loadTags(connection, module, viewTagManager);
return new ImmutableList.Builder<IFlowgraphView>().addAll(processQueryResults(resultSet, module, tags, nodeTagManager, provider, new ArrayList<CView>(), viewType, GraphType.FLOWGRAPH)).build();
} catch (final SQLException exception) {
throw new CouldntLoadDataException(exception);
}
}
use of com.google.security.zynamics.binnavi.disassembly.views.CView in project binnavi by google.
the class CProjectContent method createView.
/**
* Creates a new empty view with the given name and description in the project. The new view is
* not stored in the database until INaviView::save is called.
*
* @param name The name of the new view.
* @param description The description of the new view.
*
* @return The new view that was created in the project.
*/
public INaviView createView(final String name, final String description) {
final Date date = new Date();
final CProjectViewGenerator generator = new CProjectViewGenerator(m_provider, m_project);
final CView view = generator.generate(-1, name, description, ViewType.NonNative, GraphType.MIXED_GRAPH, date, date, 0, 0, new HashSet<CTag>(), new HashSet<CTag>(), false);
try {
view.load();
} catch (CouldntLoadDataException | CPartialLoadException | LoadCancelledException e) {
// This can not happen; new views with ID -1 do not access the database
// when they are loaded.
CUtilityFunctions.logException(e);
}
addView(view);
return view;
}
use of com.google.security.zynamics.binnavi.disassembly.views.CView in project binnavi by google.
the class CProjectContent method createView.
/**
* Creates a new view with the given name and description in the project by copying an existing
* view. The new view is not stored in the database until INaviView::save is called.
*
* @param view The view that is copied.
* @param name The name of the new view.
* @param description The description of the new view.
*
* @return The new view that was created in the project.
*/
public INaviView createView(final INaviView view, final String name, final String description) {
Preconditions.checkNotNull(view, "IE02228: view argument can not be null");
Preconditions.checkArgument(view.inSameDatabase(m_provider), "IE02229: View and project Content are not in the same database");
Preconditions.checkNotNull(name, "IE02230: name argument can not be null");
Preconditions.checkNotNull(description, "IE02231: description argument can not be null");
final CView newView = CView.createUnsavedProjectView(m_project, view, name, description, m_provider);
addView(newView);
return newView;
}
use of com.google.security.zynamics.binnavi.disassembly.views.CView in project binnavi by google.
the class CViewContainer method createView.
/**
* Creates a new empty view in the module.
*
* @param name The name of the new view.
* @param description The description of the new view.
*
* @return The new view.
*/
public CView createView(final String name, final String description) {
Preconditions.checkNotNull(name, "IE00164: Name argument can not be null");
Preconditions.checkNotNull(description, "IE00165: Name description can not be null");
final Date date = new Date();
final CModuleViewGenerator generator = new CModuleViewGenerator(m_provider, m_module);
final CView view = generator.generate(-1, name, description, ViewType.NonNative, GraphType.MIXED_GRAPH, date, date, 0, 0, new HashSet<CTag>(), new HashSet<CTag>(), false);
try {
view.load();
} catch (CouldntLoadDataException | CPartialLoadException | LoadCancelledException e) {
CUtilityFunctions.logException(e);
}
addView(view);
return view;
}
use of com.google.security.zynamics.binnavi.disassembly.views.CView in project binnavi by google.
the class PostgreSQLProviderTest method testCViewFunctionsUntagView2.
@Test(expected = NullPointerException.class)
public void testCViewFunctionsUntagView2() throws CouldntSaveDataException, CouldntLoadDataException {
final INaviModule module = getProvider().loadModules().get(0);
final CView view = (CView) module.getContent().getViewContainer().getViews().get(224);
getProvider().removeTag(view, null);
}
Aggregations