Browse Source

Check if inputs to transformation_between are models instead of folders

Yentl Van Tendeloo 7 years ago
parent
commit
7da22a1748
2 changed files with 34 additions and 14 deletions
  1. 20 14
      bootstrap/core_algorithm.alc
  2. 14 0
      unit/test_all.py

+ 20 - 14
bootstrap/core_algorithm.alc

@@ -1209,13 +1209,16 @@ String function cmd_transformation_between(source_dict : String, target_dict : S
 		mm_id = get_entry_id(mm)
 
 		if (mm_id != ""):
-			links = allIncomingAssociationInstances(core, mm_id, "transformInput")
-
-			while (set_len(links) > 0):
-				link = set_pop(links)
-				if (value_eq(read_attribute(core, link, "name"), tag)):
-					// Correct tag, so make transformation a possibility
-					set_add(subresult, readAssociationSource(core, link))
+			if (read_type(core, mm_id) != "Folder"):
+				links = allIncomingAssociationInstances(core, mm_id, "transformInput")
+
+				while (set_len(links) > 0):
+					link = set_pop(links)
+					if (value_eq(read_attribute(core, link, "name"), tag)):
+						// Correct tag, so make transformation a possibility
+						set_add(subresult, readAssociationSource(core, link))
+			else:
+				return "Not a model: " + mm!
 		else:
 			return "Model not found: " + mm!
 
@@ -1230,13 +1233,16 @@ String function cmd_transformation_between(source_dict : String, target_dict : S
 		mm_id = get_entry_id(mm)
 
 		if (mm_id != ""):
-			links = allIncomingAssociationInstances(core, mm_id, "transformOutput")
-
-			while (set_len(links) > 0):
-				link = set_pop(links)
-				if (value_eq(read_attribute(core, link, "name"), tag)):
-					// Correct tag, so make transformation a possibility
-					set_add(subresult, readAssociationSource(core, link))
+			if (read_type(core, mm_id) != "Folder"):
+				links = allIncomingAssociationInstances(core, mm_id, "transformOutput")
+
+				while (set_len(links) > 0):
+					link = set_pop(links)
+					if (value_eq(read_attribute(core, link, "name"), tag)):
+						// Correct tag, so make transformation a possibility
+						set_add(subresult, readAssociationSource(core, link))
+			else:
+				return "Not a model: " + mm!
 		else:
 			return "Model not found: " + mm!
 

+ 14 - 0
unit/test_all.py

@@ -3781,6 +3781,20 @@ class TestModelverse(unittest.TestCase):
         # Model mismatch (target)
         assert transformation_between({"key_A": "users/user/test/A"}, {"key_B": "users/user/test/A"}) == set([])
 
+        # Source model is folder
+        try:
+            transformation_between({"key_A": "users"}, {})
+            self.fail()
+        except NotAModel:
+            pass
+
+        # Target model is folder
+        try:
+            transformation_between({}, {"key_A": "users"})
+            self.fail()
+        except NotAModel:
+            pass
+
     def test_op_transformation_add_MANUAL(self):
         # Add models for transformation
         model_add("users/user/test/A", "formalisms/SimpleClassDiagrams", """