From 181107749f570bd66053d2e9faf333ae3c2f1938 Mon Sep 17 00:00:00 2001
From: Maximilian Gruber <maximilian.gruber@ptb.de>
Date: Mon, 27 May 2024 10:54:13 +0200
Subject: [PATCH] change "DCC" to "report" in most places

---
 app/cocal_methods.py                          | 33 +++++++++----------
 app/main.py                                   |  4 +--
 app/{dcc => report}/dcc.xsd                   |  0
 app/{dcc => report}/filter_template.xml       |  0
 .../report_template.xml}                      |  0
 app/testing.py                                |  2 +-
 testing_method/validating_dcc_template.py     |  4 +--
 7 files changed, 21 insertions(+), 22 deletions(-)
 rename app/{dcc => report}/dcc.xsd (100%)
 rename app/{dcc => report}/filter_template.xml (100%)
 rename app/{dcc/dcc_template.xml => report/report_template.xml} (100%)

diff --git a/app/cocal_methods.py b/app/cocal_methods.py
index 9f73b6b..1453fe9 100644
--- a/app/cocal_methods.py
+++ b/app/cocal_methods.py
@@ -45,7 +45,7 @@ class CocalMethods:
         self.audio_config = json.load(open(self.audio_config_path, "r"))
 
         self.dut_path = self.session_dir.joinpath("upload.wav")
-        self.dcc_path = self.session_dir.joinpath("dcc.xml")
+        self.report_path = self.session_dir.joinpath("report.xml")
         self.result_image_path = self.session_dir.joinpath("transfer_behaviour.png")
 
         ##### TESTING
@@ -168,12 +168,11 @@ class CocalMethods:
                 break
         return self.upload_is_ready()
 
-    def generate_dummy_dcc(self):
-        dcc_content = f"<xml>dummy dcc for {self.session.hash}</xml>"
+    def generate_dummy_report(self):
+        report_content = f"<xml>dummy report for {self.session.hash}</xml>"
 
-        filepath = self.session_dir.joinpath("dcc.xml")
-        f = open(filepath, "w")
-        f.write(dcc_content)
+        f = open(self.report_path, "w")
+        f.write(report_content)
         f.close()
 
     def get_current_git_hash(self):
@@ -300,7 +299,7 @@ class CocalMethods:
         }
 
         # load template
-        filter_template_path = os.path.abspath(r"app/dcc/filter_template.xml")
+        filter_template_path = os.path.abspath(r"app/report/filter_template.xml")
         filter_template = open(filter_template_path, "r")
         filter_tree = ET.parse(filter_template)
 
@@ -311,7 +310,7 @@ class CocalMethods:
 
         return filter_tree
 
-    def generate_dcc(self, perform_dcc_validation=False):
+    def generate_report(self, perform_dcc_validation=False):
         if self.transfer_behavior:
             placeholder_dict = {
                 "PLACEHOLDER_GIT_HASH": self.get_current_git_hash(),
@@ -331,33 +330,33 @@ class CocalMethods:
             }
 
             # load template
-            dcc_template_path = os.path.abspath(r"app/dcc/dcc_template.xml")
-            dcc_template = open(dcc_template_path, "r")
-            tree = ET.parse(dcc_template)
+            report_template_path = os.path.abspath(r"app/report/report_template.xml")
+            report_template = open(report_template_path, "r")
+            tree = ET.parse(report_template)
 
             # replace placeholders with substitute from dict
             tree = self.replace_placeholders_with_substitutes(tree, placeholder_dict)
 
-            # write DCC to file
+            # write report to file
             ET.indent(tree)
             tree.write(
-                self.dcc_path,
+                self.report_path,
                 encoding="UTF-8",
                 pretty_print=True,
             )
 
             # validate against schema (requires internet connection)
             if perform_dcc_validation:
-                dcc_schema_path = os.path.abspath(r"app/dcc/dcc.xsd")
+                report_schema_path = os.path.abspath(r"app/report/dcc.xsd")
                 try:
-                    schema = xmlschema.XMLSchema(dcc_schema_path)
-                    result = schema.validate(self.dcc_path)
+                    schema = xmlschema.XMLSchema(report_schema_path)
+                    result = schema.validate(self.report_path)
                     print(result)
                 except Exception as e:
                     print(f"Schema did not validate successfully. (Error: {e})")
 
         else:
-            print("Can't generate DCC. No transfer behavior available.")
+            print("Can't generate report. No transfer behavior available.")
 
     def replace_placeholders_with_substitutes(self, tree, placeholder_dict):
         for placeholder, substitute in placeholder_dict.items():
diff --git a/app/main.py b/app/main.py
index c268b10..3e39717 100644
--- a/app/main.py
+++ b/app/main.py
@@ -73,7 +73,7 @@ def cocal_task(db: Session = Depends(get_db), hash = hash):
         cocal.perform_computations() # perform_dummy_computations
 
         # generate (dummy) DCC
-        cocal.generate_dcc() # generate_dummy_dcc
+        cocal.generate_report() # generate_dummy_report
 
         # generate visualization of transfer behaviour
         cocal.generate_spectral_domain_visualization()
@@ -167,7 +167,7 @@ def download_certificate(hash: str, db: Session = Depends(get_db)):
     session = crud.get_cocal_session_by_hash(db, hash)
 
     if session.result_state == "ready":
-        filepath = Path(".").joinpath("sessions", session.hash, "dcc.xml")
+        filepath = Path(".").joinpath("sessions", session.hash, "report.xml")
         return FileResponse(filepath, filename=filepath.name)
     else:
         return {"message": "Result not ready."}
diff --git a/app/dcc/dcc.xsd b/app/report/dcc.xsd
similarity index 100%
rename from app/dcc/dcc.xsd
rename to app/report/dcc.xsd
diff --git a/app/dcc/filter_template.xml b/app/report/filter_template.xml
similarity index 100%
rename from app/dcc/filter_template.xml
rename to app/report/filter_template.xml
diff --git a/app/dcc/dcc_template.xml b/app/report/report_template.xml
similarity index 100%
rename from app/dcc/dcc_template.xml
rename to app/report/report_template.xml
diff --git a/app/testing.py b/app/testing.py
index 985b25e..1038a07 100644
--- a/app/testing.py
+++ b/app/testing.py
@@ -30,7 +30,7 @@ cocal.dut_path = "sessions/ad554ee7119047559a2250e7e9678ee4/upload_2.wav"
 cocal.load_files()
 cocal.perform_computations()
 
-cocal.generate_dcc()
+cocal.generate_report()
 
 cocal.generate_spectral_domain_visualization()
 
diff --git a/testing_method/validating_dcc_template.py b/testing_method/validating_dcc_template.py
index 82c651b..f8c5d2d 100644
--- a/testing_method/validating_dcc_template.py
+++ b/testing_method/validating_dcc_template.py
@@ -2,10 +2,10 @@ import xmlschema
 import os
 
 
-dcc_file = os.path.abspath(r"testing_method\templates\dcc_template.xml")
+report_file = os.path.abspath(r"testing_method\templates\report_template.xml")
 schema_file = os.path.abspath(r"testing_method\templates\dcc.xsd")
 
 schema = xmlschema.XMLSchema(schema_file)
 
-result = schema.validate(dcc_file)
+result = schema.validate(report_file)
 print(result)
\ No newline at end of file
-- 
GitLab