소스 검색

Fixed hang in model_modify if model didn't exist and had no MM registered either

Yentl Van Tendeloo 7 년 전
부모
커밋
75101502d3
4개의 변경된 파일109개의 추가작업 그리고 76개의 파일을 삭제
  1. 8 2
      bootstrap/core_algorithm.alc
  2. 5 5
      unit/test_all.py
  3. 45 31
      wrappers/classes/modelverse.xml
  4. 51 38
      wrappers/modelverse_SCCD.py

+ 8 - 2
bootstrap/core_algorithm.alc

@@ -1671,6 +1671,7 @@ String function cmd_model_modify(model_name : String, metamodel_name : String):
 	String type_id
 
 	model_id = get_entry_id(model_name)
+	log("Model modify " + model_name)
 
 	if (model_id != ""):
 		if (allow_read(current_user_id, model_id)):
@@ -1679,17 +1680,22 @@ 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())):
+					log("Conformance hierarchy")
 					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
 					model_overwrite(new_model, model_id, get_entry_id(metamodel_name))
+					log("OK")
 				return "Success"!
 			else:
+				log("READ PERM1")
 				return string_join("Read permission denied to: ", full_name(type_id))!
 		else:
+			log("READ PERM2")
 			return "Read permission denied to: " + model_name!
 	else:
+		log("location")
 		return "Location not found: " + model_name!
 
 Void function model_delete(model_id : String):
@@ -2376,7 +2382,7 @@ String function cmd_transformation_signature(transformation_name : String):
 		else:
 			return "Model is not an operation: " + transformation_name!
 	else:
-		return "No such operation: " + transformation_name!
+		return "Location not found: " + transformation_name!
 
 String function cmd_model_types(model_name : String):
 	if (get_entry_id(model_name) != ""):
@@ -2395,7 +2401,7 @@ String function cmd_model_types(model_name : String):
 
 		return result!
 	else:
-		return "No such model: " + model_name!
+		return "Location not found: " + model_name!
 	
 String function cmd_folder_create(folder_name : String):
 	if (get_entry_id(folder_name) == ""):

+ 5 - 5
unit/test_all.py

@@ -457,11 +457,11 @@ class TestModelverse(unittest.TestCase):
         except UnknownElement:
             pass
 
