|
@@ -161,6 +161,7 @@ Element function model_join(models : Element, metamodel : Element, tracability_m
|
|
|
while (read_nr_out(models) > 0):
|
|
|
tagged_model = set_pop(models)
|
|
|
retyping_key = string_join(list_read(tagged_model, 0), "/")
|
|
|
+ log("Retyping key: " + retyping_key)
|
|
|
model = list_read(tagged_model, 1)
|
|
|
|
|
|
// Add all elements from 'model'
|
|
@@ -196,6 +197,7 @@ Element function model_join(models : Element, metamodel : Element, tracability_m
|
|
|
// Now link in the tracability model
|
|
|
// Go over all TracabilityLink elements and connect them in the merged model as well
|
|
|
|
|
|
+ log("Searching for tracability links to join")
|
|
|
if (element_neq(tracability_model, read_root())):
|
|
|
Element tracability_links
|
|
|
String tracability_link
|
|
@@ -203,17 +205,29 @@ Element function model_join(models : Element, metamodel : Element, tracability_m
|
|
|
String new_name_dst
|
|
|
|
|
|
tracability_links = allInstances(tracability_model, "TracabilityLink")
|
|
|
+ log("Got tracability links to link: " + cast_v2s(read_nr_out(tracability_links)))
|
|
|
|
|
|
while (read_nr_out(tracability_links) > 0):
|
|
|
tracability_link = set_pop(tracability_links)
|
|
|
+ log("Processing link " + cast_e2s(tracability_link))
|
|
|
+ log("In tracability model: " + cast_e2s(tracability_model["model"][tracability_link]))
|
|
|
|
|
|
// Get necessary information from the tracability link
|
|
|
+ log("Source: " + cast_id2s(read_edge_src(tracability_model["model"][tracability_link])))
|
|
|
+ log("Destination: " + cast_id2s(read_edge_dst(tracability_model["model"][tracability_link])))
|
|
|
+ log("Got elem map: " + set_to_string(dict_keys(elem_map)))
|
|
|
+
|
|
|
new_name_src = elem_map[cast_id2s(read_edge_src(tracability_model["model"][tracability_link]))]
|
|
|
new_name_dst = elem_map[cast_id2s(read_edge_dst(tracability_model["model"][tracability_link]))]
|
|
|
type = read_attribute(tracability_model, tracability_link, "type")
|
|
|
|
|
|
+ log("Link element from " + new_name_src)
|
|
|
+ log("Link element fo " + new_name_dst)
|
|
|
+ log("Of type: " + type)
|
|
|
+
|
|
|
// Connect the two with the info we have
|
|
|
new_name = instantiate_link(new_model, type, "", new_name_src, new_name_dst)
|
|
|
+ log("New name of link: " + new_name)
|
|
|
|
|
|
if (new_name == ""):
|
|
|
log("ERROR: could not create a tracability link; ignoring")
|
|
@@ -245,6 +259,8 @@ Element function model_split(merged_model : Element, models : Element, tracabili
|
|
|
String source
|
|
|
String target
|
|
|
String link
|
|
|
+ String src_name
|
|
|
+ String dst_name
|
|
|
|
|
|
result = create_node()
|
|
|
tracability_model = instantiate_model(import_node("models/Tracability"))
|
|
@@ -272,16 +288,35 @@ Element function model_split(merged_model : Element, models : Element, tracabili
|
|
|
// Got a tracability link!
|
|
|
// Is always an edge (for now?)
|
|
|
// Find out source and target and hope that they are already present
|
|
|
-
|
|
|
+ log("Create tracability link in model!")
|
|
|
src = reverse[cast_id2s(read_edge_src(elem))]
|
|
|
dst = reverse[cast_id2s(read_edge_dst(elem))]
|
|
|
|
|
|
- // All present, so create the link between them
|
|
|
- source = reuse_element(tracability_model, "Reference", "", read_edge_src(elem))
|
|
|
- target = reuse_element(tracability_model, "Reference", "", read_edge_dst(elem))
|
|
|
+ src_name = list_read(string_split(read_type(merged_model, src), "/"), 0)
|
|
|
+ dst_name = list_read(string_split(read_type(merged_model, dst), "/"), 0)
|
|
|
+
|
|
|
+ log("Source model name: " + cast_v2s(src_name))
|
|
|
+ log("Destination model name: " + cast_v2s(dst_name))
|
|
|
+ log("Result: " + dict_to_string(result))
|
|
|
+
|
|
|
+ // Check if we actually keep both models around, as otherwise it is useless anyway
|
|
|
+ if (bool_and(dict_in(result, src_name), dict_in(result, dst_name))):
|
|
|
+ if (bool_and(dict_in(mapping, src), dict_in(mapping, dst))):
|
|
|
+ // All present, so create the link between them
|
|
|
+ Element src_model
|
|
|
+ Element dst_model
|
|
|
+
|
|
|
+ src_model = result[src_name]
|
|
|
+ dst_model = result[dst_name]
|
|
|
|
|
|
- link = instantiate_link(tracability_model, "TracabilityLink", "", source, target)
|
|
|
- instantiate_attribute(tracability_model, link, "type", type)
|
|
|
+ source = reuse_element(tracability_model, "Reference", "", src_model["model"][mapping[src]])
|
|
|
+ target = reuse_element(tracability_model, "Reference", "", dst_model["model"][mapping[dst]])
|
|
|
+
|
|
|
+ link = instantiate_link(tracability_model, "TracabilityLink", "", source, target)
|
|
|
+ instantiate_attribute(tracability_model, link, "type", type)
|
|
|
+ else:
|
|
|
+ // Not yet available!
|
|
|
+ set_add(second_keys, key)
|
|
|
else:
|
|
|
retyping_key = splitted[0]
|
|
|
|
|
@@ -320,5 +355,6 @@ Element function model_split(merged_model : Element, models : Element, tracabili
|
|
|
// Finally, we also add tracability information as a separate model
|
|
|
if (tracability):
|
|
|
dict_add_fast(result, "__tracability", tracability_model)
|
|
|
+ log("Tracability model created with # links = " + cast_v2s(read_nr_out(tracability_model["model"])))
|
|
|
|
|
|
return result!
|