Sfoglia il codice sorgente

Refactory métodos de workflow en entidades ONU y OLT. Update vendor ik/workflow-bundle

Guillermo Espinoza 7 anni fa
parent
commit
d270282bfa
3 ha cambiato i file con 27 aggiunte e 240 eliminazioni
  1. 2 2
      composer.lock
  2. 15 128
      src/FTTHBundle/Entity/OLT.php
  3. 10 110
      src/FTTHBundle/Entity/ONU.php

+ 2 - 2
composer.lock

@@ -1653,7 +1653,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/WorkflowBundle.git",
-                "reference": "0fc2cbf6e746cffe2c55025ea8054836ec096a54"
+                "reference": "4de74f50d761828334eb9709d4e23ee145a28c6f"
             },
             "require": {
                 "php-amqplib/rabbitmq-bundle": "^1.12"
@@ -1683,7 +1683,7 @@
                 "bundle",
                 "workflow"
             ],
-            "time": "2017-08-04 14:29:28"
+            "time": "2017-09-05 13:41:17"
         },
         {
             "name": "incenteev/composer-parameter-handler",

+ 15 - 128
src/FTTHBundle/Entity/OLT.php

@@ -13,6 +13,8 @@ use DeviceBundle\Validator\Constraints as ValidatorAssert;
 use DeviceBundle\Interfaces\DeviceInterface;
 use MapBundle\Entity\Interfaces\LocationInterface;
 use MapBundle\Entity\Traits\LocationTrait;
+use WorkflowBundle\Entity\Interfaces\WorkflowInterface;
+use WorkflowBundle\Entity\Traits\WorkflowTrait;
 
 /**
  * @ORM\Entity
@@ -20,13 +22,14 @@ use MapBundle\Entity\Traits\LocationTrait;
  * 
  * @ValidatorAssert\Device
  */
-class OLT implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
+class OLT implements DeviceInterface, TenancyIdTraitInterface, LocationInterface, WorkflowInterface
 {
 
     use ExtraDataTrait;
     use TenancyIdTrait;
     use LocationTrait;
-    
+    use WorkflowTrait;
+
     /**
      * @var bigint $id
      *
@@ -120,17 +123,18 @@ class OLT implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
      * @ORM\Column(type="integer", options={"unsigned":true, "default":5})
      */
     protected $timeOltOctets = 5;
-    
+
     /**
      * @ORM\Column(type="integer", options={"unsigned":true, "default":5})
      */
     protected $timePonStats = 5;
-    
+
     /**
      * @ORM\Column(type="integer", options={"unsigned":true, "default":5})
      */
     protected $timeOnuStats = 5;
-    
+
+
     /**
      * @return string
      */
@@ -291,47 +295,6 @@ class OLT implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
         return $this;
     }
 
-    /**
-     * @return Workflow
-     */
-    public function getWorkflow()
-    {
-        return $this->workflow;
-    }
-
-    /**
-     * @param Workflow $workflow
-     * @return $this
-     */
-    public function setWorkflow($workflow)
-    {
-        $this->workflow = $workflow;
-
-        return $this;
-    }
-
-    public function getWorkflowType()
-    {
-        $workflow = $this->getWorkflow();
-
-        if ($workflow) {
-            return $workflow->getType();
-        }
-
-        return null;
-    }
-
-    public function getWorkflowName()
-    {
-        $workflow = $this->getWorkflow();
-
-        if ($workflow) {
-            return $workflow->getName();
-        }
-
-        return null;
-    }
-
     /* Va a quedar deprecate */
 
     public function getWorkflowObject()
@@ -346,73 +309,6 @@ class OLT implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
         return $this->workflow;
     }
 
-    /**
-     * Get currentState
-     *
-     */
-    public function getCurrentState()
-    {
-        return $this->currentState;
-    }
-
-    /**
-     * Set currentState
-     *
-     */
-    public function setCurrentState($currentState)
-    {
-        $this->currentState = $currentState;
-
-        return $this;
-    }
-
-    /**
-     * Get transitionState
-     *
-     */
-    public function getTransitionState()
-    {
-        return $this->transitionState;
-    }
-
-    /**
-     * Set transitionState
-     *
-     */
-    public function setTransitionState($transitionState)
-    {
-        $this->transitionState = $transitionState;
-
-        return $this;
-    }
-
-    public function getTransitionWorkflow()
-    {
-        return "transition_state";
-    }
-
-    // Para coincider entre estos workflow servidos por servicio y aquellos levantados por ABM
-    public function getServiceWorkflow()
-    {
-        global $kernel;
-        $registry = $kernel->getContainer()->get('workflow.registry');
-
-        $workflow_name = null;
-        $workflow = $this->getWorkflow();
-        if ($workflow) {
-            $workflow_name = $workflow->getName();
-        }
-
-        try {
-            $workflow = $registry->get($this, $workflow_name);
-        } catch (ExceptionInterface $e) {
-            $kernel->getContainer()->get('session')->getFlashBag()->add('danger', $kernel->getContainer()->get('translator')->trans('Incorrect Workflow', array(), 'FTTHBundle'));
-            return null;
-        }
-
-        return $workflow;
-    }
-
     /**
      * @return array
      */
@@ -426,9 +322,9 @@ class OLT implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
         $deviceData['tenancy'] = $this->tenancyId;
 
         $deviceExtraData = array('snmpCommunity' => $this->snmpCommunity, 'sshUser' => $this->sshUser, 'sshPass' => $this->sshPass,
-                                 'libraryVersion' => $this->libraryVersion, 'name' => $this->name);
+            'libraryVersion' => $this->libraryVersion, 'name' => $this->name);
 
