|
@@ -128,6 +128,7 @@ Boolean function main(model : Element):
|
|
|
// For "delete" edges, we match using "RD" and "RDE"
|
|
|
Element create_edges
|
|
|
Element all_nodes
|
|
|
+ Element assigned
|
|
|
|
|
|
log("Matching rule " + rule)
|
|
|
nodes = allAssociationDestinations(model, rule, "Rules/contains")
|
|
@@ -135,6 +136,10 @@ Boolean function main(model : Element):
|
|
|
|
|
|
create_edges = set_create()
|
|
|
explored = set_create()
|
|
|
+ assigned = set_create()
|
|
|
+ // Username is always assigned in the beginning
|
|
|
+ set_add(assigned, "username")
|
|
|
+ set_add(assigned, "taskname")
|
|
|
while (set_len(nodes) > 0):
|
|
|
node = set_pop(nodes)
|
|
|
if (read_type(model, node) == "Rules/Root"):
|
|
@@ -176,31 +181,36 @@ Boolean function main(model : Element):
|
|
|
result = result + "\t" + destination + "_DEL, = yield [('RDNE', [" + source + ", " + string_replace(node_key, "/", "_") + "])]\n"
|
|
|
result = result + "\tyield [('DE', [" + destination + "_DEL])]\n"
|
|
|
else:
|
|
|
- if (set_in(explored, new_node)):
|
|
|
- // Already visited this one in another way, so try to merge!
|
|
|
- String rand
|
|
|
- rand = random_string(10)
|
|
|
- result = result + "\t" + rand + ", = yield [('RD', [" + source + ", " + name + "])]\n"
|
|
|
- result = result + "\t" + "if " + rand + " != " + destination + ":\n"
|
|
|
- // If the values don't agree, this is not a correct match, and we say that this element remains unmatched (i.e., assign None)
|
|
|
- result = result + "\t" + "\t" + destination + " = None\n"
|
|
|
+ if (bool_or(string_get(name, 0) == "'", set_in(assigned, name))):
|
|
|
+ if (set_in(explored, new_node)):
|
|
|
+ // Already visited this one in another way, so try to merge!
|
|
|
+ String rand
|
|
|
+ rand = random_string(10)
|
|
|
+ result = result + "\t" + rand + ", = yield [('RD', [" + source + ", " + name + "])]\n"
|
|
|
+ result = result + "\t" + "if " + rand + " != " + destination + ":\n"
|
|
|
+ // If the values don't agree, this is not a correct match, and we say that this element remains unmatched (i.e., assign None)
|
|
|
+ result = result + "\t" + "\t" + destination + " = None\n"
|
|
|
+ else:
|
|
|
+ // First visit to this element, so just assign
|
|
|
+ result = result + "\t" + destination + ", = yield [('RD', [" + source + ", " + name + "])]\n"
|
|
|
+
|
|
|
+ String value
|
|
|
+ value = read_attribute(model, new_node, "value")
|
|
|
+ if (element_neq(value, read_root())):
|
|
|
+ // Match node has a value we should compare as well!
|
|
|
+ // Read out the value from the Modelverse
|
|
|
+ if (bool_and(string_get(value, 0) != "!", string_get(value, 0) != "'")):
|
|
|
+ result = result + "\t" + value + ", = yield [('RV', [" + destination + "])]\n"
|
|
|
+ set_add(assigned, value)
|
|
|
+
|
|
|
+ set_add(to_explore, new_node)
|
|
|
+
|
|
|
+ if (read_type(model, edge) == "Rules/DeleteEdge"):
|
|
|
+ // Delete edge
|
|
|
+ result = result + "\t" + destination + "_DEL, = yield [('RDE', [" + source + ", " + name + "])]\n"
|
|
|
+ result = result + "\tyield [('DE', [" + destination + "_DEL])]\n"
|
|
|
else:
|
|
|
- // First visit to this element, so just assign
|
|
|
- result = result + "\t" + destination + ", = yield [('RD', [" + source + ", " + name + "])]\n"
|
|
|
-
|
|
|
- String value
|
|
|
- value = read_attribute(model, new_node, "value")
|
|
|
- if (element_neq(value, read_root())):
|
|
|
- // Match node has a value we should compare as well!
|
|
|
- // Read out the value from the Modelverse
|
|
|
- result = result + "\t" + destination + "_V, = yield [('RV', [" + destination + "])]\n"
|
|
|
-
|
|
|
- set_add(to_explore, new_node)
|
|
|
-
|
|
|
- if (read_type(model, edge) == "Rules/DeleteEdge"):
|
|
|
- // Delete edge
|
|
|
- result = result + "\t" + destination + "_DEL, = yield [('RDE', [" + source + ", " + name + "])]\n"
|
|
|
- result = result + "\tyield [('DE', [" + destination + "_DEL])]\n"
|
|
|
+ set_add(remainder_to_explore, node)
|
|
|
|
|
|
if (bool_and(set_len(to_explore) == 0, set_len(remainder_to_explore) > 0)):
|
|
|
to_explore = remainder_to_explore
|