|
@@ -67,77 +67,59 @@ Element function get_possible_bindings(host_model : Element, schedule_model : El
|
|
|
String original_typename
|
|
|
|
|
|
options = create_node()
|
|
|
- log("Finding possible bindings for: " + current_element)
|
|
|
- log(" knowing: " + dict_to_string(map))
|
|
|
|
|
|
typename = reverseKeyLookup(schedule_model["metamodel"]["model"], dict_read_node(schedule_model["type_mapping"], schedule_model["model"][current_element]))
|
|
|
original_typename = string_substr(typename, 4, string_len(typename))
|
|
|
|
|
|
if (is_edge(schedule_model["model"][current_element])):
|
|
|
- log("Is edge!")
|
|
|
// Is an edge, so check for already bound source/target
|
|
|
src_label = read_attribute(schedule_model, reverseKeyLookup(schedule_model["model"], read_edge_src(schedule_model["model"][current_element])), "label")
|
|
|
dst_label = read_attribute(schedule_model, reverseKeyLookup(schedule_model["model"], read_edge_dst(schedule_model["model"][current_element])), "label")
|
|
|
- log("SRC: " + src_label)
|
|
|
- log("DST: " + dst_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[dst_label], original_typename))
|
|
|
- log("Overlap!")
|
|
|
|
|
|
elif (set_in(dict_keys(map), src_label)):
|
|
|
// Source is bound
|
|
|
options = allOutgoingAssociationInstances(host_model, map[src_label], original_typename)
|
|
|
- log("Source")
|
|
|
|
|
|
elif (set_in(dict_keys(map), dst_label)):
|
|
|
// Destination is bound
|
|
|
options = allIncomingAssociationInstances(host_model, map[dst_label], original_typename)
|
|
|
- log("Destination")
|
|
|
|
|
|
else:
|
|
|
// Neither is bound, so just get all of them
|
|
|
log("ERROR: unbound source/target for association!")
|
|
|
+ //TODO should actually return all
|
|
|
return create_node()!
|
|
|
else:
|
|
|
// Is a node, so find whether or not there are some connections that are already resolved
|
|
|
- // TODO check implementation
|
|
|
- log("Is node!")
|
|
|
Element ic
|
|
|
Element oc
|
|
|
String poll
|
|
|
|
|
|
ic = allIncomingAssociationInstances(schedule_model, current_element, "Pre_Element")
|
|
|
oc = allOutgoingAssociationInstances(schedule_model, current_element, "Pre_Element")
|
|
|
- log("Incoming: " + set_to_string(ic))
|
|
|
- log("Outgoing: " + set_to_string(oc))
|
|
|
|
|
|
- log("Search in")
|
|
|
while (bool_and(read_nr_out(ic) > 0, read_nr_out(options) == 0)):
|
|
|
poll = set_pop(ic)
|
|
|
if (dict_in(map, read_attribute(schedule_model, poll, "label"))):
|
|
|
// This incoming link is already defined, so we just have one option: the destination of the link we matched
|
|
|
set_add(options, readAssociationDestination(host_model, map[read_attribute(schedule_model, poll, "label")]))
|
|
|
- log("Found mapped incoming: " + poll)
|
|
|
|
|
|
- log("Search out")
|
|
|
while (bool_and(read_nr_out(oc) > 0, read_nr_out(options) == 0)):
|
|
|
poll = set_pop(oc)
|
|
|
if (dict_in(map, read_attribute(schedule_model, poll, "label"))):
|
|
|
// This incoming link is already defined, so we just have one option: the destination of the link we matched
|
|
|
set_add(options, readAssociationSource(host_model, map[read_attribute(schedule_model, poll, "label")]))
|
|
|
- log("Found mapped outgoing: " + poll)
|
|
|
|
|
|
- log("Done")
|
|
|
if (read_nr_out(options) == 0):
|
|
|
// Is a node and no connections, so we just pick all options
|
|
|
- log("None found, revert to all")
|
|
|
options = allInstances(host_model, original_typename)
|
|
|
elif (read_nr_out(options) > 1):
|
|
|
// Multiple "only" options, which will not work out: no options!
|
|
|
- log("Multiple found; halting")
|
|
|
return create_node()!
|
|
|
|
|
|
// Filter options further
|
|
@@ -165,7 +147,6 @@ Element function get_possible_bindings(host_model : Element, schedule_model : El
|
|
|
if (result):
|
|
|
set_add(filtered_options, option)
|
|
|
|
|
|
- log(" options: " + set_to_string(filtered_options))
|
|
|
return filtered_options!
|
|
|
|
|
|
Element function match(host_model : Element, schedule_model : Element, LHS : Element):
|
|
@@ -409,9 +390,7 @@ Boolean function transform_forall(host_model : Element, schedule_model : Element
|
|
|
result = False
|
|
|
|
|
|
while (read_nr_out(mappings) > 0):
|
|
|
- log("Executing " + current)
|
|
|
mapping = set_pop(mappings)
|
|
|
- log("For mapping: " + dict_to_string(mapping))
|
|
|
// TODO check if there are actually no deletions happening in the meantime of other matched elements...
|
|
|
RHS = set_pop(allAssociationDestinations(schedule_model, current, "AtomicRHS"))
|
|
|
rewrite(host_model, schedule_model, RHS, mapping)
|