Skip to content
Snippets Groups Projects

FIX: use identifiable instead of record

Merged Henrik tom Wörden requested to merge f-identifiable into dev
1 file
+ 3
22
Compare changes
  • Side-by-side
  • Inline
@@ -121,10 +121,6 @@ class IdentifiableAdapter(object):
@@ -121,10 +121,6 @@ class IdentifiableAdapter(object):
"""
"""
pass
pass
@abstractmethod
def resolve_reference(self, record: db.Record):
pass
def get_identifiable(self, record: db.Record):
def get_identifiable(self, record: db.Record):
"""
"""
retrieve the registred identifiable and fill the property values to create an
retrieve the registred identifiable and fill the property values to create an
@@ -223,8 +219,9 @@ class LocalStorageIdentifiableAdapter(IdentifiableAdapter):
@@ -223,8 +219,9 @@ class LocalStorageIdentifiableAdapter(IdentifiableAdapter):
with open(filename, "r") as f:
with open(filename, "r") as f:
self._records = db.Container().from_xml(f.read())
self._records = db.Container().from_xml(f.read())
# TODO: move to super class?
def is_identifiable_for_record(self,
def is_identifiable_for_record(self, registered_identifiable: db.RecordType, record: db.Record):
registered_identifiable: db.RecordType,
 
record: db.Record):
"""
"""
Check whether this registered_identifiable is an identifiable for the record.
Check whether this registered_identifiable is an identifiable for the record.
@@ -301,22 +298,6 @@ class LocalStorageIdentifiableAdapter(IdentifiableAdapter):
@@ -301,22 +298,6 @@ class LocalStorageIdentifiableAdapter(IdentifiableAdapter):
return None
return None
return candidates[0]
return candidates[0]
def resolve_reference(self, value: db.Record):
if self.get_registered_identifiable(value) is None:
raise NotImplementedError("Non-identifiable references cannot"
" be used as properties in identifiables.")
# TODO: just resolve the entity
value_identifiable = self.retrieve_identified_record(value)
if value_identifiable is None:
raise RuntimeError("The identifiable which is used as property"
" here has to be inserted first.")
if value_identifiable.id is None:
raise RuntimeError("The entity has not been assigned an ID.")
return value_identifiable.id
class CaosDBIdentifiableAdapter(IdentifiableAdapter):
class CaosDBIdentifiableAdapter(IdentifiableAdapter):
"""
"""
Loading