def storeFinding(self, findingDoc, analystDoc): try: item_id = self.__addNewFinding(findingDoc) self.__logAction( LogEntry("Added new finding: " + findingDoc["description"], analystDoc["initial"]).toDocument()) return item_id except pymongo.errors.DuplicateKeyError: self.__updateFinding(findingDoc) self.__logAction( LogEntry("Updated finding: " + findingDoc["description"], analystDoc["initial"]).toDocument()) return findingDoc["_id"]
def storeSubtask(self, subtaskDoc, analystDoc): try: item_id = self.__addNewSubtask(subtaskDoc) self.__logAction( LogEntry("Added new subtask: " + subtaskDoc["title"], analystDoc["initial"]).toDocument()) return item_id except pymongo.errors.DuplicateKeyError: self.__updateSubtask(subtaskDoc) self.__logAction( LogEntry("Updated subtask: " + subtaskDoc["title"], analystDoc["initial"]).toDocument()) return subtaskDoc["_id"]
def storeEvent(self, eventDoc, analystDoc): try: event_id = self.__addNewEvent(eventDoc) self.__logAction( LogEntry("Added new event: " + eventDoc["name"], analystDoc["initial"]).toDocument()) return event_id except pymongo.errors.DuplicateKeyError: self.__updateEvent(eventDoc) self.__logAction( LogEntry("Updated event: " + eventDoc["name"], analystDoc["initial"]).toDocument()) return
def storeSystem(self, systemDoc, analystDoc): try: item_id = self.__addNewSystem(systemDoc) self.__logAction( LogEntry("Added new system: " + systemDoc["name"], analystDoc["initial"]).toDocument()) return item_id except pymongo.errors.DuplicateKeyError: self.__updateSystem(systemDoc) self.__logAction( LogEntry("Updated system: " + systemDoc["name"], analystDoc["initial"]).toDocument()) return systemDoc["_id"]
def removeFinding(self, findingDoc, analystDoc): query = {"_id": findingDoc["_id"]} self.__findingCollection.delete_one(query) self.__logAction( LogEntry("Deleted finding: " + findingDoc["name"], analystDoc["initial"]).toDocument()) return
def removeSubtask(self, subtaskDoc, analystDoc): query = {"_id": subtaskDoc["_id"]} self.__subtaskCollection.delete_one(query) self.__logAction( LogEntry("Deleted subtask: " + subtaskDoc["title"], analystDoc["initial"]).toDocument()) return
def removeSystem(self, systemDoc, analystDoc): query = {"_id": systemDoc["_id"]} self.__systemCollection.delete_one(query) self.__logAction( LogEntry("Deleted system: " + systemDoc["name"], analystDoc["initial"]).toDocument()) return
def removeEvent(self, eventDoc, analystDoc): query = {"_id": eventDoc["_id"]} self.__eventCollection.delete_one(query) self.__logAction( LogEntry("Deleted event: " + eventDoc["name"], analystDoc["initial"]).toDocument()) return