Skip to content

Commit

Permalink
solve uniqueness between amt and dokument
Browse files Browse the repository at this point in the history
  • Loading branch information
vvmruder committed Jun 16, 2023
1 parent 8bd07ea commit 5a60fde
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def office_record_to_oerebkrmtrsfr(office_record):
PLZ=office_record.postal_code,
Ort=office_record.city,
)
amt.set_TID(str(amt))
return amt


Expand Down
48 changes: 47 additions & 1 deletion src/geolink2oereb/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def run_batch(
pyramid_oereb_config_path,
section,
source_class_path="geolink2oereb.lib.interfaces.pyramid_oereb.OEREBlexSourceCustom",
c2ctemplate_style=False,
c2ctemplate_style=False
):
"""
Lads documents from ÖREBlex and transforms it to OeREBKRMtrsfr objects.
Expand Down Expand Up @@ -77,3 +77,49 @@ def run_batch(
c2ctemplate_style,
)
return gathered


def unify_gathered(gathered):
"""
Args:
gathered ([(geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.OeREBKRM_V2_0_Amt_Amt, geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.OeREBKRM_V2_0_Dokumente_Dokument)]):
Returns:
([geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.OeREBKRM_V2_0_Amt_Amt], [geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.OeREBKRM_V2_0_Dokumente_Dokument])
"""
unique_amt_tids = []
unique_amt = []
unique_dokument_tids = []
unique_dokument = []
for dokument, amt in gathered:
if str(amt) not in unique_amt_tids:
unique_amt_tids.append(str(amt))
unique_amt.append(amt)
if dokument.TID not in unique_dokument_tids:
unique_dokument_tids.append(dokument.TID)
unique_dokument.append(dokument)
return unique_dokument, unique_amt


def assign_uuids(unique_dokumente, unique_aemter):
"""
Args:
unique_dokumente ([geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.OeREBKRM_V2_0_Dokumente_Dokument]):
unique_aemter ([geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.OeREBKRM_V2_0_Amt_Amt]):
Returns:
([geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.OeREBKRM_V2_0_Amt_Amt], [geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.OeREBKRM_V2_0_Dokumente_Dokument])
"""
uuid_aemter = []
uuid_dokumente = []
for amt in unique_aemter:
new_amt_uuid = str(uuid4())
for dokument in unique_dokumente:
if dokument.ZustaendigeStelle.REF == str(amt):
dokument.ZustaendigeStelle.set_REF(new_amt_uuid)
uuid_dokumente.append(dokument)
amt.set_TID(new_amt_uuid)
uuid_aemter.append(amt)
return uuid_dokumente, uuid_aemter

0 comments on commit 5a60fde

Please sign in to comment.