bento_meta.model
This module contains Model
, a class for managing data models housed
in the Bento Metamodel Database. Models are built from bento_meta.Entity
subclasses (see bento_meta.objects
). A Model can be used with or
without a Neo4j database connection.
Module Contents
Classes
- class bento_meta.model.Model(handle=None, mdb=None)[source]
Bases:
object
- property drv
Neo4j database driver from MDB object
- property mdb
- classmethod versioning(on=None)[source]
Get or set versioning state.
- Parameters:
on (boolean) – True, apply versioning. False, do not.
Note: this delegates to
Entity.versioning()
.
- classmethod set_version_count(ct)[source]
Set the integer version counter.
- Parameters:
ct (int) – Set version counter to this value.
Note: this delegates to
Entity.set_version_count()
.
- add_node(node=None)[source]
Add a
Node
to the model.The model attribute of
node
is set to Model.handle
- add_edge(edge=None)[source]
Add an
Edge
to the model.The model attribute of
edge
is set to Model.handle
- add_prop(ent, prop=None)[source]
Add a
Property
to the model.- Parameters:
The model attribute of
prop
is set to Model.handle. Within a model,Property
entities are unique with respect to their handle (but can be reused). This method will look for an existing property within the model with the given handle, and add an item to Model.props pointing to it if found.
- annotate(ent, term)[source]
Associate a single
Term
with anEntity
. This creates a Concept entity if needed and links both the Entity and the Term to the concept, in keeping with the MDB spec. It supports the Term key in MDF. :param Entity ent:Entity
object to annotate :param Term term:Term
object to describe the Entity
- add_terms(prop, *terms)[source]
Add a list of
Term
and/or strings to aProperty
with a value domain ofvalue_set
Term
instances are created for strings; Term.value and Term.handle is set to the string.
- rm_node(node)[source]
Remove a
Node
from the Model instance.- Parameters:
node (Node) – Node to be removed
Note: A node can’t be removed if it is participating in an edge (i.e., if the node is some edge’s src or dst attribute)
Clarify what happens in the Model object, in the database when versioning is off, in the database when versioning is on
- rm_edge(edge)[source]
Remove an
Edge
instance from the Model instance.- Parameters:
edge (Edge) – Edge to be removed
Clarify what happens in the Model object, in the database when versioning is off, in the database when versioning is on
- rm_prop(prop)[source]
Remove a
Property
instance from the Model instance.- Parameters:
prop (Property) – Property to be removed
Clarify what happens in the Model object, in the database when versioning is off, in the database when versioning is on
- assign_edge_end(edge=None, end=None, node=None)[source]
Move the src or dst of an
Edge
to a differentNode
.- Parameters:
Note: Both
node
andedge
must be present in the Model instance (viaadd_node()
andadd_edge()
)
- contains(ent)[source]
Ask whether an entity is present in the Model instance.
- Parameters:
ent (Entity) – Entity in question
Note: Only works on Nodes, Edges, and Properties
- edges_by_type(edge_handle)[source]
Get all
Edge
that have a given edge type (i.e., handle)- Parameters:
edge_handle (str) – The edge type
- Returns:
list of
Edge