-        #try:
-        #    all_instances("users/user/test/b", "Class")
-        #    self.fail()
-        #except UnknownLocation:
-        #    pass
+        try:
+            all_instances("users/user/test/b", "Class")
+            self.fail()
+        except UnknownLocation:
+            pass
 
         model_add("users/user/test/b", "users/user/test/a", """
             A a {}

+ 45 - 31
wrappers/classes/modelverse.xml

@@ -1552,6 +1552,12 @@
                     </state>
 
                     <state id="megamodelling">
+                        <onentry>
+                            <script>
+                                print("Entered megamodelling with operation: " + str(self.actions))
+                            </script>
+                        </onentry>
+
                         <transition cond="self.expect_action('model_list')" target="../../operations/model_list">
                             <script>
                                 self.load_action()
@@ -1815,7 +1821,11 @@
                             <state id="manual">
                                 <transition cond="self.expect_action('exit')" target="../../../../leaving_manual"/>
 
-                                <transition cond="self.actions and self.actions[0]['name'] in self.modelling_operations and self.actions[0]['parameters'][0] != self.current_model" target="../../../../leaving_manual"/>
+                                <transition cond="self.actions and self.actions[0]['name'] in self.modelling_operations and self.actions[0]['parameters'][0] != self.current_model" target="../../../../leaving_manual">
+                                    <script>
+                                        print("Switching to normal for model " + str(self.actions[0]))
+                                    </script>
+                                </transition>
                             </state>
 
                             <state id="scripted">
@@ -1828,6 +1838,7 @@
                                 <transition cond="self.actions and self.actions[0] in self.modelling_operations and self.actions[0]['parameters'][0] != self.current_model" target=".">
                                     <script>
                                         self.load_action()
+                                        print("INTERFACE")
                                     </script>
                                     <raise event="exception">
                                         <parameter expr="'InterfaceMismatch'"/>
@@ -1836,7 +1847,6 @@
                                 </transition>
                             </state>
 
-
                             <transition cond="self.expect_action('element_list')" target="../../../operations/element_list">
                                 <script>
                                     self.load_action()
@@ -1972,6 +1982,7 @@
                             <transition cond="self.expect_action('all_instances')" target="../../../operations/all_instances">
                                 <script>
                                     self.load_action()
+                                    print("Load all_instances for " + str(self.parameters))
                                 </script>
                             </transition>
 
@@ -2015,6 +2026,9 @@
 
                     <state id="search">
                         <onentry>
+                            <script>
+                                print("Search")
+                            </script>
                             <raise event="request">
                                 <parameter expr="['model_types', self.current_model]"/>
                             </raise>
@@ -2035,39 +2049,39 @@
                         </onentry>
 
                         <transition cond="self.expect_response('Model loaded, ready for commands!', pop=True)" target="../../wait_for_action/modelling/recognized/manual"/>
+                    </state>
 
-                        <transition cond="self.expect_response_partial('Location not found: ', pop=False)" target="../../wait_for_action/megamodelling">
-                            <raise event="exception">
-                                <parameter expr="'UnknownLocation'"/>
-                                <parameter expr="'No such location: ' + self.responses.pop(0)"/>
-                            </raise>
-                            <script>
-                                self.actions.pop(0)
-                            </script>
-                        </transition>
+                    <transition cond="self.expect_response_partial('Location not found: ', pop=False)" target="../wait_for_action/megamodelling">
+                        <raise event="exception">
+                            <parameter expr="'UnknownLocation'"/>
+                            <parameter expr="'No such location: ' + self.responses.pop(0)"/>
+                        </raise>
+                        <script>
+                            self.actions.pop(0)
+                        </script>
+                    </transition>
 
-                        <transition cond="self.expect_response_partial('Read permission denied to: ', pop=False)" target="../../wait_for_action/megamodelling">
-                            <raise event="exception">
-                                <parameter expr="'ReadPermissionDenied'"/>
-                                <parameter expr="'No permission to read model ' + self.responses.pop(0)"/>
-                            </raise>
-                            <script>
-                                self.actions.pop(0)
-                            </script>
-                        </transition>
+                    <transition cond="self.expect_response_partial('Read permission denied to: ', pop=False)" target="../wait_for_action/megamodelling">
+                        <raise event="exception">
+                            <parameter expr="'ReadPermissionDenied'"/>
+                            <parameter expr="'No permission to read model ' + self.responses.pop(0)"/>
+                        </raise>
+                        <script>
+                            self.actions.pop(0)
+                        </script>
+                    </transition>
 
-                        <transition cond="self.expect_response_partial('Conformance hierarchy unknown for: ', pop=False)" target="../../wait_for_action/megamodelling">
-                            <raise event="exception">
-                                <parameter expr="'UnknownMetamodellingHierarchy'"/>
-                                <parameter expr="'Conformance relation not found'"/>
-                            </raise>
+                    <transition cond="self.expect_response_partial('Conformance hierarchy unknown for: ', pop=False)" target="../wait_for_action/megamodelling">
+                        <raise event="exception">
+                            <parameter expr="'UnknownMetamodellingHierarchy'"/>
+                            <parameter expr="'Conformance relation not found'"/>
+                        </raise>
 
-                            <script>
-                                self.responses.pop(0)
-                                self.actions.pop(0)
-                            </script>
-                        </transition>
-                    </state>
+                        <script>
+                            self.responses.pop(0)
+                            self.actions.pop(0)
+                        </script>
+                    </transition>
                 </state>
 
                 <state id="going_scripted">

+ 51 - 38
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:   Mon Jun 11 09:14:38 2018
+Date:   Mon Jun 11 09:54:06 2018
 
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server
@@ -509,6 +509,7 @@ class Modelverse(RuntimeClassBase):
         
         # state /initialized/behaviour/wait_for_action/megamodelling
         self.states["/initialized/behaviour/wait_for_action/megamodelling"] = State(105, "/initialized/behaviour/wait_for_action/megamodelling", self)
+        self.states["/initialized/behaviour/wait_for_action/megamodelling"].setEnter(self._initialized_behaviour_wait_for_action_megamodelling_enter)
         
         # state /initialized/behaviour/wait_for_action/service
         self.states["/initialized/behaviour/wait_for_action/service"] = State(106, "/initialized/behaviour/wait_for_action/service", self)
@@ -1611,6 +1612,7 @@ class Modelverse(RuntimeClassBase):
         _initialized_behaviour_wait_for_action_modelling_recognized_manual_0.setGuard(self._initialized_behaviour_wait_for_action_modelling_recognized_manual_0_guard)
         self.states["/initialized/behaviour/wait_for_action/modelling/recognized/manual"].addTransition(_initialized_behaviour_wait_for_action_modelling_recognized_manual_0)
         _initialized_behaviour_wait_for_action_modelling_recognized_manual_1 = Transition(self, self.states["/initialized/behaviour/wait_for_action/modelling/recognized/manual"], [self.states["/initialized/behaviour/leaving_manual"]])
+        _initialized_behaviour_wait_for_action_modelling_recognized_manual_1.setAction(self._initialized_behaviour_wait_for_action_modelling_recognized_manual_1_exec)
         _initialized_behaviour_wait_for_action_modelling_recognized_manual_1.setTrigger(None)
         _initialized_behaviour_wait_for_action_modelling_recognized_manual_1.setGuard(self._initialized_behaviour_wait_for_action_modelling_recognized_manual_1_guard)
         self.states["/initialized/behaviour/wait_for_action/modelling/recognized/manual"].addTransition(_initialized_behaviour_wait_for_action_modelling_recognized_manual_1)
@@ -1649,21 +1651,6 @@ class Modelverse(RuntimeClassBase):
         _initialized_behaviour_going_manual_OK_0.setTrigger(None)
         _initialized_behaviour_going_manual_OK_0.setGuard(self._initialized_behaviour_going_manual_OK_0_guard)
         self.states["/initialized/behaviour/going_manual/OK"].addTransition(_initialized_behaviour_going_manual_OK_0)
-        _initialized_behaviour_going_manual_OK_1 = Transition(self, self.states["/initialized/behaviour/going_manual/OK"], [self.states["/initialized/behaviour/wait_for_action/megamodelling"]])
-        _initialized_behaviour_going_manual_OK_1.setAction(self._initialized_behaviour_going_manual_OK_1_exec)
-        _initialized_behaviour_going_manual_OK_1.setTrigger(None)
-        _initialized_behaviour_going_manual_OK_1.setGuard(self._initialized_behaviour_going_manual_OK_1_guard)
-        self.states["/initialized/behaviour/going_manual/OK"].addTransition(_initialized_behaviour_going_manual_OK_1)
-        _initialized_behaviour_going_manual_OK_2 = Transition(self, self.states["/initialized/behaviour/going_manual/OK"], [self.states["/initialized/behaviour/wait_for_action/megamodelling"]])
-        _initialized_behaviour_going_manual_OK_2.setAction(self._initialized_behaviour_going_manual_OK_2_exec)
-        _initialized_behaviour_going_manual_OK_2.setTrigger(None)
-        _initialized_behaviour_going_manual_OK_2.setGuard(self._initialized_behaviour_going_manual_OK_2_guard)
-        self.states["/initialized/behaviour/going_manual/OK"].addTransition(_initialized_behaviour_going_manual_OK_2)
-        _initialized_behaviour_going_manual_OK_3 = Transition(self, self.states["/initialized/behaviour/going_manual/OK"], [self.states["/initialized/behaviour/wait_for_action/megamodelling"]])
-        _initialized_behaviour_going_manual_OK_3.setAction(self._initialized_behaviour_going_manual_OK_3_exec)
-        _initialized_behaviour_going_manual_OK_3.setTrigger(None)
-        _initialized_behaviour_going_manual_OK_3.setGuard(self._initialized_behaviour_going_manual_OK_3_guard)
-        self.states["/initialized/behaviour/going_manual/OK"].addTransition(_initialized_behaviour_going_manual_OK_3)
         
         # transition /initialized/behaviour/going_scripted
         _initialized_behaviour_going_scripted_0 = Transition(self, self.states["/initialized/behaviour/going_scripted"], [self.states["/initialized/behaviour/wait_for_action/modelling/recognized/scripted"]])
@@ -1928,6 +1915,23 @@ class Modelverse(RuntimeClassBase):
         _initialized_behaviour_wait_for_action_modelling_recognized_23.setTrigger(None)
         _initialized_behaviour_wait_for_action_modelling_recognized_23.setGuard(self._initialized_behaviour_wait_for_action_modelling_recognized_23_guard)
         self.states["/initialized/behaviour/wait_for_action/modelling/recognized"].addTransition(_initialized_behaviour_wait_for_action_modelling_recognized_23)
+        
+        # transition /initialized/behaviour/going_manual
+        _initialized_behaviour_going_manual_0 = Transition(self, self.states["/initialized/behaviour/going_manual"], [self.states["/initialized/behaviour/wait_for_action/megamodelling"]])
+        _initialized_behaviour_going_manual_0.setAction(self._initialized_behaviour_going_manual_0_exec)
+        _initialized_behaviour_going_manual_0.setTrigger(None)
+        _initialized_behaviour_going_manual_0.setGuard(self._initialized_behaviour_going_manual_0_guard)
+        self.states["/initialized/behaviour/going_manual"].addTransition(_initialized_behaviour_going_manual_0)
+        _initialized_behaviour_going_manual_1 = Transition(self, self.states["/initialized/behaviour/going_manual"], [self.states["/initialized/behaviour/wait_for_action/megamodelling"]])
+        _initialized_behaviour_going_manual_1.setAction(self._initialized_behaviour_going_manual_1_exec)
+        _initialized_behaviour_going_manual_1.setTrigger(None)
+        _initialized_behaviour_going_manual_1.setGuard(self._initialized_behaviour_going_manual_1_guard)
+        self.states["/initialized/behaviour/going_manual"].addTransition(_initialized_behaviour_going_manual_1)
+        _initialized_behaviour_going_manual_2 = Transition(self, self.states["/initialized/behaviour/going_manual"], [self.states["/initialized/behaviour/wait_for_action/megamodelling"]])
+        _initialized_behaviour_going_manual_2.setAction(self._initialized_behaviour_going_manual_2_exec)
+        _initialized_behaviour_going_manual_2.setTrigger(None)
+        _initialized_behaviour_going_manual_2.setGuard(self._initialized_behaviour_going_manual_2_guard)
+        self.states["/initialized/behaviour/going_manual"].addTransition(_initialized_behaviour_going_manual_2)
     
     def _initialized_enter(self):
         self.raiseInternalEvent(Event("ready", None, []))
@@ -2140,10 +2144,14 @@ class Modelverse(RuntimeClassBase):
     def _initialized_behaviour_operations_service_stop_enter(self):
         self.raiseInternalEvent(Event("request", None, [['service_stop']]))
     
+    def _initialized_behaviour_wait_for_action_megamodelling_enter(self):
+        print("Entered megamodelling with operation: " + str(self.actions))
+    
     def _initialized_behaviour_going_manual_init_enter(self):
         self.current_model = self.actions[0]["parameters"][0]
     
     def _initialized_behaviour_going_manual_search_enter(self):
+        print("Search")
         self.raiseInternalEvent(Event("request", None, [['model_types', self.current_model]]))
     
     def _initialized_behaviour_going_manual_OK_enter(self):
@@ -2409,6 +2417,7 @@ class Modelverse(RuntimeClassBase):
     
     def _initialized_behaviour_wait_for_action_modelling_recognized_22_exec(self, parameters):
         self.load_action()
+        print("Load all_instances for " + str(self.parameters))
     
     def _initialized_behaviour_wait_for_action_modelling_recognized_22_guard(self, parameters):
         return self.expect_action('all_instances')
@@ -2419,6 +2428,28 @@ class Modelverse(RuntimeClassBase):
     def _initialized_behaviour_wait_for_action_modelling_recognized_23_guard(self, parameters):
         return self.expect_action('exit_save')
     
+    def _initialized_behaviour_going_manual_0_exec(self, parameters):
+        self.raiseInternalEvent(Event("exception", None, ['UnknownLocation', 'No such location: ' + self.responses.pop(0)]))
+        self.actions.pop(0)
+    
+    def _initialized_behaviour_going_manual_0_guard(self, parameters):
+        return self.expect_response_partial('Location not found: ', pop=False)
+    
+    def _initialized_behaviour_going_manual_1_exec(self, parameters):
+        self.raiseInternalEvent(Event("exception", None, ['ReadPermissionDenied', 'No permission to read model ' + self.responses.pop(0)]))
+        self.actions.pop(0)
+    
+    def _initialized_behaviour_going_manual_1_guard(self, parameters):
+        return self.expect_response_partial('Read permission denied to: ', pop=False)
+    
+    def _initialized_behaviour_going_manual_2_exec(self, parameters):
+        self.raiseInternalEvent(Event("exception", None, ['UnknownMetamodellingHierarchy', 'Conformance relation not found']))
+        self.responses.pop(0)
+        self.actions.pop(0)
+    
+    def _initialized_behaviour_going_manual_2_guard(self, parameters):
+        return self.expect_response_partial('Conformance hierarchy unknown for: ', pop=False)
+    
     def _init_0_exec(self, parameters):
         instance = parameters[0]
         self.http_clients.append(instance)
@@ -3338,6 +3369,9 @@ class Modelverse(RuntimeClassBase):
     def _initialized_behaviour_wait_for_action_modelling_recognized_manual_0_guard(self, parameters):
         return self.expect_action('exit')
     
+    def _initialized_behaviour_wait_for_action_modelling_recognized_manual_1_exec(self, parameters):
+        print("Switching to normal for model " + str(self.actions[0]))
+    
     def _initialized_behaviour_wait_for_action_modelling_recognized_manual_1_guard(self, parameters):
         return self.actions and self.actions[0]['name'] in self.modelling_operations and self.actions[0]['parameters'][0] != self.current_model
     
@@ -3349,6 +3383,7 @@ class Modelverse(RuntimeClassBase):
     
     def _initialized_behaviour_wait_for_action_modelling_recognized_scripted_1_exec(self, parameters):
         self.load_action()
+        print("INTERFACE")
         self.raiseInternalEvent(Event("exception", None, ['InterfaceMismatch', 'Operation cannot be executed in this context']))
     
     def _initialized_behaviour_wait_for_action_modelling_recognized_scripted_1_guard(self, parameters):
@@ -3369,28 +3404,6 @@ class Modelverse(RuntimeClassBase):
     def _initialized_behaviour_going_manual_OK_0_guard(self, parameters):
         return self.expect_response('Model loaded, ready for commands!', pop=True)
     
-    def _initialized_behaviour_going_manual_OK_1_exec(self, parameters):
-        self.raiseInternalEvent(Event("exception", None, ['UnknownLocation', 'No such location: ' + self.responses.pop(0)]))
-        self.actions.pop(0)
-    
-    def _initialized_behaviour_going_manual_OK_1_guard(self, parameters):
-        return self.expect_response_partial('Location not found: ', pop=False)
-    
-    def _initialized_behaviour_going_manual_OK_2_exec(self, parameters):
-        self.raiseInternalEvent(Event("exception", None, ['ReadPermissionDenied', 'No permission to read model ' + self.responses.pop(0)]))
-        self.actions.pop(0)
-    
-    def _initialized_behaviour_going_manual_OK_2_guard(self, parameters):
-        return self.expect_response_partial('Read permission denied to: ', pop=False)
-    
-    def _initialized_behaviour_going_manual_OK_3_exec(self, parameters):
-        self.raiseInternalEvent(Event("exception", None, ['UnknownMetamodellingHierarchy', 'Conformance relation not found']))
-        self.responses.pop(0)
-        self.actions.pop(0)
-    
-    def _initialized_behaviour_going_manual_OK_3_guard(self, parameters):
-        return self.expect_response_partial('Conformance hierarchy unknown for: ', pop=False)
-    
     def _initialized_behaviour_leaving_manual_0_guard(self, parameters):
         return self.expect_response('Success', pop=True)