Selaa lähdekoodia

workflow administrative_state updated. Update onu status by client status. Related to https://gitlab.com/interlink-sa/flowdat3/modules/base/issues/13

Guillermo Espinoza 6 vuotta sitten
vanhempi
commit
dc7ccfb8bd
2 muutettua tiedostoa jossa 35 lisäystä ja 24 poistoa
  1. 18 16
      app/config/workflow.yml
  2. 17 8
      src/FTTHBundle/Controller/REST/ONURESTController.php

+ 18 - 16
app/config/workflow.yml

@@ -12,25 +12,27 @@ framework:
                 - active
                 - pre_notice
                 - suspend
+                - cancelled
+                - not_provisioned
                 - deleted
             transitions:
-                active_to_pre_notice:
-                    from: active
-                    to:   pre_notice
-                active_to_suspend:
-                    from: active
-                    to:   suspend
-                pre_notice_to_active:
-                    from: pre_notice
-                    to:   active
-                pre_notice_to_suspend:
-                    from: pre_notice
-                    to:   suspend
-                suspend_to_active:
-                    from: suspend
-                    to:   active 
+                active:
+                    from: [pre_notice,suspend,cancelled,not_provisioned,deleted]
+                    to: active
+                pre_notice:
+                    from: [active,suspend,cancelled,not_provisioned,deleted]
+                    to: pre_notice
+                suspend:
+                    from: [active,pre_notice,cancelled,not_provisioned,deleted]
+                    to: suspend
+                cancel:
+                    from: [active,pre_notice,suspend,not_provisioned,deleted]
+                    to: cancelled
+                not_provisioned:
+                    from: [active,pre_notice,suspend,cancelled,deleted]
+                    to: not_provisioned
                 delete:
-                    from: [active,suspend,pre_notice]
+                    from: [active,suspend,pre_notice,cancelled,not_provisioned]
                     to:   deleted
         transition_state:
             type: 'state_machine'

+ 17 - 8
src/FTTHBundle/Controller/REST/ONURESTController.php

@@ -137,24 +137,33 @@ class ONURESTController extends RESTController
     {
         try {
             $tenancyService = $this->getTenancyService();
+            $tenancyService->disableFilter();
+
             $em = $this->container->get("doctrine.orm.entity_manager");
 
-            $tenancyService->disableFilter();
-            $query = $em->createQuery('SELECT o FROM FTTHBundle:ONU o WHERE o.currentState != :transition AND o.clientId = :client')->setParameter('transition', $transition)->setParameter('client', $id);
+            $query = $em->createQuery("
+                SELECT o FROM FTTHBundle:ONU o
+                WHERE o.administrativeState != :transition
+                AND o.clientId = :client
+            ")->setParameters([
+                'transition' => $transition,
+                'client' => $id,
+            ]);
             $onus = $query->getResult();
-            $tenancyService->enableFilter();
 
-            $cmd_args = array();
-            $cmd_args['entity'] = '--entity:FTTHBundle\\Entity\\ONU';
-            $cmd_args['transition'] = "--transition:{$transition}";
+            $tenancyService->enableFilter();
+            
+            $cmd_args = [
+                'entity' => '--entity:FTTHBundle\\Entity\\ONU',
+                'workflow' => '--workflow:administrative_state',
+                'transition' => "--transition:{$transition}",
+            ];
 
             $serialNumbers = array();
             if ($onus) {
                 foreach ($onus as $onu) {
                     $onuId = $onu->getId();
                     $cmd_args['id'] = "--id:{$onuId}";
-                    $workflowName = $onu->getWorkflow()->getName();
-                    $cmd_args['workflow'] = "--workflow:{$workflowName}";
                     $serialNumbers[$onuId] = $onu->getPonSerialNumber();
 
                     $this->runCommand('workflow:apply', $cmd_args);