Prechádzať zdrojové kódy

Add callback for add_AL and add_MANUAL as well

Yentl Van Tendeloo 8 rokov pred
rodič
commit
817cf646b1

+ 5 - 5
bootstrap/core_algorithm.alc

@@ -1260,6 +1260,11 @@ String function transformation_add(user_id : String, source_models : Element, ta
 			return "Model not found: " + name!
 
 	if (get_model_id(operation_name) == ""):
+		// Write out a merged metamodel containing all these models: this is the MM for the manual operation
+		// New location is available, so write
+		merged_formalism = model_fuse(set_copy(all_formalisms))
+		modify(merged_formalism, True)
+
 		if (operation_type == "manual"):
 			// Finished with all information, now create the model itself!
 			model_create(instantiate_model(get_full_model(get_model_id("ManualOperation"))), operation_name, user_id, get_model_id("ManualOperation"), "ManualOperation")
@@ -1272,11 +1277,6 @@ String function transformation_add(user_id : String, source_models : Element, ta
 			model_create(import_node("AL/" + operation_name), operation_name, user_id, get_model_id("ActionLanguage"), "ActionLanguage")
 			model_id = get_model_id(operation_name)
 
-		// Write out a merged metamodel containing all these models: this is the MM for the manual operation
-		// New location is available, so write
-		merged_formalism = model_fuse(set_copy(all_formalisms))
-		//modify(merged_formalism, True)
-
 		model_create(merged_formalism, "__merged_" + operation_name, user_id, type_id, "Model")
 		merged_formalism_id = get_model_id("__merged_" + operation_name)
 

+ 0 - 1
bootstrap/mini_modify.alc

@@ -323,7 +323,6 @@ String function cmd_read_association_destination(write : Boolean, model : Elemen
 Element function modify(model : Element, write : Boolean):
 	String cmd
 
-	log("Start modify!")
 	output("Model loaded, ready for commands!")
 
 	while (True):

+ 18 - 0
wrappers/modelverse.py

@@ -460,6 +460,7 @@ def transformation_add_MT(source_metamodels, target_metamodels, operation_name,
 
 def transformation_add_AL(source_metamodels, target_metamodels, operation_name, code, callback=lambda: None):
     """Create a new action language model, which can be executed."""
+    global mode
     _goto_mode(MODE_MODELLING)
 
     try:
@@ -469,16 +470,33 @@ def transformation_add_AL(source_metamodels, target_metamodels, operation_name,
 
     mv_dict_rep = _dict_to_list(source_metamodels) + [""] + _dict_to_list(target_metamodels) + [""]
     _input(["transformation_add_AL"] + mv_dict_rep + [operation_name])
+
+    # Possibly modify the merged metamodel first (add tracability links)
+    mode = MODE_MANUAL
+    _output() # Model loaded, ready for commands
+    callback()
+    _input("exit")
+    mode = MODE_MODELLING
+
     _handle_output("Waiting for code constructors...")
     _input(compiled)
     _output("Success")
 
 def transformation_add_MANUAL(source_metamodels, target_metamodels, operation_name, callback=lambda: None):
     """Create a new manual model operation."""
+    global mode
     _goto_mode(MODE_MODELLING)
 
     mv_dict_rep = _dict_to_list(source_metamodels) + [""] + _dict_to_list(target_metamodels) + [""]
     _input(["transformation_add_MANUAL"] + mv_dict_rep + [operation_name])
+
+    # Possibly modify the merged metamodel first (add tracability links)
+    mode = MODE_MANUAL
+    _output() # Model loaded, ready for commands
+    callback()
+    _input("exit")
+    mode = MODE_MODELLING
+
     _handle_output("Success")
 
 def transformation_execute_AL(operation_name, input_models_dict, output_models_dict, callback=lambda i: None):