def getNotificationFromNodeByIndex (self, nodeId, index, queue = "control"): indexInt = int(index) nodeIdStr = str(nodeId) logger.info("From node(" + nodeIdStr + ") getting notification at index[" + str(index) + "]") notifications = self.notifications.find({"nodeId": str(nodeId), "queue": queue}) notificationdict = notifications.get(indexInt) return fromDict(**notificationdict)
def getLatestNotificationFromNode (self, nodeId, queue = "control"): # Need to reverse sort on time notifications = self.notifications.find({"nodeId": str(nodeId), "queue": queue}) for notification in notifications: if (notification["ignore"] == False): print str(notification) return fromDict(**notification) return None
def getEarliestNotificationOfCurrentState (self, nodeId, queue = "control"): nodeIdStr = str(nodeId) logger.info("From node(" + nodeIdStr + ") getting earliest notification of current state") topnotification = self.notifications.findOne({"nodeId": str(nodeId), "queue": queue}) # make sure this gets the first one. notifications = self.notifications.find({"nodeId": str(nodeId), "queue": queue}) for n in notifications: if n.value == topnotification.value: topnotification = n return fromDict(**topnotification)
def getNotificationFromNodeById (self, nodeId, notificationId, queue = "control"): nodeIdStr = str(nodeId) logger.info("From node(" + nodeIdStr + ") getting notification with nid[" + str(notificationId) + "]") notifications = self.notifications.find({"nodeId": str(nodeId), "queue": queue, "nid": notificationId}) notificationdict = notifications.get(0) #There should be exactly one return fromDict(**notificationdict)