Skip to content
Snippets Groups Projects
Commit c7fd4550 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

move

parent 16e70da9
Branches
Tags
1 merge request!8F h5 cfood
...@@ -301,58 +301,3 @@ class H5CFood(AbstractFileCFood): ...@@ -301,58 +301,3 @@ class H5CFood(AbstractFileCFood):
for prop in target_structure.get_properties(): for prop in target_structure.get_properties():
if is_reference(prop): if is_reference(prop):
self.insert_missing_structure(prop.value) self.insert_missing_structure(prop.value)
def update_structure(self, target_structure: db.Record):
"""compare the existing records with the target record tree created
from the h5 object
params
------
existing_structure:
retrieved entity; e.g. the top level identifiable
target_structure: db.Record
A record which may have references to other records. Must be a DAG.
"""
if target_structure._cuid in self.em.to_existing:
self.update_matched_entity(target_structure, self.em.to_existing[target_structure._cuid])
for prop in target_structure.get_properties():
if is_reference(prop):
self.update_structure(prop.value)
# TODO this can be moved to the general lib; it is the general case that
# two Records are compared and Properties of one are mapped to the other
# (unidirectional!)
def update_matched_entity(self, target_record, existing_record):
"""
update the Record existing in the server according to the Record
supplied as target_record
"""
for parent in target_record.get_parents():
if parent.name == "":
# TODO there should not be such a parent!!!
continue
assure_has_parent(existing_record, parent.name, force=True)
if target_record.description is not None:
# check whether description is equal
assure_has_description(existing_record, target_record.description,
to_be_updated=self.to_be_updated)
for prop in target_record.get_properties():
# check for remaining property types
if isinstance(prop.value, db.Entity):
if prop.value._cuid in self.em.to_existing:
value = self.em.to_existing[prop.value._cuid].id
else:
value = prop.value.id
else:
value = prop.value
assure_property_is(existing_record, prop.name, value,
to_be_updated=self.to_be_updated)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment