Browse Source

Patched model_overwrite with folder locations

Yentl Van Tendeloo 7 years ago
parent
commit
2514d85aa1
2 changed files with 13 additions and 13 deletions
  1. 13 10
      bootstrap/core_algorithm.alc
  2. 0 3
      unit/test_all.py

+ 13 - 10
bootstrap/core_algorithm.alc

@@ -1604,19 +1604,22 @@ String function cmd_model_overwrite(model_name : String, metamodel_name : String
 		if (allow_write(current_user_id, model_id)):
 			type_id = anAssociationDestination(core, model_id, "instanceOf")
 			if (allow_read(current_user_id, type_id)):
-				Element mm
-				mm = get_full_model(get_entry_id(metamodel_name), get_entry_id("formalisms/SimpleClassDiagrams"))
-				if (element_eq(mm, read_root())):
-					return "Type cannot be typed as formalisms/SimpleClassDiagrams: " + metamodel_name!
+				if (read_type(core, type_id) != "Folder"):
+					Element mm
+					mm = get_full_model(get_entry_id(metamodel_name), get_entry_id("formalisms/SimpleClassDiagrams"))
+					if (element_eq(mm, read_root())):
+						return "Type cannot be typed as formalisms/SimpleClassDiagrams: " + metamodel_name!
 
-				output("Waiting for model constructors...")
-				new_model = compile_model(input(), mm)
+					output("Waiting for model constructors...")
+					new_model = compile_model(input(), mm)
 
-				if (is_physical_string(new_model)):
-					return "Compilation error: " + cast_string(new_model)!
+					if (is_physical_string(new_model)):
+						return "Compilation error: " + cast_string(new_model)!
 
-				model_overwrite(new_model, model_id, get_entry_id(metamodel_name))
-				return "Success"!
+					model_overwrite(new_model, model_id, get_entry_id(metamodel_name))
+					return "Success"!
+				else:
+					return "Not a model: " + full_name(type_id)!
 			else:
 				return string_join("Read permission denied to: ", full_name(type_id))!
 		else:

+ 0 - 3
unit/test_all.py

@@ -880,9 +880,6 @@ class TestModelverse(unittest.TestCase):
         except UnknownModel:
             pass
 
-        # Test non-model location
-        assert model_types("formalisms") == set([])
-
         # Check on folder "model"
         try:
             model_types("users")