|
@@ -123,3 +123,49 @@ Element function model_retype_on_name(model : Element, new_MM : Element, operati
|
|
|
dict_add(model, "metamodel", new_MM)
|
|
|
|
|
|
return model!
|
|
|
+
|
|
|
+Void function model_join(dst_model : Element, src_model : Element, retyping_key : String):
|
|
|
+ Element queue
|
|
|
+ Element mapping
|
|
|
+ String name
|
|
|
+ String type
|
|
|
+ String src
|
|
|
+ String dst
|
|
|
+
|
|
|
+ queue = set_to_list(dict_keys(src_model["model"]))
|
|
|
+ mapping = create_node()
|
|
|
+
|
|
|
+ while (read_nr_out(queue) > 0):
|
|
|
+ name = list_pop(queue, 0)
|
|
|
+
|
|
|
+ if (is_edge(src_model["model"][name])):
|
|
|
+ // Is an edge, so potentially queue it
|
|
|
+ String src
|
|
|
+ String dst
|
|
|
+
|
|
|
+ src = reverseKeyLookup(src_model["model"], read_edge_src(src_model["model"][name]))
|
|
|
+ dst = reverseKeyLookup(src_model["model"], read_edge_dst(src_model["model"][name]))
|
|
|
+ type = reverseKeyLookup(src_model["metamodel"]["model"], dict_read_node(src_model["type_mapping"], src_model["model"][name]))
|
|
|
+
|
|
|
+ if (bool_and(dict_in(mapping, src), dict_in(mapping, dst))):
|
|
|
+ // All present, so create the link between them
|
|
|
+ dict_add(mapping, name, instantiate_link(dst_model, retyping_key + type, "", mapping[src], mapping[dst]))
|
|
|
+ else:
|
|
|
+ list_append(queue, name)
|
|
|
+
|
|
|
+ elif (has_value(src_model["model"][name])):
|
|
|
+ // Has a value, so copy that as well
|
|
|
+ type = reverseKeyLookup(src_model["metamodel"]["model"], dict_read_node(src_model["type_mapping"], src_model["model"][name]))
|
|
|
+ dict_add(mapping, name, instantiate_value(dst_model, retyping_key + type, "", src_model["model"][name]))
|
|
|
+
|
|
|
+ else:
|
|
|
+ // Is a node
|
|
|
+ type = reverseKeyLookup(src_model["metamodel"]["model"], dict_read_node(src_model["type_mapping"], src_model["model"][name]))
|
|
|
+ dict_add(mapping, name, instantiate_node(dst_model, retyping_key + type, ""))
|
|
|
+
|
|
|
+ return!
|
|
|
+
|
|
|
+Element function model_split(source_model : Element, target_metamodel : Element, retyping_key : String):
|
|
|
+ Element model
|
|
|
+
|
|
|
+ return model!
|