Commit c793e6df authored by Bogdan's avatar Bogdan

Added Duplicated Traces Functionality

parent 383b7388
......@@ -18,6 +18,7 @@ class Repository(MongoRepositoryBase):
self._transaction_collection = 'transactions'
self._failed_transaction_collection = 'transactions_failed'
self._duplicated_transactioN_collection = "transactions_duplicated"
def delete_all_transactions(self):
collection = self._database[self._transaction_collection]
......@@ -58,3 +59,15 @@ class Repository(MongoRepositoryBase):
def delete_all_failed_transactions(self, use_case:str):
collection = self._database[self._failed_transaction_collection]
collection.delete_many({"ApplicationType": use_case})
def add_duplicated_transaction(self, transaction: Transaction):
#transaction["timestamp"] = time.time()
super().insert_entry(self._duplicated_transactioN_collection, transaction.to_serializable_dict())
def all_duplicated_transactions_for_use_case(self, use_case: str) -> List[Dict]:
result = super().get_entries(self._duplicated_transaction_collection, projection={'_id': False}, selection={"use_case": use_case})
return [Transaction.from_serializable_dict(row) for row in list(result)]
def delete_all_duplicated_transactions(self, use_case:str):
collection = self._database[self._duplicated_transactioN_collection]
collection.delete_many({"ApplicationType": use_case})
\ No newline at end of file
......@@ -174,6 +174,16 @@ class MessageHandler:
return
transaction = Transaction(use_case, target_table["name"], flattened)
#check for duplicates
try:
reference = self._mongo_repo.get_transaction_with_id(transaction.id())
if reference != None:
self._mongo_repo.add_duplicated_transaction(transaction)
return #TODO should return? or continue the message to semantic linking?
except ValueError as e:
LOGGER.error(f"{e}, could not insert duplicated node.")
try:
self._mongo_repo.add_transaction(transaction)
except ValueError as e:
......
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