Skip to content
Snippets Groups Projects

Cristin64

Merged Petr.Kalashnikov requested to merge cristin64 into master
2 unresolved threads
Files
7
+ 16
6
@@ -62,9 +62,10 @@ def add_organization(
root: ET.Element,
orgmap: typing.Dict[int, Orgenhet],
context: CristinMsContext,
) -> None:
) -> typing.List:
"""Add organization to the Element"""
organisasjon = ET.SubElement(root, 'organisasjon')
stedskoder = []
for org in orgmap.values():
parent = get_org_parent(orgmap, org)
if parent is None:
@@ -114,12 +115,16 @@ def add_organization(
for k, v in values_none_okay.items():
if v is not None:
set_text(enhet, k, v)
stedskoder.append(str(avd) + str(undavd) + str(gruppe))
return stedskoder
def add_persons(root: ET.Element,
persons: typing.List[dict],
organizations: typing.Dict[int, Orgenhet],
context: CristinMsContext) -> None:
context: CristinMsContext,
stedskoder: typing.List = []) -> None:
"""Add persons to the Element"""
personer = ET.SubElement(root, 'personer')
for person_data in persons:
@@ -177,6 +182,10 @@ def add_persons(root: ET.Element,
avd, undavd, gruppe = get_stedkode(context, org.id)
if not avd or not undavd or not gruppe:
continue
stedskode = str(avd) + str(undavd) + str(gruppe)
if not stedskode in stedskoder:
continue
# Don't create the ansettelser element until we know we can add at least
# one element to it
if not ansettelser_made:
@@ -197,8 +206,9 @@ def add_persons(root: ET.Element,
stil_model.innehaver[0].innehaver_startdato)
set_text(ansettelse, 'datoTil',
stil_model.innehaver[0].innehaver_sluttdato)
set_text(ansettelse, 'stillingsbetegnelse',
stil_model.stillingsnavn)
if stil_model.stillingsnavn is not None:
set_text(ansettelse, 'stillingsbetegnelse',
stil_model.stillingsnavn)
# set_text(ansettelse, 'stillingsandel', ???)
@@ -232,12 +242,12 @@ def generate_tree(
"""Generate the whole tree"""
root = make_root_element()
add_source_info(root, context.config.source_info)
add_organization(root, organizations, context)
stedskoder = add_organization(root, organizations, context)
# Exit if no OUs added
check_org_okay(root)
add_persons(root, persons, organizations, context)
add_persons(root, persons, organizations, context, stedskoder)
return root
Loading