From 9de8fa4313eac747d2a2285c92d2820fc2d18b87 Mon Sep 17 00:00:00 2001
From: martiivGylden <martin.iversen@gyldendal.no>
Date: Thu, 7 Mar 2024 12:48:46 +0100
Subject: [PATCH] Mapped values to constants

---
 ERFormatConstants.py | 56 ++++++++++++++++++++++++++++++++++----------
 diagramParser.py     | 13 +++++++---
 dynamics.py          |  4 ++--
 3 files changed, 55 insertions(+), 18 deletions(-)

diff --git a/ERFormatConstants.py b/ERFormatConstants.py
index 697f7b0..cbbe749 100644
--- a/ERFormatConstants.py
+++ b/ERFormatConstants.py
@@ -1,10 +1,8 @@
 #File contains constants from the CSV export format of the entity relationship tool
 
-#Generic fields for all entities
+#Generic fields for all rows in the CSV file  
 componentID = "Id"              # LucidChart ID 
 Id = "Id"                       # The id of the entity 
-Description = "Description"     # The description of the entity
-
 
 textArea1 = "Text Area 1"
 textArea2 = "Text Area 2"
@@ -23,17 +21,49 @@ textArea14 = "Text Area 14"
 textArea15 = "Text Area 15"
 textArea16 = "Text Area 16"
 
-#Threats 
-Threat = "Threat"               # The threat -> Text area 1
-ThreatSource = "Threat source"  # The threat source -> Text area 4 
-Likelihood = "Likelihood"       # The likelihood of the threat -> Text area 6
-Vulnerability = "Vulnerability" # The vulnerability -> Text area 7
+#Mapped fields for Threat component 
+Threat = textArea1                  # The threat
 
-#Attack
-Type = "Type"                   # The type of the consequence -> Text area 2
-Component = "Component"         # The component related to the attack -> Text area 4
+ThreatID = textArea2            # The id of the threat
+ThreatIDValue = textArea3       # Value
+
+ThreatSource = textArea4        # The threat source
+ThreatSource = textArea5        # Value
+
+Likelihood = textArea6          # The likelihood of the threat
+LikelihoodValue = textArea7     # Value
+
+ThreatDescription = textArea8         # The description of the threat
+ThreatDescriptionValue = textArea9    # Value
+
+Vulnerability = textArea10      # The vulnerability
+VulnerabilityValue = textArea11 # Value
 
 #Consequence
-Consequence = "Consequence"                 # The consequence score of the area -> Text area 6
-AffectedComponents = "Affected components"  # The affected components -> Text area 7
+Consequence = textArea1                 # The consequence score of the area -> Text area 6
+
+ConsequenceID = textArea2                # The id of the consequence
+ConsequenceIDValue = textArea3           # Value
+
+ConsequenceDescription = textArea4                   # The description of the consequence
+ConsequenceDescriptionValue = textArea5              # Value
+
+ConsequenceScore = textArea6             # The consequence score of the area
+ConsequenceScoreValue = textArea7        # Value
+
+AffectedComponent = textArea8            # The affected component
+AffectedComponentValue = textArea9       # Value
+
+#Attack
+Attack = textArea1                       # The attack
+
+AttackType = textArea2                   # The type of attack
+AttackTypeValue = textArea3              # Value
+
+AttackedComponent = textArea4            # The attacked component
+AttackedComponentValue = textArea5       # Value
+
+AttackDescription = textArea6            # The description of the attack
+AttackDescriptionValue = textArea7       # Value
+
 
diff --git a/diagramParser.py b/diagramParser.py
index 3610a72..af00961 100644
--- a/diagramParser.py
+++ b/diagramParser.py
@@ -1,5 +1,7 @@
 import pandas as pd 
 import ERFormatConstants as const
+import components as component
+import dynamics as dynamic
 
 # Function will parse a csv file and extract the necessary information, this is step 1 of the parse 
 def parseDiagramFile(csvFile): 
@@ -24,9 +26,14 @@ def parseDiagramFile(csvFile):
 def parseThreats(df):
     for i in range(len(df)):
         if df[const.textArea1][i] == const.Threat:
-            
-            threats.append(df["Name"][i])
-            print(threats)
+            threat = component.Threat(
+                df[const.Id][i],            # The id of the entity 
+                df[const.componentID][i],   # The component ID field provided by LucidChart
+                df[const.textArea4][i], 
+                df[const.Description][i], 
+                df[const.textArea6][i], 
+                df[const.textArea7][i])    
+        
 
 def parseConsequences(df):
     for i in range(len(df)):
diff --git a/dynamics.py b/dynamics.py
index 3ee1ad9..c176358 100644
--- a/dynamics.py
+++ b/dynamics.py
@@ -4,8 +4,8 @@ from enum import Enum
 #Dynamics class parent class for all dynamic components in the diagram
 class Dynamics:
 
-    def __init__(self, id) -> None:
-        self.id = id
+    def __init__(self, componentID) -> None:
+        self.componentID = componentID
         self.metrics = [Metric] #List of metrics for the dynamic
         
         
-- 
GitLab