浏览代码

Fixed transformation execution when there are no output models

Yentl Van Tendeloo 8 年之前
父节点
当前提交
0a0e389292
共有 5 个文件被更改,包括 118 次插入20 次删除
  1. 二进制
      bootstrap/bootstrap.m.gz
  2. 0 7
      bootstrap/modelling.alc
  3. 1 0
      bootstrap/transform.alc
  4. 22 9
      core/core_algorithm.alc
  5. 95 4
      integration/test_mvc.py

二进制
bootstrap/bootstrap.m.gz


+ 0 - 7
bootstrap/modelling.alc

@@ -104,9 +104,6 @@ String function instantiate_node(model : Element, type_name : String, instance_n
 	// Basically create a node and type it immediately
 	String actual_name
 
-	log("Instantiate node " + instance_name)
-	log("   with type " + type_name)
-
 	actual_name = model_add_node(model, instance_name)
 	retype(model, actual_name, type_name)
 
@@ -129,8 +126,6 @@ String function find_attribute_type(model : Element, elem : String, name : Strin
 	direct_type = read_type(model, elem)
 
 	if (direct_type == ""):
-		log("Direct type of " + elem)
-		log("  = " + direct_type)
 		return ""!
 	
 	mm_elem = find_attribute_definer(model["metamodel"], direct_type, name)
@@ -467,7 +462,6 @@ Void function add_constraint(model : Element, element : String, constraint : Act
 Void function construct_model():
 	String command
 
-	log("Constructing model")
 	initialize_SCD("models/SimpleClassDiagrams")
 
 	while (True):
@@ -533,7 +527,6 @@ Element function construct_model_raw(metamodel : Element):
 
 	while (True):
 		command = input()
-		log("Command: " + command)
 		if (command == "add_node"):
 			model_add_node(model, input())
 		elif (command == "add_value"):

+ 1 - 0
bootstrap/transform.alc

@@ -120,6 +120,7 @@ Element function get_possible_bindings(host_model : Element, schedule_model : El
 		if (read_nr_out(options) == 0):
 			// Is a node and no connections, so we just pick all options
 			options = allInstances(host_model, original_typename)
+			log("Finding all instances of " + original_typename)
 		elif (read_nr_out(options) > 1):
 			// Multiple "only" options, which will not work out: no options!
 			return create_node()!

+ 22 - 9
core/core_algorithm.alc

@@ -388,8 +388,9 @@ Void function user_function_skip_init(user_id : String):
 						// Read out source and target links
 						sources = allOutgoingAssociationInstances(core, transformation_id, "transformInput")
 						inputs = create_node()
-						while (read_nr_out(source) > 0):
+						while (read_nr_out(sources) > 0):
 							source = set_pop(sources)
+							log("Got source link: " + cast_e2s(source))
 							output(string_join("Which model to bind for source element ", read_attribute(core, source, "name")))
 							name_id = get_model_id(input())
 							if (name_id != ""):
@@ -428,22 +429,26 @@ Void function user_function_skip_init(user_id : String):
 							Element merged_model
 							String merged_metamodel_id
 							String ramified_metamodel_id
+							Boolean result
 
 							schedule_model = import_node(read_attribute(core, transformation_id, "location"))
 							if (bool_and(bool_and(read_nr_out(inputs) == 1, read_nr_out(outputs) == 1), set_equality(inputs, outputs))):
 								// inputs and outputs have the same values and there is only one: keep in-place without additional bookkeeping
 								input_model = import_node(read_attribute(core, set_pop(inputs), "location"))
-								transform(input_model, schedule_model)
+								result = transform(input_model, schedule_model)
+								output("Transformation executed with result: " + cast_v2s(result))
 							else:
 								// Need to fall back to the default approach, which is way slower
 								// 1) Create empty instance of merged metamodel
 
 								ramified_metamodel_id = set_pop(followAssociation(core, transformation_id, "instanceOf"))
+								log("Got ramified MM: " + ramified_metamodel_id)
 								trace_links = allOutgoingAssociationInstances(core, ramified_metamodel_id, "tracability")
+								log("With tracability links: " + set_to_string(trace_links))
 								merged_metamodel_id = ""
 								while (read_nr_out(trace_links) > 0):
 									trace_link_id = set_pop(trace_links)
-									if (value_eq(read_attribute(core, trace_link_id, "type"), "ramified")):
+									if (value_eq(read_attribute(core, trace_link_id, "type"), "RAMified")):
 										merged_metamodel_id = readAssociationDestination(core, trace_link_id)
 								if (merged_metamodel_id != ""):
 									merged_model = instantiate_model(import_node(read_attribute(core, merged_metamodel_id, "location")))
@@ -458,11 +463,11 @@ Void function user_function_skip_init(user_id : String):
 									input_keys = dict_keys(inputs)
 									while (read_nr_out(input_keys) > 0):
 										key = set_pop(input_keys)
-										model_join(merged_model, import_node(read_attribute(core, inputs[key], "location")), key)
+										model_join(merged_model, import_node(read_attribute(core, inputs[key], "location")), key + "_")
 
 									// 3) Transform
 
-									transform(merged_model, schedule_model)
+									result = transform(merged_model, schedule_model)
 
 									// 4) Split in different files depending on type
 
@@ -473,7 +478,7 @@ Void function user_function_skip_init(user_id : String):
 									while (read_nr_out(output_keys) > 0):
 										key = set_pop(output_keys)
 										desired_metamodel_id = set_pop(followAssociation(core, outputs[key], "instanceOf"))
-										split_off_model = model_split(merged_model, import_node(read_attribute(core, desired_metamodel_id, "location")), key)
+										split_off_model = model_split(merged_model, import_node(read_attribute(core, desired_metamodel_id, "location")), key + "+")
 
 										// Check if the destination model already exists
 										if (get_model_id(outputs[key]) == ""):
@@ -482,7 +487,7 @@ Void function user_function_skip_init(user_id : String):
 										else:
 											// Model exists, so we overwrite
 											model_overwrite(split_off_model, outputs[key])
-
+									output("Transformation executed with result: " + cast_v2s(result))
 								else:
 									output("Could not resolve intermediate merged metamodel")
 						elif (exact_type == "ActionLanguage"):
@@ -741,10 +746,18 @@ Void function user_function_skip_init(user_id : String):
 						model_id = get_model_id(name)
 
 						// Extend metadata with info on source and target
+						String link
+						String dst
+
 						while (read_nr_out(source) > 0):
-							instantiate_link(core, "transformInput", "", model_id, set_pop(source))
+							dst = set_pop(source)
+							link = instantiate_link(core, "transformInput", "", model_id, dst)
+							instantiate_attribute(core, link, "name", read_attribute(core, dst, "name"))
+
 						while (read_nr_out(target) > 0):
-							instantiate_link(core, "transformOutput", "", model_id, set_pop(target))
+							dst = set_pop(target)
+							link = instantiate_link(core, "transformOutput", "", model_id, dst)
+							instantiate_attribute(core, link, "name", read_attribute(core, dst, "name"))
 
 						output("Meta-info correctly set!")
 					else:

+ 95 - 4
integration/test_mvc.py

@@ -358,11 +358,10 @@ class TestModelverseCore(unittest.TestCase):
             ],
             mode))
 
-    def test_po_transform_add_MT_pn_print(self):
-        self.transform_add_MT_pn_print("PO")
+    def test_po_transform_add_MT_pn_print_upload(self):
+        self.transform_add_MT_pn_print_upload("PO")
 
-    def transform_add_MT_pn_print(self, mode):
-        print("Constructors: " + str(get_raw_model_constructor(open("integration/code/pn_print_MR.mvc", "r").read())))
+    def transform_add_MT_pn_print_upload(self, mode):
         self.assertTrue(run_file(all_files,
             [ "root",
                 "model_add",
@@ -426,3 +425,95 @@ class TestModelverseCore(unittest.TestCase):
                 "Ready for command...",
             ],
             mode))
+
+    def test_po_transform_add_MT_pn_print_exec(self):
+        self.transform_add_MT_pn_print_exec("PO")
+
+    def transform_add_MT_pn_print_exec(self, mode):
+        self.assertTrue(run_file(all_files,
+            [ "root",
+                "model_add",
+                "SimpleClassDiagrams",
+                "PetriNets",
+                ] + get_raw_model_constructor(open("integration/code/pn_runtime_MR.mvc", "r").read()) + [
+                "model_add",
+                "PetriNets",
+                "my_pn",
+                ] + get_raw_model_constructor(open("integration/code/pn_runtime_model_MR.mvc", "r").read()) + [
+                "model_list_full",
+                "transformation_add_MT_language",
+                "PetriNets",
+                "",
+                "PetriNets_RAM",
+                "model_list_full",
+                "transformation_add_MT",
+                "PetriNets_RAM",
+                "PetriNets",
+                "",
+                "",
+                "PetriNets_Print",
+                ] + get_raw_model_constructor(open("integration/code/pn_print_MR.mvc", "r").read()) + [
+                "transformation_list_full",
+                "transformation_execute",
+                "PetriNets_Print",
+                "my_pn",
+                "transformation_list_full",
+            ],
+            [   "Desired username for admin user?",
+                "Welcome to the Model Management Interface v2.0!",
+                "Use the 'help' command for a list of possible commands",
+                "Ready for command...",
+                "Creating new model!",
+                "Model type?",
+                "Model name?",
+                "Waiting for model constructors...",
+                "Model upload success!",
+                "Ready for command...",
+                "Creating new model!",
+                "Model type?",
+                "Model name?",
+                "Waiting for model constructors...",
+                "Model upload success!",
+                "Ready for command...",
+                set(["  221  root admin    673   SimpleClassDiagrams : SimpleClassDiagrams",
+                     "  221  root admin    86   CoreFormalism : SimpleClassDiagrams",
+                     "  200  root nobody    22   PetriNets : SimpleClassDiagrams",
+                     "  200  root nobody    27   my_pn : PetriNets",
+                     "  200  root admin    63   core : CoreFormalism"]),
+                "Ready for command...",
+                "Formalisms to include (terminate with empty string)?",
+                "Name of the RAMified transformation metamodel?",
+                "Ready for command...",
+                set(["  221  root admin    673   SimpleClassDiagrams : SimpleClassDiagrams",
+                     "  221  root admin    86   CoreFormalism : SimpleClassDiagrams",
+                     "  200  root nobody    22   PetriNets : SimpleClassDiagrams",
+                     "  200  root nobody    22   __merged_PetriNets_RAM : SimpleClassDiagrams",
+                     "  200  root nobody    352   PetriNets_RAM : SimpleClassDiagrams",
+                     "  200  root nobody    27   my_pn : PetriNets",
+                     "  200  root admin    89   core : CoreFormalism"]),
+                "Ready for command...",
+                "RAMified metamodel to use?",
+                "Supported metamodels:",
+                set(["  PetriNets",
+                    ]),
+                "",
+                "Which ones do you want to use as source (empty string to finish)?",
+                "Model added as source",
+                "Which ones do you want to use as target (empty string to finish)?",
+                "Name of new transformation?",
+                "Waiting for model constructors...",
+                "Meta-info correctly set!",
+                "Ready for command...",
+                set(["  200  root nobody    26   [ModelTransformation] PetriNets_Print : PetriNets_RAM"
+                    ]),
+                "Ready for command...",
+                "Which transformation do you want to execute?",
+                "Which model to bind for source element PetriNets",
+                set(['"p1" --> 1',
+                     '"p2" --> 2',
+                     '"p3" --> 3',
+                    ]),
+                "Transformation executed with result: True",
+                "Ready for command...",
+            ],
+            mode))