From a786023e7545280475615bba6979ced95b18e3e4 Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Thu, 22 Dec 2022 07:25:55 +0100 Subject: [PATCH] Empty value egon fix * adds support for missing values so that EGON can properly handle these entries --- intervention/utils/egon_export.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/intervention/utils/egon_export.py b/intervention/utils/egon_export.py index 30d5841e..2589595f 100644 --- a/intervention/utils/egon_export.py +++ b/intervention/utils/egon_export.py @@ -178,6 +178,23 @@ class EgonGmlBuilder: reg_date = self.intervention.legal.registration_date bind_date = self.intervention.legal.binding_date + # EGON needs special treatment in case of missing data + if reg_office is None: + reg_office_element = {} + else: + reg_office_element = { + "@xlink:href": f"http://register.naturschutz.rlp.de/repository/services/referenzliste/1053/{reg_office.atom_id}", + "#text": reg_office.long_name + } + + if cons_office is None: + cons_office_element = {} + else: + cons_office_element = { + "@xlink:href": f"http://register.naturschutz.rlp.de/repository/services/referenzliste/907/{cons_office.atom_id}", + "#text": cons_office.long_name + } + xml_dict = { "wfs:FeatureCollection": { "@xmlns:wfs": "http://www.opengis.net/wfs", @@ -191,14 +208,8 @@ class EgonGmlBuilder: "oneo:azEintragungsstelle": self.intervention.responsible.conservation_file_number, "oneo:azZulassungsstelle": self.intervention.responsible.registration_file_number, "oneo:bemerkungZulassungsstelle": "", - "oneo:eintragungsstelle": { - "@xlink:href": f"http://register.naturschutz.rlp.de/repository/services/referenzliste/907/{cons_office.atom_id if cons_office else ''}", - "#text": cons_office.long_name if cons_office else "" - }, - "oneo:zulassungsstelle": { - "@xlink:href": f"http://register.naturschutz.rlp.de/repository/services/referenzliste/1053/{reg_office.atom_id if reg_office else ''}", - "#text": reg_office.long_name if reg_office else "" - }, + "oneo:eintragungsstelle": cons_office_element, + "oneo:zulassungsstelle": reg_office_element, "oneo:ersatzzahlung": self._float_to_localized_string(self._sum_all_payments()), "oneo:kompensationsart": { "@xlink:href": f"http://register.naturschutz.rlp.de/repository/services/referenzliste/88140/{comp_type_code}",