|
@@ -409,11 +409,12 @@ def login(username, password):
|
|
|
else:
|
|
|
raise InterfaceMismatch(_last_output())
|
|
|
|
|
|
-def model_add(model_name, metamodel_name, model_code=None):
|
|
|
+def model_add(model_name, metamodel_name, model_code=""):
|
|
|
"""Instantiate a new model."""
|
|
|
_goto_mode(MODE_MODELLING)
|
|
|
|
|
|
# Do this before creating the model, as otherwise compilation errors would make us inconsistent
|
|
|
+ """
|
|
|
if model_code is not None:
|
|
|
try:
|
|
|
compiled = _compile_model(model_code)
|
|
@@ -421,22 +422,27 @@ def model_add(model_name, metamodel_name, model_code=None):
|
|
|
raise CompilationError(e)
|
|
|
else:
|
|
|
compiled = [0]
|
|
|
+ """
|
|
|
|
|
|
_input(["model_add", metamodel_name, model_name])
|
|
|
_handle_output("Waiting for model constructors...")
|
|
|
- _input(compiled)
|
|
|
+ _input(model_code)
|
|
|
_output("Success")
|
|
|
|
|
|
global registered_metamodels
|
|
|
registered_metamodels[model_name] = metamodel_name
|
|
|
|
|
|
def upload_code(code):
|
|
|
+ _input(code)
|
|
|
+
|
|
|
+ """
|
|
|
try:
|
|
|
compiled = _compile_AL(code)
|
|
|
except Exception as e:
|
|
|
raise CompilationError(e)
|
|
|
|
|
|
_input(compiled)
|
|
|
+ """
|
|
|
|
|
|
def model_delete(model_name):
|
|
|
"""Delete an existing model."""
|
|
@@ -475,10 +481,11 @@ def verify(model_name, metamodel_name=None):
|
|
|
_input(["verify", model_name, metamodel_name])
|
|
|
return _handle_output("Success: ", split=True)[0]
|
|
|
|
|
|
-def model_overwrite(model_name, new_model=None, metamodel_name=None):
|
|
|
+def model_overwrite(model_name, new_model="", metamodel_name=None):
|
|
|
"""Upload a new model and overwrite an existing model."""
|
|
|
_goto_mode(MODE_MODIFY, model_name)
|
|
|
|
|
|
+ """
|
|
|
if new_model is not None:
|
|
|
try:
|
|
|
compiled = _compile_model(new_model)
|
|
@@ -486,10 +493,11 @@ def model_overwrite(model_name, new_model=None, metamodel_name=None):
|
|
|
raise CompilationError(e)
|
|
|
else:
|
|
|
compiled = [0]
|
|
|
+ """
|
|
|
|
|
|
_input("upload")
|
|
|
_handle_output("Waiting for model constructors...")
|
|
|
- _input(compiled)
|
|
|
+ _input(new_model)
|
|
|
_output("Success")
|
|
|
|
|
|
if metamodel_name is not None:
|
|
@@ -528,15 +536,13 @@ def transformation_add_MT(source_metamodels, target_metamodels, operation_name,
|
|
|
"""Create a new model transformation."""
|
|
|
global mode
|
|
|
_goto_mode(MODE_MODELLING)
|
|
|
- import time
|
|
|
|
|
|
- start = time.time()
|
|
|
+ """
|
|
|
try:
|
|
|
compiled = _compile_model(code)
|
|
|
except Exception as e:
|
|
|
raise CompilationError(e)
|
|
|
- #print("Compilation took: %ss" % (time.time() - start))
|
|
|
- start = time.time()
|
|
|
+ """
|
|
|
|
|
|
mv_dict_rep = _dict_to_list(source_metamodels) + [""] + _dict_to_list(target_metamodels) + [""]
|
|
|
_input(["transformation_add_MT"] + mv_dict_rep + [operation_name])
|
|
@@ -548,24 +554,23 @@ def transformation_add_MT(source_metamodels, target_metamodels, operation_name,
|
|
|
callback()
|
|
|
_input("exit")
|
|
|
mode = MODE_MODELLING
|
|
|
- #print("Callbacks took: %ss" % (time.time() - start))
|
|
|
- start = time.time()
|
|
|
|
|
|
# Done, so RAMify and upload the model
|
|
|
_handle_output("Waiting for model constructors...")
|
|
|
- _input(compiled)
|
|
|
+ _input(code)
|
|
|
_handle_output("Success")
|
|
|
- #print("Upload and RAMify took: %ss" % (time.time() - start))
|
|
|
|
|
|
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:
|
|
|
compiled = _compile_AL(code)
|
|
|
except Exception as e:
|
|
|
raise CompilationError(e)
|
|
|
+ """
|
|
|
|
|
|
mv_dict_rep = _dict_to_list(source_metamodels) + [""] + _dict_to_list(target_metamodels) + [""]
|
|
|
_input(["transformation_add_AL"] + mv_dict_rep + [operation_name])
|
|
@@ -579,7 +584,8 @@ def transformation_add_AL(source_metamodels, target_metamodels, operation_name,
|
|
|
mode = MODE_MODELLING
|
|
|
|
|
|
_handle_output("Waiting for code constructors...")
|
|
|
- _input(compiled)
|
|
|
+ #_input(compiled)
|
|
|
+ _input(code)
|
|
|
_output("Success")
|
|
|
|
|
|
def transformation_add_MANUAL(source_metamodels, target_metamodels, operation_name, callback=lambda: None):
|
|
@@ -916,16 +922,19 @@ def attr_assign(model_name, ID, attr, value):
|
|
|
def attr_assign_code(model_name, ID, attr, code):
|
|
|
"""Assign a piece of Action Language code to the attribute"""
|
|
|
_check_type(code)
|
|
|
+ """
|
|
|
try:
|
|
|
compiled = _compile_AL(code)
|
|
|
except Exception as e:
|
|
|
raise CompilationError(e)
|
|
|
+ """
|
|
|
|
|
|
_goto_mode(MODE_MODIFY, model_name)
|
|
|
|
|
|
_input(["attr_add_code", ID, attr])
|
|
|
_handle_output("Waiting for code constructors...")
|
|
|
- _input(compiled)
|
|
|
+ #_input(compiled)
|
|
|
+ _input(code)
|
|
|
_output("Success")
|
|
|
|
|
|
def attr_delete(model_name, ID, attr):
|