From 9bad703c4089fbd75fa73460551ca10bae5e62a3 Mon Sep 17 00:00:00 2001
From: martiivGylden <martin.iversen@gyldendal.no>
Date: Mon, 18 Mar 2024 09:30:16 +0100
Subject: [PATCH] Fixed metric parsing, was due to indent....

---
 dashBoard.py                             |  3 ++-
 diagramParser.py                         |  6 ------
 documentation/applicationRequirements.md |  4 ++++
 dynamics.py                              | 21 +++++++++++----------
 4 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/dashBoard.py b/dashBoard.py
index c964401..11c55fc 100644
--- a/dashBoard.py
+++ b/dashBoard.py
@@ -6,6 +6,8 @@ import diagramParser as parse
 
 
 
+# TODO Need to fix some metric parsing issues, only the metric from the bowtie gets added i think
+
 
 def openFile():
     fileName = filedialog.askopenfilename(initialdir= "/",
@@ -15,7 +17,6 @@ def openFile():
     diagram = parse.parseDiagramFile(fileName)    
     print(diagram.metrics)
     
-    
 guiRoot = Tk()
 
 guiRoot.title("Dynamics Analyzer for SSC Risk")
diff --git a/diagramParser.py b/diagramParser.py
index ba1a332..a4d252c 100644
--- a/diagramParser.py
+++ b/diagramParser.py
@@ -80,8 +80,6 @@ def parseDynamic(df, metricDict, dynamicsDict):
                     df[const.Id][i],                                    # Component ID LucidChart
                     df[const.textArea3][i]                              # Name of dynamic
                 )
-                #threatDynamic.metrics = extractMetrics(df, i, 4)        # Extracts metrics from the dynamic component
-                #metricList = joinMetrcs(threatDynamic.metrics, metricList)            # Adds the metrics to the global metric list
                 
                 threatDynamic.associateBowtie(df, threatDynamic.type, metricDict)                  # Associate the dynamic with the correct components
                 dynamicsDict[df.Id[i]] = threatDynamic
@@ -91,8 +89,6 @@ def parseDynamic(df, metricDict, dynamicsDict):
                     df[const.Id][i],                                    # Component ID LucidChart
                     df[const.textArea3][i]                              # Name of dynamic
                 )
-                #consequenceDynamic.metrics = extractMetrics(df, i, 4)   # Extracts metrics from the dynamic component
-                #metricList = joinMetrcs(consequenceDynamic.metrics, metricList)            # Adds the metrics to the global metric list@
                 
                 consequenceDynamic.associateBowtie(df, consequenceDynamic.type, metricDict)    
                 dynamicsDict[df.Id[i]] = consequenceDynamic
@@ -114,8 +110,6 @@ def parseDynamic(df, metricDict, dynamicsDict):
                     df[const.textArea3][i],                                 # Component type
                     df[const.textArea5][i]                                 # Description
                 )
-                #erDynamic.metrics = extractMetrics(df, i, 8)
-                #metricList = joinMetrcs(erDynamic.metrics, metricList)            # Adds the metrics to the global metric list
                 
                 erDynamic.associatER(df, metricDict)
                 dynamicsDict[df.Id[i]] = erDynamic
diff --git a/documentation/applicationRequirements.md b/documentation/applicationRequirements.md
index 91dc7c0..5901798 100644
--- a/documentation/applicationRequirements.md
+++ b/documentation/applicationRequirements.md
@@ -32,6 +32,10 @@ Additionally the document contains success criteria which are formulated from th
 - The application will be able to run on as a standalone application on a local machine
 - The application will only parse the diagrams if the architecture and bowtie diagram have been annotated with the custom library
 
+## Spørsmål til Aida
+
+Hvordan skal jeg definere suksesskriteriene for applikasjonen? Skal jeg definere de først og så tenke på evaluering?
+
 ## Thesis problem description
 
 The thesis aims to innovate in the area of risk modeling through the use of bowtie diagrams by facilitating the identification and documentation of dynamic indicators related to software supply chain risk.