-        if($this->model) {
+        if ($this->model) {
             $model = $this->getModel();
             $deviceExtraData['modelId'] = $model->getId();
             $deviceExtraData['mark'] = $model->getMark();
@@ -438,7 +334,7 @@ class OLT implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
             $deviceExtraData['mark'] = null;
             $deviceExtraData['library'] = null;
         }
-        
+
         $deviceExtraData['executeSnmp'] = $this->executeSnmp;
         $deviceExtraData['timeScan'] = $this->timeScan;
         $deviceExtraData['timeOnuStats'] = $this->timeOnuStats;
@@ -448,13 +344,6 @@ class OLT implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
         $deviceData['extraData'] = json_encode($deviceExtraData);
 
         return $deviceData;
-        
-        
-        /*return array(
-            'deviceType' => get_class($this),
-            'deviceId' => $this->id,
-            'ip' => $this->ip,
-        );*/
     }
 
     /**
@@ -498,7 +387,7 @@ class OLT implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
     {
         return $this->timeScan;
     }
-    
+
     /**
      * Set timeOltOctets
      *
@@ -518,7 +407,7 @@ class OLT implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
     {
         return $this->timeOltOctets;
     }
-    
+
     /**
      * Set timeOnuStats
      *
@@ -538,7 +427,7 @@ class OLT implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
     {
         return $this->timeOnuStats;
     }
-    
+
     /**
      * Set timePonStats
      *
@@ -558,7 +447,5 @@ class OLT implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
     {
         return $this->timePonStats;
     }
-    
-    
 
 }

+ 10 - 110
src/FTTHBundle/Entity/ONU.php

@@ -16,6 +16,8 @@ use DeviceBundle\Interfaces\DeviceInterface;
 use JMS\Serializer\Annotation as JMS;
 use MapBundle\Entity\Interfaces\LocationInterface;
 use MapBundle\Entity\Traits\LocationTrait;
+use WorkflowBundle\Entity\Interfaces\WorkflowInterface;
+use WorkflowBundle\Entity\Traits\WorkflowTrait;
 
 /**
  * ONU
@@ -27,13 +29,14 @@ use MapBundle\Entity\Traits\LocationTrait;
  *
  * @ValidatorAssert\Device
  */
-class ONU implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
+class ONU implements DeviceInterface, TenancyIdTraitInterface, LocationInterface, WorkflowInterface
 {
 
     use ExtraDataTrait;
     use TenancyIdTrait;
     use LocationTrait;
-    
+    use WorkflowTrait;
+
     /**
      * @var int
      *
@@ -154,7 +157,7 @@ class ONU implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
      */
     public function __toString()
     {
-        return (string)$this->ponSerialNumber;
+        return (string) $this->ponSerialNumber;
     }
 
     /**
@@ -307,26 +310,6 @@ class ONU implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
         return $this->updated;
     }
 
-    /**
-     * Get currentState
-     *
-     */
-    public function getCurrentState()
-    {
-        return $this->currentState;
-    }
-
-    /**
-     * Set currentState
-     *
-     */
-    public function setCurrentState($currentState)
-    {
-        $this->currentState = $currentState;
-
-        return $this;
-    }
-
     /**
      * Get administrativeState
      *
@@ -347,26 +330,6 @@ class ONU implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
         return $this;
     }
 
-    /**
-     * Get transitionState
-     *
-     */
-    public function getTransitionState()
-    {
-        return $this->transitionState;
-    }
-
-    /**
-     * Set transitionState
-     *
-     */
-    public function setTransitionState($transitionState)
-    {
-        $this->transitionState = $transitionState;
-
-        return $this;
-    }
-
     /**
      * @return OLT
      */
@@ -443,48 +406,12 @@ class ONU implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
 
         return $this;
     }
-
-    /**
-     * @return Workflow
-     */
-    public function getWorkflow()
-    {
-        return $this->workflow;
-    }
-
+    
     /**
-     * @param Workflow $workflow
-     * @return $this
+     * @global AppKernel $kernel
+     * 
+     * @return string
      */
-    public function setWorkflow($workflow)
-    {
-        $this->workflow = $workflow;
-
-        return $this;
-    }
-
-    public function getWorkflowType()
-    {
-        $workflow = $this->getWorkflow();
-
-        if ($workflow) {
-            return $workflow->getType();
-        }
-
-        return null;
-    }
-
-    public function getWorkflowName()
-    {
-        $workflow = $this->getWorkflow();
-
-        if ($workflow) {
-            return $workflow->getName();
-        }
-
-        return null;
-    }
-
     public function getLog()
     {
         global $kernel;
@@ -523,33 +450,6 @@ class ONU implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
         return "administrative_state";
     }
 
-    public function getTransitionWorkflow()
-    {
-        return "transition_state";
-    }
-
-    // Para coincider entre estos workflow servidos por servicio y aquellos levantados por ABM
-    public function getServiceWorkflow()
-    {
-        global $kernel;
-        $registry = $kernel->getContainer()->get('workflow.registry');
-
-        $workflow_name = null;
-        $workflow = $this->getWorkflow();
-        if ($workflow) {
-            $workflow_name = $workflow->getName();
-        }
-
-        try {
-            $workflow = $registry->get($this, $workflow_name);
-        } catch (ExceptionInterface $e) {
-            $kernel->getContainer()->get('session')->getFlashBag()->add('danger', $kernel->getContainer()->get('translator')->trans('Incorrect Workflow', array(), 'FTTHBundle'));
-            return null;
-        }
-
-        return $workflow;
-    }
-
     /**
      * Get getPosition
      *