|
@@ -32,11 +32,6 @@ Boolean function find_type_mapping(model : Element):
|
|
|
// 2) find a mapping based on the current partial mapping, but only if it is not yet complete
|
|
// 2) find a mapping based on the current partial mapping, but only if it is not yet complete
|
|
|
// TODO this must be expanded for other things than trivial metamodels!
|
|
// TODO this must be expanded for other things than trivial metamodels!
|
|
|
if (dict_len(model["model"]) > dict_len(tm)):
|
|
if (dict_len(model["model"]) > dict_len(tm)):
|
|
|
- log("Model is incompletely typed!")
|
|
|
|
|
- log("Model has: " + set_to_string(dict_keys(model["model"])))
|
|
|
|
|
- log("Type mapping has: " + set_to_string(dict_keys(tm)))
|
|
|
|
|
- log("Difference: " + set_to_string(set_difference(dict_keys(model["model"]), dict_keys(tm))))
|
|
|
|
|
-
|
|
|
|
|
// TODO for now, this only returns something for a simple case, where the MM has one edge, and one node
|
|
// TODO for now, this only returns something for a simple case, where the MM has one edge, and one node
|
|
|
// and it makes the assumption that SCD is the M3 level...
|
|
// and it makes the assumption that SCD is the M3 level...
|
|
|
|
|
|
|
@@ -53,14 +48,11 @@ Boolean function find_type_mapping(model : Element):
|
|
|
nodes = allInstances(model["metamodel"], "Class")
|
|
nodes = allInstances(model["metamodel"], "Class")
|
|
|
edges = allInstances(model["metamodel"], "Association")
|
|
edges = allInstances(model["metamodel"], "Association")
|
|
|
|
|
|
|
|
- log("Searching for type...")
|
|
|
|
|
if (bool_and(set_len(edges) == 1, set_len(nodes) == 1)):
|
|
if (bool_and(set_len(edges) == 1, set_len(nodes) == 1)):
|
|
|
// Simple allocation: this seems like conformance bottom
|
|
// Simple allocation: this seems like conformance bottom
|
|
|
node_source_element = set_pop(nodes)
|
|
node_source_element = set_pop(nodes)
|
|
|
node_target_element = node_source_element
|
|
node_target_element = node_source_element
|
|
|
edge_element = set_pop(edges)
|
|
edge_element = set_pop(edges)
|
|
|
- log("Found node: " + node_source_element)
|
|
|
|
|
- log("Found edge: " + edge_element)
|
|
|
|
|
|
|
|
|
|
elif (bool_and(set_len(edges) == 1, set_len(nodes) == 2)):
|
|
elif (bool_and(set_len(edges) == 1, set_len(nodes) == 2)):
|
|
|
// Simple allocation: this seems like a type mapping
|
|
// Simple allocation: this seems like a type mapping
|
|
@@ -70,13 +62,9 @@ Boolean function find_type_mapping(model : Element):
|
|
|
node_target_element = readAssociationDestination(model["metamodel"], edge_element)
|
|
node_target_element = readAssociationDestination(model["metamodel"], edge_element)
|
|
|
|
|
|
|
|
if (value_eq(node_source_element, node_target_element)):
|
|
if (value_eq(node_source_element, node_target_element)):
|
|
|
- log("Source and target are the same, meaning that the second node is unknown")
|
|
|
|
|
|
|
+ log("Could not automatically deduce mapping in a trivial way!")
|
|
|
return False!
|
|
return False!
|
|
|
|
|
|
|
|
- log("Found edge: " + edge_element)
|
|
|
|
|
- log("Found source node: " + node_source_element)
|
|
|
|
|
- log("Found target node: " + node_target_element)
|
|
|
|
|
-
|
|
|
|
|
else:
|
|
else:
|
|
|
log("Could not automatically deduce mapping in a trivial way!")
|
|
log("Could not automatically deduce mapping in a trivial way!")
|
|
|
return False!
|
|
return False!
|
|
@@ -84,7 +72,6 @@ Boolean function find_type_mapping(model : Element):
|
|
|
|
|
|
|
|
// Now we have both an edge_element and node_element of the metamodel
|
|
// Now we have both an edge_element and node_element of the metamodel
|
|
|
// Now just trivially bind all elements!
|
|
// Now just trivially bind all elements!
|
|
|
- log("Searching for type...")
|
|
|
|
|
elems = dict_keys(model["model"])
|
|
elems = dict_keys(model["model"])
|
|
|
while (set_len(elems) > 0):
|
|
while (set_len(elems) > 0):
|
|
|
elem = set_pop(elems)
|
|
elem = set_pop(elems)
|
|
@@ -92,13 +79,10 @@ Boolean function find_type_mapping(model : Element):
|
|
|
if (bool_and(is_edge(model["model"][elem]), read_nr_out(model["model"][elem]) == 0)):
|
|
if (bool_and(is_edge(model["model"][elem]), read_nr_out(model["model"][elem]) == 0)):
|
|
|
// An edge, and there is always exactly one, so type
|
|
// An edge, and there is always exactly one, so type
|
|
|
retype(model, elem, edge_element)
|
|
retype(model, elem, edge_element)
|
|
|
- log("Type " + elem + " as " + edge_element)
|
|
|
|
|
|
|
|
|
|
// The source and target are ALWAYS typed as well!
|
|
// The source and target are ALWAYS typed as well!
|
|
|
retype(model, readAssociationSource(model, elem), node_source_element)
|
|
retype(model, readAssociationSource(model, elem), node_source_element)
|
|
|
- log("Type " + readAssociationSource(model, elem) + " as " + node_source_element)
|
|
|
|
|
retype(model, readAssociationDestination(model, elem), node_target_element)
|
|
retype(model, readAssociationDestination(model, elem), node_target_element)
|
|
|
- log("Type " + readAssociationDestination(model, elem) + " as " + node_target_element)
|
|
|
|
|
elif (node_source_element == node_target_element):
|
|
elif (node_source_element == node_target_element):
|
|
|
// A node, and we are sure that there is only one
|
|
// A node, and we are sure that there is only one
|
|
|
retype(model, elem, node_source_element)
|
|
retype(model, elem, node_source_element)
|