|
@@ -57,10 +57,49 @@ Element function make_matching_schedule(LHS_model : Element):
|
|
|
|
|
|
Element function get_possible_bindings(host_model : Element, LHS_model : Element, current_element : String, map : Element):
|
|
Element function get_possible_bindings(host_model : Element, LHS_model : Element, current_element : String, map : Element):
|
|
Element options
|
|
Element options
|
|
|
|
+ String src_label
|
|
|
|
+ String dst_label
|
|
|
|
+ String typename
|
|
|
|
+ String original_typename
|
|
|
|
|
|
- output("FIND BINDING")
|
|
|
|
|
|
+ log("FIND BINDING")
|
|
options = create_node()
|
|
options = create_node()
|
|
|
|
|
|
|
|
+ typename = reverseKeyLookup(LHS_model["metamodel"]["model"], dict_read_node(LHS_model["type_mapping"], LHS_model["model"][current_element]))
|
|
|
|
+ original_typename = string_substr(typename, 4, string_len(typename))
|
|
|
|
+ log("Found type: " + typename)
|
|
|
|
+ log("Original type: " + original_typename)
|
|
|
|
+
|
|
|
|
+ if (is_edge(LHS_model["model"][current_element])):
|
|
|
|
+ // Is an edge, so check for already bound source/target
|
|
|
|
+ src_label = read_attribute(LHS_model, reverseKeyLookup(LHS_model["model"], read_edge_src(LHS_model["model"][current_element])), "label")
|
|
|
|
+ dst_label = read_attribute(LHS_model, reverseKeyLookup(LHS_model["model"], read_edge_dst(LHS_model["model"][current_element])), "label")
|
|
|
|
+
|
|
|
|
+ if (bool_and(set_in(dict_keys(map), src_label), set_in(dict_keys(map), dst_label))):
|
|
|
|
+ // Source and destination are bound
|
|
|
|
+ options = allOutgoingAssociationInstances(host_model, map[src_label], original_typename)
|
|
|
|
+ options = set_overlap(options, allIncomingAssociationInstances(host_model, map[src_label], original_typename))
|
|
|
|
+
|
|
|
|
+ elif (set_in(dict_keys(map), src_label)):
|
|
|
|
+ // Source is bound
|
|
|
|
+ options = allOutgoingAssociationInstances(host_model, map[src_label], original_typename)
|
|
|
|
+
|
|
|
|
+ elif (set_in(dict_keys(map), dst_label)):
|
|
|
|
+ // Destination is bound
|
|
|
|
+ options = allIncomingAssociationInstances(host_model, map[src_label], original_typename)
|
|
|
|
+
|
|
|
|
+ else:
|
|
|
|
+ // Neither is bound, so just get all of them
|
|
|
|
+ log("ERROR: unbound source/target for association!")
|
|
|
|
+ return create_node()!
|
|
|
|
+ else:
|
|
|
|
+ // Is a node, so check for already bound incoming/outgoing
|
|
|
|
+ options = allInstances(host_model, original_typename)
|
|
|
|
+
|
|
|
|
+ // Filter out duplicate matches from the map
|
|
|
|
+
|
|
|
|
+ // Filter out based on local constraints
|
|
|
|
+
|
|
return options!
|
|
return options!
|
|
|
|
|
|
Element function match(host_model : Element, LHS_model : Element):
|
|
Element function match(host_model : Element, LHS_model : Element):
|
|
@@ -88,15 +127,15 @@ Element function match(host_model : Element, LHS_model : Element):
|
|
|
|
|
|
while (read_nr_out(mappings) > 0):
|
|
while (read_nr_out(mappings) > 0):
|
|
map = set_pop(mappings)
|
|
map = set_pop(mappings)
|
|
- log("In context " + set_to_string(map))
|
|
|
|
|
|
+ log("In context " + dict_to_string(map))
|
|
options = get_possible_bindings(host_model, LHS_model, current_element, map)
|
|
options = get_possible_bindings(host_model, LHS_model, current_element, map)
|
|
log("Found options " + set_to_string(options))
|
|
log("Found options " + set_to_string(options))
|
|
|
|
|
|
while (read_nr_out(options) > 0):
|
|
while (read_nr_out(options) > 0):
|
|
option = set_pop(options)
|
|
option = set_pop(options)
|
|
- new_map = set_copy(map)
|
|
|
|
- dict_add(new_map, current_element, option)
|
|
|
|
- log(" --> adding mapping " + set_to_string(new_map))
|
|
|
|
|
|
+ new_map = dict_copy(map)
|
|
|
|
+ dict_add(new_map, read_attribute(LHS_model, current_element, "label"), option)
|
|
|
|
+ log(" --> adding mapping " + dict_to_string(new_map))
|
|
set_add(new_mappings, new_map)
|
|
set_add(new_mappings, new_map)
|
|
|
|
|
|
mappings = new_mappings
|
|
mappings = new_mappings
|