|
|
@@ -569,21 +569,63 @@ Element function tf_executeRule(tf_er_transformation: Element,tf_er_rule: Elemen
|
|
|
|
|
|
return pivots
|
|
|
|
|
|
+Element function executeRuleBlock(transformation_model : Element,hostmodel:Element, ruleblock : Element, pivots:Element):
|
|
|
+ //execute the correct ruletype
|
|
|
+ //TODO define decent succes_value
|
|
|
+ String typename
|
|
|
+ typename = getTypeName(transformation_model, ruleblock)
|
|
|
+ Boolean succes
|
|
|
+ succes = False
|
|
|
+ Element Rule
|
|
|
+ if (typename == "RuleBlockRoot"):
|
|
|
+ // do nothing
|
|
|
+ log("start transformation")
|
|
|
+ succes = True
|
|
|
+ elif (typename == "ARule"):
|
|
|
+ log("running arule")
|
|
|
+ Rule = read_edge_dst(set_pop(allOutgoingAssociationInstances(transformation_model, ruleblock, transformation_model["metamodel"]["model"]["getrule"])))
|
|
|
+ log(getName(transformation_model, Rule))
|
|
|
+ pivots = tf_executeRule(transformation_model, Rule, hostmodel, pivots)
|
|
|
+ succes = True
|
|
|
+ elif (typename == "FRule"):
|
|
|
+ log("running frule")
|
|
|
+ Rule = read_edge_dst(set_pop(allOutgoingAssociationInstances(transformation_model, ruleblock, transformation_model["metamodel"]["model"]["getrule"])))
|
|
|
+ log(getName(transformation_model, Rule))
|
|
|
+ pivots = tf_executeRule(transformation_model, Rule, hostmodel, pivots)
|
|
|
+ succes = True
|
|
|
+ else:
|
|
|
+ log("RuleType is not supported yet")
|
|
|
+ //Return the next
|
|
|
+ Element next
|
|
|
+ if succes:
|
|
|
+ next = allOutgoingAssociationInstances(transformation_model, ruleblock, transformation_model["metamodel"]["model"]["next_onSucces"])
|
|
|
+ else:
|
|
|
+ next = allOutgoingAssociationInstances(transformation_model, ruleblock, transformation_model["metamodel"]["model"]["next_onFailure"])
|
|
|
+ if (read_nr_out(next) == 0):
|
|
|
+ log("No next defined")
|
|
|
+ next = transformation_model
|
|
|
+ else:
|
|
|
+ next = read_edge_dst(set_pop(next))
|
|
|
+
|
|
|
+ return next
|
|
|
+
|
|
|
Element function tf_transform(tf_tf_transformation: Element, tf_tf_model: Element):
|
|
|
//create a list of all rules
|
|
|
- Element tf_tf_rules
|
|
|
- tf_tf_rules = allInstances(tf_tf_transformation, dict_read(dict_read(dict_read(tf_tf_transformation, "metamodel"), "model"), "Rule"))
|
|
|
- //TODO give order to rules
|
|
|
- //execute rules in random order
|
|
|
- Element tf_tf_rule
|
|
|
- Element pivots
|
|
|
- pivots = create_node()
|
|
|
- while (integer_lt(0, read_nr_out(tf_tf_rules))):
|
|
|
- tf_tf_rule = set_pop(tf_tf_rules)
|
|
|
- //tf_printNode(tf_tf_transformation, tf_tf_rule)
|
|
|
- log("= EXECUTING RULE")
|
|
|
- log(getName(tf_tf_transformation, tf_tf_rule))
|
|
|
- pivots = tf_executeRule(tf_tf_transformation, tf_tf_rule, tf_tf_model, pivots)
|
|
|
+ Element ruleblock
|
|
|
+ ruleblock = allInstances(tf_tf_transformation, tf_tf_transformation["metamodel"]["model"]["RuleBlockRoot"])
|
|
|
+ if(read_nr_out(ruleblock) > 0):
|
|
|
+ ruleblock = set_pop(ruleblock)
|
|
|
+ Element pivots
|
|
|
+ pivots = create_node()
|
|
|
+ Boolean continue
|
|
|
+ continue = True
|
|
|
+ while (continue):
|
|
|
+ ruleblock = executeRuleBlock(tf_tf_transformation,tf_tf_model, ruleblock, pivots)
|
|
|
+ if(element_eq(ruleblock,tf_tf_transformation)):
|
|
|
+ log("finished")
|
|
|
+ continue = False
|
|
|
+ else:
|
|
|
+ log("root ruleblock not found")
|
|
|
return 0
|
|
|
|
|
|
Element function test_simple_petrinet1(root:Element):
|