Commit cafae66d authored by Manuel's avatar Manuel

traceRetrieval: duplicate nodes are not entered into the db again

parent 3acc11bc
......@@ -27,13 +27,15 @@ class Repository(MongoRepositoryBase):
reference = self.get_transaction_with_id(transaction.id())
if reference == None:
super().insert_entry(self._transaction_collection, transaction.to_serializable_dict())
else:
raise ValueError(f"ID {transaction['UniqueID']} already exists")
def all_transactions_for_use_case(self, use_case: str) -> List[Transaction]:
result = super().get_entries(self._transaction_collection, projection={'_id': False}, selection={"use_case": use_case})
return [Transaction.from_serializable_dict(row) for row in list(result)]
def get_transaction_with_id(self, unique_id: str) -> Transaction:
result = list(super().get_entries(self._transaction_collection, projection={'_id': False}, selection={"id": unique_id}))
result = list(super().get_entries(self._transaction_collection, projection={'_id': False}, selection={"UniqueID": unique_id}))
if len(result) == 1:
return Transaction.from_serializable_dict(result[0])
......
......@@ -167,7 +167,10 @@ class MessageHandler:
flattened = self._flatten_transaction(transaction_message, mappings)
transaction = Transaction(use_case, flattened)
try:
self._mongo_repo.add_transaction(transaction)
except ValueError as e:
LOGGER.error(f"{e}, ignoring node")
msg = {
"type": "new-trace",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment