Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Concept and Scheme models #127

Merged
merged 10 commits into from
Nov 20, 2024
12 changes: 12 additions & 0 deletions arches_lingo/etl_modules/migrate_to_lingo.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,22 @@ def init_relationships(
part_of_scheme_nodegroup = NodeGroup.objects.get(
nodegroupid=CONCEPTS_PART_OF_SCHEME_NODEGROUP_ID
)
concepts_with_scheme = {}
for concept in concept_hierarchy:
root_list = str(concept["root_list"])
resourceinstanceid = concept["concept"]

concept_has_part_of_scheme = resourceinstanceid in concepts_with_scheme
existing_scheme = concepts_with_scheme.get(resourceinstanceid)
if not concept_has_part_of_scheme:
concepts_with_scheme[resourceinstanceid] = root_list
elif concept_has_part_of_scheme and existing_scheme == root_list:
continue
elif concept_has_part_of_scheme and existing_scheme != root_list:
raise Exception(
jacobtylerwalls marked this conversation as resolved.
Show resolved Hide resolved
f"Concept {resourceinstanceid} cannot have multiple schemes: {root_list} and {concepts_with_scheme[resourceinstanceid]}"
)

value_obj = {
str(CONCEPTS_PART_OF_SCHEME_NODEGROUP_ID): {
"notes": "",
Expand Down
Loading