|
@@ -3,7 +3,7 @@ include "object_operations.alh"
|
|
|
include "modelling.alh"
|
|
|
include "metamodels.alh"
|
|
|
|
|
|
-Element function ramify_func(model : Element, prepost : String):
|
|
|
+Element function ramify(model : Element):
|
|
|
// Create new model structure
|
|
|
Element new_model
|
|
|
new_model = create_node()
|
|
@@ -16,14 +16,10 @@ Element function ramify_func(model : Element, prepost : String):
|
|
|
Element old_m
|
|
|
Element new_m
|
|
|
Element mm
|
|
|
- String inheritor
|
|
|
new_m = new_model["model"]
|
|
|
old_m = model["model"]
|
|
|
mm = new_model["metamodel"]["model"]
|
|
|
|
|
|
- Boolean is_pre
|
|
|
- is_pre = (prepost == "pre")
|
|
|
-
|
|
|
// Add in some primitives
|
|
|
instantiate_node(new_model, "Class", "Natural")
|
|
|
instantiate_node(new_model, "Class", "String")
|
|
@@ -33,107 +29,89 @@ Element function ramify_func(model : Element, prepost : String):
|
|
|
add_AL_to_MM(new_model)
|
|
|
|
|
|
// Add some default elements
|
|
|
- if (is_pre):
|
|
|
- // Class LHS {
|
|
|
- // constraint : funcdef {
|
|
|
- // target_upper_cardinality = 1
|
|
|
- // }
|
|
|
- // upper_cardinality = 1
|
|
|
- // lower_cardinality = 1
|
|
|
- // }
|
|
|
- instantiate_node(new_model, "Class", "LHS")
|
|
|
- instantiate_attribute(new_model, "LHS", "lower_cardinality", 1)
|
|
|
- instantiate_attribute(new_model, "LHS", "upper_cardinality", 1)
|
|
|
- instantiate_link(new_model, "Association", "LHS_constraint", "LHS", "funcdef")
|
|
|
- instantiate_attribute(new_model, "LHS_constraint", "name", "constraint")
|
|
|
- instantiate_attribute(new_model, "LHS_constraint", "target_upper_cardinality", 1)
|
|
|
-
|
|
|
- // Class NAC {}
|
|
|
- //instantiate_node(new_model, "Class", "NAC")
|
|
|
-
|
|
|
- // Class Pre_Element {
|
|
|
- // label : String {
|
|
|
- // target_lower_cardinality = 1
|
|
|
- // target_upper_cardinality = 1
|
|
|
- // }
|
|
|
- // constraint : funcdef {
|
|
|
- // target_upper_cardinality = 1
|
|
|
- // }
|
|
|
- // }
|
|
|
- instantiate_node(new_model, "Class", "Pre_Element")
|
|
|
- instantiate_link(new_model, "Association", "Pre_Element_label", "Pre_Element", "String")
|
|
|
- instantiate_attribute(new_model, "Pre_Element_label", "name", "label")
|
|
|
- instantiate_attribute(new_model, "Pre_Element_label", "target_lower_cardinality", 1)
|
|
|
- instantiate_attribute(new_model, "Pre_Element_label", "target_upper_cardinality", 1)
|
|
|
- instantiate_link(new_model, "Association", "Pre_Element_constraint", "Pre_Element", "funcdef")
|
|
|
- instantiate_attribute(new_model, "Pre_Element_constraint", "name", "constraint")
|
|
|
- instantiate_attribute(new_model, "Pre_Element_constraint", "target_upper_cardinality", 1)
|
|
|
-
|
|
|
- // Association LHS_contains (LHS, Pre_Element) {}
|
|
|
- instantiate_link(new_model, "Association", "LHS_contains", "LHS", "Pre_Element")
|
|
|
- instantiate_attribute(new_model, "LHS_contains", "name", "contains")
|
|
|
-
|
|
|
- // Association NAC_contains (NAC, Pre_Element) {}
|
|
|
- //instantiate_link(new_model, "Association", "NAC_contains", "NAC", "Pre_Element")
|
|
|
- //instantiate_attribute(new_model, "NAC_contains", "name", "contains")
|
|
|
-
|
|
|
- inheritor = "Pre_Element"
|
|
|
-
|
|
|
- else:
|
|
|
- // Class RHS {
|
|
|
- // action : FuncDef {
|
|
|
- // target_upper_cardinality = 1
|
|
|
- // }
|
|
|
- // upper_cardinality = 1
|
|
|
- // lower_cardinality = 1
|
|
|
- // }
|
|
|
- instantiate_node(new_model, "Class", "RHS")
|
|
|
- instantiate_attribute(new_model, "RHS", "lower_cardinality", 1)
|
|
|
- instantiate_attribute(new_model, "RHS", "upper_cardinality", 1)
|
|
|
- instantiate_link(new_model, "Association", "RHS_action", "RHS", "funcdef")
|
|
|
- instantiate_attribute(new_model, "RHS_action", "name", "action")
|
|
|
- instantiate_attribute(new_model, "RHS_action", "target_upper_cardinality", 1)
|
|
|
-
|
|
|
- // Class Post_Element {
|
|
|
- // label : String {
|
|
|
- // target_lower_cardinality = 1
|
|
|
- // target_upper_cardinality = 1
|
|
|
- // }
|
|
|
- // value : funcdef {
|
|
|
- // target_upper_cardinality = 1
|
|
|
- // }
|
|
|
- // action : funcdef {
|
|
|
- // target_upper_cardinality = 1
|
|
|
- // }
|
|
|
- // }
|
|
|
- instantiate_node(new_model, "Class", "Post_Element")
|
|
|
- instantiate_link(new_model, "Association", "Post_Element_label", "Post_Element", "String")
|
|
|
- instantiate_attribute(new_model, "Post_Element_label", "name", "label")
|
|
|
- instantiate_attribute(new_model, "Post_Element_label", "target_lower_cardinality", 1)
|
|
|
- instantiate_attribute(new_model, "Post_Element_label", "target_upper_cardinality", 1)
|
|
|
- instantiate_link(new_model, "Association", "Post_Element_value", "Post_Element", "funcdef")
|
|
|
- instantiate_attribute(new_model, "Post_Element_value", "name", "value")
|
|
|
- instantiate_attribute(new_model, "Post_Element_value", "target_upper_cardinality", 1)
|
|
|
- instantiate_link(new_model, "Association", "Post_Element_action", "Post_Element", "funcdef")
|
|
|
- instantiate_attribute(new_model, "Post_Element_action", "name", "action")
|
|
|
- instantiate_attribute(new_model, "Post_Element_action", "target_upper_cardinality", 1)
|
|
|
-
|
|
|
- // Association RHS_contains (RHS, Post_Element) {}
|
|
|
- instantiate_link(new_model, "Association", "RHS_contains", "RHS", "Post_Element")
|
|
|
- instantiate_attribute(new_model, "RHS_contains", "name", "contains")
|
|
|
-
|
|
|
- inheritor = "Post_Element"
|
|
|
+ // Class LHS {
|
|
|
+ // constraint : funcdef {
|
|
|
+ // target_upper_cardinality = 1
|
|
|
+ // }
|
|
|
+ // upper_cardinality = 1
|
|
|
+ // lower_cardinality = 1
|
|
|
+ // }
|
|
|
+ instantiate_node(new_model, "Class", "LHS")
|
|
|
+ instantiate_attribute(new_model, "LHS", "lower_cardinality", 1)
|
|
|
+ instantiate_attribute(new_model, "LHS", "upper_cardinality", 1)
|
|
|
+ instantiate_link(new_model, "Association", "LHS_constraint", "LHS", "funcdef")
|
|
|
+ instantiate_attribute(new_model, "LHS_constraint", "name", "constraint")
|
|
|
+ instantiate_attribute(new_model, "LHS_constraint", "target_upper_cardinality", 1)
|
|
|
+
|
|
|
+ // Class Pre_Element {
|
|
|
+ // label : String {
|
|
|
+ // target_lower_cardinality = 1
|
|
|
+ // target_upper_cardinality = 1
|
|
|
+ // }
|
|
|
+ // constraint : funcdef {
|
|
|
+ // target_upper_cardinality = 1
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ instantiate_node(new_model, "Class", "Pre_Element")
|
|
|
+ instantiate_link(new_model, "Association", "Pre_Element_label", "Pre_Element", "String")
|
|
|
+ instantiate_attribute(new_model, "Pre_Element_label", "name", "label")
|
|
|
+ instantiate_attribute(new_model, "Pre_Element_label", "target_lower_cardinality", 1)
|
|
|
+ instantiate_attribute(new_model, "Pre_Element_label", "target_upper_cardinality", 1)
|
|
|
+ instantiate_link(new_model, "Association", "Pre_Element_constraint", "Pre_Element", "funcdef")
|
|
|
+ instantiate_attribute(new_model, "Pre_Element_constraint", "name", "constraint")
|
|
|
+ instantiate_attribute(new_model, "Pre_Element_constraint", "target_upper_cardinality", 1)
|
|
|
+
|
|
|
+ // Association LHS_contains (LHS, Pre_Element) {}
|
|
|
+ instantiate_link(new_model, "Association", "LHS_contains", "LHS", "Pre_Element")
|
|
|
+ instantiate_attribute(new_model, "LHS_contains", "name", "contains")
|
|
|
+
|
|
|
+ // Class RHS {
|
|
|
+ // action : FuncDef {
|
|
|
+ // target_upper_cardinality = 1
|
|
|
+ // }
|
|
|
+ // upper_cardinality = 1
|
|
|
+ // lower_cardinality = 1
|
|
|
+ // }
|
|
|
+ instantiate_node(new_model, "Class", "RHS")
|
|
|
+ instantiate_attribute(new_model, "RHS", "lower_cardinality", 1)
|
|
|
+ instantiate_attribute(new_model, "RHS", "upper_cardinality", 1)
|
|
|
+ instantiate_link(new_model, "Association", "RHS_action", "RHS", "funcdef")
|
|
|
+ instantiate_attribute(new_model, "RHS_action", "name", "action")
|
|
|
+ instantiate_attribute(new_model, "RHS_action", "target_upper_cardinality", 1)
|
|
|
+
|
|
|
+ // Class Post_Element {
|
|
|
+ // label : String {
|
|
|
+ // target_lower_cardinality = 1
|
|
|
+ // target_upper_cardinality = 1
|
|
|
+ // }
|
|
|
+ // value : funcdef {
|
|
|
+ // target_upper_cardinality = 1
|
|
|
+ // }
|
|
|
+ // action : funcdef {
|
|
|
+ // target_upper_cardinality = 1
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ instantiate_node(new_model, "Class", "Post_Element")
|
|
|
+ instantiate_link(new_model, "Association", "Post_Element_label", "Post_Element", "String")
|
|
|
+ instantiate_attribute(new_model, "Post_Element_label", "name", "label")
|
|
|
+ instantiate_attribute(new_model, "Post_Element_label", "target_lower_cardinality", 1)
|
|
|
+ instantiate_attribute(new_model, "Post_Element_label", "target_upper_cardinality", 1)
|
|
|
+ instantiate_link(new_model, "Association", "Post_Element_value", "Post_Element", "funcdef")
|
|
|
+ instantiate_attribute(new_model, "Post_Element_value", "name", "value")
|
|
|
+ instantiate_attribute(new_model, "Post_Element_value", "target_upper_cardinality", 1)
|
|
|
+ instantiate_link(new_model, "Association", "Post_Element_action", "Post_Element", "funcdef")
|
|
|
+ instantiate_attribute(new_model, "Post_Element_action", "name", "action")
|
|
|
+ instantiate_attribute(new_model, "Post_Element_action", "target_upper_cardinality", 1)
|
|
|
+
|
|
|
+ // Association RHS_contains (RHS, Post_Element) {}
|
|
|
+ instantiate_link(new_model, "Association", "RHS_contains", "RHS", "Post_Element")
|
|
|
+ instantiate_attribute(new_model, "RHS_contains", "name", "contains")
|
|
|
|
|
|
// Basics are added, now we need to add each node and transition, but slightly modified
|
|
|
Element keys
|
|
|
String key
|
|
|
Element new_entry
|
|
|
Element entry
|
|
|
- String append
|
|
|
- if (is_pre):
|
|
|
- append = "Pre_"
|
|
|
- else:
|
|
|
- append = "Post_"
|
|
|
|
|
|
keys = dict_keys(old_m)
|
|
|
String type_name
|
|
@@ -148,23 +126,28 @@ Element function ramify_func(model : Element, prepost : String):
|
|
|
|
|
|
type_name = reverseKeyLookup(model["metamodel"]["model"], dict_read_node(model["type_mapping"], entry))
|
|
|
if (type_name == "Class"):
|
|
|
- instantiate_node(new_model, type_name, append + key)
|
|
|
+ instantiate_node(new_model, type_name, "Pre_" + key)
|
|
|
+ instantiate_node(new_model, type_name, "Post_" + key)
|
|
|
|
|
|
// Also make it inherit from the "root element"
|
|
|
- instantiate_link(new_model, "Inheritance", "", append + key, inheritor)
|
|
|
+ instantiate_link(new_model, "Inheritance", "", "Pre_" + key, "Pre_Element")
|
|
|
+ instantiate_link(new_model, "Inheritance", "", "Post_" + key, "Post_Element")
|
|
|
|
|
|
elif (type_name == "Association"):
|
|
|
old_source = reverseKeyLookup(model["model"], read_edge_src(entry))
|
|
|
old_target = reverseKeyLookup(model["model"], read_edge_dst(entry))
|
|
|
- instantiate_link(new_model, type_name, append + key, append + old_source, append + old_target)
|
|
|
+ instantiate_link(new_model, type_name, "Pre_" + key, "Pre_" + old_source, "Pre_" + old_target)
|
|
|
+ instantiate_link(new_model, type_name, "Post_" + key, "Post_" + old_source, "Post_" + old_target)
|
|
|
|
|
|
// 1) Make it inherit from the Root Element (Pre_Element or Post_Element)
|
|
|
- instantiate_link(new_model, "Inheritance", "", append + key, inheritor)
|
|
|
+ instantiate_link(new_model, "Inheritance", "", "Pre_" + key, "Pre_Element")
|
|
|
+ instantiate_link(new_model, "Inheritance", "", "Post_" + key, "Post_Element")
|
|
|
|
|
|
elif (type_name == "Inheritance"):
|
|
|
old_source = reverseKeyLookup(model["model"], read_edge_src(entry))
|
|
|
old_target = reverseKeyLookup(model["model"], read_edge_dst(entry))
|
|
|
- instantiate_link(new_model, type_name, append + key, append + old_source, append + old_target)
|
|
|
+ instantiate_link(new_model, type_name, "Pre_" + key, "Pre_" + old_source, "Pre_" + old_target)
|
|
|
+ instantiate_link(new_model, type_name, "Post_" + key, "Post_" + old_source, "Post_" + old_target)
|
|
|
|
|
|
elif (bool_not(has_value(entry))):
|
|
|
create_edge(to_link, entry)
|
|
@@ -183,21 +166,96 @@ Element function ramify_func(model : Element, prepost : String):
|
|
|
old_source = reverseKeyLookup(model["model"], read_edge_src(entry))
|
|
|
if (bool_or(bool_or(name == "name", name == "upper_cardinality"), bool_or(name == "source_upper_cardinality", name == "target_upper_cardinality"))):
|
|
|
// Keep the old name for the physical attributes!
|
|
|
- instantiate_attribute(new_model, append + old_source, name, read_edge_dst(entry))
|
|
|
+ instantiate_attribute(new_model, "Pre_" + old_source, name, read_edge_dst(entry))
|
|
|
+ instantiate_attribute(new_model, "Post_" + old_source, name, read_edge_dst(entry))
|
|
|
else:
|
|
|
// Rename the attributes as well
|
|
|
- instantiate_attribute(new_model, append + old_source, append + name, read_edge_dst(entry))
|
|
|
+ instantiate_attribute(new_model, "Pre_" + old_source, "Pre_" + name, read_edge_dst(entry))
|
|
|
+ instantiate_attribute(new_model, "Post_" + old_source, "Post_" + name, read_edge_dst(entry))
|
|
|
|
|
|
- return new_model!
|
|
|
+ // Define schedule over these elements
|
|
|
|
|
|
-Element function ramify(model : Element):
|
|
|
- Element rv
|
|
|
- rv = create_node()
|
|
|
+ // Class Entry {}
|
|
|
+ instantiate_node(new_model, "Class", "Entry")
|
|
|
+
|
|
|
+ // Class Success : Entry {}
|
|
|
+ instantiate_node(new_model, "Class", "Success")
|
|
|
+ instantiate_link(new_model, "Inheritance", "", "Success", "Entry")
|
|
|
+
|
|
|
+ // Class Failure : Entry {}
|
|
|
+ instantiate_node(new_model, "Class", "Failure")
|
|
|
+ instantiate_link(new_model, "Inheritance", "", "Failure", "Entry")
|
|
|
|
|
|
- // Create Pre part
|
|
|
- dict_add(rv, "pre", ramify_func(model, "pre"))
|
|
|
+ // Class Rule : Entry {}
|
|
|
+ instantiate_node(new_model, "Class", "Rule")
|
|
|
+ instantiate_link(new_model, "Inheritance", "", "Rule", "Entry")
|
|
|
|
|
|
- // Create Post part
|
|
|
- dict_add(rv, "post", ramify_func(model, "post"))
|
|
|
+ // Association OnSuccess(Rule, Entry){
|
|
|
+ // target_lower_cardinality = 1
|
|
|
+ // target_upper_cardinality = 1
|
|
|
+ // }
|
|
|
+ instantiate_link(new_model, "Association", "OnSuccess", "Rule", "Entry")
|
|
|
+ instantiate_attribute(new_model, "OnSuccess", "target_lower_cardinality", 1)
|
|
|
+ instantiate_attribute(new_model, "OnSuccess", "target_upper_cardinality", 1)
|
|
|
|
|
|
- return rv!
|
|
|
+ // Association OnFailure(Rule, Entry){
|
|
|
+ // target_lower_cardinality = 1
|
|
|
+ // target_upper_cardinality = 1
|
|
|
+ // }
|
|
|
+ instantiate_link(new_model, "Association", "OnFailure", "Rule", "Entry")
|
|
|
+ instantiate_attribute(new_model, "OnFailure", "target_lower_cardinality", 1)
|
|
|
+ instantiate_attribute(new_model, "OnFailure", "target_upper_cardinality", 1)
|
|
|
+
|
|
|
+ // Class Query : Rule {}
|
|
|
+ instantiate_node(new_model, "Class", "Query")
|
|
|
+ instantiate_link(new_model, "Inheritance", "", "Query", "Rule")
|
|
|
+
|
|
|
+ // Association QueryLHS (Query, LHS) {
|
|
|
+ // target_lower_cardinality = 1
|
|
|
+ // target_upper_cardinality = 1
|
|
|
+ // }
|
|
|
+ instantiate_link(new_model, "Association", "QueryLHS", "Query", "LHS")
|
|
|
+ instantiate_attribute(new_model, "QueryLHS", "target_lower_cardinality", 1)
|
|
|
+ instantiate_attribute(new_model, "QueryLHS", "target_upper_cardinality", 1)
|
|
|
+
|
|
|
+ // Class Atomic : Rule {}
|
|
|
+ instantiate_node(new_model, "Class", "Atomic")
|
|
|
+ instantiate_link(new_model, "Inheritance", "", "Atomic", "Rule")
|
|
|
+
|
|
|
+ // Association AtomicLHS (Atomic, LHS) {
|
|
|
+ // target_lower_cardinality = 1
|
|
|
+ // target_upper_cardinality = 1
|
|
|
+ // }
|
|
|
+ instantiate_link(new_model, "Association", "AtomicLHS", "Atomic", "LHS")
|
|
|
+ instantiate_attribute(new_model, "AtomicLHS", "target_lower_cardinality", 1)
|
|
|
+ instantiate_attribute(new_model, "AtomicLHS", "target_upper_cardinality", 1)
|
|
|
+
|
|
|
+ // Association AtomicRHS (Atomic, RHS) {
|
|
|
+ // target_lower_cardinality = 1
|
|
|
+ // target_upper_cardinality = 1
|
|
|
+ // }
|
|
|
+ instantiate_link(new_model, "Association", "AtomicRHS", "Atomic", "RHS")
|
|
|
+ instantiate_attribute(new_model, "AtomicRHS", "target_lower_cardinality", 1)
|
|
|
+ instantiate_attribute(new_model, "AtomicRHS", "target_upper_cardinality", 1)
|
|
|
+
|
|
|
+ // Class Composite : Rule {}
|
|
|
+ instantiate_node(new_model, "Class", "Composite")
|
|
|
+ instantiate_link(new_model, "Inheritance", "", "Composite", "Rule")
|
|
|
+
|
|
|
+ // Association Initial(Composite, Entry){
|
|
|
+ // target_lower_cardinality = 1
|
|
|
+ // target_upper_cardinality = 1
|
|
|
+ // }
|
|
|
+ instantiate_link(new_model, "Association", "Initial", "Composite", "Entry")
|
|
|
+ instantiate_attribute(new_model, "Initial", "target_lower_cardinality", 1)
|
|
|
+ instantiate_attribute(new_model, "Initial", "target_upper_cardinality", 1)
|
|
|
+
|
|
|
+ // Association Contains(Composite, Entry){
|
|
|
+ // source_upper_cardinality = 1
|
|
|
+ // target_lower_cardinality = 1
|
|
|
+ // }
|
|
|
+ instantiate_link(new_model, "Association", "Contains", "Composite", "Entry")
|
|
|
+ instantiate_attribute(new_model, "Contains", "source_upper_cardinality", 1)
|
|
|
+ instantiate_attribute(new_model, "Contains", "target_lower_cardinality", 1)
|
|
|
+
|
|
|
+ return new_model!
|