Add ActionCode primitive type. Fix constraint checking.
This commit is contained in:
parent
0785b9218e
commit
59de61d0a3
11 changed files with 256 additions and 82 deletions
24
services/primitives/actioncode_type.py
Normal file
24
services/primitives/actioncode_type.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
from uuid import UUID
|
||||
from state.base import State
|
||||
from services.bottom.V0 import Bottom
|
||||
|
||||
|
||||
class ActionCode:
|
||||
def __init__(self, model: UUID, state: State):
|
||||
self.model = model
|
||||
self.bottom = Bottom(state)
|
||||
type_model_id_node, = self.bottom.read_outgoing_elements(state.read_root(), "ActionCode")
|
||||
self.type_model = UUID(self.bottom.read_value(type_model_id_node))
|
||||
|
||||
def create(self, value: str):
|
||||
if "code" in self.bottom.read_keys(self.model):
|
||||
instance, = self.bottom.read_outgoing_elements(self.model, "code")
|
||||
self.bottom.delete_element(instance)
|
||||
_instance = self.bottom.create_node(value)
|
||||
self.bottom.create_edge(self.model, _instance, "code")
|
||||
_type, = self.bottom.read_outgoing_elements(self.type_model, "ActionCode")
|
||||
self.bottom.create_edge(_instance, _type, "Morphism")
|
||||
|
||||
def read(self):
|
||||
instance, = self.bottom.read_outgoing_elements(self.model, "code")
|
||||
return self.bottom.read_value(instance)
|
||||
Loading…
Add table
Add a link
Reference in a new issue