Browse Source

FD3-790 cablemodem administrative_workflow updated. vendors updated.

Guillermo Espinoza 6 years ago
parent
commit
57b3b8be8b

+ 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'

+ 7 - 7
composer.lock

@@ -103,7 +103,7 @@
                     "homepage": "https://florian.ec"
                 }
             ],
-            "description": "Converts a string into a slug",
+            "description": "Converts a string into a slug.",
             "keywords": [
                 "slug",
                 "slugify"
@@ -1458,7 +1458,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/BaseAdmin.git",
-                "reference": "d0c7faf0c4a016856eb800ab2fb75786213b27e5"
+                "reference": "767b0aad4bd83c5677f69a8bb860793942c90f10"
             },
             "type": "library",
             "autoload": {
@@ -1473,7 +1473,7 @@
                 "bootstrap",
                 "sonata"
             ],
-            "time": "2018-12-06T11:38:28+00:00"
+            "time": "2019-01-09T17:58:40+00:00"
         },
         {
             "name": "ik/check-sintax-bundle",
@@ -1693,7 +1693,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/Webservice.git",
-                "reference": "bb39029da4924cc7c800717b5e7c799dc38aafb0"
+                "reference": "99d58259071e639cf59760e96a5063c98b5e7a43"
             },
             "require": {
                 "ext-curl": "*",
@@ -1706,7 +1706,7 @@
                 }
             },
             "description": "The Flowdat3 Webservice Rest",
-            "time": "2018-12-18T17:41:41+00:00"
+            "time": "2019-01-11T18:05:23+00:00"
         },
         {
             "name": "ik/workflow-bundle",
@@ -1714,7 +1714,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/WorkflowBundle.git",
-                "reference": "3b16291fcaf4d9aebca3a2a0914de310a28768b4"
+                "reference": "c56c95f3145caf7965392a711efaee0643329383"
             },
             "require": {
                 "php-amqplib/rabbitmq-bundle": "^1.12"
@@ -1744,7 +1744,7 @@
                 "bundle",
                 "workflow"
             ],
-            "time": "2018-12-10T15:23:26+00:00"
+            "time": "2019-01-11T18:20:57+00:00"
         },
         {
             "name": "incenteev/composer-parameter-handler",

+ 1 - 1
src/CablemodemBundle/Command/DHCPHostCRUDCommand.php

@@ -167,7 +167,7 @@ EOT
         $data = [
             'mac' => $this->mac,
             'hostType' => $this->getIdHostType($type),
-            'state' => 'active',
+            'state' => $this->cablemodem->getAdministrativeState(),
             'fixed_address' => $fixedIP ?: null,
             'fixedIP' => $fixedIP ? true : false,
             'mtaEnabled' => $this->cablemodem->getMtaEnabled(),

+ 66 - 3
src/CablemodemBundle/Controller/REST/CablemodemRESTController.php

@@ -20,7 +20,7 @@ use FOS\RestBundle\Controller\Annotations\Get;
  */
 class CablemodemRESTController extends RESTController
 {
-    
+
     /**
      * @return string Retorna el nombre de la Entity de trabajo.
      */
@@ -36,7 +36,7 @@ class CablemodemRESTController extends RESTController
     {
         return get_class(new CablemodemType());
     }
-    
+
     /**
      * GET Route annotation.
      * @Get("/cablemodem/{id}/apply/{workflow}/{transition}")
@@ -44,8 +44,8 @@ class CablemodemRESTController extends RESTController
      *
      * @param Request $request
      * @param $id
-     * @param $transition
      * @param $workflow
+     * @param $transition
      *
      * @return Response
      */
@@ -68,15 +68,78 @@ class CablemodemRESTController extends RESTController
             if (count($errors) > 0) {
                 $errorsString = (string) $errors;
                 $tenancyService->enableFilter();
+
                 return FOSView::create($errorsString, Codes::HTTP_INTERNAL_SERVER_ERROR);
             } else {
                 $em->persist($entity);
                 $em->flush($entity);
                 $tenancyService->enableFilter();
+
                 return $entity;
             }
         } catch (\Exception $e) {
             return FOSView::create($e->getMessage(), Codes::HTTP_INTERNAL_SERVER_ERROR);
         }
     }
+
+
+    /**
+     * GET Route annotation.
+     * @Get("/client/{id}/apply/{transition}")
+     * @View(statusCode=201, serializerEnableMaxDepthChecks=true)
+     *
+     * @param Request $request
+     * @param $id
+     * @param $transition
+     *
+     * @return Response
+     */
+    public function clientAction(Request $request, Int $id, String $transition)
+    {
+        try {
+            $tenancyService = $this->getTenancyService();
+            $tenancyService->disableFilter();
+
+            $em = $this->container->get("doctrine.orm.entity_manager");
+
+            $query = $em->createQuery("
+                SELECT cm FROM CablemodemBundle:Cablemodem cm
+                WHERE cm.administrativeState != :transition
+                AND cm.clientId = :client
+            ")->setParameters([
+                'transition' => $transition,
+                'client' => $id,
+            ]);
+            $cablemodems = $query->getResult();
+
+            $tenancyService->enableFilter();
+
+            $cmd_args = [
+                'entity' => '--entity:CablemodemBundle\\Entity\\Cablemodem',
+                'workflow' => '--workflow:administrative_state',
+                'transition' => "--transition:{$transition}",
+            ];
+
+            $macs = [];
+            if ($cablemodems) {
+                foreach ($cablemodems as $cablemodem) {
+                    $cablemodemId = $cablemodem->getId();
+                    $cmd_args['id'] = "--id:{$cablemodemId}";
+                    $macs[$cablemodemId] = $cablemodem->getMac();
+
+                    $this->runCommand('workflow:apply', $cmd_args);
+                }
+            }
+
+            return array(
+                'client' => $id,
+                'transition' => $transition,
+                'count' => count($cablemodems),
+                'cablemodems' => $macs,
+            );
+        } catch (\Exception $e) {
+            return FOSView::create($e->getMessage(), Codes::HTTP_INTERNAL_SERVER_ERROR);
+        }
+    }
+
 }

+ 1 - 1
src/CablemodemBundle/Resources/views/CRUD/host_show_field.html.twig

@@ -23,7 +23,7 @@
             <th>{{ 'HostType'|trans({}, 'CablemodemBundle') }}</th><td>{{ host.hostType.name }}</td>
         </tr>
         <tr class="sonata-ba-view-container">
-            <th>{{ 'State'|trans({}, 'CablemodemBundle') }}</th><td>{{ host.state|trans({}, 'CablemodemBundle') }}</td>
+            <th>{{ 'State'|trans({}, 'CablemodemBundle') }}</th><td>{{ host.state|trans({}, 'WorkflowLabel') }}</td>
         </tr>
         {% if host.options %}
         <tr class="sonata-ba-view-container">