Skip to content
Snippets Groups Projects

F h5 cfood

Merged Henrik tom Wörden requested to merge f-h5-cfood into dev
1 file
+ 0
55
Compare changes
  • Side-by-side
  • Inline
+ 0
55
@@ -301,58 +301,3 @@ class H5CFood(AbstractFileCFood):
for prop in target_structure.get_properties():
if is_reference(prop):
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)
Loading