diff --git a/dynamics.py b/dynamics.py
index 81f92e3..5f0d4ea 100644
--- a/dynamics.py
+++ b/dynamics.py
@@ -149,6 +149,7 @@ class BowtieDynamic(DynamicComponent):
             
             metricID = dynamicComponent["Text Area "+str(i)].item()  # Find the metric ID in the component      
             metricName = dynamicComponent["Text Area "+str(i+1)].item()  # Find the metric Name      
+            
             self.metrics.append(metricID) # ? Adds the metric to the metric list associated with the dynamic component specifically
             
             if checkDuplicateMetrics(metricsDict, metricID) == False: # If the metric is in the global list
@@ -169,7 +170,7 @@ class BowtieDynamic(DynamicComponent):
             if checkDuplicate(metric.bowtieID, self.associatedAttack[const.Id].item()): #* If the associated component is a duplicate   
                 continue
             metric.bowtieID.append(self.associatedAttack[const.Id].item())
-                
+            
             metricsDict[metricID] = metric  # ! Adds the metric to the global metric list
             
 class ERDynamic(DynamicComponent):
@@ -213,7 +214,6 @@ class ERDynamic(DynamicComponent):
             
             if line[const.From] == componentId or line[const.To] == componentId:    # If the line is associated with the component 
                 relevantLines.append(lines.iloc[i])   # Add the line to the relevant lines list
-        log.info("Amount of relevant lines found:", len(relevantLines))
         
         for i in range(len(relevantLines)):
             line = relevantLines[i]
@@ -227,7 +227,6 @@ class ERDynamic(DynamicComponent):
             associatedComponent = df.iloc[df.index[df[const.Id] == associatedComponentID]]  # Find the component associated with the line
                 
             self.associatedERComponents.append(associatedComponent)  # Add the associated component to the list of associated components
-            log.info("Associated components found: ", self.associatedERComponents)
         
         self.linkMetric(df, metricsDict) # Link the metrics to the ER dynamic component
 
@@ -248,31 +247,33 @@ class ERDynamic(DynamicComponent):
                 break
             
             metricID = dynamicComponent["Text Area "+str(i)].item()  # Find the metric ID      
-            metricName = dynamicComponent["Text Area "+str(i+1)].item()  # Find the metric ID      
+            metricName = dynamicComponent["Text Area "+str(i+1)].item()  # Find the metric ID    
+                          
             self.metrics.append(metricID) # ? Adds the metric to the metric list associated with the dynamic component specifically
 
             if checkDuplicateMetrics(metricsDict, metricID) == False: # If the metric is not a duplicate
                 metric = Metric(metricID, metricName)  # Create a new metric object
             else: 
                 metric = metricsDict[metricID]
-            
+                        
             for i in range(len(self.associatedERComponents)):
                 erID = self.associatedERComponents[i][const.Id].item()
                                 
                 if checkDuplicate(metric.erID, erID): #* If the associated component is a duplicate
                     continue    
                 metric.erID.append(erID)
-                
-        metricsDict[metricID] = metric  # ! Adds the metric to the global metric list 
-
+            metricsDict[metricID] = metric  # ! Adds the metric to the global metric list 
+            
             
 def checkDuplicateMetrics(metricsDict: dict, metricID: str):
     """_summary_
     Function will check if the diagrams metric dict contains a metric,
     with the same ID as the one which is listed in the dynamics component, if it does 
     """
-    if metricID in metricsDict:
+    
+    if metricID in metricsDict.keys():
         return True
+        
     else:
         return False
     
@@ -280,7 +281,7 @@ def checkDuplicate(list: list, id: str):
     """_summary_
     Check if the already contains the associated component
     """
-    if id in list:
+    if id in list:    
         return True
     else:
         return False
\ No newline at end of file
-- 
GitLab