Browse Source

Added nicer print method for mini_modify

Yentl Van Tendeloo 8 years ago
parent
commit
c1ec2a7e59
3 changed files with 89 additions and 1 deletions
  1. 16 0
      core/core_algorithm.alc
  2. 36 0
      core/mini_modify.alc
  3. 37 1
      integration/test_mvc.py

+ 16 - 0
core/core_algorithm.alc

@@ -694,6 +694,22 @@ Void function user_function_skip_init(user_id : String):
 			else:
 				output("No such transformation")
 
+		elif (cmd == "verify"):
+			// Check whether a model conforms to its specification (with the selected type mapping)
+			String model_id
+			String result
+
+			output("Which model to verify?")
+			model_id = get_model_id(input())
+			if (model_id != ""):
+				if (allow_read(user_id, model_id)):
+					result = conformance_scd(get_full_model(model_id))
+					output(result)
+				else:
+					output("Permission denied")
+			else:
+				output("No such model")
+
 		elif (cmd == "model_overwrite"):
 			// Overwrites an existing model without changing any metadata
 			String model_id

+ 36 - 0
core/mini_modify.alc

@@ -203,6 +203,42 @@ Element function modify(model : Element, write : Boolean):
 			else:
 				output("Permission denied")
 
+		elif (cmd == "nice_list"):
+			Element keys_m
+			String type
+			String v_m
+			Element attr_list
+			Element attr_keys
+			String attr_key
+
+			keys_m = dict_keys(model["model"])
+
+			while (read_nr_out(keys_m) > 0):
+				v_m = set_pop(keys_m)
+				type = read_type(model["metamodel"], read_type(model, v_m))
+
+				if (bool_or(type == "Class", type == "Association")):
+					output((("  " + v_m) + " : ") + read_type(model, v_m))
+					if (type == "Association"):
+						output((("    " + reverseKeyLookup(model["model"], read_edge_src(model["model"][v_m]))) + " --> ") + reverseKeyLookup(model["model"], read_edge_dst(model["model"][v_m])))
+
+					// Defines attributes
+					attr_list = getInstantiatableAttributes(model, v_m)
+					attr_keys = dict_keys(attr_list)
+					while (0 < read_nr_out(attr_keys)):
+						attr_key = set_pop(attr_keys)
+						output(((("      " + attr_key) + " : ") + cast_v2s(attr_list[attr_key])))
+
+					// Has attributes
+					attr_list = getAttributeList(model, v_m)
+					attr_keys = dict_keys(attr_list)
+					while (0 < read_nr_out(attr_keys)):
+						attr_key = set_pop(attr_keys)
+						if (element_eq(read_attribute(model, v_m, attr_key), read_root())):
+							output(((("      " + cast_v2s(attr_key)) + " : ") + cast_v2s(attr_list[attr_key])) + " = (undefined)")
+						else:
+							output((((("      " + cast_v2s(attr_key)) + " : ") + cast_v2s(attr_list[attr_key])) + " = ") + cast_v2s(read_attribute(model, v_m, attr_key)))
+
 		elif (cmd == "list"):
 			Element keys_m
 			keys_m = dict_keys(model["model"])

+ 37 - 1
integration/test_mvc.py

@@ -1468,8 +1468,20 @@ class TestModelverseCore(unittest.TestCase):
                     "description_model",
                     ] + get_model_constructor(open("models/description_model.mvc", "r").read()) + [
                 "model_list",
+                "model_modify",
+                "Control_PW",
+                "nice_list",
+                "exit",
+
+                "model_modify",
+                "control_model",
+                "nice_list",
+                "exit",
+                "exit",
             ],
-            [   # bootup phase
+            None))
+
+    (([   # bootup phase
                 "Desired username for admin user?",
                 "Desired password for admin user?",
                 "Please repeat the password",
@@ -1531,4 +1543,28 @@ class TestModelverseCore(unittest.TestCase):
                      "  description_model : Description_PW",
                      "  core : CoreFormalism"]),
                 "Ready for command...",
+                # verify
+                "Which model to verify?",
+                "OK",
+                "Ready for command...",
+                # verify
+                "Which model to verify?",
+                "OK",
+                "Ready for command...",
+                # verify
+                "Which model to verify?",
+                "OK",
+                "Ready for command...",
+                # verify
+                "Which model to verify?",
+                "OK",
+                "Ready for command...",
+                # verify
+                "Which model to verify?",
+                "OK",
+                "Ready for command...",
+                # verify
+                "Which model to verify?",
+                "OK",
+                "Ready for command...",
             ]))