diff --git a/qgepqwat2ili/__init__.py b/qgepqwat2ili/__init__.py index 4e533d76..7c953257 100644 --- a/qgepqwat2ili/__init__.py +++ b/qgepqwat2ili/__init__.py @@ -198,23 +198,28 @@ def main(args): SCHEMA = config.ABWASSER_SCHEMA ILI_MODEL = config.ABWASSER_ILI_MODEL ILI_MODEL_NAME = config.ABWASSER_ILI_MODEL_NAME - ILI_EXPORT_MODEL_NAME = None + ILI_EXPORT_MODEL_NAME = config.ABWASSER_ILI_MODEL_NAME if args.direction == "export": + basket_enabled = True + if args.export_sia405 or args.export_dss: + basket_enabled = False + utils.ili2db.create_ili_schema( SCHEMA, ILI_MODEL, make_log_path(log_path, "ilicreate"), recreate_schema=args.recreate_schema, - create_basket_col=False, + create_basket_col=basket_enabled, ) - # add model dependency + if args.export_sia405: # SIA405_ABWASSER_2015_LV95 qgep_export_sia405( selection=args.selection.split(",") if args.selection else None, labels_file=args.labels_file, orientation=args.labels_orientation, + basket_enabled=basket_enabled, ) elif args.export_dss: # DSS_2015_LV95 expor5t @@ -222,6 +227,7 @@ def main(args): selection=args.selection.split(",") if args.selection else None, labels_file=args.labels_file, orientation=args.labels_orientation, + basket_enabled=basket_enabled, ) else: # VSA_KEK_2019_LV95 export @@ -229,6 +235,7 @@ def main(args): selection=args.selection.split(",") if args.selection else None, labels_file=args.labels_file, orientation=args.labels_orientation, + basket_enabled=basket_enabled, ) utils.ili2db.export_xtf_data( @@ -281,7 +288,7 @@ def main(args): ILI_MODEL, make_log_path(log_path, "ilicreate"), recreate_schema=args.recreate_schema, - create_basket_col=False, + create_basket_col=True, ) utils.ili2db.import_xtf_data( SCHEMA, args.path, make_log_path(log_path, "iliimport") @@ -317,7 +324,7 @@ def main(args): ABWASSER_DSS_ILI_MODEL, make_log_path(log_path, "ilicreate"), recreate_schema=args.recreate_schema, - create_basket_col=True, + create_basket_col=False, ) utils.ili2db.import_xtf_data( ABWASSER_DSS_SCHEMA, args.path, make_log_path(log_path, "iliimport") diff --git a/qgepqwat2ili/config.py b/qgepqwat2ili/config.py index 86a3dc84..4bf58c8f 100644 --- a/qgepqwat2ili/config.py +++ b/qgepqwat2ili/config.py @@ -51,6 +51,6 @@ WASSER_ILI_MODEL_NAME = "SIA405_WASSER_2015_LV95" TOPIC_NAME_SIA405_ADMINISTRATION = "SIA405_Base_Abwasser_LV95.Administration" -TOPIC_NAME_SIA405_ABWASSER = "SIA405_ABWASSER_2015.SIA405_Abwasser" +TOPIC_NAME_SIA405_ABWASSER = "SIA405_ABWASSER_2015_LV95.SIA405_Abwasser" TOPIC_NAME_DSS = "DSS_2015.Siedlungsentwaesserung" TOPIC_NAME_KEK = "VSA_KEK_2019_LV95.KEK" diff --git a/qgepqwat2ili/gui/__init__.py b/qgepqwat2ili/gui/__init__.py index 6cc9b206..79ba58f4 100644 --- a/qgepqwat2ili/gui/__init__.py +++ b/qgepqwat2ili/gui/__init__.py @@ -178,6 +178,7 @@ def action_import(plugin): config.ABWASSER_ILI_MODEL, log_path, recreate_schema=True, + create_basket_col=True, ) elif imodel == "SIA405_ABWASSER_2015_LV95": create_ili_schema( @@ -185,6 +186,7 @@ def action_import(plugin): config.ABWASSER_SIA405_ILI_MODEL, log_path, recreate_schema=True, + create_basket_col=False, ) elif imodel == "DSS_2015_LV95": create_ili_schema( @@ -192,6 +194,7 @@ def action_import(plugin): config.ABWASSER_DSS_ILI_MODEL, log_path, recreate_schema=True, + create_basket_col=False, ) else: # print(imodel) @@ -549,7 +552,7 @@ def action_do_export(): config.ABWASSER_ILI_MODEL, log_path, recreate_schema=True, - create_basket_col=False, + create_basket_col=True, ) elif emodel == "SIA405_ABWASSER_2015_LV95": create_ili_schema( @@ -663,6 +666,7 @@ def action_do_export(): selection=export_dialog.selected_ids, labels_file=labels_file_path, orientation=eorientation, + basket_enabled=True, ) # 22.3.2023 / 28.3.2023 adjusted to qgepsia405_export elif emodel == "SIA405_ABWASSER_2015_LV95": @@ -673,6 +677,7 @@ def action_do_export(): selection=export_dialog.selected_ids, labels_file=labels_file_path, orientation=eorientation, + basket_enabled=False, ) elif emodel == "DSS_2015_LV95": logger.info("Start Exporting DSS_2015_LV95 - qgepdss_export") @@ -682,6 +687,7 @@ def action_do_export(): selection=export_dialog.selected_ids, labels_file=labels_file_path, orientation=eorientation, + basket_enabled=False, ) else: progress_dialog.close() @@ -700,7 +706,7 @@ def action_do_export(): # 12.7.2022 to do dependant on Model Selection if emodel == "VSA_KEK_2019_LV95": for model_name, export_model_name, progress in [ - (config.ABWASSER_ILI_MODEL_NAME, None, 50), + (config.ABWASSER_ILI_MODEL_NAME, config.ABWASSER_ILI_MODEL_NAME, 50), (config.ABWASSER_ILI_MODEL_NAME_SIA405, config.ABWASSER_ILI_MODEL_NAME_SIA405, 70), ]: diff --git a/qgepqwat2ili/qgep/export.py b/qgepqwat2ili/qgep/export.py index 07087053..70e775e5 100644 --- a/qgepqwat2ili/qgep/export.py +++ b/qgepqwat2ili/qgep/export.py @@ -255,6 +255,10 @@ def qgep_export_kek(selection=None, labels_file=None, orientation=None, basket_e logger.info("Exporting QGEP.benching -> ABWASSER.bankett, ABWASSER.metaattribute") qgep_export_utils.export_benching() + # From here on its about KEK -> change current basket + current_basket = basket_utils.basket_topic_kek + qgep_export_utils.current_basket = current_basket + logger.info("Exporting QGEP.examination -> ABWASSER.untersuchung, ABWASSER.metaattribute") query = qgep_session.query(qgep_model.examination) if filtered: @@ -425,6 +429,9 @@ def qgep_export_kek(selection=None, labels_file=None, orientation=None, basket_e schadenlageanfang=row.damage_begin, schadenlageende=row.damage_end, ) + + print(f"Kanalschaden: {kanalschaden.t_basket}") + abwasser_session.add(kanalschaden) qgep_export_utils.create_metaattributes(row) print(".", end="") @@ -514,6 +521,9 @@ def qgep_export_kek(selection=None, labels_file=None, orientation=None, basket_e logger.info("done") abwasser_session.flush() + current_basket = basket_utils.basket_topic_sia405_abwasser + qgep_export_utils.current_basket = current_basket + # Labels # Note: these are extracted from the optional labels file (not exported from the QGEP database) if labels_file: diff --git a/qgepqwat2ili/tests/test_qgep.py b/qgepqwat2ili/tests/test_qgep.py index 9fa7805a..10a515f2 100644 --- a/qgepqwat2ili/tests/test_qgep.py +++ b/qgepqwat2ili/tests/test_qgep.py @@ -182,6 +182,11 @@ def test_case_e_export_selection(self): # Perform various checks logger.warning("Perform various checks VSA_KEK_2019_LV95 ...") + logger.warning("Exported file content:") + with open(path) as exported_file: + for line in exported_file: + logger.warning(line) + root = ET.parse(path) self.assertEqual( @@ -222,7 +227,8 @@ def test_case_f_export_selection_sia405(self): # Prepare db main(["setupdb", "full"]) - path = os.path.join(tempfile.mkdtemp(), "export_VSA_KEK_2019_LV95.xtf") + path = os.path.join(tempfile.mkdtemp(), "export_selection_SIA405.xtf") + selection = [ # reach_id "ch13p7mzRE001221", diff --git a/qgepqwat2ili/utils/ili2db.py b/qgepqwat2ili/utils/ili2db.py index cbb146c7..1be7ba68 100644 --- a/qgepqwat2ili/utils/ili2db.py +++ b/qgepqwat2ili/utils/ili2db.py @@ -21,6 +21,7 @@ def check_organisation_subclass_data(): cursor = connection.cursor() cursor.execute("SELECT obj_id FROM qgep_od.organisation;") + if cursor.rowcount > 0: organisation_count = cursor.rowcount logger.info(f"Number of organisation datasets: {organisation_count}") diff --git a/qgepqwat2ili/utils/qgep_export_utils.py b/qgepqwat2ili/utils/qgep_export_utils.py index 5c0eec9a..8b4f919e 100644 --- a/qgepqwat2ili/utils/qgep_export_utils.py +++ b/qgepqwat2ili/utils/qgep_export_utils.py @@ -149,7 +149,7 @@ def create_metaattributes(self, row): ) if self.current_basket is not None: - metaattribute["t_basket"] = self.current_basket.t_id + metaattribute.t_basket = self.current_basket.t_id self.abwasser_session.add(metaattribute)