REfctored name
This commit is contained in:
parent
3e2d0fb96a
commit
938752ffe4
7 changed files with 24 additions and 24 deletions
|
|
@ -7,15 +7,15 @@ def bootstrap_type(type_name: str, python_type: str, scd_root: UUID, model_root:
|
||||||
# create class
|
# create class
|
||||||
class_node = bottom.create_node() # create class node
|
class_node = bottom.create_node() # create class node
|
||||||
bottom.create_edge(model_root, class_node, type_name) # attach to model
|
bottom.create_edge(model_root, class_node, type_name) # attach to model
|
||||||
scd_node, = bottom.read_outgoing_nodes(scd_root, "Class") # retrieve type
|
scd_node, = bottom.read_outgoing_elements(scd_root, "Class") # retrieve type
|
||||||
bottom.create_edge(class_node, scd_node, "Morphism") # create morphism link
|
bottom.create_edge(class_node, scd_node, "Morphism") # create morphism link
|
||||||
# set min_cardinality
|
# set min_cardinality
|
||||||
min_c_node = bottom.create_node(1)
|
min_c_node = bottom.create_node(1)
|
||||||
bottom.create_edge(model_root, min_c_node, f"{type_name}.lower_cardinality")
|
bottom.create_edge(model_root, min_c_node, f"{type_name}.lower_cardinality")
|
||||||
min_c_link = bottom.create_edge(class_node, min_c_node)
|
min_c_link = bottom.create_edge(class_node, min_c_node)
|
||||||
bottom.create_edge(model_root, min_c_link, f"{type_name}.lower_cardinality_link")
|
bottom.create_edge(model_root, min_c_link, f"{type_name}.lower_cardinality_link")
|
||||||
scd_node, = bottom.read_outgoing_nodes(scd_root, "Integer")
|
scd_node, = bottom.read_outgoing_elements(scd_root, "Integer")
|
||||||
scd_link, = bottom.read_outgoing_nodes(scd_root, "Class_lower_cardinality")
|
scd_link, = bottom.read_outgoing_elements(scd_root, "Class_lower_cardinality")
|
||||||
bottom.create_edge(min_c_node, scd_node, "Morphism")
|
bottom.create_edge(min_c_node, scd_node, "Morphism")
|
||||||
bottom.create_edge(min_c_link, scd_link, "Morphism")
|
bottom.create_edge(min_c_link, scd_link, "Morphism")
|
||||||
# set max_cardinality
|
# set max_cardinality
|
||||||
|
|
@ -23,8 +23,8 @@ def bootstrap_type(type_name: str, python_type: str, scd_root: UUID, model_root:
|
||||||
bottom.create_edge(model_root, max_c_node, f"{type_name}.upper_cardinality")
|
bottom.create_edge(model_root, max_c_node, f"{type_name}.upper_cardinality")
|
||||||
max_c_link = bottom.create_edge(class_node, max_c_node)
|
max_c_link = bottom.create_edge(class_node, max_c_node)
|
||||||
bottom.create_edge(model_root, max_c_link, f"{type_name}.upper_cardinality_link")
|
bottom.create_edge(model_root, max_c_link, f"{type_name}.upper_cardinality_link")
|
||||||
scd_node, = bottom.read_outgoing_nodes(scd_root, "Integer")
|
scd_node, = bottom.read_outgoing_elements(scd_root, "Integer")
|
||||||
scd_link, = bottom.read_outgoing_nodes(scd_root, "Class_upper_cardinality")
|
scd_link, = bottom.read_outgoing_elements(scd_root, "Class_upper_cardinality")
|
||||||
bottom.create_edge(max_c_node, scd_node, "Morphism")
|
bottom.create_edge(max_c_node, scd_node, "Morphism")
|
||||||
bottom.create_edge(max_c_link, scd_link, "Morphism")
|
bottom.create_edge(max_c_link, scd_link, "Morphism")
|
||||||
# set constraint
|
# set constraint
|
||||||
|
|
@ -32,8 +32,8 @@ def bootstrap_type(type_name: str, python_type: str, scd_root: UUID, model_root:
|
||||||
bottom.create_edge(model_root, constraint_node, f"{type_name}.constraint")
|
bottom.create_edge(model_root, constraint_node, f"{type_name}.constraint")
|
||||||
constraint_link = bottom.create_edge(class_node, constraint_node)
|
constraint_link = bottom.create_edge(class_node, constraint_node)
|
||||||
bottom.create_edge(model_root, constraint_link, f"{type_name}.constraint_link")
|
bottom.create_edge(model_root, constraint_link, f"{type_name}.constraint_link")
|
||||||
scd_node, = bottom.read_outgoing_nodes(scd_root, "ActionCode")
|
scd_node, = bottom.read_outgoing_elements(scd_root, "ActionCode")
|
||||||
scd_link, = bottom.read_outgoing_nodes(scd_root, "Element_constraint")
|
scd_link, = bottom.read_outgoing_elements(scd_root, "Element_constraint")
|
||||||
bottom.create_edge(constraint_node, scd_node, "Morphism")
|
bottom.create_edge(constraint_node, scd_node, "Morphism")
|
||||||
bottom.create_edge(constraint_link, scd_link, "Morphism")
|
bottom.create_edge(constraint_link, scd_link, "Morphism")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,14 +64,14 @@ class Bottom:
|
||||||
edges = [e for e in edges if read_label(e) == label]
|
edges = [e for e in edges if read_label(e) == label]
|
||||||
return edges
|
return edges
|
||||||
|
|
||||||
def read_incoming_nodes(self, target: UUID, label=None) -> List[UUID]:
|
def read_incoming_elements(self, target: UUID, label=None) -> List[UUID]:
|
||||||
edges = self.read_incoming_edges(target, label)
|
edges = self.read_incoming_edges(target, label)
|
||||||
if edges is None or len(edges) == 0:
|
if edges is None or len(edges) == 0:
|
||||||
return []
|
return []
|
||||||
else:
|
else:
|
||||||
return [self.read_edge_source(e) for e in edges]
|
return [self.read_edge_source(e) for e in edges]
|
||||||
|
|
||||||
def read_outgoing_nodes(self, source: UUID, label=None) -> List[UUID]:
|
def read_outgoing_elements(self, source: UUID, label=None) -> List[UUID]:
|
||||||
edges = self.read_outgoing_edges(source, label)
|
edges = self.read_outgoing_edges(source, label)
|
||||||
if edges is None or len(edges) == 0:
|
if edges is None or len(edges) == 0:
|
||||||
return []
|
return []
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,13 @@ class Boolean:
|
||||||
def __init__(self, model: UUID, state: State):
|
def __init__(self, model: UUID, state: State):
|
||||||
self.model = model
|
self.model = model
|
||||||
self.bottom = Bottom(state)
|
self.bottom = Bottom(state)
|
||||||
type_model_id_node, = self.bottom.read_outgoing_nodes(state.read_root(), "Boolean")
|
type_model_id_node, = self.bottom.read_outgoing_elements(state.read_root(), "Boolean")
|
||||||
self.type_model = UUID(self.bottom.read_value(type_model_id_node))
|
self.type_model = UUID(self.bottom.read_value(type_model_id_node))
|
||||||
|
|
||||||
def create(self, value: bool):
|
def create(self, value: bool):
|
||||||
if "boolean" in self.bottom.read_keys(self.model):
|
if "boolean" in self.bottom.read_keys(self.model):
|
||||||
instance, = self.bottom.read_outgoing_nodes(self.model, "boolean")
|
instance, = self.bottom.read_outgoing_elements(self.model, "boolean")
|
||||||
self.bottom.delete_element(instance)
|
self.bottom.delete_element(instance)
|
||||||
_instance = self.bottom.create_edge(self.model, self.bottom.create_node(value), "boolean")
|
_instance = self.bottom.create_edge(self.model, self.bottom.create_node(value), "boolean")
|
||||||
_type, = self.bottom.read_outgoing_nodes(self.type_model, "Boolean")
|
_type, = self.bottom.read_outgoing_elements(self.type_model, "Boolean")
|
||||||
self.bottom.create_edge(_instance, _type, "Morphism")
|
self.bottom.create_edge(_instance, _type, "Morphism")
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,13 @@ class Float:
|
||||||
def __init__(self, model: UUID, state: State):
|
def __init__(self, model: UUID, state: State):
|
||||||
self.model = model
|
self.model = model
|
||||||
self.bottom = Bottom(state)
|
self.bottom = Bottom(state)
|
||||||
type_model_id_node, = self.bottom.read_outgoing_nodes(state.read_root(), "Float")
|
type_model_id_node, = self.bottom.read_outgoing_elements(state.read_root(), "Float")
|
||||||
self.type_model = UUID(self.bottom.read_value(type_model_id_node))
|
self.type_model = UUID(self.bottom.read_value(type_model_id_node))
|
||||||
|
|
||||||
def create(self, value: float):
|
def create(self, value: float):
|
||||||
if "float" in self.bottom.read_keys(self.model):
|
if "float" in self.bottom.read_keys(self.model):
|
||||||
instance, = self.bottom.read_outgoing_nodes(self.model, "float")
|
instance, = self.bottom.read_outgoing_elements(self.model, "float")
|
||||||
self.bottom.delete_element(instance)
|
self.bottom.delete_element(instance)
|
||||||
_instance = self.bottom.create_edge(self.model, self.bottom.create_node(value), "float")
|
_instance = self.bottom.create_edge(self.model, self.bottom.create_node(value), "float")
|
||||||
_type, = self.bottom.read_outgoing_nodes(self.type_model, "Float")
|
_type, = self.bottom.read_outgoing_elements(self.type_model, "Float")
|
||||||
self.bottom.create_edge(_instance, _type, "Morphism")
|
self.bottom.create_edge(_instance, _type, "Morphism")
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,13 @@ class Integer:
|
||||||
def __init__(self, model: UUID, state: State):
|
def __init__(self, model: UUID, state: State):
|
||||||
self.model = model
|
self.model = model
|
||||||
self.bottom = Bottom(state)
|
self.bottom = Bottom(state)
|
||||||
type_model_id_node, = self.bottom.read_outgoing_nodes(state.read_root(), "Integer")
|
type_model_id_node, = self.bottom.read_outgoing_elements(state.read_root(), "Integer")
|
||||||
self.type_model = UUID(self.bottom.read_value(type_model_id_node))
|
self.type_model = UUID(self.bottom.read_value(type_model_id_node))
|
||||||
|
|
||||||
def create(self, value: int):
|
def create(self, value: int):
|
||||||
if "string" in self.bottom.read_keys(self.model):
|
if "string" in self.bottom.read_keys(self.model):
|
||||||
instance, = self.bottom.read_outgoing_nodes(self.model, "integer")
|
instance, = self.bottom.read_outgoing_elements(self.model, "integer")
|
||||||
self.bottom.delete_element(instance)
|
self.bottom.delete_element(instance)
|
||||||
_instance = self.bottom.create_edge(self.model, self.bottom.create_node(value), "integer")
|
_instance = self.bottom.create_edge(self.model, self.bottom.create_node(value), "integer")
|
||||||
_type, = self.bottom.read_outgoing_nodes(self.type_model, "Integer")
|
_type, = self.bottom.read_outgoing_elements(self.type_model, "Integer")
|
||||||
self.bottom.create_edge(_instance, _type, "Morphism")
|
self.bottom.create_edge(_instance, _type, "Morphism")
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,13 @@ class String:
|
||||||
def __init__(self, model: UUID, state: State):
|
def __init__(self, model: UUID, state: State):
|
||||||
self.model = model
|
self.model = model
|
||||||
self.bottom = Bottom(state)
|
self.bottom = Bottom(state)
|
||||||
type_model_id_node, = self.bottom.read_outgoing_nodes(state.read_root(), "String")
|
type_model_id_node, = self.bottom.read_outgoing_elements(state.read_root(), "String")
|
||||||
self.type_model = UUID(self.bottom.read_value(type_model_id_node))
|
self.type_model = UUID(self.bottom.read_value(type_model_id_node))
|
||||||
|
|
||||||
def create(self, value: str):
|
def create(self, value: str):
|
||||||
if "string" in self.bottom.read_keys(self.model):
|
if "string" in self.bottom.read_keys(self.model):
|
||||||
instance, = self.bottom.read_outgoing_nodes(self.model, "string")
|
instance, = self.bottom.read_outgoing_elements(self.model, "string")
|
||||||
self.bottom.delete_element(instance)
|
self.bottom.delete_element(instance)
|
||||||
_instance = self.bottom.create_edge(self.model, self.bottom.create_node(value), "string")
|
_instance = self.bottom.create_edge(self.model, self.bottom.create_node(value), "string")
|
||||||
_type, = self.bottom.read_outgoing_nodes(self.type_model, "String")
|
_type, = self.bottom.read_outgoing_elements(self.type_model, "String")
|
||||||
self.bottom.create_edge(_instance, _type, "Morphism")
|
self.bottom.create_edge(_instance, _type, "Morphism")
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,13 @@ class Integer:
|
||||||
def __init__(self, model: UUID, state: State):
|
def __init__(self, model: UUID, state: State):
|
||||||
self.model = model
|
self.model = model
|
||||||
self.bottom = Bottom(state)
|
self.bottom = Bottom(state)
|
||||||
type_model_id_node, = self.bottom.read_outgoing_nodes(state.read_root(), "Type")
|
type_model_id_node, = self.bottom.read_outgoing_elements(state.read_root(), "Type")
|
||||||
self.type_model = UUID(self.bottom.read_value(type_model_id_node))
|
self.type_model = UUID(self.bottom.read_value(type_model_id_node))
|
||||||
|
|
||||||
def create(self, value: tuple):
|
def create(self, value: tuple):
|
||||||
if "string" in self.bottom.read_keys(self.model):
|
if "string" in self.bottom.read_keys(self.model):
|
||||||
instance, = self.bottom.read_outgoing_nodes(self.model, "type")
|
instance, = self.bottom.read_outgoing_elements(self.model, "type")
|
||||||
self.bottom.delete_element(instance)
|
self.bottom.delete_element(instance)
|
||||||
_instance = self.bottom.create_edge(self.model, self.bottom.create_node(value), "type")
|
_instance = self.bottom.create_edge(self.model, self.bottom.create_node(value), "type")
|
||||||
_type, = self.bottom.read_outgoing_nodes(self.type_model, "Type")
|
_type, = self.bottom.read_outgoing_elements(self.type_model, "Type")
|
||||||
self.bottom.create_edge(_instance, _type, "Morphism")
|
self.bottom.create_edge(_instance, _type, "Morphism")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue