Browse Source

Even more fixes for hierarchy

Yentl Van Tendeloo 8 years ago
parent
commit
c75ecd838b
3 changed files with 20 additions and 16 deletions
  1. 12 10
      bootstrap/core_algorithm.alc
  2. 2 0
      bootstrap/modelling.alc
  3. 6 6
      integration/test_mvc.py

+ 12 - 10
bootstrap/core_algorithm.alc

@@ -20,9 +20,9 @@ Element core = ?
 Element caches
 
 String function full_name(model_id : String):
-	if (dict_in(caches["full_name"], model_id)):
-		if (get_entry_id(caches["full_name"]) == model_id):
-			return caches["full_name"]!
+	//if (dict_in(caches["full_name"], model_id)):
+	//	if (get_entry_id(caches["full_name"][model_id]) == model_id):
+	//		return caches["full_name"]!
 
 	// No cache, or out of date
 	Element incoming
@@ -33,7 +33,7 @@ String function full_name(model_id : String):
 	if (set_len(incoming) > 0):
 		parent = set_pop(incoming)
 		parent_name = full_name(parent)
-		dict_add(caches["full_name"], parent, parent_name)
+		//dict_add(caches["full_name"], parent, parent_name)
 		return string_join(parent_name + "/", read_attribute(core, model_id, "name"))!
 	else:
 		return ""!
@@ -252,7 +252,7 @@ String function get_entry_id(name : String):
 	Boolean found
 
 	i = 0
-	log("Searching for " + name)
+	//log("Searching for " + name)
 	hierarchy_split = string_split(name, "/")
 	current = caches["root"]
 
@@ -673,7 +673,7 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 			key = set_pop(keys)
 			if (get_entry_id(output_map[key]) == ""):
 				// New model
-				model_create(result[key], output_map[key], user_id, get_entry_id(key), "Model")
+				model_create(result[key], output_map[key], user_id, get_entry_id(outputs[key]), "Model")
 			else:
 				model_overwrite(result[key], get_entry_id(output_map[key]), get_entry_id(outputs[key]))
 		return True!
@@ -1043,12 +1043,12 @@ String function cmd_transformation_execute(user_id : String, transformation_name
 
 					if (get_entry_id(target_model_name) == ""):
 						// Doesn't exist yet, so we can easily create
-						dict_add(output_map, assoc_name, full_name(target))
+						dict_add(output_map, assoc_name, full_name(readAssociationDestination(core, target)))
 						dict_add(outputs, assoc_name, target_model_name)
 					else:
 						// Already exists, so we need to check for write access
 						if (allow_write(user_id, get_entry_id(target_model_name))):
-							dict_add(output_map, assoc_name, full_name(target))
+							dict_add(output_map, assoc_name, full_name(readAssociationDestination(core, target)))
 							dict_add(outputs, assoc_name, target_model_name)
 						else:
 							return "Permission denied to model: " + target_model_name!
@@ -1073,7 +1073,9 @@ String function cmd_transformation_execute(user_id : String, transformation_name
 						
 						if (get_entry_id(outputs[key]) == ""):
 							// New model
-							model_create(result[key], outputs[key], user_id, get_entry_id(key), "Model")
+							log("Creating new model " + cast_v2s(outputs[key]))
+							log("    typed by " + cast_v2s(output_map[key]))
+							model_create(result[key], outputs[key], user_id, get_entry_id(output_map[key]), "Model")
 						else:
 							model_overwrite(result[key], get_entry_id(outputs[key]), get_entry_id(output_map[key]))
 
@@ -1442,7 +1444,7 @@ String function cmd_transformation_add_MT(user_id : String, source_models : Elem
 
 	ramified_metamodel = ramify(merged_formalism)
 	model_create(ramified_metamodel, "RAMified/" + operation_name, user_id, get_entry_id("formalisms/SimpleClassDiagrams"), "Model")
-	ramified_metamodel_id = get_entry_id("RAMified" + operation_name)
+	ramified_metamodel_id = get_entry_id("RAMified/" + operation_name)
 	
 	// Now use the RAMified model to create the instance
 	if (get_entry_id(operation_name) == ""):

+ 2 - 0
bootstrap/modelling.alc

@@ -339,10 +339,12 @@ String function instantiate_link(model : Element, type : String, name : String,
 
 	if (bool_not(dict_in(model["model"], source))):
 		log("ERROR: source of link undefined: " + source)
+		set_pop(create_node())
 		return ""!
 
 	if (bool_not(dict_in(model["model"], destination))):
 		log("ERROR: destination of link undefined: " + destination)
+		set_pop(create_node())
 		return ""!
 
 	if (bool_not(dict_in(model["metamodel"]["model"], type))):

+ 6 - 6
integration/test_mvc.py

@@ -121,8 +121,8 @@ class TestModelverseCore(unittest.TestCase):
 
     def test_transform_add_MT(self):
         model_add("formalisms/PetriNet", "formalisms/SimpleClassDiagrams", open("integration/code/petrinets.mvc", "r").read())
-        compare_location("formalisms", set(["PetriNet"]))
-        compare_location("type mappings/formalisms", set(["PetriNet"]))
+        compare_locations("formalisms", set(["PetriNet"]))
+        compare_locations("type mappings/formalisms", set(["PetriNet"]))
         transformation_add_MT({"PetriNet": "formalisms/PetriNet"}, {}, "models/print_pn", open("integration/code/pn_print.mvc").read())
 
         compare_locations("formalisms", set(["PetriNet"]))
@@ -142,12 +142,12 @@ class TestModelverseCore(unittest.TestCase):
 
         model_add("formalisms/PetriNet", "formalisms/SimpleClassDiagrams", open("integration/code/pn_runtime.mvc", "r").read())
         model_add("models/my_pn", "formalisms/PetriNet", open("integration/code/pn_runtime_model.mvc", "r").read())
-        compare_location("models", set(["my_pn"]))
-        compare_location("type mappings/models", set(["my_pn"]))
+        compare_locations("models", set(["my_pn"]))
+        compare_locations("type mappings/models", set(["my_pn"]))
 
         transformation_add_MT({"PetriNet": "formalisms/PetriNet"}, {}, "models/print_pn", open("integration/code/pn_print.mvc").read())
-        compare_location("models", set(["my_pn", "print_pn"]))
-        compare_location("type mappings/models", set(["my_pn", "print_pn"]))
+        compare_locations("models", set(["my_pn", "print_pn"]))
+        compare_locations("type mappings/models", set(["my_pn", "print_pn"]))
 
         assert transformation_execute_MT("models/print_pn", {"PetriNet": "models/my_pn"}, {}, callback) == True