소스 검색

Begin of working hierarchy

Yentl Van Tendeloo 8 년 전
부모
커밋
fad4d5efbc
4개의 변경된 파일287개의 추가작업 그리고 284개의 파일을 삭제
  1. 25 25
      bootstrap/99_core.mvc
  2. 83 75
      bootstrap/core_algorithm.alc
  3. 168 160
      integration/test_mvc.py
  4. 11 24
      wrappers/modelverse.py

+ 25 - 25
bootstrap/99_core.mvc

@@ -62,9 +62,9 @@ CF core {
                 permissions = "221"
             }
 
-            Model bottom {
-                name = "bottom"
-                location = "models/bottom/model"
+            Model Bottom {
+                name = "Bottom"
+                location = "models/Bottom/model"
                 permissions = "221"
             }
         }
@@ -90,44 +90,44 @@ CF core {
                 permissions = "110"
 
                 TypeMapping TM_SimpleClassDiagrams {
-                    name = "TM_SimpleClassDiagrams"
+                    name = "SimpleClassDiagrams"
                     location = "models/SimpleClassDiagrams/type_mapping"
                     permissions = "221"
                 }
 
                 TypeMapping TM_TypeMapping {
-                    name = "TM_TypeMapping"
+                    name = "TypeMapping"
                     location = "models/TypeMapping/type_mapping"
                     permissions = "221"
                 }
 
                 TypeMapping TM_Tracability{
-                    name = "TM_Tracability"
+                    name = "Tracability"
                     location = "models/Tracability/type_mapping"
                     permissions = "221"
                 }
 
                 TypeMapping TM_ProcessModel {
-                    name = "TM_ProcessModel"
+                    name = "ProcessModel"
                     location = "models/ProcessModel/type_mapping"
                     permissions = "221"
                 }
 
                 TypeMapping TM_ActionLanguage {
-                    name = "TM_ActionLanguage"
+                    name = "ActionLanguage"
                     location = "models/ActionLanguage/type_mapping"
                     permissions = "221"
                 }
 
                 TypeMapping TM_ManualOperation {
-                    name = "TM_ManualOperation"
+                    name = "ManualOperation"
                     location = "models/ManualOperation/type_mapping"
-                    permissions = "111"
+                    permissions = "221"
                 }
 
-                TypeMapping TM_bottom {
-                    name = "TM_bottom"
-                    location = "models/bottom/type_mapping"
+                TypeMapping TM_Bottom {
+                    name = "Bottom"
+                    location = "models/Bottom/type_mapping"
                     permissions = "221"
                 }
 
@@ -138,7 +138,7 @@ CF core {
                 permissions = "110"
 
                 TypeMapping TM_conformance_mv {
-                    name = "TM_conformance_mv"
+                    name = "conformance_mv"
                     location = "models/Conformance_MV/type_mapping"
                     permissions = "221"
                 }
@@ -149,13 +149,13 @@ CF core {
                 permissions = "100"
 
                 TypeMapping TM_Core {
-                    name = "TM_core"
+                    name = "core"
                     location = "models/core/type_mapping"
                     permissions = "220"
                 }
 
                 TypeMapping TM_CoreFormalism {
-                    name = "TM_CoreFormalism"
+                    name = "CoreFormalism"
                     location = "models/CoreFormalism/type_mapping"
                     permissions = "221"
                 }
@@ -208,7 +208,7 @@ CF core {
     group (ProcessModel, admin_group) {}
     group (ActionLanguage, admin_group) {}
     group (ManualOperation, admin_group) {}
-    group (bottom, admin_group) {}
+    group (Bottom, admin_group) {}
     group (models, admin_group) {}
     group (conformance_mv, admin_group) {}
     group (administration, admin_group) {}
@@ -224,7 +224,7 @@ CF core {
     group (TM_Tracability, admin_group) {}
     group (TM_ProcessModel, admin_group) {}
     group (TM_ActionLanguage, admin_group) {}
-    group (TM_bottom, admin_group) {}
+    group (TM_Bottom, admin_group) {}
     group (TM_ManualOperation, admin_group) {}
     group (tm_models, admin_group) {}
     group (TM_conformance_mv, admin_group) {}
@@ -242,7 +242,7 @@ CF core {
     owner (ProcessModel, admin_user) {}
     owner (ActionLanguage, admin_user) {}
     owner (ManualOperation, admin_user) {}
-    owner (bottom, admin_user) {}
+    owner (Bottom, admin_user) {}
     owner (models, admin_user) {}
     owner (conformance_mv, admin_user) {}
     owner (administration, admin_user) {}
@@ -259,7 +259,7 @@ CF core {
     owner (TM_ProcessModel, admin_user) {}
     owner (TM_ActionLanguage, admin_user) {}
     owner (TM_ManualOperation, admin_user) {}
-    owner (TM_bottom, admin_user) {}
+    owner (TM_Bottom, admin_user) {}
     owner (tm_models, admin_user) {}
     owner (TM_conformance_mv, admin_user) {}
     owner (tm_administration, admin_user) {}
@@ -284,7 +284,7 @@ CF core {
     instanceOf inst_conf (conformance_mv, ActionLanguage) {}
     instanceOf inst_cf (CoreFormalism, SimpleClassDiagrams) {}
     instanceOf inst_core (Core, CoreFormalism) {}
-    instanceOf inst_bottom (bottom, SimpleClassDiagrams) {}
+    instanceOf inst_Bottom (Bottom, SimpleClassDiagrams) {}
 
     instanceOf TM_inst_SCD (TM_SimpleClassDiagrams, TypeMapping) {}
     instanceOf TM_inst_TM (TM_TypeMapping, TypeMapping) {}
@@ -295,7 +295,7 @@ CF core {
     instanceOf TM_inst_conf (TM_conformance_mv, TypeMapping) {}
     instanceOf TM_inst_cf (TM_CoreFormalism, TypeMapping) {}
     instanceOf TM_inst_core (TM_Core, TypeMapping) {}
-    instanceOf TM_inst_bottom (TM_bottom, TypeMapping) {}
+    instanceOf TM_inst_Bottom (TM_Bottom, TypeMapping) {}
 
     typing (inst_SCD, TM_SimpleClassDiagrams) {}
     typing (inst_TM, TM_TypeMapping) {}
@@ -306,7 +306,7 @@ CF core {
     typing (inst_conf, TM_conformance_mv) {}
     typing (inst_cf, TM_CoreFormalism) {}
     typing (inst_core, TM_Core) {}
-    typing (inst_bottom, TM_bottom) {}
+    typing (inst_Bottom, TM_Bottom) {}
 
     semantics (inst_SCD, conformance_mv) {}
     semantics (inst_TM, conformance_mv) {}
@@ -317,7 +317,7 @@ CF core {
     semantics (inst_conf, conformance_mv) {}
     semantics (inst_cf, conformance_mv) {}
     semantics (inst_core, conformance_mv) {}
-    semantics (inst_bottom, conformance_mv) {}
+    semantics (inst_Bottom, conformance_mv) {}
 
     semantics (TM_inst_SCD, conformance_mv) {}
     semantics (TM_inst_TM, conformance_mv) {}
@@ -328,7 +328,7 @@ CF core {
     semantics (TM_inst_conf, conformance_mv) {}
     semantics (TM_inst_cf, conformance_mv) {}
     semantics (TM_inst_core, conformance_mv) {}
-    semantics (TM_inst_bottom, conformance_mv) {}
+    semantics (TM_inst_Bottom, conformance_mv) {}
 }
 
 export core to models/core

+ 83 - 75
bootstrap/core_algorithm.alc

@@ -77,7 +77,7 @@ String function get_instanceOf_link(model_id : String, metamodel_id : String):
 	return choice!
 
 Element function get_full_model(model_id : String, metamodel_id : String):
-	// TODO we are restricted to using SimpleClassDiagrams as M3 level, through this code!
+	// TODO we are restricted to using formalisms/SimpleClassDiagrams as M3 level, through this code!
 	Element m
 	Element all_links
 	String choice
@@ -89,14 +89,14 @@ Element function get_full_model(model_id : String, metamodel_id : String):
 
 	// TODO for now this is restricted to the fixed semantics
 	// dict_add(m, "semantics", set_pop(allAssociationDestinations(core, choice, "semantics")))
-	dict_add(m, "semantics", get_entry_id("conformance_mv"))
+	dict_add(m, "semantics", get_entry_id("models/conformance_mv"))
 
 	if (metamodel_id == model_id):
 		// Found the meta-circular level, so we can stop!
 		dict_add(m, "metamodel", m)
 	else:
 		Element mm
-		mm = get_full_model(metamodel_id, get_entry_id("SimpleClassDiagrams"))
+		mm = get_full_model(metamodel_id, get_entry_id("formalisms/SimpleClassDiagrams"))
 		if (element_eq(mm, read_root())):
 			return read_root()!
 		else:
@@ -249,34 +249,30 @@ String function get_entry_id(name : String):
 	Element elems
 	String current_part
 	String elem
+	Boolean found
 
 	i = 0
-	name = "/" + name
+	log("Searching for " + name)
 	hierarchy_split = string_split(name, "/")
-	current = caches["models"][""]
-	log("Reading " + name)
-	log("Split up in: " + list_to_string(hierarchy_split))
+	current = caches["root"]
 
+	Element dict
 	while (i < list_len(hierarchy_split)):
 		current_part = list_read(hierarchy_split, i)
-
-		// the initial current ("") will always be in the cache as root element
-		if (bool_not(dict_in(caches["models"], current))):
-			// This element is not cached, so cache completely!
-			log("Miss for " + current_part)
+		if (current_part != ""):
+			dict = dict_create()
+			found = False
 			elems = allAssociationDestinations(core, current, "contains")
 			while (set_len(elems) > 0):
 				elem = set_pop(elems)
-				dict_overwrite(caches["models"][current], read_attribute(core, elem, "name"), elem)
-			dict_overwrite(caches["models"][current], "", current)
-		log("Ready for access: " + current_part)
+				if (value_eq(read_attribute(core, elem, "name"), current_part)):
+					current = elem
+					found = True
+					break!
 
-		if (dict_in(caches["models"][current], current_part)):
-			current = caches["models"][current][current_part]
-			log("SUCCESS: " + current)
-		else:
-			log("FAILED")
-			return ""!
+			if (bool_not(found)):
+				return ""!
+		i = i + 1
 
 	return current!
 
@@ -324,15 +320,20 @@ String function store_entry(model_id : String, full_name : String, user_id : Str
 	String prev
 	String elem
 	String new_entry
+	String cummul
 
 	i = 0
 	hierarchy = string_split(full_name, "/")
 	prev = get_entry_id("")
+	cummul = ""
 
 	// Go through folders first
 	while (i < list_len(hierarchy) - 1):
 		elem = list_read(hierarchy, i)
-		if (get_entry_id(elem) == ""):
+		if (cummul != ""):
+			cummul = string_join(cummul + "/", elem)
+
+		if (get_entry_id(cummul) == ""):
 			// Element does not exist yet!
 			new_entry = instantiate_node(core, "Folder", "")
 			instantiate_attribute(core, new_entry, "name", elem)
@@ -340,6 +341,8 @@ String function store_entry(model_id : String, full_name : String, user_id : Str
 			instantiate_link(core, "contains", "", prev, new_entry)
 			instantiate_link(core, "group", "", new_entry, get_group_id("nobody"))
 			instantiate_link(core, "owner", "", new_entry, user_id)
+		prev = get_entry_id(cummul)
+		i = i + 1
 
 	instantiate_link(core, "contains", "", prev, model_id)
 
@@ -352,7 +355,7 @@ String function export_typing(model : Element, name : String, user_id : String):
 
 	// Create type mapping model
 	String location
-	location = "type_mappings/" + cast_id2s(model["type_mapping"])
+	location = "type mappings/" + cast_id2s(model["type_mapping"])
 	export_node(location, model["type_mapping"])
 
 	String instance_of
@@ -362,8 +365,8 @@ String function export_typing(model : Element, name : String, user_id : String):
 	instantiate_attribute(core, result, "permissions", "200")
 	instantiate_link(core, "owner", "", result, user_id)
 	instantiate_link(core, "group", "", result, get_group_id("nobody"))
-	instance_of = instantiate_link(core, "instanceOf", "", result, get_entry_id("TypeMapping"))
-	instantiate_link(core, "semantics", "", instance_of, get_entry_id("conformance_mv"))
+	instance_of = instantiate_link(core, "instanceOf", "", result, get_entry_id("formalisms/TypeMapping"))
+	instantiate_link(core, "semantics", "", instance_of, get_entry_id("models/conformance_mv"))
 
 	return result!
 
@@ -383,7 +386,7 @@ Void function model_create(model : Element, name : String, user_id : String, typ
 	instantiate_link(core, "owner", "", model_id, user_id)
 	instantiate_link(core, "group", "", model_id, get_group_id("nobody"))
 	instance_of = instantiate_link(core, "instanceOf", "", model_id, type_id)
-	instantiate_link(core, "semantics", "", instance_of, get_entry_id("conformance_mv"))
+	instantiate_link(core, "semantics", "", instance_of, get_entry_id("models/conformance_mv"))
 
 	// Create type mapping model
 	instantiate_link(core, "typing", "", instance_of, export_typing(model, name, user_id))
@@ -413,7 +416,7 @@ Void function model_overwrite(model : Element, model_id : String, metamodel_id :
 	// Create a new instanceOf relation now
 	String instance_of
 	instance_of = instantiate_link(core, "instanceOf", "", model_id, metamodel_id)
-	instantiate_link(core, "semantics", "", instance_of, get_entry_id("conformance_mv"))
+	instantiate_link(core, "semantics", "", instance_of, get_entry_id("models/conformance_mv"))
 	instantiate_link(core, "typing", "", instance_of, export_typing(model, full_name(model_id), get_user_id("admin")))
 
 	return!
@@ -508,10 +511,10 @@ Element function execute_operation(operation_id : String, input_models : Element
 			set_add_node(model_tuples, create_tuple(key, mm))
 
 		Element merged_metamodel
-		merged_metamodel = get_full_model(merged_metamodel_id, get_entry_id("SimpleClassDiagrams"))
+		merged_metamodel = get_full_model(merged_metamodel_id, get_entry_id("formalisms/SimpleClassDiagrams"))
 		if (element_eq(merged_metamodel, read_root())):
-			log("Merged metamodel in operation is not of type SimpleClassDiagrams")
-			output("Merged metamodel in operation is not of type SimpleClassDiagrams")
+			log("Merged metamodel in operation is not of type formalisms/SimpleClassDiagrams")
+			output("Merged metamodel in operation is not of type formalisms/SimpleClassDiagrams")
 			return read_root()!
 
 		merged_model = model_join(model_tuples, merged_metamodel, tracability_model)
@@ -556,7 +559,7 @@ Element function execute_operation(operation_id : String, input_models : Element
 	elif (exact_type == "ActionLanguage"):
 		Element func
 		Element al
-		al = get_full_model(operation_id, get_entry_id("ActionLanguage"))
+		al = get_full_model(operation_id, get_entry_id("formalisms/ActionLanguage"))
 		if (element_eq(al, read_root())):
 			log("Action Language operation not typed by ActionLanguage metamodel!")
 			output("Action Language operation not typed by ActionLanguage metamodel!")
@@ -581,10 +584,10 @@ Element function execute_operation(operation_id : String, input_models : Element
 		while (set_len(keys) > 0):
 			key = set_pop(keys)
 			Element mm
-			mm = get_full_model(get_entry_id(output_metamodels[key]), get_entry_id("SimpleClassDiagrams"))
+			mm = get_full_model(get_entry_id(output_metamodels[key]), get_entry_id("formalisms/SimpleClassDiagrams"))
 			if (element_eq(mm, read_root())):
-				log("Output metamodel cannot be interpreted using SimpleClassDiagrams: " + key)
-				output("Output metamodel cannot be interpreted using SimpleClassDiagrams: " + key)
+				log("Output metamodel cannot be interpreted using formalisms/SimpleClassDiagrams: " + key)
+				output("Output metamodel cannot be interpreted using formalisms/SimpleClassDiagrams: " + key)
 				return read_root()!
 			set_add_node(model_tuples, create_tuple(key, mm))
 
@@ -832,9 +835,9 @@ String function cmd_model_add(user_id : String, type : String, name : String):
 			if (get_entry_id(name) == ""):
 				// Model doesn't exist yet
 				Element mm
-				mm = get_full_model(type_id, get_entry_id("SimpleClassDiagrams"))
+				mm = get_full_model(type_id, get_entry_id("formalisms/SimpleClassDiagrams"))
 				if (element_eq(mm, read_root())):
-					return "Type is not typed by SimpleClassDiagrams: " + type!
+					return "Type is not typed by formalisms/SimpleClassDiagrams: " + type!
 
 				output("Waiting for model constructors...")
 				new_model = construct_model_raw(mm)
@@ -855,7 +858,7 @@ String function cmd_process_execute(user_id : String, process : String, prefix :
 	if (process_id != ""):
 		if (allow_read(user_id, process_id)):
 			Element pm
-			pm = get_full_model(process_id, get_entry_id("ProcessModel"))
+			pm = get_full_model(process_id, get_entry_id("formalisms/ProcessModel"))
 			if (element_eq(pm, read_root())):
 				return "Specified model cannot be interpreted as a ProcessModel: " + process!
 
@@ -919,8 +922,8 @@ String function cmd_model_render(user_id : String, model_name : String, mapper_n
 				if (allow_read(user_id, mapper_ID)):
 					// Everything is fine; start the actual operation
 					// Find metamodel to render to
-					rendered_name = (("__RENDERED_" + model_name) + "__") + mapper_name
-					tracability_name = (("__TRACABILITY_" + model_name) + "__") + mapper_name
+					rendered_name = ("rendered/" + model_name) + mapper_name
+					tracability_name = ("tracability/" + model_name) + mapper_name
 
 					// Take the abstract syntax model and the previously rendered model
 					inputs = dict_create()
@@ -937,20 +940,20 @@ String function cmd_model_render(user_id : String, model_name : String, mapper_n
 					if (get_entry_id(rendered_name) == ""):
 						// Instantiate
 						Element rendered
-						rendered = get_full_model(get_entry_id(output_map["rendered"]), get_entry_id("SimpleClassDiagrams"))
+						rendered = get_full_model(get_entry_id(output_map["rendered"]), get_entry_id("formalisms/SimpleClassDiagrams"))
 						if (element_eq(rendered, read_root())):
-							return "Rendered metamodel cannot conform to SimpleClassDiagrams"!
+							return "Rendered metamodel cannot conform to formalisms/SimpleClassDiagrams"!
 
 						rendered_model = instantiate_model(rendered)
 						model_create(rendered_model, rendered_name, user_id, get_entry_id(output_map["rendered"]), "Model")
 						
 						// Tracability model won't exist either
-						tracability_model = instantiate_model(get_full_model(get_entry_id("Tracability"), get_entry_id("SimpleClassDiagrams")))
-						model_create(tracability_model, tracability_name, user_id, get_entry_id("Tracability"), "Model")
+						tracability_model = instantiate_model(get_full_model(get_entry_id("formalisms/Tracability"), get_entry_id("formalisms/SimpleClassDiagrams")))
+						model_create(tracability_model, tracability_name, user_id, get_entry_id("formalisms/Tracability"), "Model")
 
 					else:
 						// Read out tracability model
-						tracability_model = get_full_model(get_entry_id(tracability_name), get_entry_id("Tracability"))
+						tracability_model = get_full_model(get_entry_id(tracability_name), get_entry_id("formalisms/Tracability"))
 						if (element_eq(tracability_model, read_root())):
 							return "Tracability model not typed by Tracability metamodel: " + tracability_name!
 
@@ -962,8 +965,8 @@ String function cmd_model_render(user_id : String, model_name : String, mapper_n
 					model_overwrite(result["abstract"], get_entry_id(model_name), get_entry_id(output_map["abstract"]))
 
 					// Tracability updated in-place
-					model_overwrite(tracability_model, get_entry_id(tracability_name), get_entry_id("Tracability"))
-					tracability_model = get_full_model(get_entry_id(tracability_name), get_entry_id("Tracability"))
+					model_overwrite(tracability_model, get_entry_id(tracability_name), get_entry_id("formalisms/Tracability"))
+					tracability_model = get_full_model(get_entry_id(tracability_name), get_entry_id("formalisms/Tracability"))
 					if (element_eq(tracability_model, read_root())):
 						return "Tracability model not typed by Tracability metamodel: " + tracability_name!
 
@@ -1113,9 +1116,9 @@ String function cmd_model_overwrite(user_id : String, model_name : String, metam
 			type_id = set_pop(allAssociationDestinations(core, model_id, "instanceOf"))
 			if (allow_read(user_id, type_id)):
 				Element mm
-				mm = get_full_model(get_entry_id(metamodel_name), get_entry_id("SimpleClassDiagrams"))
+				mm = get_full_model(get_entry_id(metamodel_name), get_entry_id("formalisms/SimpleClassDiagrams"))
 				if (element_eq(mm, read_root())):
-					return "Metamodel does not conform to SimpleClassDiagrams: " + metamodel_name!
+					return "Metamodel does not conform to formalisms/SimpleClassDiagrams: " + metamodel_name!
 
 				output("Waiting for model constructors...")
 				new_model = construct_model_raw(mm)
@@ -1179,7 +1182,10 @@ String function cmd_model_list(location : String):
 	models = allAssociationDestinations(core, get_entry_id(location), "contains")
 	while (set_len(models) > 0):
 		m = set_pop(models)
-		result = result + string_join(string_join("  ", read_attribute(core, m, "name")), "\n")
+		if (is_nominal_instance(core, m, "Folder")):
+			result = result + string_join(read_attribute(core, m, "name"), "/\n")
+		else:
+			result = result + string_join(read_attribute(core, m, "name"), "\n")
 	return result!
 
 String function cmd_model_list_full(location : String):
@@ -1200,8 +1206,11 @@ String function cmd_model_list_full(location : String):
 		permissions = read_attribute(core, m, "permissions")
 		owner = read_attribute(core, set_pop(allAssociationDestinations(core, m, "owner")), "name")
 		group = read_attribute(core, set_pop(allAssociationDestinations(core, m, "group")), "name")
-		name = read_attribute(core, m, "name")
-		result = result + (((((((("  " + permissions) + " ") + owner) + " ") + group) + " ") + name) + "\n")
+		if (is_nominal_instance(core, m, "Folder")):
+			name = string_join(read_attribute(core, m, "name"), "/")
+		else:
+			name = read_attribute(core, m, "name")
+		result = result + (((((((permissions + " ") + owner) + " ") + group) + " ") + name) + "\n")
 
 	return result!
 
@@ -1244,9 +1253,9 @@ String function transformation_add(user_id : String, source_models : Element, ta
 			if (allow_read(user_id, model_id)):
 				if (bool_not(dict_in(source, key))):
 					dict_add(source, key, model_id)
-					mm = get_full_model(model_id, get_entry_id("SimpleClassDiagrams"))
+					mm = get_full_model(model_id, get_entry_id("formalisms/SimpleClassDiagrams"))
 					if (element_eq(mm, read_root())):
-						return "Transformation source type not in SimpleClassDiagrams hierarchy: " + key!
+						return "Transformation source type not in formalisms/SimpleClassDiagrams hierarchy: " + key!
 
 					if (bool_not(set_in(fused, key))):
 						set_add_node(formalism_map, create_tuple(key, mm))
@@ -1270,9 +1279,9 @@ String function transformation_add(user_id : String, source_models : Element, ta
 			if (allow_read(user_id, model_id)):
 				if (bool_not(dict_in(target, key))):
 					dict_add(target, key, model_id)
-					mm = get_full_model(model_id, get_entry_id("SimpleClassDiagrams"))
+					mm = get_full_model(model_id, get_entry_id("formalisms/SimpleClassDiagrams"))
 					if (element_eq(mm, read_root())):
-						return "Transformation target type not in SimpleClassDiagrams hierarchy: " + key!
+						return "Transformation target type not in formalisms/SimpleClassDiagrams hierarchy: " + key!
 
 					if (bool_not(set_in(fused, key))):
 						set_add_node(formalism_map, create_tuple(key, mm))
@@ -1297,23 +1306,23 @@ String function transformation_add(user_id : String, source_models : Element, ta
 		if (operation_type == "manual"):
 			// Finished with all information, now create the model itself!
 			Element m
-			m = get_full_model(get_entry_id("ManualOperation"), get_entry_id("SimpleClassDiagrams"))
+			m = get_full_model(get_entry_id("formalisms/ManualOperation"), get_entry_id("formalisms/SimpleClassDiagrams"))
 			if (element_eq(m, read_root())):
 				log("Error when opening ManualOperation: no conformance relation found")
 				return "Error when opening ManualOperation: no conformance relation found"!
-			model_create(instantiate_model(m), operation_name, user_id, get_entry_id("ManualOperation"), "ManualOperation")
+			model_create(instantiate_model(m), operation_name, user_id, get_entry_id("formalisms/ManualOperation"), "ManualOperation")
 			model_id = get_entry_id(operation_name)
 
 		elif (operation_type == "actionlanguage"):
 			// Finished with all information, now create the model itself!
 			output("Waiting for code constructors...")
-			add_code_model(get_full_model(get_entry_id("ActionLanguage"), get_entry_id("SimpleClassDiagrams")), "AL/" + operation_name, construct_function())
-			model_create(import_node("AL/" + operation_name), operation_name, user_id, get_entry_id("ActionLanguage"), "ActionLanguage")
+			add_code_model(get_full_model(get_entry_id("formalisms/ActionLanguage"), get_entry_id("formalisms/SimpleClassDiagrams")), "AL/" + operation_name, construct_function())
+			model_create(import_node("AL/" + operation_name), operation_name, user_id, get_entry_id("formalisms/ActionLanguage"), "ActionLanguage")
 			model_id = get_entry_id(operation_name)
 
 		if (bool_not(bool_and(dict_len(source_models) == 0, dict_len(target_models) == 0))):
-			model_create(merged_formalism, "__merged_" + operation_name, user_id, get_entry_id("SimpleClassDiagrams"), "Model")
-			merged_formalism_id = get_entry_id("__merged_" + operation_name)
+			model_create(merged_formalism, "merged/" + operation_name, user_id, get_entry_id("formalisms/SimpleClassDiagrams"), "Model")
+			merged_formalism_id = get_entry_id("merged/" + operation_name)
 
 			// Add tracability links at this level
 			while (set_len(all_formalisms) > 0):
@@ -1380,13 +1389,13 @@ String function cmd_transformation_add_MT(user_id : String, source_models : Elem
 		model_id = get_entry_id(name)
 		if (model_id != ""):
 			if (allow_read(user_id, name)):
-				// Check whether or not it is SimpleClassDiagrams
-				if (is_typed_by(model_id, get_entry_id("SimpleClassDiagrams"))):
+				// Check whether or not it is formalisms/SimpleClassDiagrams
+				if (is_typed_by(model_id, get_entry_id("formalisms/SimpleClassDiagrams"))):
 					if (bool_not(dict_in(source, key))):
 						dict_add(source, key, model_id)
-						mm = get_full_model(model_id, get_entry_id("SimpleClassDiagrams"))
+						mm = get_full_model(model_id, get_entry_id("formalisms/SimpleClassDiagrams"))
 						if (element_eq(mm, read_root())):
-							return "ModelTransformation source type not in SimpleClassDiagrams hierarchy: " + name!
+							return "ModelTransformation source type not in formalisms/SimpleClassDiagrams hierarchy: " + name!
 						set_add_node(to_ramify, create_tuple(key, mm))
 					else:
 						return "Name was already assigned a metamodel: " + key!
@@ -1404,7 +1413,7 @@ String function cmd_transformation_add_MT(user_id : String, source_models : Elem
 		model_id = get_entry_id(name)
 		if (model_id != ""):
 			if (allow_read(user_id, name)):
-				if (is_typed_by(model_id, get_entry_id("SimpleClassDiagrams"))):
+				if (is_typed_by(model_id, get_entry_id("formalisms/SimpleClassDiagrams"))):
 					if (bool_not(dict_in(target, key))):
 						if (dict_in(source, key)):
 							if (value_eq(model_id, source[key])):
@@ -1414,9 +1423,9 @@ String function cmd_transformation_add_MT(user_id : String, source_models : Elem
 								return "Name in output cannot have different type than input: " + key!
 						else:
 							dict_add(target, key, model_id)
-							mm = get_full_model(model_id, get_entry_id("SimpleClassDiagrams"))
+							mm = get_full_model(model_id, get_entry_id("formalisms/SimpleClassDiagrams"))
 							if (element_eq(mm, read_root())):
-								return "ModelTransformation target type not in SimpleClassDiagrams hierarchy: " + name!
+								return "ModelTransformation target type not in formalisms/SimpleClassDiagrams hierarchy: " + name!
 							set_add_node(to_ramify, create_tuple(key, mm))
 					else:
 						return "Name was already assigned a metamodel: " + key!
@@ -1431,22 +1440,22 @@ String function cmd_transformation_add_MT(user_id : String, source_models : Elem
 	modify(merged_formalism, True)
 
 	ramified_metamodel = ramify(merged_formalism)
-	model_create(ramified_metamodel, "__RAM_" + operation_name, user_id, get_entry_id("SimpleClassDiagrams"), "Model")
-	ramified_metamodel_id = get_entry_id("__RAM_" + operation_name)
+	model_create(ramified_metamodel, "RAMified/" + operation_name, user_id, get_entry_id("formalisms/SimpleClassDiagrams"), "Model")
+	ramified_metamodel_id = get_entry_id("RAMified" + operation_name)
 	
 	// Now use the RAMified model to create the instance
 	if (get_entry_id(operation_name) == ""):
 		String new_model
 		// Finished with all information, now create the model itself!
 		output("Waiting for model constructors...")
-		new_model = construct_model_raw(get_full_model(ramified_metamodel_id, get_entry_id("SimpleClassDiagrams")))
+		new_model = construct_model_raw(get_full_model(ramified_metamodel_id, get_entry_id("formalisms/SimpleClassDiagrams")))
 		model_create(new_model, operation_name, user_id, ramified_metamodel_id, "ModelTransformation")
 		model_id = get_entry_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_entry_id("SimpleClassDiagrams"), "Model")
-		merged_formalism_id = get_entry_id("__merged_" + operation_name)
+		model_create(merged_formalism, "merged/" + operation_name, user_id, get_entry_id("formalisms/SimpleClassDiagrams"), "Model")
+		merged_formalism_id = get_entry_id("merged/" + operation_name)
 
 		// Add tracability links at this level
 		tracability_link = instantiate_link(core, "tracability", "", model_id, merged_formalism_id)
@@ -1824,8 +1833,7 @@ Void function user_function_skip_init(user_id : String):
 		elem = set_pop(elems)
 		if (value_eq(read_attribute(core, elem, "name"), "")):
 			if (set_len(allIncomingAssociationInstances(core, elem, "contains")) == 0):
-				dict_add_fast(caches["models"], "", dict_create())
-				dict_add_fast(caches["models"][""], "", elem)
+				dict_add_fast(caches, "root", elem)
 				break!
 
 	output("Welcome to the Model Management Interface v2.0!")

+ 168 - 160
integration/test_mvc.py

@@ -6,51 +6,54 @@ import sys
 sys.path.append("wrappers")
 from modelverse import *
 
-expected_model_list = set([("SimpleClassDiagrams", "SimpleClassDiagrams"),
-                           ("CoreFormalism", "SimpleClassDiagrams"),
-                           ("ManualOperation", "SimpleClassDiagrams"),
-                           ("ActionLanguage", "SimpleClassDiagrams"),
-                           ("ProcessModel", "SimpleClassDiagrams"),
-                           ("Tracability", "SimpleClassDiagrams"),
-                           ("conformance_mv", "ActionLanguage"),
-                           ("bottom", "SimpleClassDiagrams"),
-                           ("core", "CoreFormalism"),
-                           ('TypeMapping', 'SimpleClassDiagrams'),
-                           ('TM_SimpleClassDiagrams', 'TypeMapping'),
-                           ('TM_TypeMapping', 'TypeMapping'),
-                           ('TM_Tracability', 'TypeMapping'),
-                           ('TM_ProcessModel', 'TypeMapping'),
-                           ('TM_ActionLanguage', 'TypeMapping'),
-                           ('TM_ManualOperation', 'TypeMapping'),
-                           ('TM_conformance_mv', 'TypeMapping'),
-                           ('TM_CoreFormalism', 'TypeMapping'),
-                           ('TM_core', 'TypeMapping'),
-                           ('TM_bottom', 'TypeMapping'),
-                          ])
-
-expected_model_full_list = set([("SimpleClassDiagrams", "SimpleClassDiagrams", "admin", "admin", "221"),
-                                ("CoreFormalism", "SimpleClassDiagrams", "admin", "admin", "221"),
-                                ("ManualOperation", "SimpleClassDiagrams", "admin", "admin", "221"),
-                                ("ActionLanguage", "SimpleClassDiagrams", "admin", "admin", "221"),
-                                ("ProcessModel", "SimpleClassDiagrams", "admin", "admin", "221"),
-                                ("Tracability", "SimpleClassDiagrams", "admin", "admin", "221"),
-                                ("bottom", "SimpleClassDiagrams", "admin", "admin", "221"),
-                                ("conformance_mv", "ActionLanguage", "admin", "admin", "221"),
-                                ("core", "CoreFormalism", "admin", "admin", "220"),
-                                ('TypeMapping', 'SimpleClassDiagrams', "admin", "admin", "221"),
-                                ('TM_SimpleClassDiagrams', 'TypeMapping', "admin", "admin", "221"),
-                                ('TM_TypeMapping', 'TypeMapping', "admin", "admin", "221"),
-                                ('TM_Tracability', 'TypeMapping', "admin", "admin", "221"),
-                                ('TM_ProcessModel', 'TypeMapping', "admin", "admin", "221"),
-                                ('TM_ActionLanguage', 'TypeMapping', "admin", "admin", "221"),
-                                ('TM_ManualOperation', 'TypeMapping', "admin", "admin", "221"),
-                                ('TM_conformance_mv', 'TypeMapping', "admin", "admin", "221"),
-                                ('TM_CoreFormalism', 'TypeMapping', "admin", "admin", "221"),
-                                ('TM_core', 'TypeMapping', "admin", "admin", "220"),
-                                ('TM_bottom', 'TypeMapping', "admin", "admin", "221"),
-                                ])
-
-expected_transformation_list = set([("ActionLanguage", "conformance_mv")])
+model_hierarchy = \
+            {"formalisms/": {"SimpleClassDiagrams": {},
+                             "TypeMapping": {},
+                             "Tracability": {},
+                             "ProcessModel": {},
+                             "ActionLanguage": {},
+                             "ManualOperation": {},
+                             "Bottom": {},
+                            },
+            "models/": {"conformance_mv": {},
+                        },
+            "administration/": {"core": {},
+                                "CoreFormalism": {},
+                               },
+            "users/": {"admin/": {}
+                      },
+            "type mappings/": {"formalisms/": {"SimpleClassDiagrams": {},
+                                               "TypeMapping": {},
+                                               "Tracability": {},
+                                               "ProcessModel": {},
+                                               "ActionLanguage": {},
+                                               "ManualOperation": {},
+                                               "Bottom": {},
+                                              },
+                               "models/": {"conformance_mv": {},
+                                          },
+                               "administration/": {"core": {},
+                                                   "CoreFormalism": {},
+                                                  },
+                               "users/": {"admin/": {}
+                                         },
+                              },
+            }
+
+def get_model_list(location):
+    try:
+        location_parts = location.split("/")
+        current = model_hierarchy
+        while location_parts:
+            l = location_parts.pop(0)
+            if l != "":
+                current = current[l + "/"]
+        return set(current.keys())
+    except:
+        return set([])
+
+def compare_locations(location, extra_to_default):
+    assert model_list(location) == get_model_list(location) | set(extra_to_default)
 
 class TestModelverseCore(unittest.TestCase):
     def setUp(self):
@@ -65,56 +68,71 @@ class TestModelverseCore(unittest.TestCase):
             print("Got exception during teardown.")
 
     def test_list(self):
-        assert model_list() == expected_model_list
+        compare_locations("", set())
+        compare_locations("formalisms", set())
+        compare_locations("models", set())
+        compare_locations("administration", set())
+        compare_locations("type mappings", set())
+        compare_locations("type mappings/formalisms", set())
+        compare_locations("type mappings/administration", set())
+        compare_locations("type mappings/models", set())
         
     def test_list_full(self):
-        assert model_list_full() == expected_model_full_list
+        assert model_list_full("") == set([("formalisms/", "admin", "admin", "221"),
+                                           ("models/", "admin", "admin", "221"),
+                                           ("administration/", "admin", "admin", "110"),
+                                           ("type mappings/", "admin", "admin", "221"),
+                                           ("users/", "admin", "admin", "221"),
+                                          ])
 
     def test_model_add_empty(self):
-        model_add("Empty", "SimpleClassDiagrams")
-        assert model_list() == set(list(expected_model_list) + [("Empty", "SimpleClassDiagrams"), ("TM_Empty", "TypeMapping")])
-        assert model_list_full() == set(list(expected_model_full_list) + [("Empty", "SimpleClassDiagrams", "admin", "nobody", "200"),
-                                                                          ("TM_Empty", "TypeMapping", "admin", "nobody", "200"),
-                                                                         ])
+        model_add("formalisms/Empty", "formalisms/SimpleClassDiagrams")
+        compare_locations("formalisms", set(["Empty"]))
+        compare_locations("type mappings/formalisms", set(["Empty"]))
+        assert model_list_full("formalisms") == set([(name, "admin", "admin", "221") for name in get_model_list("formalisms")]) | \
+                                                set([("Empty", "admin", "nobody", "200")])
+        assert model_list_full("type mappings/formalisms") == set([(name, "admin", "admin", "221") for name in get_model_list("type mappings/formalisms")]) | \
+                                                              set([("Empty", "admin", "nobody", "200")])
 
     def test_model_verify(self):
-        assert verify("SimpleClassDiagrams", "SimpleClassDiagrams") == "OK"
+        assert verify("formalisms/SimpleClassDiagrams", "formalisms/SimpleClassDiagrams") == "OK"
 
     def test_model_empty_instantiate(self):
-        model_add("Empty", "SimpleClassDiagrams")
-        assert model_list() == set(list(expected_model_list) + [("Empty", "SimpleClassDiagrams"), ("TM_Empty", "TypeMapping")])
-        assert element_list("Empty") == set([])
-        instantiate("Empty", "Class", ID="A")
-        assert element_list("Empty") == set([("A", "Class")])
-        assert model_list() == set(list(expected_model_list) + [("Empty", "SimpleClassDiagrams"), ("TM_Empty", "TypeMapping")])
+        model_add("formalisms/Empty", "formalisms/SimpleClassDiagrams")
+        instantiate("formalisms/Empty", "Class", ID="A")
+        assert element_list("formalisms/Empty") == set([("A", "Class")])
+        compare_locations("formalisms", set(["Empty"]))
+        compare_locations("type mappings/formalisms", set(["Empty"]))
 
     def test_model_overwrite(self):
-        model_add("Empty", "SimpleClassDiagrams")
-        assert model_list() == set(list(expected_model_list) + [("Empty", "SimpleClassDiagrams"), ("TM_Empty", "TypeMapping")])
-        assert element_list("Empty") == set([])
-        instantiate("Empty", "Class", ID="A")
-        assert element_list("Empty") == set([("A", "Class")])
-        model_overwrite("Empty")
-        assert element_list("Empty") == set([])
-        assert model_list() == set(list(expected_model_list) + [("Empty", "SimpleClassDiagrams"), ("TM_Empty", "TypeMapping")])
-        instantiate("Empty", "Class", ID="B")
-        assert element_list("Empty") == set([("B", "Class")])
+        model_add("formalisms/Empty", "formalisms/SimpleClassDiagrams")
+        assert element_list("formalisms/Empty") == set([])
+        instantiate("formalisms/Empty", "Class", ID="A")
+        assert element_list("formalisms/Empty") == set([("A", "Class")])
+        model_overwrite("formalisms/Empty")
+        assert element_list("formalisms/Empty") == set([])
+        compare_locations("formalisms", set(["Empty"]))
+        compare_locations("type mappings/formalisms", set(["Empty"]))
+        assert element_list("formalisms/Empty") == set([])
+
+        instantiate("formalisms/Empty", "Class", ID="B")
+        compare_locations("formalisms", set(["Empty"]))
+        compare_locations("type mappings/formalisms", set(["Empty"]))
 
     def test_transform_add_MT(self):
-        model_add("PetriNet", "SimpleClassDiagrams", open("integration/code/petrinets.mvc", "r").read())
-        assert model_list() == set(list(expected_model_list) + [("PetriNet", "SimpleClassDiagrams"),
-                                                                ("TM_PetriNet", "TypeMapping"),
-                                                               ])
-        transformation_add_MT({"PetriNet": "PetriNet"}, {}, "print_pn", open("integration/code/pn_print.mvc").read())
-        assert model_list() == set(list(expected_model_list) + [("PetriNet", "SimpleClassDiagrams"),
-                                                                ("TM_PetriNet", "TypeMapping"),
-                                                                ("__RAM_print_pn", "SimpleClassDiagrams"),
-                                                                ("TM___RAM_print_pn", "TypeMapping"),
-                                                                ("__merged_print_pn", "SimpleClassDiagrams"),
-                                                                ("TM___merged_print_pn", "TypeMapping"),
-                                                                ("print_pn", "__RAM_print_pn"),
-                                                                ("TM_print_pn", "TypeMapping")])
-        assert transformation_list() == set(list(expected_transformation_list) + [("ModelTransformation", "print_pn")])
+        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"]))
+        transformation_add_MT({"PetriNet": "formalisms/PetriNet"}, {}, "models/print_pn", open("integration/code/pn_print.mvc").read())
+
+        compare_locations("formalisms", set(["PetriNet"]))
+        compare_locations("models", set(["print_pn"]))
+        compare_locations("RAMified/formalisms", set(["print_pn"]))
+        compare_locations("merged/formalisms", set(["print_pn"]))
+        compare_locations("type mappings/formalisms", set(["PetriNet"]))
+        compare_locations("type mappings/models", set(["print_pn"]))
+        compare_locations("type mappings/RAMified/formalisms", set(["print_pn"]))
+        compare_locations("type mappings/merged/formalisms", set(["print_pn"]))
 
     def test_transform_add_MT_pn_print_exec(self):
         log = []
@@ -122,26 +140,16 @@ class TestModelverseCore(unittest.TestCase):
         def callback(value):
             log.append(value)
 
-        model_add("PetriNet", "SimpleClassDiagrams", open("integration/code/pn_runtime.mvc", "r").read())
-        model_add("my_pn", "PetriNet", open("integration/code/pn_runtime_model.mvc", "r").read())
-        assert model_list() == set(list(expected_model_list) + [("PetriNet", "SimpleClassDiagrams"),
-                                                                ("TM_PetriNet", "TypeMapping"),
-                                                                ("my_pn", "PetriNet"),
-                                                                ("TM_my_pn", "TypeMapping"),
-                                                               ])
-        transformation_add_MT({"PetriNet": "PetriNet"}, {}, "print_pn", open("integration/code/pn_print.mvc").read())
-        assert model_list() == set(list(expected_model_list) + [("PetriNet", "SimpleClassDiagrams"),
-                                                                ("TM_PetriNet", "TypeMapping"),
-                                                                ("my_pn", "PetriNet"),
-                                                                ("TM_my_pn", "TypeMapping"),
-                                                                ("__RAM_print_pn", "SimpleClassDiagrams"),
-                                                                ("TM___RAM_print_pn", "TypeMapping"),
-                                                                ("__merged_print_pn", "SimpleClassDiagrams"),
-                                                                ("TM___merged_print_pn", "TypeMapping"),
-                                                                ("print_pn", "__RAM_print_pn"),
-                                                                ("TM_print_pn", "TypeMapping")])
-        assert transformation_list() == set(list(expected_transformation_list) + [("ModelTransformation", "print_pn")])
-        assert transformation_execute_MT("print_pn", {"PetriNet": "my_pn"}, {}, callback) == True
+        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"]))
+
+        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"]))
+
+        assert transformation_execute_MT("models/print_pn", {"PetriNet": "models/my_pn"}, {}, callback) == True
 
         assert set(log) == set(['"p1" --> 1',
                                 '"p2" --> 2',
@@ -166,10 +174,10 @@ class TestModelverseCore(unittest.TestCase):
         def callback(value):
             log.append(value)
 
-        model_add("PetriNet", "SimpleClassDiagrams", open("integration/code/pn_design.mvc", "r").read())
-        model_add("PetriNet_Runtime", "SimpleClassDiagrams", open("integration/code/pn_runtime.mvc", "r").read())
+        model_add("formalisms/PetriNet", "formalisms/SimpleClassDiagrams", open("integration/code/pn_design.mvc", "r").read())
+        model_add("formalisms/PetriNet_Runtime", "formalisms/SimpleClassDiagrams", open("integration/code/pn_runtime.mvc", "r").read())
 
-        model_add("my_pn", "PetriNet", open("integration/code/pn_design_model.mvc", "r").read())
+        model_add("models/my_pn", "PetriNet", open("integration/code/pn_design_model.mvc", "r").read())
 
         def add_tracability_D2R():
             instantiate(None, "Association", ("PetriNet/Place", "PetriNet_Runtime/Place"), ID="D2R_PlaceLink")
@@ -179,23 +187,23 @@ class TestModelverseCore(unittest.TestCase):
             instantiate(None, "Association", ("PetriNet_Runtime/Place", "PetriNet/Place"), ID="R2D_PlaceLink")
             instantiate(None, "Association", ("PetriNet_Runtime/Transition", "PetriNet/Transition"), ID="R2D_TransitionLink")
 
-        transformation_add_MT({"PetriNet": "PetriNet"}, {}, "print_pn", open("integration/code/pn_print.mvc").read())
-        transformation_add_MT({"PetriNet": "PetriNet"}, {"PetriNet_Runtime": "PetriNet_Runtime"}, "pn_design_to_runtime", open("integration/code/pn_design_to_runtime.mvc").read(), add_tracability_D2R)
-        transformation_add_MT({"PetriNet_Runtime": "PetriNet_Runtime"}, {"PetriNet_Runtime": "PetriNet_Runtime"}, "pn_simulate", open("integration/code/pn_simulate.mvc").read())
-        transformation_add_MT({"PetriNet_Runtime": "PetriNet_Runtime"}, {"PetriNet": "PetriNet"}, "pn_runtime_to_design", open("integration/code/pn_runtime_to_design.mvc").read(), add_tracability_R2D)
+        transformation_add_MT({"PetriNet": "formalisms/PetriNet"}, {}, "models/print_pn", open("integration/code/pn_print.mvc").read())
+        transformation_add_MT({"PetriNet": "formalisms/PetriNet"}, {"PetriNet_Runtime": "formalisms/PetriNet_Runtime"}, "models/pn_design_to_runtime", open("integration/code/pn_design_to_runtime.mvc").read(), add_tracability_D2R)
+        transformation_add_MT({"PetriNet_Runtime": "formalisms/PetriNet_Runtime"}, {"PetriNet_Runtime": "formalisms/PetriNet_Runtime"}, "models/pn_simulate", open("integration/code/pn_simulate.mvc").read())
+        transformation_add_MT({"PetriNet_Runtime": "formalisms/PetriNet_Runtime"}, {"PetriNet": "formalisms/PetriNet"}, "models/pn_runtime_to_design", open("integration/code/pn_runtime_to_design.mvc").read(), add_tracability_R2D)
 
         log = []
-        assert transformation_execute_MT("print_pn", {"PetriNet": "my_pn"}, {}, callback) == True
+        assert transformation_execute_MT("models/print_pn", {"PetriNet": "models/my_pn"}, {}, callback) == True
         assert set(log) == set(['"p1" --> 1',
                                 '"p2" --> 2',
                                 '"p3" --> 3'])
 
-        assert transformation_execute_MT("pn_design_to_runtime", {"PetriNet": "my_pn"}, {"PetriNet_Runtime": "my_pn_RT"}) == True
-        assert transformation_execute_MT("pn_simulate", {"PetriNet_Runtime": "my_pn_RT"}, {"PetriNet_Runtime": "my_pn_RT"}) == True
-        assert transformation_execute_MT("pn_runtime_to_design", {"PetriNet_Runtime": "my_pn_RT"}, {"PetriNet": "my_pn"}) == True
+        assert transformation_execute_MT("models/pn_design_to_runtime", {"PetriNet": "models/my_pn"}, {"PetriNet_Runtime": "models/my_pn_RT"}) == True
+        assert transformation_execute_MT("models/pn_simulate", {"PetriNet_Runtime": "models/my_pn_RT"}, {"PetriNet_Runtime": "models/my_pn_RT"}) == True
+        assert transformation_execute_MT("models/pn_runtime_to_design", {"PetriNet_Runtime": "models/my_pn_RT"}, {"PetriNet": "models/my_pn"}) == True
 
         log = []
-        assert transformation_execute_MT("print_pn", {"PetriNet": "my_pn"}, {}, callback) == True
+        assert transformation_execute_MT("models/print_pn", {"PetriNet": "models/my_pn"}, {}, callback) == True
         assert set(log) == set(['"p1" --> 0',
                                 '"p2" --> 1',
                                 '"p3" --> 5'])
@@ -206,10 +214,10 @@ class TestModelverseCore(unittest.TestCase):
         def callback(value):
             log.append(value)
 
-        model_add("PetriNet", "SimpleClassDiagrams", open("integration/code/pn_design.mvc", "r").read())
-        model_add("PetriNet_Runtime", "SimpleClassDiagrams", open("integration/code/pn_runtime.mvc", "r").read())
+        model_add("formalisms/PetriNet", "formalisms/SimpleClassDiagrams", open("integration/code/pn_design.mvc", "r").read())
+        model_add("formalisms/PetriNet_Runtime", "formalisms/SimpleClassDiagrams", open("integration/code/pn_runtime.mvc", "r").read())
 
-        model_add("my_pn", "PetriNet", open("integration/code/pn_design_model.mvc", "r").read())
+        model_add("models/my_pn", "formalisms/PetriNet", open("integration/code/pn_design_model.mvc", "r").read())
 
         def add_tracability_D2R():
             instantiate(None, "Association", ("PetriNet/Place", "PetriNet_Runtime/Place"), ID="D2R_PlaceLink")
@@ -219,23 +227,23 @@ class TestModelverseCore(unittest.TestCase):
             instantiate(None, "Association", ("PetriNet_Runtime/Place", "PetriNet/Place"), ID="R2D_PlaceLink")
             instantiate(None, "Association", ("PetriNet_Runtime/Transition", "PetriNet/Transition"), ID="R2D_TransitionLink")
 
-        transformation_add_MT({"PetriNet": "PetriNet"}, {}, "print_pn", open("integration/code/pn_print.mvc").read())
-        transformation_add_MT({"PetriNet": "PetriNet"}, {"PetriNet_Runtime": "PetriNet_Runtime"}, "pn_design_to_runtime", open("integration/code/pn_design_to_runtime.mvc").read(), add_tracability_D2R)
-        transformation_add_AL({"PetriNet_Runtime": "PetriNet_Runtime"}, {"PetriNet_Runtime": "PetriNet_Runtime"}, "pn_simulate", open("integration/code/pn_simulate.alc").read())
-        transformation_add_MT({"PetriNet_Runtime": "PetriNet_Runtime"}, {"PetriNet": "PetriNet"}, "pn_runtime_to_design", open("integration/code/pn_runtime_to_design.mvc").read(), add_tracability_R2D)
+        transformation_add_MT({"PetriNet": "formalisms/PetriNet"}, {}, "models/print_pn", open("integration/code/pn_print.mvc").read())
+        transformation_add_MT({"PetriNet": "formalisms/PetriNet"}, {"PetriNet_Runtime": "formalisms/PetriNet_Runtime"}, "models/pn_design_to_runtime", open("integration/code/pn_design_to_runtime.mvc").read(), add_tracability_D2R)
+        transformation_add_AL({"PetriNet_Runtime": "formalisms/PetriNet_Runtime"}, {"PetriNet_Runtime": "formalisms/PetriNet_Runtime"}, "models/pn_simulate", open("integration/code/pn_simulate.alc").read())
+        transformation_add_MT({"PetriNet_Runtime": "formalisms/PetriNet_Runtime"}, {"PetriNet": "formalisms/PetriNet"}, "models/pn_runtime_to_design", open("integration/code/pn_runtime_to_design.mvc").read(), add_tracability_R2D)
 
         log = []
-        assert transformation_execute_MT("print_pn", {"PetriNet": "my_pn"}, {}, callback) == True
+        assert transformation_execute_MT("models/print_pn", {"PetriNet": "models/my_pn"}, {}, callback) == True
         assert set(log) == set(['"p1" --> 1',
                                 '"p2" --> 2',
                                 '"p3" --> 3'])
 
-        assert transformation_execute_MT("pn_design_to_runtime", {"PetriNet": "my_pn"}, {"PetriNet_Runtime": "my_pn_RT"}) == True
-        assert transformation_execute_AL("pn_simulate", {"PetriNet_Runtime": "my_pn_RT"}, {"PetriNet_Runtime": "my_pn_RT"}) == True
-        assert transformation_execute_MT("pn_runtime_to_design", {"PetriNet_Runtime": "my_pn_RT"}, {"PetriNet": "my_pn"}) == True
+        assert transformation_execute_MT("models/pn_design_to_runtime", {"PetriNet": "models/my_pn"}, {"PetriNet_Runtime": "models/my_pn_RT"}) == True
+        assert transformation_execute_AL("models/pn_simulate", {"PetriNet_Runtime": "models/my_pn_RT"}, {"PetriNet_Runtime": "models/my_pn_RT"}) == True
+        assert transformation_execute_MT("models/pn_runtime_to_design", {"PetriNet_Runtime": "models/my_pn_RT"}, {"PetriNet": "models/my_pn"}) == True
 
         log = []
-        assert transformation_execute_MT("print_pn", {"PetriNet": "my_pn"}, {}, callback) == True
+        assert transformation_execute_MT("models/print_pn", {"PetriNet": "models/my_pn"}, {}, callback) == True
         assert set(log) == set(['"p1" --> 0',
                                 '"p2" --> 1',
                                 '"p3" --> 5'])
@@ -266,10 +274,10 @@ class TestModelverseCore(unittest.TestCase):
             t2p1 = instantiate(None, "PetriNet_Runtime/T2P", (t1, p3))
             attr_assign(None, t2p1, "weight", 2)
 
-        model_add("PetriNet", "SimpleClassDiagrams", open("integration/code/pn_design.mvc", "r").read())
-        model_add("PetriNet_Runtime", "SimpleClassDiagrams", open("integration/code/pn_runtime.mvc", "r").read())
+        model_add("formalisms/PetriNet", "formalisms/SimpleClassDiagrams", open("integration/code/pn_design.mvc", "r").read())
+        model_add("formalisms/PetriNet_Runtime", "formalisms/SimpleClassDiagrams", open("integration/code/pn_runtime.mvc", "r").read())
 
-        model_add("my_pn", "PetriNet", open("integration/code/pn_design_model.mvc", "r").read())
+        model_add("models/my_pn", "formalisms/PetriNet", open("integration/code/pn_design_model.mvc", "r").read())
 
         def add_tracability_D2R():
             instantiate(None, "Association", ("PetriNet/Place", "PetriNet_Runtime/Place"), ID="D2R_PlaceLink")
@@ -279,35 +287,35 @@ class TestModelverseCore(unittest.TestCase):
             instantiate(None, "Association", ("PetriNet_Runtime/Place", "PetriNet/Place"), ID="R2D_PlaceLink")
             instantiate(None, "Association", ("PetriNet_Runtime/Transition", "PetriNet/Transition"), ID="R2D_TransitionLink")
 
-        transformation_add_MT({"PetriNet": "PetriNet"}, {}, "print_pn", open("integration/code/pn_print.mvc").read())
-        transformation_add_MANUAL({"PetriNet": "PetriNet"}, {"PetriNet_Runtime": "PetriNet_Runtime"}, "pn_design_to_runtime", add_tracability_D2R)
-        transformation_add_AL({"PetriNet_Runtime": "PetriNet_Runtime"}, {"PetriNet_Runtime": "PetriNet_Runtime"}, "pn_simulate", open("integration/code/pn_simulate.alc").read())
-        transformation_add_MT({"PetriNet_Runtime": "PetriNet_Runtime"}, {"PetriNet": "PetriNet"}, "pn_runtime_to_design", open("integration/code/pn_runtime_to_design.mvc").read(), add_tracability_R2D)
+        transformation_add_MT({"PetriNet": "formalisms/PetriNet"}, {}, "models/print_pn", open("integration/code/pn_print.mvc").read())
+        transformation_add_MANUAL({"PetriNet": "formalisms/PetriNet"}, {"PetriNet_Runtime": "formalisms/PetriNet_Runtime"}, "models/pn_design_to_runtime", add_tracability_D2R)
+        transformation_add_AL({"PetriNet_Runtime": "formalisms/PetriNet_Runtime"}, {"PetriNet_Runtime": "formalisms/PetriNet_Runtime"}, "models/pn_simulate", open("integration/code/pn_simulate.alc").read())
+        transformation_add_MT({"PetriNet_Runtime": "formalisms/PetriNet_Runtime"}, {"PetriNet": "formalisms/PetriNet"}, "models/pn_runtime_to_design", open("integration/code/pn_runtime_to_design.mvc").read(), add_tracability_R2D)
 
         log = []
-        assert transformation_execute_MT("print_pn", {"PetriNet": "my_pn"}, {}, callback) == True
+        assert transformation_execute_MT("models/print_pn", {"PetriNet": "models/my_pn"}, {}, callback) == True
         assert set(log) == set(['"p1" --> 1',
                                 '"p2" --> 2',
                                 '"p3" --> 3'])
 
-        assert transformation_execute_MANUAL("pn_design_to_runtime", {"PetriNet": "my_pn"}, {"PetriNet_Runtime": "my_pn_RT"}, manual_callback) == True
-        assert transformation_execute_AL("pn_simulate", {"PetriNet_Runtime": "my_pn_RT"}, {"PetriNet_Runtime": "my_pn_RT"}) == True
-        assert transformation_execute_MT("pn_runtime_to_design", {"PetriNet_Runtime": "my_pn_RT"}, {"PetriNet": "my_pn"}) == True
+        assert transformation_execute_MANUAL("models/pn_design_to_runtime", {"PetriNet": "models/my_pn"}, {"PetriNet_Runtime": "models/my_pn_RT"}, manual_callback) == True
+        assert transformation_execute_AL("models/pn_simulate", {"PetriNet_Runtime": "models/my_pn_RT"}, {"PetriNet_Runtime": "models/my_pn_RT"}) == True
+        assert transformation_execute_MT("models/pn_runtime_to_design", {"PetriNet_Runtime": "models/my_pn_RT"}, {"PetriNet": "models/my_pn"}) == True
 
         log = []
-        assert transformation_execute_MT("print_pn", {"PetriNet": "my_pn"}, {}, callback) == True
+        assert transformation_execute_MT("models/print_pn", {"PetriNet": "models/my_pn"}, {}, callback) == True
         assert set(log) == set(['"p1" --> 0',
                                 '"p2" --> 1',
                                 '"p3" --> 5'])
 
     def test_process_model_trivial_pn_bigmain(self):
-        model_add("PetriNet", "SimpleClassDiagrams", open("integration/code/pn_design.mvc", "r").read())
-        model_add("ReachabilityGraph", "SimpleClassDiagrams", open("integration/code/reachability_graph.mvc", "r").read())
-        model_add("pn_reachability", "ProcessModel", open("integration/code/pm_pn_reachability.mvc", "r").read())
-        transformation_add_MT({}, {"PetriNet": "PetriNet"}, "initialize_PN", open("integration/code/initialize_PN.mvc", "r").read())
-        transformation_add_MANUAL({"PetriNet": "PetriNet"}, {"PetriNet": "PetriNet"}, "refine_PN")
-        transformation_add_AL({"PetriNet": "PetriNet"}, {"ReachabilityGraph": "ReachabilityGraph"}, "reachability", open("integration/code/reachability.alc", "r").read())
-        transformation_add_MT({"ReachabilityGraph": "ReachabilityGraph"}, {}, "reachability_print", open("integration/code/reachabilitygraph_print.mvc", 'r').read())
+        model_add("formalisms/PetriNet", "formalisms/SimpleClassDiagrams", open("integration/code/pn_design.mvc", "r").read())
+        model_add("formalisms/ReachabilityGraph", "formalisms/SimpleClassDiagrams", open("integration/code/reachability_graph.mvc", "r").read())
+        model_add("models/pn_reachability", "formalisms/ProcessModel", open("integration/code/pm_pn_reachability.mvc", "r").read())
+        transformation_add_MT({}, {"PetriNet": "formalisms/PetriNet"}, "models/initialize_PN", open("integration/code/initialize_PN.mvc", "r").read())
+        transformation_add_MANUAL({"PetriNet": "formalisms/PetriNet"}, {"PetriNet": "formalisms/PetriNet"}, "models/refine_PN")
+        transformation_add_AL({"PetriNet": "formalisms/PetriNet"}, {"ReachabilityGraph": "formalisms/ReachabilityGraph"}, "models/reachability", open("integration/code/reachability.alc", "r").read())
+        transformation_add_MT({"ReachabilityGraph": "formalisms/ReachabilityGraph"}, {}, "models/reachability_print", open("integration/code/reachabilitygraph_print.mvc", 'r').read())
 
         def callback_refine_PN():
             p1 = instantiate(None, "PetriNet/Place")
@@ -324,20 +332,20 @@ class TestModelverseCore(unittest.TestCase):
         def callback_print(value):
             log.add(value)
 
-        process_execute("pn_reachability", "my_", {"refine_PN": callback_refine_PN, "reachability_print": callback_print})
+        process_execute("models/pn_reachability", "my_", {"models/refine_PN": callback_refine_PN, "models/reachability_print": callback_print})
 
         assert log == set(['"0": {"p1": 1, }',
                            '"1": {"p1": 0, }',
                            '"0" --["t1"]--> "1"'])
 
     def test_process_model_trivial_pn_subfunction(self):
-        model_add("PetriNet", "SimpleClassDiagrams", open("integration/code/pn_design.mvc", "r").read())
-        model_add("ReachabilityGraph", "SimpleClassDiagrams", open("integration/code/reachability_graph.mvc", "r").read())
-        model_add("pn_reachability", "ProcessModel", open("integration/code/pm_pn_reachability.mvc", "r").read())
-        transformation_add_MT({}, {"PetriNet": "PetriNet"}, "initialize_PN", open("integration/code/initialize_PN.mvc", "r").read())
-        transformation_add_MANUAL({"PetriNet": "PetriNet"}, {"PetriNet": "PetriNet"}, "refine_PN")
-        transformation_add_AL({"PetriNet": "PetriNet"}, {"ReachabilityGraph": "ReachabilityGraph"}, "reachability", open("integration/code/reachability_subfunction.alc", "r").read())
-        transformation_add_MT({"ReachabilityGraph": "ReachabilityGraph"}, {}, "reachability_print", open("integration/code/reachabilitygraph_print.mvc", 'r').read())
+        model_add("formalisms/PetriNet", "formalisms/SimpleClassDiagrams", open("integration/code/pn_design.mvc", "r").read())
+        model_add("formalisms/ReachabilityGraph", "formalisms/SimpleClassDiagrams", open("integration/code/reachability_graph.mvc", "r").read())
+        model_add("models/pn_reachability", "formalisms/ProcessModel", open("integration/code/pm_pn_reachability.mvc", "r").read())
+        transformation_add_MT({}, {"PetriNet": "formalisms/PetriNet"}, "models/initialize_PN", open("integration/code/initialize_PN.mvc", "r").read())
+        transformation_add_MANUAL({"PetriNet": "formalisms/PetriNet"}, {"PetriNet": "formalisms/PetriNet"}, "models/refine_PN")
+        transformation_add_AL({"PetriNet": "formalisms/PetriNet"}, {"ReachabilityGraph": "formalisms/ReachabilityGraph"}, "models/reachability", open("integration/code/reachability_subfunction.alc", "r").read())
+        transformation_add_MT({"ReachabilityGraph": "formalisms/ReachabilityGraph"}, {}, "models/reachability_print", open("integration/code/reachabilitygraph_print.mvc", 'r').read())
 
         def callback_refine_PN():
             p1 = instantiate(None, "PetriNet/Place")
@@ -354,20 +362,20 @@ class TestModelverseCore(unittest.TestCase):
         def callback_print(value):
             log.add(value)
 
-        process_execute("pn_reachability", "my_", {"refine_PN": callback_refine_PN, "reachability_print": callback_print})
+        process_execute("models/pn_reachability", "my_", {"models/refine_PN": callback_refine_PN, "models/reachability_print": callback_print})
 
         assert log == set(['"0": {"p1": 1, }',
                            '"1": {"p1": 0, }',
                            '"0" --["t1"]--> "1"'])
 
     def test_render(self):
-        model_add("CausalBlockDiagrams", "SimpleClassDiagrams", open("integration/code/cbd_design.mvc", 'r').read())
-        model_add("MM_rendered_graphical", "SimpleClassDiagrams", open("models/MM_rendered_graphical.mvc", 'r').read())
-        model_add("my_CBD", "CausalBlockDiagrams", open("integration/code/my_cbd.mvc", 'r').read())
+        model_add("formalisms/CausalBlockDiagrams", "formalisms/SimpleClassDiagrams", open("integration/code/cbd_design.mvc", 'r').read())
+        model_add("formalisms/MM_rendered_graphical", "formalisms/SimpleClassDiagrams", open("models/MM_rendered_graphical.mvc", 'r').read())
+        model_add("models/my_CBD", "formalisms/CausalBlockDiagrams", open("integration/code/my_cbd.mvc", 'r').read())
 
         def add_tracability():
             instantiate(None, "Association", ("abstract/Block", "rendered/Group"), ID="TracabilityLink")
 
-        transformation_add_MT({"abstract": "CausalBlockDiagrams", "rendered": "MM_rendered_graphical"}, {"abstract": "CausalBlockDiagrams", "rendered": "MM_rendered_graphical"}, "render_graphical_CBD", open("models/CBD_mapper.mvc", 'r').read(), add_tracability)
-        result = model_render("my_CBD", "render_graphical_CBD")
+        transformation_add_MT({"abstract": "formalisms/CausalBlockDiagrams", "rendered": "formalisms/MM_rendered_graphical"}, {"abstract": "formalisms/CausalBlockDiagrams", "rendered": "formalisms/MM_rendered_graphical"}, "models/render_graphical_CBD", open("models/CBD_mapper.mvc", 'r').read(), add_tracability)
+        result = model_render("models/my_CBD", "models/render_graphical_CBD")
         assert len(result) == 23

+ 11 - 24
wrappers/modelverse.py

@@ -110,7 +110,7 @@ def _goto_mode(new_mode, model_name=None):
 
 def _input(value, port=None):
     # Ugly json encoding of primitives
-    #print("[IN] %s" % value)
+    print("[IN] %s" % value)
     if port is None:
         port = taskname
     if isinstance(value, type([])):
@@ -167,7 +167,7 @@ def _output(expected=None,port=None):
     try:
         global last_output
         last_output = json.loads(urllib2.urlopen(urllib2.Request(address, urllib.urlencode({"op": "get_output", "taskname": port}))).read())
-        #print("[OUT] %s" % last_output)
+        print("[OUT] %s" % last_output)
     except:
         raise UnknownError()
     if expected is not None and last_output != expected:
@@ -335,28 +335,16 @@ def model_delete(model_name):
     _input(["model_delete", model_name])
     _handle_output("Success")
 
-def model_list():
+def model_list(location):
     """List all models."""
     _goto_mode(MODE_MODELLING)
-    _input("model_list")
-    output = _handle_output("Success: ", split=" ")
-    if output == "":
-        return set([])
-
-    lst = set([])
-    value = output.strip().split("\n")
-    for v in value:
-        m, mm = v.split(":")
-        m = m.strip()
-        mm = mm.strip()
-        lst.add((m, mm))
-
-    return lst
+    _input(["model_list", location])
+    return set(_handle_output("Success: ", split=" ").split("\n"))
 
-def model_list_full():
+def model_list_full(location):
     """List full information on all models."""
     _goto_mode(MODE_MODELLING)
-    _input("model_list_full")
+    _input(["model_list_full", location])
     output = _handle_output("Success: ", split=" ")
     if output == "":
         return set([])
@@ -364,11 +352,10 @@ def model_list_full():
     lst = set([])
     value = output.strip().split("\n")
     for v in value:
-        m, mm = v.split(":")
-        m = m.strip()
-        mm = mm.strip()
-        perm, own, grp, m = m.split(" ")
-        lst.add((m, mm, own, grp, perm))
+        m = v.strip()
+        print("Splitting " + m)
+        perm, own, grp, m = m.split(" ", 3)
+        lst.add((m, own, grp, perm))
 
     return lst