From de90e831b4b2f8f52d2fa44cb000f4ac56169299 Mon Sep 17 00:00:00 2001
From: thomaswoehlke <thomas.woehlke@gmail.com>
Date: Mon, 8 Feb 2021 11:48:49 +0100
Subject: [PATCH] ### 0.0.14 Release * Fixed #69 Branch: ISSUE_66_ATTEMPT_01 *
 Fixed #70 load package.json from Bootstrap-Template sb-admin-angular into
 statics * Fixed #67 implement Flask-Login (wontfix) * Issue #159 merge Branch
 ISSUE_66_ATTEMPT_01 to master

---
 BACKLOG.md                                    |  8 ++++----
 docs/Domain_Model.md                          |  2 +-
 docs/uml_gaphor/covid19python_url.gaphor      |  2 +-
 .../blueprints/rki/rki_service_import.py      | 12 +++++------
 .../vaccination/vaccination_model.py          |  5 +++++
 .../vaccination/vaccination_model_import.py   | 10 ++++++++++
 .../vaccination/vaccination_service.py        |  4 ++--
 .../vaccination/vaccination_service_config.py |  2 +-
 .../vaccination_service_download.py           |  4 ++--
 .../vaccination/vaccination_service_import.py |  4 ++--
 .../vaccination/vaccination_service_update.py |  4 ++--
 .../blueprints/who/who_model_import.py        |  6 +++---
 .../blueprints/who/who_service_config.py      |  2 +-
 .../blueprints/who/who_service_download.py    |  4 ++--
 .../blueprints/who/who_service_import.py      | 10 +++++-----
 .../blueprints/who/who_service_update.py      | 20 +++++++++----------
 src/covid19/blueprints/who/who_views.py       |  4 ++--
 17 files changed, 59 insertions(+), 44 deletions(-)

diff --git a/BACKLOG.md b/BACKLOG.md
index 1f490f92..9a7414e5 100644
--- a/BACKLOG.md
+++ b/BACKLOG.md
@@ -108,7 +108,7 @@
 * Issue #39 SQLalchemy instead of SQL: AllModelClasses.remove_all()
 * Issue #40 SQLalchemy instead of SQL: EuropeImport.get_date_rep()
 * Issue #41 SQLalchemy instead of SQL: EuropeImport.get_countries_of_continent()
-* Issue #42 SQLalchemy instead of SQL: WhoGlobalDataImportTable.get_new_dates_as_array()
+* Issue #42 SQLalchemy instead of SQL: WhoImport.get_new_dates_as_array()
 * Issue #71 add python modules to requirements.txt for User Login, Authentication and Autorisation
 * Issue #72 add python modules to requirements.txt for Ajax and other JS Features
 * Issue #73 add python modules to requirements.txt for further research and development
@@ -118,10 +118,10 @@
 * Issue #77 add Tasks to RKI Tasks Html 
 * Issue #78 add PlantUML
 * Issue #79 add Gaphor UML
-* Issue #80 rename WhoGlobalDataImportTable to WhoImport
+* Issue #80 rename WhoImport to WhoImport
 * Issue #81 change tablename from who_global_data_import to who_import
 * Issue #82 BUG: change to ORM ClassHierarchy
-* Issue #83 SQLalchemy instead of SQL in WhoGlobalDataImportTable.get_new_dates_as_array
+* Issue #83 SQLalchemy instead of SQL in WhoImport.get_new_dates_as_array
 * Issue #84 rename tablename from who_global_data to who_data
 * Issue #85 rename WhoData to WhoData
 * Fixed #86 rename VaccinationData to Vaccination
@@ -177,7 +177,7 @@
 * Issue #137 implement RkiBundeslaenderService.run_update_star_schema_incremental
 * Issue #138 implement RkiBundeslaenderService.run_update_star_schema_initial
 * Issue #139 refactor RkiBundeslaenderServiceDownload to new method scheme introduced 07.02.2021
-* Issue #140 move WhoGlobalDataImportTable to RKI in: rk_service_import.py
+* Issue #140 move WhoImport to RKI in: rk_service_import.py
 * Issue #141 implement RkiBundeslaenderServiceUpdate.update_dimension_tables_only
 * Issue #142 implement RkiBundeslaenderServiceUpdate.update_fact_table_incremental_only
 * Issue #143 implement RkiBundeslaenderServiceUpdate.update_fact_table_initial_only
