use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.CodeNodeCommentNotificationContainer in project binnavi by google.
the class PostgreSQLCommentNotificationParser method processNodeLocalNodeCommentNotification.
/**
* Parses the {@link PGNotification} notifications from the PostgreSQL database back end for local
* code node comments by using a regular expression. If the regular expression matches the
* supplied {@link PGNotification} notification, it is determined if the code node in the
* notification is currently loaded, and if a {@link CommentNotificationContainer} with the
* gathered data from the notification is returned.
*
* @param notification The {@link PGNotification} from the PostgreSQL database server.
* @param provider The {@link SQLProvider} which is used to communicate with the database.
*/
static CommentNotification processNodeLocalNodeCommentNotification(final PGNotification notification, final SQLProvider provider) {
final Matcher matcher = NODE_LOCAL_PATTERN.matcher(notification.getParameter());
if (!matcher.find()) {
return null;
}
final Integer moduleId = Integer.parseInt(matcher.group(3));
final Integer nodeId = Integer.parseInt(matcher.group(4));
final Integer commentId = matcher.group(6).equals("null") ? null : Integer.parseInt(matcher.group(6));
final INaviModule module = provider.findModule(moduleId);
if (!module.isLoaded()) {
return null;
}
final INaviCodeNode codeNode = (INaviCodeNode) NodeCache.get(provider).getNodeById(nodeId);
if (codeNode == null) {
return null;
}
final CommentOperation operation = commentId == null ? CommentOperation.DELETE : CommentOperation.APPEND;
return new CodeNodeCommentNotificationContainer(codeNode, operation, CommentScope.LOCAL, commentId);
}
use of com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.CodeNodeCommentNotificationContainer in project binnavi by google.
the class PostgreSQLCommentNotificationParser method processNodeGlobalCommentNotification.
/**
* Parses the notifications from the database back end for global code node comments by using a
* regular expression. If the regular expression matches the supplied {@link PGNotification}
* notification, it is determined if the code node in the notification is currently loaded, and if
* a {@link CommentNotificationContainer} with the data from the notification is returned.
*
* @param notification The {@link PGNotification} from the PostgreSQL database server.
* @param provider The {@link SQLProvider} which is used to communicate with the database.
*/
static Collection<CommentNotification> processNodeGlobalCommentNotification(final PGNotification notification, final SQLProvider provider) {
final Matcher matcher = NODE_GLOBAL_PATTERN.matcher(notification.getParameter());
if (!matcher.find()) {
return new ArrayList<>();
}
final String databaseOperation = matcher.group(2);
final int moduleId = Integer.parseInt(matcher.group(3));
final IAddress nodeAddress = new CAddress(new BigInteger(matcher.group(4)));
final Integer commentId = matcher.group(6) == null ? null : Integer.parseInt(matcher.group(6));
final INaviModule notificationModule = provider.findModule(moduleId);
if ((notificationModule == null) || !notificationModule.isLoaded()) {
return new ArrayList<>();
}
final ImmutableCollection<INaviViewNode> nodes = NodeCache.get(provider).getNodeByAddress(nodeAddress, moduleId);
if (nodes == null) {
return new ArrayList<>();
}
final CommentOperation operation = databaseOperation.equalsIgnoreCase("DELETE") ? CommentOperation.DELETE : CommentOperation.APPEND;
Collection<CommentNotification> notifications = new ArrayList<>();
for (INaviViewNode node : nodes) {
notifications.add(new CodeNodeCommentNotificationContainer((INaviCodeNode) node, operation, CommentScope.GLOBAL, commentId));
}
return notifications;
}
Aggregations