Browse Source

Fix creating new user

Yentl Van Tendeloo 7 years ago
parent
commit
9c971d6177
2 changed files with 25 additions and 7 deletions
  1. 7 1
      wrappers/classes/modelverse.xml
  2. 18 6
      wrappers/modelverse_SCCD.py

+ 7 - 1
wrappers/classes/modelverse.xml

@@ -168,6 +168,7 @@
                         </raise>
                         <script>
                             self.responses.append(json.loads(data))
+                            #print("Got data: " + str(json.loads(data)))
                         </script>
                     </transition>
 
@@ -275,7 +276,12 @@
                         </state>
 
                         <state id="wait_prompt_existing">
-                            <transition cond="self.expect_response('Please repeat the password', pop=True)" target="."/>
+                            <transition cond="self.expect_response('Please repeat the password', pop=True)" target=".">
+                                <raise event="request">
+                                    <parameter expr="self.parameters[1]"/>
+                                </raise>
+                            </transition>
+                            <transition cond="self.expect_response('Passwords match!', pop=True)" target="."/>
                             <transition cond="self.expect_response('Welcome to the Model Management Interface v2.0!', pop=True)" target="../login_ok"/>
                             <transition cond="self.expect_response('Wrong password!', pop=True)" target="../../../wait_for_action/connected">
                                 <raise event="exception">

+ 18 - 6
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 Oct 31 08:57:11 2017
+Date:   Tue Oct 31 10:44:35 2017
 
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server
@@ -823,18 +823,23 @@ class Modelverse(RuntimeClassBase):
         
         # transition /initialized/behaviour/operations/login/wait_prompt_existing
         _initialized_behaviour_operations_login_wait_prompt_existing_0 = Transition(self, self.states["/initialized/behaviour/operations/login/wait_prompt_existing"], [self.states["/initialized/behaviour/operations/login/wait_prompt_existing"]])
+        _initialized_behaviour_operations_login_wait_prompt_existing_0.setAction(self._initialized_behaviour_operations_login_wait_prompt_existing_0_exec)
         _initialized_behaviour_operations_login_wait_prompt_existing_0.setTrigger(None)
         _initialized_behaviour_operations_login_wait_prompt_existing_0.setGuard(self._initialized_behaviour_operations_login_wait_prompt_existing_0_guard)
         self.states["/initialized/behaviour/operations/login/wait_prompt_existing"].addTransition(_initialized_behaviour_operations_login_wait_prompt_existing_0)
-        _initialized_behaviour_operations_login_wait_prompt_existing_1 = Transition(self, self.states["/initialized/behaviour/operations/login/wait_prompt_existing"], [self.states["/initialized/behaviour/operations/login/login_ok"]])
+        _initialized_behaviour_operations_login_wait_prompt_existing_1 = Transition(self, self.states["/initialized/behaviour/operations/login/wait_prompt_existing"], [self.states["/initialized/behaviour/operations/login/wait_prompt_existing"]])
         _initialized_behaviour_operations_login_wait_prompt_existing_1.setTrigger(None)
         _initialized_behaviour_operations_login_wait_prompt_existing_1.setGuard(self._initialized_behaviour_operations_login_wait_prompt_existing_1_guard)
         self.states["/initialized/behaviour/operations/login/wait_prompt_existing"].addTransition(_initialized_behaviour_operations_login_wait_prompt_existing_1)
-        _initialized_behaviour_operations_login_wait_prompt_existing_2 = Transition(self, self.states["/initialized/behaviour/operations/login/wait_prompt_existing"], [self.states["/initialized/behaviour/wait_for_action/connected"]])
-        _initialized_behaviour_operations_login_wait_prompt_existing_2.setAction(self._initialized_behaviour_operations_login_wait_prompt_existing_2_exec)
+        _initialized_behaviour_operations_login_wait_prompt_existing_2 = Transition(self, self.states["/initialized/behaviour/operations/login/wait_prompt_existing"], [self.states["/initialized/behaviour/operations/login/login_ok"]])
         _initialized_behaviour_operations_login_wait_prompt_existing_2.setTrigger(None)
         _initialized_behaviour_operations_login_wait_prompt_existing_2.setGuard(self._initialized_behaviour_operations_login_wait_prompt_existing_2_guard)
         self.states["/initialized/behaviour/operations/login/wait_prompt_existing"].addTransition(_initialized_behaviour_operations_login_wait_prompt_existing_2)
+        _initialized_behaviour_operations_login_wait_prompt_existing_3 = Transition(self, self.states["/initialized/behaviour/operations/login/wait_prompt_existing"], [self.states["/initialized/behaviour/wait_for_action/connected"]])
+        _initialized_behaviour_operations_login_wait_prompt_existing_3.setAction(self._initialized_behaviour_operations_login_wait_prompt_existing_3_exec)
+        _initialized_behaviour_operations_login_wait_prompt_existing_3.setTrigger(None)
+        _initialized_behaviour_operations_login_wait_prompt_existing_3.setGuard(self._initialized_behaviour_operations_login_wait_prompt_existing_3_guard)
+        self.states["/initialized/behaviour/operations/login/wait_prompt_existing"].addTransition(_initialized_behaviour_operations_login_wait_prompt_existing_3)
         
         # transition /initialized/behaviour/operations/login/login_ok
         _initialized_behaviour_operations_login_login_ok_0 = Transition(self, self.states["/initialized/behaviour/operations/login/login_ok"], [self.states["/initialized/behaviour/wait_for_action/megamodelling"]])
@@ -2357,6 +2362,7 @@ class Modelverse(RuntimeClassBase):
         data = parameters[0]
         self.big_step.outputEventOM(Event("narrow_cast", None, [self, self.http_clients[1], Event("HTTP_input", None, [urllib.urlencode({"op": "get_output", "taskname": self.taskname}), "parent"])]))
         self.responses.append(json.loads(data))
+        #print("Got data: " + str(json.loads(data)))
     
     def _initialized_http_mapper_init_3_guard(self, parameters):
         data = parameters[0]
@@ -2412,16 +2418,22 @@ class Modelverse(RuntimeClassBase):
     def _initialized_behaviour_operations_login_wait_prompt_2_1_guard(self, parameters):
         return self.expect_response('This is a new user: please give password!', pop=True)
     
+    def _initialized_behaviour_operations_login_wait_prompt_existing_0_exec(self, parameters):
+        self.raiseInternalEvent(Event("request", None, [self.parameters[1]]))
+    
     def _initialized_behaviour_operations_login_wait_prompt_existing_0_guard(self, parameters):
         return self.expect_response('Please repeat the password', pop=True)
     
     def _initialized_behaviour_operations_login_wait_prompt_existing_1_guard(self, parameters):
+        return self.expect_response('Passwords match!', pop=True)
+    
+    def _initialized_behaviour_operations_login_wait_prompt_existing_2_guard(self, parameters):
         return self.expect_response('Welcome to the Model Management Interface v2.0!', pop=True)
     
-    def _initialized_behaviour_operations_login_wait_prompt_existing_2_exec(self, parameters):
+    def _initialized_behaviour_operations_login_wait_prompt_existing_3_exec(self, parameters):
         self.raiseInternalEvent(Event("exception", None, ['PermissionDenied', 'Permission denied!']))
     
-    def _initialized_behaviour_operations_login_wait_prompt_existing_2_guard(self, parameters):
+    def _initialized_behaviour_operations_login_wait_prompt_existing_3_guard(self, parameters):
         return self.expect_response('Wrong password!', pop=True)
     
     def _initialized_behaviour_operations_login_login_ok_0_exec(self, parameters):