diff --git a/docs/Domain_Model.md b/docs/Domain_Model.md
index e581ad46..e9adf864 100644
--- a/docs/Domain_Model.md
+++ b/docs/Domain_Model.md
@@ -97,7 +97,7 @@ CREATE TABLE public.who_global_data_import (
 );
 ````
 ````python
-class WhoGlobalDataImportTable(db.Model):
+class WhoImport(db.Model):
     __tablename__ = 'who_global_data_import'
 
     id = db.Column(db.Integer, primary_key=True)
diff --git a/docs/uml_gaphor/covid19python_url.gaphor b/docs/uml_gaphor/covid19python_url.gaphor
index 28be6302..640c5d1a 100644
--- a/docs/uml_gaphor/covid19python_url.gaphor
+++ b/docs/uml_gaphor/covid19python_url.gaphor
@@ -336,7 +336,7 @@
 </Class>
 <Class id="c6bfca9c-67bd-11eb-9897-e5e5c434bbb8">
 <name>
-<val>WhoGlobalDataImportTable</val>
+<val>WhoImport</val>
 </name>
 <package>
 <ref refid="05e1daa8-67be-11eb-9897-e5e5c434bbb8"/>
diff --git a/src/covid19/blueprints/rki/rki_service_import.py b/src/covid19/blueprints/rki/rki_service_import.py
index e53e008c..15bf4afb 100644
--- a/src/covid19/blueprints/rki/rki_service_import.py
+++ b/src/covid19/blueprints/rki/rki_service_import.py
@@ -5,8 +5,8 @@ import psycopg2
 
 from database import db, app
 
-# TODO: #140 move WhoGlobalDataImportTable to RKI in: rk_service_import.py
-from covid19.blueprints.who.who_model_import import WhoGlobalDataImportTable
+# TODO: #140 move WhoImport to RKI in: rk_service_import.py
+from covid19.blueprints.who.who_model_import import WhoImport
 
 
 # TODO: #123 split RkiService into two Services: RkiBundeslaenderService and RkiLandkreiseService
@@ -37,14 +37,14 @@ class RkiBundeslaenderServiceImport:
         else:
             keyDate_reported = 'Date_reported'
         try:
-            # TODO: #140 move WhoGlobalDataImportTable to RKI in: rk_service_import.py
-            WhoGlobalDataImportTable.remove_all()
+            # TODO: #140 move WhoImport to RKI in: rk_service_import.py
+            WhoImport.remove_all()
             with open(self.__src_who_cvsfile_name, newline='\n') as csv_file:
                 file_reader = csv.DictReader(csv_file, delimiter=',', quotechar='"')
                 k = 0
                 for row in file_reader:
