Browse Source

Fixed model transformations with in-place RAMification

Yentl Van Tendeloo 8 years ago
parent
commit
648b214bde
3 changed files with 41 additions and 29 deletions
  1. 17 14
      bootstrap/core_algorithm.alc
  2. 23 15
      doc/wrappers.rst
  3. 1 0
      integration/test_mvc.py

+ 17 - 14
bootstrap/core_algorithm.alc

@@ -531,19 +531,8 @@ Element function execute_operation(operation_id : String, input_models : Element
 
 	exact_type = read_type(core, operation_id)
 
-	if (exact_type == "ModelTransformation"):
-		linktype = "RAMified"
-		ramified_metamodel_id = set_pop(allAssociationDestinations(core, operation_id, "instanceOf"))
-		trace_links = allOutgoingAssociationInstances(core, ramified_metamodel_id, "tracability")
-	elif (exact_type == "ManualOperation"):
-		linktype = "operatesOn"
-		trace_links = allOutgoingAssociationInstances(core, operation_id, "tracability")
-	elif (exact_type == "ActionLanguage"):
-		linktype = "operatesOn"
-		trace_links = allOutgoingAssociationInstances(core, operation_id, "tracability")
-	else:
-		// Don't know how to execute this operation!
-		return read_root()!
+	trace_links = allOutgoingAssociationInstances(core, operation_id, "tracability")
+	linktype = "operatesOn"
 
 	merged_metamodel_id = ""
 	while (read_nr_out(trace_links) > 0):
@@ -575,7 +564,7 @@ Element function execute_operation(operation_id : String, input_models : Element
 			func = get_func_AL_model(get_full_model(operation_id))
 			result = func(merged_model)
 		else:
-			log("ERROR")
+			return read_root()!
 
 		// 4) Split in different models depending on type
 
@@ -1057,6 +1046,7 @@ String function cmd_transformation_execute(user_id : String, transformation_name
 				else:
 					output("Success: ready for MT execution")
 
+				log("Start execution: " + cast_e2s(transformation_id))
 				result = execute_operation(transformation_id, inputs, output_map, read_root())
 
 				// Now write out the models again
@@ -1338,6 +1328,9 @@ String function cmd_transformation_add_MT(user_id : String, source_models : Elem
 	String key
 	String mm
 	Element to_ramify
+	String source_formalism_id
+	String merged_formalism_id
+	String tracability_link
 
 	source = create_node()
 	target = create_node()
@@ -1390,6 +1383,7 @@ String function cmd_transformation_add_MT(user_id : String, source_models : Elem
 			return "Model not found: " + name!
 
 	merged_formalism = model_fuse(to_ramify)
+
 	ramified_metamodel = ramify(merged_formalism)
 	model_create(ramified_metamodel, "__RAM_" + operation_name, user_id, get_model_id("SimpleClassDiagrams"), "Model")
 	ramified_metamodel_id = get_model_id("__RAM_" + operation_name)
@@ -1403,6 +1397,15 @@ String function cmd_transformation_add_MT(user_id : String, source_models : Elem
 		model_create(new_model, operation_name, user_id, ramified_metamodel_id, "ModelTransformation")
 		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
+		model_create(merged_formalism, "__merged_" + operation_name, user_id, get_model_id("SimpleClassDiagrams"), "Model")
+		merged_formalism_id = get_model_id("__merged_" + operation_name)
+
+		// Add tracability links at this level
+		tracability_link = instantiate_link(core, "tracability", "", model_id, merged_formalism_id)
+		instantiate_attribute(core, tracability_link, "type", "operatesOn")
+
 		// Extend metadata with info on source and target
 		String link
 		String dst

+ 23 - 15
doc/wrappers.rst

@@ -31,35 +31,51 @@ Functions
 
 .. function:: init(address_param="http://127.0.0.1:8001", timeout=20.0)
 
-   Explanation of init.
+   Start up the connection to the Modelverse, residing at *address_param*.
+   This connection is an XML/HTTPRequest and will start up a new task at the Modelverse.
+   Retries for *timeout* seconds until giving up.
+   The timeout includes all HTTP errors, and will therefore keep retrying even on failed attempts.
+   As this request is synchronous, like all others, it will block until a connection has been established.
 
 .. function:: login(username, password)
 
    Explanation
+   Logs in the currently active Modelverse connection to the specified *username* and *password*.
+   If the user does not exist, it will create a new user with the specified password.
+   If the user already exists, it will try to log in with the provided password.
 
 .. function:: model_add(model_name, metamodel_name, model_code=None)
 
    Explanation
+   Upload a new model that can later be referred to as *model_name*, conforming to *metamodel_name*.
+   The model itself is stored in the string *model_code*.
+   This string is parsed using the HUTN compiler and subsequently sent to the Modelverse.
+   When *model_code* is empty, an empty model is created.
 
 .. function:: upload_code(code)
 
-   Expl
+   Upload a string of *code* in the Action Language formalism.
+   This piece of code is compiled with the HUTN compiler and sent to the Modelverse directly.
+   Makes the assumption that the **construct_function()** operation is currently running on the Modelverse, as otherwise the data will be misinterpreted.
+   This is normally only useful in model transformations, where you want to upload a piece of code on-the-fly (e.g., adding a breakpoint in Action Language).
 
 .. function:: model_delete(model_name)
 
-   Expl
+   Delete the model referred to by name *model_name*.
+   This is a non-cascading delete, with almost no checks: model transformations depending on this model will likely become corrupted.
 
 .. function:: model_list()
 
-   Expl
+   Returns a list of all models existing in the Modelverse, together with their type.
 
 .. function:: model_list_full()
 
-   Expl
+   Returns a detailed list of all models existing in the Modelverse.
+   This list includes information on permissions, owner, and group.
 
 .. function:: verify(model_name)
 
-   Expl
+   Verify whether *model_name* conforms to its specified metamodel, as stored in the Modelverse.
 
 .. function:: model_overwrite(model_name, new_model_code=None)
 
@@ -81,11 +97,7 @@ Functions
 
    Expl
 
-.. function:: transformation_add_MT_language(metamodels, RAMified_name)
-
-   Expl
-
-.. function:: transformation_add_MT(RAMified_metamodel, source_metamodels, target_metamodels, operation_name, code)
+.. function:: transformation_add_MT(source_metamodels, target_metamodels, operation_name, code)
 
    Expl
 
@@ -113,10 +125,6 @@ Functions
 
    Expl
 
-.. function:: transformation_RAMify(metamodel_name, RAMified_metamodel_name)
-
-   Expl
-
 .. function:: process_execute(process_name, prefix, callbacks)
 
    Expl

+ 1 - 0
integration/test_mvc.py

@@ -93,6 +93,7 @@ class TestModelverseCore(unittest.TestCase):
         assert model_list() == set(list(expected_model_list) + [("PetriNet", "SimpleClassDiagrams"),
                                                                 ("my_pn", "PetriNet"),
                                                                 ("__RAM_print_pn", "SimpleClassDiagrams"),
+                                                                ("__merged_print_pn", "SimpleClassDiagrams"),
                                                                 ("print_pn", "__RAM_print_pn")])
         assert transformation_list() == set(list(expected_transformation_list) + [("ModelTransformation", "print_pn")])
         assert transformation_execute_MT("print_pn", {"PetriNet": "my_pn"}, {}, callback) == True