From f56db7ba34f46b85a08d74632911cdcc76385663 Mon Sep 17 00:00:00 2001 From: Robert Isele Date: Tue, 9 Jan 2024 09:50:53 +0100 Subject: [PATCH] Added is_attribute to EntityPath and sub_schemata to EntitySchema. (#11) * Added is_attribute to EntityPath * Added sub_schemata to EntitySchema * Added doc to sub_schemata * Fixed doc for sub_schemata * Fixed doc for sub_schemata * Renamed EntitySchema and EntityPath attributes. --- cmem_plugin_base/dataintegration/entity.py | 25 +++++++++++++++------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/cmem_plugin_base/dataintegration/entity.py b/cmem_plugin_base/dataintegration/entity.py index 2fd417d..fcde0a2 100644 --- a/cmem_plugin_base/dataintegration/entity.py +++ b/cmem_plugin_base/dataintegration/entity.py @@ -5,14 +5,19 @@ class EntityPath: """A path in a schema. - :param path: The path string using the Silk path language. - :param is_uri: If true, values for this path must only contain URIs that point to - a sub entity. + :param is_relation: If true, values for this path must only contain URIs that + point to a sub entity. + :param is_single_value If true, a single value is expected and supporting datasets + will not use arrays etc. For instance, in XML, attributes will be used instead of + nested elements. """ - def __init__(self, path: str, is_uri: bool = False) -> None: + def __init__(self, path: str, + is_relation: bool = False, + is_single_value: bool = False) -> None: self.path = path - self.is_uri = is_uri + self.is_relation = is_relation + self.is_single_value = is_single_value class EntitySchema: @@ -20,16 +25,20 @@ class EntitySchema: :param type_uri: The entity type :param paths: Ordered list of paths - :param sub_path: Path starting from the root for enumerating the entities. + :param path_to_root: Specifies a path which defines where this schema is located + in the schema tree + :param sub_schemata: Nested entity schemata """ def __init__(self, type_uri: str, paths: Sequence[EntityPath], - sub_path: EntityPath = EntityPath("")) -> None: + path_to_root: EntityPath = EntityPath(""), + sub_schemata: Optional[Sequence['EntitySchema']] = None) -> None: self.type_uri = type_uri self.paths = paths - self.sub_path = sub_path + self.path_to_root = path_to_root + self.sub_schemata = sub_schemata class Entity: