Skip to content

Commit

Permalink
Added is_attribute to EntityPath and sub_schemata to EntitySchema. (#11)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
robertisele authored Jan 9, 2024
1 parent c73ed45 commit f56db7b
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions cmem_plugin_base/dataintegration/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,40 @@
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:
"""An entity schema.
: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:
Expand Down

0 comments on commit f56db7b

Please sign in to comment.