|
@@ -11,6 +11,8 @@ Element function get_type_mapping(model : Element):
|
|
|
Element edge
|
|
|
Element keys
|
|
|
String key
|
|
|
+ String m_name
|
|
|
+ String mm_name
|
|
|
|
|
|
keys = dict_keys(model["type_mapping"])
|
|
|
|
|
@@ -20,9 +22,11 @@ Element function get_type_mapping(model : Element):
|
|
|
mm = model["metamodel"]["model"][model["type_mapping"][key]]
|
|
|
edge = create_edge(m, mm)
|
|
|
|
|
|
- dict_add_fast(tm_model, cast_id(m), m)
|
|
|
- if (bool_not(dict_in(tm_model, cast_id(mm)))):
|
|
|
- dict_add_fast(tm_model, cast_id(mm), mm)
|
|
|
+ m_name = "instance_" + key
|
|
|
+ mm_name = "type_" + cast_string(model["type_mapping"][key])
|
|
|
+ dict_add_fast(tm_model, m_name, m)
|
|
|
+ if (bool_not(dict_in(tm_model, mm_name))):
|
|
|
+ dict_add_fast(tm_model, mm_name, mm)
|
|
|
dict_add_fast(tm_model, cast_id(edge), edge)
|
|
|
|
|
|
return tm_model!
|
|
@@ -30,24 +34,41 @@ Element function get_type_mapping(model : Element):
|
|
|
Void function set_type_mapping(model : Element, type_mapping_model : Element):
|
|
|
// Serialize model to dictionary
|
|
|
Element type_mapping
|
|
|
- Element rev_model
|
|
|
- Element rev_metamodel
|
|
|
Element keys
|
|
|
String key
|
|
|
+ String source_name
|
|
|
+ String destination_name
|
|
|
+ String tmp_source_name
|
|
|
+ String tmp_destination_name
|
|
|
+ Element lookups
|
|
|
|
|
|
type_mapping = dict_create()
|
|
|
keys = dict_keys(type_mapping_model)
|
|
|
- rev_model = make_reverse_dictionary(model["model"])
|
|
|
- rev_metamodel = make_reverse_dictionary(model["metamodel"]["model"])
|
|
|
|
|
|
while (set_len(keys) > 0):
|
|
|
key = set_pop(keys)
|
|
|
if (is_edge(type_mapping_model[key])):
|
|
|
- if (bool_not(bool_or(dict_in(rev_model, cast_id(type_mapping_model[key])), dict_in(rev_metamodel, cast_id(type_mapping_model[key]))))):
|
|
|
+ lookups = reverseKeyLookupMultiID(type_mapping_model, read_edge_src(type_mapping_model[key]))
|
|
|
+ source_name = ""
|
|
|
+ while (set_len(lookups) > 0):
|
|
|
+ tmp_source_name = set_pop(lookups)
|
|
|
+ if (string_startswith(tmp_source_name, "instance_")):
|
|
|
+ source_name = string_replace(tmp_source_name, "instance_", "")
|
|
|
+ break!
|
|
|
+
|
|
|
+ lookups = reverseKeyLookupMultiID(type_mapping_model, read_edge_dst(type_mapping_model[key]))
|
|
|
+ destination_name = ""
|
|
|
+ while (set_len(lookups) > 0):
|
|
|
+ tmp_destination_name = set_pop(lookups)
|
|
|
+ if (string_startswith(tmp_destination_name, "type_")):
|
|
|
+ destination_name = string_replace(tmp_destination_name, "type_", "")
|
|
|
+ break!
|
|
|
+
|
|
|
+ if (bool_and(dict_in(model["model"], source_name), dict_in(model["metamodel"]["model"], destination_name))):
|
|
|
// Element is in neither model or metamodel
|
|
|
// Must be a typing link!
|
|
|
// So add it
|
|
|
- dict_add_fast(type_mapping, rev_model[cast_id(read_edge_src(type_mapping_model[key]))], rev_metamodel[cast_id(read_edge_dst(type_mapping_model[key]))])
|
|
|
+ dict_add_fast(type_mapping, source_name, destination_name)
|
|
|
|
|
|
dict_overwrite(model, "type_mapping", type_mapping)
|
|
|
return!
|
|
@@ -58,7 +79,7 @@ Element function elements_typed_by(model : Element, type_name : String):
|
|
|
String temp
|
|
|
|
|
|
result = set_create()
|
|
|
- temp_result = reverseKeyLookupMulti(get_type_mapping_as_dict(model), type_name)
|
|
|
+ temp_result = reverseKeyLookupMultiValue(get_type_mapping_as_dict(model), type_name)
|
|
|
while (set_len(temp_result) > 0):
|
|
|
temp = set_pop(temp_result)
|
|
|
if (dict_in(model["model"], temp)):
|