Browse Source

Patched conformance problems and added test (including type mapping and bottom)

Yentl Van Tendeloo 3 years ago
parent
commit
02f346e0a8

+ 0 - 5
bootstrap/90_core_formalism.mvc

@@ -107,11 +107,6 @@ SimpleClassDiagrams CoreFormalism {
         type : String
     }
 
-    Association semantics (instanceOf, ActionLanguage) {
-        name = "semantics"
-        target_lower_cardinality = 1
-        target_upper_cardinality = 1
-    }
     Association typing (instanceOf, TypeMapping) {
         name = "typing"
         target_lower_cardinality = 1

+ 0 - 48
bootstrap/99_core.mvc

@@ -73,12 +73,6 @@ CF core {
             name = "models"
             permissions = "221"
 
-            ActionLanguage conformance_mv {
-                name = "models/conformance_mv"
-                location = "models/Conformance_MV/model"
-                permissions = "221"
-            }
-
         }
 
         Folder typemappings {
@@ -136,12 +130,6 @@ CF core {
             Folder tm_models {
                 name = "type mappings/models"
                 permissions = "110"
-
-                TypeMapping TM_conformance_mv {
-                    name = "type mappings/models/conformance_mv"
-                    location = "models/Conformance_MV/types"
-                    permissions = "221"
-                }
             }
 
             Folder tm_administration {
@@ -210,7 +198,6 @@ CF core {
     group (ManualOperation, admin_group) {}
     group (Bottom, admin_group) {}
     group (models, admin_group) {}
-    group (conformance_mv, admin_group) {}
     group (administration, admin_group) {}
     group (CoreFormalism, admin_group) {}
     group (Core, admin_group) {}
@@ -227,7 +214,6 @@ CF core {
     group (TM_Bottom, admin_group) {}
     group (TM_ManualOperation, admin_group) {}
     group (tm_models, admin_group) {}
-    group (TM_conformance_mv, admin_group) {}
     group (tm_administration, admin_group) {}
     group (TM_CoreFormalism, admin_group) {}
     group (TM_Core, admin_group) {}
@@ -244,7 +230,6 @@ CF core {
     owner (ManualOperation, admin_user) {}
     owner (Bottom, admin_user) {}
     owner (models, admin_user) {}
-    owner (conformance_mv, admin_user) {}
     owner (administration, admin_user) {}
     owner (CoreFormalism, admin_user) {}
     owner (Core, admin_user) {}
@@ -261,27 +246,18 @@ CF core {
     owner (TM_ManualOperation, admin_user) {}
     owner (TM_Bottom, admin_user) {}
     owner (tm_models, admin_user) {}
-    owner (TM_conformance_mv, admin_user) {}
     owner (tm_administration, admin_user) {}
     owner (TM_CoreFormalism, admin_user) {}
     owner (TM_Core, admin_user) {}
     owner (tm_users, admin_user) {}
     owner (tm_users_admin, admin_user) {}
 
-    transformInput (conformance_mv, SimpleClassDiagrams) {
-        name = "model"
-    }
-    transformInput (conformance_mv, SimpleClassDiagrams) {
-        name = "metamodel"
-    }
-
     instanceOf inst_SCD (SimpleClassDiagrams, SimpleClassDiagrams) {}
     instanceOf inst_TM (TypeMapping, SimpleClassDiagrams) {}
     instanceOf inst_trace (Tracability, SimpleClassDiagrams) {}
     instanceOf inst_pm (ProcessModel, SimpleClassDiagrams) {}
     instanceOf inst_al (ActionLanguage, SimpleClassDiagrams) {}
     instanceOf inst_man (ManualOperation, SimpleClassDiagrams) {}
-    instanceOf inst_conf (conformance_mv, ActionLanguage) {}
     instanceOf inst_cf (CoreFormalism, SimpleClassDiagrams) {}
     instanceOf inst_core (Core, CoreFormalism) {}
     instanceOf inst_Bottom (Bottom, SimpleClassDiagrams) {}
@@ -292,7 +268,6 @@ CF core {
     instanceOf TM_inst_pm (TM_ProcessModel, TypeMapping) {}
     instanceOf TM_inst_al (TM_ActionLanguage, TypeMapping) {}
     instanceOf TM_inst_man (TM_ManualOperation, TypeMapping) {}
-    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) {}
@@ -303,32 +278,9 @@ CF core {
     typing (inst_pm, TM_ProcessModel) {}
     typing (inst_al, TM_ActionLanguage) {}
     typing (inst_man, TM_ManualOperation) {}
-    typing (inst_conf, TM_conformance_mv) {}
     typing (inst_cf, TM_CoreFormalism) {}
     typing (inst_core, TM_Core) {}
     typing (inst_Bottom, TM_Bottom) {}
-
-    semantics (inst_SCD, conformance_mv) {}
-    semantics (inst_TM, conformance_mv) {}
-    semantics (inst_trace, conformance_mv) {}
-    semantics (inst_pm, conformance_mv) {}
-    semantics (inst_al, conformance_mv) {}
-    semantics (inst_man, conformance_mv) {}
-    semantics (inst_conf, conformance_mv) {}
-    semantics (inst_cf, conformance_mv) {}
-    semantics (inst_core, conformance_mv) {}
-    semantics (inst_Bottom, conformance_mv) {}
-
-    semantics (TM_inst_SCD, conformance_mv) {}
-    semantics (TM_inst_TM, conformance_mv) {}
-    semantics (TM_inst_trace, conformance_mv) {}
-    semantics (TM_inst_pm, conformance_mv) {}
-    semantics (TM_inst_al, conformance_mv) {}
-    semantics (TM_inst_man, conformance_mv) {}
-    semantics (TM_inst_conf, conformance_mv) {}
-    semantics (TM_inst_cf, conformance_mv) {}
-    semantics (TM_inst_core, conformance_mv) {}
-    semantics (TM_inst_Bottom, conformance_mv) {}
 }
 
 export core to models/core

+ 7 - 6
bootstrap/core_algorithm.alc

@@ -102,7 +102,7 @@ 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", anAssociationDestination(core, choice, "semantics"))
-	dict_add(m, "semantics", get_entry_id("models/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!
@@ -406,7 +406,7 @@ String function export_typing(model : Element, name : String):
 	instantiate_link(core, "owner", "", result, current_user_id)
 	instantiate_link(core, "group", "", result, get_group_id("nobody"))
 	instance_of = instantiate_link(core, "instanceOf", "", result, get_entry_id("formalisms/TypeMapping"))
-	instantiate_link(core, "semantics", "", instance_of, get_entry_id("models/conformance_mv"))
+	//instantiate_link(core, "semantics", "", instance_of, get_entry_id("models/conformance_mv"))
 
 	return result!
 
@@ -426,7 +426,7 @@ Void function model_create(model : Element, name : String, type_id : String, kin
 	instantiate_link(core, "owner", "", model_id, current_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("models/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))
@@ -464,7 +464,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("models/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)))
 
 	return!
@@ -1647,7 +1647,8 @@ String function cmd_model_modify(model_name : String, metamodel_name : String):
 				Element new_model
 				new_model = get_full_model(model_id, get_entry_id(metamodel_name))
 				if (element_eq(new_model, read_root())):
-					return "No conformance relation can be found between these models"!
+					log("Failed to find conformance...")
+					return "Conformance hierarchy unknown for: " + model_name!
 				modify(new_model, allow_write(current_user_id, model_id))
 				if (allow_write(current_user_id, model_id)):
 					// Overwrite the modified model
@@ -2357,7 +2358,7 @@ String function cmd_model_types(model_name : String):
 		types = allOutgoingAssociationInstances(core, model_id, "instanceOf")
 		while (set_len(types) > 0):
 			type_link = set_pop(types)
-			result = result + cast_string(full_name(readAssociationDestination(core, type_link))) + ", " + cast_string(full_name(anAssociationDestination(core, type_link, "typing"))) + ", " + cast_string(full_name(anAssociationDestination(core, type_link, "semantics"))) + "\n"
+			result = result + cast_string(full_name(readAssociationDestination(core, type_link))) + ", " + cast_string(full_name(anAssociationDestination(core, type_link, "typing"))) + ", NONE\n"
 
 		return result!
 	else:

+ 9 - 1
bootstrap/metamodels.alt

@@ -102,8 +102,11 @@ Element function initialize_SCD(location : String):
 
 	// Add some attributes, now that it is an ordinary model
 	instantiate_node(scd, "SimpleAttribute", "Location")
+	instantiate_attribute(scd, "Location", "name", "Location")
 	instantiate_node(scd, "SimpleAttribute", "Natural")
+	instantiate_attribute(scd, "Natural", "name", "Natural")
 	instantiate_node(scd, "SimpleAttribute", "Boolean")
+	instantiate_attribute(scd, "Boolean", "name", "Boolean")
 	instantiate_link(scd, "AttributeLink", "attr_optional", "AttributeLink", "Boolean")
 	instantiate_attribute(scd, "attr_optional", "name", "optional")
 	instantiate_attribute(scd, "attr_optional", "optional", False)
@@ -123,6 +126,11 @@ Element function initialize_SCD(location : String):
 	model_define_attribute(scd, "Class", "abstract", True, "Boolean")
 	model_define_attribute(scd, "SimpleAttribute", "name", False, "String")
 	model_define_attribute(scd, "Association", "name", False, "String")
+	instantiate_attribute(scd, "String", "name", "String")
+	instantiate_attribute(scd, "Element", "name", "Element")
+	instantiate_attribute(scd, "Element", "abstract", True)
+	instantiate_attribute(scd, "Attribute", "name", "Attribute")
+	instantiate_attribute(scd, "Attribute", "abstract", True)
 	instantiate_attribute(scd, "Class", "name", "Class")
 	instantiate_attribute(scd, "Association", "name", "Association")
 	instantiate_attribute(scd, "SimpleAttribute", "name", "SimpleAttribute")
@@ -139,7 +147,7 @@ Element function initialize_SCD(location : String):
 
 	// Define additional attributes that define functions
 	instantiate_node(scd, "ActionLanguage", "ActionCode")
-	instantiate_attribute(scd, "ActionCode", "name", "ActionCode")
+	instantiate_attribute(scd, "ActionLanguage", "name", "ActionLanguage")
 	model_define_attribute(scd, "Element", "constraint", True, "ActionCode")
 
 	// Define some constraints

+ 30 - 4
unit/test_all.py

@@ -22,8 +22,7 @@ model_hierarchy = \
                              "ManualOperation": {},
                              "Bottom": {},
                             },
-            "models/": {"conformance_mv": {},
-                        },
+            "models/": {},
             "administration/": {"core": {},
                                 "CoreFormalism": {},
                                },
@@ -37,8 +36,7 @@ model_hierarchy = \
                                                "ManualOperation": {},
                                                "Bottom": {},
                                               },
-                               "models/": {"conformance_mv": {},
-                                          },
+                               "models/": {},
                                "administration/": {"core": {},
                                                    "CoreFormalism": {},
                                                   },
@@ -159,6 +157,34 @@ class TestModelverse(unittest.TestCase):
                                                       ("Bottom", "admin", "admin", "221"),
                                                      ])
 
+    def test_op_verify(self):
+        assert verify("formalisms/SimpleClassDiagrams", "formalisms/SimpleClassDiagrams") == "OK"
+        assert verify("formalisms/SimpleClassDiagrams", "formalisms/Bottom") == "OK"
+        for tm in model_types("formalisms/SimpleClassDiagrams"):
+            assert verify(tm[1], "formalisms/TypeMapping") == "OK"
+        try:
+            verify("formalisms/SimpleClassDiagrams", "formalisms/ProcessModel")
+            self.fail()
+        except:
+            pass
+
+        assert verify("formalisms/ProcessModel", "formalisms/SimpleClassDiagrams") == "OK"
+        assert verify("formalisms/ProcessModel", "formalisms/Bottom") == "OK"
+        for tm in model_types("formalisms/ProcessModel"):
+            assert verify(tm[1], "formalisms/TypeMapping") == "OK"
+        try:
+            verify("formalisms/ProcessModel", "formalisms/ProcessModel")
+            self.fail()
+        except:
+            pass
+
+        model_add("test/a", "formalisms/ProcessModel")
+        assert verify("test/a", "formalisms/ProcessModel").startswith("Lower cardinality violated for class: ")
+        instantiate("test/a", "Start")
+        assert verify("test/a", "formalisms/ProcessModel") == "Lower cardinality violated for class: Finish"
+        instantiate("test/a", "Finish")
+        assert verify("test/a", "formalisms/ProcessModel") == "OK"
+
     """
     def test_op_model_add(self):
     def test_op_model_move(self):

+ 2 - 0
wrappers/classes/modelverse.xml

@@ -1453,6 +1453,7 @@
                     <transition cond="self.expect_response_partial('Admin permission denied', pop=False)" target="../wait_for_action/history">
                         <raise event="exception">
                             <parameter expr="'AdminPermissionDenied'"/>
+                            <parameter expr="'Admin permissions are required for this operation!'"/>
                         </raise>
                     </transition>
 
@@ -1480,6 +1481,7 @@
                     <transition cond="self.expect_response_partial('No conformance relation can be found ', pop=False)" target="../wait_for_action/history">
                         <raise event="exception">
                             <parameter expr="'UnknownMetamodellingHierarchy'"/>
+                            <parameter expr="'Metamodelling hierarchy could not be resolved or automatically inferred: there is no typing relation between your specified model and metamodel'"/>
                         </raise>
 
                         <script>

+ 3 - 3
wrappers/modelverse_SCCD.py

@@ -1,7 +1,7 @@
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Tue Jun  5 15:43:17 2018
+Date:   Tue Jun  5 16:38:58 2018
 
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server
@@ -2260,7 +2260,7 @@ class Modelverse(RuntimeClassBase):
         return self.expect_response_partial('User permission denied to: ', pop=False)
     
     def _initialized_behaviour_operations_11_exec(self, parameters):
-        self.raiseInternalEvent(Event("exception", None, ['AdminPermissionDenied']))
+        self.raiseInternalEvent(Event("exception", None, ['AdminPermissionDenied', 'Admin permissions are required for this operation!']))
     
     def _initialized_behaviour_operations_11_guard(self, parameters):
         return self.expect_response_partial('Admin permission denied', pop=False)
@@ -2284,7 +2284,7 @@ class Modelverse(RuntimeClassBase):
         return self.expect_response_partial('Location not found: ', pop=False)
     
     def _initialized_behaviour_operations_15_exec(self, parameters):
-        self.raiseInternalEvent(Event("exception", None, ['UnknownMetamodellingHierarchy']))
+        self.raiseInternalEvent(Event("exception", None, ['UnknownMetamodellingHierarchy', 'Metamodelling hierarchy could not be resolved or automatically inferred: there is no typing relation between your specified model and metamodel']))
         self.responses.pop(0)
     
     def _initialized_behaviour_operations_15_guard(self, parameters):