Park structural conformance for now, finish constraints for nominal
This commit is contained in:
parent
3c1d1fa002
commit
6ce8a4ef5c
4 changed files with 285 additions and 35 deletions
40
bootstrap/pn.py
Normal file
40
bootstrap/pn.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
from services.scd import SCD
|
||||
from uuid import UUID
|
||||
from state.base import State
|
||||
|
||||
|
||||
def bootstrap_pn(state: State, model_name: str) -> UUID:
|
||||
# Retrieve scd model
|
||||
scd_id = state.read_dict(state.read_root(), "SCD")
|
||||
scd = UUID(state.read_value(scd_id))
|
||||
# Retrieve refs to primitive type models
|
||||
# # integer
|
||||
int_type_id = state.read_dict(state.read_root(), "Integer")
|
||||
int_type = UUID(state.read_value(int_type_id))
|
||||
# # string
|
||||
str_type_id = state.read_dict(state.read_root(), "String")
|
||||
str_type = UUID(state.read_value(str_type_id))
|
||||
# Create LTM_PN
|
||||
model_uuid = state.create_node()
|
||||
mcl_root_id = state.create_nodevalue(str(model_uuid))
|
||||
state.create_dict(state.read_root(), model_name, mcl_root_id)
|
||||
service = SCD(scd, model_uuid, state)
|
||||
# Create classes
|
||||
service.create_class("P")
|
||||
service.create_class("T")
|
||||
# Create associations
|
||||
service.create_association("P2T", "P", "T")
|
||||
service.create_association("T2P", "T", "P")
|
||||
# Create model refs
|
||||
service.create_model_ref("Integer", int_type)
|
||||
service.create_model_ref("String", str_type)
|
||||
# Create class attributes
|
||||
service.create_attribute_link("P", "Integer", "t", False)
|
||||
service.create_attribute_link("P", "String", "n", False)
|
||||
service.create_attribute_link("T", "String", "n", False)
|
||||
# Create association attributes
|
||||
service.create_attribute_link("P2T", "Integer", "w", False)
|
||||
service.create_attribute_link("T2P", "Integer", "w", False)
|
||||
# Create test constraint
|
||||
service.add_constraint("P", "print(element)\nreturn True")
|
||||
return model_uuid
|
||||
|
|
@ -74,6 +74,8 @@ def bootstrap_scd(state: State) -> UUID:
|
|||
# # INHERITANCES, i.e. elements typed by Inheritance
|
||||
# # Class inherits from Element
|
||||
add_edge_element("class_inh_element", class_node, element_node)
|
||||
# # GlobalConstraint inherits from Element
|
||||
add_edge_element("gc_inh_element", glob_constr_node, element_node)
|
||||
# # Attribute inherits from Element
|
||||
add_edge_element("attr_inh_element", attr_node, element_node)
|
||||
# # Association inherits from Element
|
||||
|
|
@ -186,6 +188,7 @@ def bootstrap_scd(state: State) -> UUID:
|
|||
add_mcl_morphism("AttributeLink", "Association")
|
||||
# Inheritance
|
||||
add_mcl_morphism("class_inh_element", "Inheritance")
|
||||
add_mcl_morphism("gc_inh_element", "Inheritance")
|
||||
add_mcl_morphism("attr_inh_element", "Inheritance")
|
||||
add_mcl_morphism("assoc_inh_element", "Inheritance")
|
||||
add_mcl_morphism("attr_link_inh_element", "Inheritance")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue