Skip to content
Snippets Groups Projects
Commit 36a8dd3a authored by martiivGylden's avatar martiivGylden
Browse files

Backend done for now, dashboard next

parent 9bad703c
No related branches found
No related tags found
No related merge requests found
......@@ -15,7 +15,7 @@ def openFile():
filetypes=(("CSV Diagram file", "*.csv"),)
)
diagram = parse.parseDiagramFile(fileName)
print(diagram.metrics)
print(diagram.threats)
guiRoot = Tk()
......
......@@ -19,12 +19,13 @@ def parseDiagramFile(csvFile) -> component.Diagram:
dynamics = diagram.dynamics
metrics = diagram.metrics
metricsMatrix = matrix.parseTable(df) #Parse the table
threats = parseThreats(df, threats)
consequences = parseConsequences(df, consequences)
metrics, dynamics = parseDynamic(df, metrics, dynamics)
metricsMatrix = matrix.parseTable(df, metrics) #Parse the table
return diagram
def parseThreats(df, threatDict):
......
This diff is collapsed.
......@@ -7,7 +7,7 @@ Parses csv table and returns a dataframe
This is quite finicky as lucidchart has a very weird way of structuring tables as it is based on when different cells were created
This is quite a big EDGE case and will only work for the specific table shape that I have created
"""
def parseTable(df):
def parseTable(df, metricsDict):
cols = [const.Er_ID, const.Bowtie_ID, const.Metric_ID, const.Metric_Name, const.Value, const.Measure_date, const.Frequency ,const.Measurement_guide]
......@@ -28,7 +28,11 @@ def parseTable(df):
Guide1 = table[const.textArea19].item() # Define the Measurement guide
matrics.loc[0] = erID1, BowTieID1, MetricID1, MetricName1, Value1, MeasureDate1, Frequency1, Guide1
matrics.loc[0] = erID1, BowTieID1, MetricID1, MetricName1, Value1, MeasureDate1, Frequency1, Guide1 # Fill inn dataframe
# TODO Error handle/Communicate to end user here, "You seem to have a metric in your table which is not used etc"
metricsdict = fillMetricinfo(erID1, BowTieID1, MetricID1, MetricName1, Value1, MeasureDate1, Frequency1, Guide1, metricsDict)
# Parsing the second row, this row is also specialized
erID2 = table[const.textArea7].item() # Define the ER ID
......@@ -42,12 +46,19 @@ def parseTable(df):
matrics.loc[1] = erID2, BowTieID2, MetricID2, MetricName2, Value2, MeasureDate2, Frequency2, Guide2
metric = metricsDict[MetricID2] # Access the appropriate metric in the dictionary
# TODO Error handle/Communicate to end user here, "You seem to have a metric in your table which is not used etc"
if metric == None:
handleMissingMetric()
matricsIndex = 2
# Parsing from the third row and onwards is standard format
for i in range(25, len(table.columns), 8):
if pd.isnull(table["Text Area "+str(i)].item()) == True:
if pd.isnull(table["Text Area "+str(i)].item()) == True or pd.isnull(table["Text Area "+str(i+1)].item()) == True:
break
erID = table["Text Area "+str(i)].item() # Define the ER ID
......@@ -64,4 +75,41 @@ def parseTable(df):
matrics.loc[matricsIndex] = erID, BowTieID, MetricID, MetricName, Value, MeasureDate, Frequency, Guide
matricsIndex += 1
return matrics
\ No newline at end of file
return matrics
def handleMissingMetric():
"""Function will communicate to end user that a metric is in the matrics but is not used in the diagram
This will provide clarity to the end user and inform them of unlinked metrics
"""
pass
def fillMetricinfo(erID1: str,
BowTieID1: str,
MetricID1: str,
MetricName1: str,
Value1: str,
MeasureDate1: str,
Frequency1: str,
Guide1: str, metricsDict: dict)-> dict:
"""Function will fill in the metric information in the dataframe into the metric object and return the updated dictionary
"""
metric = metricsDict[MetricID1] # Access the appropriate metric in the dictionary
if metric == None:
print("Metric is not used in the diagram!!!")
return
# Updates the metric with the information found in the dynamics matrix
metric.erID = erID1 # Should be string
metric.bowtieID = BowTieID1 # is list and should be i guess
metric.name = MetricName1 # Should be string
metric.value = Value1 # Should be string
metric.date = MeasureDate1 # TODO Parse this and change it to a date object maybe? Not sure if its necessary...
metric.frequency = Frequency1 # Should be string
metric.guide = Guide1 # Should be string
metricsDict[MetricID1] = metric
return metricsDict
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment