|
|
@@ -7,6 +7,72 @@ include "io.alh"
|
|
|
include "metamodels.alh"
|
|
|
include "modelling.alh"
|
|
|
|
|
|
+Element function tf_printNode(tf_pn_model: Element, tf_pn_node: Element):
|
|
|
+ //print header name
|
|
|
+ String tf_pn_node_name
|
|
|
+ tf_pn_node_name = getName(tf_pn_model, tf_pn_node)
|
|
|
+ log("== NAME OF THE ELEMENT")
|
|
|
+ log(tf_pn_node_name)
|
|
|
+ //log(find_attribute_type(tf_pn_model, tf_pn_node_name, name : String)
|
|
|
+ log("== ATTRIBUTELIST")
|
|
|
+ // Get all outgoing "dictionary" links
|
|
|
+ Element tf_pn_attributelist
|
|
|
+ tf_pn_attributelist = dict_keys(getAttributeList(tf_pn_model, tf_pn_node_name))
|
|
|
+ String tf_pn_attributename
|
|
|
+ String tf_pn_attributetype
|
|
|
+ while (integer_lt(0, read_nr_out(tf_pn_attributelist))):
|
|
|
+ tf_pn_attributename = set_pop(tf_pn_attributelist)
|
|
|
+ tf_pn_attributetype = find_attribute_type(tf_pn_model, tf_pn_node_name, tf_pn_attributename)
|
|
|
+ log( tf_pn_attributetype)
|
|
|
+ if( tf_pn_attributetype == "String"):
|
|
|
+ log(string_join(string_join(tf_pn_attributename, " : "),read_attribute(tf_pn_model, tf_pn_node_name, tf_pn_attributename)))
|
|
|
+ elif (tf_pn_attributetype == "Integer"):
|
|
|
+ log(string_join(string_join(tf_pn_attributename, " : "),cast_i2s(read_attribute(tf_pn_model, tf_pn_node_name, tf_pn_attributename))))
|
|
|
+ else:
|
|
|
+ log(string_join(tf_pn_attributename, " : "))
|
|
|
+ log(read_attribute(tf_pn_model, tf_pn_node_name, tf_pn_attributename))
|
|
|
+ return 0
|
|
|
+
|
|
|
+//namespace is tf_ma_
|
|
|
+Element function tf_matchAll(tf_ma_transformation: Element, tf_ma_pattern : Element, tf_ma_model: Element ):
|
|
|
+ //log("executing: tf_matchAll()")
|
|
|
+ Element tf_ma_metamodelTransf
|
|
|
+ //log(tf_ma_pattern)
|
|
|
+ tf_ma_metamodelTransf = dict_read(dict_read(tf_ma_transformation, "metamodel"), "model")
|
|
|
+ Element tf_ma_pattern_nodes
|
|
|
+ tf_ma_pattern_nodes = create_node()
|
|
|
+ tf_ma_pattern_nodes = allOutgoingAssociationInstances(tf_ma_transformation, tf_ma_pattern, dict_read(tf_ma_metamodelTransf, "pre2ram"))
|
|
|
+ //check if this works
|
|
|
+ Element tf_ma_ramified_node
|
|
|
+ while (integer_lt(0, read_nr_out(tf_ma_pattern_nodes))):
|
|
|
+ tf_ma_ramified_node = read_edge_dst(set_pop(tf_ma_pattern_nodes))
|
|
|
+ //plabel not found
|
|
|
+ //log(readAttribute(tf_ma_transformation,tf_ma_ramified_node, "plabel"))
|
|
|
+ Element tf_ma_attrlist
|
|
|
+ return 0
|
|
|
+
|
|
|
+//namespace tf_er_
|
|
|
+Element function tf_executeRule(tf_er_transformation: Element,tf_er_rule: Element, tf_er_model: Element):
|
|
|
+ //log("find matches based on lhs")
|
|
|
+ Element tf_er_lhs
|
|
|
+ tf_er_lhs = allOutgoingAssociationInstances(tf_er_transformation, tf_er_rule, dict_read(dict_read(dict_read(tf_er_transformation, "metamodel"), "model"), "lhs"))
|
|
|
+ tf_matchAll(tf_er_transformation, read_edge_dst(set_pop(tf_er_lhs)), tf_er_model)
|
|
|
+ return 0
|
|
|
+
|
|
|
+//namespace tf_tf_
|
|
|
+Element function tf_transform(tf_tf_transformation: Element, tf_tf_model: Element):
|
|
|
+ //log("getting rule")
|
|
|
+ //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")) //print rules
|
|
|
+ //log("execute rule")
|
|
|
+ Element tf_tf_rule
|
|
|
+ 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)
|
|
|
+ tf_executeRule(tf_tf_transformation, tf_tf_rule, tf_tf_model)
|
|
|
+ return 0
|
|
|
+
|
|
|
Element function petrinet_transformation(root: Element):
|
|
|
// Create A transformation model for petrinets (useful for testing)
|
|
|
|
|
|
@@ -505,6 +571,7 @@ Element function initial_prompt():
|
|
|
|
|
|
Void function main():
|
|
|
//initial_prompt()
|
|
|
+ log("==========================================================================")
|
|
|
log("creating metamodels")
|
|
|
Element root
|
|
|
root = create_metamodels()
|
|
|
@@ -513,5 +580,8 @@ Void function main():
|
|
|
transf = petrinet_transformation(root)
|
|
|
log("check conformance of transformation")
|
|
|
log(conformance_scd(transf))
|
|
|
+ log("run transform")
|
|
|
+ tf_transform(transf, create_node())
|
|
|
log("done")
|
|
|
+ log("==========================================================================")
|
|
|
return
|