|
@@ -366,13 +366,30 @@ def transformation_between(source, target):
|
|
|
return []
|
|
|
lst = [v for v in output.split("\n")]
|
|
|
|
|
|
-def transformation_add_MT_language():
|
|
|
+def transformation_add_MT_language(metamodels, RAMified_name):
|
|
|
"""Create a new Model Transformation language out of a set of metamodels."""
|
|
|
- raise NotImplementedError()
|
|
|
+ global mode
|
|
|
+ if mode != 2:
|
|
|
+ raise InvalidMode()
|
|
|
+
|
|
|
+ _input(["transformation_add_MT_language"] + metamodels + ["", RAMified_name])
|
|
|
+ _handle_output("Success")
|
|
|
|
|
|
-def transformation_add_MT():
|
|
|
+def transformation_add_MT(RAMified_metamodel, source_metamodels, target_metamodels, operation_name, code):
|
|
|
"""Create a new model transformation."""
|
|
|
- raise NotImplementedError()
|
|
|
+ global mode
|
|
|
+ if mode != 2:
|
|
|
+ raise InvalidMode()
|
|
|
+
|
|
|
+ try:
|
|
|
+ compiled = _compile_model(code)
|
|
|
+ except Exception as e:
|
|
|
+ raise CompilationError(e)
|
|
|
+
|
|
|
+ _input(["transformation_add_MT", RAMified_metamodel] + source_metamodels + [""] + target_metamodels + ["", operation_name])
|
|
|
+ _handle_output("Waiting for model constructors...")
|
|
|
+ _input(compiled)
|
|
|
+ _handle_output("Success")
|
|
|
|
|
|
def transformation_add_AL(source_metamodels, target_metamodels, operation_name, code):
|
|
|
"""Create a new action language model, which can be executed."""
|
|
@@ -423,6 +440,35 @@ def transformation_execute_AL(operation_name, input_models_dict, output_models_d
|
|
|
else:
|
|
|
return False
|
|
|
|
|
|
+def transformation_execute_MT(operation_name, input_models_dict, output_models_dict, callback=lambda i: None):
|
|
|
+ """Execute an existing model operation."""
|
|
|
+ global mode
|
|
|
+ if mode != 2:
|
|
|
+ raise InvalidMode()
|
|
|
+
|
|
|
+ mv_dict_rep = []
|
|
|
+ for key, value in input_models_dict.items():
|
|
|
+ mv_dict_rep += [key, value]
|
|
|
+ mv_dict_rep += [""]
|
|
|
+ for key, value in output_models_dict.items():
|
|
|
+ mv_dict_rep += [key, value]
|
|
|
+ mv_dict_rep += [""]
|
|
|
+
|
|
|
+ _input(["transformation_execute", operation_name] + mv_dict_rep)
|
|
|
+ _handle_output("Success: ready for MT execution")
|
|
|
+
|
|
|
+ # We are now executing, so everything we get is part of the dialog, except if it is the string for transformation termination
|
|
|
+ while _output() not in ["Success", "Failure"]:
|
|
|
+ reply = callback(_last_output())
|
|
|
+ if reply is not None:
|
|
|
+ _input(reply)
|
|
|
+
|
|
|
+ # Got termination message, so we are done!
|
|
|
+ if _last_output() == "Success":
|
|
|
+ return True
|
|
|
+ else:
|
|
|
+ return False
|
|
|
+
|
|
|
def transformation_list():
|
|
|
"""List existing model operations."""
|
|
|
raise NotImplementedError()
|