Add ActionCode primitive type. Fix constraint checking.

This commit is contained in:
Joeri Exelmans 2024-10-07 16:08:23 +02:00
parent 0785b9218e
commit 59de61d0a3
11 changed files with 256 additions and 82 deletions

View 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)