-                    # TODO: #140 move WhoGlobalDataImportTable to RKI in: rk_service_import.py
-                    o = WhoGlobalDataImportTable(
+                    # TODO: #140 move WhoImport to RKI in: rk_service_import.py
+                    o = WhoImport(
                         date_reported=row[keyDate_reported],
                         country_code=row['Country_code'],
                         country=row['Country'],
diff --git a/src/covid19/blueprints/vaccination/vaccination_model.py b/src/covid19/blueprints/vaccination/vaccination_model.py
index 0e9e2e6e..26401c83 100644
--- a/src/covid19/blueprints/vaccination/vaccination_model.py
+++ b/src/covid19/blueprints/vaccination/vaccination_model.py
@@ -94,3 +94,8 @@ class VaccinationData(db.Model):
         return db.session.query(cls) \
             .filter(cls.datum == other_datum) \
             .one_or_none()
+
+    @classmethod
+    def create_new_object_factory(cls, my_date_rep):
+        # TODO implement VaccinationData.create_new_object_factory
+        pass
diff --git a/src/covid19/blueprints/vaccination/vaccination_model_import.py b/src/covid19/blueprints/vaccination/vaccination_model_import.py
index ed4f794f..1db2e8b7 100644
--- a/src/covid19/blueprints/vaccination/vaccination_model_import.py
+++ b/src/covid19/blueprints/vaccination/vaccination_model_import.py
@@ -66,3 +66,13 @@ class VaccinationImport(db.Model):
             .filter(cls.datum == other_datum) \
             .one_or_none()
 
+    @classmethod
+    def find_by_date_reported(cls, europe_date_reported):
+        # TODO implement VaccinationImport.find_by_date_reported
+        pass
+
+    @classmethod
+    def get_date_rep(cls):
+        # TODO implement VaccinationImport.get_date_rep
+        pass
+
diff --git a/src/covid19/blueprints/vaccination/vaccination_service.py b/src/covid19/blueprints/vaccination/vaccination_service.py
index a9862e81..04db95b7 100644
--- a/src/covid19/blueprints/vaccination/vaccination_service.py
+++ b/src/covid19/blueprints/vaccination/vaccination_service.py
@@ -3,7 +3,7 @@ from flask import flash
 from database import app
 from covid19.blueprints.vaccination.vaccination_service_download import VaccinationServiceDownload
 from covid19.blueprints.vaccination.vaccination_service_import import VaccinationServiceImport
-from covid19.blueprints.vaccination.vaccination_service_config import VaccinationServiceDownloadConfig
+from covid19.blueprints.vaccination.vaccination_service_config import VaccinationServiceConfig
 
 
 # TODO: #90 refactor VaccinationService to new method scheme introduced 07.02.2021
@@ -13,7 +13,7 @@ class VaccinationService:
         app.logger.debug(" Vaccination Service [init]")
         app.logger.debug("------------------------------------------------------------")
         self.__database = database
-        self.cfg = VaccinationServiceDownloadConfig()
+        self.cfg = VaccinationServiceConfig()
         self.vaccination_service_download = VaccinationServiceDownload(database)
         self.vaccination_service_import = VaccinationServiceImport(database)
         app.logger.debug("------------------------------------------------------------")
diff --git a/src/covid19/blueprints/vaccination/vaccination_service_config.py b/src/covid19/blueprints/vaccination/vaccination_service_config.py
index 3a3ddf96..86f321b4 100644
--- a/src/covid19/blueprints/vaccination/vaccination_service_config.py
+++ b/src/covid19/blueprints/vaccination/vaccination_service_config.py
@@ -1,7 +1,7 @@
 import os
 
 
-class VaccinationServiceDownloadConfig:
+class VaccinationServiceConfig:
     def __init__(self):
         self.limit_nr = 20
         self.data_path = ".."+os.sep+".."+os.sep+"data"
diff --git a/src/covid19/blueprints/vaccination/vaccination_service_download.py b/src/covid19/blueprints/vaccination/vaccination_service_download.py
index 0b8a891c..56aef73a 100644
--- a/src/covid19/blueprints/vaccination/vaccination_service_download.py
+++ b/src/covid19/blueprints/vaccination/vaccination_service_download.py
@@ -2,7 +2,7 @@ import os
 import wget
 from flask import flash
 from database import app
-from covid19.blueprints.vaccination.vaccination_service_config import VaccinationServiceDownloadConfig
+from covid19.blueprints.vaccination.vaccination_service_config import VaccinationServiceConfig
 
 
 # TODO: #98 refactor VaccinationServiceDownload to new method scheme introduced 07.02.2021
@@ -12,7 +12,7 @@ class VaccinationServiceDownload:
         app.logger.debug(" Vaccination Service Download [init]")
         app.logger.debug("------------------------------------------------------------")
         self.__database = database
-        self.cfg = VaccinationServiceDownloadConfig()
+        self.cfg = VaccinationServiceConfig()
         app.logger.debug("------------------------------------------------------------")
         app.logger.debug(" Vaccination Service Download [ready]")
 
diff --git a/src/covid19/blueprints/vaccination/vaccination_service_import.py b/src/covid19/blueprints/vaccination/vaccination_service_import.py
index d220be7a..e246b061 100644
--- a/src/covid19/blueprints/vaccination/vaccination_service_import.py
+++ b/src/covid19/blueprints/vaccination/vaccination_service_import.py
@@ -4,7 +4,7 @@ import psycopg2
 
 from database import db, app
 from covid19.blueprints.vaccination.vaccination_model_import import VaccinationImport
-from covid19.blueprints.vaccination.vaccination_service_config import VaccinationServiceDownloadConfig
+from covid19.blueprints.vaccination.vaccination_service_config import VaccinationServiceConfig
 
 
 # TODO: #99 refactor VaccinationServiceImport to new method scheme introduced 07.02.2021
@@ -14,7 +14,7 @@ class VaccinationServiceImport:
         app.logger.debug(" Vaccination Service Import [init]")
         app.logger.debug("------------------------------------------------------------")
         self.__database = database
-        self.cfg = VaccinationServiceDownloadConfig()
+        self.cfg = VaccinationServiceConfig()
         app.logger.debug("------------------------------------------------------------")
         app.logger.debug(" Vaccination Service Import [ready]")
 
diff --git a/src/covid19/blueprints/vaccination/vaccination_service_update.py b/src/covid19/blueprints/vaccination/vaccination_service_update.py
index 7007a2dc..7e87e9af 100644
--- a/src/covid19/blueprints/vaccination/vaccination_service_update.py
+++ b/src/covid19/blueprints/vaccination/vaccination_service_update.py
@@ -1,6 +1,6 @@
 from database import db, app
 
-from covid19.blueprints.vaccination.vaccination_service_config import VaccinationServiceDownloadConfig
+from covid19.blueprints.vaccination.vaccination_service_config import VaccinationServiceConfig
 from covid19.blueprints.vaccination.vaccination_model_import import VaccinationImport
 from covid19.blueprints.vaccination.vaccination_model import VaccinationDateReported, VaccinationData
 
@@ -12,7 +12,7 @@ class VaccinationsServiceUpdate:
         app.logger.debug(" Europe Service Update [init]")
         app.logger.debug("------------------------------------------------------------")
         self.__database = database
-        self.cfg = VaccinationServiceDownloadConfig()
+        self.cfg = VaccinationServiceConfig()
         app.logger.debug("------------------------------------------------------------")
         app.logger.debug(" Europe Service Update [ready] ")
 
diff --git a/src/covid19/blueprints/who/who_model_import.py b/src/covid19/blueprints/who/who_model_import.py
index 546a740e..6f35997d 100644
--- a/src/covid19/blueprints/who/who_model_import.py
+++ b/src/covid19/blueprints/who/who_model_import.py
@@ -1,9 +1,9 @@
 from database import db, ITEMS_PER_PAGE
 
 
-# TODO: #80 rename WhoGlobalDataImportTable to WhoImport
+# TODO: #80 rename WhoImport to WhoImport
 # TODO: #81 change tablename from who_global_data_import to who_import
-class WhoGlobalDataImportTable(db.Model):
+class WhoImport(db.Model):
     __tablename__ = 'who_import'
 
     id = db.Column(db.Integer, primary_key=True)
@@ -65,7 +65,7 @@ class WhoGlobalDataImportTable(db.Model):
     @classmethod
     def get_new_dates_as_array(cls):
         # TODO: #82 BUG: change to ORM ClassHierarchy
-        # TODO: #83 SQLalchemy instead of SQL in WhoGlobalDataImportTable.get_new_dates_as_array
+        # TODO: #83 SQLalchemy instead of SQL in WhoImport.get_new_dates_as_array
         sql_query = """
             select
                 date_reported
diff --git a/src/covid19/blueprints/who/who_service_config.py b/src/covid19/blueprints/who/who_service_config.py
index fab8361d..e3dc633f 100644
--- a/src/covid19/blueprints/who/who_service_config.py
+++ b/src/covid19/blueprints/who/who_service_config.py
@@ -1,7 +1,7 @@
 import os
 
 
-class WhoServiceDownloadConfig:
+class WhoServiceConfig:
     def __init__(self):
         self.limit_nr = 20
         self.data_path = ".."+os.sep+".."+os.sep+"data"
diff --git a/src/covid19/blueprints/who/who_service_download.py b/src/covid19/blueprints/who/who_service_download.py
index 25dcff0a..88156284 100644
--- a/src/covid19/blueprints/who/who_service_download.py
+++ b/src/covid19/blueprints/who/who_service_download.py
@@ -2,7 +2,7 @@ import os
 import wget
 from flask import flash
 from database import app
-from covid19.blueprints.who.who_service_config import WhoServiceDownloadConfig
+from covid19.blueprints.who.who_service_config import WhoServiceConfig
 
 
 class WhoServiceDownload:
@@ -11,7 +11,7 @@ class WhoServiceDownload:
         app.logger.debug(" WHO Service Download [init]")
         app.logger.debug("------------------------------------------------------------")
         self.__database = database
-        self.cfg = WhoServiceDownloadConfig()
+        self.cfg = WhoServiceConfig()
         app.logger.debug("------------------------------------------------------------")
         app.logger.debug(" WHO Service Download [ready]")
 
diff --git a/src/covid19/blueprints/who/who_service_import.py b/src/covid19/blueprints/who/who_service_import.py
index ed80e710..dfb27441 100644
--- a/src/covid19/blueprints/who/who_service_import.py
+++ b/src/covid19/blueprints/who/who_service_import.py
@@ -3,8 +3,8 @@ import sys
 import csv
 import psycopg2
 from database import db, app
-from covid19.blueprints.who.who_model_import import WhoGlobalDataImportTable
-from covid19.blueprints.who.who_service_download import WhoServiceDownloadConfig
+from covid19.blueprints.who.who_model_import import WhoImport
+from covid19.blueprints.who.who_service_download import WhoServiceConfig
 
 
 class WhoServiceImport:
@@ -13,7 +13,7 @@ class WhoServiceImport:
         app.logger.debug(" WHO Service Import [init]")
         app.logger.debug("------------------------------------------------------------")
         self.__database = database
-        self.cfg = WhoServiceDownloadConfig()
+        self.cfg = WhoServiceConfig()
         app.logger.debug("------------------------------------------------------------")
         app.logger.debug(" WHO Service Import [ready]")
 
@@ -30,12 +30,12 @@ class WhoServiceImport:
         else:
             keyDate_reported = 'Date_reported'
         try:
-            WhoGlobalDataImportTable.remove_all()
+            WhoImport.remove_all()
             with open(src_cvsfile_name, newline='\n') as csv_file:
                 file_reader = csv.DictReader(csv_file, delimiter=',', quotechar='"')
                 k = 0
                 for row in file_reader:
-                    o = WhoGlobalDataImportTable(
+                    o = WhoImport(
                         date_reported=row[keyDate_reported],
                         country_code=row['Country_code'],
                         country=row['Country'],
diff --git a/src/covid19/blueprints/who/who_service_update.py b/src/covid19/blueprints/who/who_service_update.py
index 49fe6023..6c3f3ac2 100644
--- a/src/covid19/blueprints/who/who_service_update.py
+++ b/src/covid19/blueprints/who/who_service_update.py
@@ -1,7 +1,7 @@
 from database import db, app
 from covid19.blueprints.who.who_model import WhoRegion, WhoDateReported, WhoCountry, WhoData
-from covid19.blueprints.who.who_model_import import WhoGlobalDataImportTable
-from covid19.blueprints.who.who_service_download import WhoServiceDownloadConfig
+from covid19.blueprints.who.who_model_import import WhoImport
+from covid19.blueprints.who.who_service_download import WhoServiceConfig
 
 
 class WhoServiceUpdate:
@@ -10,7 +10,7 @@ class WhoServiceUpdate:
         app.logger.debug(" WHO Service Update [init]")
         app.logger.debug("------------------------------------------------------------")
         self.__database = database
-        self.cfg = WhoServiceDownloadConfig()
+        self.cfg = WhoServiceConfig()
         app.logger.debug("------------------------------------------------------------")
         app.logger.debug(" WHO Service Update [ready]")
 
@@ -18,7 +18,7 @@ class WhoServiceUpdate:
         app.logger.info(" __update_who_date_reported [begin]")
         app.logger.info("------------------------------------------------------------")
         i = 0
-        for i_date_reported, in WhoGlobalDataImportTable.get_dates_reported():
+        for i_date_reported, in WhoImport.get_dates_reported():
             i += 1
             output = " [ " + str(i) + " ] " + i_date_reported
             c = WhoDateReported.find_by_date_reported(i_date_reported)
@@ -38,7 +38,7 @@ class WhoServiceUpdate:
         app.logger.info(" __update_who_region [begin]")
         app.logger.info("------------------------------------------------------------")
         i = 0
-        for i_who_region, in WhoGlobalDataImportTable.get_regions():
+        for i_who_region, in WhoImport.get_regions():
             i += 1
             output = " [ " + str(i) + " ] " + i_who_region
             c = WhoRegion.find_by_region(i_who_region)
@@ -57,7 +57,7 @@ class WhoServiceUpdate:
     def __update_who_country(self):
         app.logger.info(" __update_who_country [begin]")
         app.logger.info("------------------------------------------------------------")
-        result = WhoGlobalDataImportTable.countries()
+        result = WhoImport.countries()
         i = 0
         for result_item in result:
             i += 1
@@ -90,7 +90,7 @@ class WhoServiceUpdate:
     def __update_fact_table_incremental(self):
         app.logger.info(" __update_fact_tables_incremental [begin]")
         app.logger.info("------------------------------------------------------------")
-        new_dates_reported_from_import = WhoGlobalDataImportTable.get_new_dates_as_array()
+        new_dates_reported_from_import = WhoImport.get_new_dates_as_array()
         i = 0
         for my_date_reported in new_dates_reported_from_import:
             my_date = WhoDateReported.find_by_date_reported(my_date_reported)
@@ -100,7 +100,7 @@ class WhoServiceUpdate:
                 db.session.commit()
             my_date = WhoDateReported.get_by_date_reported(my_date_reported)
             k = 0
-            for result_item in WhoGlobalDataImportTable.get_for_one_day(my_date_reported):
+            for result_item in WhoImport.get_for_one_day(my_date_reported):
                 if result_item.country_code == "":
                     my_country = WhoCountry.get_by_country(result_item.country)
                 else:
@@ -129,7 +129,7 @@ class WhoServiceUpdate:
         app.logger.info(" __update_fact_table_initial [begin]")
         app.logger.info("------------------------------------------------------------")
         WhoData.remove_all()
-        new_dates_reported_from_import = WhoGlobalDataImportTable.get_new_dates_as_array()
+        new_dates_reported_from_import = WhoImport.get_new_dates_as_array()
         i = 0
         for my_date_reported in new_dates_reported_from_import:
             my_date = WhoDateReported.find_by_date_reported(my_date_reported)
@@ -137,7 +137,7 @@ class WhoServiceUpdate:
                 myday = WhoDateReported.create_new_object_factory(my_date_reported)
                 db.session.add(myday)
                 my_date = myday
-            for result_item in WhoGlobalDataImportTable.get_for_one_day(my_date_reported):
+            for result_item in WhoImport.get_for_one_day(my_date_reported):
                 my_country = WhoCountry.find_by_country_code(result_item.country_code)
                 o = WhoData(
                     cases_new=int(result_item.new_cases),
diff --git a/src/covid19/blueprints/who/who_views.py b/src/covid19/blueprints/who/who_views.py
index 9513fd11..465ffc95 100644
--- a/src/covid19/blueprints/who/who_views.py
+++ b/src/covid19/blueprints/who/who_views.py
@@ -7,7 +7,7 @@ from database import app
 from covid19.services import who_service
 from covid19.workers import celery
 
-from covid19.blueprints.who.who_model_import import WhoGlobalDataImportTable
+from covid19.blueprints.who.who_model_import import WhoImport
 from covid19.blueprints.who.who_model import WhoRegion, WhoCountry, WhoDateReported, WhoData
 from covid19.blueprints.common.common_model_transient import ApplicationPage
 
@@ -207,7 +207,7 @@ def url_who_tasks():
 def url_who_imported(page=1):
     page_info = ApplicationPage('WHO', "Last Import")
     try:
-        page_data = WhoGlobalDataImportTable.get_all_as_page(page)
+        page_data = WhoImport.get_all_as_page(page)
     except OperationalError:
         flash("No data in the database.")
         page_data = None
-- 
GitLab